<?php extract($_POST);
$PageSecurity = 1;
$tabindex=0;
include('includes/DefinePaymentClass.php');
$title = _('Material Requirement 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>Order No. Wise</strong></th>
			    <td><select name="orderno" onchange="getdata(this.value)">
	<option value="000">Select</option>
	<?php 
	$name_sql=DB_query("Select  orderNo,id from salesorder",$db);
	while($name_row=DB_fetch_array($name_sql)) {
	?>
	<option value="<?php echo $name_row['id'];?>"><?php echo $name_row['orderNo'];?></option>
	<?php } ?>
    </select>	</td>
    <th  align="left"><strong>Job Card No</strong></th>
				<td id="hotfoil" ><select name="jobcard" id="jobcard" style="width:98%">
				     <option value="0">Select</option>
				</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="2" cellpadding="2" >
              <tr>
               <th align='center'><strong>S.No</strong></th>
               <th align='center' ><strong>Item Code </strong></th>
               <th align='center' width='25%'><strong>Item Name </strong></th>
				<th align='center'><strong>Unit</strong></th>
				<th align='center'><strong> Group </strong></th>
               <th align='center'><strong>Make</strong></th>
                <th align='center'><strong>Grade</strong></th>
               <th align='center'><strong>Gsm</strong></th>
                <th align='center'><strong>Size</strong></th>
               <th align='center'><strong>Total Req Qty</strong></th>
               <th align='center'><strong>Act Consume Qty</strong></th>
               <th align='center'><strong>Diff. Qty</strong></th>                  
              </tr>
    	  <?php 
    	 if(isset($_POST['Proceed']))
		 {		  	
    	$filter=array();		
		if($_REQUEST['jobcard']!='0')
		$filter[]="A.job_card_id='".$_REQUEST['jobcard']."'";
		if($filter!='')
		{
			if($_REQUEST['jobcard']!='0'){$filter2=implode(" and ",$filter)." group by job_card_id";}
			else
			$filter2=implode(" and ",$filter);
		}			
				
		if($_REQUEST['jobcard']!='0')
		{
		 $sql="Select A.*, B.*  from daily_production_process A, daily_raw_material_consu B where B.daily_id=A.daily_id and $filter2 ";	
	 		}
		else{
		  $sql="Select A.*, B.*  from daily_production_process A, daily_raw_material_consu B where B.daily_id=A.daily_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 echo $myrow['item_code']; ?></td>
	 	  <td><?php echo $myrow['item_name'];?></td>
    	    <td><?php echo $myrow['unit'];?></td>
    	     <td><?php echo $myrow['group1'];?></td>
    	       	      <td><?php echo $myrow['make'];?></td>
    	       <td><?php echo $myrow['grade'];?></td>
    	         <td><?php echo $myrow['gsm'];?></td>
    	         <td><?php echo $myrow['size'];?></td>
    	         <td><?php echo $myrow['total_req_qty'];?></td>
    	         <td><?php echo $myrow['act_consu_qty'];?></td>
    	         <td><?php echo $myrow['diff_qty'];?></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');
?>
<script language="JavaScript">
function getdata(data)
{
if (data.length==0)
  {
  document.getElementById("hotfoil").innerHTML="";
 
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("hotfoil").innerHTML=xmlhttp.responseText;
      }
  }
 
xmlhttp.open("GET","get_entryslip_jobcard.php?data="+data,true);
xmlhttp.send();	
	
	
}	
	
	
	
</script>