<link href="css/purchses1.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 
   
	
?>
<?php 
//$mpdf=new mPDF();
//$mpdf->Bookmark('Start of the document');
$Compamies=DB_query("select * from companies",$db);
$CompamiesRow=DB_fetch_array($Compamies);
 $sql= $_SESSION['data1'];
?>
<div style="width:100%; color:#006699; font-size:16px; font-weight:900; padding:10px; text-align:center;"><?php echo $CompamiesRow['CompanyName']?> <br />
  Purchase Order Ammanendment Register</div>
<div align="center"><strong><?php echo $_SESSION['mess']; ?></strong> </div>

<br />
<br />
 <table width="1133px" cellpadding="0" cellspacing="0" border="1" style="border:solid 1px #666666; font-size:12px;">
     <tr>
    <th width="28">S.N. </th>
    <th width="40">Date</th>
    <th width="96">P. O. No.</th>
	<th width="92">Amd. P.O. No</th>
    <?php if($_REQUEST['vendor']=='') { ?>
	<th width="111">Vendor Name</th>  
	<?php } ?>
	 <?php if($_REQUEST['site']=='') { ?>
	 <th width="132">Branch Name</th>  
	 <?php } ?>
    <th width="149">V. Quote No.</th>	
	<th width="96">Item Name</th>
	<th width="56">Qty</th>
	<th width="73">Rate</th>
	<th width="136">Delivery Schedule</th>
	<th width="98">Status</th>
  </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><?php echo $sno;?></td>
	 <td><?php echo ConvertSQLDate($myrow['orddate']);?></td>
	  <td><?php echo $s->getField('purchorders','orderno',$myrow['against_po_id'],'PO_Orderno');  ?></td>
	   <td><?php echo $myrow['ammndmnt_no'];?></td>
	     <?php if($_REQUEST['vendor']=='') { ?><td><?php 
	  $vendorname=$s->getField('suppliers','id',$myrow['vendor_id'],'vendor_name');
	  echo $vendorname;?></td><?php } ?>
	  <?php if($_REQUEST['site']=='') { ?>
	  <td><?php 
	  $vendorname1=$s->getField('locations','loccode',$myrow['sitecode'],'locationname');
	  echo $vendorname1;?></td>
	  <?php } ?>
     
    <td><?php echo $vernder_quotation=$s->getField('venderquotations','id',$myrow['mst_vendor_quotesid'],'vernder_quotation');?></td>
	
   
	<td colspan="5"><table width="100%" border="0" cellpadding="0" cellspacing="0" style="font-size:12px;">
   <?php 
        if($_REQUEST['itemdata']=='') 
	    $details_sql="Select * from purchorderdetails_ammd where orderno='".$myrow['orderno']."'";
		else
		 $details_sql="Select * from purchorderdetails_ammd where orderno='".$myrow['orderno']."' and mst_itemid='".$_REQUEST['itemdata']."'";
	$_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="112" >
			<?php echo $s->getField('item_master','id',$details_row['mst_itemid'],'item_name'); ?></td>
            <td width="61" class="jjrs_tabledata1" ><?php $issueqty[]=$details_row['quatity'];
			 echo $details_row['quatity']; ?> </td>
            <td width="51"  class="jjrs_tabledata1"  ><span class="jjrs_tabledata1" style="width:70px;">
			<?php $req_qty[]=$details_row['rate'];
			echo $details_row['rate'];?></span></td>
			
            <td width="174"  class="jjrs_tabledata1"  ><?php echo $myrow['delivery_date'];
				//$req_qty[]=$details_row['returnqty'];
				?></td>
				<td width="60"  class="jjrs_tabledata1"  ><?php echo $details_row['status'];
				//$req_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['vendor']=='') { ?> <td class="jjrs_tabledata1">&nbsp;</td><?php } ?>
	 <?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">&nbsp;</td>
	   <td class="jjrs_tabledata1"><strong>Total</strong></td>
       <td class="jjrs_tabledata1"><strong>&nbsp;<?php echo $a[]=array_sum($issueqty)?></strong></td>
      <td class="jjrs_tabledata1"><strong>
        <?php echo $b[]=array_sum($req_qty);?>
      </strong></td>
      <td class="jjrs_tabledata1">&nbsp;</td>
      <td class="jjrs_tabledata1">&nbsp;</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>
<div id="foo">
  <p align="center"> <a href="#" id="fis" onClick="javascript:toggle_visibility('foo');" >Print</a> </p>
</div>
