<style type="text/css">
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.mrp-haiding{
		font:16px Georgia, "Times New Roman", Times, serif;
		color:#000;
		font-weight:bold;
}
.search-haiding{
		font:14px Georgia, "Times New Roman", Times, serif;
		color:#000;
		font-weight:bold;
}
.text{
		font:12px Georgia, "Times New Roman", Times, serif;
		color:#000;
}
.text-table{
		font:12px Georgia, "Times New Roman", Times, serif;
		color:#fff;
		padding-left:12px;
}
.border-table{
		border:1px solid #dedede;
}
.scroll{margin:0px;
		padding:0px;
		overflow:scroll;
		width:988px;
		height: 300px;}
	
</style>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="tab_div">
<center> <h2>Goods Incoming Inspection Reports</h2></center>
<div id="container">
<form action=""  method="post">	
<table width="100%" border="0" cellspacing="0" cellpadding="3">
          <tr class="row1">
            <td width="13%" align="left" valign="top"><strong>From Date :</strong> </td>
            <td width="20%" align="left" valign="top">
            <input type="text" style="width:100%;" name="from_date"  id="from_date" class="datepicker" value="<?php echo $_REQUEST['from_date']; ?>"/></td>
            <td width="13%" align="left" valign="top"><strong>To Date :</strong></td>
            <td width="20%" align="left" valign="top"><input type="text" name="to_date" style="width:100%;"  id="to_date" class="datepicker" value="<?php echo $_REQUEST['to_date']; ?>"/></td>
            <td width="13%" align="left" valign="top"><strong>Branch :</strong></td>
            <td align="left" valign="top"><select name="site" id="site" style="width:100%;" >
            <option value="000">Select Branch</option>
          <?php  $site_sql = "SELECT prefix,loccode, locationname from locations where CompanyId='".$_SESSION['ACGCompanyId']."'";
          $site_result=DB_query($site_sql,$db);
		while($site_row = DB_fetch_array($site_result))	{	?>
         <option value="<?php echo $site_row['loccode']; ?>" <?php if($_REQUEST['site']==$site_row['locationname']){ ?> selected="selected" <?php }?>><?php echo $site_row['locationname']; ?></option>
            <?php } ?>
   </select></td> 
            
          </tr>
		  <tr class="row1"><td colspan="6" style="text-align:center;"><input type="submit" name="Search" value="Search" class="search" /></td></tr>
		  <tr class="row1">
		  <td colspan="6" align="center" valign="top" style="padding:0px;">
		  <div style="width:970px; overflow:auto;">
        	<table width="1600" border="1" cellpadding="3" cellspacing="0">
              <tr bgcolor="#CCCCCC">
                <td width="109" height="40" align="left"><strong>Dispatch No.</strong></td>
                <td width="116" align="left"><strong>Dispatch Date</strong></td>
                <td width="105" align="left"><strong>SOP Number</strong></td>
                <td width="109" align="left"><strong>SOP Date</strong></td>
                <td width="133" align="left"><strong>Party Ord. No.</strong></td>
                <td width="116" align="left"><strong>Party Ord. Date</strong></td>
                <td width="213" align="left"><strong>Party Name</strong></td>
                <td width="103" align="left"><strong>Delivery Date</strong></td>
                <td width="109" align="left"><strong>Batch Number</strong></td>
                <td width="100" align="left"><strong>Part Code</strong></td>
                <td width="360" align="left"><strong>Material Name</strong></td>
                <td width="51" align="left"><strong>UOM</strong></td>
                <td width="112" align="left"><strong>Quantity</strong></td>
                <td width="100" align="left"><strong>Rejection Qty</strong></td>
                <td width="100" align="left"><strong>Rejection Reason</strong></td>
                  <td width="100" align="left"><strong>Others</strong></td>
                <td width="129" align="left"><strong>Unit/Name</strong></td>
              </tr>
              <?php
              if(isset($_POST['Search']))
			   {    	
                    $fordate = $_POST['from_date'];
					$todate = $_POST['to_date'];
					$fromdate = explode("/", $fordate);
					$daydate = $fromdate['0'];
					$Monthdate = $fromdate['1'];
					$yeardate = $fromdate['2'];
					$fdate = $yeardate."-".$Monthdate."-".$daydate;					   
					$tredate   = explode("/", $todate);
					$dayda     = $tredate['0'];
					$Monthda   = $tredate['1'];
					$yearda    = $tredate['2'];
					$toyrdate  = $yearda."-".$Monthda."-".$dayda;
					$filter = array();	
					if($_REQUEST['from_date'] != '' && $_REQUEST['to_date'] != '')
 	                $filter[]="dispatch_Date between '".$fdate."' and '".$toyrdate."'";
 	                if($_REQUEST['site']!='000')
	                $filter[]="branch_id='".$_REQUEST['site']."' ";  
				   if($filter != '')	{
		          $filter1 = implode(" and ",$filter);
				if($_REQUEST['site']!='000' || $_REQUEST['from_date']!='' || $_REQUEST['to_date']!='')
				{
				$sql = "select * from pre_dispatch_inspection where  $filter1 group by id";
				}
				else
				{
				$sql = "select * from pre_dispatch_inspection "; 
				}
				}
			    else
			  	{  
	  		   $sql="select * from pre_dispatch_inspection";
		        } 
				$i=0;    
               $sql1=DB_query($sql,$db);
               $num=DB_num_rows($sql1);
			   if($num>0)
			   {
               while($data=DB_fetch_array($sql1))
			   {
			   ?>
              <tr height="25px;">
                <td align="left" valign="top"><?php echo $data['dispatch_no']; ?></td>
                <td align="left" valign="top"><?php echo $data['dispatch_date']; ?></td>
                <td align="left" valign="top"><?php echo  $storeid=$s->getField('salesorder','id',$data['Sop_no'],'orderNo'); ?></td>
                <td align="left" valign="top"><?php echo  $data['sop_date']; ?></td>	
                <td align="left" valign="top"><?php echo  $data['party_ord_no']; ?>       
                </td><td align="left" valign="top"> <?php echo  $data['party_ord_date']; ?></td> 
                <td align="left" valign="top"><?php echo  $data['party_name']; ?> </td> 
                <td align="left" valign="top"><?php echo $data['delivery_date']; ?></td>
                <td align="left" valign="top"><?php echo $data['batch_no']; ?></td>
                <td align="left" valign="top"><?php echo $data['part_code']; ?></td>
                <td align="left" valign="top"><?php echo  $data['material_name']; ?></td>   
                <td align="left" valign="top"><?php echo  $data['uom']; ?></td>                
                <td align="left" valign="top"><?php echo $data['quantity']; ?></td>
               <td align="left" valign="top"><?php echo $data['rejection_qty']; ?></td>
               <td align="left" valign="top"><?php echo $data['rejection_reason']; ?></td>
                <td align="left" valign="top"><?php echo $data['others']; ?></td>
                <td align="left" valign="top"><?php echo  $locationname=$s->getField('locations','loccode',$data['branch_id'],'locationname'); ?> </td>
                 </tr><?php $i++; } } else { ?>
              	<tr><td colspan="14"><?php echo "Sorry No Records"; ?></td></tr>
              	<?php } } ?><input type="hidden" name="count" value="<?php echo $i; ?>" />
              
              </table>
        	</div>
		  
		  </td>
		  </tr>
      </table>        	
			
</form>
</div>
</div>