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

101 lines
2.8 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);
$('#product_name').val(data.product_name);
$('#product_nominal').val(znNumFormat(data.product_nominal));
$('#rank').val(data.rank);
$('#product_group_id').val(data.product_group_id).trigger('change.select2');
$('#is_active').val(data.is_active);
$('#formData').data('bootstrapValidator').validate();
})
}
//VALIDASI
$(document).ready(function () {
$("#formData").bootstrapValidator({
excluded: [':disabled'],
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
product_name: {
validators: {
notEmpty: {
message: 'Tidak Boleh Kosong'
},
stringLength: {
max:200,
message: 'Maksimal 200 Karakter'
}
}
},
product_nominal: {
validators: {
notEmpty: {
message: 'Tidak Boleh Kosong'
},
stringLength: {
min: 4,
max:10,
message: 'Nominal Minimal 1000 dan Maksimal 99.999.999'
}
}
},
rank: {
validators: {
notEmpty: {
message: 'Tidak Boleh Kosong'
}
}
},
product_group: {
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();
});
});
</script>