<?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" />
<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="95%" border="0" align="center" cellpadding="0" cellspacing="1" class="box-wrap">
  <tr>
    <td><?php //include("top.php")?></td>
  </tr>
  <tr>
    <td valign="top" class="center_page_white"><table width="100%" border="0" cellspacing="1" cellpadding="0">
      <tr>
        <td align="center" class="red">&nbsp;</td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="1" cellpadding="0">
        <tr>
          <td valign="top"><table width="100%" border="0" cellspacing="1" cellpadding="0">
            <tr>
              <td valign="top"></td>
            </tr>
            <tr>
              <td valign="top"><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
                    <tr>
                      <td colspan="8" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tbody>
                          <tr>
                            <td width="55%"><img src="images/logop.png" width="262" height="90" alt=""/></td>
                            <td width="45%">&nbsp;</td>
                          </tr>
                        </tbody>
                      </table></td>
                      </tr>
                    <tr>
                      <td width="3%" bgcolor="#FFFFFF"><span class="smoll"><strong>Sr</strong></span></td>
                      <td width="8%" bgcolor="#FFFFFF"><span class="smoll"><strong>Invoice No  </strong></span></td>
                      <td width="11%" align="left" bgcolor="#FFFFFF"><span class="smoll"><strong>Date </strong></span></td>
                      <td width="14%" align="left" bgcolor="#FFFFFF"><span class="smoll"><strong>Customer </strong></span></td>
                      <td width="10%" align="left" bgcolor="#FFFFFF"><span class="smoll">phone </span></td>
                      <td width="24%" align="left" bgcolor="#FFFFFF"><span class="smoll">item</span></td>
                      <td width="8%" align="left" bgcolor="#FFFFFF"><span class="smoll">Delivary Time</span></td>
                      <td width="15%" align="left" bgcolor="#FFFFFF"><span class="smoll">adress</span></td>
                      </tr>
                    <?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;
			do{
			$sr++;
			?>
                    <tr>
                      <td width="3%" valign="top" bgcolor="#FFFFFF" class="link"><span class="smoll"><?php echo $sr; ?></span></td>
                      <td width="8%" valign="top" bgcolor="#FFFFFF" class="link">
					    <span class="smoll">
					  <?php 
			 echo $row[id];
			   ?>
					    </span></td>
                      <td width="11%" align="left" valign="top" bgcolor="#FFFFFF" class="link"><span class="smoll">
                        <?php 
			echo dtformat($row[cdate]);
				?>
                      </span></td>
                      <td width="14%" align="left" valign="top" bgcolor="#FFFFFF" class="link"><span class="smoll">
                        <?php 
		
		
	$bresult=mysql_query("select * from customer WHERE id='$row[client_id]'");
	$brow=mysql_fetch_array($bresult);
	echo $brow[customer_name];
	echo " - ";
	echo $brow[personal_phn];
				?> 
                      </span></td>
                      <td width="10%" align="left" valign="top" bgcolor="#FFFFFF" class="link"><span class="smoll">
                      <?php 
 
	echo $brow[phone];
				?>
                      </span></td>
                      <td width="24%" align="left" valign="top" bgcolor="#FFFFFF" class="link"> <table width="100%" border="0" cellspacing="2" cellpadding="0">
              <?php 

$uresult=mysql_query("select * from chalan_product WHERE cid='$row[id]'");
$urow=mysql_fetch_array($uresult);

 do{
	
$tresult=mysql_query("select * from product_details  WHERE id='$urow[product_type]'");
$trow=mysql_fetch_array($tresult);
?>
              <tr >
                <td width="33%" bgcolor="#FFFFFF" ><span class="smoll"><?php echo $trow[pname];?></span></td>
                <td width="26%" bgcolor="#FFFFFF" ><span class="smoll"><?php echo $urow[qty];?></span></td>
                <td width="21%" bgcolor="#FFFFFF" ><span class="smoll"><?php echo $urow[unit_price];?></span></td>
                <td width="20%" bgcolor="#FFFFFF" ><span class="smoll"><?php echo $urow[total_prize];?></span></td>
              </tr>
              <?php }while($urow=mysql_fetch_array($uresult));?>
            </table>
                        <span class="smoll">
                        </p>
                        </span></td>
                      <td width="8%" align="left" valign="top" bgcolor="#FFFFFF" class="link"><span class="smoll">
                        <?php 
			 echo $row[dtime];
			   ?>
                      </span></td>
                      <td width="15%" align="left" valign="top" bgcolor="#FFFFFF" class="link"><span class="smoll">
                        <?php 
 
	echo $brow[address];
				?>
                      </span></td>
                      </tr>
                    <?php }while($row=mysql_fetch_array($result));?>
                  </table>
                <br /></td>
            </tr>
          </table>
            <br /></td>
        </tr>
      </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>
<?php }?>