<link href="css/tender_project.css" rel="stylesheet" type="text/css" />
<?php

session_name('CAKEPHP'); session_start();
error_reporting(FALSE);
$PageSecurity = 3;
	
include ('includes/session.inc');
include ('includes/function_lib.php');
include('includes/fun-php.php');
include('includes/fun-HRClass.php');
 ?>
<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['issuereport'];
	
?>
<?php 
//$mpdf=new mPDF();
//$mpdf->Bookmark('Start of the document');
$Compamies=DB_query("select * from companies",$db);
$CompamiesRow=DB_fetch_array($Compamies);

?>
<div style="width:auto; color:#006699; font-size:16px; font-weight:900; margin:5px; text-align:center;"><?php echo $CompamiesRow['CompanyName']?> <br />
  Site to Site Return/Rejection</div>
<div align="center"><strong><?php echo $_SESSION['mess']; ?></strong> </div>
  <p id="foo" align="right" style="padding-right:10px;"> <a href="#" id="fis" onClick="javascript:toggle_visibility('foo');" >Print</a> </p>

  <table width="100%" cellpadding="0" cellspacing="0" border="1" style="border:solid 1px #666666;">
    <tr style="background-color:#CCCCCC; height: 30px">
	  <td width="10px" class="jjrs_tablehead"><strong>S.No</strong></td>
      <td width="61" class="jjrs_tablehead"><strong>Date</strong></td>
      <td width="180" class="jjrs_tablehead"><strong>Issue Branch</strong></td>
      <?php if($_REQUEST['site']=='') { ?>
	  <td width="59" class="jjrs_tablehead"><strong>Branch</strong></td>
	  <?php } ?>
            <td width="168" class="jjrs_tablehead"><strong>Issued Store</strong></td>
      <td width="114" class="jjrs_tablehead" style="width:114px;"><strong>
        
        Item Name
       
        </strong></td>
      <td width="52" class="jjrs_tablehead" style="width:49px;"><strong>UOM</strong></td>
      <td width="82" class="jjrs_tablehead" style="width:76px;"><span class="jjrs_tablehead" style="width:76px;"><strong>Issue Qt </strong></span></td>
      <td width="82" class="jjrs_tablehead" style="width:76px;"><strong>Receive Qty </strong></td>
	    <td width="132" class="jjrs_tablehead"  style="width:77px;"><strong>Rejection Qty.</strong></td>
      <!-- <td width="97" class="jjrs_tablehead"  style="width:77px;"><strong>Total Price </strong></td>
	 <td width="102" class="jjrs_tablehead"  style="width:77px;"><strong>Amount</strong></td>
	 -->
    </tr>
    <?php 
 // $sql = "Select * from addissue";
  //zecho $sql;
  $sno=1;
  $result=DB_query($sql,$db);
  while($myrow=DB_fetch_array($result))
  {
  	
  ?>
    <tr bgcolor="#FFFFFF">
	<td style="width:50px;" class="jjrs_tablehead"><?php echo $sno; ?></td>
      <td  style="width:50px;" class="jjrs_tablehead"><?php echo ConvertSQLDate($myrow['date']);?></td>
      <td  style="width:120px;" class="jjrs_tablehead"><?php  
	  
	    echo $site = $s->GetFieldValue('locations',"loccode='".$myrow['issue_branch']."'",'locationname'); 
		
		?></td>
      <?php if($_REQUEST['site']=='') { ?>
	  <td  style="width:60px;" class="jjrs_tablehead"> <?php 
	   echo $site = $s->GetFieldValue('locations',"loccode='".$myrow['receive_branch']."'",'locationname'); 
	   } ?>
          <td  style="width:120px;" class="jjrs_tablehead"><?php 
	 echo $site = $s->GetFieldValue('storetype',"id='".$myrow['issue_stroe']."'",'StoreName'); ?></td><?php
		?>
          </td>
          <td colspan="9"><table width="100%" border="0" cellpadding="0" cellspacing="0" style="font-size:12px">
          <?php 
	   $details_sql="Select * from rejection_tbl_details where parentid='".$myrow['parentid']."'";
	$_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){
	while($details_row=DB_fetch_array($details_res)){?>
          <tr bgcolor="99CCCC">
            <td width="114" class="jjrs_tabledata1" style="width:109px;">
			<?php echo $s->getField('item_master','id',$details_row['itemid'],'item_name'); ?></td>
            <td width="82" class="jjrs_tabledata1" style="width:47px;"><?php 
			 $unitname1 = $s->GetFieldValue('item_master',"id='".$details_row['itemid']."'",'unit');
			echo $unitname = $s->GetFieldValue('unitsofmeasure',"unitid='".$unitname1."'",'unitname') ; ?> </td>
            <td width="96" class="jjrs_tabledata1"  style="width:70px;"><span class="jjrs_tabledata1" style="width:70px;"><?php echo $details_row['issue_qty'];
			$issueqty[]=$details_row['issue_qty'];
		?></span></td>
            <td width="97" class="jjrs_tabledata1"  style="width:73px;"><?php echo $details_row['receiveqty'];
				$req_qty[]=$details_row['receiveqty'];
				?></td>
				<td width="97" class="jjrs_tabledata1"  style="width:72px;"><?php echo $details_row['returnqty'];
				$rej_qty[]=$details_row['returnqty'];
				?></td>
            <!--<td width="93" class="jjrs_tabledata1"  style="width:70px;"><?php //echo $details_row['totalamount'];?></td>
		<td width="101" class="jjrs_tabledata1"  style="width:70px;"><?php //echo $details_row['itemdesc'];?></td>-->
          </tr>
          <?php } ?>
       
          <?php } ?>
        </table></td>
    </tr>
    <?php $sno++; } if($numrow1>0) { ?>
    <tr bgcolor="#e7e7e7" style="height: 25px">
      <td class="jjrs_tabledata1"><strong></strong></td>
      <?php if($_REQUEST['site']=='') { ?> <td class="jjrs_tabledata1">&nbsp;</td><?php } ?>
       <td class="jjrs_tabledata1">&nbsp;</td>
       <td class="jjrs_tabledata1"><strong>&nbsp;</strong></td>
      <td class="jjrs_tabledata1"><strong></strong></td>
      <td class="jjrs_tabledata1"><strong>Total</strong></td>
	  <td class="jjrs_tabledata1"><strong>&nbsp;</strong></td>
      <td class="jjrs_tabledata1"><?php echo $a[]=array_sum($issueqty)?></td>
      <td class="jjrs_tabledata1"><?php echo $b[]=array_sum($req_qty);?></td>
	  <td class="jjrs_tabledata1"><?php echo $c[]=array_sum($rej_qty);?></td>
	  </tr>
      <?php } else { ?>
	   <tr bgcolor="#e7e7e7" style="height: 25px">
       <td class="jjrs_tabledata1" colspan="8" align="center"><strong>No Records</strong></td>
       </tr>	  
      <?php } ?>     
    
  </table>
