<?php session_start();
if($_SESSION[invcox] == ""){
header("location:login.php?action=need");
}else{

include("config.php");?>

 <?php 
$result=mysql_query("select * from chalan where id='$_GET[cid]' order by id desc");
			$row=mysql_fetch_array($result);
		
	$bresult=mysql_query("select * from client WHERE id='$row[client_id]'");
	$brow=mysql_fetch_array($bresult);
	
				?>
<style type="text/css">
 body {
	margin: 0px;
	font-size:10px;
	font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif;
}
 </style>
 
 <table width="100%" border="0" cellspacing="0" cellpadding="2">
                              <tbody>
                                <tr>
                                  <td><img src="images/logop.png" alt="" width="262" height="90"/></td>
                                </tr>
                                <tr>
                                  <td >Date:
                                      <?php 
			echo dtformat($row[cdate]);
				?>
                                  Invoice:
                                      <?php 
			 echo $row[id];
			   ?>
                                  </td>
                                </tr>
                                
                               
                                <tr>
                                  <td ><?php echo $brow[company];?></td>
                                </tr>
                                <tr>
                                  <td ><?php 
 
	echo $brow[phone];
				?></td>
                                </tr>
                                <tr>
                                  <td ><?php 
 
	echo $brow[address];
				?></td>
                                </tr>
                                <tr>
                                  <td > </td>
                                </tr>
                                <tr>
                                  <td valign="top" ><table width="100%" border="0" cellspacing="0" cellpadding="1" bgcolor="#000000">
                                    <tbody>
                                      <tr>
                                        <td width="6%" align="center" bgcolor="#FFFFFF" >SL</td>
                                        <td width="50%" align="center" bgcolor="#FFFFFF" >Item</td>
                                        <td width="16%" align="center" bgcolor="#FFFFFF" >Price</td>
                                        <td width="9%" align="center" bgcolor="#FFFFFF" >Qty</td>
                                        <td width="19%" align="center" bgcolor="#FFFFFF" >Total</td>
                                      </tr>
                                      <?php 
$uresult=mysql_query("select * from chalan_product WHERE cid='$_GET[cid]'");
$urow=mysql_fetch_array($uresult);
$sr1=0;
$total_prize=0;
 do{
$sr1=$sr1+1;

$tresult=mysql_query("select * from product_details  WHERE id='$urow[product_type]'");
$trow=mysql_fetch_array($tresult);
?>
                                      <tr>
                                        <td colspan="5" align="center" bgcolor="#FFFFFF" >--------------------------------------</td>
                                      </tr>
                                      <tr>
                                        <td align="center" bgcolor="#FFFFFF" ><?php echo $sr1;?></td>
                                        <td bgcolor="#FFFFFF" ><?php echo $trow[pname];?></td>
                                        <td bgcolor="#FFFFFF" ><?php echo $urow[unit_price];?></td>
                                        <td bgcolor="#FFFFFF" ><?php echo $urow[qty];?></td>
                                        <td align="right" bgcolor="#FFFFFF" ><?php echo number_format($urow[total_prize]); 
									$total_prize=$total_prize+$urow[total_prize];?></td>
                                      </tr>
                                      <?php }while($urow=mysql_fetch_array($uresult));?>
                                     
                                      <tr>
                                        <td colspan="5" align="center" bgcolor="#FFFFFF" >--------------------------------------</td>
                                      </tr>
                                      <tr>
                                        <td colspan="4" align="center" bgcolor="#FFFFFF" ><?php echo number_format($total_prize); ?> Taka Only</td>
                                        <td align="right" bgcolor="#FFFFFF" ><?php echo number_format($total_prize); ?>&nbsp; </td>
                                      </tr>
                                    </tbody>
                                  </table></td>
                                </tr>
                                <tr>
                                  <td ><table width="100%" border="0" cellspacing="0" cellpadding="3">
                                    <tbody>
                                      <tr>
                                        <td width="51%" align="center" valign="middle" >Thank you for your Order</td>
                                      </tr>
                                    </tbody>
                                  </table></td>
                                </tr>
                              </tbody>
                            </table>
<?php }?>
<script language="javascript">
window.print();
</script>