<?php
 $modid=$_REQUEST['modid'];
$frmid=$_REQUEST['frmid'];
$rurl="&modid=".$modid."&frmid=".$frmid;
 if($_REQUEST['Save'])
{
$fstatus=true;
  if($_REQUEST['site']=='000')
  {
  	  $msgErr[]="Please Select Branch Name"	;
      $fstatus=false;
  }
  if($_REQUEST['job_ticket']=='')
  {
  	  $msgErr[]="Please Enter Job Ticket No"	;
      $fstatus=false;
  }	
	 if($_REQUEST['jobdate']=='')
  {
  	  $msgErr[]="Please Enter  Date";
      $fstatus=false;
  }
   
  if($_REQUEST['operator']=='')
  {
  	  $msgErr[]="Please Enter Operator Name"	;
      $fstatus=false;
  }
   if($_REQUEST['feedback_slip']=='')
  {
  	  $msgErr[]="Must Enter Feedback  Slip"	;
      $fstatus=false;
  }
 	 if($_REQUEST['shift']=='')
  {
  	  $msgErr[]="Must Enter Shift"	;
      $fstatus=false;
  }
  if($_REQUEST['issue_date']=='')
  {
  	  $msgErr[]="Must Enter Issue Date"	;
      $fstatus=false;
  }
  if($_REQUEST['supervisor']=='')
  {
  	  $msgErr[]="Must Enter Supervisor Name"	;
      $fstatus=false;
  }
  if($_REQUEST['process_date']=='')
  {
  	  $msgErr[]="Must Enter Process Date"	;
      $fstatus=false;
  }
	 if($_REQUEST['machine']=='')
  {
  	  $msgErr[]="Must Enter Machine Center"	;
      $fstatus=false;
  }
 
  if($_REQUEST['defective_qty']=='')
  {
  	  $msgErr[]="Must Enter Defective Qty"	;
      $fstatus=false;
  }
  if($_REQUEST['total_qty']=='')
  {
  	  $msgErr[]="Must Enter Total Qty"	;
      $fstatus=false;
  }
  
  if($_REQUEST['approved']=='0')
  {
  	  $msgErr[]="Please Select Approved By"	;
      $fstatus=false;
  } 
	
}
if($_REQUEST['Save']!='' and $fstatus)
{
 $data['branch_id'] = $_REQUEST['site'];
 $data['feedback_slip'] = $_REQUEST['feedback_slip'];
 $data['job_card_no'] = $_REQUEST['job_ticket'];	
 $data['job_card_date'] = $_REQUEST['jobdate'];
 $data['machine']=$_REQUEST['machine'];
 $data['shift']= $_REQUEST['shift'];
 $data['process_date']=FormatDateForSQL($_REQUEST['process_date']);
 $data['operator']=$_REQUEST['operator'];
 $data['defective_qty']=$_REQUEST['defective_qty'];
 $data['total_qty']=$_REQUEST['total_qty'];
 $data['date_issue']=FormatDateForSQL($_REQUEST['issue_date']);
 $data['supervisor']=$_REQUEST['supervisor'];
 $data['feedback_nc_details']=$_REQUEST['feedback_nc_details'];
 $data['qa_sign']=$_REQUEST['qa_sign'];
 $data['reef_cause']=$_REQUEST['reef_cause'];
 $data['corrective_action']=$_REQUEST['corrective_action'];
 $data['production_sign']=$_REQUEST['production_sign'];
 $data['problem_ele']=$_REQUEST['problem_ele'];
 $data['disposal_nc']=$_REQUEST['disposal_nc'];
 $data['final_qty']=$_REQUEST['final_qty'];
 $data['qty_value']=$_REQUEST['qty_value'];
 $data['created']=$_REQUEST['created'];
 $data['approved']=$_REQUEST['approved']; 
 $inprocess_printing=$s->insertRecord('tbl_inprocess_feed_back_fomat', $data);
 $insertResult = DB_query($inprocess_printing,$db,$ErrMsg); 
$s->pageLocation('index.php?route=view_process_feedbackform&modid='.$_REQUEST['modid'].'&frmid='.$_REQUEST['frmid'].$rurl);
 }
 
 
