File manager - Edit - /home/autoph/public_html/connectv1/dist/js/customer_update/dealer_assign.js
Back
var new_customer_is_individual = false; var shown = false; var count_customer_summary = null; var customer_grid = null; var onShowFiltersDialog = function() { if (getCookie("customer_toggle") == null || parseInt($.cookie("customer_toggle")) == 0) { var $table = $('#customer-table'); $table.bootstrapTable('destroy'); initGrid() $.cookie("customer_toggle", 1); } else { // initList() $.cookie("customer_toggle", 0); } refreshTableCustomer() } function buttonsFunction() { return { grid_refresh: { 'icon': 'fa fa-sync', 'event': 'refreshTableCustomer', 'attributes': { 'title': 'Refresh', 'data-test': 'test123' } }, grid_toggle_on: { 'icon': 'fa fa-toggle-on', 'event': 'onShowFiltersDialog', 'attributes': { 'title': 'Toggle List View', 'data-test': 'test123' } }, grid_toggle_off: { 'icon': 'fa fa-toggle-off', 'event': 'onShowFiltersDialog', 'attributes': { 'title': 'Toggle Grid View', 'data-test': 'test123' } } } } function initGrid() { var $table = $('#customer-table'); // $table.bootstrapTable('destroy'); $table.bootstrapTable({ formatSearch: function() { return '';//'Search Customer' }, }); } function initList() { var $table = $('#customer-table') $table.bootstrapTable('destroy') $table.bootstrapTable({ sidePagination: 'server', formatSearch: function() { return ''//'Search Customer' }, onSearch: function(text) { $table.addClass('loading'); }, onLoadSuccess: function() { $table.removeClass('loading'); } }); } function customSearch(data, text) { if (getCookie("customer_toggle") != null && $.cookie("customer_toggle") == 1) { refreshTableCustomer(); } return data.filter(function(row) { return row.name.toLowerCase().replace(/\s/g, "").indexOf(text.toLowerCase().replace(/\s/g, "")) > -1 }) } function customerCountSummary() { var batch_no = ($("#batch").val() == '') ? '0' : $("#batch").val(); var company = ($("#company-filter").val() == '') ? '0' : $("#company-filter").val(); var gender = ($("#gender").val() == '') ? 'all' : $("#gender").val(); var type = ($("#type").val() == '') ? '0' : $("#type").val(); var filter_age = ($("#filter-age").val() == '') ? '0' : $("#filter-age").val(); var filter_data = ($("#filter-data").val() == '') ? '0' : $("#filter-data").val(); var customer_actions = ($("#customer-actions").val() == '') ? '0' : $("#customer-actions").val(); var my_records = $('#my_record_filter').is(":checked"); if(count_customer_summary != null){ count_customer_summary.abort(); } count_customer_summary = $.ajax({ url: "api/customer_update/dealer_customerv2_update.php", type: "POST", dataType: 'json', data: { batch: batch, company: company, type: type, gender: gender, filter_age: filter_age, filter_data: filter_data, apiKey: '8666264351338448', my_records : my_records }, beforeSend: function() {}, success: function(result) { // console.log('result total' +result); a=result.total_icu.replace(/\,/g,''); // 1125, but a string, so convert it to number total_avail_inactive=parseInt(a,10); $("#no_assign").attr({ "max" : total_avail_inactive, "min" : 1 }); $('#total_customer_count').text(result.total_icu); if(result.total_icu ==0) { $("#sl_company").attr('disabled', true); $("#btn-submit-manually").attr('disabled', true); } else { $("#sl_company").attr('disabled', false); $("#btn-submit-manually").attr('disabled', false); } // $('#new_customer_count').text(result.new_customer_count); // $('#updated_customer_count').text(result.updated_customer_count); // $('#new_today_customer_count').text(result.new_today_customer_count); } }); } function refreshTableCustomer() { if (getCookie("customer_toggle") != null && $.cookie("customer_toggle") == 1) { initGrid() getCustomerGrid(0, 9); showGrid(); } else { initList() var $table = $('#customer-table') // $table.bootstrapTable('destroy') $(function() { $table.bootstrapTable('refresh', { url: 'app/table/bt_dealer_assignment_update_list.php' }); }) showList(); } customerCountSummary(); } function gotoOffsetCustomer(n) { // alert(n) // $.cookie("customer_list_offset",n); getCustomerGrid(n, 9); } function getCustomerGrid(offset, limit) { var dms = ($("#dms").val() == '') ? '0' : $("#dms").val(); var company = ($("#company-filter").val() == '') ? '0' : $("#company-filter").val(); var gender = ($("#gender").val() == '') ? 'all' : $("#gender").val(); var type = ($("#type").val() == '') ? '0' : $("#type").val(); var filter_age = ($("#filter-age").val() == '') ? '0' : $("#filter-age").val(); var filter_data = ($("#filter-data").val() == '') ? '0' : $("#filter-data").val(); var customer_actions = ($("#customer-actions").val() == '') ? '0' : $("#customer-actions").val(); var search = $(".search-input").val(); var my_records = $('#my_record_filter').is(":checked"); if(customer_grid != null){ customer_grid.abort(); } customer_grid = $.ajax({ url: 'app/table/bt_customer_update_list.php', type: "POST", dataType: 'json', data: { search: search, grid: 1, offset: offset, limit: limit, dms: dms, company: company, type: type, gender: gender, filter_age: filter_age, filter_data: filter_data, customer_actions: customer_actions, my_records : my_records }, beforeSend: function() { $('#loader-main').show(); }, success: function(result) { // result.total $('#customer-grid-data').html(''); $('#customer-grid-data').append(result.customer_list); $('#customer-grid-data-paging').html(''); // if(result.total <= 0){ // $('#customer-grid-data-paging').append(result.customer_list_paging); // } // if(result.grid_offset > 6){ $('#customer-grid-data-paging').append(result.customer_list_paging); // } $('#loader-main').hide(); } }); } function showGrid() { $("#customer-grid").show(); $("#grid-card").show(); $('#customer-grid-data-paging').show(); $("button[name='grid_toggle_on']").show(); $("#customer-table").hide(); $(".fixed-table-pagination").hide(); $("button[name='grid_toggle_off']").hide(); } function showList() { $("#customer-table").show(); $("#grid-card").hide(); $(".fixed-table-pagination").show(); $("button[name='grid_toggle_off']").hide();//show(); $("#customer-grid").hide(); $('#customer-grid-data-paging').hide(); $("button[name='grid_toggle_on']").hide(); } function queryParams(params) { var dms = ($("#dms").val() == '') ? '0' : $("#dms").val(); var company = ($("#company-filter").val() == '') ? '0' : $("#company-filter").val(); var gender = ($("#gender").val() == '') ? 'all' : $("#gender").val(); var type = ($("#type").val() == '') ? '0' : $("#type").val(); var filter_age = ($("#filter-age").val() == '') ? '0' : $("#filter-age").val(); var filter_data = ($("#filter-data").val() == '') ? '0' : $("#filter-data").val(); var customer_actions = ($("#customer-actions").val() == '') ? '0' : $("#customer-actions").val(); var my_records = $('#my_record_filter').is(":checked"); return { search: params.search, offset: params.offset, limit: params.limit, sort: params.sort, order: params.order, dms: dms, company: company, type: type, gender: gender, filter_age: filter_age, filter_data: filter_data, customer_actions: customer_actions, my_records : my_records }; } function customerModal(isIndividual) { new_customer_is_individual = isIndividual; $('#proceed-button').text("Add Customer"); $('.customer-modal-overlay').hide(); if (isIndividual) { $('#modal-title').text("New Customera (Individual)"); checkFieldsModal(true); } else { $('#modal-title').text("New Customerb (Corporation)"); checkFieldsModal(false); } resetCustomerModal(); $("#addRowDataSource").click(); } function customerInfo(id) { $.cookie("customer_selected_tab", 'custom-tabs-three-home-tab'); // window.location.href = "customer_view.php?q=" + id; } function addFilterListener(){ $('#dms').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); $('#company-filter').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); $('#gender').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); $('#type').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); $('#filter-data').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); $('#filter-age').off('change.mychange').on('change.mychange', function() { $('#customer-actions').off('change.mychange'); $('#customer-actions').val('').trigger('change') addFilterListenerCustomerAction(); refreshTableCustomer(); }); addFilterListenerCustomerAction(); } function addFilterListenerCustomerAction(){ $('#customer-actions').off('change.mychange').on('change.mychange', function() { refreshTableCustomer(); }); } ///////////////////////////////////////////////////////////////////////////////////////////////////// $(document).ready(function() { // if (getCookie("customer_toggle") != null && parseInt($.cookie("customer_toggle")) == 1) { // initGrid() // } else { // initList() // } refreshTableCustomer() addFilterListener(); var $table = $('#customer-table'); $('#customer_action_all').on('click', function(event) { $table.addClass('loading'); $('#customer-actions').val('all').trigger('change'); }); $('#customer_action_new').on('click', function(event) { $table.addClass('loading'); $('#customer-actions').val('new').trigger('change'); }); $('#customer_action_updated').on('click', function(event) { $table.addClass('loading'); $('#customer-actions').val('updated').trigger('change'); }); $('#customer_action_added').on('click', function(event) { $table.addClass('loading'); $('#customer-actions').val('added').trigger('change'); }); $('#dms').select2({ // placeholder: "DMS Type", placeholder: "Batch No", allowClear: true }) $('#company-filter').select2({ placeholder: "Company", allowClear: true }) $('#gender').select2({ placeholder: "Gender", allowClear: true }) $('#type').select2({ placeholder: "Customer Type", allowClear: true }) $('#filter-age').select2({ placeholder: "Age", allowClear: true }) $('#filter-data').select2({ placeholder: "Data Type", allowClear: true }) $('#customer-actions').select2({ placeholder: "Customer Actions", allowClear: true }) $( "#my_record_filter").on( "click", function() { refreshTableCustomer(); }); $('#customer-table').on('click-cell.bs.table', function(field, value, row, $el) { // alert(value) if (value == 'email_1' || value == 'mobile_phone_1') { return; } customerInfo($el.id); }); //for click bnalloon not hiding -> filter // document.getElementById("dropdown-filter").addEventListener('click', function(event) { // // alert("click outside"); // event.stopPropagation(); // }); $('#new-customer').on("click", function() { shown ? $(this).hideBalloon() : $(this).showBalloon(); shown = !shown; }).showBalloon({ position: 'right', html: true, css: { color: 'black' }, contents: ` <div class="row"> <div class="col-sm-6 p-1"> <input style="width: 90px !important;" type="button" onclick="customerModal(true)" id="new-individual-customer" class="btn btn-primary btn-sm" value="Individual" data-toggle="modal" data-target="#modal-customer"></input> </div> <div class="col-sm-6 p-1"> <input style="width: 90px !important;" type="button" onclick="customerModal(false)" id="new-corporate-customer" class="btn btn-primary btn-sm" value="Corporation" data-toggle="modal" data-target="#modal-customer"></input> </div> <div class="col-sm-4 p-1" hidden> <input style="width: 90px !important;" type="button" id="new-import-customer" class="btn btn-primary btn-sm" value="Import"></input> </div> </div> ` }); $('#new-customer').hideBalloon(); $(document).mouseup(function(e) { var container = $("#new-customer"); // if the target of the click isn't the container nor a descendant of the container if (!container.is(e.target) && container.has(e.target).length === 0) { container.hideBalloon(); shown = false; } }); $('#btnCustomerListNoFilter').click(function() { $('#dms').off('change.mychange'); $('#company-filter').off('change.mychange'); $('#gender').off('change.mychange'); $('#type').off('change.mychange'); $('#filter-age').off('change.mychange'); $('#filter-data').off('change.mychange'); $('#customer-actions').off('change.mychange'); $('#dms').val('').trigger('change') $('#company-filter').val('').trigger('change') $('#gender').val('').trigger('change') $('#type').val('').trigger('change') $('#filter-age').val('').trigger('change') $('#filter-data').val('').trigger('change') $('#customer-actions').val('').trigger('change') $('#my_record_filter').prop('checked', false); addFilterListener(); refreshTableCustomer(); }) $('#proceed-button').on("click", function() { // alert('fire'); return; if (new_customer_is_individual) { if (isEmpty($('#mod-firstname').val())) { addCustomerModalTabSelectedTab(1); $('#mod-firstname').focus(); sweetAlertSimple('error', 'Oops...', 'Firstname can\'t be left blank') return; } if (isEmpty($('#mod-lastname').val())) { addCustomerModalTabSelectedTab(1); $('#mod-lastname').focus(); sweetAlertSimple('error', 'Oops...', 'Lastname can\'t be left blank') return; } if (!isEmpty($('#mod-birthdate').val())) { cust_dob = new Date($('#mod-birthdate').val()); var cust_today = new Date(); var cust_age = Math.floor((cust_today-cust_dob) / (365.25 * 24 * 60 * 60 * 1000)); // alert(cust_age+' years old'); if(parseInt(cust_age) < 17 ){ addCustomerModalTabSelectedTab(1); $('#mod-birthdate').focus(); sweetAlertSimple('error', 'Oops...', 'Age must be 17 and above.') return; } } } else { if (isEmpty($('#mod-corporation-name').val())) { addCustomerModalTabSelectedTab(1); $('#mod-corporation-name').focus(); sweetAlertSimple('error', 'Oops...', 'Corporation name can\'t be left blank') return; } } if (!checkIfDataSourceIncomplete() && $('#data-source-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(1); $('#data-source-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the data source details first'); return; } if (new_customer_is_individual) { if (isEmpty($('#mod-contact').val())) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', 'Mobile number is required'); return; } if ($('#mod-contact').val().length < 10 || !$('#mod-contact').val().startsWith("9")) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } } else { if (isEmpty($('#mod-contact').val()) && isEmpty($('#mod-landline').val())) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', 'Mobile number or landline is required'); return; } if (!isEmpty($('#mod-contact').val())) { if ($('#mod-contact').val().length < 5) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } } } // if (isEmpty($('#mod-email').val())) { // addCustomerModalTabSelectedTab(2); // $('#mod-email').focus(); // sweetAlertSimple('error', 'Oops...', 'Email address is required'); // return; // } // if (!isEmail($('#mod-email').val())) { // addCustomerModalTabSelectedTab(2); // $('#mod-email').focus(); // sweetAlertSimple('error', 'Oops...', 'Invalid email address'); // return; // } if (!isEmpty($('#mod-email').val())) { if (!isEmail($('#mod-email').val())) { addCustomerModalTabSelectedTab(2); $('#mod-email').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid email address'); return; } } if($('#mod-email').val() =='') { addCustomerModalTabSelectedTab(2); $('#mod-email').focus(); sweetAlertSimple('error', 'Oops...', 'Email address required'); return; } // if (!isEmpty($('#mod-other-email').val())) { // if (!isEmail($('#mod-other-email').val())) { // addCustomerModalTabSelectedTab(2); // $('#mod-other-email').focus(); // sweetAlertSimple('error', 'Oops...', 'Invalid other email address'); // return; // } // } var validate_data_contact_person = checkIfContactPersonIncomplete(); if (!validate_data_contact_person[0] && $('#contact-person-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(2); $('#contact-person-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the data of contact person first') return; } else if (!validate_data_contact_person[1]) { addCustomerModalTabSelectedTab(2); $('#contact-person-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Contact person invalid email') return; } else if (!validate_data_contact_person[2]) { addCustomerModalTabSelectedTab(2); $('#contact-person-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Contact person invalid mobile') return; } // if (isEmpty($('#mod-address-1').val())) { // addCustomerModalTabSelectedTab(2); // $('#mod-address-1').focus(); // sweetAlertSimple('error', 'Oops...', 'Primary address is required'); // return; // } // if (isEmpty($('#mod-dd-city-1').val())) { // addCustomerModalTabSelectedTab(2); // $('#mod-dd-city-1').focus(); // sweetAlertSimple('error', 'Oops...', 'Primary city is required'); // return; // } // if (!isEmpty($('#mod-address-2').val()) && isEmpty($('#mod-dd-city-2').val())) { // addCustomerModalTabSelectedTab(2); // $('#mod-dd-city-2').focus(); // sweetAlertSimple('error', 'Oops...', 'Select secondary city'); // return; // } if (!isEmpty($('#mod-dd-city-2').val())) { if (isEmpty($('#mod-address-2').val())) { addCustomerModalTabSelectedTab(2); $('#mod-address-2').focus(); sweetAlertSimple('error', 'Oops...', 'Enter secondary address'); return; } } var validate_data_children_list = checkIfChildrenIncomplete(); if (!validate_data_children_list[0] && $('#children-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(3); $('#children-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the child details first'); return; } else if (!validate_data_children_list[1]) { addCustomerModalTabSelectedTab(3); $('#children-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Children data invalid mobile'); return; } if (!checkIfInterestIncomplete() && $('#interest-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(5); $('#interest-list-table select').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the interest/hobbies details first'); return; } if (!checkIfAffiliationsIncomplete() && $('#affiliations-list-table tbody tr').length > 0) { addCustomerModalTabSelectedTab(4); $('#affiliations-list-table select').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the affiliations details first'); return; } // /check exist the input if($('#mod-other-mobile-number1').length > 0 && $('#mod-other-mobile-number1').val() != '') { $(this).attr("required", "true"); if ($('#mod-other-mobile-number1').val().length < 10 || !$('#mod-other-mobile-number1').val().startsWith("9")) { addCustomerModalTabSelectedTab(2); alert('error other mobile contact');return; $('#mod-other-mobile-number1').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } if($('#mod-other-mobile-number1').val().length > 10) { // $('#mod-other-mobile-number1').val(''); $('#mod-other-mobile-number1').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } if($('#mod-other-mobile-number1').val() == $('#mod-contact').val()) { sweetAlertSimple('error', 'Oops...', 'Duplicate mobile number'); return; } }else if($('#mod-other-mobile-number1').length ===1 && $('#mod-other-mobile-number1').val()===''){ // console.log('accept validation');return; $("#mod-other-mobile-number1").prop('required',true); sweetAlertSimple('error', 'Oops...', 'Field required.'); $('#mod-other-mobile-number2').focus(); return; } else { } if($('#mod-other-mobile-number2').length > 0 && $('#mod-other-mobile-number2').val() != '') { // console.log('accept validation');return; if($('#mod-other-mobile-number2').val().length < 10 || !$('#mod-other-mobile-number2').val().startsWith("9")) { addCustomerModalTabSelectedTab(2);alert('error other mobile contact'); $('#mod-other-mobile-number2').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } if($('#mod-other-mobile-number1').val() == $('#mod-other-mobile-number2').val()) { sweetAlertSimple('error', 'Oops...', 'Duplicate mobile number'); return; } if($('#mod-other-mobile-number2').val() == $('#mod-contact').val()) { sweetAlertSimple('error', 'Oops...', 'Duplicate mobile number'); return; } if($('#mod-other-mobile-number1').val().length > 10) { // $('#mod-other-mobile-number1').val(''); $('#mod-other-mobile-number1').focus(); sweetAlertSimple('error', 'Oops...', 'Invalid mobile number'); return; } } else if($('#mod-other-mobile-number2').length ===1 && $('#mod-other-mobile-number2').val()===''){ // console.log('accept validation');return; $("#mod-other-mobile-number2").prop('required',true); sweetAlertSimple('error', 'Oops...', 'Field required.'); $('#mod-other-mobile-number2').focus(); return; } else { console.log('dito'+$('#mod-other-mobile-number2').length); $('#mod-other-mobile-number2').attr("required", "false"); $('#mod-other-mobile-number2').removeAttr('required'); } // alert(force_update+ ' - '+force_update_reason); // console.log(getAllContactPersonTableData());return; $.ajax({ url: "api/customer/customerv2_update.php", method: "POST", dataType: 'json', data: { apiKey: '7347482808054211', customer_data: getCustomerAllModalData(), customer_dms: getAllDataSourceTableData(), customer_contact_person: getAllContactPersonTableData(), customer_children: getAllChildrenTableData(), customer_interest: getAllInterestTableData(), customer_affiliations: getAllAffiliationsTableData(), force_update : force_update, force_update_reason:force_update_reason }, beforeSend: function() { //show loader $('#proceed-button').attr('disabled', true); $('.customer-modal-overlay').show(); }, success: function(result) { if (parseInt(result.status) === 1) { sweetAlertSimple('success', 'Nice...', result.message); refreshTableCustomer(); $('#modal-customer').modal('hide'); } else if (parseInt(result.status) === 0) { sweetAlertSimple('error', 'Oops...', result.message); } else if (parseInt(result.status) === 2) { addCustomerModalTabSelectedTab(2); $('#mod-contact').focus(); sweetAlertSimple('error', 'Oops...', result.message); if(customer_force_edit){ Swal.fire({ title: 'Update anyway?', input: 'textarea', inputPlaceholder: 'Enter your reason', confirmButtonText: `Save`, showCancelButton: true, inputValidator: (value) => { if (!value) { return 'Enter your reason to proceed.' }else{ force_update = 1; force_update_reason = value; $('#proceed-button').click(); } } }); } } else if (parseInt(result.status) === 3) { addCustomerModalTabSelectedTab(2); $('#mod-email').focus(); sweetAlertSimple('error', 'Oops...', result.message); if(customer_force_edit){ Swal.fire({ title: 'Update anyway?', input: 'textarea', inputPlaceholder: 'Enter your reason', confirmButtonText: `Save`, showCancelButton: true, inputValidator: (value) => { if (!value) { return 'Enter your reason to proceed.' }else{ force_update = 1; force_update_reason = value; $('#proceed-button').click(); } } }); } } else if (parseInt(result.status) === 4) { addCustomerModalTabSelectedTab(1); $('#data-source-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', result.message); } refreshModalReligion(); // refreshModalCities(); $('#proceed-button').attr('disabled', false); $('.customer-modal-overlay').hide(); force_update = 0; force_update_reason = ''; }, error: handleError }); }); $('#aha-status').on('change',function(){ if($(this).is(':checked')){ $(this).val('1'); }else{ $(this).val('0'); } }); $("#btn-add-mobile").on('click', function(){ // var count = $("#countInputMobile").val(); // count++; let inputMobLengh = $('.mod-div input[name="mob[]"]').length; // alert(inputMobLengh); if(inputMobLengh<2){ let divGrid = $('<div></div>').attr({'class':'mod-div'}); let inputGroup = $('<div></div>').attr({'class':'input-group mb-0 input-other-mob'}); let inputBtl = $('<div></div>').attr({'class' : 'edit-customer input-group-append'}).css("height", "28px");; let inputText = $('<div></div>').attr({'class':'input-group-text'}).text("+63"); let inputjson = $('<input>').attr({'name':'mob[]','id':'mod-other-mobile-number','class':'big-letter edit-customer lbl-forms-sm form-control form-control-sm inputMobile', 'id':'mod-other-mobile-number2','type':'number','maxlength':'10','json-modal':'true'}); let label = $('<label></label>').attr({'for': 'Other Mobile','class':'lbl-forms mx-0 my-0'}).text("Other Mobile"); $(inputBtl).append(inputText); let deleteSPan = $('<a><i class="fas fa-minus-circle"></i></a>').attr({'class':'customDeleleBtn float-right text-danger'}).click(function(e){ // count--; // $("#countInputMobile").prop("value",count); $(this).closest('.mod-div').remove(); inputMobLengh = inputMobLengh-1; if(inputMobLengh<2){ $("#btn-add-mobile").show(); } else { $("#btn-add-mobile").hide(); } $('#mod-contact-div input[name="mob[]"]').each(function(index){ $(this).attr('id',"mod-other-mobile-number"+(index+1)); }); }); //end delete $(inputGroup).append(inputBtl,inputjson,deleteSPan); $(divGrid).append(label,inputGroup); $("#mod-contact-div").append(divGrid); // $("#countInputMobile").val(count); $('#mod-contact-div input[name="mob[]"]').each(function(index){ $(this).attr('id',"mod-other-mobile-number"+(index+1)); }); // alert(inputMobLengh); if(inputMobLengh>=1){ $("#btn-add-mobile").hide(); } else{ $("#btn-add-mobile").show(); } } //end if }); $("#btn-add-email").on('click', function(){ // var count = $("#countInputMobile").val(); // count++; let inputEmailCount =$('#email-add input[name="mob-email[]"]').length; if(inputEmailCount<2){ let divGrid = $('<div></div>').attr({'class':'col-sm-12 mb-1 div-email'}); let inputGroup = $('<div></div>').attr({'class':'form-group mb-0'}); let inputGroup2 = $('<div></div>').attr({'class':'input-group'}); let label = $('<label></label>').attr({'class':'lbl-forms mx-0 my-0'}).text("Other Email"); let inputjson = $('<input>').attr({'name':'mob-email[]','id':'mod-other-email','class':'big-letter edit-customer lbl-forms-sm form-control form-control-sm inputMobile','type':'email','json-modal':'true'}); let deleteSPan = $('<a><i class="fas fa-minus-circle"></i></a>').attr({'class':'customDeleleBtn float-right text-danger','required':true}).click(function(e){ inputEmailCount = inputEmailCount-1; // $("#countInputMobile").prop("value",count); if(inputEmailCount>=1){ $("#btn-add-email").hide(); } else{ $("#btn-add-email").show(); } // alert('fire') $(this).closest('.div-email').remove(); $('#email-add input[name="mob-email[]"]').each(function(index){ // $(this).attr('id',"mod-other-mobile-number"+(index+1)); $(this).attr('id',"mod-other-email"+(index+1)); }); }); //end delete $(inputGroup2).append(inputjson,deleteSPan); $(inputGroup).append(label,inputGroup2); $(divGrid).append(inputGroup); $('#email-add').append(divGrid); if(inputEmailCount>=1){ $("#btn-add-email").hide(); } else{ $("#btn-add-email").show(); } $('#email-add input[name="mob-email[]"]').each(function(index){ $(this).attr('id',"mod-other-email"+(index+1)); }); } //end if }); }); function company() { $.ajax({ url: "api/customer_update/assign_dealer.php", type: "POST", dataType: 'json', data: { apiKey: 'mRLAZ8te7cnv', }, beforeSend: function() {}, success: function(result) { $("#sl_company").val(''); $.each(result, function(key, value) { $('#sl_company') .append($("<option></option>") .attr("value",value.id) .text(value.text)); }); } }); } company(); $("#sl_company").on('change', function(){ $("#sl_dealer").empty(); if($(this).val()!=''){ $("#sl_dealer").prop( "disabled", false ); $("#batchNo").prop("disabled",false); $("#sl_cu_city").prop('disabled',false); $("#sl_cu_city").attr('disabled',false); } else { $("#sl_dealer").prop( "disabled", true ); } $.ajax({ url: "api/customer_update/assign_dealer.php", type: "POST", dataType: 'json', data: { apiKey: 'f5AHTwg8MF9c', cid:$(this).val() }, beforeSend: function() {}, success: function(result) { $.each(result, function(key, value) { $('#sl_dealer') .append($("<option></option>") .attr("value",value.id) .text(value.text)); }); $("#sl_dealer").val(''); } }); }); // $("#sl_dealer").on('change', function(){ // $("#sl_user").empty(); // if($(this).val()!=''){ // $("#sl_user").prop( "disabled", false ); // } // else // { // $("#sl_user").prop( "disabled", true ); // } // $.ajax({ // url: "api/customer_update/assign_dealer.php", // type: "POST", // dataType: 'json', // data: { // apiKey: 'L9T6kZfc8K4D', // cdi:$(this).val() // }, // beforeSend: function() {}, // success: function(result) { // $.each(result, function(key, value) { // $('#sl_user') // .append($("<option></option>") // .attr("value",value.id) // .text(value.text)); // }); // $("#sl_user").val(''); // } // }); // }); $("#sl_dealer").on('change', function(){ $("#no_assign").val(''); if($(this).val()!=''){ $("#no_assign").prop( "disabled", false ); } else { $("#no_assign").prop( "disabled", true ); } }); function autoAssign(apy) { $("#spinner-loader").show(); $('.fieldset').prop('disabled', true) $(":button").prop('disabled',true); $("#assign_to_dealers").hide(); $("#spinner-loader").show(); $.ajax({ url: "api/customer_update/assign_dealer.php",//"api/customer_update/customerv2_update.php", type: "POST", dataType: 'json', data: { apiKey: apy, // cdi:$(this).val() }, // beforeSend: function() {}, // beforeSend: function(xhr) { // // Show loader before the request starts // $("#spinner-loader").show(); // $('.fieldset').prop('disabled', true); // $(":button").prop('disabled', true); // $("#assign_to_dealers").hide(); // // Track progress // // Check if xhr.upload is defined before adding the event listener // if (xhr.upload) { // xhr.upload.addEventListener("progress", function(evt) { // if (evt.lengthComputable) { // var percentComplete = (evt.loaded / evt.total) * 100; // console.log(percentComplete + "%"); // // Update the progress bar or display the percentage as needed // } // }, false); // } // }, complete: function(){ $("#spinner-loader").hide(); $('.fieldset').prop('disabled', false) $(":button").prop('disabled',false); $("#assign_to_dealers").show(); }, success: function(result) { if(result.status==0){ Swal.fire({ icon: 'warning', title: 'Oops!', text: result.msg, allowEnterKey: true // default value }); } if(result.status==1){ Swal.fire({ icon: 'success', title: 'Success!', text: result.no_assign+' '+result.msg+' '+result.no_of_dealers+' '+result.dealer, allowEnterKey: true // default value }); location.reload(); } } }); } function resetAssign(apy) { Swal.fire({ title: 'Are you sure?', text: "You are about to execute this command. Do you want to proceed?", icon: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: 'Yes, execute it!' }).then((result) => { if (result.isConfirmed) { $("#spinner-loader").show(); $('.fieldset').prop('disabled', true) $(":button").prop('disabled',true); $("#reset-assignment").hide(); $("#spinner-loader-purple").show(); $.ajax({ url: "api/customer_update/assign_dealer.php",//"api/customer_update/customerv2_update.php", type: "POST", dataType: 'json', data: { apiKey: apy, // cdi:$(this).val() }, // beforeSend: function() {}, // beforeSend: function(xhr) { // }, complete: function(){ $("#spinner-loader-purple").hide(); $('.fieldset').prop('disabled', false) $(":button").prop('disabled',false); $("#reset-assignment").show(); }, success: function(result) { if(result.status==0){ Swal.fire({ icon: 'warning', title: 'Oops!', text: result.msg, allowEnterKey: true // default value }); } if(result.status==1){ Swal.fire({ icon: 'success', title: 'Success!', text: result.no_assign+' '+result.msg+' '+result.no_of_dealers+' '+result.dealer, allowEnterKey: true // default value }); location.reload(); } } }); } }); } // $(document).on('change', '.usr-id', function() { // let hdr = $(this).closest('tr').find('.hdr').val(); // let did = $(this).closest('tr').find('.did').val(); // $.ajax({ // url: "api/customer_update/assign_dealer.php", // type: "POST", // dataType: 'json', // data: { // apiKey: $("#ausr-py").val(), // uid:$(this).val(), // hdr:hdr, // did:did, // }, // success: function(result) { // if(result.status==1) // { // Swal.fire({ // icon: 'success', // title: 'Success!', // text: result.msg, // allowEnterKey: true // default value // }); // setTimeout(()=>{ // // location.reload(); // },3000); // } // if(result.status==0){ // Swal.fire({ // icon: 'warning', // title: 'Oops!', // text: result.msg, // allowEnterKey: true // default value // }); // } // } // }); // }); function relodMdl() { location.reload(); } function loadDealers(apy){ $.ajax({ url: 'api/customer_update/assign_dealer.php', method: 'POST', data: {apiKey:apy }, success: function(response) { $('#table_dlr tbody').empty(); // Parse JSON response var dealers = JSON.parse(response); // Loop through each dealer object and append to the table $.each(dealers, function(index, dealer) { console.log(dealer); var row = $("<tr>"); row.append($("<td>").text(index+1)); row.append($("<td>").text(dealer.text)); row.append($("<td>").html("<input type='checkbox' class='chk-active-dlr' "+dealer.check+" value='" + dealer.id + "'/>")); row.append($("<td>").html("")); $('#table_dlr tbody').append(row); }); $('#table_dlr').DataTable({ // "scrollY": "300px", // Set fixed height with scrolling // "lengthMenu": false,//remove select result "paging": true, // Enable pagination "searching": true, // Enable search bar "pagingType": "simple_numbers", // Use buttons for pagination "language": { "paginate": { "previous": "<", "next": ">" } } }); }, error: function(xhr, status, error) { console.error(error); // Log any errors } }); } //select ALL CITY $("#select-all-btn-cities").on('click', function(){ $('#sl_cu_city option').prop('selected', true); $('#sl_cu_city').trigger('change'); // Select all options }); //clear all selected cities $("#clear-all-btn-cities").on('click', function(){ $('#sl_cu_city option').prop('selected', false); $('#sl_cu_city').trigger('change'); // Trigger change event if necessary }); $("#btn-submit-manually").on('click', function(e) { var selectCities = $("#sl_cu_city"); if(selectCities && selectCities.find("option:selected").length === 0){ // console.log('city is empty'); Swal.fire({ icon: 'warning', title: 'Oops!', text: " DB source city field is required.", allowEnterKey: true // default value }); return; } $(this).prop('disabled',true); e.preventDefault(); $.ajax({ url: "api/customer_update/assign_dealer.php", type: "POST", dataType: 'json', data: { apiKey: $("#apiy").val(), cty : selectCities.val(), btno:$("#batchNo").val(), cm: $("#sl_company").val(), dlr: $("#sl_dealer").val(), usr: $("#sl_user").val(), nos: $("#no_assign").val() }, beforeSend: function() { $('#loader-main').show(); }, success: function(result) { if(result.status==1) { Swal.fire({ icon: 'success', title: 'Success!', text: result.nos+' '+result.msg+' '+result.dealer, allowEnterKey: true // default value }); setTimeout(()=>{ location.reload(); },1300); }else{ Swal.fire({ icon: 'warning', title: 'Oops!', text: result.msg, allowEnterKey: true // default value }); } $("#btn-submit-manually").prop('disabled',false); } }); }); $('#table_dlr').on('click', '.chk-active-dlr', function() { let dlr_id=[]; let active =($(this).is(':checked') ? 1 : 0); let data ={'did':$(this).val(),'active':active}; dlr_id.push(data); }); function chkAll() { let active = ($("#chk_all").is(':checked')) ? 0 : 1; // Determine active status dlr_id = []; // Clear the array // Iterate over all pages of DataTables $('#table_dlr').DataTable().rows().every(function(rowIdx, tableLoop, rowLoop) { // Get the data for each row let data = rowIdx;//this.data(); // Find the checkbox within the row let checkbox = $(this.node()).find('.chk-active-dlr'); // Set the checked state for each checkbox checkbox.prop('checked', active); // Push each checkbox's data into the dlr_id array dlr_id.push({'did': data, 'active': active}); }); console.log(dlr_id); } function exl_dlr() { let dlr_id= []; let active =1; $('#table_dlr').DataTable().rows().every(function(rowIdx, tableLoop, rowLoop) { // Get the data for each row (assuming you need this) let rowData = this.data(); // Find the checkbox within the row let checkbox = $(this.node()).find('.chk-active-dlr'); // Get the value of the checkbox let value = checkbox.val(); // Check if the checkbox is checked let active = (checkbox.is(':checked')) ? 0 : 1; // Push each checkbox's data into the dlr_id array dlr_id.push({'did': value, 'active': active}); }); $.ajax({ url: "api/customer_update/assign_dealer.php", type: 'POST', dataType: 'json', // data: {apiKey:excl_py,attr:active,did:$(this).val()}, data: {apiKey:excl_py,attr:dlr_id}, success: function(response) { if(response.status==1) { Swal.fire({ icon: 'success', title: 'Success!', text: response.msg, allowEnterKey: true // default value }); setTimeout(()=>{ Swal.close() ; // setTimeout(function () { // Swal.close() // }, 2000) },3000); }else{ Swal.fire({ icon: 'warning', title: 'Oops!', text: response.msg, allowEnterKey: true // default value }); } }, error: function(error) { console.error(error); // Log any errors } }); } // } $("#assign_to_dealers").hide(); $("#fieldset-assign").hide(); function swichAssignment() { $('#toggleForms').change(function() { var label = $(this).prop('checked') ? 'Auto' : 'Manual'; $(this).siblings('.custom-control-label').text(label + ''); $(this).siblings('.fieldset-form').text(label + ''); if(label ==='Auto') { $("#assign_to_dealers").show(); $("#fieldset-assign").hide(); } if(label ==='Manual') { $("#assign_to_dealers").hide(); $("#fieldset-assign").show(); } }); } $(document).ready(function(){ $(document).on('click', '.btn-dealer-users', function() { // var didUsersValue = $(this).siblings('.modal-content').find('.did_users').val(); let dealer_id = $(this).attr("data-id"); let dealer_hdr = $(this).attr("data-hdr"); console.log(dealer_id+' '+dealer_hdr); $.ajax({ url: "api/customer_update/assign_dealer.php", type: 'POST', dataType: 'json', // data: {apiKey:excl_py,attr:active,did:$(this).val()}, data: {apiKey:apy,hdr: dealer_hdr,dealer_id : dealer_id}, success: function(response) { var isChecked =''; const userID=[]; const userNoDB=[]; $.each(response.users_in_cu_assigned,function(i,user_id){ userID.push(user_id); userNoDB.push(user_id['total_assigned']); }); console.log(userID); delete response.users_in_cu_assigned; delete response.user_total_assigned_db; $('.modal-body-user').empty(); $('.div-user').empty(); $(this).closest('.modal').find(".dealer_hdrs").empty(); $(this).closest('.modal').find(".daeler_ids").empty(); $(this).closest('.modal-body-user').html(''); // if($.isEmptyObject(response)){ // alert('empty'); // } // console.log(userNoDB); // console.log(userID);return; if(!$.isEmptyObject(response)){ $(".btn-save-users").prop('disabled',false); var divRowDealerInfo = $('<div></div>').addClass('row div-label').css('padding-top','1rem').css('padding-bottom','1rem').css('margin-bottom','10px'); var divRowLable = $('<div></div>').addClass('row div-label').css('padding-top','1rem').css('padding-bottom','1rem').css('margin-bottom','10px'); var actionLabel = $('<div></div>').addClass('col-md-1 ').text('Action').css('font-weight','Bold').css('font-size','15px'); var no_of_db_label = $('<div></div>').addClass('col-md-2 nodColumn').text('No of Database').css('font-weight','Bold').css('font-size','15px'); var gmsm_label= $('<div></div>').addClass('col-md-9').text("GM/SM").css('font-weight','Bold').css('font-size','15px').css('padding-left','1rem'); divRowLable.append(actionLabel,no_of_db_label,gmsm_label); $('.modal-body-user').append(divRowLable); $.each(response, function(e, v) { let currentAssignedDB = ''; let isChecked = false; // Initialize isChecked to false outside the loop // Check each element in userID for matching employee_id for (let i = 0; i < userID.length; i++) { if (userID[i] && typeof userID[i] === 'object' && userID[i]['user_id'].includes(`${v.employee_id}`)) { isChecked = true; currentAssignedDB = userID[i]['total_assigned']; console.log('true ' + userID[i]['user_id'] + ' ' + currentAssignedDB); break; // Exit the inner loop after finding a match } } // Create DOM elements based on the isChecked value var divRow = $('<div></div>').addClass('row div-user'); var checkColumn = $('<div></div>').addClass('col-md-1 '); var nodColumn = $('<div></div>').addClass('col-md-2 nodColumn'); var labelColumn = $('<div></div>').addClass('col-md-9'); var label = $('<label></label>').addClass('lbl-forms form-control').attr('for', 'employee').text(v.employee_name +' - '+v.position); if (isChecked) { var inputCheck = $('<input>').addClass('userID').attr({ 'name': 'userID[]', 'id': 'userID', 'type': 'checkbox','disabled':'disabled'}).val(v.employee_id).prop('checked', isChecked); var inputNoOfDb = $('<span>').attr({'name':'dealer_no_db','placeholder':'Enter no of DB','id':'dealer_no_db','class':'badge'}).text(currentAssignedDB).css('width','110px').css('background-color','#f9ce69').css('margin-top','10px'); } else { var inputCheck = $('<input>').addClass('userID').attr({ 'name': 'userID[]', 'id': 'userID', 'type': 'checkbox','disabled':'disabled'}).val(v.employee_id).prop('checked', isChecked).css('opacity','0.2'); var inputNoOfDb = $('<input>').attr({'name':'dealer_no_db','placeholder':'Enter no of DB','id':'dealer_no_db','required':'required','class':'form-control dealer_no_db','type':'number'}).val(currentAssignedDB).css('width','110px'); } let inputHdr = $('<input>').attr({'name':'dealer_hrd','id':'dealer_hrd','class':'form-control-sm dealer_hdrs','type':'hidden'}).val(dealer_hdr); let inputDid = $('<input>').attr({'name':'dealer_id','id':'dealer_id','class':'form-control-sm dealer_ids','type':'hidden'}).val(dealer_id); inputCheck.css('margin-top', '13px'); // Adjust this value to center the checkbox vertically label.css('margin-left', '-10px'); // Move the label element to the left by 10 pixels label.css('font-size', '16px'); label.css('border', 'none'); label.css('font-style','Italic'); nodColumn.append(inputNoOfDb); checkColumn.append(inputCheck); labelColumn.append(label); divRow.append(checkColumn,nodColumn, labelColumn); $('.modal-body-user').append(divRow,inputHdr,inputDid); }); } else { $(".btn-save-users").prop('disabled',true); $('#UserModal').modal('hide'); var SpanWarning = $('<span></span>').addClass('col-md-12 badge badge-warning').text("No users are available in this dealer."); $('.modal-body-user').append(SpanWarning); // Swal.fire({ // icon: 'warning', // title: 'Warning!', // text: "There is no avilable user to assign", // // allowEnterKey: true // default value // }); } }, error: function(error) { console.error(error); // Log any errors } }); }); // let uidarr = []; // $(document).on('click', '.userID', function() { // let currnetValue = $(this).val(); // if($(this).is(":checked")){ // uidarr= uidarr.concat(currnetValue); // $(this).closest('.modal').find('.nodColumn').show(); // $(this).closest('.modal').find('.nodColumn').focus(); // $(this).closest('.modal').find('.dealer_no_db').attr('required', true); // } // else // { // uidarr = uidarr.filter(element => element !== currnetValue); // $(this).closest('.modal').find('.nodColumn').hide(); // $(this).closest('.modal').find('.dealer_no_db').attr('required', false); // } // var hdrValue = $(this).closest('.modal').find('.dealer_hdrs').val(); // var didUsersValue = $(this).closest('.modal').find('.dealer_ids').val(); // //SALES MANAGER // $('.btn-save-users').off('click').on('click', function() { // var didUsersNoDB = $(this).closest('.modal').find('.dealer_no_db').val(); // if(isNaN(didUsersNoDB) || didUsersNoDB.trim() === ''){ // Swal.fire({ // icon: 'warning', // title: 'Oops!', // text: 'No of DB field is required', // allowEnterKey: true // default value // }); // } // else{ // var didUsersNoDB = $(this).closest('.modal').find('.dealer_no_db').val(); // Swal.fire({ // title: 'Are you sure?', // text: "You are about to execute this command. Do you want to proceed?", // icon: 'warning', // showCancelButton: true, // confirmButtonColor: '#3085d6', // cancelButtonColor: '#d33', // confirmButtonText: 'Yes, execute it!' // }).then((result) => { // if (result.isConfirmed) { // assignUsers([hdrValue, didUsersValue, uidarr, didUsersNoDB]); // } // }); // } // }); // }); $(document).on('keyup', '.dealer_no_db', function() { let currentCHK = $(this).closest('.div-user').find('.userID'); if ($(this).val() > 0) { currentCHK.prop('disabled', false); currentCHK.css({ 'opacity': '100', 'border': '2px solid black' }); currentCHK.prop('checked', false); // Uncheck the nearby checkbox } else { currentCHK.prop('disabled', true); currentCHK.prop('checked', false); // Uncheck the nearby checkbox currentCHK.css('opacity', '0.2'); } }); let userData = []; // Define userData array to store user data $(document).on('click', '.userID', function() { userData = []; let container = $(this).closest('.modal-body-user'); let currnetValue = $(this).val(); let no_of_db = 0; // Default value let hdr_value = container.find('.dealer_hdrs').val(); let dealer_value = container.find('.dealer_ids').val(); if ($(this).is(":checked")) { // Find the no_of_db input relative to the checkbox that was checked no_of_db = $(this).closest('.div-user').find('.dealer_no_db').val(); // Add user data to userData array if checkbox is checked and no_of_db is filled userData.push([currnetValue, no_of_db, hdr_value, dealer_value]); // $(this).closest('.div-user').find('.nodColumn').show(); $(this).closest('.div-user').find('.dealer_no_db').attr('required', true); } else { // Remove user data from userData array if checkbox is unchecked userData = userData.filter(user => user[0] !== currnetValue); // $(this).closest('.div-user').find('.nodColumn').hide(); $(this).closest('.div-user').find('.dealer_no_db').attr('required', false); } // console.log(userData); }); $(document).on('click', '.btn-save-users', function() { if(userData.length ===0) { Swal.fire({ icon: 'warning', title: 'Oops!', text: 'Please tick the box if you want to assign a user.', allowEnterKey: true // default value }); return; } let noDBEmpty = false; $.each(userData, function(e, v) { // console.log(v[1]) if(isNaN(v[1]) || v[1].trim() == '') { noDBEmpty = true; // Set flag to true if empty no_of_db is found return false; } }); if (noDBEmpty) { Swal.fire({ icon: 'warning', title: 'Oops!', text: 'No of DB field is required and it must be whole number.', allowEnterKey: true // default value }); $(".userID").prop('checked', false); return; // Exit the function if any empty no_of_db is found } // console.log(userData);return; Swal.fire({ title: 'Are you sure?', text: "You are about to execute this command. Do you want to proceed?", icon: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: 'Yes, execute it!' }).then((result) => { if (result.isConfirmed) { // console.log(hdrValue);console.log(didUsersValue); console.log(uidarr);console.log(didUsersNoDB);return; // assignUsers([hdrValue, didUsersValue, uidarr, didUsersNoDB]); assignUsers(userData); } }); }); function assignUsers(userInfo) { $.ajax({ url: "api/customer_update/assign_dealer.php", type: "POST", dataType: 'json', data: { apiKey: $("#ausr-py").val(), user_data:userInfo }, success: function(result) { if(result.status==1) { Swal.fire({ icon: 'success', title: 'Success!', text: result.msg, allowEnterKey: true // default value }); // location.reload(); setTimeout(()=>{ location.reload(); },2500); } if(result.status==0){ Swal.fire({ icon: 'warning', title: 'Oops!', text: result.msg, allowEnterKey: true // default value }); } } }); } $("#sl_cu_city").on('change', function(){ $("#sl_company").prop('disabled',true); if($(this).val() != '') { $("#sl_company").prop('disabled',false); $("#sl_company").attr('disabled', false); } }); function load_city(){ $.ajax({ url: "api/customer_update/assign_dealer.php", type: "POST", dataType: 'json', data: { apiKey: 'L9T6kZfc8K4D', }, // beforeSend: function() {}, success: function(result) { $("#sl_cu_city").prop( "disabled", false ); // $("#sl_user").empty(); $.each(result, function(key, value) { var option = $("<option></option>") .attr("value", value.id) .text(value.text); $('#sl_cu_city').append(option); }); } }); } load_city(); const goBack = () => { window.history.back(); } });
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings