var dt = {}; var session; var bool = false; var json = []; $(function(){ dt.api = $("#api").val(); $c.waitDialog.start('Checking Session'); $(".header").hide(); check_session(); load_banks(); window.alert = $.promptMe.alert; window.confirm = $.promptMe.confirm; $("#deposit_date").datepicker({'endDate' : new Date()}); // if($("body").width()>=1400){ // $("#pos_transaction").css('margin-left','10%'); // } // window.onresize = function(){ // if($("body").width()>=1400){ // $("#pos_transaction").css('margin-left','10%'); // } // } $(".logo img").click(function(){ $("#active_processor").trigger("click"); }) }) t_columns = [ { 'field': '', 'title': 'Payment Date', 'width': '200px', 'className': '' }, { 'field': '', 'title': 'AR Number', 'width': '400px', 'className': '' }, { 'field': '', 'title': 'Amount', 'width': '150px', 'className': 'amount' }, { 'field': '','title': 'Mode of Payment', 'width' : '250px','className': 'text-center' }, { 'field': '','title': 'Processed By', 'width' : '400px','className': 'text-center' }, ]; dt.tx = $("#transactions").DataTable({ 'aoColumns': t_columns, // 'bStateSave': true, // 'bAutoWidth': true, searching: false, paging: false, 'scrollY': "170px", 'scrollCollapse':true, order: [[1,"desc"]], info: false, }); $(".square").on('click',function(e){ $('.square').removeClass('active'); $(this).addClass('active'); $("#check_payment,#direct_deposit_payment").hide(); $("#default_payment").show(); dt.payment = {}; dt.transaction.method = $(this).attr("id").toUpperCase().replace("_"," "); }); $("#check").on('click',function(){ dt.payment.pay_channel = '02'; $("#check_payment").show(); $("#default_payment").hide(); $("#payment_detail").fadeIn("fast"); $("#bank_name").focus(); scroll_bottom(); }); $("#gcash").on('click',function(){ dt.payment.pay_channel = '10'; $("#reference_number").parent().show(); $("#payment_detail").fadeIn(); $("#reference_number").focus(); scroll_bottom(); }); $("#paymaya").on('click',function(){ dt.payment.pay_channel = '11'; $("#reference_number").parent().show(); $("#payment_detail").fadeIn(); $("#reference_number").focus(); scroll_bottom(); }); $("#cash").on('click',function(){ dt.payment.pay_channel = '01'; $("#payment_detail").fadeIn(); $("#reference_number").val('').parent().hide(); $("#payment_amount").focus(); scroll_bottom(); }); $("#direct_deposit").on('click',function(){ dt.payment.pay_channel = '04'; $("#check_payment").hide(); $("#default_payment").hide(); $("#direct_deposit_payment").show(); $("#payment_detail").fadeIn("fast"); $("#bank_name").focus(); scroll_bottom(); }) $("#pay_now").on('click',function(){ check_session(); if(validate()){ if(dt.balance<=0){ alert('Payment',"Fully Paid",function(){ $(this).dialog('close'); $("#payment_amount").val(''); }); return; } if(parseFloat($("#payment_amount").val()) > dt.balance){ alert('Payment',"Cannot pay more than the expected balance",function(){ $(this).dialog('close'); $("#payment_amount").val(''); }); return; } if(parseFloat($("#payment_amount").val()) < 0){ alert('Payment',"Invalid amount",function(){ $(this).dialog('close'); $("#payment_amount").val(''); }); return; } dt.payment.amount = dt.transaction.method=="CHECK" ? $("#check_amount").val() : $("#payment_amount").val(); dt.payment.amount = dt.transaction.method=="DIRECT DEPOSIT" ? $("#dd_amount").val() : dt.payment.amount; dt.payment.reference_number = dt.payment.pay_channel=='01' ? "" : $("#reference_number").val(); dt.payment.session_id = dt.active_session.session_id; dt.payment.processor = dt.active_session.processor; dt.payment.registration_number = dt.registration_number; dt.payment.event_id = dt.event_id; dt.payment.registration_id = dt.registration_id; // dt.payment.congregation_id = dt.active_session.congregation_id; dt.payment.balance = dt.balance - parseFloat(dt.payment.amount); dt.payment.user_id = dt.active_session.user_id; //Build Message var message = "Registration Number: " + dt.registration_number.toUpperCase(); message += "
Name: " + dt.transaction.name_first + " " + dt.transaction.name_last; message += "
Event Name: " + $("#event_name").html(); //End Build Message if(dt.transaction.method=="CHECK"){ dt.payment.bank_name = $("#bank_name option:selected").text(); dt.payment.bank_code = $("#bank_name").val(); dt.payment.check_number = $("#check_number").val(); message += "
Amount: PHP "+ parseFloat(dt.payment.amount).format_comma(2); message += "
Bank Name: " + dt.payment.bank_name.toUpperCase(); // message += "
Bank Code: " + dt.payment.bank_code; message += "
Check Number: " + dt.payment.check_number; message += "
Payment Method: " + dt.transaction.method; } else if(dt.transaction.method == 'DIRECT DEPOSIT'){ dt.payment.bank_name = $("#dd_bank_name option:selected").text(); dt.payment.bank_code = $("#dd_bank_name").val(); dt.payment.reference_number = $("#dd_reference_number").val(); dt.payment.deposit_date = $("#deposit_date").val(); message += "
Amount: PHP "+ parseFloat(dt.payment.amount).format_comma(2); message += "
Bank Name: " + dt.payment.bank_name.toUpperCase(); message += "
DEPOSIT DATE: " + dt.payment.deposit_date; message += "
Reference Number: " + dt.payment.reference_number; message += "
Payment Method: " + dt.transaction.method; } else{ if(dt.payment.reference_number!=""){ message +="
Reference Number: " + dt.payment.reference_number.toUpperCase(); } message += "
Amount: PHP "+ parseFloat(dt.payment.amount).format_comma(2); message += "
Payment Method: " + dt.transaction.method; } //Payment Function confirm("Payment Verification",message,send_payment); } }); $("#btnsubmit").on('click',function(){ check_session(); if($("#ref_num").val()==""){ $("#ref_num").addClass('required'); return; } load_data($("#ref_num").val(),function(){ //Display Data $(".header-title").html('Payment'); $("#pos_transaction").show(); $("#pos_transaction_code").hide(); $("#reference_code").val($("#ref_num").val()); $("#reference_code2").text($("#ref_num").val()); $("#active_sessions").hide(); $("#payment_amount,#check_amount").val(''); $("#ref_num").val(''); $("#dd_amount").val(''); $("#dd_reference_number").val(''); dt.tx.draw(); $("#cash").trigger('click'); }); }); $("#a_back").on('click',function(){ $("#pos_processor").show(); $("#pos_transaction_code").hide(); clearInterval(session); }); $("#b_back").on('click',function(){ $("#pos_transaction").hide(); $("#pos_transaction_code").show(); $("#reference_code,#ref_num").val(''); $("#payment_detail").hide(); $(".square").removeClass('active'); $(".header-title").html('Registration'); check_session(); }); $("#back_button2").click(function(){ $("#pos_transaction").hide(); $("#pos_transaction_code").show(); $("#reference_code,#ref_num").val(''); $("#payment_detail").hide(); $(".square").removeClass('active'); $(".header-title").html('Registration'); check_session(); }) $("#back_button3").click(function(){ $("#c_back").trigger('click'); }) $("#c_back").on('click',function(){ $("#receipt_view").empty(); $("#display_receipt").hide(); if($(this).attr('goto')=="#transaction_list"){ $('.header-title').html('Transaction List'); } else{ $('.header-title').html('Payment'); } $($(this).attr('goto')).show(); scroll_bottom(); }); $("#new_session").on('click',function(){ get_session(dt.partial); $(".sess:gt(0)").remove(); $("#active_sessions").hide(); $('#pos_processor').show(); json = []; delete dt.partial; }); $("#ref_num").on('keyup',function(e){ if(e.which==13){ $("#btnsubmit").trigger('click'); } }); $("#volunteer_name").on('keyup',function(e){ if(e.which==13){ $("#btncontinue").trigger('click'); } }); $(document).on('click','.sess',function(){ if($(this).attr('id')=='new_session'){return;} var session_id = $(this).attr('session_id'); var session = $.session_retrieve(session_id); var datetime = new Date($(this).find('#session_datetime').text()) session.session_id = session_id; var message = "Volunteer Name: " + session.processor + "
Date and Time: " + datetime.toLocaleString(); $.promptMe.confirm("Do you want to use this session?",message, //Click OK function(){ $c.waitDialog.start(); $.ajax({ url: "pos/setSession", type: 'POST', data:session, success:function(d){ $(".sess:gt(0)").remove(); $("#active_sessions").hide(); json = []; $("#processor_name").text(d.userdata.processor); check_session(); add_session_detail(session_id); }, dataType:'json' }); $(this).dialog('close'); }, //Click Cancel function(){ $(this).dialog('close'); }) }); $("#ac_sessions").on('click',function(){ $(".dropdown-item").removeClass('active'); $(this).addClass('active'); clearInterval(session); bool = false; $(".page").hide(); $("#active_sessions").show(); }); $("#active_processor").on('click',function(){ $(".dropdown-item").removeClass('active'); $(".page").hide(); $("#transaction_list,#pos_transaction").hide(); $("#pos_transaction_code").show(); check_session(); }); $("#session_transactions").on('click',function(){ clearInterval(session); $(".header-title").html('Transaction List'); bool = false; $(".dropdown-item").removeClass('active'); $(this).addClass('active'); $("#pos_transaction_code").hide(); $('#pos_transaction').hide(); $("#receipt_view").empty(); $("#transaction_list").show(); var sess = {username: dt.active_session.username,session_id: dt.active_session.session_id }; load_transaction(sess); }); $("#transaction_today").on('click',function(){ clearInterval(session); bool = false; $(".dropdown-item").removeClass('active'); $(this).addClass('active'); $(".page").hide(); $("#transaction_list").show(); var sess = {username: $("#active_user").html() ,session_id: null }; load_transaction(sess); }); $("#btncontinue").on('click',function(){ if($("#volunteer_name").val()==""){ $("#volunteer_name").addClass('required'); return; } $c.waitDialog.stop('Saving Session'); $.ajax({ url: "pos/setSession", type: 'POST', data: { processor: $("#volunteer_name").val() }, success:function(d){ dt.active_session = d; $("#processor_name").text(d.userdata.processor); $("#logout").show(); // $("#cancel_sign_in").show(); $("#pos_processor").hide(); $('.header-title').html("Registration"); $("#pos_transaction_code").show(); $("#volunteer_name").val(""); save_session(); }, dataType:'json' }) }); $("#end_session").on('click',function(){ confirm('Close Session','Are you sure you want to end your session?

This will generate a Volunteer Turnover Report.',function(){ $c.waitDialog.start('Closing Session'); $(this).dialog('close'); session_data(); }); }) $("input.amount").on('keyup',function(_){ var me = $(this); // var keyset = ['48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '96', '97', '98', '99', '100', '101', '102', '103', '104', '105','188']; // if (keyset.indexOf(e.which) < 0) { // if (!$.isNumeric($(this).val().replace(/,/g,''))) { // if(e.which==190 && me.val()==""){ // me.val("0."); // return; // } // else{ // var str = String.fromCharCode(e.which).toLowerCase(); // me.val($(this).val().replace(str,'')); // } // } // } var regex = /^[0-9]\d*(((,\d{3}){1})?(\.\d{0,2})?)$/; if(parseFloat(me.val()) < 1 && parseFloat(me.val()) != 0){ setTimeout(()=>{ me.val(parseFloat(me.val()).toFixed(2)); },500); } }) $("#view_report").on('click',function(){ window.open("pos/vtr/" + dt.active_session.session_id,"_blank"); }); $(document).on('click',"#transactions tbody tr td",function(){ $(".header-title").html('Acknowledgement Receipt'); var ind = $(this).parent().index(); var tr = $("#transactions tbody tr")[ind]; var ar_number = $(tr).find('td').eq(1).text(); get_ar(ar_number,"#pos_transaction"); $("#c_back").attr('goto',"#pos_transaction"); }); $(document).on('click','.ar_number',function(){ $(".header-title").html('Acknowledgement Receipt'); var ar_number = $(this).text(); get_ar(ar_number,"#transaction_list"); $("#c_back").attr('goto',"#transaction_list"); }); $("#resend_receipt").on('click',function(){ var receipt_no = $(this).attr('receipt_no'); confirm("Resend Acknowledgement Receipt","Are you sure you want to resend AR (" + receipt_no + ")?",function(){ $(this).dialog('close'); $c.waitDialog.start('Resending AR'); send_receipt(receipt_no,dt.transaction.email_address,function(){ alert('Acknowledgement Receipt',"Acknowledgement Receipt successfully resent",function(){ $(this).dialog('close'); $("#c_back").trigger('click'); $c.waitDialog.stop(); var w = window.open('pos/receipt/' + receipt_no,"_blank"); w.print(); }); }); }); }); $("#print_receipt").on('click',function(){ var receipt_no = $(this).attr('receipt_no'); var w = window.open('pos/receipt/' + receipt_no,"_blank"); w.print(); }); // Functions function get_ar(ar_number,hide){ $c.waitDialog.start('Loading Receipt'); $.ajax({ url: "pos/view_receipt/" + ar_number, type: "GET", success:function(d){ $(hide).hide(); $("#display_receipt").show(); $("#resend_receipt, #print_receipt").attr("receipt_no",ar_number); $("#receipt_view").html(d); $c.waitDialog.stop(); } }); } function session_data(){ $.ajax({ url: "pos/session_tx", type: "POST", data: { session_id:dt.active_session.session_id, }, success:function(d){ dt.send_session = {}; dt.send_session = d; dt.send_session.session_id = dt.active_session.session_id; dt.send_session.user_id = dt.active_session.user_id; dt.send_session.processor = dt.active_session.processor; dt.send_session.congregation_id = dt.active_session.congregation_id; if(d.total_transactions>0){ //Sending End Session Details send_session(); } else{ //Closing Session; end_session(); } }, dataType:'json' }) } function send_session(){ $.ajax({ url: dt.api + "/kiosk_session", type: "POST", data: dt.send_session, success:function(){ end_session(); }, error:function(){ $.promptMe.alert('Sending Data Exception',"Error Sending Data"); $c.waitDialog.stop(); } }) } function end_session(){ $.ajax({ url: "pos/session_close", type: "POST", data:{ session_id: dt.active_session.session_id }, success:function(){ $c.waitDialog.stop(); //Open Report window.open("pos/vtr/" + dt.active_session.session_id,"_blank"); check_session(); } }) } function load_data(ref,fn){ $c.waitDialog.start('Loading Registration'); $.ajax({ // url: "/victory/registration/get_info", url: dt.api + "/get_info", type: 'POST', data:{ registration_number: ref, congregation_id: dt.active_session.congregation_id, user_id: dt.active_session.user_id }, success:function(d){ // console.log(d); if(d.result=="failed"){ $c.waitDialog.stop(); } // return; var reg = d; var pay = d.payments; dt.event_id = reg.event_id; if(d.result=='failed'){ $("#ref_num").val(''); alert('Exception','Invalid Registration Number

Please check the registration number, then try again.'); return; } if(reg.name_first==undefined){ alert('Exception','No data loaded, contact system administrator!'); $c.waitDialog.stop(); return; } //Load Data $("#member_name").html(reg.name_first + " " + reg.name_last); $("#event_name").html(reg.event_name); $("#event_date").html($.event_date(reg.event_date,"")); $("#total_amount").html("PHP " + parseFloat(reg.event_total).format_comma(2)); $("#check_amount,#payment_amount,#dd_amount").attr('type','text'); $("#check_amount,#payment_amount,#dd_amount").attr('type','number').val(); //Payment Details dt.tx.clear().draw(); var amount_paid=0; for(var i in pay){ dt.tx.row.add([ new Date(pay[i].date).toLocaleDateString(), pay[i].id, parseFloat(pay[i].amount).format_comma(2), pay[i].channel_label, pay[i].processor ]); amount_paid += parseFloat(pay[i].amount); } dt.tx.draw(); var balance = parseFloat(reg.event_total) - parseFloat(amount_paid); dt.balance = balance; $("#remaining_amount").html("PHP " + balance.format_comma(2)); $("#total_payment").html("PHP" + amount_paid.format_comma(2)); dt.registration_number = ref; dt.registration_id = reg.reg_id; dt.transaction = {}; dt.transaction.registration_number = dt.registration_number; dt.transaction.name_first = reg.name_first; dt.transaction.name_last = reg.name_last; dt.transaction.event_name = reg.event_name; dt.transaction.event_id = reg.event_id; dt.transaction.email_address = reg.emz; fn(); $c.waitDialog.stop(); }, error:function(){ alert("Exception","Error connecting to server, please try again",function(){ $(this).dialog('close'); $c.waitDialog.stop(); }); }, dataType:'json' }) } function load_transaction(obj){ $c.waitDialog.start('Loading Transactions'); $.ajax({ url: "pos/transactions", type: "POST", data:obj, success:function(d){ dt.list.clear();//.draw(); for(var i in d){ dt.list.row.add([ d[i].registration_number.toUpperCase(), new Date(d[i].payment_date).toLocaleDateString(), d[i].name_last, d[i].name_first, parseFloat(d[i].amount_paid).format_comma(2), "" + d[i].receipt_no + "", d[i].payment_method, d[i].processor ]) } var load = setInterval(function(){ $c.waitDialog.stop(); dt.list.draw(); clearInterval(load); },2000); }, dataType: 'json' }); } function load_banks(){ module("read","beta","bank_codes",{},function(d){ var opt = ""; for(var i of d){ opt +=``; } $("#bank_name").html(opt); }) } function validate(){ var valid = true; if(dt.transaction.method == "CASH" || dt.transaction.method == "GCASH" || dt.transaction.method == "PAYMAYA"){ if(dt.transaction.method=="GCASH" || dt.transaction.method=="PAYMAYA"){ if($("#reference_number").val() == ""){ $("#reference_number").addClass('required'); valid = false; } } if($("#payment_amount").val() == ""){ $.promptMe.alert('Registration, Payment','Payment Amount Required'); $("#payment_amount").addClass('required'); valid = false; } if(parseFloat($("#payment_amount").val())<="0"){ $.promptMe.alert('Registration, Payment','Payment Amount should not be equal or less then zero'); $("#payment_amount").addClass('required'); $("#payment_amount").addClass('required'); valid = false; } } else if (dt.transaction.method=="DIRECT DEPOSIT"){ if($("#deposit_date").val() == ""){ $("#deposit_date").addClass('required'); valid = false; } if($("#dd_reference_number").val() == ""){ $("#dd_reference_number").addClass('required'); valid = false; } if($("#dd_amount").val() == ""){ $("#dd_amount").addClass('required'); valid = false; } } else { if($("#bank_name").val() == "0" || $("#bank_name").val()==null){ $("#bank_name").addClass('required'); valid = false; } // if($("#bank_branch").val() == ""){ // $("#bank_branch").addClass('required'); // valid = false; // } if($("#check_number").val() == ""){ $("#check_number").addClass('required'); valid = false; } if($("#check_amount").val() == ""){ $("#check_amount").addClass('required'); valid = false; } } return valid; } function get_session(d){ $.ajax({ url: "pos/setSession", type: 'POST', data: d, success:function(d){ $c.waitDialog.start(); check_session(); } }) } function check_session(){ // $c.waitDialog.start('Loading...'); // if(bool){ return;} // session = setInterval(function(){ // },2000); $.ajax({ url: 'pos/check_session', type: 'GET', success:function(d){ console.log(d); if(!d.session){ $("#pos_login").show(); $("#pos_transaction,#pos_processor,#pos_transaction_code").hide(); clearInterval(session); $c.waitDialog.stop(); } else{ if(d.data.userdata.session_id != undefined){ $.ajax({ url: "pos/is_session_active", type: "POST", data:{ session_id: d.data.userdata.session_id }, success:function(d){ if(!d){ alert("Browser Session Ended","Please login again",function(){ window.location = $("base").attr('href') + "/beta/pos/clearSession"; $(this).dialog('close'); }); } }, dataType: 'json' }); } dt.active_session = d.data.userdata; // console.log(d.data); $("#sign_in_name").html(d.data.userdata.username); if(d.data.userdata.processor == undefined){ //$(".header-title").html("Volunteer Assignment"); $("#pos_processor").show(); $(".volunteer").hide(); $(".admin-staff").show(); } else{ //$(".header-title").html("Registration"); if($("#reference_code").val()==""){ $("#pos_transaction_code,.volunteer").show(); $("#pos_transaction,#pos_processor,.admin-staff").hide(); $("#active_processor").html("Make Payment"); } } $(".link").show(); $c.waitDialog.stop(); bool = true; $("#pos_login").hide(); } }, dataType: 'json', }) } function save_session(){ $.ajax({ url : "pos/save_session", type: "GET", success:function(d){ //if(!bool){ check_session(); //} } }) } function add_session_detail(sess_id){ $.ajax({ url: "pos/session_detail", type: "POST", data:{ session_id: sess_id }, success:function(){} }) } function scroll_bottom(){ $('html,body').animate({ scrollTop: document.body.scrollHeight }, 2000); } function send_payment(){ $(this).dialog('close'); clearInterval(session); bool = false; $c.waitDialog.start('Processing'); $.ajax({ url: dt.api + "/payment", // url :'/victory/registration/payment', type: "POST", data: dt.payment, success:function(d){ // console.log(d); // return; if(d.result=='success'){ dt.transaction.receipt_no = d.payment_id; dt.transaction.amount_paid = dt.payment.amount; dt.transaction.reference_no = dt.payment.reference_number; dt.transaction.payment_response = d.status; dt.transaction.payment_method = dt.transaction.method; dt.transaction.session_id = dt.active_session.session_id; dt.transaction.bank_name = dt.payment.bank_name; dt.transaction.bank_branch = dt.payment.bank_branch; dt.transaction.check_number = dt.payment.check_number; dt.transaction.deposit_date = $.datepicker.formatDate('yy-mm-dd', new Date(dt.payment.deposit_date)) delete dt.transaction.method; save_transaction(); }else{ alert('Payment Failed',d.message); } $c.waitDialog.stop() }, error:function(){ alert('Payment Failed','Error processing payment'); $c.waitDialog.stop() }, dataType: 'json' }) } function save_transaction(){ $.ajax({ url: 'pos/payment', type: "POST", data: dt.transaction, success:function(){ dt.ar_number = dt.transaction.receipt_no; dt.receipt_dialog.dialog('open'); if(dt.transaction.email_address===undefined){ $("#d_close").html("Close").removeAttr("disabled"); return; } else{ send_receipt(dt.transaction.receipt_no, dt.transaction.email_address,function(){ $("#d_close").html("Close").removeAttr("disabled"); }); } // alert('Payment Status',"Payment Successful", function(){ // $(this).dialog('close'); // $("#reference_number,#payment_amount").val(''); // dt.ar_number = dt.transaction.receipt_no; // $c.waitDialog.start('Sending AR'); // send_receipt(dt.transaction.receipt_no,dt.transaction.email_address,function(){ // dt.receipt_dialog.dialog('open'); // },function(){ // dt.receipt_dialog.dialog('open'); // }); // }); } }) } function send_receipt(receipt,email_address,successful = null,failed=null){ if(email_address===undefined){ setTimeout(function(){ $("#d_close").html("Close").removeAttr("disabled"); },1500) return; } $.ajax({ url: "pos/receipt/" + receipt, success:function(d){ message = d; $.ajax({ url: "pos/email_receipt/", type: "POST", data:{ recipient: email_address, message : message }, success:function(e){ if(e || e===1){ if(successful==null){ load_data(dt.registration_number,function(){ $("#reference_number,#payment_amount,#dd_amount").val(''); $c.waitDialog.stop(); $(".square.active").trigger('click') dt.tx.draw(); }); } else{ successful(); } } }, error:function(){ $c.waitDialog.stop(); alert('Auto-generated Email Failed',"Acknowledgement Receipt Email Failed"); if(failed==null){ load_data(dt.registration_number,function(){ $("#reference_number,#bank_name,#bank_branch,#check_number").val(''); $("#check_amount,#payment_amount").attr('type','text').val('') $("#check_amount,#payment_amount").attr('type','number'); $c.waitDialog.stop(); $(".square.active").trigger('click'); dt.tx.draw(); }); } else{ failed(); } $("#d_close").html("Close").removeAttr("disabled"); }, dataType:'json' }) } }) } (function($){ $.session_retrieve = function(id){ var session = {}; for(var i in json){ if(json[i].session_id == id){ session = json[i].json; break; } } return session; } $.event_date = function(d1,d2=''){ var date = ""; if(d2!=''){ if(new Date(d1).getFullYear()== new Date(d2).getFullYear()){ date += $.datepicker.formatDate('M d - ',new Date(d1)); date += $.datepicker.formatDate('M d, yy',new Date(d2)); } else{ date += $.datepicker.formatDate('M d, yy - ',new Date(d1)); date += $.datepicker.formatDate('M d, yy',new Date(d2)); } } else{ date += $.datepicker.formatDate('M d, yy',new Date(d1)); } return date; } })(jQuery)