?>

<form action="" method="post" >
<p align="center"><strong><h2 align="center">Process Feed Back Format</h2></strong></p>
<br>
<table width="70%">	
<?php if(count($msgErr)>0){?>
   <tr>
   <td colspan="4"><?php
   for($i=0;$i<count($msgErr);$i++)
   {
     echo "<div class='error'>".$msgErr[$i].'</div>';
   }
    ?></td>
   </tr>
   <?php } ?>	
	</table>
<p align="center"><strong>Branch:</strong>
	 <?php
 		$sql = 'SELECT loccode, locationname FROM locations';
	 	$resultStkLocs = DB_query($sql,$db);
		?>
	<select name="site" style="width:100px" onchange="getdata(this.value);" >
	<option value="000">Select</option>
      <?php    
			while ($myrow=DB_fetch_array($resultStkLocs))
				{
				?>
      <option value="<?php echo $myrow['loccode']; ?>"><?php echo $myrow['locationname'];?></option>
      <?php  }	?> 
    </select></p>


<table cellpadding="0" cellspacing="0" border="0" align="center">
    <tr>
        <td nowrap="nowrap" colspan="2" width="50%" valign="top">
        <div id="enquiryId" style="width:100%; margin:0 auto;">
            <table width="100%" cellpadding="2" cellspacing="1" border="0">
            	<tr>
            		<th align="left" width="20%"><strong>Feedback Slip</strong></th>
                     <td id="feedback"><input type="text" id="feedback_slip" name="feedback_slip" style="width:100%;" />
                     </td>
                 <th align="left" width="24%"><strong>Job Card No</strong></th>
                    <td width="27%" ><select  name="job_ticket" id="job_ticket" style="width:100%" onchange="getdata1(this.value);" >
                    	<option value="0">Select</option> 
                    	<?php
                    	$sql=DB_query("select * from job_route_card",$db);
						while($row=DB_fetch_array($sql))
						{ 
                    	?>
                    	<option value="<?php echo $row['id']; ?>"><?php echo $row['job_card_no']; ?></option>
                    	<?php } ?></select>                    	
                    	</td>
                    	
      </tr>
      <tr>
      	<th align="left" width="20%"><strong>Job Card Date</strong></th>
                     <td><input type="text" id="jobdate" name="jobdate" style="width:100%;" />
                     </td>
            
        <th align="left" width="20%"><strong>Operator</strong></th>
        <td  id="vouchar"><input type="text" name="operator" style="width:100%" id="operator" >        	
        	</td>
      </tr>
            	
            	<tr>
                 <th align="left" width="24%"><strong>Machine</strong></th>
                    <td width="27%" id="vouchar"><input type="text" name="machine" id="machine" style="width:100%" ></td>
                    	<th align="left" width="20%"><strong>Shift</strong></th>
                     <td><input type="text" name="shift" style="width:100%" id="shift">            	                 	
                       	
                     </td>
       </tr>
       
       <tr>
                 <th align="left" width="24%"><strong>Defective Qty</strong></th>
                    <td width="27%" id="vouchar"><input type="text" name="defective_qty" style="width:100%;" id="defective_qty"/></td>
                    	<th align="left" width="20%"><strong>Total Quantity</strong></th>
                     <td><input type="text" name="total_qty" style="width:100%" id="total_qty">            	                 	
                       	
                     </td>
       </tr>
       <tr>
                 <th align="left" width="24%"><strong>Date Of Issue</strong></th>
                    <td width="27%" id="vouchar"><input type="text" name="issue_date" style="width:100%;" id="issue_date" class="datepicker"/></td>
                    	<th align="left" width="20%"><strong>Supervisor</strong></th>
                     <td><input type="text" name="supervisor" style="width:100%" id="supervisor">            	                 	
                     
                     </td>
       </tr>
       <tr>
                 <th align="left" width="24%"><strong>Process/Date</strong></th>
        <td width="27%" id="vouchar"><input type="text" name="process_date" style="width:100%;" id="process_date" class="datepicker"/>
                     	
        	
        	
        	</td>
                    	<td ></td>
                     <td>           	                 	
                     
                     </td>
       </tr>
      </table></div></td>
      </tr>  
   
      <tr><td>&nbsp;</td></tr>
   
   <tr><td><p align="left"><strong> Feedback/NC Details </strong></p>
                  <table width="100%" cellpadding="2" cellspacing="1" border="0">
                 <tr>
       
        <td colspan="2"><textarea style="width:100%" name="feedback_nc_details"></textarea></td>
     </tr> </table></td></tr>
     <tr><td><table >
     	<tr><th>Sign QA</th><td><input type="text" name="qa_sign" id="qa_sign" style="width:100%" /></td>  
     </tr></table></td></tr>
     	
    
                                 
                <tr><td>&nbsp;</td></tr>
                <tr><td><p align="left"><strong>Reef Cause Analysis (By Concerned Section Incharge) </strong></p>
                  <table width="100%" cellpadding="2" cellspacing="1" border="0">
                 <tr>
       
        <td colspan="2"><textarea style="width:100%" name="reef_cause"></textarea></td>
     </tr>  
         </table></td></tr>
         <tr><td>&nbsp;</td></tr>
                <tr><td><p align="left"><strong>Corrective & Preventive Action </strong></p>
                  <table width="100%" cellpadding="2" cellspacing="1" border="0">
                 <tr>
       
        <td colspan="2"><textarea style="width:100%" name="corrective_action"></textarea></td>
     </tr>  
         </table></td></tr>
                        <tr><td>
                  <table width="100%" cellpadding="2" cellspacing="1" border="0">
                 <tr>
       
        <td><strong>Sign.Production</strong></td><td><input type="text" style="width:100%" name="production_sign"></td>
     </tr>  
      <tr>
      <td><strong>Problem Eleminated</strong></td><td>Yes<input  type="radio" name="problem_ele" value="Yes" />No<input type="radio" name="problem_ele" value="No" /></td>	
          </tr>
      <tr>
     <td><strong>Disposal Of NC Material</strong></td><td>Yes<input  type="radio" name="disposal_nc" value="Yes" />No<input type="radio" name="disposal_nc" value="No" /></td>	
     	
     </tr>
     <tr>
    <td><strong>Scrap/Hold for salvage/Kept to send under devuation</strong></td>
     </tr>
      <tr>
    <td><strong>Final quantity rejected</strong></td><td><input type="text" name="final_qty"></td><td>Value</td><td><input type="text" name="qty_value"></td>	
       </tr> 
         </table></td></tr>
                <tr><td> <table width="100%" cellpadding="2" cellspacing="1" border="0">
                <tr>
                 <th align="left"  width="25%"><strong>Created By</strong></th>
                    <td  ><input type="text" name="created" style="width:100%">
                    	</td>
				     <th>Approved By Qc Head</th><td><select name="approved"  style="width:100%">
					<option value="0">Select</option>
					<option value="Yes">Yes</option>
					<option value="No">No</option>
					<option value="Pending">Pending</option>
					</select></td></tr>
										</table></td></tr>
                
             </table>
						<p align="center"><input type="submit" name="Save" value="Save" /></p>				

</form>
<script language="JavaScript"> 
 function getdata1(str)
{

var xmlhttp;
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)
    {
	 var data=xmlhttp.responseText.split("__");	
	
		document.getElementById("shift").value=data[4];
	document.getElementById("machine").value=data[2];
	document.getElementById("operator").value=data[3];
	document.getElementById("jobdate").value=data[5];
	document.getElementById("jobdate").value=data[6];
    document.getElementById("defective_qty").value=data[7];
	document.getElementById("total_qty").value=data[8];
	
    }
  }
  xmlhttp.open("GET","get_inprocess_audit.php?site="+str,true);
xmlhttp.send();

//xmlhttp.open("GET","getSort.php?s="+str+"&cat="+cat,true);

}


function getdata(str11) 
{	 
	
if (str11.length==0)
  {
  document.getElementById("feedback").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("feedback").innerHTML=xmlhttp.responseText;
      }
  }
 
xmlhttp.open("GET","get_entryslip_jobcard.php?site11="+str11,true);
xmlhttp.send();
}




</script>
