<h2> <?php  echo  $page_title;
include('Class-ItemMaster.php');
?></h2>

<form action="" method="post">
<table width="50%" border="0">
  <tr>
  	<td>Site</td>
  	<td><select name="site" id="site">
  		<option value="000">--ALL--</option>
  		<?php
  		$sql="Select loccode,locationname from locations where CompanyId='".$_SESSION['ACGCompanyId']."' and loccode in ('".$_SESSION['AssignedBranch']."')";
		$sitesql=DB_query($sql,$db);
		
  		
         while($siteres=DB_fetch_array($sitesql))  	
		 {
		 	?>
		 	<option value="<?php echo $siteres['loccode'];?>"><?php echo $siteres['locationname'];?></option>
			
			<?php
		 }	
		 ?>
  		
  		</select>
  	</td>
    <td>ITEM:		</td>
    <td><?php echo $ClassItem->GetItem($_REQUEST['ItemList']);
	
	?></td>
	    <td>TO:</td>
    <td><input name="todate"  class="datepicker"type="text" value="<?php  echo $_REQUEST['todate'];?>"  readonly="true" ></td>
 <td>From:</td>
    <td><input name="fromdate"  class="datepicker"type="text" value="<?php echo $_REQUEST['fromdate'] ?>" readonly="true" ></td>
	<td><input name="Go" type="submit" value="Go"></td>
  </tr>
   
</table>
</form>

<?php 
  if($_REQUEST['Go']){
$filter='1=1 ';

 
     if($_REQUEST['todate']!='' && $_REQUEST['fromdate']!='')
	 $filter.=" and A.prdate between '".FormatDateForSQL($_REQUEST['todate'])."' AND '".FormatDateForSQL($_REQUEST['fromdate']) ."' ";
	 
	 if($_REQUEST['ItemList']!='000' ) 
	 $filter.=" and B.mst_itemid='".$_REQUEST['ItemList']."' ";
	 if($_REQUEST['site']!='000' ) 
	 {
	 $filter.=" and A.sitecode='".$_REQUEST['site']."' ";
	 }
	 else {
		  $filter.=" and 1=1";
	 }
	 
        $sql2 = "select * ,(B.required_qty) as REQ , (B.App_quantity) as  APPREQ ,B.status AS Bstatus  from materialrequisitions A,requisitionorderdetails  B  where A.requisitionno=B.requsitionno  and  $filter  ";
  }else
  {
  	      $sql2 = "select * ,(B.required_qty) as REQ , (B.App_quantity) as  APPREQ ,B.status AS Bstatus  from materialrequisitions A,requisitionorderdetails  B  where A.requisitionno=B.requsitionno   ";
  }
  
   
?>
<table width="100%" border="0" class="inborder">
  <tr  style="background-color:#B7B7B7 " >
    <th width="6%">SNo.</th>  
   <th width="18%">Site</th> 
    <th width="11%">Date</th>
	<th width="20%">Reqno.</th>
    <th width="13%">Item Code </th>
    <th width="11%">Item Name </th>
	  <th width="11%">PR Qty </th>
	  <th width="10%">Status</th>
  </tr>
  
   <?php

$i=1;
	 $res = DB_query($sql2,$db);
  	 while($row = DB_fetch_array($res))
	 {
	 ?>
  <tr bgcolor="#FFFFFF" onmouseover="this.style.backgroundColor='#fffeb3'; this.style.color='#00f';" onmouseout="this.style.backgroundColor='#FFF'; this.style.color='#000000';">
<td style="padding-left:5px;" ><?php echo $i++;?></td>

<td >
	<?php 
	$sitesql="select locationname from locations where loccode='".$row['sitecode']."'";
	$siteres=DB_query($sitesql,$db);
	$siterow=DB_fetch_array($siteres);
 echo $siterow['locationname']; ?>
 </td>
<td><?php  echo ConvertSQLDate($row['prdate']);?></td>
<td><?php  echo $row['Reqno'];?></td>

<td><?php  echo $s->GetFieldValue('item_master',"id='".$row['mst_itemid']."'" ,'StockID'); ?></td>

  <td><?php  echo $s->GetFieldValue('item_master',"id='".$row['mst_itemid']."'" ,'item_name'); ?></td>

 <td><?php  echo $row['REQ'];?></td>
  <td><?php  echo $row['Bstatus'];?></td>

  </tr>
  <?php  }?>
</table>
