Files
code-cegled/template/templates/training_data_create.tpl
2019-08-26 16:16:55 +02:00

168 lines
5.9 KiB
Smarty

<div class="form_wrapper">
<form method="post" id="training-create">
<input type="hidden" name="action" id="action" value="training_data_create">
<input type="hidden" name="jumpTo" id="jumpTo" value="0">
<div>
<label class="desc" for="training_templates">Sablon:</label>
<div>
<select name="training_templates" id="training_templates">
<option value="null"> - </option>
{foreach $training_templates as $template}
<option value="{$template.tt_id}">
{$template.tt_name}
</option>
{/foreach}
</select>
</div>
</div>
<br><br>
<div>
<label class="desc" id="title1" for="tr_date">Dátum:</label>
<div><input type="text" name="tr_date" id="tr_date" title="ÉÉÉÉ-HH-NN ÓÓ:PP" placeholder="ÉÉÉÉ-HH-NN ÓÓ:PP" required></div>
</div>
<div>
<label class="desc" id="title2" for="tr_training_type_trt_id">Típus:</label>
<div>
<select name="tr_training_type_trt_id" id="tr_training_type_trt_id">
<option value="null"> - </option>
{foreach $training_type_assoc_array as $training_type_array}
<option value="{$training_type_array.trt_id}">
{$training_type_array.trt_name}
</option>
{/foreach}
</select>
</div>
</div>
<div>
<label class="desc" id="title1" for="tr_duration">Időtartam (perc):</label>
<div><input type="text" name="tr_duration" id="tr_duration" required></div>
</div>
<div>
<label class="desc" for="tr_price">Ár:</label>
<div><input type="text" name="tr_price" id="tr_price" required></div>
</div>
<div>
<label class="desc" id="title1" for="every_week">Minden héten ebben az időpontban: (az adott hónapban)</label>
<div><input type="checkbox" name="every_week" id="every_week" value="1"></div>
</div>
<div>
<label class="desc" for="tr_note">Megjegyzés:</label>
<div>
<textarea rows="4" name="tr_note" id="tr_note"></textarea>
</div>
</div>
<div>
<label class="desc" id="title1" for="coaches">Edző(k):</label>
<table>
<tr>
<td class="bold">Név</td>
<td class="bold center">E</td>
<td class="bold center">SE</td>
</tr>
{foreach $coach_array as $coach}
<tr>
<td class="coach">{$coach->get_ua_name()}</td>
<td><input type="checkbox" name="coaches[]" value="{$coach->get_ua_id()}" class="coach_type"></td>
<td><input type="checkbox" name="helpers[]" value="{$coach->get_ua_id()}" class="coach_type"></td>
</tr>
{/foreach}
</table>
</div>
<div>
<div>
<input class="button black save" type="submit" value="Létrehozás">
<input class="button black jump-to" type="button" value="Létrehozás és ugrás a jelenléthez">
</div>
</div>
</form>
</div>
<script type="text/javascript">
$('.jump-to').click(function () {
$('#jumpTo').val(1);
if ($('#tr_date').val().length && $('#tr_training_type_trt_id').val() != 'null' && $('#tr_duration').val().length) {
//$('#training-create').submit();
$('.save').trigger('click');
}
});
$('#training_templates').on('change', function(e) {
let selectedTemplate = $('#training_templates option:selected').val();
$.ajax({
url: '/_ajax/get_training_template.php',
//method: 'GET',
data: {
'template_id' : selectedTemplate
},
success: function(data, status, jqXHR) {
var pdata = JSON.parse(data);
if (null == pdata) {
$('#tr_date').val('');
$('#tr_training_type_trt_id').val('null');
$('#tr_training_type_trt_id').trigger('change');
$('#tr_duration').val('');
return;
}
console.log(pdata);
var d = new Date();
var month = d.getMonth()+1;
var day = d.getDate();
var output = d.getFullYear() + '-' +
((''+month).length<2 ? '0' : '') + month + '-' +
((''+day).length<2 ? '0' : '') + day;
if (null != pdata['tt_time']) $('#tr_date').val(output + ' ' + pdata['tt_time']);
if (null != pdata['tt_training_type']) {
$('#tr_training_type_trt_id').val(pdata['tt_training_type']);
$('#tr_training_type_trt_id').trigger('change');
}
if (null != pdata['tt_duration']) $('#tr_duration').val(pdata['tt_duration']);
}
});
});
$('#tr_training_type_trt_id').on('change', function(e) {
//get trt default price by ajax
let selectedType = $('#tr_training_type_trt_id option:selected').val();
$.ajax({
url: '/_ajax/get_trt_default_price.php',
//method: 'GET',
data: {
'trt_id' : selectedType
},
success: function(data, status, jqXHR) {
let pdata = JSON.parse(data);
//console.log(pdata);
if (null === pdata) {
$('#tr_price').val('');
return;
}
$('#tr_price').val(pdata);
}
});
});
</script>