109 lines
2.9 KiB
PHP
109 lines
2.9 KiB
PHP
<script>
|
|
// INIT FORM
|
|
function clearForm() {
|
|
$('#mForm_title').html(`Tambah Data`);
|
|
$('#mForm_subTitle').html(`Tambah Data `+title);
|
|
$('#get_id').val('');
|
|
$("#formData")[0].reset();
|
|
$('#formData').bootstrapValidator("resetForm",true);
|
|
reInitForm();
|
|
}
|
|
|
|
function edit(id) {
|
|
clearForm();
|
|
$('#mForm').modal('show');
|
|
znLoadingModal('mForm');
|
|
$('#mForm_title').html(`Edit Data`);
|
|
$('#mForm_subTitle').html(`Edit Data `+title);
|
|
|
|
let formData = new FormData();
|
|
formData.append('id',id);
|
|
doPost(routeEdit, formData, function (msg, res) {
|
|
console.log(res);
|
|
znLoadingModalEnd('mForm');
|
|
var data = res.data;
|
|
$('#get_id').val(data.id);
|
|
$('#description').val(data.description);
|
|
$('#is_active').val(data.is_active);
|
|
|
|
$('#formData').data('bootstrapValidator').validate();
|
|
})
|
|
}
|
|
|
|
|
|
function getTable() {
|
|
let startDate = $('#berkala_startDate').val();
|
|
let endDate = $('#berkala_endDate').val();
|
|
let merchant = $('#merchant_filter').val();
|
|
|
|
if (userRole == '2') {
|
|
merchant = userMID;
|
|
}
|
|
|
|
table.ajax.url(routeTable+'&startDate='+startDate+'&endDate='+endDate+'&merchant='+merchant).load();
|
|
}
|
|
|
|
//VALIDASI
|
|
$(document).ready(function () {
|
|
|
|
$('.select2').select2({
|
|
placeholder: "Silahkan Pilih"
|
|
});
|
|
|
|
$('#berkala_startDate').datepicker({
|
|
rtl: KTUtil.isRTL(),
|
|
orientation: "bottom left",
|
|
todayHighlight: false,
|
|
format: 'dd-mm-yyyy',
|
|
autoclose: true,
|
|
}).on('changeDate', function (selected) {
|
|
var minDate = new Date(selected.date.valueOf());
|
|
$('#berkala_endDate').datepicker('setStartDate', minDate);
|
|
$("#berkala_endDate").datepicker().datepicker("setDate", minDate);
|
|
});
|
|
|
|
$(".znDate").inputmask("99-99-9999", {
|
|
"placeholder": "dd-mm-yyyy"
|
|
});
|
|
|
|
$('#berkala_endDate').datepicker({
|
|
rtl: KTUtil.isRTL(),
|
|
orientation: "bottom left",
|
|
todayHighlight: false,
|
|
format: 'dd-mm-yyyy',
|
|
autoclose: true,
|
|
});
|
|
|
|
$("#formData").bootstrapValidator({
|
|
excluded: [':disabled'],
|
|
feedbackIcons: {
|
|
valid: 'glyphicon glyphicon-ok',
|
|
invalid: 'glyphicon glyphicon-remove',
|
|
validating: 'glyphicon glyphicon-refresh'
|
|
},
|
|
fields: {
|
|
description: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Tidak Boleh Kosong'
|
|
},
|
|
stringLength: {
|
|
max:50,
|
|
message: 'Maksimal 50 Karakter'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}).on('success.field.bv', function (e, data) {
|
|
var $parent = data.element.parents('.form-group');
|
|
$parent.removeClass('has-success');
|
|
$parent.find('.form-control-feedback[data-bv-icon-for="' + data.field + '"]').hide();
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|