<link rel="stylesheet" href="css/new_mxerp.css">
<?php extract($_POST);
$PageSecurity = 1;
$tabindex=0;
include('includes/DefinePaymentClass.php');
$title = _('Job Route Card Report');
include('includes/SQL_CommonFunctions.inc');
?>


<div class="body_contain">
<div class="tab_div">

   <h1><?php echo $title;?></h1>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

   <tr>
		<td><div align="center">
			<form  action="" method="post">
			<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
			  <tr>
				<td class="tabledata">Job Card No</td>
				<td><select name="jobcard"
				id="jobcard" style="width:100%">
				   <option value="0">---Select---</option>
				  <?php 		
		$site_sql=DB_query("Select id,job_card_no from job_route_card where CompanyId='".$_SESSION['ACGCompanyId']."'",$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>
				<td class="tabledata">Order No. Wise</td>
			    <td><select name="orderno" style="width:100%">
	<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="left" style="padding-left:10px;"><input type="Submit" name="Proceed" value="Proceed" /></p>
		  </form>
	  </div></td>
	</tr>    
     <tr>
    	<td>&nbsp;</td>
    </tr>
   
	</table>

	
<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
    	  <tr>
    	    <td class="tabledata">S.No.</td>
    	    <td class="tabledata">Branch</td>
    	    <td class="tabledata">job card no.</td>
    	    <td class="tabledata">Date</td>
    	     <td class="tabledata">Batch no.</td>
    	    <td class="tabledata">W.O. No.</td>
    	    <td class="tabledata">W.O.date</td>
    	    <td class="tabledata" width="20%">Item Desc.</td>
    	    <td class="tabledata">Order qty</td>
    	    <td class="tabledata">Excess %</td>
    	    <td class="tabledata">Total prod qty</td>
    	    <td class="tabledata" width="10%">Process</td>
    	     	      </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="#c1c1c1">
    	    <td><?php echo $i;?></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 bgcolor="#c1c1c1">
		   <td colspan="12"><font color="#FF0000">No Record Found</font></td></tr>
		<?php 	
		}
		}
	?></table>

</div></div>

     
<?php
//include('includes/footer.inc');
?>