$(document).ready(function() { $(document).ajaxStart(function() { $(document.body).css({'cursor' : 'wait'}); }).ajaxStop(function() { $(document.body).css({'cursor' : 'default'}); }); $('#CustomerCSV').click(function() { UploadCustomers(); }) $('#ServicesCSV').click(function() { UploadServices(); }) $('#customer-button').click(function() { CustomerLogIn(); }) }); function ShowPaymentForm() { var service = $('input[name="service-selected"]:checked').attr('rel'); //console.log(service); $('#charge-amount').html('$'+service); $('#customerTwo').slideUp(); $('#customerThree').slideDown(); } function CustomerLogIn() { $('#customer-button').prop('disabled',true); $('#customer-button').toggleClass('disabled'); data = new FormData(); data.append( 'Email', $( '#customer-email' ).val() ); data.append( 'Code', $( '#customer-code' ).val() ); $.ajax({ type: 'POST', url: 'https://www.concordawning.com/Components/Customer/Assets/AJAX/CustomerLogin.php', processData: false, contentType: false, data : data, success: function(msg){ var ret = msg.split(':'); if (ret[0] == 1 && ret[2] != 0) { $('#mobile-number').val(ret[3]); $.ajax({ type: 'POST', url: 'https://www.concordawning.com/Components/Customer/Assets/AJAX/CustomerServices.php', data : 'id='+ret[1], success: function(msg){ var ret = msg.split(';;'); if (ret[0] == 1) { $('#customerOne').slideUp(); $('#customerServices').html(ret[1]); $('#customerTwo').slideDown(); $('#customer-button2').bind('mousedown',function() { ShowPaymentForm(); }); } else { $('#customer-button').prop('disabled',false); $('#customer-button').toggleClass('disabled'); $('#customerMessage').html('
'+ret[1]+'
'); setTimeout(function() { $('#customerMessage').html(''); }, 3000); } } }); } else { $('#customer-button').prop('disabled',false); $('#customer-button').toggleClass('disabled'); $('#customerMessage').html('
'+ret[1]+'
'); setTimeout(function() { $('#customerMessage').html(''); }, 3000); } } }); } function UploadCustomers() { //console.log($(this).val()); data = new FormData(); data.append( 'CSV', $( '#csvCustomer' )[0].files[0] ); $.ajax({ type: 'POST', url: 'https://www.concordawning.com/Components/Customer/Assets/AJAX/UploadCustomers.php', processData: false, contentType: false, data : data, success: function(msg){ var ret = msg.split(':'); if (ret[0] == 1) { $('#UploadMessage').html('
'+ret[1]+'
'); setTimeout( function(){ window.location.href = 'https://www.concordawning.com/admin/?task=Customer'; }, 1000); } else { $('#UploadMessage').html('
'+ret[1]+'
'); setTimeout(function() { $('#UploadMessage').html(''); }, 3000); } } }); } function UploadServices() { //console.log($(this).val()); data = new FormData(); data.append( 'CSV', $( '#csvService' )[0].files[0] ); data.append( 'Discount', $( '#discount' ).val() ); data.append( 'EndDate', $( '#enddate' ).val() ); $.ajax({ type: 'POST', url: 'https://www.concordawning.com/Components/Customer/Assets/AJAX/UploadServices.php', processData: false, contentType: false, data : data, success: function(msg){ var ret = msg.split(':'); if (ret[0] == 1) { $('#UploadMessage').html('
'+ret[1]+'
'); setTimeout( function(){ window.location.href = 'https://www.concordawning.com/admin/?task=Customer'; }, 1000); } else { $('#UploadMessage').html('
'+ret[1]+'
'); setTimeout(function() { $('#UploadMessage').html(''); }, 3000); } } }); }