<?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'];

$papertypeone=$_POST['papertypeone'];
$papertypetwo=$_POST['papertypetwo'];
$papertypethree=$_POST['papertypethree'];
$papertypefour=$_POST['papertypefour'];
$papertypefive=$_POST['papertypefive'];
$papergsmone=$_POST['papergsmone'];
$papergsmtwo=$_POST['papergsmtwo'];
$papergsmthree=$_POST['papergsmthree'];
$papergsmfour=$_POST['papergsmfour'];
$papergsmfive=$_POST['papergsmfive'];


$inkcolor=$_POST['inkcolor'];
$numberofbooks=$_POST['numberofbooks'];
$numberofsetsperbooks=$_POST['numberofsetsperbooks'];
$startingno=$_POST['startingno'];
$typeofbndboard=$_POST['typeofbndboard'];
$binding=$_POST['binding'];
$stapling=$_POST['stapling'];
$stitching=$_POST['stitching'];
$pasting=$_POST['pasting'];
$prntlastcopy=$_POST['prntlastcopy'];

$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 estimatetwo_temp_table(customer,product_code,product_name,machine_id,category_id,type_one,type_two,type_three,type_four,type_five,pr_length,pr_width,gsm_one,gsm_two,gsm_three,gsm_four,gsm_five,inkcolor,numberofbooks,numberofsetsperbooks,startingno,typeofbndboard,binding,stapling,stitching,pasting,prntlastcopy,typeofwork,workdescription,amount,tax,date,permission,user)

values ('$customer','$cod','$name','$machinename','$categor','$papertypeone','$papertypetwo','$papertypethree','$papertypefour','$papertypefive','$length','$prwidth','$papergsmone','$papergsmtwo','$papergsmthree','$papergsmfour','$papergsmfive','$inkcolor','$numberofbooks','$numberofsetsperbooks','$startingno','$typeofbndboard','$binding','$stapling','$stitching','$pasting','$prntlastcopy','$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 estimate_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%">'.$papertypeone.'</td>
<td width="12%">'.$papergsmone.'</td>
<td width="11%">'.$inkcolor.'</td>
<td width="11%">'.$numberofbooks.'</td>
<td width="11%">'.$numberofsetsperbooks.'</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>';
 }
}
?>