<?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['lamination_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"	;
      $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['die_punching_slip'] = $_REQUEST['lamination_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['punched_sheed'] = $_REQUEST['punched_sheed'];
 $data['finished_size'] = $_REQUEST['finished_size'];
 $data['embossing'] = $_REQUEST['embossing'];
 $data['remarks'] = $_REQUEST['remarks1'];
 $data['created_by'] = $_REQUEST['created'];
 $data['approved_by'] = $_REQUEST['approved'];
 $inprocess_printing=$s->insertRecord('tbl_inprocess_die_punching', $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['punching_date']=FormatDateForSQL($_REQUEST['punching_date']);
			$data1['punching_time']=$_REQUEST['punching_time'];	
			$data1['punching_period']=$_REQUEST['punching_period'];	
			$data1['punching_remarks']=$_REQUEST['punching_remarks'];	
			$data1['halfcut_date']=FormatDateForSQL($_REQUEST['halfcut_date']);	
			$data1['halfcut_time']=$_REQUEST['halfcut_time'];	
			$data1['start_AMPM_period']=$_REQUEST['start_AMPM_period'];	
			$data1['halfcut_remarks']=$_REQUEST['halfcut_remarks'];	
			$data1['embossing']=FormatDateForSQL($_REQUEST['embossing']);	
			$data1['embossing_time']=$_REQUEST['embossing_time'];	
			$data1['start_AMPM_embossing']=$_REQUEST['start_AMPM_embossing'];
			$data1['embossing_remarks']=$_REQUEST['embossing_remarks'];
			$data1['rough_cutting_date']=FormatDateForSQL($_REQUEST['rough_cutting_date']);
			$data1['rough_cutting_time']=$_REQUEST['rough_cutting_time'];
			$data1['start_AMPM_rough_cutting']=$_REQUEST['start_AMPM_rough_cutting'];	
			$data1['rough_cutting_remarks']=$_REQUEST['rough_cutting_remarks'];
			$data1['preforation_date']=FormatDateForSQL($_REQUEST['preforation_date']);
			$data1['preforation_time']=$_REQUEST['preforation_time'];
			$data1['start_AMPM_preforation']=$_REQUEST['start_AMPM_preforation'];
			$data1['perforation_remarks']=$_REQUEST['perforation_remarks'];		
			$data1['deep_date']=FormatDateForSQL($_REQUEST['deep_date']);	
			$data1['deep_time']=$_REQUEST['deep_time'];	
			$data1['start_AMPM_deep']=$_REQUEST['start_AMPM_deep'];	
			$data1['deep_remarks']=$_REQUEST['deep_remarks'];			
			$data1['dia_punching_date']=FormatDateForSQL($_REQUEST['dia_punching_date']);	
			$data1['dia_punching_time']=$_REQUEST['dia_punching_time'];	
			$data1['start_AMPM_dia_punching']=$_REQUEST['start_AMPM_dia_punching'];				
			$data1['dia_punching_remarks']=$_REQUEST['dia_punching_remarks'];
			
			
			
			$insert_data=$s->insertRecord('tbl_inprocess_die_punching_details', $data1);
					$insertResult = DB_query($insert_data,$db,$ErrMsg);
			}
$s->pageLocation('index.php?route=view_process_dieaudit&modid='.$_REQUEST['modid'].'&frmid='.$_REQUEST['frmid'].$rurl);
 }
 
 
?>

<form action="" method="post" >
<p align="center"><strong><h2 align="center">In Process Audit For Die Punching</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 cellpadding="0" cellspacing="0" border="1" 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>Dia Punching Slip. No</strong></th>
                    <td width="27%" id="hotfoil"><input type="text"  name="lamination_slip" id="lamination_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>Positioning Register of the punched sheet is as per the die-tracting</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="punched_sheed" value="Yes" /></td><th width="10%">No</th>
                    	<td width="15%"><input type="radio" name="punched_sheed" value="No" /></td></tr>	
                               	
                    </table></td>
     </tr>
     <tr>
        <th align="left" width="40%"><strong>Finished size of all ups as per party specifications size(4.1mm)</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="finished_size" value="Yes" /></td>
                    	<th width="10%">No</th><td width="15%"><input type="radio" name="finished_size" value="No" /></td></tr>	
                               	
                    </table></td>
      </tr>
       <tr>
        <th align="left" width="40%"><strong>Embossing should be ok as per key time. if embossing  in the job(0.5mm)</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="embossing" value="Ok" /></td>
                    	<th width="10%">No</th><td width="15%"><input type="radio" name="embossing" value="NotOk" /></td></tr>	
                               	
                    </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>Sr. No</th> 	
          <th width="24%" align="left" class="text">Check Point</th>
          <th width="27%" align="center" valign="top"><center>Observations</center></th>          
          <th  align="left" width="65%"><center>Remarks</center></th>
          <td align="left" valign="top"></td>
          </tr>  
           <tr>
           	<td>1</td>
          	<td><strong>Punching Out</stong></td><td>
          	<table border="0">
          	<tr><td><input type="text" class="datepicker" name="punching_date" /></td>
          	<td><input type="text"  name="punching_time" value="<?php echo $timestamp; ?>" /></td>
          	<td><select name="punching_period" id="punching_period" style="width:40px">
	 <option value="AM"<?php echo ($_REQUEST['punching_period']=='AM'?'selected':'')?>>AM</option>
	 <option value="PM"<?php echo ($_REQUEST['punching_period']=='PM'?'selected':'')?>>PM</option>
	 </select></td>
          	</tr>	
          	</table>	
          	</td><td width="65%"><textarea style="width:100%" name="punching_remarks"></textarea></td>
          </tr>     
          <tr>
          	<td>2</td>
          	<td><strong>Half cut & full cut should be proper</strong></td><td>
          	<table border="0">
          	<tr><td><input type="text" class="datepicker" name="halfcut_date" /></td>
          		<td><input type="text"  name="halfcut_time" value="<?php echo $timestamp; ?>" /></td>
          	<td><select name="start_AMPM_period" id="start_AMPM_period" style="width:40px">
	 <option value="AM"<?php echo ($_REQUEST['start_AMPM_period']=='AM'?'selected':'')?>>AM</option>
	 <option value="PM"<?php echo ($_REQUEST['start_AMPM_period']=='PM'?'selected':'')?>>PM</option>
	 </select></td>	
          		
          	</tr>	
          	</table>	
          	</td><td width="65%"><textarea style="width:100%" name="halfcut_remarks"></textarea></td>
          </tr>     
          <tr>
          	<td>3</td>
          	<td><strong>Embossing should be proper (not checking on the edge1)</strong></td><td>
          	<table border="0">
          		
          	<tr><td><input type="text" class="datepicker" name="embossing" /></td>
          		<td><input type="text" name="embossing_time" value="<?php echo $timestamp; ?>"  /></td>
          		<td><select name="start_AMPM_embossing" id="start_AMPM_wrinkless" style="width:40px">
	 <option value="AM"<?php echo ($_REQUEST['start_AMPM_embossing']=='AM'?'selected':'')?>>AM</option>
	 <option value="PM"<?php echo ($_REQUEST['start_AMPM_embossing']=='PM'?'selected':'')?>>PM</option>
	 </select></td>
          	</tr>	
          	</table>	
          		
          	</td><td width="65%"><textarea style="width:100%" name="embossing_remarks"></textarea></td>
          </tr>     
          <tr>
          	<td>4</td>
          	<td><strong>Rough cutting at cutting area</strong></td><td>
          	<table border="0">
          	<tr><td><input type="text" class="datepicker"  name="rough_cutting_date"/></td>
          		<td><input type="text"  name="rough_cutting_time" value="<?php echo $timestamp; ?>" /></td>
          		<td><select name="start_AMPM_rough_cutting" id="start_AMPM_rough_cutting" style="width:40px">
	 <option value="AM"<?php echo ($_REQUEST['start_AMPM_rough_cutting']=='AM'?'selected':'')?>>AM</option>
	 <option value="PM"<?php echo ($_REQUEST['start_AMPM_rough_cutting']=='PM'?'selected':'')?>>PM</option>
	 </select></td>
          	</tr>	
          	</table>	
          	</td><td width="65%"><textarea style="width:100%" name="rough_cutting_remarks"></textarea></td>
          </tr>     
          <tr>
          	<td>5</td>
          	<td><strong>Perforation cut is good not too deep & to shadow</strong></td><td>
          	<table border="0">
          		
          	<tr><td><input type="text" class="datepicker" name="preforation_date" /></td>
          		<td><input type="text"  name="preforation_time" value="<?php echo $timestamp; ?>" /></td>
          		<td><select name="start_AMPM_preforation" id="start_AMPM_preforation" style="width:40px">
	 <option value="AM"<?php echo ($_REQUEST['start_AMPM_preforation']=='AM'?'selected':'')?>>AM</option>
	 <option value="PM"<?php echo ($_REQUEST['start_AMPM_preforation']=='PM'?'selected':'')?>>PM</option>
	 </select></td>
          	</tr>	
          	</table>
          	</td><td width="65%"><textarea style="width:100%" name="perforation_remarks"></textarea></td>
          </tr>     
           <tr>
           	<td>6</td>
          	<td><strong>Deep Punch</strong></td><td>
          	<table border="0">
          		
          	<tr><td><input type="text" class="datepicker" name="deep_date" /></td>
          		<td><input type="text"  name="deep_time" value="<?php echo $timestamp; ?>" /></td>
          		<td><select name="start_AMPM_deep" id="start_AMPM_deep" style="width:40px">
	 <option value="AM"<?php echo ($_REQUEST['start_AMPM_deep']=='AM'?'selected':'')?>>AM</option>
	 <option value="PM"<?php echo ($_REQUEST['start_AMPM_deep']=='PM'?'selected':'')?>>PM</option>
	 </select></td>
          	</tr>	
          	</table>
          	</td><td width="65%"><textarea style="width:100%" name="deep_remarks"></textarea></td>
          </tr>  
           <tr>
           	<td>7</td>
          	<td><strong>Dia Punching Process</strong></td><td>
          	<table border="0">
          		
          	<tr><td><input type="text" class="datepicker" name="dia_punching_date" /></td>
          		<td><input type="text"  name="dia_punching_time" value="<?php echo $timestamp; ?>" /></td>
          		<td><select name="start_AMPM_dia_punching" id="start_AMPM_dia_punching" style="width:40px">
	 <option value="AM"<?php echo ($_REQUEST['start_AMPM_dia_punching']=='AM'?'selected':'')?>>AM</option>
	 <option value="PM"<?php echo ($_REQUEST['start_AMPM_dia_punching']=='PM'?'selected':'')?>>PM</option>
	 </select></td>
          	</tr>	
          	</table>
          	</td><td width="65%"><textarea style="width:100%" name="dia_punching_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(str10) 
{	 
	
if (str10.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?site10="+str10,true);
xmlhttp.send();
}




</script>
