760 $('input#card_year_0').val($('#card_year').val()); 761 $('input#card_security_0').val($('#card_security').val()); 762 763 $('div#card_details_modal').modal('hide'); 764 pos_form_obj.submit(); 765 }); 766 767 $('button#pos-suspend').click(function(e) { 768 769 e.preventDefault(); 770 771 // Important: JS level suspend flag 772 global_is_suspend = true; 773 774 // If the same Suspend modal was opened by Unpaid Invoice, keep print mode. 775 // Otherwise this is a normal Suspend and must NOT print. 776 if (!global_is_unpaid_invoice) { 777 global_is_unpaid_invoice = false; 778 } 779 780 // Hidden field ho to set karo 781 if ($('input#is_suspend').length) { 782 $('input#is_suspend').val(1); 783 } 784 785 $('div#confirmSuspendModal').modal('hide'); 786 787 pos_form_obj.submit(); 788 789 return false; 790 }); 791 792 // ZRX: UNPAID INVOICE = exact Suspend/Draft flow + receipt print 793 // Add a button with id="pos-unpaid-invoice" beside Suspend in pos_form_actions.blade.php. 794 $(document).on('click', 'button#pos-unpaid-invoice', function(e) { 795 e.preventDefault(); 796 797 if ($('table#pos_table tbody').find('.product_row').length <= 0) { 798 toastr.warning(LANG.no_products_added); 799 return false; 800 } 801 802 // Mark only that this Suspend save must print. 803 // The existing #pos-suspend modal Save button will set suspend=true and submit ONCE. 804 global_is_unpaid_invoice = true; 805 806 // Same Suspend note/dialog. 807 $('div#confirmSuspendModal').modal('show'); 808 return false; 809 }); 810 811 //fix select2 input issue on modal 812 $('#modal_payment') 813 .find('.select2') 814 .each(function() { 815 $(this).select2({ 816 dropdownParent: $('#modal_payment'), 817 }); 818 }); 819 820 $('button#add-payment-row').click(function() { 821 var row_index = $('#payment_row_index').val(); 822 var location_id = $('input#location_id').val(); 823 $.ajax({ 824 method: 'POST', 825 url: base_path + '/sells/pos/get_payment_row', 826 data: { row_index: row_index, location_id: location_id }, 827 dataType: 'html', 828 success: function(result) { 829 if (result) { 830 var appended = $('#payment_rows_div').append(result); 831 832 var total_payable = __read_number($('input#final_total_input')); 833 var total_paying = __read_number($('input#total_paying_input')); 834 var b_due = total_payable - total_paying; 835 $(appended)