templates
This commit is contained in:
@@ -3,6 +3,21 @@
|
||||
<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>
|
||||
@@ -78,4 +93,45 @@
|
||||
$('.save').trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
$('#training_templates').on('change', function(e) {
|
||||
let selectedTemplate = $('#training_templates option:selected').val();
|
||||
console.log(selectedTemplate);
|
||||
$.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_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']);
|
||||
if (null != pdata['tt_duration']) $('#tr_duration').val(pdata['tt_duration']);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user