<?php
ob_start();
$PageSecurity = 1;
include ('includes/session.inc');
include ('includes/function_lib.php');
include('includes/fun-php.php');
include('includes/fun-HRClass.php');

//$mpdf=new mPDF();
//$mpdf->Bookmark('Start of the document');

$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(); 

?>

<!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>Physical Stock Adjustment 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; 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;}

h1{
  font-size: 20px; line-height: 30px;
  font-weight:bold;
  text-transform: uppercase;
}
h2{
  font-size: 18px; line-height: 28px;
  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:100%;
  border-top: #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{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;}

.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%;}
.border_top{border-top:#000 1px solid;}
.border_bottom{border-bottom:#000 1px solid;}
.wdt1{width:60px;}
.wdt2{width:100px;}
.wdt3{width: 66px;}
.wdt4{width: 80px;}
.wdt5{width: 50px;}
.wdt6{width: 60px;}
}

@media screen{
/* CSS Document */
*{box-sizing:border-box;}
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: 30px;
  font-weight:bold;
  text-transform: uppercase;
}
h2{
  font-size: 18px; line-height: 28px;
  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 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:56%;}
.border_top{border-top:#000 1px solid;}
.border_bottom{border-bottom:#000 1px solid;}
.wdt1{width:80px;}
.wdt2{width:180px;}
.wdt3{width: 66px;}
.wdt4{width: 120px;}
.wdt5{width: 40px;}
.wdt6{width: 60px;}
}
</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']=='')?'Final_Logo_RM.png':$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>Stock Ledger Register Report</h2>
        </div>
        <div class="right"></div>
  </div> -->
  <div class="div_first">
      <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">

	<table width="100%" border="0" cellpadding="3" cellspacing="0">
	<tr>
    <th width="3%" class="f12">S. No.</th>  
	  <th width="9%" class="f12">PSA No.</th>
    <th width="6%" class="f12">Adjst. Date</th>     
	  <th class="f12 wdt1">Part Code</th>
    <th class="f12 wdt2">Part Name</th>
    <th class="f12 wdt1">Batch No.</th>
    <!-- <th width="70px;">Grade</th>
	  <th style="width:25px;" >UOM</th>-->
	  <th class="f12">Adjst. Qty.</th> 
    <th class="f12 wdt3">Adjst. Type</th>
	  <th class="f12 wdt4">Remark</th>	
    <th class="f12" width="9%">Created By</th>  
  </tr>
  
   <?php

	 $i=1;
	  $sql=$_SESSION['phy_sql_query'];
	 $res = DB_query($sql,$db);
	if(DB_num_rows($res)>0)
	{
  	 while($result = DB_fetch_array($res))
	 {
	   //echo '<pre>';print_r($result);
	 ?>
  <tr>
<td class="f11"><?php echo $i++;?></td>
<td class="f11"><?php  echo $result['ADJ_voucher_no'];?></td>
<td class="f11"><?php  echo $result['date1']; ?></td>
<td class="f11" colspan="6" style="padding:0px;" valign="top"> 
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<?php   
		$item_query = "select * from physical_stock_details where physical_stock_id='".$result['id']."'";
		$item_res = DB_query($item_query,$db) or die(DB_error());
		while($item_result = DB_fetch_array($item_res))
		{
			$item_query_1 = "select * from item_master where id='".$item_result['mstitemid']."'";
			$item_res_1 = DB_query($item_query_1,$db) or die(DB_error());
			while($item_result_1 = DB_fetch_array($item_res_1))
			{
	?>
	<tr>
		<td class="wdt1"><?php echo $item_result_1['StockID'];?></td>
		<td class="wdt2"><?php echo $item_result_1['item_name']; ?></td> 
		<td class="wdt1"><?php echo $item_result['batch_no']; ?></td> 
		<!--<td width="19%" align="left" valign="top" style="border:1px solid #666666;"><?php //echo $s->getField('product_grade','id',$item_result['grade_id'],'grade');  ?></td> 
		<?php 
			//$query2 = "select * from unitsofmeasure where unitid='".$item_result_1['mst_unitid']."'";
			//$res2 = DB_query($query2,$db) or die(DB_error());
			//$result2 = DB_fetch_array($res2);
		?>
		<td width="9%" align="left" valign="top" style="border:1px solid #666666;"><?php  //echo $result2['unitname'];?> </td>-->
			<td class="wdt6 f11" style="text-align:right"><?php echo number_format($item_result['adjustment_qty'],2); ?></td>
			<td class="wdt5 f11"><?php echo $s->getField('unitsofmeasure','unitid',$item_result['uom'],'unitname'); ?> </td>
			<td class="wdt6 f11" style="text-align:right"><?php echo number_format($item_result['stock_qty2'],2); ?></td>
			<td class="f11"><?php echo $s->getField('unitsofmeasure','unitid',$item_result['uom1'],'unitname');  ?></td>		
		  <td class="wdt3 f11"><?php echo $item_result['adjustment_type']; ?></td> 
		  <td class="wdt4"><?php echo $item_result['remarks']; ?></td> 
	</tr> 
	<?php } } 
         
	?>
</table>
</td> 
<td><?php echo $s->getField('www_users','id',$result['createdBy'],'realname'); ?></td>
		

  </tr>
  
  
  <?php  } } else {

        	?>
         <tr>
         	 <td colspan="10" class="f12">There are no records found</td>
         </tr>
        	<?php
        } 
   
  ?>
  
    <?php if($numrow1>0) { ?>
   <?php if(!empty($a)) { ?>
   

      <?php } } else { ?>  
      <?php } ?>   
</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>