<?php
$date=date('d/m/Y');
 $time=date('h:i', time());
 $period=date(A);
 $timestamp = date("H:i", time());
 $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['date']=='')
  {
  	  $msgErr[]="Please Select  Date";
      $fstatus=false;
  }
    if($_REQUEST['item']=='')
  {
  	  $msgErr[]="Please Select Item  Name"	;
      $fstatus=false;
  }
  if($_REQUEST['customer_name']=='')
  {
  	  $msgErr[]="Please Enter Customer Name"	;
      $fstatus=false;
  }
   if($_REQUEST['hot_foil_slip']=='')
  {
  	  $msgErr[]="Must Enter Entry Slip"	;
      $fstatus=false;
  }
  if($_REQUEST['operator']=='')
  {
  	  $msgErr[]="Must Enter Machine Operator"	;
      $fstatus=false;
  }
	 if($_REQUEST['shift']=='')
  {
  	  $msgErr[]="Must Enter Shift name"	;
      $fstatus=false;
  }
	 if($_REQUEST['machine']=='')
  {
  	  $msgErr[]="Must Enter Machine Center"	;
      $fstatus=false;
  }
 
  if($_REQUEST['approved']=='0')
  {
  	  $msgErr[]="Please Select Approved By"	;
      $fstatus=false;
  } 
	
}
if($_REQUEST['Save']!='' and $fstatus)
{

		 $data['branch_id'] =$_REQUEST['site'];
		 $data['job_card_id']=$_REQUEST['job_ticket'];	
		 $data['hotfoil_slip']=$_REQUEST['hot_foil_slip'];
		 $data['date']=FormatDateForSQL($_REQUEST['date']);
		 $data['item_name']=$_REQUEST['item'];
		 $data['customer_name']=$_REQUEST['customer_name'];
		 $data['shift']=$_REQUEST['shift'];
		 $data['machine']=$_REQUEST['machine'];
		 $data['operator']=$_REQUEST['operator'];
		 $data['foil_used']=$_REQUEST['foil'];
		 $data['dia_checking']=$_REQUEST['possition'];
		 $data['foil_quality']=$_REQUEST['foil_quality'];
		 $data['checked_matter']=$_REQUEST['matter_design'];
		 $data['remarks']=$_REQUEST['remarks1'];
		 $data['created_by']=$_REQUEST['created'];
		 $data['approved_qa']=$_REQUEST['approved'];
 $inprocess_printing=$s->insertRecord('tbl_inprocess_audit_hotfoil', $data);
 $insertResult = DB_query($inprocess_printing,$db,$ErrMsg); 
		if(!$insertResult)
			{
			  die("Not Inserted".DB_error_msg($db));
			}
			$Lastreq_id=DB_Last_Insert_ID($db,'tbl_inprocess_audit_hotfoil',$ErrMsg);
			if($Lastreq_id!='')
			{
			$data1['parent_id']=$Lastreq_id;	
			$data1['matter_cut_date']=FormatDateForSQL($_REQUEST['matter_cut_date']);
			$data1['matter_cut_time']=$_REQUEST['matter_cut_time'];	
			$data1['matter_cut_period']=$_REQUEST['start_AMPM_matter'];	
			$data1['matter_cut_remarks']=$_REQUEST['matter_remarks'];	
			$data1['bubble_date']=FormatDateForSQL($_REQUEST['bubble_date']);	
			$data1['bubble_time']=$_REQUEST['bubble_time'];	
			$data1['bubble_period']=$_REQUEST['start_AMPM_bubble'];	
			$data1['bubble_remarks']=$_REQUEST['bubble_remarks'];	
			$data1['wrinkless_date']=FormatDateForSQL($_REQUEST['wrinkless_date']);	
			$data1['wrinkless_time']=$_REQUEST['wrinkless_time'];	
			$data1['wrinkless_period']=$_REQUEST['start_AMPM_wrinkless'];
			$data1['wrinkless_remarks']=$_REQUEST['wrinkless_remarks'];
			$data1['cross_foil_date']=FormatDateForSQL($_REQUEST['cross_foiling_date']);
			$data1['cross_foil_time']=$_REQUEST['cross_foiling_time'];
			$data1['cross_foil_period']=$_REQUEST['start_AMPM_cross'];	
			$data1['cross_foil_remarks']=$_REQUEST['cross_foiling_remarks'];
			$data1['short_foil_date']=FormatDateForSQL($_REQUEST['short_foiling_date']);
			$data1['short_foil_time']=$_REQUEST['short_foiling_time'];
			$data1['short_foil_period']=$_REQUEST['start_AMPM_short'];
			$data1['short_foil_remarks']=$_REQUEST['short_foiling_remarks'];	
			$insert_data=$s->insertRecord('tbl_inprocess_audit_checkpoint_details', $data1);
			$insertResult = DB_query($insert_data,$db,$ErrMsg);
			}
$s->pageLocation('index.php?route=view_process_audit&modid='.$_REQUEST['modid'].'&frmid='.$_REQUEST['frmid'].$rurl);
 }
 
 
