<?php
ob_start();
$PageSecurity = 1;
include('config.php');
include('includes/ConnectDB.inc');
include('includes/function_lib.php');
include('includes/LanguageSetup.php');
include('includes/DateFunctions.inc');
function convertDate($Dt)
{
	$dateBRK=explode('-',$Dt);
	$newFormat=$dateBRK[2]."/".$dateBRK[1]."/".$dateBRK[0];
	return $newFormat;
}
$req_sql=DB_query("Select * from materialrequisitions where requisitionno='".$_REQUEST['RequisitionNo']."'",$db);
$req_row=DB_fetch_array($req_sql);
$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(); 


  $site_sql=DB_query("Select * from locations where loccode='".$req_row['sitecode']."'",$db);
  $site_row=DB_fetch_array($site_sql);
?>

<!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>Purchase Requisition</title>

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

@media print{
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: 24px;
  font-weight:normal;
  font-family:Arial, Helvetica, sans-serif !important;
  text-transform: uppercase;
  /*color:#006699; */ 
}
h2{
  font-size: 18px; line-height: 22px;
  font-weight:normal;
  font-family:Arial, Helvetica, sans-serif !important;
}
.wrapper{width:100%; 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;
}
 .div_first .left
        {
          width:16%; text-align:left; height:auto; vertical-align:middle; height:auto; padding: 10px; position: absolute; left: 0; top: 0;
        }
        .div_first .middle
        {
          width:68%; text-align:center; padding: 10px; margin:0 auto; position: relative;
        }
        .div_first .right
        {
          width:16%;text-align:right; padding: 10px; position: absolute; right: 0; top: 0;
        }
.div_first .full{text-align: center; border: 0;}
.div_second, .div_third{
  width: 100%;
  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, .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:16px; line-height: 22px; font-weight: bold;}
.mt26{margin-top:14px; width:96%;}
.mt27{margin-top:4px; width:56%;}
.border_top{border-top:#000 1px solid;}
.border_bottom{border-bottom:#000 1px solid;}
}

@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;
  /*color:#006699;*/  
  text-transform: uppercase;
}
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: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:16px; line-height: 22px; font-weight: bold;}
.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;}
}
</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>Purchase Requisition</h2>
        </div>
      </div>
      <div class="right"><img src="images/rusa-logo.jpeg" vspace="10" class="mt27" /></div>
</div>-->

    <div class="div_first">
        <?php echo $s->print_header(); ?>
        <h3 style="text-transform:uppercase;text-align:center;padding:5px;">Purchase Requisition</h3>
    </div>

<div class="div_second">
<table width="100%" border="0" cellspacing="0" cellpadding="3" >
        <tr >
	        <td width="15%" class="f12">Branch</td>
	        <td class="f11" width="18%"><?php 
          $cat = array("PPC"=>"Material","NonPPC"=>"Asset","Service"=>"Service");
			
			echo $site_row['locationname']; ?>
			</td>
	        <td width="15%" class="f12">Requisition Number</td>
	        <td width="18%" class="f11"><?php echo $req_row['Reqno'];?></td>
	        <td width="15%" class="f12">Requisition By</td>
	        <td class="f11"><?php echo $s->GetFieldValue('empmaster',"id='".$req_row['requition_by']."'",'emp_name');?></td>
        </tr>
        <tr>         
          <td class="f12">Requisition Date</td>
          <td class="f11"><?php echo convertDate($req_row['prdate'])?></td>      
          <td class="f12">Category</td>
          <td class="f11"><?php if($req_row['category']!=''){ echo $cat[$req_row['category']];};?></td>
          <td class="f12">Remarks</td>
          <td class="f11"><?php echo $req_row['comments'];?></td>
        </tr>
      </table>
</div>
<div class="div_third">
 <table width="100%" border="0" cellspacing="0" cellpadding="3">
        <tr>
          <th width="15%" class="f12">Item Code</th>
          <th class="f12">Item Name</th>
		  <th width="8%" class="f12">Unit</th>
		  <th width="10%" class="f12">Current Stock</th>
		  <th width="10%" class="f12">Requisition Qty</th>
		  <th width="8%" class="f12">Material Required Date</th>
		  <!--<th class="tabledata"><strong>Make</strong></th>
		   <th class="tabledata"><strong>Color</strong></th>
		   <th class="tabledata"><strong>Grade</strong></th>
          <th class="tabledata"><strong>Size</strong></th>-->        
		  <th width="20%" class="f12">Remarks</th>
        </tr>
        <?php 
	$get_sql="Select * from requisitionorderdetails where requsitionno='".$_REQUEST['RequisitionNo']."'";
	$get_result=DB_query($get_sql,$db);
	$i=0;
	while($get_row=DB_fetch_array($get_result))
	{	
		$item_sql="Select * from item_master where id='".$get_row['mst_itemid']."'";
		$item_result=DB_query($item_sql,$db);
		$item_row=DB_fetch_array($item_result);
?>
        <tr>
         <td class="f11"><?php echo $item_row['StockID'];?> </td>
         <td class="f11"><?php echo $item_row['item_name'];?></td>
         <td class="f11"><?php echo $unitname=$s->getField('unitsofmeasure','unitid',$get_row['uom'],'unitname');?>  </td>
		 <td class="f11"><?php echo $get_row['stock_qty'];?></td>
		 <td class="f11"><?php echo $get_row['requisition_qty'];?></td>
		 <td class="f11"><?php echo convertDate($get_row['material_required_by']);?></td>
		 <?php /*?><td><?php echo $get_row['make']; ?>   </td>
		  <td><?php echo $get_row['color']; ?>   </td>
		   <td><?php echo $get_row['grade']; ?>   </td>
		    <td><?php echo $get_row['size']; ?>   </td><?php */?>
          <td class="f11"><?php echo $get_row['Remarks'];?></td>
        </tr>
        <?php $i++; }?>
      </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>