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/customerv2.php",
type: "POST",
dataType: 'json',
data: {
dms: dms,
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) {
// result.total
$('#total_customer_count').text(result.total_count);
$('#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_customer_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_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']").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 Customer (Individual)");
checkFieldsModal(true);
} else {
$('#modal-title').text("New Customer (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: `
`
});
$('#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() {
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 (!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;
}
//MODIFY
// /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
{
$('#mod-other-mobile-number2').attr("required", "false");
$('#mod-other-mobile-number2').removeAttr('required');
}
// END MODIFY
// alert(force_update+ ' - '+force_update_reason);
$.ajax({
url: "api/customer/customerv2.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');
}
});
// MODIFY
$("#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 = $('').attr({'class':'mod-div'});
let inputGroup = $('').attr({'class':'input-group mb-0 input-other-mob'});
let inputBtl = $('').attr({'class' : 'edit-customer input-group-append'}).css("height", "28px");;
let inputText = $('').attr({'class':'input-group-text'}).text("+63");
let inputjson = $('').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 = $('').attr({'for': 'Other Mobile','class':'lbl-forms mx-0 my-0'}).text("Other Mobile");
$(inputBtl).append(inputText);
let deleteSPan = $('').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 = $('').attr({'class':'col-sm-12 mb-1 div-email'});
let inputGroup = $('').attr({'class':'form-group mb-0'});
let inputGroup2 = $('').attr({'class':'input-group'});
let label = $('').attr({'class':'lbl-forms mx-0 my-0'}).text("Other Email");
let inputjson = $('').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 = $('').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-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
});
// END MODIFY
});