229 lines
7.9 KiB
PHP
229 lines
7.9 KiB
PHP
<script>
|
|
var routeTable,
|
|
colum,
|
|
columnStyle,
|
|
table,
|
|
validation,
|
|
validation_ba;
|
|
$(document).ready(function() {
|
|
$('#project_name_head').attr('readonly', true)
|
|
$('#budget_head').attr('readonly', true)
|
|
$('#budget_terpakai_head').attr('readonly', true)
|
|
$('#sisa_budget_head').attr('readonly', true)
|
|
|
|
routeTable = '{{ $table }}';
|
|
colum = [
|
|
{data: 'DT_RowIndex', name: 'DT_RowIndex'},
|
|
{data: 'tx_date', name: 'tx_date'},
|
|
{data: 'budget_name', name: 'budget_name'},
|
|
{data: 'tx_type', name: 'tx_type'},
|
|
{data: 'tx_note', name: 'tx_note'},
|
|
{data: 'amount_tx', name: 'amount_tx'},
|
|
{data: 'outstanding', name: 'outstanding'},
|
|
{data: 'action', name: 'action'},
|
|
];
|
|
|
|
columStyle =
|
|
[
|
|
{ "orderable": false, "targets": [-1] },
|
|
];
|
|
|
|
table = znGetTableScrolling(routeTable,colum,columStyle,'indexTable');
|
|
|
|
validation = FormValidation.formValidation(
|
|
KTUtil.getById('form_budget'),
|
|
{
|
|
fields: {
|
|
tx_date: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
budget_type: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
tx_type: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
amount_tx: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
tx_note: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
},
|
|
plugins: {
|
|
trigger: new FormValidation.plugins.Trigger(),
|
|
bootstrap: new FormValidation.plugins.Bootstrap()
|
|
}
|
|
}
|
|
);
|
|
|
|
validation_ba = FormValidation.formValidation(
|
|
KTUtil.getById('form_budget_awal'),
|
|
{
|
|
fields: {
|
|
amount_tx_ba: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
},
|
|
plugins: {
|
|
trigger: new FormValidation.plugins.Trigger(),
|
|
bootstrap: new FormValidation.plugins.Bootstrap()
|
|
}
|
|
}
|
|
);
|
|
|
|
$('#budget_type').on('select2:select', function (e) {
|
|
var data = e.params.data.element;
|
|
var txtype = $(data).data('txtype');
|
|
var operator = $(data).data('operator');
|
|
$('#tx_type').val(txtype);
|
|
$('#operator').val(operator);
|
|
});
|
|
})
|
|
|
|
function clearModalForm() {
|
|
$('#get_id').val('');
|
|
$('#form_budget')[0].reset();
|
|
validation.resetForm();
|
|
$('#tx_type').attr('readonly', true);
|
|
reInitForm();
|
|
}
|
|
|
|
function storeBudget() {
|
|
validation.validate().then(function (status) {
|
|
if(status=='Valid') {
|
|
let myForm = document.getElementById('form_budget');
|
|
let formData = new FormData(myForm);
|
|
popConfirm("Konfirmasi Data Budget",
|
|
`<div class="mt-2">Yakin Akan Menyimpan Data Buget Ini ?</div>`,
|
|
function() {
|
|
znLoadingModal('mFormBudget')
|
|
doPost(base_url+'projects/act_any/store_data_budget', formData, function (msg, data) {
|
|
// znLoadingPageEnd();
|
|
znLoadingModalEnd('mFormBudget')
|
|
|
|
if (data == null){
|
|
znNotif("danger", msg);
|
|
}else {
|
|
if(data.rc == 0){
|
|
znNotif('success','Berhasil Menyimpan Data');
|
|
$('#budget_head').val(znNumFormat(data.budget))
|
|
var budget = znNumFormatClear($('#budget_head').val());
|
|
var terpakai = parseFloat(budget)-parseFloat(data.outstanding);
|
|
$('#budget_terpakai_head').val(znNumFormat(terpakai))
|
|
$('#sisa_budget_head').val(znNumFormat(data.outstanding))
|
|
table.ajax.url(routeTable).load();
|
|
$('#mFormBudget').modal('hide')
|
|
}else{
|
|
znNotif("danger", data.rm);
|
|
}
|
|
}
|
|
})
|
|
});
|
|
}
|
|
})
|
|
}
|
|
|
|
function reversal(idBudget, typeBudget) {
|
|
let formData = new FormData();
|
|
formData.append('idBudget', idBudget)
|
|
formData.append('typeBudget', typeBudget)
|
|
popConfirm("Konfirmasi Data Reversal Budget",
|
|
`<div class="mt-2">Yakin Akan Reversal Data Buget Ini ?</div>`,
|
|
function() {
|
|
znLoadingPage();
|
|
doPost(base_url+'projects/act_any/store_reversal_data_budget', formData, function (msg, data) {
|
|
// znLoadingPageEnd();
|
|
znLoadingPageEnd();
|
|
|
|
if (data == null){
|
|
znNotif("danger", msg);
|
|
}else {
|
|
if(data.rc == 0){
|
|
znNotif('success','Berhasil Reversal Data Budget');
|
|
if(typeBudget==1) {
|
|
$('#budget_head').val(0)
|
|
} else {
|
|
$('#budget_head').val(znNumFormat(data.budget))
|
|
}
|
|
var budget = znNumFormatClear($('#budget_head').val());
|
|
var terpakai = parseFloat(budget)-parseFloat(data.outstanding);
|
|
$('#budget_terpakai_head').val(znNumFormat(terpakai))
|
|
$('#sisa_budget_head').val(znNumFormat(data.outstanding))
|
|
table.ajax.url(routeTable).load();
|
|
$('#mFormBudget').modal('hide')
|
|
if(budget==0) {
|
|
znLoadingPage()
|
|
location.reload()
|
|
}
|
|
}else{
|
|
znNotif("danger", data.rm);
|
|
}
|
|
}
|
|
})
|
|
});
|
|
}
|
|
|
|
function budgetingAwal() {
|
|
$('#get_id_ba').val('');
|
|
$('#form_budget_awal')[0].reset();
|
|
validation.resetForm();
|
|
reInitForm();
|
|
znModal('mFormBudgetAwal')
|
|
}
|
|
|
|
function storeBudgetAwal() {
|
|
validation_ba.validate().then(function (status) {
|
|
if(status=='Valid') {
|
|
let myForm = document.getElementById('form_budget_awal');
|
|
let formData = new FormData(myForm);
|
|
popConfirm("Konfirmasi Data Budget",
|
|
`<div class="mt-2">Yakin Akan Menyimpan Data Buget Ini ?</div>`,
|
|
function() {
|
|
znLoadingModal('mFormBudgetAwal')
|
|
doPost(base_url+'projects/act_any/store_data_budget_awal', formData, function (msg, data) {
|
|
// znLoadingPageEnd();
|
|
znLoadingModalEnd('mFormBudgetAwal')
|
|
|
|
if (data == null){
|
|
znNotif("danger", msg);
|
|
}else {
|
|
if(data.rc == 0){
|
|
znNotif('success','Berhasil Menyimpan Data');
|
|
$('#mFormBudgetAwal').modal('hide')
|
|
znLoadingPage();
|
|
location.reload()
|
|
}else{
|
|
znNotif("danger", data.rm);
|
|
}
|
|
}
|
|
})
|
|
});
|
|
}
|
|
})
|
|
}
|
|
</script> |