<?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 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Quotation Ammendment Register</title>
<link href="css/purchses1.css" rel="stylesheet" type="text/css" />
<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>
</head>

<body>
<form name="" id="" method="POST" action="">
<div id="page" style="margin-left:auto; margin-right:auto;">
		
  <div id="form">
	<!-- Start Header --->
  	<div>
  <div style="50px; float:left; margin-left:30px;"><img src="images/logo_img.png" width="29" height="46" /></div>
<div style="width:auto; float:left; padding-left:60px; margin:0px;">
		<h3 style="padding-top:10"><img src="images/logo1.png" width="160" height="23" /></h3>
	  				<h3 style="border-width: 0 0 0 0px;">Quotation Ammendment Register</h3>
	
	</div>

	<div style="clear:both;"></div>


<div class="bordertop" style="border-collapse:collapse;">
	  
	<div style="width:auto; margin-left:auto; margin-right:auto;" >
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td style="width:100px; padding-top:5px;padding-bottom:5px; padding-left:5px;">Branch:</td>
    <td colspan="3"><?php 
	
	$Site_Query=DB_query("Select * from locations where loccode='".$_REQUEST['site']."'",$db);
	$Site_row = DB_fetch_array($Site_Query);
	if($_REQUEST['site']=='')
	{
	echo "Not Selected";}
	else
	{echo $Site_row['locationname'];}
	 ?></td>
  </tr>
  <tr>
    <th>Vendor:</th>
	 <td><?php
	  $Vendor_Query=DB_query("Select * from suppliers where id='".$_REQUEST['vendor_code']."'",$db);
	$Vendor_row = DB_fetch_array($Vendor_Query);
	if($_REQUEST['vendor_code']=='')
	{
	echo "Not Selected";}
	else
	{echo $Vendor_row['vendor_name'];}
	 ?>
       </td>
  </tr>
	<tr>
    <td style="width:100px; padding-top:5px;padding-bottom:5px; padding-left:5px;">From Date:</td>
    <td style="width:100px;">
	
	<?php if($_REQUEST['fromdate']=='' && $_REQUEST['todate']=='')
	{ echo "Not Selected"; }
	else
	{
	echo $_REQUEST['fromdate'];
	
	}
	
	?>
	</td>
	<td style="width:70px;">To Date:</td>
    <td><?php if($_REQUEST['fromdate']=='' && $_REQUEST['todate']=='')
	{ echo "Not Selected"; }
	else
	{
	echo $_REQUEST['fromdate'];
	
	}?></td>
	<td style="width:70px;">Item Code:</td>
	<th>Item Code</th>
	 <td><?php
	  $item_sql=DB_query("Select StockID from item_master where  StockID='".$_REQUEST['itemCode']."'",$db);
	$item_row=DB_fetch_array($item_sql);
	if($_REQUEST['itemCode']!='')
	{
	echo $item_row['StockID'];
	}
	else
	{
	echo "Not Selected";
	}
	
	 ?>
       </td>
	   <td>ITEM Name:</td>
    <td><?php 
	$sql_state=DB_query("SELECT item_name ,StockID FROM  item_master where id='".$_REQUEST['itemName']."'",$db);	
	$row=DB_fetch_array($sql_state);
	if($_REQUEST['itemName']!='')
	{
echo $row['item_name'];
	}
	else
	{
	echo "Not Selected";
	}
	
	?></td>
	</tr>
</table>

	</div><!-- Table 1 close -->
	
	

	<!-- Table 3 close -->			
		<div class="cl"></div>
	  </div>

