<?php session_start();
 include("config.php");?>

<link href="style.css" rel="stylesheet" type="text/css">

<title>chalan </title>

<SCRIPT LANGUAGE="JavaScript">



<!-- Begin

function popUp(URL) {

day = new Date();

id = day.getTime();

eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=1,resizable=yes,width=800,height=550,left = 100,top = 50');");

}

// End -->

</script>
<table width="95%" height="656" border="0" align="center" cellpadding="0" cellspacing="0">

  <tr>

    <td><?php include("top.php")?></td>
  </tr>

  <tr>
    <td height="25" align="right"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="30" background="images/place_bg.jpg" class="link2"><strong>&nbsp;&nbsp;<a href="index.php">Home</a> &gt; <a href="sales.php">Sales</a> &gt; <a href="chalan_entry.php">Create Invoice </a> &gt; <a href="chalan_view.php">Invoice View </a></strong></td>
      </tr>
    </table></td>
  </tr>
  <tr>

    <td height="25" align="right" bgcolor="#FFFFFF" class="link"><table width="100%" border="0" cellspacing="2" cellpadding="0">

      <tr>

        <td width="25%">&nbsp;</td>

        <td width="40%" height="25">&nbsp;</td>

        <td width="22%" align="center" bgcolor="#CCCCCC"><a href="chalan_entry.php"><strong>&lt; Back to Invoice Entry </strong></a></td>

        <td width="13%" align="center" bgcolor="#999999"><strong><a href="JavaScript:popUp('print_chalan.php?cid=<?php echo $_GET[cid];?>');">Print </a></strong></td>
      </tr>

    </table>      

    <strong>&nbsp; </strong></td>
  </tr>

  <tr>

    <td height="346" valign="top" bgcolor="#FFFFFF"><br>
      <table width="100%" border="0" cellspacing="0" cellpadding="2">
        <tbody>
    <tr>
      <td align="center"><img src="images/logop.png" alt="" width="262" height="90"/><br>
        <span class="smoll"><strong class="learge">
        <?php 

	$result=mysql_query("select * from chalan WHERE id='$_GET[cid]'");
	$row=mysql_fetch_array($result);

 

	$xbresult=mysql_query("select * from company WHERE id='$row[com_id]'");

	$xbrow=mysql_fetch_array($xbresult);

	echo $xbrow[company];

	?>
        </strong><br>
        <?php echo $xbrow[address];?></span></td>
    </tr>
    <tr>
      <td >Date:
        <?php 
			echo dtformat($row[cdate]);
				?>
        <br>
        Invoice:
        <?php 
			 echo $row[id];
			   ?></td>
    </tr>
    <tr>
      <td >&nbsp;</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="2" 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 cp . * , pd . *
FROM chalan_product cp
JOIN product_details pd ON pd.id = cp.product_type
WHERE cp.cid = '$_GET[cid]'");
$urow=mysql_fetch_array($uresult);
$sr1=0;
$total_prize=0;

 

 do{
$sr1=$sr1+1;
 
?>
            <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 $urow[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></td>
  </tr>

  <tr>

    <td valign="bottom" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">

      <tr>

        <td width="43%" height="26">&nbsp;</td>
        </tr>

      <tr>

        <td align="center">&nbsp;</td>
        </tr>

    </table></td>
  </tr>
  <tr>
    <td valign="bottom" bgcolor="#FFFFFF">&nbsp;</td>
  </tr>
  <tr>
    <td><?php include("bot.php")?></td>
  </tr>
</table>

<br />

&nbsp;

<script language="javascript">

//popUp('print_chalan.php?cid=<?php echo $_GET[cid];?>');

</script>