<?php
include('db_connection.php');
$Mainclass=new DB_Controller();



 $UpdateIndDtl="delete from gold_indent_details  where Order_No='".$_REQUEST['Order_No']."' and Scan2 ='0'";
 mysqli_query($Mainclass->dbh,$UpdateIndDtl);
 

$Sql="select sum(Price) as TotalPrice,sum(Discount) as TotalDiscount, sum(Total) as Gross_Total,sum(Order_Total) as Net_Amt, sum(Order_Quantity) as Total_Qty,sum(GST) as GST,sum(CGST) as CGST,sum(SGST) as SGST,sum(IGST) as IGST,sum(Product_Weight) as Total_Weight  from gold_indent_details where Order_No='".$_REQUEST['Order_No']."'";
$RS=mysqli_query($Mainclass->dbh,$Sql);
$ROW=mysqli_fetch_array($RS);


$UpdateOrder="update gold_indent_master set Total_Quantity='".$ROW['Total_Qty']."',Toal_Product_Weight='".$ROW['Total_Weight']."',Total='".$ROW['TotalPrice']."',Discount='".$ROW['TotalDiscount']."',Gross_Total='".$ROW['Gross_Total']."',Net_Total='".$ROW['Net_Amt']."',GST='".$ROW['GST']."',CGST='".$ROW['CGST']."',SGST='".$ROW['SGST']."',IGST='".$ROW['IGST']."' where Order_No='".$_REQUEST['Order_No']."'";
mysqli_query($Mainclass->dbh,$UpdateOrder);


$UpdateOrder="update gold_indent_master set Indent_Status='Completed', Scan2_Status=1, Scan2_By='".$_COOKIE['User_Name']."' where Order_No='".$_REQUEST['Order_No']."'";
mysqli_query($Mainclass->dbh,$UpdateOrder);
?>