<?php

include('connection.php');
//echo "showing Ideal_quotation_update_div.php";
$Ideal=$_GET['Ideal'];
$Ideal_name=$_GET[rawurldecode('Ideal_name')];
$Title=$_GET['Title'];
$Company=$_GET['Company'];
$Address=$_GET['Address'];
//$q=$_GET['q'];
$Client=$_GET['Client'];
$Client_name=$_GET['Client_name'];
$Terms=$_GET['Terms'];
$Terms1=$_GET['Terms1'];
$Terms2=$_GET['Terms2'];
$Emp_id=$_GET['Emp_id'];
$Emp=$_GET['Emp'];
$time=$_GET['time'];
$Increment=$_GET['Increment'];

$Inst_charges=$_GET['Inst_charges'];
$charges=$_GET['charges'];
$Inst=$_GET['Inst'];
//$Transport=$_GET['Transport'];
//$Wastage=$_GET['Wastage'];
//$Profit=$_GET['Profit'];

$Amount=0;
$itemrows=1;
$total=0;

$que="SELECT `Company_name` FROM `company_osmosis` WHERE `Company_code`='$Company'";
$query=mysqli_query($GLOBALS["___mysqli_ston"], $que) or die ("Query Fail:".mysqli_error($GLOBALS["___mysqli_ston"]));
while($rw=mysqli_fetch_assoc($query))
{
$Company_name=$rw['Company_name'];

}


$sql_no="SELECT `quo_no` FROM `quo_data` WHERE `Ideal_quotation_name`='$Ideal_name'";
$result_no=mysqli_query($GLOBALS["___mysqli_ston"], $sql_no) or die ("Error Message" . mysqli_error($GLOBALS["___mysqli_ston"]));

	while($rno=mysqli_fetch_assoc($result_no))
	{
	$q=$rno['quo_no'];
	
	}



echo 
"<table border='1' bgcolor=#FFFFFF style='border-collapse: collapse; border-style: solid; border-width: 1px;' width='100%'>
<tr >
<td align='center' width='20%' bgcolor='#999999' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>Quotation no</td>
<td align='center' width='20%' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee' size='2'> $q </td>
<td align='center' width='20%' bgcolor='#999999' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>Company Name</td>
<td align='center' width='20%' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee' size='2'>$Company_name</td>
</tr>
 <tr>
 <td align='center' colspan='9' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>&nbsp;</td>
 </tr>
</table>";



echo "<table border='1' width='100%' bgcolor=#FFFFFF style='border-collapse: collapse; border-style: solid; border-width: 1px;'>
<tr bgcolor='#999999'>
<td align='center' width=10%><font color='white' font face='Leelawadee'>
<span style=' padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px; font-weight:400'>Sr. No</span></td>
<td align='center' width=50%><font color='white' font face='Leelawadee'>
<span style='padding-left: 1px; padding-right: 1px; padding-top: 3px; padding-bottom: 3px; font-weight:400'>Name </span></td>
<td align='center' width=50%><font color='white' font face='Leelawadee'>
<span style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px; font-weight:400'>Rate</span></td>

</tr>
 </table>";

	


