 <?php
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');

$sql4 = "SELECT * FROM companies WHERE CompanyId= ".$_SESSION['ACGCompanyId']."";
$result4 = DB_query($sql4,$db);
$row4 = DB_fetch_array($result4);
//print_r($row4);

$sqlq = "select * from tpl_breakdown_mgmt_assig where id='".$_REQUEST['rid']."'";
$sql=DB_query($sqlq,$db);
$row = DB_fetch_array($sql);
extract($row);

/* $sql2 ="SELECT asset_id FROM tpl_breakdown_mgmt_machine where master_id='".$row['MAIN_ID']."'";
$result2 = DB_query($sql2,$db);
$row2 = DB_fetch_array($result2);

$sql3 = "SELECT * FROM machine_center WHERE ID= ".$row2['asset_id']."";
$result3 = DB_query($sql3,$db);
$row3 = DB_fetch_array($result3); */
?>
<style type="text/css"> 
/* CSS Document */
body{ margin:0px; padding:0px; background-color:#CCC; font-size:10px; font-family: Arial, Helvetica, sans-serif; color:#000; font-weight:normal;}
h1,h2,h3,h4,h5,p{ margin:0px; padding:0px;}
p{ text-align:left;}
.wrapper{
  width: 865px;
  /* [disabled]height:1220px; */
  background-color: #FFF;
  border: 1px solid #000;
  margin: auto;
  padding: 15px 90px 15px 70px;
}
.main{
  width: 860px;
  /* [disabled]height:1200px; */
  border: 1px solid #000;
  border-bottom:none;
}
.div_first{
  width: 860px;
  /* [disabled]height:90px; */
  margin: auto;
  border-bottom: #000000 1px solid;
  min-height:80px;
}
h2{
  font-size: 20px;
  font-weight:normal;
  font-family:Arial, Helvetica, sans-serif !important;
  
}
.div_second{ width:850px; border-bottom: #000000 1px solid; padding:5px;}
.div_third{width:860px; margin:auto; border-bottom: #000000 1px solid;}
.div_third .left{width:286px; float:left; border-right:#000 1px solid;}
.div_third .middle{width:286px; float:left; border-right:#000 1px solid;}
.div_third .right{width:286px; float:left;}
.div_forth{
  width: 860px;
  margin: auto;
  
}
.div_forth table tr th { color:#000; font-size:12px; border-right:1px solid #000; border-bottom:1px solid #000;}
.div_forth table tr th:last-child {border-right:none;}
.div_forth table tr td { color: #000;font-size: 12px; border-right: 1px solid #000;}
.div_forth table tr td:last-child{border-right:none;}

.div_fifth {}
.f12{ font-family:Arial, Helvetica, sans-serif; font-weight: bold; color:#000; font-size:12px;}
.f11{ font-family:Arial, Helvetica, sans-serif; color:#000; font-size:11px; line-height:20px;}
.f14{
  font-family: Arial, Helvetica, sans-serif;
  color: #000;
  font-size: 13px;
  font-weight: bold;
}
.fn14{
  font-family: Arial, Helvetica, sans-serif;
  color: #000;
  font-size: 13px;
  line-height:18px;
}
.f16{
  font-family: Arial, Helvetica, sans-serif;
  color: #000;
  font-size: 16px;
  line-height:20px;
}
.f12_normal{ font-family:Arial, Helvetica, sans-serif; color:#000; font-size:12px;}
.border_top{border-top:#000 1px solid;}
.border_bottom{border-bottom:#000 1px solid;}
.border_right{border-right:#000 1px solid;}
.border_inside_right{box-shadow:inset -13px 0px 0px -12px #000000; -moz-box-shadow:inset 0px 0px 0px 1px #000000; -webkit-box-shadow:inset 0px 0px 0px 1px #000000;}
.border_inside_left{box-shadow:inset 1px 0px 0px 0px #000000; -moz-box-shadow:inset 0px 0px 0px 1px #000000; -webkit-box-shadow:inset 0px 0px 0px 1px #000000;}
</style>
<div class="wrapper">
<table width='99%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td align="center"><h2><strong>Asset Job Card Testing</strong></h2></td>
</tr>
<tr>
<td align="right" style="height:14px;">
<div id="foo">
  <p style="text-align:right;"><input type="button" onclick="javascript:toggle_visibility('foo');" value="Print" /></p>
</div>
</td>
</tr>
</table>
<div class="main">
<div class="div_first">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="25%" height="100" align="center" valign="middle" class="border_inside_right"><img src="Setup/CompanyLogo/<?php echo $row4['CompanyLogo'];?>"  /></td>
    <td>
    <div style="text-align:center; margin-top:0px; margin-left:70px; width:500px;">
    <span class='f16'><?php echo $row4['CompanyName'];?></span><br />
  <span class='fn14'><?php echo $row4['Address1']." ".$row4['Address2']." ".$row4['Address3'];?></span><br />
    <span class='fn14'><?php echo $row4['City'];?>, </span><span class='fn14'><?php echo $row4['State'];?>, </span><span class='fn14'><?php echo $row4['Country'];?>, </span><span class='fn14'> Pincode - <?php echo $row4['Zipcode'];?></span><br />
<span class='fn14'>Phone: <?php echo $row4['Phone'];?> |</span><span class='fn14'> Email: <?php echo $row4['email'];?> |</span><span class='fn14'> Website: <?php echo $row4['HomePage'];?></span>
    </div>
    </td>
  </tr>
</table>
</div>

<div class="div_third">
<div class="left">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="27%" class="f12">Branch</td>
    <td width="1%" class="f12">:</td>
    <td class="f11"><?php echo $row['site'];?></td>
    </tr>  
</table>
</div>
<div class="middle">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="22%" class="f12">Slip No.</td>
    <td width="1%" class="f12">:</td>
    <td class="f11"><?php echo $row['slip_no'];?></td>
    </tr>  
</table>

</div>
<div class="right">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="22%" class="f12">Slip Date</td>
    <td width="1%" class="f12">:</td>
    <td class="f11"><?php if($row['assign_date']!='') echo date('d/m/y',strtotime($row['assign_date'])); else echo ""; ?></td>
    </tr>  
</table>
</div>
<div style="clear:both;"></div>
</div>
<div class="div_third">
<div class="left">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="27%" class="f12">Job Card No.</td>
    <td width="1%" class="f12">:</td>
    <td class="f11"><?php echo $s->getField('tpl_breakdown_mgmt','id',$job_id,'tt_no'); ?></td>
    </tr>  
</table>
</div>
<div class="middle">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="22%" class="f12">Job Card Date</td>
    <td width="1%" class="f12">:</td>
    <td class="f11"><?php echo $s->getField('tpl_breakdown_mgmt','id',$job_id,'asset_rec_date_time');?></td>
    </tr>  
</table>

</div>
<div class="right">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="22%" class="f12">Received From</td>
    <td width="1%" class="f12">:</td>
    <td class="f11"><?php echo $s->getField('tpl_breakdown_mgmt','id',$job_id,'rec_from');?></td>
    </tr>  
</table>
</div>
<div style="clear:both;"></div>
</div>

<div class="div_third">
<div class="left">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="27%" class="f12">Received By</td>
    <td width="1%" class="f12">:</td>
    <td class="f11"><?php echo $s->getField('tpl_breakdown_mgmt','id',$job_id,'rec_by');?></td>
    </tr>  
</table>
</div>
<div class="middle">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="22%" class="f12">Maintenance Type</td>
    <td width="1%" class="f12">:</td>
    <td class="f11"><?php echo $s->getField('tpl_breakdown_mgmt','id',$job_id,'maintenance_type');?></td>
    </tr>  
</table>

</div>
<div class="right">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="22%" class="f12"></td>
    <td width="1%" class="f12"></td>
    <td class="f11"></td>
    </tr>  
</table>
</div>
<div style="clear:both;"></div>
</div>

<div class="div_third">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="9%" class="f12">Break Down Description</td>
    <td width="1%" class="f12">:</td>
    <td class="f11"><?php echo $s->getField('tpl_breakdown_mgmt','id',$job_id,'remarks');?></td>
  </tr>
</table>

</div>
<div class="div_forth">
<table width="100%" border="0" cellspacing="0" cellpadding="3" style="border-collapse:collapse;" align="left">
  <tbody>
  <tr>
    <th>S.No.</th>
    <th>Asset Code</th>
    <th>Asset Name</th>
    <th>Asset Unit</th>
    <th>Asset Group</th>
  <!--   <?php 
   $title='';
   $title1=DB_query("select * from tbl_title_master order by serial_no ASC limit 0,3",$db);
   while($r=DB_fetch_array($title1))
   { ?>
    <th><?php echo $r['title_name'];?></th>
    <?php } ?> -->
    <th style="width:80px;">Breakdown Type</th>
   <th style="width:80px;">Breakdown Sub Type</th>
   <th style="width:80px;">Breakdown Reason</th>
     <th style="width:80px;">Technician</th>
     <th style="width:80px;">Received Date</th>
    <th style="width:100px;">Exp.Com. Date</th>
    </tr>
    <?php 
    $srno=1;
    $sql_2=DB_query("select * from tpl_breakdown_mgmt_machine where master_id='".$job_id."'",$db);
     while($row1=DB_fetch_array($sql_2)) 
     {
          $unit_id=$s->getField('machine_center','id',$row1['asset_id'],'unit');
          $group_id=$s->getField('machine_center','id',$row1['asset_id'],'under_group');
    ?>
  <tr>
    <td class="border_bottom"><?php echo  $srno;?></td>
    <td class="border_bottom"><?php echo $s->getField('machine_center','id',$row1['asset_id'],'code');?></td>
    <td class="border_bottom"><?php echo $s->getField('machine_center','id',$row1['asset_id'],'name');?></td>
    <td class="border_bottom"><?php echo $s->getField('unitsofmeasure','unitid',$unit_id,'unitname'); ?></td>
    <td class="border_bottom"><?php echo $s->getField('machine_group_master','id',$group_id,'machine_gp_location'); ?></td>
   <!-- <td class="border_bottom"><?php echo $row3[$title[0]];?></td>
    <td class="border_bottom"><?php echo $row3[$title[1]];?></td>
    <td class="border_bottom"><?php echo $row3[$title[2]];?></td> -->
    <td colspan="6">
    <table cellspacing="0" cellpadding="0" style="border-collapse:collapse;" align="left">
    <?php 
    //  echo "SELECT * FROM tpl_breakdown_mgmt_details WHERE master_id='".$_REQUEST['Viewid']."'";
       $id_query1=DB_query("SELECT * FROM tpl_breakdown_mgmt_details WHERE master_id='".$_REQUEST['rid']."'",$db);
       $result_query2=DB_fetch_array($id_query1);
   // while($id_row_type=DB_fetch_array($id_query1))
    //{
    extract($result_query2);
    ?>
    <?php// } ?>
    <tr>
      <td style="width:80px;" class="border_bottom"><?php  $break_type; echo $s->GetFieldValue('break_down_type',"id='".$break_type."'",'breakdown_reason'); ?> </td>
      <td style="width:80px;" class="border_bottom"><?php  $break_sub_type; echo $s->GetFieldValue('tbl_sub_break_type',"id='".$break_sub_type."'",'sub_breaktype'); ?> </td>
      <td style="width:80px;" class="border_bottom"><?php echo $break_reason; ?>  </td>
      <td style="width:80px;" class="border_bottom"><?php $technician; echo $s->GetFieldValue('technicians',"id='".$technician."'",'technician'); ?>  </td>
      <td style="width:80px;" class="border_bottom"><?php $com_date; echo ConvertSQLDate($rec_date); ?> </td>
      <td style="width:100px;" class="border_bottom"><?php $com_date; echo ConvertSQLDate($com_date); ?> </td>
    </tr>
    <?php } ?>
    </table>
  </td>
    </tr>
  </tbody>
</table>
<div style="clear:both;"></div>
</div>

<div style="clear:both;"></div>
<div class="div_third">
<div class="left">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td colspan="3" class="f12" height="10"></td>
    </tr>
  <tr>
    <td width="27%" class="f12" nowrap>Prepared By</td>
    <td width="1%" class="f12">:</td>
    <td class="f11"><?php echo $s->GetFieldValue('www_users','id="'.$row['created_by'].'"','realname');?></td>
    </tr>
  <tr>
    <td class="f12">Date</td>
    <td class="f12">:</td>
    <td class="f11"><?php if($row['date']!='') echo date('d/m/y',strtotime($row['date'])); else echo ""; ?></td>
  </tr>
  <tr>
    <td colspan="3" class="f12" height="10"></td>
    </tr>  
</table>
</div>
<div class="middle">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td colspan="3" class="f12" height="10"></td>
    </tr>
  <tr>
    <td width="27%" class="f12" nowrap>Check By</td>
    <td width="1%" class="f12">:</td>
    <td class="f11">&nbsp;</td>
    </tr>
  <tr>
    <td class="f12">Date</td>
    <td class="f12">:</td>
    <td class="f11">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="3" class="f12" height="10"></td>
    </tr>  
</table>

</div>
<div class="right">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td colspan="3" class="f12" height="10"></td>
    </tr>
    <tr>
    <td colspan="3" class="f12" height="10"></td>
    </tr> 
    <tr>
    <td colspan="3" class="f12" height="10"></td>
    </tr> 
    <tr>
    <td colspan="3" class="f12" height="10"></td>
    </tr> 
    <tr>
    <td colspan="3" class="f12" align="center">Authorized Signatory</td>
    </tr> 
</table>
</div>
<div style="clear:both;"></div>
</div>
<div style="clear:both;"></div>
</div>
</div>
<script type="text/javascript" language="javascript">
  function toggle_visibility(id) {
  
       var e = document.getElementById(id);
        e.style.display = 'none';
         window.print();
  }
</script>
