<?php include("../../include/dbconnect.php"); 



if ( isset($submit) && $submit == "Update")
{




	$value = $quantity * $rate;


   $result=mysql_query("update labourinv set invno='$invno',invdate='$invdate',compcode='$compcode',prodcode='$prodcode',drawing_no='$drawing_no',quantity='$quantity',rate='$rate',value='$value',round_off='$round_off',gtotal='$gtotal',invstatus='$invstatus',po_no='$po_no',po_date='$po_date',schedule_no='$schedule_no',schedule_date='$schedule_date',month='$month',year='$year',account_year='$account_year' where record ='$record' ") or die(mysql_error());
   
   $result = mysql_query("select sum(value) from  labourinv where invno ='$invno' and account_year ='$account_year' and drawing_no != 'TOTAL' ") or die(mysql_error());
   $row = mysql_fetch_row($result);
   $value = $row[0];

   $ceiled_amt = round($value,0);
   $difference = $ceiled_amt - $value;


     $result=mysql_query("update labourinv set value = '$value', round_off='$difference', gtotal = '$ceiled_amt' where invno ='$invno' and account_year ='$account_year',remarks='$remarks',reference='$reference' and drawing_no = 'TOTAL' ") or die(mysql_error());
 
   
   
 //  $result = mysql_query("select cust_record from labourinv where record ='$record' ") or die(mysql_error());
 //  $row = mysql_fetch_row($result);
 //  $cust_record = $row[0];
   
  // $result = mysql_query("update custledger set dbamt = '$gtotal', rate='$rate',qty ='$quantity' where record = '$cust_record' ") or die(mysql_error());

}
elseif (isset($submit) && $submit == "Delete")

{
$result=mysql_query("delete from labourinv where record='$record'") or die(mysql_error());
}

?>
<table>
<tr><td colspan=4 align=middle>

<h4><a href="inv_view_sele.php">View Sales Labour Invoice Details  </a>


<br><br><font size=1><center><a href= "index.html">Return to index page</center></font></table>
