<?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="style.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>
<?php include("calendar.php");?>

<meta name="viewport" content="width=device-width, initial-scale=1.0">
</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"><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; Invoice List</strong></td>
              </tr>
            </table></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"><form id="form1" name="form1" method="post" action="invoice_list-custom.php">
                          <table width="100%" border="0" cellspacing="1" cellpadding="2">
                            <tbody>
                              <tr>
                                <td><table width="150" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                      <td width="70%"><?php 
$lastsaterday=date("Y-m-d");
 ?>
                                        <input name="date1" type="text" id="date1" value="<?php if($_POST[date1] == ""){echo dtformat($lastsaterday);}else{echo $_POST[date1];} ?>" size="15" /></td>
                                      <td width="30%" align="center"><a title="Calendar" onclick="displayDatePicker('date1', this);" href="javascript:;"><img src="images/calendar.gif" width="20" height="20" border="0" /></a></td>
                                    </tr>
                                  </table></td>
                              </tr>
                              <tr>
                                <td><table width="150" border="0" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td width="70%"><?php 
$lastsaterday=date("Y-m-d");
 ?>
                                      <input name="date2" type="text" id="date2" value="<?php if($_POST[date1] == ""){echo dtformat($lastsaterday);}else{echo $_POST[date1];} ?>" size="15" /></td>
                                    <td width="30%" align="center"><a title="Calendar" onclick="displayDatePicker('date2', this);" href="javascript:;"><img src="images/calendar.gif" width="20" height="20" border="0" /></a></td>
                                    </tr>
                                </table></td>
                              </tr>
                              <tr>
                                <td><input name="submit" type="submit" id="submit" formaction="invoice_list-custom.php" value="Submit" /></td>
                              </tr>
                              <tr>
                                <td>&nbsp;</td>
                              </tr>
                            </tbody>
                          </table>
                      </form></td>
                    </tr>
                    <tr>
                      <td height="98" valign="top"><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
                          <tr>
                            <td colspan="4" bgcolor="#FFFFFF">&nbsp;</td>
                            <td bgcolor="#CCCCCC"><span class="link"><a href="print_invoice_list_custom.php?date1=<?php echo $_POST[date1]; ?>&amp;date2=<?php echo $_POST[date2]; ?>&amp;salesteam=<?php echo $_POST[salesteam]; ?>&amp;dtime=<?php echo $_POST[dtime]; ?>" target="_blank"><img src="images/print.png" width="20" height="20" alt=""/></a></span></td>
                          </tr>
                          <tr>
                            <td width="3%" bgcolor="#74DCB3"><strong>Sr</strong></td>
                            <td width="24%" align="left" bgcolor="#74DCB3">Product</td>
                            <td width="22%" align="left" bgcolor="#74DCB3">Qty</td>
                            <td width="19%" align="left" bgcolor="#74DCB3">Unit Price</td>
                            <td width="7%" align="left" bgcolor="#74DCB3">TOtal </td>
                          </tr>
                          <?php 
					
$today1=date("Y-m-d");
$today2=date("Y-m-d");
					
$date1=dtformat($_POST[date1]);
$date2=dtformat($_POST[date2]);

if($_POST[date1]!=''){$d1=" and date1>='$date1'";}else{$d1=" and date1>='$today1'";}
if($_POST[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="#74DCB3" class="link">&nbsp;</td>
                            <td bgcolor="#74DCB3" >&nbsp; </td>
                            <td bgcolor="#74DCB3" ><?php echo number_format($xt1); ?></td>
                            <td bgcolor="#74DCB3" > </td>
                            <td bgcolor="#74DCB3" ><?php echo number_format($xt2); ?></td>
                          </tr>
                        </table>
                        <br /></td>
                    </tr>
                  </table>
                  <br /></td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td><?php include("bot.php")?></td>
  </tr>
</table>
</body>
</html>
<?php }?>