	<?php
session_name('CAKEPHP'); @session_start();
ob_start();
$PageSecurity = 1;
include('config.php');
include('includes/ConnectDB.inc');
include('includes/function_lib.php');
include('includes/LanguageSetup.php');
include('includes/DateFunctions.inc');
?>

<!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' />
<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"> 
@print {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; border-top:#000000 1px solid;}
.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; 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{border-top:0;}
.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:#000 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: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: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; 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: 32px;
  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:10%;}
.wdt2{width:180px;}
.wdt3{width: 66px;}
.wdt4{width: 120px;}
.wdt5{width: 52px;}
.wdt6{width: 70px;}
}
</style>

<title>PR V/S PO Balance Qty Report</title>

</head>
<body>
<div id="foo">
  <p style="text-align:right;"><a href="#" onclick="javascript:toggle_visibility('foo');"><input type="button" value="Print" class="search" /></a></p>
</div>
<div class="wrapper">
<form name="" id="" method="POST" action="">
	<!-- Start Header -->
 

<?php 
   $sql1 = "SELECT * FROM companies where CompanyId='".$_SESSION['ACGCompanyId']."'";
  $sqlres = DB_query($sql1,$db);
  $companyRow = DB_fetch_array($sqlres);

  $arr=array(1=>"Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec");
  
// order Details

  $companylogo=$companyRow['CompanyLogo'];
  $SQLIno=DB_query("select * from locations where CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
$InoRow=DB_fetch_array($SQLIno);
$Compamies=DB_query("select * from companies",$db);
$CompamiesRow=DB_fetch_array($Compamies);

?>
  
  <!-- <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>PR V/S PO Balance Qty Report</h2>
      </div>
      <div class="right"></div>    
  </div> -->
  <div class="div_first">
        <?php echo $s->print_header(); ?>
        <h3 style="text-transform:uppercase;text-align:center;padding:5px;">PR V/S PO Balance Qty Report</h3>
    </div>

 <div class="div_second">
<table width="100%" border="0" cellspacing="0" cellpadding="3" style="border-collapse:collapse;">
<thead>
  <tr>
    <th width="3%" class="f12">S. No.</th>  
	  <th width="5%" class="f12">Date</th>
    <th width="11%" class="f12">Branch</th>     
	  <th width="12%" class="f12">Req. No.</th>
    <!--<th width="10%">PR No. </th><th width="10%">PR Date </th>-->
     <th width="110" class="f12">Item Code</th>
     <th class="f12">Item Name</th>
     <th width="70" class="f12">Unit</th>
     <th width="70" class="f12">PR Qty.</th> 
     <th width="70" class="f12">PO Qty.</th>
  </tr>
</thead>
 <?php
   $poreport=$_SESSION['poreport1'];
$i=1;
	 $res = DB_query($poreport,$db);
  	 while($row = DB_fetch_array($res))
	 {
	  if($row['APPREQ']!='') 
	 { 
	 
	 ?>
      <tr>
<td class="f11"><?php echo $i++;?></td>
<td class="f11"><?php  echo ConvertSQLDate($row['prdate']);?></td>
<td class="f11" >
	<?php echo $s->getField('locations','loccode',$row['sitecode'],'locationname');
	?> </td>
 <?php  //echo $row['APPREQ'];
 // $getpodata="select orddate,orderno from purchorders where mst_reqino='".$row['requisitionno']."' and  FIND_IN_SET('".$row['mst_itemid']."',mst_vendor_pid);";
 //$result = DB_query($getpodata,$db);
   //$PODATA = DB_fetch_array($result);

?> 
<td class="f11"><?php  echo $row['Reqno'];?></td>
<!--<td><?php  echo $PODATA['orderno'];?></td>
<td><?php  echo ConvertSQLDate($PODATA['orddate']);?></td>	-->				
<td colspan="5" style="padding:0px;" valign="top">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
 <?php 
 
    if($_SESSION['ItemList']!=000)
     $details_sql="Select * from requisitionorderdetails where requsitionno='".$row['requsitionno']."' and mst_itemid='".$_SESSION['ItemList']."'";
	else
	  $details_sql="Select * from requisitionorderdetails where requsitionno='".$row['requsitionno']."'";
	$_SESSION['details_sql']=$details_sql;
	$details_res=DB_query($details_sql,$db);
	$issueqty[]='';
	$req_qty[]='';

	$numrow1=DB_num_rows($details_res);
	if(DB_num_rows($details_res)>0){
		$apqty='';
	while($details_row=DB_fetch_array($details_res)){
    $quotation_id=$s->getField('venderquotations','indent_prno',$row['requisitionno'],'id');

	 $poqty1=DB_query("SELECT purchorderdetails.Quantity AS qty FROM purchorderdetails INNER JOIN purchorders
 ON purchorderdetails.parantId=purchorders.id WHERE 
   purchorderdetails.mst_itemid='".$details_row['mst_itemid']."' and quotationId='".$quotation_id."' ",$db);
	$poqty2=DB_fetch_array($poqty1);
	 if($details_row['App_quantity']!='0.00') 
	 { 
	?>
          <tr>
            <td width="110" class="f11"><?php echo $s->getField('item_master','id',$details_row['mst_itemid'],'StockID'); ?></td>
            <td class="f11"><?php echo $s->getField('item_master','id',$details_row['mst_itemid'],'item_name'); ?></td>
            <td class="f11" width="70"><?php $unitname1 = $s->GetFieldValue('item_master',"id='".$details_row['mst_itemid']."'",'mst_unitid');
			               echo $unitname = $s->GetFieldValue('unitsofmeasure',"unitid='".$unitname1."'",'unitname') ; ?></td>
             <td width="71" class="f11" style="text-align:right;"><?php echo $details_row['App_quantity'];
			               $apqty[]=$details_row['App_quantity']; ?></td>
      		 <td width="70" class="f11" style="text-align:right;"><?php echo $poqty2['qty']; ?></td> 
          </tr>
        <?php } }
        if(!empty($apqty)){?>
          <tr>
        <td colspan="3" style="text-align:right;"><strong class="f12">Total</td>
     <td style="text-align:right;"><span class="f12"><?php echo $a[]=array_sum($apqty); ?></span></td>
     <td></td>
  
        </tr><?php } ?>
          <?php }  ?>
        </table></td>

  </tr>
  
  
  <?php }  }?>
 <?php if($numrow1>0) { ?>
    <!--<tr bgcolor="#e7e7e7" style="height: 25px">
      <td class="jjrs_tabledata1"></td>
      <?php if($_REQUEST['site']=='') { ?> <td class="jjrs_tabledata1">&nbsp;</td><?php } ?>
       <td class="jjrs_tabledata1">&nbsp;</td>
       <td class="jjrs_tabledata1">&nbsp;</td>
	   <td class="jjrs_tabledata1">&nbsp;</td>
      <td class="jjrs_tabledata1"></td>
     <td width="20%" class="jjrs_tabledata1" style="padding-left:5px; padding-right:5px; white-space:nowrap;">Grand Total</td>
	          <td class="jjrs_tabledata1">&nbsp;</td>
			   <td  width="11%" class="jjrs_tabledata1"><?php echo array_sum($a);?></td>
      <td width="10%" class="jjrs_tabledata1"><?php //echo $b[]=array_sum($req_qty);?></td>
 
	  </tr> -->
      <?php } else { ?>
	   <tr>
       <td colspan="9" align="center">No Records</td>
       </tr>	  
      <?php } ?>   
</table>
	</form>

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