<?php
session_name('CAKEPHP'); session_start();
error_reporting(FALSE);
$PageSecurity = 3;  
  
include('config.php');
include('includes/ConnectDB.inc');
include('includes/function_lib.php');
include('includes/LanguageSetup.php');
include('includes/DateFunctions.inc');
 ?>
<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>
<?php 
 $sql =$_SESSION['ReceivedReportSql'];  
 $s=new db_query();
?>
<?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>Transfer Receive 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: 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:auto;
  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:40px;}
.wdt2{width:60px;}
.wdt3{width: 70px;}
.wdt5{width: 50px;}
.wdt4{width: 40px;}
}

@media screen{
/* CSS Document */
*{box-sizing:border-box;}
body{ margin:0px; padding:0px; background-color:#fff; font-size:12px; line-height: 18px; color:#000; font-weight:normal; font-family: Arial, Helvetica, sans-serif;}
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-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:56%;}
.border_top{border-top:#000 1px solid;}
.border_bottom{border-bottom:#000 1px solid;}
.wdt1{width:64px;}
.wdt2{width:80px;}
.wdt3{width: 70px;}
.wdt5{width: 60px;}
.wdt4{width: 40px;}
}
</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>Transfer Receive 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>Transfer Receive 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%" cellpadding="3" cellspacing="0" border="0">

    <tr>
      <th width="3%" class="f12">S.No.</th>
      <th width="5%" class="f12">SRN Date</th>      
      <th width="8%" class="f12">SRN Slip No.</th>   
      <th width="8%" class="f12">STN</th>
      <!-- <th width="8%" class="f12">Issue Branch</th> -->
      <th width="8%" class="f12">Received Store</th>
      <th class="f12 wdt1">Item Code</th> 
      <th class="f12 wdt2">Item Name</th>
      <th class="f12 wdt1">Batch No.</th>
      <th class="f12 wdt1">Transfered Qty.</th> 
      <th class="f12">Receive Qty.</th>
      <!--<th width="114" class="tabledata" style="width:114px;">UOM</th>-->
      <!--<th width="114" class="tabledata" style="width:114px;"><span class="tabledata" style="width:76px;">Size </span></th>-->
      <!--<th width="114" class="tabledata" style="width:114px;">Batch No</th>-->
      <th class="f12 wdt5">Pending Qty.</th>
      <!-- <td width="97" class="tabledata1"  style="width:77px;"><strong>Total Price </td>
      <td width="102" class="tabledata1"  style="width:77px;"><strong>Amount</strong></td>-->
    </tr>
    <?php 
 // $sql = "Select * from addissue";
 
  $result=DB_query($sql,$db);
  $sno = 0;
  while($myrow=DB_fetch_array($result))
  {
   // print_r($$myrow['sitecode_to']);
    $sno += 1;
  ?>
    <tr>
      <td class="f11"><?php echo $sno;?></td>
      <td class="f11"><?php echo ConvertSQLDate($myrow['received_date']);?></td>
      <td class="f11"><?php echo $myrow['received_slip_no'];?></td>
      <td class="f11"><?php echo $s->GetFieldValue('transfer_issue',"id='".$myrow['issue_slipno']."'",'issue_slipno')  ; ?></td>
      <!-- <td class="f11"><?php echo $s->GetFieldValue('locations',"loccode='".$myrow['site_from']."'",'locationname') ; ?></td> -->
      <td class="f11"><?php echo $s->GetFieldValue('storetype',"id='".$myrow['site_from']."'",'StoreName') ;  ?></td>
      <td colspan="6" style="padding:0px;" class="f11" valign="top">
        <table width="100%" border="0" cellpadding="3" cellspacing="0">
          <?php 
    $details_sql="Select * from transfer_receipt_details where transfer_receipt_id='".$myrow['id']."'";
    if($_REQUEST['itmname']!='0'){
      $details_sql .= " AND itemid='".$_REQUEST['itmname']."'";
    }
  $_SESSION['details_sql']=$details_sql;
  $details_res=DB_query($details_sql,$db);
  $issueqty[]='';
  $req_qty[]='';
  $pendingqty[]='';
    $i="1";
  $numrow1=DB_num_rows($details_res);
  if(DB_num_rows($details_res)>0){

  while($details_row=DB_fetch_array($details_res)){ 
    

    $pendingqty[$i]=$details_row['issue_qty'] - $details_row['reciveqty'];
    //print_r($pendingqty);

     // $pendingqty[$i];
     //  if($pendingqty[$i]!='0' && $pendingqty[$i]!='')
     //    {
     //      //echo $pendingqty[$i];

     //      $pq = $pendingqty[$i]-$details_row['reciveqty'];
     //      $pendingqty[$i]=$pq;
     //    }
     //    else{

     //      $pq=$details_row['issue_qty'] - $details_row['reciveqty'];
     //      $pendingqty[$i]=$pq;
     //    } 

    
    ?>
          <tr>
            <td class="f11 wdt1"><?php echo $s->getField('item_master','id',$details_row['itemid'],'StockID'); ?>&nbsp;</td>
            <td class="f11 wdt2"><?php echo $s->getField('item_master','id',$details_row['itemid'],'item_name'); ?>&nbsp;</td>
            <td class="f11 wdt1"><?php echo $details_row['batch_no']; // $s->GetFieldValue('unitsofmeasure',"unitid='".$details_row['mst_unitid']."'",'unitname'); ?>&nbsp;</td>
            <td class="f11 wdt1" style="text-align:right"><?php echo number_format($details_row['issue_qty'],2);
            $issueqty[]=$details_row['issue_qty']; ?></td>
            <td class="f11 wdt5" style="text-align:right"><?php echo number_format($details_row['reciveqty'],2);
            $receiveqty[]=$details_row['reciveqty']; ?></td>
            <td class="f11 wdt4" style="text-align:right"><?php 
                  //echo  $s->GetFieldValue('product_grade',"id='".$details_row['uom']."'",'grade');
                   echo $s->GetFieldValue('unitsofmeasure',"unitid='".$details_row['uom']."'",'unitname') ; ?></td>
            <td class="f11 wdt5" style="text-align:right"><?php echo number_format((float)$details_row['stock_qty2'],2);
                         $stock_qty2[]=$details_row['stock_qty2']; ?></td>           
            <td class="f11"><?php 
        // $unitname1 = $s->GetFieldValue('item_master',"id='".$details_row['itemid']."'",'mst_unitid');
        //echo $unitname = $s->GetFieldValue('unitsofmeasure',"unitid='".$unitname1."'",'unitname') ;
            echo $s->GetFieldValue('unitsofmeasure',"unitid='".$details_row['uom1']."'",'unitname') ; ?></td>
            <td class="f11 wdt5" style="text-align:right"><?php echo number_format((float)$pendingqty[$i],2)  ?></td>
          </tr>
          <?php } }?>       
   </table>
 </td>
    </tr>
    <?php } if($numrow1>0) { ?>
    <tr>
      <td><strong></strong></td>
      <td>&nbsp;</td>
       <td>&nbsp;</td>
       <td><strong>&nbsp;</strong></td>
       <td><strong></strong></td>
       <td colspan="6" style="padding:0px;" class="f11" valign="top">
        <table width="100%" border="0" cellpadding="3" cellspacing="0">
        <tr>
        <td class="wdt1">&nbsp;</td>
        <td class="wdt2">&nbsp;</td>
       <td class="f12 wdt1" style="text-align:right;">Total</td>
       <td class="f12 wdt1" style="text-align:right"><?php echo number_format(array_sum($issueqty),2); ?></td>
       <td class="f12 wdt5" style="text-align:right"><?php echo number_format(array_sum($receiveqty),2); ?></td>
        <td class="wdt4">&nbsp;</td>
        <td class="wdt5">&nbsp;</td>
        <td>&nbsp;</td>
        <td class="wdt5">&nbsp;</td>
    </tr>
      <?php } else { ?>
     <tr bgcolor="#e7e7e7" style="height: 25px">
      <td class="jjrs_tabledata1" colspan="12" align="center"><strong>No Records</strong></td>
    </tr>
    
      <?php } ?>     
    
  </table>

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