<?php

?>
<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:5px;
}
.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>Shop Floor Production QC Reports</h2></center>
<div id="container">
<form action="" method="post">
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="0">
<tr class="row1">
<td width="13%" align="left" valign="top"><strong>From Date :</strong></td>
<td align="left" valign="top">
<input type="text" name="from_date"  id="from_date" class="datepicker" style="width:100%;" value="<?php echo $_REQUEST['from_date']; ?>"/></td>
<td width="13%" align="left" valign="top"><strong>To Date :</strong></td>
<td align="left" valign="top"><input type="text" name="to_date"  id="to_date" style="width:100%;" 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="0">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> 
</tr>
<tr class="row1">
  <td colspan="6" align="center" valign="top" style="text-align:center;"><input type="submit" name="Search" value="Search" class="search" /></td>
  </tr>
<tr class="row1">
  <td colspan="6" align="left" valign="top" style="padding:0px;">
  <div style="width:970px; overflow:auto;">
  <table width="2800" border="0" cellpadding="0" cellspacing="0">
              <tr bgcolor="#CCCCCC" height="30">
                <td  align="left"><strong>Job No.</strong></td>
                <td  align="left"><strong>Job Date</strong></td>
                <td  align="left"><strong>Party Name</strong></td>
                <td  align="left"><strong>Order Number</strong></td>
                <td  align="left"> <strong>Order Date</strong></td>
                <td  align="left"><strong>Part Code</strong></td>
                <td  align="left"><strong>Material Name</strong></td>
                <td  align="left"><strong>UOM</strong></td>
                <td  align="left"><strong>Production Date</strong></td>
                <td  align="left"><strong>Process Name</strong></td>
                <td  align="left"><strong>Process Parameter</strong></td>
                <td  align="left"><strong>Machine Center</strong></td>
                <td  align="left"><strong>Production Operator</strong></td>
                <td  align="left"><strong>Shift of Production</strong></td>
                <td  align="left"><strong>In Time</strong></td>
                <td  align="left"><strong>Out Time</strong></td>
                <td  align="left"><strong>Last Pending WIP QTY</strong></td>
                <td  align="left"><strong>Production Qty</strong></td>
                <td  align="left"><strong>Rejection Date & Time</strong></td>
                <td  align="left"><strong>Quality Inspec Executive Name</strong></td>
                <td  align="left"><strong>Rejection Qty</strong></td>
                <td  align="left"><strong>QC OK Qty</strong></td>
                <td  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[]="job_route_card.job_card_date between '".$fdate."' and '".$toyrdate."'";
 	                if($_REQUEST['site']!='000')
	                $filter[]="job_route_card.branch_code='".$_REQUEST['site']."' ";  
				   if($filter != '')	{
		          $filter1 = implode(" and ",$filter);
		if($_REQUEST['site']!='000' || $_REQUEST['from_date']!='' || $_REQUEST['to_date']!='')
		{
	    $sql = "select job_route_card.*,shop_floor_production.* from job_route_card inner join  shop_floor_production on(job_route_card.id = shop_floor_production.job_route_card_id) where job_route_card.status='1' and  $filter1 group by shop_floor_production.job_route_card_id";
		}
		else
		{
		$sql = "select job_route_card.*,shop_floor_production.* from job_route_card inner join  shop_floor_production on(job_route_card.id = shop_floor_production.job_route_card_id) where job_route_card.status='1'"; 
		}
		}
	    else
	  	{  
	    $sql="select job_route_card.*,,shop_floor_production.* from job_route_card inner join  shop_floor_production on(job_route_card.id = shop_floor_production.job_route_card_id) where job_route_card.status='1'";
		}
		$i=0;    
        $sql1=DB_query($sql,$db);
        $num=DB_num_rows($sql1);
		if($num>0)
		{
        while($data=DB_fetch_array($sql1))
			   {			   	
			  ?>
              <tr height="20px;">
                <td align="left" valign="top"><?php echo $data['job_card_no']; ?> </td>
                <td align="left" valign="top"><?php echo $data['job_card_date']; ?></td>
                <td align="left" valign="top"><?php echo $data['job_card_no']; ?></td>
                <td align="left" valign="top"><?php echo $data['party_order_no']; ?></td>
                <td align="left" valign="top"><?php echo $data['order_date']; ?></td>
                <td align="left" valign="top"><?php	echo $storeid=$s->getField('item_master','id',$data['part_code'],'StockId'); ?> </td>
                <td align="left" valign="top"><?php echo $data['item_name']; ?></td>
                <td align="left" valign="top"><?php echo $data['unit']; ?></td>
                <td align="left" valign="top"><?php echo $data['job_card_date']; ?></td>
       <td align="left" valign="top"><?php echo $process=$s->getField('production_process_master','id',$data['process_name'],'manuf_process_name'); ?></td>
                <td align="left" valign="top"><?php echo $data['process_para']; ?></td>
            <td align="left" valign="top"><?php echo $machine=$s->getField('machine_center','id',$data['machine_center'],'code'); ?>	</td>
           <td align="left" valign="top"><?php echo $production_op=$s->getField('production_operator_master','id',$data['production_operator'],'operator_name'); ?>	</td>
           <td align="left" valign="top"><?php echo $shift_of_production=$s->getField('production_shift','id',$data['shift_of_production'],'shift_name'); ?></td>
                <td align="left" valign="top"><?php echo $data['in_time']; ?></td>
                <td align="left" valign="top"><?php echo $data['out_time']; ?></td>
                <td align="left" valign="top"><?php echo $data['last_pend_wip_qty']; ?></td>
                <td align="left" valign="top"><?php echo $prod=$s->getField('job_route_process','masterid',$data['job_route_card_id'],'total_prod_qty'); ?> </td>
                <td align="left" valign="top"><?php echo $data['rejection_date']; ?></td>
                <td align="left" valign="top"><?php echo $data['quality_insp_ex_name']; ?></td>
                <td align="left" valign="top"><?php echo $data['rejection_qty']; ?></td>
                <td align="left" valign="top"><?php echo $data['qc_ok_qty']; ?></td>
                <td align="left" valign="top"><?php echo $site=$s->getField('locations','loccode',$data['branch_code'],'locationname'); ?></td>
                </tr><?php $i++; }} else { ?>
                 <tr><td colspan="23" align="center"><?php echo "No Records Found"; ?></td><?php  } } ?><input type="hidden" name="count" value="<?php echo $i; ?>" />
                 </table>
  
  
  </div>
  </td>
</tr>
</table>
</form>
</div>
</div>

<script language="JavaScript">
function calqty(str)
{
var receive=document.getElementById("production_qty_"+str).value;
var	reject=document.getElementById("rejection_qty_"+str).value;
var t=parseFloat(receive)-parseFloat(reject);
document.getElementById("qc_ok_qty_"+str).value=t.toFixed(2);
}
</script>



