File manager - Edit - /home/autoph/public_html/connectv1/resources/views/common/scripts/finance/finance_information.js
Back
//GLOBAL VARIABLES var fin_id = 0; // Update variables var fni_edit_plate_cs_number = ""; var fni_edit_brand = ""; var fni_edit_model = ""; var fni_edit_variant = ""; var fni_edit_dealer = ""; var fni_edit_customer_fullname = ""; var fni_edit_customer_mobile = ""; var fni_edit_customer_other_contact = ""; var fni_edit_customer_email = ""; var fni_edit_customer_address = ""; var fni_edit_policy_issue_date = ""; var fni_edit_policy_start_date = ""; var fni_edit_policy_end_date = ""; var fni_edit_policy_number = ""; var fni_edit_bank = ""; var fni_edit_insurance_provider = ""; var fni_edit_insurance_type = ""; var fni_edit_sales_consultant = ""; var fni_edit_paid_amount = ""; var fni_edit_lock_in_year = ""; var fni_edit_terms = ""; var fni_edit_locked_in = 1; // others: for dropdown var selected_brand = ""; var selected_model = ""; $(function(){ refreshFinanceInformationTable(); loadFinanceInformation(); initTableFinanceInformation(); initTableRemainingDays(); editFNIModalTabSelectedTab(1); $('#finance-information-table').on('click', '.clickable-row', function(event) { // wala lang ito, 'di pa gumagana if($(this).hasClass('active')){ $(this).removeClass('active'); } else { $(this).addClass('active').siblings().removeClass('active'); } }); $('#fni-edit-brand').select2({ placeholder: "Brand", allowClear: true }); $('#fni-edit-model').select2({ placeholder: "Model", allowClear: true }); $('#fni-edit-variant').select2({ placeholder: "Variant", allowClear: true }); $('#fni-edit-dealer').select2({ placeholder: "Dealer", allowClear: true }) $('#fni-edit-insurance-provider').select2({ placeholder: "Insurance Provider", allowClear: true }) $('#fni-edit-insurance-type').select2({ placeholder: "Insurance Type", allowClear: true }) $('#issue-date').datetimepicker({ format: 'L' }); $('#start-date').datetimepicker({ format: 'L' }); $('#end-date').datetimepicker({ format: 'L' }); //Date picker $('#mod-birth-date').datetimepicker({ format: 'L' }); $('[data-mask]').inputmask(); }); function initTableFinanceInformation() { var $table = $('#finance-information-table') $table.bootstrapTable('destroy').bootstrapTable({ }) } function initTableRemainingDays() { var $table = $('#finance-remaining-days') $table.bootstrapTable('destroy').bootstrapTable({ onLoadSuccess: function(data) { // alert(data.rows.length); } }) } function initTableFinanceActivityLog() { var $table = $('#finance-activity-log-table') $table.bootstrapTable('destroy').bootstrapTable({ }); } function refreshFinanceInformationTable() { // 2 finance information table var $table = $('#finance-information-table') $(function() { $table.bootstrapTable('refresh', { url: '/app/table/finance_table.php' }); }) } function refreshFinanceRemainingDays() { // 3 remaining days table var $table = $('#finance-remaining-days') $(function() { $table.bootstrapTable('refresh', { url: '/app/table/finance_table.php' }); }) } function refreshFNIActivityLogTable() { // 6 activity log table initTableFinanceActivityLog(); $('#modal-act-log-title').text("Activity Log (" + plate_cs_number + ")"); var $table = $('#finance-activity-log-table'); $(function() { $table.bootstrapTable('refresh', { url: '/app/table/finance_table.php' }); }) } function queryParamsFinanceInformationTable(params) { return { search: params.search, offset: params.offset, limit: params.limit, type: 2, // app/table/finance_table > finance information insurance table list plate_cs_number: plate_cs_number }; } function queryParamsFinanceRemainingDaysTable(params) { return { search: params.search, offset: params.offset, limit: params.limit, type: 3, // app/table/finance_table > finance information insurance table list fin_id: fin_id, plate_cs_number: plate_cs_number, policy_number: policy_number }; } function queryParamsFinanceActivityLogTable(params) { return { search: params.search, offset: params.offset, limit: params.limit, type: 6, // app/table/finance_table > finance activity log table list plate_cs_number1: plate_cs_number }; } function back(){ $('#span-customer-fullname').text(""); $('#span-mobile-number').text(""); $('#span-email').text(""); $('#span-sales-consultant').text(""); $('#span-address').text(""); $('#span-bank-name').text(""); $('#span-locked-in-status').text(""); $('#span-locked-in-years').text(""); $('#span-terms').text(""); window.history.back(); } function loadFinanceInformation(){ $.ajax({ url: "/app/finance/finance_information.php", method: "POST", dataType: 'json', data: { plate_cs_number: plate_cs_number, type: 1 // (function) }, beforeSend: function() { }, success: function(result) { // $('#span-plate-cs').text(result.plate_cs_number); $('#fni-info-plate-cs').val(result.plate_cs_number); // if(result.brand == "(None)"){$('#span-brand').text("(Not provided)"); $('#span-brand').css('color', 'red'); } else { $('#span-brand').css('color', 'black'); $('#span-brand').text(result.brand); } $('#fni-info-brand').val(result.brand); $('#fni-info-company-dealer').val(result.company + "/" + result.dealer); // $('#span-company-dealer').text(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 loadFinanceDetails(fin_id, policy_number, policy_issue_date){ $.ajax({ url: "/app/finance/finance_information.php", method: "POST", dataType: 'json', data: { policy_number: policy_number, policy_issue_date: policy_issue_date, type: 2 // inner table }, beforeSend: function() { }, success: function(result) { // alert($.trim(result.modified_by)); return; if(result.customer_fullname == ""){ $('#span-customer-fullname').css('color', 'red'); $('#span-customer-fullname').text("(Not provided)");} else { $('#span-customer-fullname').css('color', 'black'); $('#span-customer-fullname').text(result.customer_fullname); } if(result.mobile_number == ""){ $('#span-mobile-number').css('color', 'red'); $('#span-mobile-number').text("(Not provided)");} else { $('#span-mobile-number').css('color', 'black'); $('#span-mobile-number').text(result.mobile_number); } if(result.email == ""){ $('#span-email').css('color', 'red'); $('#span-email').text("(Not provided)");} else { $('#span-email').css('color', 'black'); $('#span-email').text(result.email); } if(result.sales_consultant == ""){ $('#span-sales-consultant').css('color', 'red'); $('#span-sales-consultant').text("(Not provided)");} else { $('#span-sales-consultant').css('color', 'black'); $('#span-sales-consultant').text(result.sales_consultant); } if(result.customer_address == ""){ $('#span-address').css('color', 'red'); $('#span-address').text("(Not provided)");} else { $('#span-address').css('color', 'black'); $('#span-address').text(result.customer_address); } if(result.bank_name == ""){ $('#span-bank-name').css('color', 'red'); $('#span-bank-name').text("(Not provided)");} else { $('#span-bank-name').css('color', 'black'); $('#span-bank-name').text(result.bank_name); } $('#span-locked-in-status').text(result.locked_in); if(result.locked_in_years == ""){ $('#span-locked-in-years').css('color', 'red'); $('#span-locked-in-years').text("(Not provided)");} else { $('#span-locked-in-years').css('color', 'black'); $('#span-locked-in-years').text(result.locked_in_years); } $('#span-terms').text(result.terms); // if(result.brand == "-"){ $('#span-brand').css('color', 'red'); $('#span-brand').text("(Not provided)");} else { $('#span-brand').css('color', 'black'); $('#span-brand').text(result.brand); } if(result.model == "-"){ $('#span-car-model').css('color', 'red'); $('#span-car-model').text("(Not provided)");} else { $('#span-car-model').css('color', 'black'); $('#span-car-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_uploaded + " " + result.add_source); $('#span-uploaded-by').text(result.uploaded_by); if($.trim(result.modified_by) == "Unknown"){ $('#span-modified-by').text(""); } else { $('#span-modified-by').text(result.modified_by + " (" + result.date_modified + ")"); } $('#finance-plate-cs-information').attr('hidden', false); } }); refreshFinanceRemainingDays(); } function editFNIInfo(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.finance_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.finance_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.finance_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.finance_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.finance_id + ')" data-toggle="modal" data-target="#modal-finance-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.finance_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.finance_id + ')" data-toggle="modal" data-target="#modal-finance-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.finance_id + ')">' + '<i class="fas fa-times" style="color: red;"></i>' + '</div>' + '</div>' ; } } } 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; editFNIModalTabSelectedTab(1); $.ajax({ url: "/app/finance/finance_crud.php", method: "POST", dataType: 'json', data: { edit_id: edit_id, type: 2 // read details }, beforeSend: function(){ }, success: function(result) { // alert(result.customer_mobile_number); return; $('#fni-edit-plate-cs-number').val(result.plate_cs_number); $('#fni-edit-brand').val(result.brand_id).trigger('change'); // var promises = fillModelDropdown(result.brand_id); // $.when.apply($, promises).then(function(){ // fillVariantDropdown(result.model_id); // }); // $.when(a(result.brand_id)).done(function(){ // b(result.model_id); // }); $('#fni-edit-model').off('change.mychange'); $('#fni-edit-model').val(result.model_id).trigger('change'); $('#fni-edit-model').on('change'); $('#fni-edit-variant').off('change.mychange'); $('#fni-edit-variant').val(result.variant_id).trigger('change'); $('#fni-edit-variant').on('change'); $('#fni-edit-dealer').val(result.dealer_id).trigger('change'); $('#fni-edit-customer-fullname').val(result.customer_fullname); $('#fni-edit-customer-mobile').val(parseInt(result.customer_mobile_number)); $('#fni-edit-customer-other-contact').val(result.customer_other_contact); $('#fni-edit-customer-email').val(result.customer_email); $('#fni-edit-customer-address').val(result.customer_address); $('#issue-date').val(result.policy_issue_date); $('#start-date').val(result.policy_start_date); $('#end-date').val(result.policy_end_date); $('#fni-edit-policy-number').val(result.policy_number); $('#fni-edit-bank').val(result.bank_name); $('#fni-edit-insurance-provider').val(result.insurance_provider).trigger('change'); $('#fni-edit-insurance-type').val(result.insurance_business_type).trigger('change'); $('#fni-edit-sales-consultant').val(result.sales_consultant); $('#fni-edit-paid-amount').val(result.paid_amount); $('#fni-edit-lock-in-year').val(result.locked_in_years); $('#fni-edit-terms').val(result.terms); // check box locked in if(result.locked_in == 0){ $('#check-lock-in').prop('checked', false); fni_edit_locked_in = 0; } else { $('#check-lock-in').prop('checked', true); fni_edit_locked_in = 1; } } }); } } function a(value){ $('#fni-edit-model').off('change.mychange'); $('#fni-edit-model').val(value).trigger('change'); $('#fni-edit-model').on('change'); } function b(value){ $('#fni-edit-variant').off('change.mychange'); $('#fni-edit-variant').val(value).trigger('change'); $('#fni-edit-variant').on('change'); } function editFNIModalTabSelectedTab(type){ $('#fni-modal-tab .nav-link').removeClass('active'); $('#fni-edit-modal-tab-content .tab-pane').removeClass('show'); $('#fni-edit-modal-tab-content .tab-pane').removeClass('active'); switch (type) { case 1: $('#fni-edit-modal-tab-information').addClass('active'); $('#fni-edit-modal-information').addClass('active'); $('#fni-edit-modal-information').addClass('show'); break; case 2: $('#fni-edit-modal-tab-insurance').addClass('active'); $('#fni-edit-modal-insurance').addClass('active'); $('#fni-edit-modal-insurance').addClass('show'); break; } } 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(){ $.ajax({ url:"/app/finance/dd_get_model.php", type:"POST", async: false, data: { brand_id: selected_brand, type: 1 }, beforeSend: function(){ }, success: function(result){ $('#fni-edit-model').html(''); $('#fni-edit-model').append("\"<option value=''></option>\""); $('#fni-edit-model').append("\"" + result + "\""); } }); } function fillVariantDropdown(){ $.ajax({ url:"/app/finance/dd_get_variant.php", type:"POST", async: false, data: { model_id: selected_model, type: 1 }, beforeSend: function(){ }, success: function(result){ $('#fni-edit-variant').html(''); $('#fni-edit-variant').append("\"<option value=''></option>\""); $('#fni-edit-variant').append("\"" + result + "\""); } }); } function deleteInformation(row_id){ if(can_delete_record == 0){ toastr.remove(); toastr.error('Sorry, you have no access in deleting record', 'No access'); } else { swalDeleteFNIRecord(row_id); } } function swalDeleteFNIRecord(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/finance_crud.php", method: "POST", dataType: 'json', data: { type: 4, // delete record_id: record_id }, beforeSend: function() { // sweetAlertSimple('info', 'Oops...', 'Removing FNI record...'); }, success: function(result) { if(parseInt(result.status) === 0) { // deletion success if(result.record_count > 0){ window.location.href = "/financelist/" + plate_cs_number; } else { window.location.href = "/financelist"; } 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') } }) } $('#finance-information-table').on('click-cell.bs.table', function(field, value, row, $el) { fin_id = $el.finance_id; policy_number = $el.policy_number; policy_issue_date = $el.policy_issue_date; loadFinanceDetails(fin_id, policy_number, policy_issue_date); loadFinanceInformation(); }); $('#fni-edit-brand').on('change', function(){ selected_brand = $('#fni-edit-brand').val(); $('#fni-edit-variant').html(''); // fillModelDropdown(selected_brand); $.when(fillModelDropdown()).done(function(){ fillVariantDropdown(); }); // var promises = fillModelDropdown(selected_brand); // $.when.apply($, promises).then(function(){ // fillVariantDropdown(selected_model); // }); }); $('#fni-edit-model').on('change', function(){ selected_model = $('#fni-edit-model').val(); fillVariantDropdown(selected_model); }); $('#fni-edit-brand').on('select2: unselecting', function(event){ fni_edit_brand = 0; }) $('#check-lock-in').on('click', function(){ if(fni_edit_locked_in == 0){ fni_edit_locked_in = 1; } else { fni_edit_locked_in = 0; } }); $('#button-edit-fni-details').on('click', function(){ // alert("Working"); return; if(can_edit_record == 0){ toastr.remove(); toastr.error("You do not have access in updating record", "No access"); return; } fni_edit_plate_cs_number = $('#fni-edit-plate-cs-number').val(); fni_edit_dealer = $('#fni-edit-dealer').val(); fni_edit_brand = $('#fni-edit-brand').val(); if(fni_edit_brand === null || fni_edit_brand == "" || typeof fni_edit_brand === "undefined"){ fni_edit_brand = 0; } fni_edit_model = $('#fni-edit-model').val(); if(fni_edit_model === null || fni_edit_model == "" || typeof fni_edit_model === "undefined"){ fni_edit_model = 0; } fni_edit_variant = $('#fni-edit-variant').val(); if(fni_edit_variant === null || fni_edit_variant == "" || typeof fni_edit_variant === "undefined"){ fni_edit_variant = 0; } fni_edit_customer_fullname = $('#fni-edit-customer-fullname').val(); fni_edit_customer_mobile = "+63" + $('#fni-edit-customer-mobile').val(); fni_edit_customer_other_contact = $('#fni-edit-customer-other-contact').val(); fni_edit_customer_email = $('#fni-edit-customer-email').val(); fni_edit_customer_address = $('#fni-edit-customer-address').val(); fni_edit_policy_issue_date = $('#issue-date').val(); fni_edit_policy_start_date = $('#start-date').val(); fni_edit_policy_end_date = $('#end-date').val(); fni_edit_policy_number = $('#fni-edit-policy-number').val(); fni_edit_bank = $('#fni-edit-bank').val(); fni_edit_sales_consultant = $('#fni-edit-sales-consultant').val(); fni_edit_paid_amount = $('#fni-edit-paid-amount').val(); fni_edit_lock_in_year = $('#fni-edit-lock-in-year').val(); fni_edit_terms = $('#fni-edit-terms').val(); // dropdowns fni_edit_brand = $('#fni-edit-brand').val(); if(fni_edit_brand === null || fni_edit_brand == "" || typeof fni_edit_brand === "undefined"){ fni_edit_brand = 0; } fni_edit_insurance_provider = $('#fni-edit-insurance-provider').val(); if(fni_edit_insurance_provider === null || fni_edit_insurance_provider == "" || typeof fni_edit_insurance_provider === "undefined"){ fni_edit_insurance_provider = 0; } fni_edit_insurance_type = $('#fni-edit-insurance-type').val(); if(fni_edit_insurance_type === null || fni_edit_insurance_type == "" || typeof fni_edit_insurance_type === "undefined"){ fni_edit_insurance_type = 0; } // required fields if(fni_edit_plate_cs_number == ""){ // plate/cs number toastr.remove(); toastr.error("Plate/CS Number field cannot be empty", "Incomplete!"); editFNIModalTabSelectedTab(1); $('#fni-edit-plate-cs-number').trigger('focus'); $('#fni-edit-plate-cs-number').css('border-color', 'red'); setTimeout(function(){ $('#fni-edit-plate-cs-number').css("border", ""); $("#fni-edit-plate-cs-number").trigger('blur'); }, 3000); return; } if(fni_edit_brand == 0){ // brand toastr.remove(); toastr.error("Please specify brand", "Incomplete!"); editFNIModalTabSelectedTab(1); $('#div-brand').css('border', '1px solid #dc3545'); setTimeout(function(){ $('#div-brand').css("border", ""); $("#div-brand").trigger('blur'); }, 3000); return; } // if(fni_edit_model == 0){ // model // toastr.remove(); // toastr.error("Please specify model", "Incomplete!"); // editFNIModalTabSelectedTab(1); // $('#div-model').css('border', '1px solid #dc3545'); // setTimeout(function(){ // $('#div-model').css("border", ""); // $("#div-model").trigger('blur'); // }, 3000); // return; // } if(fni_edit_dealer == 0){ // dealer toastr.remove(); toastr.error("Please specify dealer", "Incomplete!"); editFNIModalTabSelectedTab(1); $('#div-dealer').css('border', '1px solid #dc3545'); setTimeout(function(){ $('#div-dealer').css("border", ""); $("#div-dealer").trigger('blur'); }, 3000); return; } if(fni_edit_customer_fullname == ""){ // customer fullname toastr.remove(); toastr.error("Customer fullname field cannot be empty", "Incomplete!"); editFNIModalTabSelectedTab(1); $('#fni-edit-customer-fullname').trigger('focus'); $('#fni-edit-customer-fullname').css('border-color', 'red'); setTimeout(function(){ $('#fni-edit-customer-fullname').css("border", ""); $("#fni-edit-customer-fullname").trigger('blur'); }, 3000); return; } if(edit_mobile_required == 1){ if(fni_edit_customer_mobile == "+63"){ // customer mobile toastr.remove(); toastr.error("Customer mobile is required", "Incomplete!"); editFNIModalTabSelectedTab(1); $('#fni-edit-customer-mobile').trigger('focus'); $('#fni-edit-customer-mobile').css('border-color', 'red'); setTimeout(function(){ $('#fni-edit-customer-mobile').css("border", ""); $("#fni-edit-customer-mobile").trigger('blur'); }, 3000); return; } else { if(fni_edit_customer_mobile.length != 13 || fni_edit_customer_mobile.substring(0, 4) != "+639"){ toastr.remove(); toastr.warning("It seems that customer mobile is invalid", "Warning!"); editFNIModalTabSelectedTab(1); $('#fni-edit-customer-mobile').trigger('focus'); $('#fni-edit-customer-mobile').css('border-color', 'red'); setTimeout(function(){ $('#fni-edit-customer-mobile').css("border", ""); $("#fni-edit-customer-mobile").trigger('blur'); }, 3000); return; } } } else { if(fni_edit_customer_mobile != ""){ if(fni_edit_customer_mobile.length != 13 || fni_edit_customer_mobile.substring(0, 4) != "+639"){ toastr.remove(); toastr.warning("It seems that customer mobile is invalid", "Invalid mobile"); editFNIModalTabSelectedTab(1); $('#fni-edit-customer-mobile').trigger('focus'); $('#fni-edit-customer-mobile').css('border-color', 'red'); setTimeout(function(){ $('#fni-edit-customer-mobile').css("border", ""); $("#fni-edit-customer-mobile").trigger('blur'); }, 3000); return; } } } if(edit_email_required == 1){ if(fni_edit_customer_email == ""){ // customer email toastr.remove(); toastr.error("Customer email is required", "Incomplete!"); editFNIModalTabSelectedTab(1); $('#fni-edit-customer-email').trigger('focus'); $('#fni-edit-customer-email').css('border-color', 'red'); setTimeout(function(){ $('#fni-edit-customer-email').css("border", ""); $("#fni-edit-customer-email").trigger('blur'); }, 3000); return; } else { if(isEmail(fni_edit_customer_email) == false){ toastr.remove(); toastr.warning("It seems that customer email is invalid", "Invalid email"); editFNIModalTabSelectedTab(1); $('#fni-edit-customer-email').trigger('focus'); $('#fni-edit-customer-email').css('border-color', 'red'); setTimeout(function(){ $('#fni-edit-customer-email').css("border", ""); $("#fni-edit-customer-email").trigger('blur'); }, 3000); return; } } } if(fni_edit_policy_issue_date == ""){ // policy issue date toastr.remove(); toastr.error("Policy Issue Date field cannot be empty", "Incomplete!"); editFNIModalTabSelectedTab(2); $('#issue-date').trigger('focus'); $('#issue-date').css('border-color', 'red'); setTimeout(function(){ $('#issue-date').css("border", ""); $("#issue-date").trigger('blur'); }, 3000); return; } if(fni_edit_policy_start_date == ""){ // policy start date toastr.remove(); toastr.error("Policy Start Date field cannot be empty", "Incomplete!"); editFNIModalTabSelectedTab(2); $('#start-date').trigger('focus'); $('#start-date').css('border-color', 'red'); setTimeout(function(){ $('#start-date').css("border", ""); $("#start-date").trigger('blur'); }, 3000); return; } if(fni_edit_policy_end_date == ""){ // policy end date toastr.remove(); toastr.error("Policy End Date field cannot be empty", "Incomplete!"); editFNIModalTabSelectedTab(2); $('#end-date').trigger('focus'); $('#end-date').css('border-color', 'red'); setTimeout(function(){ $('#end-date').css("border", ""); $("#end-date").trigger('blur'); }, 3000); return; } if(edit_policy_required == 1){ if(fni_edit_policy_number == ""){ // policy number toastr.remove(); toastr.error("Policy Number field cannot be empty", "Incomplete!"); editFNIModalTabSelectedTab(2); $('#fni-edit-policy-number').trigger('focus'); $('#fni-edit-policy-number').css('border-color', 'red'); setTimeout(function(){ $('#fni-edit-policy-number').css("border", ""); $("#fni-edit-policy-number").trigger('blur'); }, 3000); return; } } if(fni_edit_insurance_provider == 0){ // insurance company/provider toastr.remove(); toastr.error("Please specify Insurance Company/Provider", "Incomplete!"); editFNIModalTabSelectedTab(2); $('#div-insurance-provider').css('border', '1px solid #dc3545'); setTimeout(function(){ $('#div-insurance-provider').css("border", ""); $("#div-insurance-provider").trigger('blur'); }, 3000); return; } if(fni_edit_insurance_type == 0){ // insurance company/provider toastr.remove(); toastr.error("Please specify Insurance Type", "Incomplete!"); editFNIModalTabSelectedTab(2); $('#div-insurance-type').css('border', '1px solid #dc3545'); setTimeout(function(){ $('#div-insurance-type').css("border", ""); $("#div-insurance-type").trigger('blur'); }, 3000); return; } // alert("No invalid"); // return; $.ajax({ url: "/app/finance/finance_crud.php", method: "POST", dataType: 'json', data: { edit_id: edit_id, update_plate_cs_number: fni_edit_plate_cs_number, update_brand: fni_edit_brand, update_model: fni_edit_model, update_variant: fni_edit_variant, update_dealer: fni_edit_dealer, update_customer_fullname: fni_edit_customer_fullname, update_customer_mobile: fni_edit_customer_mobile, update_customer_other_contact: fni_edit_customer_other_contact, update_customer_email: fni_edit_customer_email, update_customer_address: fni_edit_customer_address, update_policy_issue_date: fni_edit_policy_issue_date, update_policy_start_date: fni_edit_policy_start_date, update_policy_end_date: fni_edit_policy_end_date, update_policy_number: fni_edit_policy_number, update_bank: fni_edit_bank, update_insurance_provider: fni_edit_insurance_provider, update_insurance_type: fni_edit_insurance_type, update_sales_consultant: fni_edit_sales_consultant, update_paid_amount: fni_edit_paid_amount, update_lock_in_year: fni_edit_lock_in_year, update_terms: fni_edit_terms, update_lock_in: fni_edit_locked_in, type: 3 // update details }, beforeSend: function(){ }, success: function(result) { if(result.status == 0){ // update success toastr.remove(); toastr.success("Successfully updated"); $('#modal-finance-edit-info').modal('hide'); refreshFinanceInformationTable(); loadFinanceDetails(fin_id, fni_edit_policy_number, fni_edit_policy_issue_date); 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){ // duplicate 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("Updated details matched a record", "Duplicate found"); return; } } }); });
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings