js/create_sale.js
// When btn-print clicked; two actions are done 1- print the cart 2- data is edited into db.
When btn-print clicked; two actions are done 1- print the cart 2- data is edited into db.
When btn - print clicked ; two actions are done 1 - print the cart 2 - data is edited into db .
function onSaveSale() {
    var totalToPay = $('input#total_to_pay').val();
    var recieved_amount = 0;
    var recieveable_amount = 0;
    if ($('#paid_all').is(':checked')) {
        recieved_amount = $('span#sub_total').data('sub-total');
    } else {
        recieved_amount = $('input#recieved').val();
        recieveable_amount = $('input#payable').val();
    }
    var pntType = $('#payment_type').val();
    var transCode = $('#transCode').val();
    var tax = $('input.tax_value').val();
    $.ajax({
        type: "POST",
        url: "/sale",
        dataType: "json",
        data: {
            'custID': cid,
            'payment': pntType,
            'recieved': recieved_amount,
            'recieveable': recieveable_amount,
            'totalToPay': totalToPay,
            'transCode': transCode,
            'tax': tax,
            '_token': $('input[name=_token]').val()
        },
        success: function (response) {
            $('#inv_message').css('display', 'block');
            $('#inv_message').attr('style', response.style);
            $('#inv_message').html(response.sale_msg);
            $('#inv_message').fadeOut(4000);
            _invoiceID = response.invoice_id;
            onPrintInvoice(cid, _invoiceID);
        },
        error: function (error) {
            console.log(error);
        }
    });
}
function onSaveSale ( ) { var totalToPay = $ ( 'input#total_to_pay' ) . val ( ) ; var recieved_amount = 0 ; var recieveable_amount = 0 ; if ( $ ( '#paid_all' ) . is ( ':checked' ) ) { recieved_amount = $ ( 'span#sub_total' ) . data ( 'sub-total' ) ; } else { recieved_amount = $ ( 'input#recieved' ) . val ( ) ; recieveable_amount = $ ( 'input#payable' ) . val ( ) ; } var pntType = $ ( '#payment_type' ) . val ( ) ; var transCode = $ ( '#transCode' ) . val ( ) ; var tax = $ ( 'input.tax_value' ) . val ( ) ; $ . ajax ( { type : "POST" , url : "/sale" , dataType : "json" , data : { 'custID' : cid , 'payment' : pntType , 'recieved' : recieved_amount , 'recieveable' : recieveable_amount , 'totalToPay' : totalToPay , 'transCode' : transCode , 'tax' : tax , '_token' : $ ( 'input[name=_token]' ) . val ( ) } , success : function ( response ) { $ ( '#inv_message' ) . css ( 'display' , 'block' ) ; $ ( '#inv_message' ) . attr ( 'style' , response . style ) ; $ ( '#inv_message' ) . html ( response . sale_msg ) ; $ ( '#inv_message' ) . fadeOut ( 4000 ) ; _invoiceID = response . invoice_id ; onPrintInvoice ( cid , _invoiceID ) ; } , error : function ( error ) { console . log ( error ) ; } } ) ; }
When btn-print clicked; two actions are done 1- print the cart 2- data is edited into db.
When btn - print clicked ; two actions are done 1 - print the cart 2 - data is edited into db .
// var recieved_amount = $('input#recieved').val(); // var recieveable_amount = $('input#payable').val(); // data: {'_token': $('input[name=_token]').val()}, // $('#sale_section').load(' #sale_section'); // setTimeout(function () { location.reload(); }, 5000);