$('#invoicecustomername').val('$disname');";
}
if(isset($_POST['getinvoice_no']))
{
$getinvoice_no=$_POST['getinvoice_no'];
$invoiceproductchangecoderowid=$_POST['invoicerowid'];
$invoicepartcode=$_POST['invoicepartcode'];
$invoiceinvid=$_POST['invoiceinvid'];
$selectinven="SELECT * FROM `inventory` WHERE id='$invoiceinvid'";
$run_query=mysqli_query($conn,$selectinven);
$row_inventory=mysqli_fetch_array($run_query);
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('.changeinvoicecalculation').keyup();";
}
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"]) || !empty($_SESSION["labourinvoicetotal"]))
{
$no = 0;
$grttotal = 0;
$overallinvoicetotal=0;
$alllabourinvoicetotal=0;
$invoice_overall_discount_amount=$_POST['invoice_overall_discount_amount'];
if($invoice_overall_discount_amount == '')
{
$invoice_overall_discount_amount=0;
}
if(!empty($_SESSION["invoicetotal"]))
{
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 "";
$overallinvoicetotal = $overallinvoicetotal + $totalprice;
}
}
if(!empty($_SESSION["labourinvoicetotal"]))
{
foreach ($_SESSION["labourinvoicetotal"] as $keys => $values)
{
$invid = $values["rowid"];
$price = $values["price"];
$tax = $values["gst"];
$num2 = $tax * $price;
$total2 = $num2 / 100;
$distotal = $price + $total2;
$distotal = number_format($distotal, 2);
$distotal = str_replace(",", "", $distotal);
$alllabourinvoicetotal = $alllabourinvoicetotal + $distotal;
}
}
$grttotal=$overallinvoicetotal+$alllabourinvoicetotal;
// echo "";
$grttotal=$grttotal-$invoice_overall_discount_amount;
$grttotal1 = number_format($grttotal, 2);
$grttotaldis = str_replace(",", "", $grttotal1);
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'];
$invoice_paid_amt = $_POST['invoice_paid_amt'];
$invoicetypename = $_POST['invoicetypename'];
$adddiscount_amount = $_POST['addinvoice_overall_discount_amount'];
$addinvoicecustomervehiclenumber = $_POST['addinvoicecustomervehiclenumber'];
$checkinsert = 1;
$firststore = 1;
$date = date("Y-m-d");
$amt_status='';
$product_code=$_POST['product_code'];
$labourname=$_POST['labourname'];
$productcount = count($product_code);
$productcountall = $productcount - 1;
$labournamecount = count($labourname);
$labournamecountall = $labournamecount - 1;
$checkinsert=1;
for($i = 0; $i < $productcount; $i++)
{
if ($_POST['product_code'][$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();
}
}
for($i = 0; $i < $labournamecount; $i++)
{
if ($_POST['labourname'][$i] == '')
{
echo "";
$checkinsert = 0;
exit();
}
if ($_POST['productdescription'][$i] == '')
{
echo "";
$checkinsert = 0;
exit();
}
if ($_POST['productcost'][$i] == '')
{
echo "";
$checkinsert = 0;
exit();
}
if ($_POST['productgst'][$i] == '')
{
echo "";
$checkinsert = 0;
exit();
}
}
$displayinventorypid='';
$displaycode='';
$displayinvoicenumber='';
$displayname='';
$displayunit='';
$displayunittype='';
$displaycategory='';
$displayprice='';
$displaysallesprice='';
$displaygst='';
$displayhsn='';
$displayqty='';
$displaytotal='';
$displaylabourname='';
$displaydescription='';
$displaycost='';
$displaylabourgst='';
if($checkinsert == '1')
{
for ($i = 0; $i < $productcount; $i++)
{
if($i == 0)
{
$displayinventorypid .=$_POST['inventory_part_id'][$i];
$displaycode .=$_POST['product_code'][$i];
$displayinvoicenumber .=$_POST['product_invoicenumber'][$i];
$displayname .=$_POST['product_name'][$i];
$displayunit .=$_POST['product_unit'][$i];
$displayunittype .=$_POST['product_unittype'][$i];
$displaycategory .=$_POST['product_category'][$i];
$displayprice .=$_POST['product_price'][$i];
$displaysallesprice .=$_POST['product_selling_price'][$i];
$displaygst .=$_POST['product_gst'][$i];
$displayhsn .=$_POST['inven_hsn'][$i];
$displayqty .=$_POST['inven_qty'][$i];
$displaytotal .=$_POST['inven_total'][$i];
}
else
{
$displayinventorypid .='@@@@'.$_POST['inventory_part_id'][$i];
$displaycode .='@@@@'.$_POST['product_code'][$i];
$displayinvoicenumber .='@@@@'.$_POST['product_invoicenumber'][$i];
$displayname .='@@@@'.$_POST['product_name'][$i];
$displayunit .='@@@@'.$_POST['product_unit'][$i];
$displayunittype .='@@@@'.$_POST['product_unittype'][$i];
$displaycategory .='@@@@'.$_POST['product_category'][$i];
$displayprice .='@@@@'.$_POST['product_price'][$i];
$displaysallesprice .='@@@@'.$_POST['product_selling_price'][$i];
$displaygst .='@@@@'.$_POST['product_gst'][$i];
$displayhsn .='@@@@'.$_POST['inven_hsn'][$i];
$displayqty .='@@@@'.$_POST['inven_qty'][$i];
$displaytotal .='@@@@'.$_POST['inven_total'][$i];
}
}
for ($i = 0; $i < $labournamecount; $i++)
{
if($i == 0)
{
$displaylabourname .=$_POST['labourname'][$i];
$displaydescription .=$_POST['productdescription'][$i];
$displaycost .=$_POST['productcost'][$i];
$displaylabourgst .=$_POST['productgst'][$i];
}
else
{
$displaylabourname .='@@@@'.$_POST['labourname'][$i];
$displaydescription .='@@@@'.$_POST['productdescription'][$i];
$displaycost .='@@@@'.$_POST['productcost'][$i];
$displaylabourgst .='@@@@'.$_POST['productgst'][$i];
}
}
$insert="INSERT INTO `invoice`(`invoicenum`, `invoicedate`, `customer`,`vehiclenumber`,`type`,`inventory_pro_id`,`code`, `inventoryinvoicenum`, `name`, `unit`, `unittype`, `category`, `price`, `sellingprice`, `gst`, `qty`, `hsn`, `total`, `labourname`,`description`,`cost`,`labourgst`,`overalldiscount`,`granttotal`,`paidamount`) VALUES ('$invoice_invoice_no','$invoicedate','$invoicecustomercode','$addinvoicecustomervehiclenumber','$invoicetypename','$displayinventorypid','$displaycode','$displayinvoicenumber','$displayname','$displayunit','$displayunittype','$displaycategory','$displayprice','$displaysallesprice','$displaygst','$displayqty','$displayhsn','$displaytotal','$displaylabourname','$displaydescription','$displaycost','$displaygst','$adddiscount_amount','$invoice_grand_total','$invoice_paid_amt')";
$runinsert=mysqli_query($conn,$insert);
if($runinsert)
{
$selectsalno = "SELECT * FROM `count` WHERE name='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='invoice'";
$run_upcus = mysqli_query($conn, $updateno);
for($i=0;$i<$productcount;$i++)
{
$temp_inventory_part_id=$_POST['inventory_part_id'][$i];
$temp_invoice_newquan=$_POST['inven_qty'][$i];
$selectinven="SELECT * FROM `inventory` WHERE id='$temp_inventory_part_id'";
$run_qq=mysqli_query($conn,$selectinven);
$row_qq=mysqli_fetch_array($run_qq);
$invenquantity=$row_qq['invoice_qty'];
$storeqty=$invenquantity-$temp_invoice_newquan;
if($storeqty < 0)
{
$storeqty=0;
}
$updateqq="UPDATE `inventory` SET `invoice_qty`='$storeqty' WHERE id='$temp_inventory_part_id'";
$run_upqq=mysqli_query($conn,$updateqq);
}
echo "";
}
}
}
if(isset($_POST['inventoryremovegetid']))
{
$inventoryremovegetid=$_POST['inventoryremovegetid'];
$delete="DELETE FROM `inventory` WHERE invoiceid='$inventoryremovegetid'";
$run=mysqli_query($conn,$delete);
if($run)
{
echo "";
}
}
if(isset($_POST['invoiceproductcode']))
{
$invoiceproductcode=$_POST['invoiceproductcode'];
$invoiceproductchangecoderowid=$_POST['invoiceproductchangecoderowid'];
$invoiceproductchangepartid=$_POST['invoiceproductchangepartid'];
?>