$('#invoicecustomername').val('$disname');"; } if(isset($_POST['invoicetotalrowid'])) { $invoicetotalrowid = $_POST['invoicetotalrowid']; $invoice_price = $_POST['invoice_price']; $invoice_gst = $_POST['invoice_gst']; $invoice_qty = $_POST['invoice_qty']; $item = array( 'rowid' => $invoicetotalrowid, 'price' => $invoice_price, 'gst' => $invoice_gst, 'qty' => $invoice_qty ); $_SESSION["invoicetotal"][$invoicetotalrowid] = $item; echo ''; } if(isset($_POST['loadinvoicetotal'])) { if (!empty($_SESSION["invoicetotal"])) { $no = 0; $grttotal = 0; $subtotal = 0; $gstamount = 0; foreach ($_SESSION["invoicetotal"] as $keys => $values) { $invid = $values["rowid"]; $quantity = $values["qty"]; $price = $values["price"]; $tax = $values["gst"]; $num2 = $tax * $price; $total2 = $num2 / 100; $distotal = $price + $total2; $totalprice = $quantity * $distotal; $qtyprice = $quantity * $price; $num3 = $tax * $qtyprice; $total3 = $num3 / 100; $totalprice = number_format($totalprice, 2); $totalprice = str_replace(",", "", $totalprice); echo ""; $subtotal1 = $quantity * $price; $subtotal = $subtotal1 + $subtotal; $gstamount = $gstamount + $total3; $grttotal = $grttotal + $totalprice; } $subtotal1 = number_format($subtotal, 2); $subtotaldis = str_replace(",", "", $subtotal1); $gstamount1 = number_format($gstamount, 2); $gstamountdis = str_replace(",", "", $gstamount1); $grttotal1 = number_format($grttotal, 2); $grttotaldis = str_replace(",", "", $grttotal1); echo ''; echo ''; echo ''; } else { echo ''; echo ''; echo ''; } } if (isset($_POST['invoice_invoice_no'])) { $invoice_invoice_no = $_POST['invoice_invoice_no']; $invoicecustomercode = $_POST['invoicecustomercode']; $invoicedate = $_POST['invoicedate']; $invoice_grand_total = $_POST['invoice_grand_total']; $invoicetypename = $_POST['invoicetypename']; $checkinsert = 1; $firststore = 1; $date = date("Y-m-d"); $amt_status=''; $product_code=$_POST['product_name']; $productcount = count($product_code); $productcountall = $productcount - 1; $checkinsert=1; for($i = 0; $i < $productcount; $i++) { if ($_POST['product_name'][$i] == '') { echo ""; $checkinsert = 0; exit(); } if ($_POST['product_price'][$i] == '') { echo ""; $checkinsert = 0; exit(); } if ($_POST['product_gst'][$i] == '') { echo ""; $checkinsert = 0; exit(); } if ($_POST['product_Qty'][$i] == '') { echo ""; $checkinsert = 0; exit(); } } $displayname=''; $displayprice=''; $displaygst=''; $displayhsn=''; $displayqty=''; $displaytotal=''; if($checkinsert == '1') { for ($i = 0; $i < $productcount; $i++) { if($i == 0) { $displayname .=$_POST['product_name'][$i]; $displayprice .=$_POST['product_price'][$i]; $displaygst .=$_POST['product_gst'][$i]; $displayhsn .=$_POST['product_hsn'][$i]; $displayqty .=$_POST['product_Qty'][$i]; $displaytotal .=$_POST['inven_total'][$i]; } else { $displayname .='@@@@'.$_POST['product_name'][$i]; $displayprice .='@@@@'.$_POST['product_price'][$i]; $displaygst .='@@@@'.$_POST['product_gst'][$i]; $displayhsn .='@@@@'.$_POST['product_hsn'][$i]; $displayqty .='@@@@'.$_POST['product_Qty'][$i]; $displaytotal .='@@@@'.$_POST['inven_total'][$i]; } } $insert="INSERT INTO `perfoma-invoice`(`invoicenum`, `invoicedate`, `customer`, `name`, `price`, `gst`, `qty`, `hsn`, `total`, `granttotal`) VALUES ('$invoice_invoice_no','$invoicedate','$invoicecustomercode','$displayname','$displayprice','$displaygst','$displayqty','$displayhsn','$displaytotal','$invoice_grand_total')"; $runinsert=mysqli_query($conn,$insert); if($runinsert) { $selectsalno = "SELECT * FROM `count` WHERE name='perfoma-invoice'"; $run_sal = mysqli_query($conn, $selectsalno); $rowsalnonew = mysqli_fetch_array($run_sal); $countnew = $rowsalnonew['count']; $newcount = $countnew + 1; $updateno = "UPDATE `count` SET `count` = '$newcount' WHERE name='perfoma-invoice'"; $run_upcus = mysqli_query($conn, $updateno); echo ""; } } } if(isset($_POST['deleteperfomainvoicegetid'])) { $deleteperfomainvoicegetid=$_POST['deleteperfomainvoicegetid']; $delete="DELETE FROM `perfoma-invoice` WHERE id='$deleteperfomainvoicegetid'"; $run=mysqli_query($conn,$delete); if($run) { echo ""; } } if(isset($_POST['removeinvoicerowvalid'])) { $removeinvoicerowvalid=$_POST['removeinvoicerowvalid']; if (!empty($_SESSION["invoicetotal"])) { unset($_SESSION["invoicetotal"][$removeinvoicerowvalid]); echo ''; } } if (isset($_POST['uinvoice_invoice_no'])) { $invoice_invoice_no = $_POST['uinvoice_invoice_no']; $invoicecustomercode = $_POST['uinvoicecustomercode']; $invoicedate = $_POST['uinvoicedate']; $invoice_grand_total = $_POST['uinvoice_grand_total']; $uinvoice_update_id=$_POST['uinvoice_update_id']; $updateinvoicetypename=$_POST['updateinvoicetypename']; $checkinsert = 1; $firststore = 1; $date = date("Y-m-d"); $amt_status=''; $product_code=$_POST['product_name']; $productcount = count($product_code); $productcountall = $productcount - 1; $checkinsert=1; for($i = 0; $i < $productcount; $i++) { if ($_POST['product_name'][$i] == '') { echo ""; $checkinsert = 0; exit(); } if ($_POST['product_price'][$i] == '') { echo ""; $checkinsert = 0; exit(); } if ($_POST['product_gst'][$i] == '') { echo ""; $checkinsert = 0; exit(); } if ($_POST['product_Qty'][$i] == '') { echo ""; $checkinsert = 0; exit(); } } $displayname=''; $displayprice=''; $displaygst=''; $displayhsn=''; $displayqty=''; $displaytotal=''; if($checkinsert == '1') { for ($i = 0; $i < $productcount; $i++) { if($i == 0) { $displayname .=$_POST['product_name'][$i]; $displayprice .=$_POST['product_price'][$i]; $displaygst .=$_POST['product_gst'][$i]; $displayhsn .=$_POST['inven_hsn'][$i]; $displayqty .=$_POST['product_Qty'][$i]; $displaytotal .=$_POST['inven_total'][$i]; } else { $displayname .='@@@@'.$_POST['product_name'][$i]; $displayprice .='@@@@'.$_POST['product_price'][$i]; $displaygst .='@@@@'.$_POST['product_gst'][$i]; $displayhsn .='@@@@'.$_POST['inven_hsn'][$i]; $displayqty .='@@@@'.$_POST['product_Qty'][$i]; $displaytotal .='@@@@'.$_POST['inven_total'][$i]; } } $update="UPDATE `perfoma-invoice` SET `invoicenum`='$invoice_invoice_no',`invoicedate`='$invoicedate',`customer`='$invoicecustomercode',`name`='$displayname',`price`='$displayprice',`gst`='$displaygst',`qty`='$displayqty',`hsn`='$displayhsn',`total`='$displaytotal',`granttotal`='$invoice_grand_total',`type`='$updateinvoicetypename' WHERE id='$uinvoice_update_id'"; $runupdate=mysqli_query($conn,$update); if($runupdate) { echo ""; } } } ?>