?>

<form action="" method="post" >
<p align="center"><strong><h2 align="center">INProcess Audit Report For Hot Foil Stamping</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>
   
<p align="left"><strong>General Details</strong></p>
<table width="100%" 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="24%"><strong>Hot Foil Slip.</strong></th>
                    <td width="27%" id="hotfoil"><input type="text"  name="hot_foil_slip" id="hot_foil_slip" style="width:100%"  >                    	
                    	</td>
                    	<th align="left" width="20%"><strong>Date</strong></th>
                     <td><input type="text" id="date" name="date" style="width:100%;" class="datepicker"/>
                     </td>
      </tr>
            	<tr>
                 <th align="left" width="24%"><strong>Job Card  No.</strong></th>
                    <td width="27%" id="vouchar"><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>
                    	<th align="left" width="20%"><strong>Item Name..</strong></th>
                     <td><input type="text" id="item" name="item" style="width:100%;"/>
                     </td>
      </tr>
            	<tr>
                 <th align="left" width="24%"><strong>Customer</strong></th>
                    <td width="27%" id="vouchar"><input type="text" name="customer_name" style="width:100%;" id="customer_name"/></td>
                    	<th align="left" width="20%"><strong>Shift</strong></th>
                     <td><input type="text" name="shift" style="width:100%" id="shift">            	                 	
                       	
                     </td>
       </tr>
      </table></div></td>
      </tr> 
   
    <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="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>Operator</strong></th>
        <td  id="vouchar"><input type="text" name="operator" style="width:100%" id="operator" >
                     	
        	
        	
        	</td>
      </tr>
      
      </table></div></td>
      </tr> 
      <tr><td>&nbsp;</td></tr>
   
   <tr><td><p align="left"><strong> INITIAL CHECK POINT </strong></p>
                    <table width="100%" cellpadding="2" cellspacing="1" border="0">
                 <tr>
        <th align="left" width="40%" ><strong>Foil used as per job card</strong></th>
        <td><table width="100%" border="0">
        	
                    <tr><td width="65%">&nbsp;</td><th width="5%">Yes</th><td width="15%"><input type="radio" name="foil" value="Yes" /></td><th width="10%">No</th><td width="15%"><input type="radio" name="foil" value="No" /></td></tr>	
                               	
                    </table></td>
     </tr>
     <tr>
        <th align="left" width="40%"><strong>Possition of foiling checked as per die tracking on it observed as</strong></th>
        <td><table width="100%" border="0">
                    <tr><td width="65%">&nbsp;</td><th width="5%">Ok</th><td width="15%"><input type="radio" name="possition" value="ok" /></td><th width="10%">Not Ok</th><td width="15%"><input type="radio" name="possition" value="notok" /></td></tr>	
                               	
                    </table></td>
      </tr>
      
                    
                 </table></td></tr>
                 <tr><td><table width="100%" cellpadding="2" cellspacing="1" border="0">
                 	<tr>
        <th align="left" width="40%"><strong>Foil Quality Used</strong></th>
        <td><table width="100%" border="0">
                    <tr><td width="35%">&nbsp;</td>
                    	<th>Silver</th><td><input type="radio" name="foil_quality" value="silver" /></td>
                    	<th>Gold</th><td><input type="radio" name="foil_quality" value="gold" /></td>
                    	<th>Both</th><td ><input type="radio" name="foil_quality" value="silver/gold" /></td>
                    	<th>Other</th><td><input type="radio" name="foil_quality" value="other" /></td></tr>	
                               	
                    </table></td>
      </tr>
                 	
                 	
                </table> </td></tr>
                <tr><td><table width="100%" cellpadding="2" cellspacing="1" border="0">
                 	<tr>
        <th align="left" width="40%"><strong>Checked Matter/Design and found as per customer approved sample:</strong></th>
        <td><table width="100%" border="0">
                    <tr><td width="65%">&nbsp;</td>
                    	<th>Ok</th><td><input type="radio" name="matter_design" value="notok" /></td>
                    	<th>Not Ok</th><td><input type="radio" name="matter_design" value="ok" /></td>
                    	
                               	
                    </table></td>
      </tr>
                 	
                 	
                </table> </td></tr>
                <tr><td>&nbsp;</td></tr>
                <tr><td> <p align="center"><strong>Check Point Details</strong></p>
                 
            <table width="100%" cellpadding="2" cellspacing="1" border="1" align="center" >
            <tr>
          <th width="24%" align="left" class="text">Check Point</th>
          <th width="27%" align="left" valign="top">Observations</th>          
          <th  align="left" width="65%">Remarks</th>
          <td align="left" valign="top"></td>
          </tr>  
           <tr>
          	<td><strong>Matter Cut/Missing</stong></td><td>
          	<table border="0">
          	<tr><td><input type="text" class="datepicker" name="matter_cut_date" /></td>
          	<td><input type="text"  name="matter_cut_time" value="<?php echo $timestamp; ?>" /></td>
          	<td><select name="start_AMPM_matter" id="start_AMPM_matter" style="width:40px">
	 <option value="AM"<?php echo ($_REQUEST['start_AMPM_matter']=='AM'?'selected':'')?>>AM</option>
	 <option value="PM"<?php echo ($_REQUEST['start_AMPM_matter']=='PM'?'selected':'')?>>PM</option>
	 </select></td>
          	</tr>	
          	</table>	
          	</td><td width="65%"><textarea style="width:100%" name="matter_remarks"></textarea></td>
          </tr>     
          <tr>
          	<td><strong> Bubble</strong></td><td>
          	<table border="0">
          	<tr><td><input type="text" class="datepicker" name="bubble_date" /></td>
          		<td><input type="text"  name="bubble_time" value="<?php echo $timestamp; ?>" /></td>
          	<td><select name="start_AMPM_bubble" id="start_AMPM_bubble" style="width:40px">
	 <option value="AM"<?php echo ($_REQUEST['start_AMPM_bubble']=='AM'?'selected':'')?>>AM</option>
	 <option value="PM"<?php echo ($_REQUEST['start_AMPM_bubble']=='PM'?'selected':'')?>>PM</option>
	 </select></td>	
          		
          	</tr>	
          	</table>	
          	</td><td width="65%"><textarea style="width:100%" name="bubble_remarks"></textarea></td>
          </tr>     
          <tr>
          	<td><strong>Wrinkless</strong></td><td>
          	<table border="0">
          		
          	<tr><td><input type="text" class="datepicker" name="wrinkless_date" /></td>
          		<td><input type="text" name="wrinkless_time" value="<?php echo $timestamp; ?>"  /></td>
          		<td><select name="start_AMPM" id="start_AMPM_wrinkless" style="width:40px">
	 <option value="AM"<?php echo ($_REQUEST['start_AMPM_wrinkless']=='AM'?'selected':'')?>>AM</option>
	 <option value="PM"<?php echo ($_REQUEST['start_AMPM_wrinkless']=='PM'?'selected':'')?>>PM</option>
	 </select></td>
          	</tr>	
          	</table>	
          		
          	</td><td width="65%"><textarea style="width:100%" name="wrinkless_remarks"></textarea></td>
          </tr>     
          <tr>
          	<td><strong>Cross Foiling</strong></td><td>
          	<table border="0">
          	<tr><td><input type="text" class="datepicker"  name="cross_foiling_date"/></td>
          		<td><input type="text"  name="cross_foiling_time" value="<?php echo $timestamp; ?>" /></td>
          		<td><select name="start_AMPM" id="start_AMPM_cross" style="width:40px">
	 <option value="AM"<?php echo ($_REQUEST['start_AMPM_cross']=='AM'?'selected':'')?>>AM</option>
	 <option value="PM"<?php echo ($_REQUEST['start_AMPM_cross']=='PM'?'selected':'')?>>PM</option>
	 </select></td>
          	</tr>	
          	</table>	
          	</td><td width="65%"><textarea style="width:100%" name="cross_foiling_remarks"></textarea></td>
          </tr>     
          <tr>
          	<td><strong>Short Foiling</strong></td><td>
          	<table border="0">
          		
          	<tr><td><input type="text" class="datepicker" name="short_foiling_date" /></td>
          		<td><input type="text"  name="short_foiling_time" value="<?php echo $timestamp; ?>" /></td>
          		<td><select name="start_AMPM" id="start_AMPM_short" style="width:40px">
	 <option value="AM"<?php echo ($_REQUEST['start_AMPM_short']=='AM'?'selected':'')?>>AM</option>
	 <option value="PM"<?php echo ($_REQUEST['start_AMPM_short']=='PM'?'selected':'')?>>PM</option>
	 </select></td>
          	</tr>	
          	</table>
          	</td><td width="65%"><textarea style="width:100%" name="short_foiling_remarks"></textarea></td>
          </tr>     
                </table></td></tr>
                 <tr><td><table width="100%" cellpadding="2" cellspacing="1" border="0">
                <tr>
                 <th align="left" colspan="2" width="25%"><strong>Remarks</strong></th>
                    <td colspan="2" width="75%"><textarea name="remarks1" style="width:100%" ></textarea>
                    	</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 QA 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("customer_name").value=data[1];
	document.getElementById("shift").value=data[4];
	document.getElementById("machine").value=data[2];
	document.getElementById("operator").value=data[3];
	document.getElementById("item").value=data[0];	
    }
  }
  xmlhttp.open("GET","get_inprocess_audit.php?site="+str,true);
xmlhttp.send();
//xmlhttp.open("GET","getSort.php?s="+str+"&cat="+cat,true);
}
function getdata(str8) 
{	 
	
if (str8.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?site8="+str8,true);
xmlhttp.send();
}




</script>
