<?php extract($_POST);
$PageSecurity = 1;
$tabindex=0;
include('includes/DefinePaymentClass.php');
$title = _('Job Route Card Report');
include('includes/SQL_CommonFunctions.inc');
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr>
		  	<td align="center" height="30" colspan="6" style="font-family:Arial, Helvetica, sans-serif; font-size:14px;"><div align="center"><strong><?php echo $title;?></strong></div></td>
    </tr>
	<tr>
		<td><div align="center">
			<form  action="" method="post">
			<table  border="0" cellspacing="1" cellpadding="3" align="center" bgcolor="#FFFFFF" style="border:1px solid #ccc;">
			  <tr>
				<th  align="left"><strong>Job Card No</strong></th>
				<td ><select name="jobcard" id="jobcard" style="width:98%">
				   <option value="0">---Select---</option>
				  <?php 		
		$site_sql=DB_query("Select id,job_card_no from job_route_card",$db);
		while($site_row=DB_fetch_array($site_sql)){
				?>
				  <option value="<?php echo $site_row['id'];?><?php echo ($_REQUEST['jobcard']==$site_row['id']?'selected':'')?>"><?php echo $site_row['job_card_no'];?></option>
				  <?php } ?>
				</select></td>
				<th align="left"><strong>Order No. Wise</strong></th>
			    <td><select name="orderno">
	<option value="000">Select</option>
	<?php 
	$name_sql=DB_query("Select distinct orderNo from salesorder",$db);
	while($name_row=DB_fetch_array($name_sql)) {
	?>
	<option value="<?php echo $name_row['orderNo'];?>"><?php echo $name_row['orderNo'];?></option>
	<?php } ?>
    </select>	</td>
			  </tr>	 
			 
    
  
		  </table>
		  <p align="center"><input type="Submit" name="Proceed" value="Proceed" /></p>
		  </form>
	  </div></td>
	</tr>    
     <tr>
    	<td>&nbsp;</td>
    </tr>
   
	</table>

	
	<table  border="0" cellspacing="1" cellpadding="2" align="center">
    	  <tr>
    	    <th ><strong>S.No.</strong></th>
    	    <th ><strong>Branch</strong></th>
    	    <th ><strong>job card no.</strong></th>
    	    <th ><strong>Date</strong></th>
    	     <th ><strong>Batch no.</strong></th>
    	    <th ><strong>W.O. No.</strong></th>
    	    <th ><strong>W.O.date</strong></th>
    	    <th width="20%"><strong>Item Desc.</strong></th>
    	    <th><strong>Order qty</strong></th>
    	    <th><strong>Excess %</strong></th>
    	    <th ><strong>Total prod qty</strong></th>
    	    <th width="10%" ><strong>Process</strong></th>
    	     	      </tr>
    	  <?php 
    	 if(isset($_POST['Proceed']))
		 {		  	
    	$filter=array();		
		if($_REQUEST['jobcard']!='0')
		$filter[]="A.id='".$_REQUEST['jobcard']."'";
		if($_REQUEST['orderno']!='0')
		$filter[]="A.sop_no='".$_REQUEST['orderno']."'";		
		
		if($filter!='')
		{
			if($_REQUEST['jobcard']!='0'){$filter2=implode(" and ",$filter)." group by B.job_card_id";}
			else
			$filter2=implode(" and ",$filter);
		}			
				
		if($_REQUEST['jobcard']!='0')
		{
	  $sql="Select A.*, B.*  from job_route_card A, material_slip_against_job_card B where B.job_card_id=A.id and $filter2 ";
		}
		else{
		  $sql="Select A.*, B.*  from job_route_card A, material_slip_against_job_card B where B.job_card_id=A.id "; }
		$result=DB_query($sql,$db);
		$i=1;
		 $mmm=DB_num_rows($result);
		if(DB_num_rows($result)>0)
		{			
		while($myrow=DB_fetch_array($result))
			{				
          ?>
    	  <tr bgcolor="#FFFFFF">
    	    <td><strong><?php echo $i;?></strong></td>
    	    <td><?php 
	$sitename=$s->getField('locations','loccode',$myrow['branch_id'],'locationname');
	echo $sitename;?></td>
	 <td><?php echo $myrow['job_card_no'];?></td>
    	    <td><?php echo ConvertSQLDate($myrow['date']);?></td>
    	    <td><?php echo $myrow['batch_no'];?></td>
    	    <td><?php echo $myrow['sop_no'];?></td>
    	    <td><?php echo $myrow['sop_date'];?></td>
    	      <td><?php echo $myrow['item_name'];?></td>
    	       <td><?php echo $myrow['order_qty'];?></td>
    	       <td><?php echo $myrow['tollerence_per'];?></td>
    	       <td><?php echo $myrow['total_prod_qty'];?></td>
    	         <td><?php echo $myrow['process_name'];?></td>
    	    	       </tr>
    	  
  	  <?php $i++; }  }else
		{?>
		<tr><td colspan="12"><font color="#FF0000"><strong>No Record Found</strong></font></td></tr>
		<?php 	
		}
		}
	?></table>
	
<?php
include('includes/footer.inc');
?>