<?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 R.*, E.emp_name, L.loccode 
        from tpl_asset_transfer_request R 
        INNER JOIN empmaster E on E.id=R.requested_by
        INNER JOIN locations L on L.loccode=R.requested_site
        where R.CompanyId='".$_SESSION['ACGCompanyId']."' and R.id='".$_REQUEST['rid']."'";
$sql=DB_query($sqlq,$db);
$row = DB_fetch_array($sql);

$sqlq=$_SESSION['asset_issue_rep'];
   $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>AMC Entry Print</title>

<style type="text/css">
@page {size:A4; margin:20px;}
@media print{
body{ margin:0px; padding:0px; font-size:12px; font-family: "Times New Roman", Times, serif; color:#000; font-weight:normal;}
h1,h2,h3,h4,h5,p{ margin:0px; padding:0px;}
#foo{width:800px; height: auto; margin:0px auto;}
.wrapper{width:800px; height: auto; float:left; border-top:#000000 1px solid;}
.div_first{
  width: 798px; 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_first .left{
  width: 100px;
  float:left;
  text-align:center;
  padding-top:10px;
  padding-bottom:10px;
  border-right:#000 1px solid;
}
.div_first .right{
  width:697px;
  float:left; 
  padding-top:10px;
  padding-bottom:10px;
  text-align:center;
}
.div_second{
  width: 798px;
  height:100%;
  /*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, td{border-right:#000000 1px solid; border-bottom:#000000 1px solid;}
.div_second table tr th{border-top:#000000 1px solid;}
.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;}
thead{display: table-header-group;}
.panel{width:100%; overflow:auto; margin:auto;}
.mt26{margin-top:8px; width:60%;}
.f12{ font-size:13px; color:#000;}
.f11{font-size:12px; color:#000;}
h2{font-size:18px; font-weight:normal;}
h3{font-size:16px; font-weight:normal;}
}
@media screen{
body{ margin:0px; padding:0px; font-size:12px; font-family: "Times New Roman", Times, serif; color:#000; font-weight:normal;}
h1,h2,h3,h4,h5,p{ margin:0px; padding:0px;}
#foo{width:1200px; height: auto; margin:0px auto;}
.wrapper{width:1200px; height: auto; margin:10px auto; border-top:#000000 1px solid;}
.div_first{
  width: 1200px; 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_first .left{
  width: 107px;
  float:left;
  text-align:center;
  padding-top:10px;
  padding-bottom:10px;
   border-right:#000 1px solid;
}
.div_first .right{
  width:1091px;
  float:left; 
  padding-top:10px;
  padding-bottom:10px;
  text-align:center;
}
.div_second{
  width: 1200px; 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, td{border-right:#000000 1px solid; border-bottom:#000000 1px solid;}
.div_second table tr th{background-color: #ccc;}
.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;}
.panel{width:1200px; overflow:auto; margin:auto;}
.mt26{margin-top:8px; width:60%;}
.f12{font-size:13px; color:#000;}
.f11{font-size:12px; color:#000;}
h2{font-size:20px; font-weight:normal;}
h3{font-size:18px; font-weight:normal;}
}
</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 echo "<strong>". $companylogo=$s->getField('companies','CompanyId',$_SESSION['ACGCompanyId'],'CompanyName');"</strong>"?>-->
  <?php
      $logoImage=($companyRow['CompanyLogo']=='')?'index11.jpeg':$companyRow['CompanyLogo'];

   ?>
      <div class="left"><img src="Setup/CompanyLogo/<?php echo $logoImage;  ?>" class="mt26" /></div>
        <div class="right">
        <h2><?php echo $row4['CompanyName'];?></h2>
     <h3>AMC Entry</h3>
  <p class="f11"><?php echo $row4['Address1']." ".$row4['Address2']." ".$row4['Address3'];?>, <?php echo $row4['City'];?>, <?php echo $row4['State'];?>, <?php echo $row4['Country'];?>, Pincode - <?php echo $row4['Zipcode'];?><br />
<strong>Phone:</strong> <?php echo $row4['Phone'];?>, <strong>Email:</strong> <?php echo $row4['email'];?>, <strong>Website:</strong> <?php echo $row4['HomePage'];?></p>
    </div>
</div>
<div class="div_second">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<thead>
<tr>
        <th class="f12" width="4%" style="text-align:left;"><strong>S. No.</strong></th>
        <th class="f12" width="5%" style="text-align:left;"><strong>Branch</strong></th>
        <th class="f12" width="10%" style="text-align:left;"><strong>AMC No.</strong></th>
        <th class="f12" width="26%" style="text-align:left;"><strong>Vendor Name</strong></th>
        <th class="f12" width="12%" style="text-align:left;"><strong>Financial Year</strong></th>
        <th class="f12" style="text-align:left;"><strong>Asset Name</strong></th>  
        <th class="f12" width="70" style="text-align:left;"><strong>Start date</strong></th>
        <th class="f12" width="70" style="text-align:left;"><strong>End date</strong></th>
        <th class="f12" width="70" style="text-align:left;"><strong>Amount</strong></th>  
</tr>
</thead>
<?php 
 // $sql=$_SESSION['myone'];

         $id1=$_REQUEST['rid'];
        $sql ="select * from tpl_amc where id='$id1' "; 
        
                 
         $record=DB_query($sql,$db);
        $i=0;
        if(DB_num_rows($record)>0){
        while($row=DB_fetch_array($record))
        {
        $i++;
        extract($row);
        $pid=$row['id'];


?>
<tr>
      <td class="f11"><?php  echo $i;?></td>
      <td class="f11">     
      <?php  
      echo $s->getField('locations','loccode',$row['site'] ,'locationname');
       ?>
      </td>
      <td class="f11"><?php   echo $row['slip_no'];  ?></td>
      <td class="f11"><?php   echo $s->getField('suppliers','id',$row['vendor_id'] ,'vendor_name'); ?></td>
      <td class="f11">
<?php
         $sdate=$s->getField('company_financial_years','id',$row['fin_year'] ,'year_start');
         $sdate1=explode("-",$sdate);
         $sdate2=$sdate1[0];
         $edate=$s->getField('company_financial_years','id',$row['fin_year'] ,'year_end');
        $edate1=explode("-",$edate);
        $edate2=$edate1[0];
         $sdate2."-".$edate2;
?>
        <?php echo $sdate2."-".$edate2; ?>
</td>
  <td class="f11" colspan="4" style="padding:0px;" valign="top">
  <table width="100%" border="0" cellpadding="3" cellspacing="0">
  <?php
    $reqDet_sql = "select * from tpl_amc_dtls where tpl_amc_id=$pid;";
          
    $result = DB_query($reqDet_sql,$db);
    if(DB_num_rows($result)>0){
      while($assetRow = DB_fetch_array($result)){?>
        <tr>          
          <td><?php  echo $s->getField('machine_center','id',$assetRow['asset_id'] ,'name');?></td>
          <td width="70"><?php  echo $assetRow['start_date'];?></td>
          <td width="70"><?php  echo $assetRow['end_date'];?></td>
          <td width="70" style="text-align:right;"><?php  echo $assetRow['amount'];?></td> 
  </tr>
    <?php }
    }
  ?>  
  </table>
</td>
</tr><?php 
} }


else{?>
<tr>
<td colspan="9"><font color="#FF0000">No Record Found</font></td>
</tr>
<?php }?>
</table>
            </div>

              <?php if(isset($_SESSION['success_msg']))
              { ?>
                <script> alert("<?php echo ($_SESSION['success_msg']);?>");</script>
              <?php 
              } unset($_SESSION['success_msg']);
              ?>
</div>
</form>

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