<?php
session_start();
require "../model/configuration.php";
$gtot=0;
$price=0;
if(isset($_POST['datepicker']))
{
$datepicker=date("Y-m-d", strtotime($_POST['datepicker']));
$customer=$_POST['customer'];
list($code,$pname) = explode("|", $_POST['product']);
$name=$pname;
$cod=$code;
$machinename=$_POST['machinename'];
$categor=$_POST['categor'];
$length=$_POST['length'];
$prwidth=$_POST['prwidth'];

$numofcopys=$_POST['numofcopys'];
$plate=$_POST['plate'];
$ctp=$_POST['ctp'];
$binding=$_POST['binding'];

$typeofwrk=$_POST['typeofwrk'];
$wrkdescription=$_POST['wrkdescription'];

$sion=$_POST['sion'];
   
   
   
$prcequery=$db->execute("select * from price_details where machine_id='$machinename' and cata_id='$categor'");
$prcro=$prcequery->fetch_assoc();   
   
   
//$query="insert into temp_puechase(inno) values ('$pno')";
$query=$db->execute("insert into estimatethree_temp_table(customer,product_code,product_name,machine_id,category_id,pr_length,pr_width,numofcopys,plate,ctp,binding,typeofwork,workdescription,amount,tax,date,permission,user)

values ('$customer','$cod','$name','$machinename','$categor','$length','$prwidth','$numofcopys','$plate','$ctp','$binding','$typeofwrk','$wrkdescription','".$prcro['amount']."','".$prcro['tax']."','$datepicker','$sion','".$_SESSION['UNAME']."')");


$selprdqy=$db->execute("select * from machines_table where id='$machinename'");
$prtx=$selprdqy->fetch_assoc();	

$catquery=$db->execute("select * from category_table where id='$categor' and machine_id='$machinename'");
$catro=$catquery->fetch_assoc();	

//	setcookie(	
		
		
if($query) {
	$c=0;
$selquery1=$db->execute("select * from estimatethree_temp_table where permission='$sion' order by id");
while($selrow1=$selquery1->fetch_assoc())
{
$c++;
$sl=$c;
$id=$selrow1['id'];	
}



$my_id = $db->lastid();


echo '<tr id="item_'.$my_id.'">
<td width="7%">'.$sl.'</td>
<td width="10%">'.$prtx['Machine_Name'].'</td>
<td width="12%">'.$catro['category'].'</td>
<td width="12%">'.$numofcopys.'</td>
<td width="11%">'.$plate.'</td>
<td width="11%">'.$ctp.'</td>
<td width="11%">'.$binding.'</td>
<td width="9%" class="text-center" style="border-right:none;"><span class="delete_button"><a href="#" class="del_button" id="del-'.$my_id.'" title="Delete"><i class="fa fa-trash-o"></i></a></span></td>
</tr>';
 }
}
?>