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

	$sql = "SELECT * FROM tpl_breakdown_mgmt where id='".$_REQUEST['rid']."'";
	$result = DB_query($sql,$db);
	$row = DB_fetch_array($result);
	
	$sql2 ="SELECT asset_id FROM tpl_breakdown_mgmt_machine where master_id='".$_REQUEST['rid']."'";
	$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);
       $path=$s->getField('companies','CompanyId',$_SESSION['ACGCompanyId'],'CompanyLogo');

  $Compamies=DB_query("select * from companies",$db);
$CompamiesRow=DB_fetch_array($Compamies);
$sql1 = "SELECT * FROM companies where CompanyId='".$_SESSION['ACGCompanyId']."'";
  $sqlres = DB_query($sql1,$db);
  $companyRow = DB_fetch_array($sqlres);
		
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
  <title>Fixed Asset Transfer Request</title>

<style type="text/css" media="print">
  @page port {size: portrait;}
@page land {size: landscape;}
 .portrait {page: port;}
.wrapper {page: land;}

</style>

<style type="text/css"> 
@print {size: portrait; margin:10px;}

@media print{
body{ margin:0px; padding:0px;  font-size:12px; line-height: 18px; 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;}

h1{
  font-size: 20px; line-height: 24px;
  font-weight:normal;
  font-family:Arial, Helvetica, sans-serif !important;
}
h2{
  font-size: 18px; line-height: 22px;
  font-weight:normal;
  font-family:Arial, Helvetica, sans-serif !important;
}
thead{display: table-header-group;}
.wrapper{width:99%; height: auto; float:left; border:#000000 1px solid; border-bottom:#000000 1px solid;}
.div_first, .div_first .full{
  width: 100%; height: auto;
  /*border-bottom: #000000 1px solid;
  border-top: #000000 1px solid;*/
  /*border-left: #000000 1px solid;
  border-right: #000000 1px solid;*/
  float: left; position: relative;
}
 .div_first .left
  {
    width:18%; text-align:left; height:auto; vertical-align:middle; height:auto; padding: 1%; float:left;
  }
  .div_first .middle
  {
    width:58%; text-align:center; padding: 1%; margin:0 auto; float: left;
  }
  .div_first .right
  {
    width:18%; text-align:right; padding: 1%; float: left;
  }

.div_first .full{text-align: center; border: 0;}
.div_second, .div_third, .div_forth{
  width: 100%;
  height:auto;
  border-top: #000000 1px solid;
  /*border-bottom: #000000 1px solid;*/
  /*border-left: #000000 1px solid;
  border-right: #000000 1px solid;*/
  float: left;
}
.div_second table tr th, .div_second table tr td{border-right:#000000 0px solid; border-bottom:#000000 1px solid;}
.div_second table tr th{text-align: left;}
.div_second table tr th:last-child, .div_second table tr td:last-child{border-right:0;}
.div_second table tr:last-child td{border-bottom:0;}
.div_second table tr td > table tr td{border-right:#000000 1px solid; border-bottom:#000000 1px solid;}
.div_second table tr td > table tr td:last-child{border-right:0;}
.div_second table tr td > table tr:last-child td{border-bottom:0;}

.div_third table tr th, .div_third table tr td{ border-bottom:#000 1px solid; border-right:#000 1px solid;}
.div_third table tr th{background-color:transparent; text-align: left;}
.div_third table tr th:last-child, .div_third table tr td:last-child{border-right:none;}
.div_third table tr:last-child td{border-bottom:none;}

.div_forth table tr th, .div_forth table tr td{ border-bottom:#000 1px solid; border-right:#000 1px solid;}
.div_forth table tr th{background-color: #ccc; text-align: left;}
.div_forth table tr th:last-child, .div_forth table tr td:last-child{border-right:none;}
.div_forth table tr:last-child td{border-bottom:none;}

.f12{ font-weight: bold; color:#000; font-size:12px;}
.f11{color:#000; font-size:12px; font-weight: normal; line-height:18px;}
.f14{color:#000; font-size:18px;}
.mt26{margin-top:4px; width:90%;}
.mt27{margin-top:0px; width:70%;}
.mt28{margin-top:0px; width:100%;}
.border_top{border-top:#000 1px solid;}
.border_bottom{border-bottom:#000 1px solid;}
.wdt1{width:8%;}
.wdt2{width:100px;}
.wdt3{width: 66px;}
.wdt4{width: 80px;}
.wdt5{width: 52px;}
.wdt6{width: 60px;}
}

@media screen{
/* CSS Document */
body{ margin:0px; padding:0px; background-color:#fff; font-size:12px; line-height: 18px; 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;}

#foo{width:1070px; height: auto; margin:0px auto;}
.wrapper{width:1070px; height: auto; margin:10px auto; border-top:#000000 1px solid;}

h1{
  font-size: 24px; line-height: 28px;
  font-weight:bold;
  font-family:Arial, Helvetica, sans-serif !important;
}
h2{
  font-size: 18px; line-height: 22px;
  font-weight:normal;
  font-family:Arial, Helvetica, sans-serif !important;  
}
.div_first, .div_first .full{
  width: 100%; height: auto;
  /*border-bottom: #000000 1px solid;
  border-top: #000000 1px solid;*/
  border-left: #000000 1px solid;
  border-right: #000000 1px solid;
  float: left; position: relative; display: table;
}
.div_first .full{text-align: center; border: 0; margin:10px 0 0;}
.div_first .left, .div_first .middle, .div_first .right{float: left; display: table-cell; vertical-align: middle;}
.div_first .left
{
  width:18%; text-align:center; height:auto; vertical-align:middle; padding: 1%; 
}
.div_first .middle
{
  width:58%; text-align:center; padding: 1%; position: relative; margin:0 auto;
}
.div_first .right
{
  width:18%; text-align:center; padding:1%; 
}
.div_second, .div_third, .div_forth{
  width: 100%; height: auto;
  /*border-bottom: #000000 1px solid;*/
  border-top: #000000 1px solid;
  border-left: #000000 1px solid;
  border-right: #000000 1px solid;
  float: left;
}
.div_second table tr th, .div_second table tr td{border-right:#000000 0px solid; border-bottom:#000000 1px solid;}
.div_second table tr th{background-color: #ccc; text-align: left;}
.div_second table tr th:last-child, .div_second table tr td:last-child{border-right:0;}
.div_second table tr:last-child td{border-bottom:0;}
.div_second table tr td > table tr td{border-right:#000000 1px solid; border-bottom:#000000 1px solid;}
.div_second table tr td > table tr td:last-child{border-right:0;}
.div_second table tr td > table tr:last-child td{border-bottom:0;}

.div_third table tr th, .div_third table tr td{ border-bottom:#000 1px solid; border-right:#000 1px solid;}
.div_third table tr th{background-color: #ccc; text-align: left;}
.div_third table tr th:last-child, .div_third table tr td:last-child{border-right:none;}
.div_third table tr:last-child td{border-bottom:none;}

.div_forth{border-bottom:#000000 1px solid;}

.f12{font-weight: bold; color:#000; font-size:12px;}
.f11{ color:#000; font-size:12px; font-weight: normal; line-height:18px;}
.f14{ color:#000; font-size:18px;}
.mt26{margin-top:4px; width:90%;}
.mt27{margin-top:0px; width:100%;}
.mt28{margin-top:0px; width:90%;}
.border_top{border-top:#000 1px solid;}
.border_bottom{border-bottom:#000 1px solid;}
.wdt1{width:10%;}
.wdt2{width:180px;}
.wdt3{width: 66px;}
.wdt4{width: 120px;}
.wdt5{width: 52px;}
.wdt6{width: 70px;}
}
</style>
</head>
 <body>
<div id="foo">
  <p style="text-align:right;"><input type="button" onclick="javascript:toggle_visibility('foo');" value="Print" /></p>
</div>

<div class="wrapper">
<div class="div_first">
<?php $logoImage=($CompamiesRow['CompanyLogo']=='')?'electra.jpg':$CompamiesRow['CompanyLogo']; ?>
      <div class="left"><img src="Setup/CompanyLogo/<?php echo $logoImage;  ?>" class="mt26" /></div>
      <div class="middle"><?php 
    if($CompamiesRow['CompanyName']!="") {echo "<h1>".$CompamiesRow['CompanyName']."</h1>"; } else { echo "";}
    
    if($InoRow['deladd1']!="") { echo $InoRow['deladd1']; } else { echo "";}
    if($InoRow['deladd2']!="") { echo ", ". $InoRow['deladd2']; } else { echo "";}
    if($InoRow['deladd3']!="") { echo ", ". $InoRow['deladd3']; } else { echo "";}
    if($InoRow['city']!="") { echo ", ". $s->getFieldValue("city_master", "id='".$InoRow['city']."'", "city"); } else { echo "";}
    if($InoRow['pincode']!="") { echo " - ".$InoRow['pincode']; } else { echo "";}
    if($InoRow['state']!="") { echo ", ". $s->getFieldValue("state_master", "id='".$InoRow['state']."'", "state"); } else { echo "";}
    if($InoRow['country']!="") { echo ", ". $s->getFieldValue("country_master", "id='".$InoRow['country']."'", "country");
    
     } else { echo "";}
    ?>
     <div class="full"><span class="f11"><?php echo "Phone No.:".$CompamiesRow['Phone'].",   Fax No.: ".$CompamiesRow['fax'].", Email ID.: ".$CompamiesRow['email'].",   Website: ".$CompamiesRow['website']; ?><br>
  <?php  echo $_SESSION['mess']; ?>
  </span></div>
      <h2>Asset Breakdown Slip</h2>
      </div>
      <div class="right"></div>
</div>

<div class="div_second">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr class="f12">
	<th colspan="4">General Details</th>
</tr>
<tr class="f11">
	<td class="f12" width="13%">Requested Site:</td>
	<td width="35%"><?php echo $s->GetFieldValue('locations','loccode="'.$row['site'].'"','locationname');  //$row['site'];?></td>
	<td class="f12" width="13%">Received Date:</td>
	<td><?php if($row['asset_rec_date_time']!='') echo date('d/m/y',strtotime($row['asset_rec_date_time'])); else echo ""; ?></td>
</tr>
<tr class="f11">
	<td class="f12">Received From:</td>
	<td><?php echo $row['rec_from']; ?></td>
	<td class="f12">Received By:</td>
	<td><?php echo $row['rec_by'];?></td>
</tr>
</table>
</div>
<div class="div_third">
	<table width="100%" border="0" cellpadding="3" cellspacing="0">
	<tr>
		<th colspan="6" class="f12">Assets Details</th>
	</tr>
		<tr>
			<th width="4%">S. No.</th>
			<th width="10%">Asset Code</th>
			<th>Asset Name</th>
			<th width="10%">Asset Group</th>			
			<th width="15%">Model No.</th>
			<th width="15%">Unit of Measurement</th>			
		</tr> 
   <?php 
   $sqlU=DB_query("Select * from unitsofmeasure where unitid='".$row3['unit']."' ",$db); 
		 $myrow_unit=DB_fetch_array($sqlU);
		 
		 // asset group
  	$reqDet_sql1 = "SELECT * FROM tpl_materialcategorydefinition WHERE ID= ".$row3['under_group']."";
		$result1 = DB_query($reqDet_sql1,$db);
		$assetRow1 = DB_fetch_array($result1);
   ?>

<tr>
	<td><?php echo  $_REQUEST['srno'];?></td>
	<td><?php echo $row3['code']; ?></td>
	<td><?php echo $row3['name']; ?></td>
	<td><?php echo $s->GetFieldValue('machine_group_master','id="'.$row3['under_group'].'"','machine_gp_location');   //$assetRow1['asset_capitalisation']; ?></td>
	<td><?php echo $row3['model_no']; ?></td>
	<td><?php echo $myrow_unit['unitname']; ?></td>	
</tr>
</table>
</div>

<!--<tr class="row1">
	<td colspan="4" style="padding:0px;">
	<table width="100%" border="1" cellpadding="3" cellspacing="0">
		<tr class="row1">
		<td width="4%">Sr no.</td>
			<td width="4%">Breakdown Type</td>
			<td width="10%">Sub Break Down Type</td>
			<td width="10%">Breakdown Reason</td>
			<td width="10%">Technician Name</td>
	</tr> 
   <?php 
   
   //$sqlBR=DB_query("SELECT * FROM tpl_breakdown_mgmt_details where master_id='".$_REQUEST['rid']."' ",$db); 
  // $i=0;
		// while($row4=DB_fetch_array($sqlBR))
		// {
		 
	//	$i++;
		//$site_sql1=DB_query("Select id,breakdown_reason from break_down_type where id='".$row4['break_type']."' ",$db);
		//$site_row1=DB_fetch_array($site_sql1);
		
		//$id_query1=DB_query("Select * from tbl_sub_break_type where id='".$row4['break_sub_type']."' ",$db);
	//$id_row_type=DB_fetch_array($id_query1);
	
	//$id_query2=DB_query("Select * from technicians where id='".$row4['technician']."' ", $db);
	//$id_row_technician=DB_fetch_array($id_query2);
   ?>

<tr class="row1">
	<td style="width:1%"><?php //echo  $i; ?></td>
	<td><?php //echo $site_row1['breakdown_reason']; ?></td>
	<td><?php //echo $id_row_type['sub_breaktype']; ?></td>
	<td><?php //echo $row4['break_reason']; ?></td>
	<td><?php //echo  $id_row_technician['technician']; ?></td>
	
</tr>
<?php //} ?>
</table>
</td>
</tr>-->
<div class="div_forth">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr class="f12">
<td width="50%">Created By:</td>
<td align="right">Approved By:</td>
</tr>
<tr class="f12">
<td valign="bottom"><?php echo $s->GetFieldValue('www_users','id="'.$row['created_by'].'"','realname');?></td>
<td align="right" valign="bottom">&nbsp; </td>
</tr>
</table>
</div>
</div>
<script type="text/javascript" language="javascript">
  function toggle_visibility(id) {
       var e = document.getElementById(id);
        e.style.display = 'none';
           //alert(e.style.display);
         window.print();
	}
</script>
</body>
</html>