File manager - Edit - /home/autoph/public_html/connectv1/dist/js/customer_update/dealer_assign_user.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 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"); if(count_customer_summary != null){ count_customer_summary.abort(); } count_customer_summary = $.ajax({ url: "api/customer_update/assign_dealer_user.php", //dealer_customerv2_update.php", type: "POST", dataType: 'json', data: { apiKey: '8666264351338448' }, beforeSend: function() {}, success: function(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' url: 'app/table/bt_dealer_assignment_user_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", 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 users(){ $("#sl_dealer").empty(); $("#sl_dealer").prop( "disabled", false ); $.ajax({ url: "api/customer_update/assign_dealer_user.php", type: "POST", dataType: 'json', data: {apiKey: apy,cdi:ucdi}, beforeSend: function() {}, success: function(result) { $("#sl_user").attr('required',true); $('#sl_user').append($('<option value=""></option>').text('Select User')); $.each(result, function(key, value) { $('#sl_user') .append($("<option></option>") .attr("value",value.id) .text(value.text)); }); } }); }users(); // 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 ); // } // 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(); // $.ajax({ // url: "api/customer_update/assign_dealer.php", // type: "POST", // dataType: 'json', // data: { // apiKey: $("#ausr-py").val(), // uid:$(this).val(), // hdr:hdr, // }, // success: function(result) { // if(result.status==1) // { // Swal.fire({ // icon: 'success', // title: 'Success!', // text: result.msg, // allowEnterKey: true // default value // }); // setTimeout(()=>{ // // location.reload(); // },3000); // }else{ // 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) { // 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 + "'/>")); // $('#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 // } // }); // } // $("#btn-submit-manually").on('click', function(e) { // e.preventDefault(); // $.ajax({ // url: "api/customer_update/assign_dealer.php", // type: "POST", // dataType: 'json', // data: { // apiKey: $("#apiy").val(), // cm: $("#sl_company").val(), // dlr: $("#sl_dealer").val(), // usr: $("#sl_user").val(), // nos: $("#no_assign").val() // }, // success: function(result) { // if(result.status==1) // { // setTimeout(()=>{ // Swal.fire({ // icon: 'success', // title: 'Success!', // text: result.nos+' '+result.msg+' '+result.dealer, // allowEnterKey: true // default value // }); // location.reload(); // },3000); // }else{ // Swal.fire({ // icon: 'warning', // title: 'Oops!', // text: result.msg, // allowEnterKey: true // default value // }); // } // } // }); // }); $(document).ready(function(){ function count_avl_cu() { $("#sl_source").attr('disabled',false); $("#sl_user").attr('disabled',false); $("#btn-submit-manually").attr('disabled',false); $.ajax({ url: "api/customer_update/assign_dealer_user.php", //dealer_customerv2_update.php", type: "POST", dataType: 'json', data: { apiKey: '8666264351338448' }, beforeSend: function() {}, success: function(result) { if(result.total_icu_assigned<=0) { $("#sl_source").attr('disabled',true); $("#sl_user").attr('disabled',true); $("#btn-submit-manually").attr('disabled',true); } else{ $('#total_customer_count').text("/"+ result.total_icu_assigned); a=result.total_icu_assigned.replace(/\,/g,''); total_avail_inactive=parseInt(a,10); if(total_avail_inactive ==0) { $("#no_assign").attr('disabled', true); $("#btn-submit-manually").attr('disabled', true); } else { $("#no_assign").attr({ "max" : total_avail_inactive, "min" : 1 }); $("#sl_user").attr('disabled',false); // $("#no_assign").attr('disabled', false); // $("#btn-submit-manually").attr('disabled', false); } } } }); } count_avl_cu(); function source() { $.ajax({ url: "api/customer_update/assign_dealer_user.php", //dealer_customerv2_update.php", type: "POST", dataType: 'json', data: { apiKey: spy }, beforeSend: function() {}, success: function(result) { $.each(result, function(key, value) { $('#sl_source') .append($("<option></option>") .attr("value",value.id) .text(value.text)); }); } }); } source(); $("#sl_source").on('change', function(){ $("#no_assign").attr('disabled', true); $("#btn-submit-manually").attr('disabled', true); $("#sl_user").attr('disabled', true); $.ajax({ url: "api/customer_update/assign_dealer_user.php", //dealer_customerv2_update.php", type: "POST", dataType: 'json', data: { apiKey: stpy, hdr:$(this).val() }, beforeSend: function() {}, success: function(result) { // a=result.total_avl_customer.replace(/\,/g,''); // total_available_customer=parseInt(a,10); if(parseInt(result.total_avl_customer)>0) { $("#no_assign").attr('disabled', false); $("#btn-submit-manually").attr('disabled', false); $("#sl_user").attr('disabled', false); } } }); }); $("#btn-submit-manually").on('click', function(e) { $("#btn-submit-manually").attr('disabled', true); e.preventDefault(); let shouldSubmit = true; Swal.fire({ title: 'Are you sure?', text: "You are about to assign a customer list to this user. Please ensure that the selected user is under your supervision or within your group under the same dealer to avoid conflicts arising from incorrect assignments.", icon: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: 'Yes, execute it!' }).then((result) => { if (result.isConfirmed) { // Check if the select box has a selected option if ($("#sl_user option:selected").val() === "") { Swal.fire({ icon: 'warning', title: 'Oops!', text: "User field is required.", allowEnterKey: true // default value }); $("#sl_user").focus(); $("#btn-submit-manually").attr('disabled', false); shouldSubmit = false; return false; } // If shouldSubmit is true, proceed with AJAX call if (shouldSubmit) { $.ajax({ url: "api/customer_update/assign_dealer_user.php", type: "POST", dataType: 'json', data: { apiKey: xtpy, hdr: $("#sl_source").val(), nos: $("#no_assign").val(), uid: $("#sl_user").val(), }, beforeSend: function() {}, success: function(response) { if(response.status == 1) { Swal.fire({ icon: 'success', title: 'Success!', text: response.msg, allowEnterKey: true // default value }); $("#btn-submit-manually").attr('disabled', false); setTimeout(() => { Swal.close(); location.reload(); }, 2500); } else { Swal.fire({ icon: 'warning', title: 'Oops!', text: response.msg, allowEnterKey: true // default value }); } } }); } } }); }); // $("#btn-submit-manually").on('click', function(e) { // e.preventDefault(); // let shouldSubmit = true; // Swal.fire({ // title: 'Are you sure?', // text: "You are about to assign a customer list to this user. Please ensure that the selected user is under your supervision or within your group under the same dealer to avoid conflicts arising from incorrect assignments.", // icon: 'warning', // showCancelButton: true, // confirmButtonColor: '#3085d6', // cancelButtonColor: '#d33', // confirmButtonText: 'Yes, execute it!' // }).then((result) => { // if (result.isConfirmed) { // if($("#sl_user").val() === "") // { // Swal.fire({ // icon: 'warning', // title: 'Oops!', // text: "User field is required.", // allowEnterKey: true // default value // }); // // users(); // // location.reload(); // $("#sl_user").focus(); // shouldSubmit = false; // return false; // } // $.ajax({ // url: "api/customer_update/assign_dealer_user.php", //dealer_customerv2_update.php", // type: "POST", // dataType: 'json', // data: { // apiKey: xtpy, // hdr: $("#sl_source").val(), // nos: $("#no_assign").val(), // uid: $("#sl_user").val(), // }, // beforeSend: function() {}, // success: function(response) { // if(response.status==1) // { // Swal.fire({ // icon: 'success', // title: 'Success!', // text: response.msg, // allowEnterKey: true // default value // }); // setTimeout(()=>{ // Swal.close() ; // location.reload(); // },2500); // }else{ // Swal.fire({ // icon: 'warning', // title: 'Oops!', // text: response.msg, // allowEnterKey: true // default value // }); // } // } // }); // } // }); // }); }); const goBack = () => { window.history.back(); }
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings