<?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 width="93%" 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 bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
                        <tr>
                          <td colspan="4" bgcolor="#FFFFFF">&nbsp;</td>
                          <td bgcolor="#FFFFFF">&nbsp;</td>
                        </tr>
                        <tr>
                          <td width="3%" bgcolor="#FFFFFF"><strong>Sr</strong></td>
                          <td width="24%" align="left" bgcolor="#FFFFFF"><strong>Product</strong></td>
                          <td width="22%" align="left" bgcolor="#FFFFFF"><strong>Qty</strong></td>
                          <td width="19%" align="left" bgcolor="#FFFFFF"><strong>Unit Price</strong></td>
                          <td width="7%" align="left" bgcolor="#FFFFFF"><strong>Total </strong></td>
                        </tr>
                        <?php 
					
$today1=date("Y-m-d");
$today2=date("Y-m-d");
					
$date1=dtformat($_GET[date1]);
$date2=dtformat($_GET[date2]);

if($_GET[date1]!=''){$d1=" and date1>='$date1'";}else{$d1=" and date1>='$today1'";}
if($_GET[date2]!=''){$d2=" and date1<='$date2'";}else{$d2=" and date1<='$today2'";}	

 
 
 			$uresult=mysql_query("select sum(qty)as qty, product_type  from restaurant_chalan_product where date1!='' $d1 $d2  group by product_type  ");
			$urow=mysql_fetch_array($uresult);
			$sr=0;
			 			$sr++; 
						do{  
			 
			$tresult=mysql_query("select * from restaurant_product_details  WHERE id='$urow[product_type]'");
$trow=mysql_fetch_array($tresult);
						
			?>
                        <tr>
                          <td width="3%" valign="top" bgcolor="#FFFFFF" class="link"><?php echo $sr; ?></td>
                          <td bgcolor="#FFFFFF" ><?php echo $trow[pname];?></td>
                          <td bgcolor="#FFFFFF" ><?php echo $urow[qty]; $xt1=$xt1+$urow[qty];?></td>
                          <td bgcolor="#FFFFFF" ><?php echo $trow[sale_rate];?></td>
                          <td bgcolor="#FFFFFF" ><?php $tt=$urow[qty]*$trow[sale_rate]; echo number_format($tt);  $xt2=$xt2+$tt;?></td>
                        </tr>
                        <?php }while($urow=mysql_fetch_array($uresult));?>
                        <tr>
                          <td valign="top" bgcolor="#FFFFFF" class="link">&nbsp;</td>
                          <td bgcolor="#FFFFFF" >&nbsp;</td>
                          <td bgcolor="#FFFFFF" ><?php echo number_format($xt1); ?></td>
                          <td bgcolor="#FFFFFF" ></td>
                          <td bgcolor="#FFFFFF" ><?php echo number_format($xt2); ?></td>
                        </tr>
                      </table></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 restaurant_chalan where dtime!='' $d1 $d2 $salesteam $dtime order by id desc");
			$row=mysql_fetch_array($result);
			$sr=0;
			do{
			$sr++;
			?>
                    <?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 }?>