<div>
<table width="100%" border="1" cellspacing="2" cellpadding="2">
  <tr>
    <td>S. No. </td>
	<td>Date</td>
    <td style="width:100px;">Ammendment No.</td>
	<td style="width:40px;">Revision No.</td>
	<td style="width:130px;">Vendor</td>
	<td style="width:120px;"d>Against Quatation No.</td>
	<td style="width:100px;"><strong>Item Name</strong></td>
	<td style="width:50px;"><strong>UOM</strong></td>
	<td style="width:45px;"><strong>Qty</strong></td>
	<td><strong>Actual Rate</strong></td>
	<td><strong>Ammend Rate</strong></td>
	<td><strong>Total Amt.</strong></td>
	
    </tr>
	<?php 
	
		$sql=$_SESSION['quat_reg1'];
		
		$result=DB_query($sql,$db);
		$i=1;
		
			while($myrow=DB_fetch_array($result))
			{
		?>
  <tr bgcolor="#FFFFFF">
    <td><?php echo $i;?></td>
	<td><?php echo ConvertSQLDate($myrow['quotation_date']);?></td>
	 <td><?php echo $myrow['vernder_quotation']; ; ?></td>
	 <td><?php echo $myrow['revision_no']; ?></td>
	  <td><?php echo $vender_name=$s->getField('suppliers','id',$myrow['mst_supplierno'],'vendor_name'); ?></td>
    <td><?php echo $quat_no=$s->getField('venderquotations','id',$myrow['old_quotetion_no'],'vernder_quotation'); ?></td>
	<td colspan="6">
	
	<table width="100%" border="0" cellspacing="2" cellpadding="2">
	<?php $details_sql="Select * from vendor_quotes_ammendment_details where vendor_quotes_ammendment_id=".$myrow['id']."";
		  $details_res=DB_query($details_sql,$db);
		  $tot_received='';
		  while($details_row=DB_fetch_array($details_res)){
	?>
    <tr bgcolor="#99CCCC" >
		<td style="width:97px;"><?php $sitename1=$s->getField('item_master','id',$details_row['item_id'],'item_name'); echo $sitename1; ?></td>
		<td style="width:50px;"><?php        
		  	$sitename1=$s->getField('item_master','id',$details_row['item_id'],'unit');
			$sitename2=$s->getField('unitsofmeasure','unitid',$sitename1,'unitname'); echo $sitename2;?>
		</td>
		<td style="width:50px;"><?php if($_REQUEST['site']!='0'){echo $details_row['sum(quantity)'];}
			if($_REQUEST['itemCode']!='0' || $_REQUEST['itemName']!='0'){echo $details_row['quantity'];}
			 //$tot_received[]=$details_row['quantity'];
			?>
		</td>
		<?php $details_sql1="Select rate from vendorquotationdetails where mst_productid=".$details_row['item_id']." and quotation_no=".$myrow['old_quotetion_no']."";
	$details_res1=DB_query($details_sql1,$db);
	$details_row1=DB_fetch_array($details_res1);
	?>
		<td style="width:75px;"><?php echo $details_row1['rate'];  ?></td>
		<td style="width:80px;"><?php echo $details_row['rate']; ?></td>
        <td style="text-align:right"><?php echo $tot_amt=($details_row['quantity']*$details_row['rate']); $tot_received[]=$tot_amt;?></td>
	</tr>
	<?php } ?>
	<tr bgcolor="#FFFFFF" style="height: 25px">
        <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"><span class="jjrs_tabledata1" style="white-space:nowrap;"><strong>Total</strong></span></td>
        <td class="jjrs_tabledata1" style="text-align:right"><?php echo $a[]=array_sum($tot_received);?></td>
        </tr>
  	</table></td>
  <?php $i++;}	?>
  </tr>
</table>
<?php if(!empty($a)) { ?>
<!--<table width="100%" cellpadding="0" cellspacing="0" border="0" style="border:solid 1px #666666;">
  <tr style="background-color:#CCCCCC; height: 30px">
	<td width="6%" class="jjrs_tabledata1" style="padding-left:5px; padding-right:5px; white-space:nowrap;">&nbsp;</td>
	<td width="6%" class="jjrs_tabledata1" style="padding-left:5px; padding-right:5px; white-space:nowrap;">&nbsp;</td>
	<td width="6%" class="jjrs_tabledata1" style="padding-left:5px; padding-right:5px; white-space:nowrap;">&nbsp;</td>
	<td width="20%" class="jjrs_tabledata1" style="padding-left:5px; padding-right:5px; white-space:nowrap;">&nbsp;</td>
	<td width="28%" class="jjrs_tabledata1" style="padding-left:5px; padding-right:5px; white-space:nowrap;">&nbsp;</td>
        <td width="15%" class="jjrs_tabledata1" style="padding-left:5px; padding-right:5px; white-space:nowrap;"><strong>Grand Total</strong></td>
        <td width="23%" class="jjrs_tabledata1" style="padding-left:5px; padding-right:5px; white-space:nowrap;"><span class="jjrs_tabledata1" style=" white-space:nowrap;"><?php  echo array_sum($a); ?></span></td>
        <td width="6%" class="jjrs_tabledata1" style="padding-left:5px; padding-right:5px; white-space:nowrap;">&nbsp;</td>
        <td width="6%" class="jjrs_tabledata1" style="padding-left:5px; padding-right:5px; white-space:nowrap;"><?php echo $a[]=array_sum($tot_received);?></td>
  </tr>
</table>-->
<?php } ?>
<div id="foo">
  <p align="center"> <a href="#" id="fis" onclick="javascript:toggle_visibility('foo');" >Print</a> </p>
</div>
</div>
	<div>


	</div>


	  </div><!-- end Header -->
	  
	
	<!-- Start T & C -->
	
		
  </div>
	
		</div> <!-- end of  T & C -->
</div>
</form>
</body>
</html>