$sql="SELECT * FROM `quo_data` WHERE `Ideal_quotation_name`='$Ideal_name'";
$result=mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die ("Error Message" . mysqli_error($GLOBALS["___mysqli_ston"]));
	if(mysqli_num_rows($result)>0)
	{
	while($r1=mysqli_fetch_assoc($result))
	{
	$Type=$r1['type'];
	$Topic_name=$r1['Topic_name'];
	$Topic_des=$r1['Topic_des'];
	$No_days=$r1['No_days'];
	$Max=$r1['Max'];
	$Min=$r1['Min'];
	$Rate=$r1['tRate'];
	$Noe=$r1['Noe'];
	$Twh=$r1['Twh'];
	$q=$r1['quo_no'];
	$mname=$r1['mname'];
	$mdisc=$r1['mdisc'];
	$mrate=$r1['mrate'];
	$warranty=$r1['warranty'];
	$month=$r1['month'];
	$serialno1=$r1['serialno1'];
	$modelno=$r1['modelno'];
	
	
	
	
	If($Type=='topic_quotation')
{
echo "<table border='1' width='100%' bgcolor=#FFFFFF style='border-collapse: collapse; border-style: solid; border-width: 1px;'>
<tr>
<td align='center' width=10%><font face='Leelawadee'>
<span style=' padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px; font-weight:400'>$itemrows</span></td>
<td align='center' width=50%><font face='Leelawadee'>
<span style='padding-left: 1px; padding-right: 1px; padding-top: 3px; padding-bottom: 3px; font-weight:400'>$Topic_name</span></td>
<td align='center' width=50%><font face='Leelawadee'>
<span style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px; font-weight:400'>$Rate</span></td>

</tr>
 </table>";
$itemrows++;
$total=$total+$Rate;
}

if($Type=="machine_master")
{
echo "<table border='1' width='100%' bgcolor=#FFFFFF style='border-collapse: collapse; border-style: solid; border-width: 1px;'>
<tr>
<td align='center' width=10%><font face='Leelawadee'>
<span style=' padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px; font-weight:400'>$itemrows</span></td>
<td align='center' width=50%><font face='Leelawadee'>
<span style='padding-left: 1px; padding-right: 1px; padding-top: 3px; padding-bottom: 3px; font-weight:400'>$mname</span></td>
<td align='center' width=50%><font face='Leelawadee'>
<span style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px; font-weight:400'>$mrate</span></td>

</tr>
 </table>";
$itemrows++;
$total=$total+$mrate;
}
}
}

echo "<table border='1' width='100%' bgcolor=#FFFFFF style='border-collapse: collapse; border-style: solid; border-width: 1px;'>
<tr bgcolor='#999999'>
<td align='center' width=60%><font color='white' font face='Leelawadee'>
<span style=' padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px; font-weight:400'>Total Rs.</span></td>
<td align='center' width=40%><font color='white' font face='Leelawadee'>
<span style='padding-left: 1px; padding-right: 1px; padding-top: 3px; padding-bottom: 3px; font-weight:400'>$total</span></td>
</tr></table>";

$sql1="SELECT * FROM `quotation_ideal` WHERE `Ideal_quotation_name`='$Ideal_name'";

$result1=mysqli_query($GLOBALS["___mysqli_ston"], $sql1) or die ("Error Message" . mysqli_error($GLOBALS["___mysqli_ston"]));
	if(mysqli_num_rows($result1)>0)
	{
	while($r2=mysqli_fetch_assoc($result1))
	{
	$Increment=$r2['Increment'];
	$Profit=$r2['Profit'];
	$Wastage=$r2['Watage'];
	$Transport=$r2['Transport'];
	}
	}

$TRANS=$Transport;
$WASTE=($Wastage*$total/100);
$PROFIT=($Profit*$total/100);
$INCREMENT=($Increment*$total/100);

