$('#inventorysupliername').val('$disname');"; } if(isset($_POST['invententoryproductcode'])) { $invententoryproductcode=$_POST['invententoryproductcode']; $inventproductchangecoderowid=$_POST['inventproductchangecoderowid']; $inventproductchangepartid=$_POST['inventproductchangepartid']; $selectproductdetails = "SELECT * FROM `productdetails` WHERE id='$inventproductchangepartid'"; $run_productdetails = mysqli_query($conn, $selectproductdetails); $row_productdetails = mysqli_fetch_array($run_productdetails); ?> $inventorytotalrowid, 'price' => $inventory_price, 'gst' => $inventory_gst, 'qty' => $inventory_qty ); $_SESSION["inventorytotal"][$inventorytotalrowid] = $item; echo ''; } if(isset($_POST['loadinvetntorytotal'])) { if (!empty($_SESSION["inventorytotal"])) { $no = 0; $grttotal = 0; $subtotal = 0; $gstamount = 0; foreach ($_SESSION["inventorytotal"] 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['inventory_invoice_no'])) { $inventory_invoice_no = $_POST['inventory_invoice_no']; $inventorysupliercode = $_POST['inventorysupliercode']; $inventorydate = $_POST['inventorydate']; $ineventory_paid_amt = $_POST['ineventory_paid_amt']; $ineventory_grand_total = $_POST['ineventory_grand_total']; $checkinsert = 1; $firststore = 1; $date = date("Y-m-d"); $amt_status=''; $product_code=$_POST['product_code']; $productcount = count($product_code); $productcountall = $productcount - 1; $checkinsert=1; for ($i = 0; $i < $productcount; $i++) { if ($_POST['product_code'][$i] == '') { echo ""; $checkinsert = 0; exit(); } if ($_POST['product_price'][$i] == '') { echo ""; $checkinsert = 0; exit(); } if ($_POST['product_selling_price'][$i] == '') { echo ""; $checkinsert = 0; exit(); } if ($_POST['product_gst'][$i] == '') { echo ""; $checkinsert = 0; exit(); } if ($_POST['inven_qty'][$i] == '') { echo ""; $checkinsert = 0; exit(); } } if ($checkinsert == '1') { $selcetcount = "SELECT * FROM `count` WHERE name='local-inventory'"; $runcount = mysqli_query($conn, $selcetcount); $rowcount = mysqli_fetch_array($runcount); $rowcountno = $rowcount['count']; $inventoryid = 1000 + $rowcountno; for ($i = 0; $i < $productcount; $i++) { $check_code = $_POST['product_code'][$i]; $check_name = $_POST['product_name'][$i]; $check_unit = $_POST['product_unit'][$i]; $check_unittype = $_POST['product_unittype'][$i]; $check_category = $_POST['product_category'][$i]; $check_price = $_POST['product_price'][$i]; $check_selling_price = $_POST['product_selling_price'][$i]; $check_gst = $_POST['product_gst'][$i]; $check_hsn = $_POST['inven_hsn'][$i]; $check_qty = $_POST['inven_qty'][$i]; $check_total = $_POST['inven_total'][$i]; $insertinventory = "INSERT INTO `inventory`(`inventoryid`,`inventoryinvoiceno`, `inventorysupliernum`, `inventorydate`, `code`, `name`, `unit`, `unittype`, `category`, `price`, `sellingprice`, `gst`, `inventory_qty`,`invoice_qty`, `hsn`, `total`, `grandtotal`, `paidamount`) VALUES ('$inventoryid','$inventory_invoice_no','$inventorysupliercode','$inventorydate','$check_code','$check_name','$check_unit','$check_unittype','$check_category','$check_price','$check_selling_price','$check_gst','$check_qty','$check_qty','$check_hsn','$check_total','$ineventory_grand_total','$ineventory_paid_amt')"; $run_query = mysqli_query($conn, $insertinventory); //echo "

"; } $selectsalno = "SELECT * FROM `count` WHERE name='local-inventory'"; $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='local-inventory'"; $run_upcus = mysqli_query($conn, $updateno); echo ""; } } if(isset($_POST['inventoryremovegetid'])) { $inventoryremovegetid=$_POST['inventoryremovegetid']; $delete="DELETE FROM `inventory` WHERE inventoryid='$inventoryremovegetid'"; $run=mysqli_query($conn,$delete); if($run) { echo ""; } } if(isset($_POST['removeinventoryvalrowid'])) { $removeinventoryvalrowid=$_POST['removeinventoryvalrowid']; if (!empty($_SESSION["inventorytotal"])) { unset($_SESSION["inventorytotal"][$removeinventoryvalrowid]); echo ''; } } if(isset($_POST['uinventory_invoice_no'])) { $uinventory_invoice_no = $_POST['uinventory_invoice_no']; $uinventorysupliercode = $_POST['uinventorysupliercode']; $uinventorydate = $_POST['uinventorydate']; $uineventory_paid_amt = $_POST['uineventory_paid_amt']; $uineventory_grand_total = $_POST['uineventory_grand_total']; $uinventoryupdateid = $_POST['uinventoryupdateid']; $checkinsert = 1; $firststore = 1; $date = date("Y-m-d"); $amt_status=''; $product_code=$_POST['product_code']; $productcount = count($product_code); $productcountall = $productcount - 1; $checkinsert=1; for ($i = 0; $i < $productcount; $i++) { if ($_POST['product_code'][$i] == '') { echo ""; $checkinsert = 0; exit(); } if ($_POST['product_price'][$i] == '') { echo ""; $checkinsert = 0; exit(); } if ($_POST['product_selling_price'][$i] == '') { echo ""; $checkinsert = 0; exit(); } if ($_POST['product_gst'][$i] == '') { echo ""; $checkinsert = 0; exit(); } if ($_POST['inven_qty'][$i] == '') { echo ""; $checkinsert = 0; exit(); } } if ($checkinsert == '1') { $deleteinventory = "DELETE FROM `inventory` WHERE inventoryid='$uinventoryupdateid'"; $runinventory = mysqli_query($conn, $deleteinventory); for ($i = 0; $i < $productcount; $i++) { $check_code = $_POST['product_code'][$i]; $check_name = $_POST['product_name'][$i]; $check_unit = $_POST['product_unit'][$i]; $check_unittype = $_POST['product_unittype'][$i]; $check_category = $_POST['product_category'][$i]; $check_price = $_POST['product_price'][$i]; $check_selling_price = $_POST['product_selling_price'][$i]; $check_gst = $_POST['product_gst'][$i]; $check_hsn = $_POST['inven_hsn'][$i]; $check_qty = $_POST['inven_qty'][$i]; $check_total = $_POST['inven_total'][$i]; $insertinventory = "INSERT INTO `inventory`(`inventoryid`,`inventoryinvoiceno`, `inventorysupliernum`, `inventorydate`, `code`, `name`, `unit`, `unittype`, `category`, `price`, `sellingprice`, `gst`, `inventory_qty`,`invoice_qty`, `hsn`, `total`, `grandtotal`, `paidamount`) VALUES ('$uinventoryupdateid','$uinventory_invoice_no','$uinventorysupliercode','$uinventorydate','$check_code','$check_name','$check_unit','$check_unittype','$check_category','$check_price','$check_selling_price','$check_gst','$check_qty','$check_qty','$check_hsn','$check_total','$uineventory_grand_total','$uineventory_paid_amt')"; $run_query = mysqli_query($conn, $insertinventory); //echo "

"; } echo ""; } } ?>