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

include("config.php");?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>A2Z Accounting Software</title>
<link href="print.css" rel="stylesheet" type="text/css" />
<style type="text/css">
@media print {
	.page-break	{ display: block; page-break-after: always; padding-bottom:50px;}
}
</style>
<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> 
</head>

<body>

<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
                    <?php 
$date1=dtformat($_GET[date1]);
$date2=dtformat($_GET[date2]);
if($_GET[date1]!=''){$d1=" and cdate>='$date1'";}else{$d1="";}
if($_GET[date2]!=''){$d2=" and cdate<='$date2'";}else{$d2="";}	

if($_GET[salesteam]!=''){$salesteam=" and salesteam='$_GET[salesteam]'";}else{$salesteam="";}	
if($_GET[dtime]!=''){$dtime=" and dtime='$_GET[dtime]'";}else{$dtime="";}	

 			$result=mysql_query("select * from chalan where dtime!='' $d1 $d2 $salesteam $dtime order by id desc");
			$row=mysql_fetch_array($result);
			$sr=0;
			$gsr=0;
			
			?>
                    <tr>
                    <?php do{
						 
						$gsr=$gsr+1;
						
						$sr=$sr+1;?>
                      <td width="25%" valign="top" bgcolor="#FFFFFF" class="link"><table width="100%" border="0" cellspacing="0" cellpadding="3">
                        <tbody>
                          <tr>
                            <td><table width="100%" border="0" cellspacing="0" cellpadding="2">
                              <tbody>
                                <tr>
                                  <td colspan="2">&nbsp;</td>
                                </tr>
                                <tr>
                                  <td colspan="2"> <img src="images/header.jpg" width="200" alt=""/></td>
                                </tr>
                                <tr>
                                  <td width="58%" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><span  >Invoice to</span>:
                                    <?php 
		
		
	$bresult=mysql_query("select * from client WHERE id='$row[client_id]'");
	$brow=mysql_fetch_array($bresult);
	echo $brow[company];
				?></td>
                                  <td width="42%" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif">Date:
                                    <?php 
			echo dtformat($row[cdate]);
				?></td>
                                </tr>
                                <tr>
                                  <td style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif">Phone :
                                    <?php 
 
	echo $brow[phone];
				?></td>
                                  <td style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif">Invoice:
                                    <?php 
			 echo $row[id];
			   ?></td>
                                </tr>
                                <tr>
                                  <td colspan="2" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif"><?php 
 
	echo $brow[address];
				?></td>
                                </tr>
                                <tr>
                                  <td colspan="2" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"> </td>
                                </tr>
                                <tr>
                                  <td colspan="2" valign="top" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif"><table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#000000">
                                    <tbody>
                                      <tr>
                                        <td width="6%" align="center" bgcolor="#FFFFFF" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif"><span class="invoicefont">SL</span></td>
                                        <td width="50%" align="center" bgcolor="#FFFFFF" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif"><span class="invoicefont">Item Description</span></td>
                                        <td width="16%" align="center" bgcolor="#FFFFFF" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif"><span class="invoicefont">Price</span></td>
                                        <td width="9%" align="center" bgcolor="#FFFFFF" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif"><span class="invoicefont">Qty</span></td>
                                        <td width="19%" align="center" bgcolor="#FFFFFF" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif"><span class="invoicefont">Total</span></td>
                                      </tr>
                                      <?php 
$uresult=mysql_query("select * from chalan_product WHERE cid='$row[id]'");
$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 align="center" bgcolor="#FFFFFF" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif"><span class="invoicefont"><?php echo $sr1;?></span></td>
                                        <td bgcolor="#FFFFFF" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif"><span class="invoicefont"><?php echo $trow[pname];?></span></td>
                                        <td bgcolor="#FFFFFF" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif"><span class="invoicefont"><?php echo $urow[unit_price];?></span></td>
                                        <td bgcolor="#FFFFFF" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif"><span class="invoicefont"><?php echo $urow[qty];?></span></td>
                                        <td align="right" bgcolor="#FFFFFF" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif"><span class="invoicefont"><?php echo number_format($urow[total_prize]); 
									$total_prize=$total_prize+$urow[total_prize];?></span></td>
                                      </tr>
                                      <?php }while($urow=mysql_fetch_array($uresult));?>
                                      <tr>
                                        <td colspan="4" align="center" bgcolor="#FFFFFF" class="invoicefont" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif"> Delivary charge </td>
                                        <td align="right" bgcolor="#FFFFFF"><span class="invoicefont" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif">30
                                          <?php $total_prize=$total_prize+30;?>
                                        </span></td>
                                      </tr>
                                      <tr>
                                        <td colspan="4" align="center" bgcolor="#FFFFFF" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif"><span class="invoicefont"><?php echo number_format($total_prize); ?> Taka Only</span></td>
                                        <td align="right" bgcolor="#FFFFFF" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif"><span class="invoicefont"><?php echo number_format($total_prize); ?>&nbsp; </span></td>
                                      </tr>
                                    </tbody>
                                  </table></td>
                                </tr>
                                <tr>
                                  <td colspan="2" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif"><table width="100%" border="0" cellspacing="0" cellpadding="3">
                                    <tbody>
                                      <tr>
                                        <td colspan="3">&nbsp;</td>
                                      </tr>
                                      <tr>
                                        <td width="51%" valign="middle" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif"><span class="invoicefont">Thank you for your Order</span></td>
                                        <td width="16%">&nbsp;</td>
                                        <td width="33%"><span class="invoicefont"><img src="images/signature_smoll.jpg" width="136" height="57" alt=""/></span></td>
                                      </tr>
                                      <tr>
                                        <td>&nbsp;</td>
                                        <td>&nbsp;</td>
                                        <td style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif"><span class="invoicefont">Authorised Sign</span></td>
                                      </tr>
                                    </tbody>
                                  </table></td>
                                </tr>
                              </tbody>
                            </table></td>
                          </tr>
                        </tbody>
                      </table></td><?php 
					  if($sr == "3"){echo '</tr><tr>'; $sr=0;}
					  
if($gsr == "6"){echo '</tr></table><div class="page-break"></div><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"><tr>'; $gsr=0;} 
					  
					  }while($row=mysql_fetch_array($result));
					  echo $sr;
					  if($sr<"3"){echo '<td bgcolor="#FFFFFF" > </td>'; $sr=$sr+1; }
					  if($sr<"3"){echo '<td bgcolor="#FFFFFF" > </td>'; $sr=$sr+1;}
					  if($sr<"3"){echo '<td bgcolor="#FFFFFF" > </td>'; $sr=$sr+1;}
					  
					  
					 
					  
					  
					  ?>
                      </tr>
                    
                  </table>
</body>
</html>
<?php }?>