pos-gis/resources/views/content/ref/device/action.blade.php
2024-10-07 13:13:42 +07:00

143 lines
4.0 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.device_id);
$('#sn').val(data.sn);
$('#imei').val(data.imei)
$('#model').val(data.model);
$('#tid').val(data.tid);
$('#imei').val(data.imei);
$('#mid').val(data.mid).trigger('change.select2');
$('#brand').val(data.brand).trigger('change.select2');
$('#formData').data('bootstrapValidator').validate();
})
}
function getTable() {
let merchant = $('#merchant_filter').val();
table.ajax.url(routeTable+'&merchant='+merchant).load();
}
//VALIDASI
$(document).ready(function () {
$('.select2').select2({
placeholder: "Silahkan Pilih"
});
$("#formData").bootstrapValidator({
excluded: [':disabled'],
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
sn: {
validators: {
notEmpty: {
message: 'Tidak Boleh Kosong'
}
}
},
imei: {
validators: {
notEmpty: {
message: 'Tidak Boleh Kosong'
}
}
},
brand: {
validators: {
notEmpty: {
message: 'Tidak Boleh Kosong'
}
}
},
model: {
validators: {
notEmpty: {
message: 'Tidak Boleh Kosong'
}
}
},
tid: {
validators: {
notEmpty: {
message: 'Tidak Boleh Kosong'
}
}
},
// mid: {
// validators: {
// notEmpty: {
// message: 'Tidak Boleh Kosong'
// }
// }
// }
}
}).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();
});
$("#formDataExcel").bootstrapValidator({
excluded: [':disabled'],
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
xls_file: {
validators: {
notEmpty: {
message: 'Tidak Boleh Kosong'
},
file: {
extension: 'xlsx,xls',
type: 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
message: 'Format yang diperbolehkan Hanya .xlsx, .xls'
}
}
},
}
}).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>