<?php
ob_start();
session_name('CAKEPHP'); session_start();
$PageSecurity = 1;
include('config.php');
include('includes/ConnectDB.inc');
include('includes/function_lib.php');
include('includes/LanguageSetup.php');
include('includes/DateFunctions.inc');
include('includes/SQL_CommonFunctions.inc');
function convertDate($Dt)
{
	$dateBRK=explode('-',$Dt);
	$newFormat=$dateBRK[2]."/".$dateBRK[1]."/".$dateBRK[0];
	return $newFormat;
}

$sql="Select * from job_card where id='".$_REQUEST['id']."'";
$result=DB_query($sql,$db);
$myrow=DB_fetch_array($result);
$remarks=$myrow['remarks'];
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Job Card Details</title>
<link href="css/purchses.css" rel="stylesheet" type="text/css" />
</head>

<body>
<?php

$company=DB_query("select * from companies where CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
$company_row=DB_fetch_array($company);

?>
<div id="page">
		
  <div id="form">
	<!-- Start Header --->
  	<div>
	 <h2 align="center" style="margin-bottom:0px;"><font color="#006699">
    <?php echo $company_row['CompanyName']; ?></font></h2>
  	  <h3>Job Card </h3>
	  <br />

      <div class="left_part" style="border:#000000 solid 1px;">

		<table width="100%" border="0" cellspacing="1" cellpadding="2">
  
  
  <tr>
    
    <th width="11%">Branch </th>
	<td width="1%">:</td>
    <td width="19%"><?php echo ucwords($branchname=$s->getField('locations','loccode',$myrow['site'],locationname));?></td>
	<td width="10%">Job Card No </td>
	<td width="1%">&nbsp;</td>
	<td width="21%"><?php echo $myrow['job_card_no']; ?></td>
	<?php
	$citysql="Select * from locations where loccode='".$myrow['site']."'";
		$cityrow=DB_query($citysql,$db);
		$city_res=DB_fetch_array($cityrow);
	?>
	<th width="14%">Job Card Date </th>
	<td width="1%">:</td>
	<td width="22%"><?php echo convertDate($myrow['job_date']); ?></td>
  </tr>
	 <tr>
    
    <th width="11%">W/O No </th>
	<td width="1%">:</td>
    <td width="19%"><?php echo ucwords($branchname=$s->getField('salesorder','id',$myrow['wo_no'],'orderNo'));?></td>
	<td width="10%">W/O Item </td>
	<td width="1%">&nbsp;</td>
	<td width="21%"><?php 	echo $branchname=$s->getField('item_master','id',$myrow['work_itemid'],'item_name');	  ?></td>
	<?php
	$citysql="Select * from locations where loccode='".$myrow['site']."'";
		$cityrow=DB_query($citysql,$db);
		$city_res=DB_fetch_array($cityrow);
	?>
	<th width="14%">W/O Date </th>
	<td width="1%">:</td>
	<td width="22%"><?php echo convertDate($branchname=$s->getField('salesorder','id',$myrow['wo_no'],'orderDate')) ;?></td>
  </tr>
 <tr>
    
    <th width="11%">Order Date </th>
	<td width="1%">:</td>
    <td width="19%"><?php echo convertDate($branchname=$s->getField('salesorder','id',$myrow['wo_no'],orderDate));?></td>
	<td width="10%">Priority</td>
	<td width="1%">&nbsp;</td>
	<td width="21%"><?php echo $myrow['priority']; ?></td>
	<th colspan="3"></th>
	</tr>
</table>
	<div style="clear:both;"></div>
	</div>
<div class="bordertop" style="border-collapse:collapse;"><!-- Table 1 close -->
	<!-- Table 2 close -->
    <!-- Table 3 close -->
<div class="cl"></div>
	  </div>

<div>
	<p align="left"><strong> Job Card Item Details</strong></p>
	
	<table  width="100%" border="1" cellspacing="0" cellpadding="0" class="tbale1" >
  <tr style="text-align:center; font-weight:bold;">
  <br />
<td width="5%" style="padding-top:5px; padding-bottom:5px; padding-left:5px;" align="left" class="row2">S.No</td>
    <td width="19%" style="padding-top:5px; padding-bottom:5px; padding-left:5px;" align="left" class="row2">Item Code</td>
    <td width="22%" align="left" style="padding-left:5px;" class="row2">Item Name </td>
    <td width="30%" align="left" style="padding-left:5px;" class="row2">Description</td>
   
	
    <td width="6%" align="left" style="padding-left:5px;" class="row2">UOM</td>
    <td width="8%" align="left" style="padding-left:5px;" class="row2">Qty.</td>
   <td width="15%" align="left" style="padding-left:5px;" class="row2"> EXP COM DATE</td>
  </tr>
   <?php 
 
		
        $sql="Select * from job_card_item_details where jobid='".$_REQUEST['id']."'";
		$result=DB_query($sql,$db);
        $i=1;
        while($myrow1=DB_fetch_array($result))
        {       
		$itemname=$s->GetFieldValue('item_master',"id='".$myrow1['mst_itemid']."'" ,'item_name');
		$itemcode=$s->GetFieldValue('item_master',"id='".$myrow1['mst_itemid']."'" ,'StockID');
		$itemdesc=$s->GetFieldValue('item_master',"id='".$myrow1['mst_itemid']."'" ,'item_desc');
		$unitname=$s->GetFieldValue('item_master',"id='".$myrow1['mst_itemid']."'" ,'mst_unitid');
		$unit=$s->GetFieldValue('unitsofmeasure',"unitid='".$unitname."'" ,'unitname');
		?>
    <tr>
	<td style="padding-top:5px; padding-bottom:5px; padding-left:5px;" class="row3"><?php echo $i;?>    </td>
    <td style="padding-top:5px; padding-bottom:5px; padding-left:5px;" class="row3"><?php echo $itemcode;?>    </td>
    <td style=" padding-left:5px;" class="row3"><?php echo $itemname;?>    </td>
    <td style=" padding-left:5px;" class="row3"><?php echo $itemdesc;?></td>
	<td style=" padding-left:5px;" class="row3"><?php echo $unit; ?></td>
	<td style=" padding-right:5px; text-align: right;" class="row3"><?php echo $myrow1['item_qty'];?></td>
	<td style=" padding-right:5px; text-align: right;" class="row3"><?php echo convertDate($myrow1['expected_date']);?></td>
	 </tr>
  <?php $i++;} ?>	
  
</table>

	<p align="left"><strong>Job Card Process Detail</strong> </p>
	
	<table  width="100%" border="1" cellspacing="0" cellpadding="0" class="tbale1" >
  <tr style="text-align:center; font-weight:bold;">
   <td width="6%" style="padding-top:5px; padding-bottom:5px; padding-left:5px;" align="left" class="row2">S.No</td>
    <td width="17%" style="padding-top:5px; padding-bottom:5px; padding-left:5px;" align="left" class="row2">Process</td>
    <td width="18%" align="left" style="padding-left:5px;" class="row2">Machine </td>
    <td width="19%" align="left" style="padding-left:5px;" class="row2">OPERATOR</td>
   
	
    <td width="14%" align="left" style="padding-left:5px;" class="row2">EXP COM DATE</td>
    <td width="26%" align="left" style="padding-left:5px;" class="row2"><p>CURRENT STATUS</p>
      <p>(To Be Filled By Production Dept.)</p></td>
       
  </tr>
   <?php 
		
        $sql="Select * from job_process_details where jobid='".$_REQUEST['id']."'";
		$result=DB_query($sql,$db);
        $j=1;
        while($myrow1=DB_fetch_array($result))
        {       
		$process=$s->GetFieldValue('production_process_master',"id='".$myrow1['process']."'" ,'manuf_process_name');
		$machine=$s->GetFieldValue('machine_center',"id='".$myrow1['machine']."'" ,'name');
		$operator=$s->GetFieldValue('production_operator_master',"id='".$myrow1['operator']."'" ,'operator_name');
		
		?>
    <tr>
	 <td style="padding-top:5px; padding-bottom:5px; padding-left:5px;" class="row3"><?php echo $j;?>    </td>
    <td style="padding-top:5px; padding-bottom:5px; padding-left:5px;" class="row3"><?php echo $process;?>    </td>
    <td style=" padding-left:5px;" class="row3"><?php echo $machine;?>    </td>
    <td style=" padding-left:5px;" class="row3"><?php echo $operator;?></td>
	<td style=" padding-left:5px;" class="row3"><?php echo convertDate($myrow1['exp_date']); ?></td>
	<td style=" padding-right:5px; text-align: right;" class="row3"></td>
	
	 </tr>
  <?php $j++;} ?>
	</table>
	</div>
	<div></div>
<br /><br />
<?php if($remarks!=''){ ?>
<table width="100%" border="0" cellspacing="2" cellpadding="2" align="right" class="label">
                <tr>
                  <td style="padding-top:3px; padding-bottom:0px;"><h2 style="margin:0px; padding-bottom:0px; font-size:18px; text-decoration:underline;">Remarks</h2> </td>
          </tr>
                 <tr>
                  <td ><textarea  name="remarks" id="remarks"  style="width:100%;  padding-top:0px; text-align:justify; padding-left:10px; padding-right:10px; border-width:0 0 0 0;" ><?php echo $remarks; ?></textarea></td>
                </tr>	</table> <?php } ?>

    </div><!-- end Header -->
	<div style="clear:both;"></div>	  
	
	
	
	  
	  <div style="clear:both;"></div>
	
	<div class="authorize1" style=" position:absolute; top:1000px;">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>(Prepared By) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		(Checked By.)  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		(Approved By) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	 (Accepted By) </td>
  </tr>
  <tr>
    <td><div align="center" style="width:130px; margin-left:auto; margin-right:auto;">
<div align="center" style="width:130px; margin-left:auto; margin-right:auto;">
	<div style="background-image:url(images/print_icon.png); background-repeat:no-repeat; width:50px; height:100px; padding:5px;" onclick="toggle_visibility()" id="print">&nbsp;</div>	
	
	</div>
		</div></td>
  </tr>
</table>

		
			</div>
	
	<!-- Start T & C -->
	<div>	
	
	<br/>
	
	

	      

    <div class="authorize">
			</div>


      
    </div>	
  </div>
	<div align="center" style="width:130px; margin-left:auto; margin-right:auto;">
<div align="center" style="width:130px; margin-left:auto; margin-right:auto;">
	<div style="background-image:url(images/print_icon.png); background-repeat:no-repeat; width:50px; height:100; float:left; padding:5px;" onclick="toggle_visibility()" id="print">&nbsp;</div>	
	
	</div>
		</div> <!-- end of  T & C -->
</div>

</body>
</html>


<script type="text/javascript" language="javascript">
  function toggle_visibility(id) {
	
       var e = document.getElementById("print");
      
     	       e.style.display = 'none';
		       //alert(e.style.display);
			   window.print();
    }
</script>

