<!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=utf-8" />
<title>Pre-Dispatch Inspection</title>
<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></head>
<body>
<table width="990" border="0" align="center" cellpadding="0" cellspacing="0"> 
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td align="left" valign="top">
    <fieldset>
    <legend class="search-haiding">Pre-Dispatch Inspection</legend>
    <table width="990" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td>&nbsp;</td>
      </tr> 
      <tr>
        <td align="left" valign="top"> <form action=""  method="post">	
        	<table width="990" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="81" align="left" valign="top" class="text">From Date :</td>
            <td width="113" align="left" valign="top">
              <input type="text" name="from_date"  id="from_date" class="datepicker" value="<?php echo $_REQUEST['from_date']; ?>"/></td>
            <td width="64" align="left" valign="top" class="text">To Date :</td>
            <td width="124" align="left" valign="top"><input type="text" name="to_date"  id="to_date" class="datepicker" value="<?php echo $_REQUEST['to_date']; ?>"/></td>
            <td width="60" align="left" valign="top" class="text">Branch :</td>
            <td width="331" align="left" valign="top"><select name="site" id="site" >
            <option value="000">Select Branch</option>
          <?php  $site_sql = "SELECT prefix,loccode, locationname from locations";$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> 
            <td  width="250"  align="left" valign="top"><input type="submit" name="Search" value="Search" /></td>
          </tr>
        </table></form></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><div class="scroll">
        	
        	<table width="988" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td><table width="2400" border="0" cellpadding="0" cellspacing="0">
              <tr class="text-table">
                <td class="text-table" width="109" height="40" align="left" bgcolor="#999999">Dispatch No.</td>
                <td class="text-table" width="116" align="left" bgcolor="#999999">Dispatch Date</td>
                <td class="text-table" width="105" align="left" bgcolor="#999999">SOP Number</td>
                <td class="text-table" width="109" align="left" bgcolor="#999999">SOP Date</td>
                <td class="text-table" width="133" align="left" bgcolor="#999999">Party Ord. No.</td>
                <td class="text-table" width="116" align="left" bgcolor="#999999">Party Ord. Date</td>
                <td class="text-table" width="213" align="left" bgcolor="#999999">Party Name</td>
                <td class="text-table" width="103" align="left" bgcolor="#999999">Delivery Date</td>
                <td class="text-table" width="109" align="left" bgcolor="#999999">Batch Number</td>
                <td class="text-table" width="100" align="left" bgcolor="#999999">Part Code</td>
                <td class="text-table" width="360" align="left" bgcolor="#999999">Material Name</td>
                <td class="text-table" width="51" align="left" bgcolor="#999999">UOM</td>
                <td class="text-table" width="112" align="left" bgcolor="#999999">Quantity</td>
                <td class="text-table" width="100" align="left" bgcolor="#999999">Rejection Qty</td>
                <td class="text-table" width="100" align="left" bgcolor="#999999">Rejection Reason </td>
                  <td class="text-table" width="100" align="left" bgcolor="#999999">Others</td>
                <td class="text-table" width="129" align="left" bgcolor="#999999">Unit/Name</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></td>
          </tr>
                 
        </table></div>
        </td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table>    
    </fieldset>
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>
