$(document).on('click','#addinvoicerowid',function(e) { e.preventDefault(); var count=$("#dynamic_field tr").last().length; if(count == '0') { var n=0; } else { var n=$("#dynamic_field tr").last().attr("count"); } var m=1; var i= parseInt(m, 10) + parseInt(n, 10); $('#dynamic_field').append(''); }); $(document).on('change','.changelocalcustomernum',function(e){ changelocalcustomernum(); }); $(document).on('keyup','.changelocalcustomernum',function(e){ changelocalcustomernum(); }); $(document).on('change','.changelocalinvoicepartcode',function() { var invoice_changepartid=''; var invoice_code=$(this).val(); var invoice_changecodeid=$(this).attr("changeid"); invoice_changepartid=$('#part_code option').filter(function() { return this.value == invoice_code; }).data('proid'); if(typeof invoice_changepartid !== 'undefined') { invoice_changepartid=''; } $.ajax({ url:'action.php', type:'POST', data:{invoiceproductcode:invoice_code,invoiceproductchangecoderowid:invoice_changecodeid,invoiceproductchangepartid:invoice_changepartid}, success:function(data){ $("#display_inven_invno"+invoice_changecodeid).html(data); } }); }); $(document).on('keyup','.changeinvoicecalculation',function(e) { var invoicetotalid=$(this).attr("invoiceid"); loadinvoicealltotal(invoicetotalid); }); $(document).on('keyup','.changeoverallinvoicecal',function(e) { loadinvoicetotal(); }); $(document).on('submit','#addinvoiceform',function(e) { e.preventDefault(); var invoice_invoice_no=$("#invoice_invoice_no").val(); var invoicecustomername=$("#invoicecustomername").val(); var invoicecustomervehiclenumber=$("#invoicecustomervehiclenumber").val(); var invoicedate=$("#inven_date").val(); var invoice_grand_total=$("#invoice_grand_total").val(); var invoice_paid_amt=$("#invoice_paid_amt").val(); var invoicetypename=$("#invoicetypename").val(); var invoice_overall_discount_amount=$("#invoice_overall_discount_amount").val(); var a=1; if(invoice_invoice_no == '') { alert('Please Enter Invoice Number'); return false; } if(invoicecustomername == '') { alert('Please Select Customer'); return false; } if(invoicetypename == '') { alert('Please Enter Invoice Type'); return false; } if(invoice_overall_discount_amount == '') { alert('Please Enter Discount Amount'); return false; } if(invoice_paid_amt == '') { invoice_paid_amt=0; } var invoicecustomernamevalid=$('#listcustomername option').filter(function() { return this.value == invoicecustomername; }).data('cusid'); var formData = new FormData(this); formData.append('invoice_invoice_no',invoice_invoice_no); formData.append('invoicecustomercode',invoicecustomernamevalid); formData.append('invoicedate',invoicedate); formData.append('invoice_grand_total',invoice_grand_total); formData.append('invoice_paid_amt',invoice_paid_amt); formData.append('addinvoicecustomervehiclenumber',invoicecustomervehiclenumber); formData.append('invoicetypename',invoicetypename); formData.append('addinvoice_overall_discount_amount',invoice_overall_discount_amount); $.ajax({ type: 'POST', url: 'action.php', data: formData, contentType: false, cache: false, processData:false, success: function(data){ $("#display_invoice_all").html(data); }, }); }); $(document).on('click','.clickdeleteinvoiceory',function() { if(confirm("Are You Confirm")) { var invoiceoryremovegetid=$(this).attr("removecusid"); $.ajax({ url:'action.php', type:'POST', data:{invoiceoryremovegetid:invoiceoryremovegetid}, success:function(data){ $("#deletecusid").html(data); } }); } }); $(document).on('change','.change_invoice_no',function() { var getinvoice_no=$(this).val(); var invoicerowid=$(this).attr("changeid"); var invoicepartcode=$('#invoice_part_code'+invoicerowid+'').val(); if(getinvoice_no == '') { return false; } var invoiceinvid=$('#inven_invno'+invoicerowid+' option').filter(function() { return this.value == getinvoice_no; }).data('invid'); $.ajax({ url:'action.php', type:'POST', data:{getinvoice_no:getinvoice_no,invoicerowid:invoicerowid,invoicepartcode:invoicepartcode,invoiceinvid:invoiceinvid}, success:function(data){ $("#display_invoice"+invoicerowid).html(data); } }); }); $(document).on('click','.removeinvoicerowval',function() { var removeinvoicerowvalid=$(this).attr("id"); $(this).closest("tr").remove(); $.ajax({ url:'action.php', type:'POST', data:{removeinvoicerowvalid:removeinvoicerowvalid}, success:function(data){ $("#displayinvoice").html(data); } }); }); $(document).on('submit','#updateinvoiceform',function(e) { e.preventDefault(); var invoice_invoice_no=$("#invoice_invoice_no").val(); var invoicecustomername=$("#invoicecustomername").val(); var invoicecustomervehiclenumber=$("#invoicecustomervehiclenumber").val(); var invoicedate=$("#inven_date").val(); var invoice_grand_total=$("#invoice_grand_total").val(); var invoice_paid_amt=$("#invoice_paid_amt").val(); var invoice_update_id=$("#invoice_update_id").val(); var updateinvoicetypename=$("#updateinvoicetypename").val(); var invoice_overall_discount_amount=$("#invoice_overall_discount_amount").val(); var a=1; if(invoice_invoice_no == '') { alert('Please Enter Invoice Number'); return false; } if(invoicecustomername == '') { alert('Please Select Customer'); return false; } if(updateinvoicetypename == '') { alert('Please Enter Invoice Type'); return false; } if(invoice_overall_discount_amount == '') { alert('Please Enter Discount Amount'); return false; } if(invoice_paid_amt == '') { invoice_paid_amt=0; } var invoicecustomernamevalid=$('#listcustomername option').filter(function() { return this.value == invoicecustomername; }).data('cusid'); var formData = new FormData(this); formData.append('uinvoice_invoice_no',invoice_invoice_no); formData.append('uinvoicecustomercode',invoicecustomernamevalid); formData.append('uinvoicecustomervehiclenumber',invoicecustomervehiclenumber); formData.append('uinvoicedate',invoicedate); formData.append('uinvoice_grand_total',invoice_grand_total); formData.append('uinvoice_paid_amt',invoice_paid_amt); formData.append('uinvoice_update_id',invoice_update_id); formData.append('updatediscount_amount',invoice_overall_discount_amount); formData.append('updateinvoicetypename',updateinvoicetypename); $.ajax({ type: 'POST', url: 'action.php', data: formData, contentType: false, cache: false, processData:false, success: function(data){ $("#display_invoice_all").html(data); }, }); }); $(document).on('change','.changeinvoicecustomervehiclenumber',function() { changeinvoicecustomervehiclenumber(); }); $(document).on('keyup','.changeinvoicecustomervehiclenumber',function() { changeinvoicecustomervehiclenumber(); }); $(document).on('change','.changelocalcustomername',function() { changeinvoicecustomername(); }); $(document).on('keyup','.changelocalcustomername',function() { changeinvoicecustomername(); }); $(document).on('click','#addinvoicerowlabourid',function(e) { e.preventDefault(); var count=$("#dynamic_labour tr").last().length; if(count == '0') { var n=0; } else { var n=$("#dynamic_labour tr").last().attr("count"); } var m=1; var i= parseInt(m, 10) + parseInt(n, 10); $('#dynamic_labour').append(''); }); $(document).on('keyup','.changelabourproductcost',function(e) { var labourproductchangeid=$(this).attr("changeid"); loadlabourinvoicealltotal(labourproductchangeid); }); $(document).on('keyup','.changeinvoicejobcardnumber',function(e) { loadinvoicejobcardnumber(); }); $(document).on('change','.changeinvoicejobcardnumber',function(e) { loadinvoicejobcardnumber(); }); function loadinvoicejobcardnumber() { var invoicecustomerjobcardnumber=$("#invoicecustomerjobcardnumber").val(); if(invoicecustomerjobcardnumber != '') { var invoicecustomerjobcardnumberid=$('#listcustomerjobcardnumber option').filter(function() { return this.value == invoicecustomerjobcardnumber; }).data('cusid'); if(typeof invoicecustomerjobcardnumberid !== 'undefined') { $.ajax({ url:'action.php', type:'POST', data:{invoicecustomerjobcardnumberid:invoicecustomerjobcardnumberid}, success:function(data){ $("#display_invoice_all").html(data); } }); } } } function loadlabourinvoicealltotal(i) { var labourinvoicealltotalid=parseInt(i); if(labourinvoicealltotalid != '') { var labourinvoice_price=$("#productcost"+labourinvoicealltotalid).val(); var labourinvoice_gst=$("#productgst"+labourinvoicealltotalid).val(); if(labourinvoice_price == '') { return false; } if(labourinvoice_gst == '') { return false; } $.ajax({ url:'action.php', type:'POST', data:{labourinvoice_price:labourinvoice_price,labourinvoice_gst:labourinvoice_gst,labourinvoicealltotalid:labourinvoicealltotalid}, success:function(data) { $("#displayinvoice").html(data); } }); } } function changeinvoicecustomername() { var invoicecustomernameval=$("#invoicecustomername").val(); if(invoicecustomernameval != '') { var invoicecustomernamevalid=$('#listcustomername option').filter(function() { return this.value == invoicecustomernameval; }).data('cusid'); if(typeof invoicecustomernamevalid !== 'undefined') { $.ajax({ url:'action.php', type:'POST', data:{invoicecustomernamevalid:invoicecustomernamevalid}, success:function(data){ $("#listcustomervehiclenumber").html(data); } }); } } } function changeinvoicecustomervehiclenumber() { var invoicecustomervehiclenumberval=$("#invoicecustomervehiclenumber").val(); if(invoicecustomervehiclenumberval != '') { var invoicecustomervehiclenumberid=$('#listcustomervehiclenumber option').filter(function() { return this.value == invoicecustomervehiclenumberval; }).data('cusid'); if(typeof invoicecustomervehiclenumberid !== 'undefined') { $.ajax({ url:'action.php', type:'POST', data:{invoicecustomervehiclenumberid:invoicecustomervehiclenumberid}, success:function(data){ $("#display_invoice_all").html(data); } }); } } } function changelocalcustomernum() { var invoicecustomercode=$("#invoicecustomercode").val(); if(invoicecustomercode != '') { $.ajax({ url:'action.php', type:'POST', data:{invoicecustomercode:invoicecustomercode}, success:function(data){ $("#displayinvoice").html(data); } }); } } function loadinvoicealltotal(i) { var invoicetotalrowid=parseInt(i); if(invoicetotalrowid != '') { var invoice_price=$("#sellingprice"+invoicetotalrowid).val(); var invoice_gst=$("#gst"+invoicetotalrowid).val(); var invoice_qty=$("#qty"+invoicetotalrowid).val(); var invoice_inventory_qty=$("#inventoryqty"+invoicetotalrowid).val(); if(invoice_price == '') { return false; } if(invoice_gst == '') { return false; } if(invoice_qty == '') { return false; } invoice_qty=parseInt(invoice_qty, 10); invoice_inventory_qty=parseInt(invoice_inventory_qty, 10); if(invoice_inventory_qty