<?php 
if(isset($_REQUEST['submit']))
{
    if($_REQUEST['site']!="0"){
       $cond.= "and sitecode='".$_REQUEST['site']."' ";
    }
    if($_REQUEST['from_date']=="" && $_REQUEST['to_date']==""){
      $cond.="and qc_date  BETWEEN '".$_SESSION['financialYrStart']."'   AND '".$_SESSION['financialYrEnd']."' ";
    }
    else
    {
     $cond.=" and qc_date  BETWEEN '".ConvertSQLDate($_REQUEST['from_date'])."'   AND '".ConvertSQLDate($_REQUEST['to_date'])."'  "; 
    }

$sql="select * from qc_shop_floor where CompanyId='".$_SESSION['ACGCompanyId']."'".$cond; 
} else{
    $sql="select * from qc_shop_floor where CompanyId='".$_SESSION['ACGCompanyId']."'
and qc_date  BETWEEN '".$_SESSION['financialYrStart']."'   AND '".$_SESSION['financialYrEnd']."'"; 
} ?>


<link rel="stylesheet" href="css/new_mxerp.css">
<div class="tab_div">
<center> <h2>Shop Floor Process Inspection Register</h2></center>
<div id="container">
    
<form action=""  method="post">	
<table  border="0" cellspacing="0" cellpadding="3" width="100%">
          <tr class="row1">
              <td width="13%" align="left" valign="top" class="text"><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 where CompanyId='".$_SESSION['ACGCompanyId']."'";
     $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['loccode']){ ?> selected="selected" <?php }?>><?php echo $site_row['locationname']; ?></option>
            <?php } ?>
   </select></td> 
              
		  <td width="13%" align="left" valign="top" class="text"><strong>From Date :</strong></td>
            <td width="20%" align="left" valign="top">
            <input type="text" name="from_date" style="width:100%;" id="from_date" class="datepicker" value="<?php echo $_REQUEST['from_date']; ?>"/></td>
            <td width="13%" align="left" valign="top" class="text"><strong>To Date :</strong></td>
            <td width="20%" align="left" valign="top"><input type="text" name="to_date"  id="to_date" class="datepicker" value="<?php echo $_REQUEST['to_date']; ?>" style="width:100%;"/></td>
          </tr>
          <tr>
              <td colspan="6" style="text-align: center"><input class="search" type="submit" name="submit" value="Search"/></td>
          </tr>
</table>
</form>
    <table width="100%" border="1" cellspacing="0" cellpadding="3" style="border-collapse:collapse;">
  <tr>
    <th><strong>Sr No</strong></th>
    <th><strong>Branch</strong></th>
	 <th><strong>QC No </strong></th>
        
	<th><strong>QC Date</strong></th>
        <th><strong>Job Card No </strong></th>
	<th><strong>Client</strong></th>
	<th><strong>Item  Details</strong></th>
	<th><strong>Analysed By</strong></th>
   <!-- <th><strong>Remarks</strong></th>-->
  </tr>
  <?php
  $i=1;
  //echo $sql;
  $mrnsql=DB_query($sql,$db);
  while($myrow1=DB_fetch_assoc($mrnsql)){
  	$myrow[]=$myrow1;
	}	
	
	if(!empty($myrow)){
	foreach ($myrow as $val){
  ?>
  <tr bgcolor="#FFFFFF">
  	<td ><?php echo $i;?></td>
	<td><?php  echo  $s->getField('locations','loccode',$val['sitecode'],'locationname'); ?></td>
    <td><?php echo $val['qc_no'];?></td>
	
    <td><?php echo ConvertSQLDate($val['qc_date']);?></td>
    <td><?php $jobdet= DB_fetch_assoc(DB_query("select * from job_card where id='".$val['jobid']."' ",$db)); echo $jobdet['job_card_no'];?></td>
    <td><?php   echo $s->getField('clientmaster','id',$jobdet['client_id'],'c_name');?></td>
	<td><?php echo $s->getField('item_master','id',$val['mst_itemid'],'item_name');?></td>
	 <td><?php echo $val['analysed']?></td>
	  <!--<td><?php echo $val['remarks']?></td>-->
	  
  </tr>
  <?php 
  $i++;}	}	
  else
  {?>
  <tr>
  <td colspan="9"><h3 align="center"><strong>No Record Found</strong></h3></td>
  </tr>
  <?php 	
  }
  ?>
</table>
</div>
</div>
