<?php session_name('CAKEPHP'); session_start();
$PageSecurity = 4;
include('includes/session.inc');
include('includes/function_lib.php');
global $db;
   echo   $getlead=DB_query( "select * from crm_accounts where mst_leadid='".$_REQUEST['q']."' and mst_accoutledgerid ='".$_REQUEST['accountid']."'",$db);
	 while($row_lead=DB_fetch_array($getlead))
	 {
		$leadcode=$row_lead['leadcode'];
		$company_name=$row_lead['company_name'];
 	    	$address1=$row_lead['address1'];
		$groupid=$row_lead['groupid'];
 		$city=$row_lead['city'];
		$zipcode=$row_lead['zipcode'];
		$country=$row_lead['country'];
		$Shipping_address=$row_lead['Shipping_address'];
 		$Shipping_zipcode=$row_lead['Shipping_zipcode'];
		$Shipping_city=$row_lead['Shipping_city'];
		$Shipping_country=$row_lead['Shipping_country'];
  	 }
?>





	<!--- table 2 --><table width="80%">	
	
   <tr>
   <td colspan="4"><h2 style="font-size:14px; color:#006699">Account  Billing  &  shipping  Address  Information:-</h2></td>
   </tr>
   
<tr>
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="2" align="center">
  <tr>
    <th width="25%" nowrap="nowrap" scope="row"><strong>Billing Address</strong></th>
    <td width="25%" nowrap="nowrap">
    <input type="text" name="address1" style="width:150px;"   value="<?php  echo $address1;?>"/></td>
    <th width="25%"><strong>Shipping Address</strong></th>
    <td width="25%" id="CODE"><input type="text" name="Shipping_address" style="width:150px;"   value="<?php  echo $Shipping_address;?>"/></td>
  </tr>
  <tr>
    <th scope="row"><strong>Billing city</strong></th>
    <td nowrap="nowrap"><input name="city" type="text"  style="width:150px;" value="<?php  echo $city?>"/></td>
    <th nowrap="nowrap">shipping City</th>
    <td nowrap="nowrap"><input name="Shipping_city" type="text"  style="width:150px;" value="<?php  echo $Shipping_city?>"/></td>
  </tr>
	
<tr>
    <th nowrap="nowrap"><strong>Billing Postal Code</strong></th>
    <td nowrap="nowrap">
    <input type="text" name="zipcode" style="width:150px;"  value="<?php  echo $zipcode?>" /></td>
    <th scope="row"><strong>Shipping Postal Code</strong></th>
    <td><input type="text" name="Shipping_zipcode" style="width:150px;"  value="<?php  echo $Shipping_zipcode?>" /></td>
    </tr>
	
	<tr>
    <th nowrap="nowrap"><strong>Billing Country</strong></th>
    <td nowrap="nowrap"><input name="country" type="text"  style="width:150px;" value="<?php  echo $country?>"/></td>
    <th scope="row"><strong>Shipping Country</strong></th>
    <td><input name="Shipping_country" type="text"  style="width:150px;" value="<?php  echo $Shipping_country?>"/></td>
    </tr>
</table>
</td>
</tr>

</table>


  
<table align="center" width="100%">
<tr><th style="text-align:center;" colspan="11">Item Details</th></tr>
<tr>
<th>Item Code</th>
<th>Item Name</th>
<th>Unit</th>
<th>Qty</th>
<th>Price</th>
<th>Per Unit(s)</th>
<th>Value</th>
<th>Discount Type</th>
<th>Discount</th>
 <th>Total</th>
</tr>
	<?php $total=0; $i=0;$after_discount=0;
//	echo "select * from quotation_details where parentId='".$_REQUEST['q']."'";
	$getitem=DB_query("select * from quotation_details where parentId='".$_REQUEST['q']."' ",$db); 
    while($row=DB_fetch_array($getitem))
 	{
  	 $itemquery=DB_query("select * from item_master where id='".$row['item_code']."'" , $db);
 	while($item_row=DB_fetch_array($itemquery))
	{
		if($i%2==0)
		{$bg="#CCCCCC";}
		else
		$bg="#C8BECB";
	
	?>
	<tr bgcolor="<?php echo $bg;?>">
  
    <td><?php echo $row['item_code'];?><input type="hidden" name="item_code[<?php echo $i;?>]" id="item_code_<?php echo $i;?>" value="<?php echo $row['item_code'];?>">	</td>
   <td><?php echo $item_row['item_name'];?><input type="hidden" name="item_name[<?php echo $i;?>]" id="item_name[<?php echo $i;?>]" value="<?php echo $item_row['item_name'];?>"/>	</td>
   <td><?php		$grade_query=DB_query("select * from unitsofmeasure where unitid='".$item_row['unit']."'", $db);
		while($grade_row=DB_fetch_array($grade_query))
		 {
		 echo $grade_row['unitname'];?>
		<?php } ?><input type="hidden" name="Unit[<?php echo $i;?>]" id="Unit[<?php echo $i;?>]" value="<?php $grade_row['id'];?>"/>			</td>
    <td><input type="text" name="stock_qty[<?php echo $i;?>]" id="stock_qty_<?php echo $i;?>" style="width:80px;"  value="<?php echo $row['stock_qty'];?>" readonly="true"/></td>
    <td><input type="text" name="stock_price[<?php echo $i;?>]" id="stock_price_<?php echo $i;?>" style="width:60px;" value="<?php echo $row['stock_price'];?>" readonly="true" /></td>
    <td><input type="text" name="stock_perunit[<?php echo $i;?>]" id="stock_perunit_<?php echo $i;?>" style="width:50px;" value="<?php echo $row['stock_perunit'];?>" readonly="true"/></td>
    <td><input type="text" name="stock_value[<?php echo $i;?>]" id="stock_value_<?php echo $i;?>" style="width:50px;" value="<?php echo $row['stock_value'];?>" readonly="true"/></td>
     
	 
	 <td><select   name="discountType[<?php echo $i;?>]" id="discountType_<?php echo $i;?>"  style="width: 98%">
         <option value="A">Amount</option>
         <option value="P">Percent</option>
       </select></td>

<td>
<?php  $total+=$row['total_stock'];
$after_discount+=$row['stock_value']-$row['total_stock'];
 ?>
<input type="text" name="total_stock[<?php echo $i;?>]" id="total_stock_<?php echo $i;?>" style="width:50px;" value="<?php echo $row['total_stock'];?>" /></td>
 
<td><input type="text" name="valueAfterDisc[<?php echo $i;?>]" id="valueAfterDisc_<?php echo $i;?>" value="<?php echo $row['stock_value']-$row['total_stock']?>" size="15"/></td>
   
</tr>

   
  
  <?php } 
    $i++;
  }?>
</table>
 
<input type="hidden" name="itemcount_totalamt" id="itemcount_totalamt" value="<?php echo $total;?>" />
<input type="hidden" name="itemcount_AfterDisc" id="itemcount_AfterDisc" value="<?php echo $after_discount;?>" />

<input type="hidden" name="hiditemcount" id="hiditemcount" value="<?php echo $i;?>" />

<br>
<br>

<script language="javascript">
function calculateECess(str)
{
 	var exciseValue=document.getElementById("basic"+str).value;
	var ECessPercentage=document.getElementById("rate_"+str).value;
	var total=exciseValue*(ECessPercentage/100);
	document.getElementById("caption_value_"+str).value=total.toFixed(2);
 }
</script>

	