//echo $Inst_charges;
/*
if($Inst_charges!='')
	{
 //echo $charges;
 $GRAND_TOTAL=$total+$TRANS+$WASTE+$PROFIT+$INCREMENT+$charges;
 
 //echo $GRAND_TOTAL;
 
 echo "<table border='1' width='100%' bgcolor=#FFFFFF style='border-collapse: collapse; border-style: solid; border-width: 1px;'> 
 <tr>
 <td align='center' colspan='9' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>&nbsp;</td>
 </tr>
 <tr bgcolor='#EFEFEF'>
  <td align='center' colspan='5' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>CHARGES</td>
<td align='center' colspan='1' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>RATE</td>
<td align='center' colspan='3' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>Amount (in Rs.)</td>
 </tr>
 <tr>
 <td align='center' colspan='9' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>&nbsp;</td>
 </tr>

<tr>
<td align='center' colspan='5' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>TRANSPORTATION CHARGES</td>
 <td align='center' colspan='1' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$Transport Rs.</td>
 <td align='center' colspan='3' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$Transport</td>
</tr>
 <tr>
 <td align='center' colspan='9' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>&nbsp;</td>
 </tr>

<tr bgcolor='#EFEFEF'>
<td align='center' colspan='5' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>WASTAGE CHARGES</td>
<td align='center' colspan='1' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$Wastage %</td>
<td align='center' colspan='3' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$WASTE</td>
</tr>
 <tr>
 <td align='center' colspan='9' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>&nbsp;</td>
 </tr>

<tr>
<tr bgcolor='#EFEFEF'>
<td align='center' colspan='5' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>PROFIT CHARGES</td>
<td align='center' colspan='1' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$Profit %</td>
<td align='center' colspan='3' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$PROFIT</td>
</tr>
 <tr>
 <td align='center' colspan='9' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>&nbsp;</td>
 </tr>

<tr bgcolor='#EFEFEF'>
<td align='center' colspan='5' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>MARGIN</td>
<td align='center' colspan='1' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$Increment %</td>
<td align='center' colspan='3' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$INCREMENT</td>
</tr>
 <tr>
 <td align='center' colspan='9' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>&nbsp;</td>
 </tr>
 
 
 <tr bgcolor='#EFEFEF'>
<td align='center' colspan='5' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>INSTALLATION & LABOUR CHARGES</td>
<td align='center' colspan='1' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$charges Rs.</td>
<td align='center' colspan='3' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$charges</td>
</tr>
 <tr>
 <td align='center' colspan='9' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>&nbsp;</td>
 </tr>
 

 
 <tr bgcolor='#EFEFEF'>
<td align='center' colspan='5' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>&nbsp;</td>
<td align='center' colspan='1' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>GRAND TOTAL</td>
<td align='center' colspan='3' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$GRAND_TOTAL</td>
</tr>
 <tr>
 <td align='center' colspan='9' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>&nbsp;</td>
 </tr>


</table>";


}
else
{
	*/
	 $GRAND_TOTAL=$total+$TRANS+$WASTE+$PROFIT+$INCREMENT;
	 
	 echo "<table border='1' width='100%' bgcolor=#FFFFFF style='border-collapse: collapse; border-style: solid; border-width: 1px;'> 
 <tr>
 <td align='center' colspan='9' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>&nbsp;</td>
 </tr>
 <tr bgcolor='#EFEFEF'>
  <td align='center' colspan='5' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>CHARGES</td>
<td align='center' colspan='1' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>RATE</td>
<td align='center' colspan='3' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>Amount</td>
 </tr>
 <tr>
 <td align='center' colspan='9' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>&nbsp;</td>
 </tr>

<tr>
<td align='center' colspan='5' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>TRANSPORTATION CHARGES</td>
 <td align='center' colspan='1' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$Transport Rs.</td>
 <td align='center' colspan='3' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$Transport</td>
</tr>
 <tr>
 <td align='center' colspan='9' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>&nbsp;</td>
 </tr>

<tr bgcolor='#EFEFEF'>
<td align='center' colspan='5' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>WASTAGE CHARGES</td>
<td align='center' colspan='1' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$Wastage %</td>
<td align='center' colspan='3' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$WASTE</td>
</tr>
 <tr>
 <td align='center' colspan='9' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>&nbsp;</td>
 </tr>

<tr>
<tr bgcolor='#EFEFEF'>
<td align='center' colspan='5' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>PROFIT CHARGES</td>
<td align='center' colspan='1' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$Profit %</td>
<td align='center' colspan='3' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$PROFIT</td>
</tr>
 <tr>
 <td align='center' colspan='9' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>&nbsp;</td>
 </tr>

<tr bgcolor='#EFEFEF'>
<td align='center' colspan='5' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>MARGIN</td>
<td align='center' colspan='1' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$Increment %</td>
<td align='center' colspan='3' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$INCREMENT</td>
</tr>
 <tr>
 <td align='center' colspan='9' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>&nbsp;</td>
 </tr>
 
 
 <tr bgcolor='#EFEFEF'>
<td align='center' colspan='5' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>&nbsp;</td>
<td align='center' colspan='1' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>GRAND TOTAL</td>
<td align='center' colspan='3' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>$GRAND_TOTAL</td>
</tr>
 <tr>
 <td align='center' colspan='9' style='padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px'><font face='Leelawadee'>&nbsp;</td>
 </tr>


</table>";
	
	

?>
