File manager - Edit - /home/autoph/public_html/data03252025consolidation/resources/views/common/scripts/finance_pdc/pdc_information.js
Back
var record_id = ""; var edit_id = ""; // Update variables var pdc_edit_client_name = ""; var pdc_edit_client_mobile = ""; var pdc_edit_client_other_contact = ""; var pdc_edit_client_email = ""; var pdc_edit_plate_cs_number = ""; var pdc_edit_dealer = ""; var pdc_edit_brand = ""; var pdc_edit_model = ""; var pdc_edit_variant = ""; var pdc_edit_check_number = ""; var pdc_edit_check_amount = ""; var pdc_edit_check_date = ""; var pdc_edit_policy_number = ""; var pdc_edit_insurance_company = ""; var pdc_edit_bank = ""; var pdc_edit_branch = ""; $(function(){ initTablePDCInformation(); initTableRemainingDays(); refreshPDCInformationTable(); loadPDCInformation(); editPDCModalTabSelectedTab(1); // INITIALIZATION $('#pdc-edit-dealer').select2({ placeholder: "Dealer", allowClear: true }) $('#pdc-edit-brand').select2({ placeholder: "Brand", allowClear: true }) $('#pdc-edit-model').select2({ placeholder: "Model", allowClear: true }) $('#pdc-edit-variant').select2({ placeholder: "Variant", allowClear: true }) $('#pdc-edit-insurance-company').select2({ placeholder: "Insurance Company", allowClear: true }) $('#pdc-edit-bank').select2({ placeholder: "Bank", allowClear: true }) $('#check-date').datetimepicker({ format: 'L' }); $('[data-mask]').inputmask(); }) function initTablePDCInformation() { var $table = $('#pdc-information-table') $table.bootstrapTable('destroy').bootstrapTable({ // onLoadSuccess: function(data){ // $('#pdc-info-plate-cs').val(data.rows[0].plate_cs_number); // $('#pdc-info-brand').val(data.rows[0].brand); // $('#pdc-info-company-dealer').val(data.rows[0].company_dealer); // } }) } function initTableRemainingDays() { var $table = $('#pdc-remaining-days') $table.bootstrapTable('destroy').bootstrapTable({ }) } function initTablePDCActivityLog() { var $table = $('#pdc-activity-log-table') $table.bootstrapTable('destroy').bootstrapTable({ }) } function refreshPDCInformationTable() { // 2 var $table = $('#pdc-information-table') $(function() { $table.bootstrapTable('refresh', { url: '/app/table/finance_pdc_table.php' }); }) } function refreshPDCRemainingDays() { // 3 var $table = $('#pdc-remaining-days'); $(function() { $table.bootstrapTable('refresh', { url: '/app/table/finance_pdc_table.php' }); }) } function refreshPDCActivityLogTable() { // 4 activity log table initTablePDCActivityLog(); $('#modal-act-log-title').text("Activity Log (" + pdc_plate_cs_number + ")"); var $table = $('#pdc-activity-log-table'); $(function() { $table.bootstrapTable('refresh', { url: '/app/table/finance_pdc_table.php' }); }) } function queryParamsPDCInformationTable(params) { return { search: params.search, offset: params.offset, limit: params.limit, type: 2, // app/table/finance_pdc_table > pdc information insurance table list pdc_plate_cs_number: pdc_plate_cs_number }; } function queryParamsPDCRemainingDaysTable(params) { return { search: params.search, offset: params.offset, limit: params.limit, type: 3, // app/table/finance_pdc_table > finance information insurance table list record_id: record_id }; } function queryParamsPDCActivityLogTable(params) { return { search: params.search, offset: params.offset, limit: params.limit, type: 4, // app/table/finance_table > finance activity log table list plate_cs_number1: pdc_plate_cs_number }; } function back(){ window.history.back(); } function editPDCModalTabSelectedTab(type){ $('#pdc-modal-tab .nav-link').removeClass('active'); $('#pdc-edit-modal-tab-content .tab-pane').removeClass('show'); $('#pdc-edit-modal-tab-content .tab-pane').removeClass('active'); switch (type) { case 1: $('#pdc-edit-modal-tab-information').addClass('active'); $('#pdc-edit-modal-information').addClass('active'); $('#pdc-edit-modal-information').addClass('show'); break; case 2: $('#pdc-edit-modal-tab-insurance').addClass('active'); $('#pdc-edit-modal-insurance').addClass('active'); $('#pdc-edit-modal-insurance').addClass('show'); break; } } function editPDCInfo(value, row, index){ if(can_edit_record == 0){ if(can_delete_record == 0){ return '<div class="row">' + '<div class="col-6 btn btn-tertiary btn-sm" style="border-right: 1px solid #e5e4e2; border-radius: 0px;" title="Edit this info" onclick="editInformation(' + row.record_id + ')">' + '<i class="fas fa-pen" style="color: gray;"></i>' + '</div>' + '<div class="col-6 btn btn-tertiary btn-sm" title="Delete record" onclick="deleteInformation(' + row.record_id + ')">' + '<i class="fas fa-times" style="color: gray;"></i>' + '</div>' + '</div>' ; } else { return '<div class="row">' + '<div class="col-6 btn btn-tertiary btn-sm" style="border-right: 1px solid #e5e4e2; border-radius: 0px;" title="Edit this info" onclick="editInformation(' + row.record_id + ')">' + '<i class="fas fa-pen" style="color: gray;"></i>' + '</div>' + '<div class="col-6 btn btn-tertiary btn-sm" title="Delete record" onclick="deleteInformation(' + row.record_id + ')">' + '<i class="fas fa-times" style="color: red;"></i>' + '</div>' + '</div>' ; } } else { if(can_delete_record == 0){ return '<div class="row">' + '<div class="col-6 btn btn-tertiary btn-sm" style="border-right: 1px solid #e5e4e2; border-radius: 0px;" title="Edit this info" onclick="editInformation(' + row.record_id + ')" data-toggle="modal" data-target="#modal-pdc-edit-info">' + '<i class="fas fa-pen" style="color: #007BFF;"></i>' + '</div>' + '<div class="col-6 btn btn-tertiary btn-sm" title="Delete record" onclick="deleteInformation(' + row.record_id + ')">' + '<i class="fas fa-times" style="color: gray;"></i>' + '</div>' + '</div>' ; } else { return '<div class="row">' + '<div class="col-6 btn btn-tertiary btn-sm" style="border-right: 1px solid #e5e4e2; border-radius: 0px;" title="Edit this info" onclick="editInformation(' + row.record_id + ')" data-toggle="modal" data-target="#modal-pdc-edit-info">' + '<i class="fas fa-pen" style="color: #007BFF;"></i>' + '</div>' + '<div class="col-6 btn btn-tertiary btn-sm" title="Delete record" onclick="deleteInformation(' + row.record_id + ')">' + '<i class="fas fa-times" style="color: red;"></i>' + '</div>' + '</div>' ; } } } function loadPDCInformation(){ $.ajax({ url: "/app/finance_pdc/pdc_information.php", method: "POST", dataType: 'json', data: { pdc_plate_cs_number1: pdc_plate_cs_number, type: 1 // (function) }, beforeSend: function() { }, success: function(result) { $('#pdc-info-plate-cs').val(result.plate_cs_number); $('#pdc-info-brand').val(result.brand); $('#pdc-info-company-dealer').val(result.company + "/" + result.dealer); $('#span-date-uploaded').text(result.date_uploaded); $('#span-uploaded-by').text(result.uploaded_by); $('#span-modified-by').text(result.modified_by); } }); } function editInformation(row_id){ if(can_edit_record == 0){ toastr.remove(); toastr.error("Sorry, you have no access in updating record", "No access"); return; } else { edit_id = row_id; editPDCModalTabSelectedTab(1); $.ajax({ url: "/app/finance_pdc/pdc_crud.php", method: "POST", dataType: 'json', data: { edit_id: edit_id, type: 2 // read details }, beforeSend: function(){ }, success: function(result) { // alert(result.client_mobile); $('#pdc-edit-client-fullname').val(result.client_name); $('#pdc-edit-client-mobile').val(parseInt(result.client_mobile)); $('#pdc-edit-client-other-contact').val(result.client_other_contact); $('#pdc-edit-client-email').val(result.client_email); $('#pdc-edit-plate-cs-number').val(result.plate_cs_number); $('#pdc-edit-dealer').val(result.dealer_id).trigger('change'); $('#pdc-edit-brand').val(result.brand_id).trigger('change'); $('#pdc-edit-model').off('change.mychange'); $('#pdc-edit-model').val(result.model_id).trigger('change'); $('#pdc-edit-model').on('change'); $('#pdc-edit-variant').off('change.mychange'); $('#pdc-edit-variant').val(result.variant_id).trigger('change'); $('#pdc-edit-variant').on('change'); $('#check-date').val(result.check_date); $('#pdc-edit-policy-number').val(result.policy_number); $('#pdc-edit-bank').val(result.bank_id).trigger('change'); $('#pdc-edit-branch').val(result.branch); $('#pdc-edit-insurance-company').val(result.insurance_company_id).trigger('change'); $('#pdc-edit-check-amount').val(result.check_amount); $('#pdc-edit-check-number').val(result.check_number); } }); } } function deleteInformation(row_id){ if(can_delete_record == 0){ toastr.remove(); toastr.error('Sorry, you have no access in deleting record', 'No access'); } else { swalDeletePDCRecord(row_id); } } function swalDeletePDCRecord(record_id){ Swal.fire({ icon: 'question', html: 'Are you sure you want to remove this record?', showDenyButton: false, showCancelButton: true, confirmButtonText: `Confirm`, denyButtonText: `Don't Confirm`, }).then((result) => { if (result.isConfirmed) { $.ajax({ url: "/app/finance_pdc/pdc_crud.php", method: "POST", dataType: 'json', data: { type: 4, // delete record_id: record_id }, beforeSend: function() { // sweetAlertSimple('info', 'Oops...', 'Removing PDC record...'); }, success: function(result) { if(parseInt(result.status) === 0) { // deletion success if(result.record_count > 0){ window.location.href = "/financepdc/" + pdc_plate_cs_number; } else { window.location.href = "/financepdc"; } toastr.remove(); toastr.success('Record successfully deleted', 'Success'); } else { toastr.remove(); toastr.error('Oops.. an error has occurred in deleting', 'Deletion failed'); } }, error: function() { toastr.remove(); toastr.error('Oops.. an error has occurred in deleting', 'Deletion failed'); } }); } else if (result.isDenied) { // Swal.fire('', 'Changes are not saved', 'info') } }) } function loadPDCDetails(record_id){ $.ajax({ url: "/app/finance_pdc/pdc_information.php", method: "POST", dataType: 'json', data: { record_id: record_id, type: 2 // inner table }, beforeSend: function() { }, success: function(result) { // alert(result.check_amount); return; if(result.client_name == ""){ $('#span-client-fullname').css('color', 'red'); $('#span-client-fullname').text("(Not provided)");} else { $('#span-client-fullname').css('color', 'black'); $('#span-client-fullname').text(result.client_name); } if(result.client_mobile == ""){ $('#span-client-mobile').css('color', 'red'); $('#span-client-mobile').text("(Not provided)");} else { $('#span-client-mobile').css('color', 'black'); $('#span-client-mobile').text(result.client_mobile); } if(result.client_email == ""){ $('#span-client-email').css('color', 'red'); $('#span-client-email').text("(Not provided)");} else { $('#span-client-email').css('color', 'black'); $('#span-client-email').text(result.client_email); } if(result.bank_branch == ""){ $('#span-bank-branch-name').css('color', 'red'); $('#span-bank-branch-name').text("(Not provided)");} else { $('#span-bank-branch-name').css('color', 'black'); $('#span-bank-branch-name').text(result.bank_branch); } if(result.check_amount == ""){ $('#span-check-amount').css('color', 'red'); $('#span-check-amount').text("(Not provided)");} else { $('#span-check-amount').css('color', 'black'); $('#span-check-amount').text(result.check_amount); } if(result.model == "-"){ $('#span-model').css('color', 'red'); $('#span-model').text("(Not provided)");} else { $('#span-model').css('color', 'black'); $('#span-model').text(result.model); } if(result.variant == "-"){ $('#span-variant').css('color', 'red'); $('#span-variant').text("(Not provided)");} else { $('#span-variant').css('color', 'black'); $('#span-variant').text(result.variant); } $('#span-date-uploaded').text(result.date_added); $('#span-uploaded-by').text(result.added_by); $('#span-modified-by').text(result.modified_by); refreshPDCRemainingDays(); } }); } function isEmail(email) { var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if(!regex.test(email)) { return false; } else { return true; } } function fillModelDropdown(brand){ $.ajax({ url:"/app/finance_pdc/dd_get_model.php", type:"POST", async: false, data: { brand_id: brand, type: 1 }, beforeSend: function(){ }, success: function(result){ $('#pdc-edit-model').html(''); $('#pdc-edit-model').append("\"<option value=''></option>\""); $('#pdc-edit-model').append("\"" + result + "\""); } }); } function fillVariantDropdown(model){ $.ajax({ url:"/app/finance_pdc/dd_get_variant.php", type:"POST", async: false, data: { model_id: model, type: 1 }, beforeSend: function(){ }, success: function(result){ $('#pdc-edit-variant').html(''); $('#pdc-edit-variant').append("\"<option value=''></option>\""); $('#pdc-edit-variant').append("\"" + result + "\""); } }); } $('#pdc-edit-brand').on('change', function(){ var selected_brand = $('#pdc-edit-brand').val(); fillModelDropdown(selected_brand); }); $('#pdc-edit-model').on('change', function(){ var selected_model = $('#pdc-edit-model').val(); fillVariantDropdown(selected_model); }); $('#pdc-information-table').on('click-cell.bs.table', function(field, value, row, $el) { record_id = $el.record_id; loadPDCDetails(record_id); }); $('#button-edit-pdc-details').on('click', function(){ if(can_edit_record == 0){ toastr.remove(); toastr.error("You do not have access in updating record", "No access"); return; } pdc_edit_client_name = $('#pdc-edit-client-fullname').val(); pdc_edit_client_mobile = "+63" + $('#pdc-edit-client-mobile').val(); pdc_edit_client_other_contact = $('#pdc-edit-client-other-contact').val(); pdc_edit_client_email = $('#pdc-edit-client-email').val(); pdc_edit_plate_cs_number = $('#pdc-edit-plate-cs-number').val(); pdc_edit_dealer = $('#pdc-edit-dealer').val(); if(pdc_edit_dealer === null || pdc_edit_dealer == "" || typeof pdc_edit_dealer === "undefined"){ pdc_edit_dealer = 0; } pdc_edit_brand = $('#pdc-edit-brand').val(); if(pdc_edit_brand === null || pdc_edit_brand == "" || typeof pdc_edit_brand === "undefined"){ pdc_edit_brand = 0; } pdc_edit_model = $('#pdc-edit-model').val(); if(pdc_edit_model === null || pdc_edit_model == "" || typeof pdc_edit_model === "undefined"){ pdc_edit_model = 0; } pdc_edit_variant = $('#pdc-edit-variant').val(); if(pdc_edit_variant === null || pdc_edit_variant == "" || typeof pdc_edit_variant === "undefined"){ pdc_edit_variant = 0; } pdc_edit_check_number = $('#pdc-edit-check-number').val(); pdc_edit_check_amount = $('#pdc-edit-check-amount').val(); pdc_edit_check_date = $('#check-date').val(); pdc_edit_policy_number = $('#pdc-edit-policy-number').val(); pdc_edit_insurance_company = $('#pdc-edit-insurance-company').val(); if(pdc_edit_insurance_company === null || pdc_edit_insurance_company == "" || typeof pdc_edit_insurance_company === "undefined"){ pdc_edit_insurance_company = 0; } pdc_edit_bank = $('#pdc-edit-bank').val(); if(pdc_edit_bank === null || pdc_edit_bank == "" || typeof pdc_edit_bank === "undefined"){ pdc_edit_bank = 0; } pdc_edit_branch = $('#pdc-edit-branch').val(); // required fields if(pdc_edit_client_name == ""){ toastr.remove(); toastr.error("Client name field cannot be empty", "Incomplete data"); editPDCModalTabSelectedTab(1); $('#pdc-edit-client-fullname').trigger('focus'); $('#pdc-edit-client-fullname').css('border-color', 'red'); setTimeout(function(){ $('#pdc-edit-client-fullname').css("border", ""); $("#pdc-edit-client-fullname").trigger('blur'); }, 3000); return; } if(pdc_edit_client_mobile == ""){ toastr.remove(); toastr.error("Client mobile field cannot be empty", "Incomplete data"); editPDCModalTabSelectedTab(1); $('#pdc-edit-client-mobile').trigger('focus'); $('#pdc-edit-client-mobile').css('border-color', 'red'); setTimeout(function(){ $('#pdc-edit-client-mobile').css("border", ""); $("#pdc-edit-client-mobile").trigger('blur'); }, 3000); return; } if(pdc_edit_client_email == ""){ toastr.remove(); toastr.error("Client email field cannot be empty", "Incomplete data"); editPDCModalTabSelectedTab(1); $('#pdc-edit-client-email').trigger('focus'); $('#pdc-edit-client-email').css('border-color', 'red'); setTimeout(function(){ $('#pdc-edit-client-fullname').css("border", ""); $("#pdc-edit-client-fullname").trigger('blur'); }, 3000); return; } if(pdc_edit_plate_cs_number == ""){ toastr.remove(); toastr.error("Plate/CS Number field cannot be empty", "Incomplete data"); editPDCModalTabSelectedTab(1); $('#pdc-edit-plate-cs-number').trigger('focus'); $('#pdc-edit-plate-cs-number').css('border-color', 'red'); setTimeout(function(){ $('#pdc-edit-plate-cs-number').css("border", ""); $("#pdc-edit-plate-cs-number").trigger('blur'); }, 3000); return; } if(pdc_edit_dealer == 0){ toastr.remove(); toastr.error("Please specify dealer", "Incomplete data"); editPDCModalTabSelectedTab(1); $('#div-dealer').css('border', '1px solid #dc3545'); setTimeout(function(){ $('#div-dealer').css("border", ""); $("#div-dealer").trigger('blur'); }, 3000); return; } if(pdc_edit_brand == 0){ toastr.remove(); toastr.error("Please specify brand", "Incomplete data"); editPDCModalTabSelectedTab(1); $('#div-brand').css('border', '1px solid #dc3545'); setTimeout(function(){ $('#div-brand').css("border", ""); $("#div-brand").trigger('blur'); }, 3000); return; } if(pdc_edit_check_number == ""){ toastr.remove(); toastr.error("Check number field cannot be empty", "Incomplete data"); editPDCModalTabSelectedTab(2); $('#pdc-edit-check-number').trigger('focus'); $('#pdc-edit-check-number').css('border-color', 'red'); setTimeout(function(){ $('#pdc-edit-check-number').css("border", ""); $("#pdc-edit-check-number").trigger('blur'); }, 3000); return; } if(pdc_edit_check_amount == ""){ toastr.remove(); toastr.error("Check amount field cannot be empty", "Incomplete data"); editPDCModalTabSelectedTab(2); $('#pdc-edit-check-amount').trigger('focus'); $('#pdc-edit-check-amount').css('border-color', 'red'); setTimeout(function(){ $('#pdc-edit-check-amount').css("border", ""); $("#pdc-edit-check-amount").trigger('blur'); }, 3000); return; } if(pdc_edit_check_date == ""){ toastr.remove(); toastr.error("Check date field cannot be empty", "Incomplete data"); editPDCModalTabSelectedTab(2); $('#pdc-edit-check-date').trigger('focus'); $('#pdc-edit-check-date').css('border-color', 'red'); setTimeout(function(){ $('#pdc-edit-check-date').css("border", ""); $("#pdc-edit-check-date").trigger('blur'); }, 3000); return; } // if(pdc_edit_policy_number == ""){ // toastr.remove(); // toastr.error("Policy number field cannot be empty", "Incomplete data"); // editPDCModalTabSelectedTab(2); // $('#pdc-edit-policy-number').trigger('focus'); // $('#pdc-edit-policy-number').css('border-color', 'red'); // setTimeout(function(){ // $('#pdc-edit-policy-number').css("border", ""); // $("#pdc-edit-policy-number").trigger('blur'); // }, 3000); // return; // } if(pdc_edit_insurance_company == 0){ toastr.remove(); toastr.error("Please specify insurance company", "Incomplete data"); editPDCModalTabSelectedTab(2); $('#div-insurance-company').css('border', '1px solid #dc3545'); setTimeout(function(){ $('#div-insurance-company').css("border", ""); $("#div-insurance-company").trigger('blur'); }, 3000); return; } if(pdc_edit_bank == 0){ toastr.remove(); toastr.error("Please specify bank", "Incomplete data"); editPDCModalTabSelectedTab(2); $('#div-bank').css('border', '1px solid #dc3545'); setTimeout(function(){ $('#div-bank').css("border", ""); $("#div-bank").trigger('blur'); }, 3000); return; } // alert(pdc_edit_client_mobile); return; // VALIDATIONS // mobile if(pdc_edit_client_mobile.length != 13 || pdc_edit_client_mobile.substring(0, 4) != "+639"){ toastr.remove(); toastr.warning("It seems that client mobile is invalid", "Warning"); editPDCModalTabSelectedTab(1); $('#pdc-edit-client-mobile').trigger('focus'); $('#pdc-edit-client-mobile').css('border-color', 'red'); setTimeout(function(){ $('#pdc-edit-client-mobile').css("border", ""); $("#pdc-edit-client-mobile").trigger('blur'); }, 3000); return; } // email if(isEmail(pdc_edit_client_email) == false){ toastr.remove(); toastr.warning("It seems that client email is invalid", "Warning"); editPDCModalTabSelectedTab(1); $('#pdc-edit-client-email').trigger('focus'); $('#pdc-edit-client-email').css('border-color', 'red'); setTimeout(function(){ $('#pdc-edit-client-email').css("border", ""); $("#pdc-edit-client-email").trigger('blur'); }, 3000); return; } $.ajax({ url: "/app/finance_pdc/pdc_crud.php", method: "POST", dataType: 'json', data: { edit_id: edit_id, update_client_fullname: pdc_edit_client_name, update_client_mobile: pdc_edit_client_mobile, update_client_other_contact: pdc_edit_client_other_contact, update_client_email: pdc_edit_client_email, update_plate_cs_number: pdc_edit_plate_cs_number, update_dealer: pdc_edit_dealer, update_brand: pdc_edit_brand, update_model: pdc_edit_model, update_variant: pdc_edit_variant, update_check_number: pdc_edit_check_number, update_check_amount: pdc_edit_check_amount, update_check_date: pdc_edit_check_date, update_policy_number: pdc_edit_policy_number, update_insurance_company: pdc_edit_insurance_company, update_bank: pdc_edit_bank, update_branch: pdc_edit_branch, type: 3 // update details }, beforeSend: function(){ }, success: function(result) { if(result.status == 0){ // update success toastr.remove(); toastr.success("Successfully updated"); $('#modal-pdc-edit-info').modal('hide'); pdc_plate_cs_number1 = result.plate_cs_number1; refreshPDCInformationTable(); window.history.pushState({ "html": Response.html, "pageTitle": Response.pageTitle }, "", "/financepdc/" + pdc_plate_cs_number1 ); loadPDCInformation(); loadPDCDetails(result.record_id); return; } else if(result.status == 1){ // update failed toastr.remove(); toastr.error("Something went wrong, please try again", "Update failed"); return; } else if(result.status == 2){ // no company found toastr.remove(); toastr.error("It seems that the dealer selected is not designated to any company", "Dealer error / Company not found"); return; } else if(result.status == 3){ // duplicate found toastr.remove(); toastr.error("You may be entering a record that is already existing", "Duplicate found"); return; } // else if(result.status == 4){ // invalid mobile // toastr.remove(); // toastr.warning("It seems that both client mobile is invalid", "Invalid mobile"); // editPDCModalTabSelectedTab(1); // $('#pdc-edit-client-mobile').trigger('focus'); // $('#pdc-edit-client-mobile').css('border-color', 'red'); // setTimeout(function(){ // $('#pdc-edit-client-mobile').css("border", ""); // $("#pdc-edit-client-mobile").trigger('blur'); // }, 3000); // return; // } } }); })
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings