<?php error_reporting(0);
   session_name('CAKEPHP'); session_start();
  $PageSecurity = 3;
  include ('includes/session.inc');
  include ('includes/function_lib.php');
  include('includes/fun-php.php');
  include('includes/fun-HRClass.php');
  global $db;   
 $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);
  $s=new db_query(); 
?>

<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>

<!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>Stock Ledger Register</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"> 
@page {size: portrait; margin:10px;}

@media print{
*{box-sizing:border-box;}
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: 28px;
  font-weight:bold;
  text-transform: uppercase;
}
h2{
  font-size: 18px; line-height: 26px;
  font-weight:normal;
}
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;
  float: left; position: relative;
}
 .div_first .left
  {
    width:16%; text-align:center; height:auto; vertical-align:middle; height:auto; padding: 1% 0; float:left;
  }
  .div_first .middle
  {
    width:68%; text-align:center; padding: 1% 0; margin:0 auto; float: left;
  }
  .div_first .right
  {
    width:16%; text-align:center; padding: 1% 0; float: left;
  }

.div_first .full{text-align: center; border: 0;}
.div_second, .div_third{
  width: 100%;
  height:auto;
  float: left;
}
.div_second table tr th, .div_second table tr td{border-right:#000000 1px solid; border-bottom:#000000 1px solid;}
.div_second table tr th{text-align: left; 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;}

.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;}

.f12{ font-weight: bold; color:#000; font-size:12px;}
.f11{color:#000; font-size:12px; line-height:18px;}
.f14{color:#000; font-size:18px;}
.mt26{margin-top:8px; width:96%;}
.mt27{margin-top:4px; width:66%;}
.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 */
*{box-sizing:border-box;}
body{ margin:0px; padding:0px; background-color:#fff; font-size:12px; 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;
  text-transform: uppercase;
}
h2{
  font-size: 18px; line-height: 22px;
  font-weight:normal; 
}
.div_first, .div_first .full{
  width: 100%; height: auto;
  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:16%; text-align:center; height:auto; vertical-align:middle; padding: 1% 0; 
}
.div_first .middle
{
  width:68%; text-align:center; padding: 1% 0; position: relative; margin:0 auto;
}
.div_first .right
{
  width:16%; text-align:center; padding:1% 0; 
}
.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 1px 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;}*/

.f12{font-weight: bold; color:#000; font-size:12px;}
.f11{ color:#000; font-size:12px; line-height:18px;}
.f14{ color:#000; font-size:18px;}
.mt26{margin-top:4px; width:96%;}
.mt27{margin-top:4px; width:66%;}
.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']=='')?'ssmh-logo.jpeg':$CompamiesRow['CompanyLogo']; ?>
      <!-- <div class="left"><img src="Setup/CompanyLogo/<?php //echo $logoImage;  ?>" class="mt26" /></div> -->
      <div class="left"><img src="images/ssmh-logo.jpeg" class="mt26" /></div>
      <div class="middle"><h1>Shekhar Sharraf Memorial Hospital</h1>
        <div class="f14">RUSA Medical Centre (Aligarh)</div>
        <div class="f12">6Km. Milestone, Agra Road, Aligarh - 202001, U.P. (India)</div>
        <div class="f12">Email : info@rusamedicalcentre.com</div>
        <div class="full"><h2>Stock Ledger Register Report</h2></div>
      </div>
      <div class="right"><img src="images/rusa-logo.jpeg" vspace="10" class="mt27" /></div>
  </div>
<div class="div_second">
 <p align="center"><?php echo $message; ?></p>
 <table width="100%" border="0" cellpadding="3" cellspacing="0">
 <thead>
 <tr>
    <th class="f12" width="3%" rowspan="2" align="left">S.No.</th>
    <th class="f12" width="5%" rowspan="2" align="left">Date</th>
    <th class="f12" rowspan="2" align="left">Particulars of Transactions</th>
    <th class="f12" width="15%" rowspan="2" align="left">Transaction No.</th>
    <th class="f12" rowspan="2" align="left">Against Bill/Challan</th>
    <th class="f12" colspan="2" style="text-align:center">Received Qty.</th>
    <th class="f12" colspan="2" style="text-align:center">Issued Qty.</th>
    <th class="f12" colspan="2" style="text-align:center">Balance Qty.</th>
  </tr>
  <tr>
    <th class="f12" width="6%">Primary</th>
    <th class="f12" width="6%">Secondary</th>
    <th class="f12" width="6%">Primary</th>
    <th class="f12" width="6%">Secondary</th>
    <th class="f12" width="6%">Primary</th>
    <th class="f12" width="6%">Secondary</th>
  </tr>
</thead>
    <?php
    //echo "manish";stock_ledger_print
   // $data=$_SESSION['stock_ledger_print_data'];
    //echo "<pre>";print_r($data);
    $data=$_SESSION['stock_ledger_print'];
  if(count($data)>0)
  {
  $var=0;
  $i=1;
  foreach($data as $key=>$value)
  { 
  $confac=$s->getField('item_master','id',$value['itemid'],'conv_factor');
  if($value['reciveqty']!='' || $value['issueqty']!='')
  {
    if($value['description']=='Opening')
    {
    $bgcolor='#999999';
    }
    else
    {
    $bgcolor='#FFFFFF';
    }
  ?>    
  <tr>
    <td class="f11"><?php echo $i++;?></td>
    <td class="f11"><?php echo ConvertSQLDate($value['date']);?></td>
    <td class="f11"><?php echo $value['description'];?>&nbsp;</td>
    <td class="f11"><?php echo $value['slipno'];?>&nbsp;</td>
    <td class="f11"><?php echo $value['doc'];?>&nbsp;</td>     
    <td class="f11" style="text-align:right;">&nbsp;<?php   echo $value['reciveqty'];
     $recieve[]=$value['reciveqty'];
    //}
    ?></td>
    <td class="f11" style="text-align:right;">&nbsp;<?php   echo round($value['reciveqty']*$confac,2);
     $recieve2[]=$value['reciveqty']*$confac;
    //}
    ?></td>
      <td class="f11" style="text-align:right;"><?php echo $value['issueqty']; $issue[]=$value['issueqty'];?>&nbsp;</td>
     <td class="f11" style="text-align:right;"><?php echo round($value['issueqty']*$confac,2); $issue2[]=$value['issueqty']*$confac;?>&nbsp;</td>
      <td class="f11" style="text-align:right;"><?php $total12=array_sum($recieve);
              $total13=array_sum($issue);
        $opentotal=trim($total12)-trim($total13);
    
     echo $opentotal; ?></td>
     <td class="f11" style="text-align:right;"><?php $total12=array_sum($recieve2);
              $total13=array_sum($issue2);
        $opentotal=trim($total12)-trim($total13);
    
     echo round($opentotal,2); ?></td
    >
    </tr>
 <?php } }  ?>

<tr>
  <td class="f12" colspan="5" align="right">Total</td> 
  <td class="f12" style="text-align:right;"><?php echo $stock1=array_sum($recieve);?></td>
  <td class="f12" style="text-align:right;"><?php echo $stock2=round(array_sum($recieve2),2); ?></td>
  <td class="f12" style="text-align:right;"><?php echo $stock2=array_sum($issue); ?></td>
  <td class="f12" style="text-align:right;"><?php echo $stock1=round(array_sum($issue2),2); ?></td>
  <td class="f12" style="text-align:right;"><?php
     $receivedata=array_sum($recieve);
   $issuedata=array_sum($issue);
      $total=trim($receivedata)-trim($issuedata);
   echo $stock1=$total;
    ?></td>
  <td class="f12" style="text-align:right;"><?php
     $receivedata1=array_sum($recieve2);
   $issuedata1=array_sum($issue2);
     $total=trim($receivedata1)-trim($issuedata1);
     echo $stock1=round($total,2);  
    ?></td> 
  </tr>
  
 <tr>
  <td class="f12" colspan="10" align="right">Total Primary in Store </td> 
  <td class="f12" align="right">
 <?php 
     $receivedata2=array_sum($recieve);
   $issuedata2=array_sum($issue);
      $total2=trim($receivedata2)-trim($issuedata2);
 echo $stock1=$total2;
    ?></td>    
    </tr>
  <tr><td class="f12" colspan="10" align="right">Total Secondary in Store </td>
 <td class="f12" align="right">
 <?php 
     $receivedata2=array_sum($recieve2);
   $issuedata2=array_sum($issue2);
      $total2=trim($receivedata2)-trim($issuedata2);
 echo $stock1=round($total2,2);
    ?></td>    
    </tr>
<?php } else { ?>
<tr bgcolor="#FFFFFF">
<td class="f12" colspan="11">No Records</td></tr>
<?php } ?>
  </table>
</div>
</div>

</body>
</html>
