<style type="text/css">
.body_lightbox {
width:25%;
background-color:#e7e7e7;
position:fixed;
left:280px;
top:200px;
padding-left:5px;
padding-right:5px;
border:#666666 solid 3px;
height:250px;
overflow:auto;}
</style>
<?php
include('includes/stockcalculation.php');
$prefixtitle='Enquiry';

if(isset($_POST['Submit']) && $_REQUEST['action']=='Edit')
	{
	                    $sql =DB_query("update  dbl_enquiry_form SET
						`form_type`       ='".$_POST['formtype']."',
						`date`	          ='".FormatDateForSQL($_POST['enquiry_date'])."',  
						`customer`	      ='".$_POST['customer']."',  
						`dealer`	      ='".$_POST['dealer']."',
						`zone`	          ='".$_POST['zone']."',
						`subzone`	      ='".$_POST['subzone']."',
						`engineer`	      ='".$_POST['engname']."',
						`ref_no`	      ='".$_POST['ref_no']."',
						`ref_date`	 	  ='".FormatDateForSQL($_POST['ref_date'])."',
						`subject`	      ='".$_POST['subject']."',
						`remarks`	      ='".$_POST['ramarks']."',
						`term_and_condition`='".$_POST['term_and_condition']."',
						`validity`='".FormatDateForSQL($_POST['validity'])."',
						`payment_term`='".$_POST['payment_term']."',
						`basic_amt`='".$_POST['basic_amt']."',
						`discount`='".$_POST['discount']."',
						`discount_Amt`='".$_POST['discount_Amt']."',
						`discountAmt`='".$_POST['discountAmt']."',
						`EDBillRate`='".$_POST['EDBillRate']."',
						`totalDiscountedPrice`='".$_POST['totalDiscountedPrice']."',
						`VatCst`='".$_POST['VatCst']."',
						`VatCstValue`='".$_POST['VatCstValue']."',
						`surcharge`='".$_POST['surcharge']."',
						`surcharge_Amt`='".$_POST['surcharge_Amt']."',
						`ecess_per`='".$_POST['ECessPercentage']."',
	                    `sah_per`='".$_POST['SAHCessPercentage']."',
	                    `ecess_value`='".$_POST['ECessValue1']."',
	                    `sah_value`='".$_POST['SAHCessValue1']."',
						`totalexcise`='".$_POST['totalexcise']."',
						`additional_chrg`='".$_POST['additional_chrg']."',
						`grand_tatal`='".$_POST['grand_tatal']."',
						`company`	      ='".$_SESSION['ACGCompanyId']."'
						 where id='".$_REQUEST['id']."'",$db);
						 
	
	$deletebill=DB_query("delete from dbl_enquiry_details where parent_id='".$_REQUEST['id']."'",$db);
	for($CR=0;$CR<count($_REQUEST['itemname']);$CR++)
	{
	if($_REQUEST['itemname'][$CR]!='')
	{	
	$UOMID=$s->getField('unitsofmeasure','unitname',$_REQUEST['uom'][$CR],'unitid');
		
	$insert_contact="Insert into dbl_enquiry_details set
	parent_id='".$_REQUEST['id']."',  
	mst_itemid='".$_REQUEST['item_code'][$CR]."',  
	type ='".$_REQUEST['type'][$CR]."', 
	mst_unitid='".$UOMID."',
	lot_no='".$_REQUEST['lotno'][$CR]."',  
	req_qty='".$_REQUEST['qty'][$CR]."',
	pendingqty='".$_REQUEST['qty'][$CR]."',
	price='".$_REQUEST['price'][$CR]."',
	part_no='".$_REQUEST['itemcode'][$CR]."',
	part_name='".$_REQUEST['itemname'][$CR]."',	
	amount='".$_REQUEST['total'][$CR]."'";	
	$insert_res=DB_query($insert_contact,$db);			
	}	
	}
		
				
					
$s->pageLocation('index.php?route=DealerDistrbutions/Transaction/enquiry_index&modid='.$_REQUEST['modid'].'&frmid='.$_REQUEST['frmid'].'');
	}
	
	





if($_REQUEST['action']=='Edit')
{
$sql=DB_query("select * from dbl_enquiry_form where id='".$_REQUEST['id']."'",$db);
$row1=DB_fetch_array($sql);
extract($row1);
$function_filter[]=$dealer;
$function_filter[]='';
$function_filter[]=$date; 
$function_filter[]=$date; 
}

if($_REQUEST['act']=='delitem')
{
	$DelCond="id='".$_REQUEST['delid']."'";
	$s->DeleteRecord('dbl_enquiry_details',$DelCond);
	$s->pageLocation("index.php?route=DealerDistrbutions/Transaction/enquiry_form_Edit&action=Edit&id=".$_REQUEST['id']."".$rurl);
}


if($_REQUEST['act']=='delmanualitem')
{
	$DelmanualCond="id='".$_REQUEST['delmanuid']."'";
	$s->DeleteRecord('temp_item_master',$DelmanualCond);
	$s->pageLocation("index.php?route=DealerDistrbutions/Transaction/enquiry_form_Edit&action=Edit&id=".$_REQUEST['id']."".$rurl);
}

?>

<h2 align="center"><strong><?php echo $s->getField('companies','CompanyId',$_SESSION['ACGCompanyId'],'CompanyName'); ?>
</strong></h2>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<h1>Enquiry Form</h1>
<form name="form1" action="" method="post" >
<table width="100%" border="1" cellpadding="3" cellspacing="0">
<tr class="row1">
    <td class="tabledata1"><strong>Form Type<font color="#FF0000"><strong>*</strong></font></strong></th>
    <td>
<select name="formtype" id="formtype" style="width:150px;">
 <option value="Enquiry Forms"<?php if($form_type=='Enquiry Forms'){ ?> selected="selected" <?php } ?> ?>Enquiry Forms </option>
	 </select></td>
    <td class="tabledata1"><strong>Form No</strong><font color="#FF0000"><strong>*</strong></font></th>
    <td><input name="form_no" type="text" style="width:150px;" id="form_no" 
	value="<?php if(isset($form_no)) { echo $form_no; } else { echo "Auto Generated"; } ?>"  readonly="readonly"  /></td>
    <td class="tabledata1"><strong>Date</strong><font color="#FF0000"><strong>*</strong></font></th>
    <td><?php if($_REQUEST['action']=='Edit') { $c1=''; $c2="readonly"; } else { $c1='class="datepicker"'; $c2='';} ?>
	<input name="enquiry_date" type="text" style="width:150px;"   <?php echo $c1; ?>  <?php echo $c2; ?> id="enquiry_date"
	 value="<?php if($date!=''){echo ConvertSQLDate($date);}  else { echo ConvertSQLDate(date('Y-m-d')); } ?>" /></td>
</tr>

<tr class="row1"> 
<td class="tabledata1"><strong>Customer Name<font color="#FF0000"><strong>*</strong></font></strong></th>
    <td align="left" valign="top">
	<?php
	  if($_REQUEST['action']!='Edit')
 	  $dealer=$_SESSION['dealerid'];
	  else
	  $dealer=$s->GetFieldValue("dbl_dealer","id='".$dealer."'","id");   ?>
	<select name="customer" id="customer" style="width:150px;" onChange="showclientcode(this.value)">	
	<option value="0">--Select--</option>
	<option value="new">--New--</option>
	<?php 
	if($dealer=='')
	$sql=DB_query("select * from clientmaster where CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
	else
	$sql=DB_query("select * from clientmaster where CompanyId='".$_SESSION['ACGCompanyId']."' and dealer='".$dealer."'",$db);
	while($row1=DB_fetch_array($sql))
	{
	$c='';
	if($row1['id']==$customer)
	$c='selected';
	?>
	<option value="<?php echo $row1['id']; ?>"<?php echo $c; ?>><?php echo $row1['c_name']; ?></option> 
	<?php } ?>
	
	 </select></td>
    <td class="tabledata1"><strong>Customer Code</strong><font color="#FF0000"><strong>*</strong></font></th>
    <td><div id="customercode1"><input name="customer_code" id="customer_code" type="text" style="width:150px;" 
	value="<?php echo $s->getField('clientmaster','id',$customer,'client_code'); ?>" readonly="readonly"   /></div></td>
    <td class="tabledata1"><strong>Under Associate</strong> <font color="#FF0000"><strong>*</strong></font></th>
    <td><div id="dealerdata2">
	<input name="dealer1" type="text" id="dealer1" style="width:150px;" value="<?php echo $s->getField('dbl_dealer','id',$dealer,'dealer_name') ; ?>"  readonly="readonly" />
	<input type="hidden" name="dealer" id="dealer" value="<?php echo $dealer;?>" />
	</div>
	</td>
</tr>

<tr class="row1">
<td class="tabledata1"><strong> Area Name<font color="#FF0000"><strong>*</strong></font></strong></th>
<td align="left" valign="top"><div id="areadata"><input name="areaname" type="text" style="width:150px;" id="areaname"
value="<?php echo $s->getField('zone_master','id',$zone,'ZoneTitle'); ?>"  />
<input name='zone' type='hidden' style='width:100%' id='zone' value="<?php echo $zone; ?>"  />

</div></td>
<td class="tabledata1"><strong>Sub Area Name
  </th>
</strong>
<td><div id="subdata"><input name="subareaname" type="text" style="width:150px;" id="subareaname" 
value="<?php echo $s->getField('subzone_master','id',$subzone,'subzone'); ?>" />
<input name='subzone' type='hidden' style='width:100%' id='subzone' value="<?php echo $subzone; ?>" /></div></td>
<td class="tabledata1"><strong>Engineer Name</strong><font color="#FF0000"><strong>*</strong></font></th>
 <td><div id="engineerdata"><input name="engineer_name" id="engineer_name" type="text" style="width:150px;"  value="<?php echo $s->getField('dbl_engineer_dealer_maste','id',$engineer,'engineer_name'); ?>"  />
 <input name='engname' type='hidden' style='width:100%' id='engname' value="<?php echo $engineer; ?>"  />

 
 </div></td>
</tr>

<tr class="row1">
       <td class="tabledata1"><strong>Area Code<font color="#FF0000"><strong>*</strong></font></strong></th>
      <td align="left" valign="top" ><div id="areacodedata"><input name="areacode" id="areacode" type="text" style="width:150px;" value="<?php echo $s->getField('zone_master','id',$zone,'zonecode'); ?>" readonly="readonly" /></div></td>


    
    <td class="tabledata1"><strong>Sub Area Code
      </th>
    </strong>
    <td><div id="subareacodedata"><input name="subareacode" id="subareacode" type="text" style="width:150px;"  value="<?php echo $s->getField('subzone_master','id',$subzone,'subzonecode'); ?>" readonly="readonly" /></div></td>
    <td class="tabledata1"><strong>Engineer Code</strong><font color="#FF0000"><strong>*</strong></font></th>
    <td><div id="engineercodedata"><input name="engineer_code" id="engineer_code" type="text" style="width:150px;" value="<?php echo $s->getField('dbl_engineer_dealer_maste','id',$engineer,'engineer_code'); ?>"  /></div></td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>Ref No.</strong></td>
	<td><input type="text" name="ref_no" id="ref_no" value="<?php echo $ref_no; ?>" style="width:150px;" /></td>
	<td class="tabledata1"><strong>Ref Date</strong></td>
	<td colspan="3"><input type="text" name="ref_date" id="ref_date" value="<?php if(isset($ref_date)){echo ConvertSQLDate($ref_date);} ?>" class="datepicker" style="width:150px;" /></td>
</tr>

<tr class="row1">
    <td class="tabledata1"><strong>Subject</strong></th>
    <td colspan="5"><textarea name="subject" id="subject"  style="width:100%"><?php echo $subject; ?></textarea></td>
    </tr>
	<tr class="row1">
    <td class="tabledata1"><strong>Remark</strong></th>
    <td colspan="5"><textarea name="ramarks" id="remarks"  style="width:100%"><?php echo $remarks;?></textarea></td>
    </tr>
</table> 
	
<p align="left">
 <input type="button" class="search" value="Add Rows For Manual" onclick="addRowdata('dataTable')" />                     
<input type="button" class="search"  onclick="deleteRowOrder('dataTable')" value="Delete" />
<!--<input type="button" class="search" id="manualitemid"    value="Manual Part No" />-->
</p>

<div id="pickeditems" style="display:block;">
<table width="100%" border="1" cellpadding="3" cellspacing="0">
<tr class="row1">
<th width="5%"><strong>S. N.</strong></th>
<th width="3%"></th>
<th width="12%"><strong>Part Number </strong></th>
<th width="16%"><strong>Part Name</strong></th>
<th width="16%"><strong>Type(Exciable/Non Exciable) </strong></th>
<th width="9%"><strong> UOM</strong></th>
<th width="9%"><strong>Stock Qty </strong></th>
<th width="9%"><strong>Req Qty</strong></th>
<th width="6%"><strong>Price</strong></th>
<th width="6%"><strong>Amount</strong></th>
</tr>
<?php
$i=1;
$sql=DB_query("select * from dbl_enquiry_details where parent_id='".$_REQUEST['id']."'",$db);
while($row=DB_fetch_array($sql))
{
    if($row['mst_itemid']!=0)
	{
	$itemcode=$s->getField('item_master','id',$row['mst_itemid'],'StockID');
	$itemname=$s->getField('item_master','id',$row['mst_itemid'],'item_name');
	$unit1=$s->getField('item_master','id',$row['mst_itemid'],'mst_unitid');
	$unit=$s->getField('unitsofmeasure','unitid',$unit1,'unitname');
	}
	else
	{
	$itemcode=$row['part_no'];
	$itemname=$row['part_name'];
	 $unit=$s->getField('unitsofmeasure','unitid',$row['mst_unitid'],'unitname');
	}
	
	$op=openingBalance($function_filter,$row['mst_itemid']);
	$in_1=receivedMRN($function_filter,$row['mst_itemid']);
	$out_1=issueSlip($function_filter,$row['mst_itemid']);
	$out_2=issueSiteToSite($function_filter,$row['mst_itemid']);		
	$in_2=receivedSiteToSite($function_filter,$row['mst_itemid']);
	$out_3=issueMatarialReturn($function_filter,$row['mst_itemid']);
	$in_3=receivedReturn($function_filter,$row['mst_itemid']);	
	$out_4=Rgpchallan($function_filter,$row['mst_itemid']);
	$out_5=Nrgp($function_filter,$row['mst_itemid']);
	$in_4=Rgpreturn($function_filter,$row['mst_itemid']);	 
	$in_5=FinishedMR($function_filter,$row['mst_itemid']);
	$in_6=dispatchreturnsaleorder($function_filter,$row['mst_itemid']);
	$out_6=dispatchsaleorder($function_filter,$row['mst_itemid']);
	$invalue=($op+$in_1+$in_2+$in_3+$in_4+$in_5+$in_6);
	$outvalue=($out_1+$out_2+$out_3+$out_4+$out_5+$out_6);
	$tot=$invalue-$outvalue;
	$stockbalance=$tot;
?>
<tr id="hide_<?php echo $i; ?>">
	<td style="white-space:nowrap;" class="tabledata"><a href="index.php?route=DealerDistrbutions/Transaction/enquiry_form_Edit&action=Edit&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&act=delitem&delid=<?php echo $row['id'];?>&id=<?php echo $_REQUEST['id']; ?>"><img src="images/delete.gif" /></a></td>	
	<td class="tabledata"><input type="hidden" name="item_code[]" id="itemid_<?php echo $i; ?>" value="<?php echo $row['mst_itemid']; ?>" /></td>
	<td class="tabledata"><input type="text" name="itemcode[]"  id="itemcode_<?php echo $i; ?>" size="9" value="<?php echo $itemcode; ?>" readonly="readonly" /></td>
	<td class="tabledata" style="white-space:nowrap"><input type="text" name="itemname[]" value="<?php echo $itemname; ?>" id="itemname_<?php echo $i; ?>" readonly="readonly" /></td>
	<td class="tabledata"><input type="text" name="type[]" id="type1_<?php echo $i; ?>" value="<?php echo $row['type']; ?>" readonly="readonly" /></td>
	<td class="tabledata"><input type="text" name="uom[]"  id="uom_<?php echo $i; ?>" size="9" value="<?php echo $unit; ?>" readonly="readonly" /></td>
	<td class="tabledata"><input type="text" name="stock_price[]" value="<?php echo $stockbalance; ?>" id="stock_<?php echo $i; ?>" size="6" readonly="readonly" /></td>
	
	<td class="tabledata"><input type="text" name="qty[]" value="<?php echo $row['req_qty']; ?>" id="qty1_<?php echo $i; ?>" onKeyUp="calcValue21(this.value,this.id)" size="9" /></td>
	<td class="tabledata"><input type="text" name="price[]" id="price_<?php echo $i; ?>" readonly="" style="width:50px;"   value="<?php echo $row['price']; ?>"   /></td>
	<td class="tabledata"><input type="text" name="total[]" id="total_<?php echo $i; ?>" style="width:50px;" value="<?php echo $row['amount']; ?>"  readonly="true" /></td>
</tr>
<?php $i++; } ?>

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

<tbody id="dataTable">
	<tr class="row">
		<td class="tabledata"><input name="delitem[]" type="checkbox" value="" onclick="showdata(this.id)"  /></td>
		<td class="tabledata"><input type="hidden" name="item_code[]" id="itemid1" value=""  readonly="readonly" /></td>
		<td class="tabledata"><input type="text" name="itemcode[]"  id="itemcode1" size="9" value="" readonly="readonly" /></td>
		<td class="tabledata"><input type="text" name="itemname[]" id="itemname1" value="" readonly="readonly" /></td>
		<td class="tabledata"><input type="text" name="type[]" id="type2" value=""  onkeyup="showdata1(this.value,this.id)"  maxlength="1" readonly="readonly"  /></td>
		<td class="tabledata"><input type="text" name="uom[]" id="uom1"  size="9" value="" onkeyup="showdata2(this.value,this.id)" readonly="readonly" /></td>
		<td class="tabledata"><input type="text" name="stock_price[]" id="stock" size="6" value="" readonly="readonly" /></td>
		<td class="tabledata"><input type="text" name="qty[]" id="qty1" size="9" value="" onKeyUp="calcValue21(this.value,this.id)" /></td>
		<td class="tabledata"><input type="text" name="price[]" readonly="" id="price"  style="width:50px;" value=""  /></td>
		<td class="tabledata"><input type="text" name="total[]" id="total" style="width:50px;" value="" readonly="readonly" /></td>
	</tr>
</tbody>
</table>
</div>
  
<input type="hidden" name="hiditemcount" id="hiditemcount" value="" />
<br />
<table width="100%" border="1" cellpadding="3" cellspacing="0">
<tr class="row1">
	<td width="50%" valign="top">
		<table width="100%" border="0" cellpadding="3" cellspacing="0">
			<tr class="row1">
				<td class="tabledata1">Term & Conditions</td>
				<td><input type="text" name="term_and_condition" id="term_and_condition" value="<?php echo $term_and_condition; ?>" style="width:150px;" /></td>
			</tr>
			<tr class="row1">
				<td class="tabledata1">Validity</td>
				<td><input type="text" name="validity" id="validity" value="<?php echo ConvertSQLDate($validity); ?>" class="datepicker" style="width:150px;" /></td>
			</tr>
			<tr class="row1">
				<td class="tabledata1">Payment Terms</td>
				<td><select name="payment_term" id="payment_term" style="width:150px;">
						<option value="">Select</option>
						<?php $SQLP=DB_query("SELECT * FROM paymentterms",$db);
						while($Payment=DB_fetch_array($SQLP)) {
						$selA='';
						if($payment_term==$Payment['termsindicator'])
						$selA='selected';
						?>
						<option value="<?php echo $Payment['termsindicator']; ?>" <?php echo $selA; ?>><?php echo $Payment['terms']; ?></option>
						<?php } ?>
					</select>
				</td>
			</tr>
		</table>
	</td>
	<td width="50%" valign="top">
		<table width="100%" border="1" cellpadding="3" cellspacing="0">
			<tr class="row1">
				<td class="tabledata1">Basic Amount</td>
				<td><input type="text" name="basic_amt" id="basic_amt" value="<?php echo $basic_amt; ?>" onFocus="calculateBasicAmt()" style="width:150px;" readonly="readonly"/></td>
			</tr>
			<tr class="row1">
				<td class="tabledata1">Discount</td>
				<td><input type="text" name="discount" id="discount" value="<?php echo $discount; ?>" style="width:60px;" />
				<input type="text" name="discount_Amt" id="discountAmt" onfocus="caldiscountAmt()" value="<?php echo $discount_Amt; ?>" style="width:90px;" readonly="readonly" />
				</td>
			</tr>
			<tr class="row1">
				<td class="tabledata1">Discount Price </td>
				<td><input type="text" name="discountAmt" id="discount_Amt"  value="<?php echo $discountAmt; ?>" style="width:150px;" readonly="readonly" />
				</td>
			</tr>
			<tr class="row1">
				<td class="tabledata1">Excise Duty</td>
				<td><select name="EDBillRate" id="EDRate" style="width:150px" onChange="calculateBillExcise(this.value)"  >
						<option value="0">--Select--</option>
						<?php
						$ServiceSql="select * from  excise_tax WHERE caption LIKE '%excise%'" ;
						$ServiceRes=DB_query($ServiceSql,$db);
						while($ServiceRow=DB_fetch_array($ServiceRes))
						{
						$selA11='';
						if($EDBillRate==$ServiceRow['id'])
						$selA11='selected';
						?>
						<option value="<?php echo $ServiceRow['id'];?>" <?php echo $selA11; ?>><?php echo $ServiceRow['caption']?></option>
						<?php	
						}
						
						?>
						</select>
						<input name="totalDiscountedPrice" id="totalDiscountedPrice" type="text" value="<?php echo $totalDiscountedPrice; ?>"  style="width:90px;" onFocus="calculateTotalExcise()" readonly="readonly"/>
						</td>
			</tr>
			
			<?php 
			$cessSql=DB_query("Select caption from excise_tax where caption like '%cess%'",$db);
			$k=1;
			while($cessRow=DB_fetch_array($cessSql))
			{
			$caption[$k]=$cessRow['caption']; 
			
			$rate_sql=DB_query("Select def_rate from excise_tax where caption='".$caption[$k]."'",$db);
			while($rate_row=DB_fetch_array($rate_sql))
			{
			$rate[$k]=$rate_row['def_rate'];
			}
			$k++;
			} 
			?>
			<tr>
					<td class="tabledata1">E-Cess</td>
					<td><input name="ECessPercentage" id="ECessPercentage" type="text" value="<?php echo $rate[1];?>" style="width:60px;" readonly />
						<input name="ECessValue1" id="ECessValue" type="text" value="<?php echo $ecess_value?>" style="width:120px;"  onfocus="calculateECess1()" readonly="readonly" /></td>
					</tr>
			<tr >
					<td class="tabledata1">SAH-E Cess</td>
					<td><input name="SAHCessPercentage" id="SAHCessPercentage" type="text" value="<?php echo $rate[2];?>" style="width:60px;" />
						<input name="SAHCessValue1" id="SAHCessValue" type="text" value="<?php echo $sah_value;?>" style="width:120px;"  onfocus="calculateSAHCess1()" readonly="readonly" /></td>
					</tr>
			<tr>
				<td class="tabledata1">Total Excise Amout</td>
<td><input name="totalexcise" id="totalDiscountedamount" type="text" value="<?php echo $totalexcise; ?>" style="width:120px;"  onfocus="caltotalexciseamt()" readonly="readonly" /></td>
				
				</tr>	
			<tr class="row1">
				<td class="tabledata1">Sales Tax</td>
				<td><select name="VatCst" id="value3" onChange="calculateVATCST(this.value)" style="width:150px;">
						<option value="" >Select</option>
						<?php 
						$salesSql=DB_query("Select * from sales_tax_master",$db);
						while($salesRow=DB_fetch_array($salesSql))
						{?>
						<option value="<?php echo $salesRow['salestax_id'];?>" <?php echo $VatCst==$salesRow['salestax_id']?'selected':''?>><?php echo $salesRow['tax_code'];?></option>
						<?php 	
						}
						?>
						</select>
						<div id="VATId"><input name="VatCstValue" id="VatCstValue" type="text" value="<?php echo $VatCstValue?>" style="width:150px;"   onfocus="calculateEditVATCST()" readonly="readonly" /></div>
						<?php $rate=$s->getField('sales_tax_master','salestax_id',$VatCst,'taxrate'); ?>
						<input type="hidden" name="" id="rate" value="<?php echo $rate;?>" /> </td>
			</tr>
			<tr class="row1">
				<td class="tabledata1">SurCharges</td>
				<td><input type="text" name="surcharge" id="surcharge" value="<?php echo $surcharge; ?>" style="width:60px;" />
					<input type="text" name="surcharge_Amt" id="surcharge_Amt" value="<?php echo $surcharge_Amt; ?>" onFocus="calsurchrg()" style="width:90px;" readonly="readonly" />
				</td>
			</tr>
			<?php 
			$u=1;
			$sql_charge=DB_query("select * from dbl_enquiry_charge where parentid='".$_REQUEST['id']."'",$db);
			while($row12=DB_fetch_array($sql_charge))
			{
			?>
			<tr class="row1">
			<input type='hidden' name='chargeid[]' value='<?php echo $row12['charge_id']; ?>'>
		<td class="tabledata1"><?php echo $s->getField('dbl_dealer_charge_master','id',$row12['charge_id'],'charge_name'); ?></td>
				<td><input type="text" name="freight[]" id="freight_<?php echo $u; ?>" value="<?php echo $row12['charge_per']; ?>"  style="width:60px;" readonly="readonly"  />
					<input type="text" name="freight_Amt[]" id="freight_Amt_<?php echo  $u; ?>" value="<?php echo $row12['charge_amt']; ?>" style="width:90px;" onfocus="calfreight(<?php echo $u; ?>)"  readonly/>
				</td>
			</tr>
			<?php $u++; }?>
			<input type='hidden' id='charge_count' name='charge_count' value='<?php echo $u; ?>'>
			
			<tr class="row1">
				<td class="tabledata1"><strong>Grand Total</strong></td>
				<td><input type="text" name="grand_tatal" id="grand_tatal" value="<?php echo $grand_tatal; ?>" onFocus="calgrandTotal()" style="width:150px;" readonly="readonly" /></td>
			</tr>
		</table>
	</td>
</tr>
</table>


<p align="center">
  <input type="submit" name="Submit" class="search" onClick="return validate();" value="Save"  />
</p>

</form>


<div id="manualitems" style="display:none;">
<form method="post">
<table width="100%" border="1" cellpadding="3" cellspacing="0">
<tr class="row1">
<td class="tabledata1" width="5%"><strong>S. N.</strong></td>
<td width="12%"><strong>Part Number </strong></td>
<td width="16%"><strong>Part Name</strong></td>
<td width="16%"><strong>Type(Exciable/Non Exciable) </strong></td>
<td width="9%"><strong> UOM</strong></td>
<td width="9%"><strong>Stock Qty </strong></td>
<td width="9%"><strong>Lot No </strong></td>
<td width="9%"><strong>Req Qty</strong></td>
<td width="6%"><strong>Price</strong></td>
<td width="6%"><strong>Amount</strong></td>
</tr>
<?php for($k=0;$k<3;$k++) {?>
<tr class="row1">
	<td class="tabledata"><?php echo $k+1; ?></td>	
	<td class="tabledata"><input type="text" name="manual_item[]" id="manual_item_<?php echo $k; ?>" style="width:100px;"/></td>
	<td class="tabledata"><input type="text" name="manual_item_name[]" id="manual_item_name_<?php echo $k; ?>" style="width:100px;"  /></td>
	<td class="tabledata"><select name="exc_type[]" id="exc_type_<?php echo $k; ?>" style="width:100px;">
								<option value="">Select</option>
								<option value="exciable">Exciable</option>
								<option value="non exciable">Non Exciable</option>
							</select>
	</td>
	<td class="tabledata"><select name="manual_unit[]"  id="manual_unit_<?php echo $k; ?>" style="width:70px;">
							<option value="">Select</option>
							<?php $SQLUnit=DB_query("SELECT * FROM unitsofmeasure",$db);
							while($unitId1=DB_fetch_array($SQLUnit)){?>
							<option value="<?php echo $unitId1['unitid']; ?>"><?php echo $unitId1['unitname']; ?></option>
							<?php } ?>
						</select>
	</td>
	<td class="tabledata"><input type="text" name="manual_stock[]" id="manual_stock_<?php echo $k; ?>" style="width:70px;"/></td>
	<td class="tabledata"><input type="text" name="manual_lotno[]" id="manual_lotno_<?php echo $k; ?>" style="width:80px;"  /></td>
	<td class="tabledata"><input type="text" name="manual_qty[]" value="" id="manual_qty_<?php echo $k; ?>" style="width:80px;" /></td>
	<td class="tabledata"><input type="text" name="manual_price[]" id="manual_price_<?php echo $k; ?>" style="width:60px;" onkeyup="calcValue23(this.value,<?php echo $k; ?>)"   /></td>
	<td class="tabledata"><input type="text" name="manual_total[]" id="manual_total_<?php echo $k; ?>" style="width:60px;"  readonly="true" /></td>
</tr>
<?php } ?>

<input type="hidden" name="hiditemcount11" id="hiditemcount11" value="<?php echo $k; ?>" />
</table>
<br />
	<p align="center"><input type="submit" class="search" name="savemanual" value="Save" /></p>
</form>
</div>
<div class="body_lightbox" id="lightbox" style="overflow:auto; width:215px;  display:none;"></div>

<script>
function disabledivs()
{
	document.getElementById("manualitems").style.display='block';
	document.getElementById("pickeditems").style.display='none';
}

function showclientcode(str)
{
	if(str=='new')
	{
		window.open("index.php?route=DealerDistrbutions/Client_Master&modid=21&frmid=454","_self")
	return false;
	}
	if(str==0)
	{
		document.getElementById("areadata").innerHTML='';
		document.getElementById("subdata").innerHTML='';
		document.getElementById("engineerdata").innerHTML='';
		document.getElementById("areacodedata").innerHTML='';
		document.getElementById("subareacodedata").innerHTML='';
		document.getElementById("engineercodedata").innerHTML='';	
		document.getElementById("customercode1").innerHTML='';
		document.getElementById("dealerdata2").innerHTML='';
	}
	if(str!=0)
	{
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	if (xmlhttp.readyState==4 && xmlhttp.status==200)
	{
	var data=xmlhttp.responseText.split("__");;
		document.getElementById("areadata").innerHTML=data[0];
		document.getElementById("subdata").innerHTML=data[1];
		document.getElementById("engineerdata").innerHTML=data[2];
		document.getElementById("areacodedata").innerHTML=data[3];
		document.getElementById("subareacodedata").innerHTML=data[4];
		document.getElementById("engineercodedata").innerHTML=data[5];	
		document.getElementById("customercode1").innerHTML=data[6];
		document.getElementById("dealerdata2").innerHTML=data[7];
	}
	}
	xmlhttp.open("GET","dbl_customerdata.php?str1="+str,true);
	xmlhttp.send();
	}
}



function open_items()
{
	document.getElementById("manualitems").style.display='none';
	document.getElementById("pickeditems").style.display='block';
	var str=document.getElementById("dealer").value;
	window.open("Enquiry_itemsedit.php?site="+str+"&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'] ?>&action=<?php echo $_REQUEST['action']?>","itempopup_window","height=500,width=700,toolbar=no,menubar=no,dependent=yes,resizable =yes, scrollbars=yes");
}

function deleteRowOrder(tableID) 
{
		try 
		{
			var table = document.getElementById(tableID);
			//alert(table);
			var rowCount = table.rows.length;
			//alert(rowCount);
			for(var i=0; i<rowCount; i++) 
				{
					var row = table.rows[i];
					var chkbox = row.cells[0].childNodes[0];
					if(null != chkbox && true == chkbox.checked) 
					{
						if(rowCount <= 1) 
						{
							alert("Cannot delete all the rows.");
							break;
						}
					table.deleteRow(i);
					rowCount--;
					i--;
					}
					
				}
		document.getElementById("hiditemcount").value=parseInt(rowCount)-1;		
		}
		catch(e) 
		{
			alert(e);
		}

	}	


function calcValue2(str,id)
{
	var brk=id.split('_');
	if(brk[1]==undefined)
	{
		var qty=document.getElementById("qty").value;
		if(qty!=''){
		
		var tot=qty*str;
		document.getElementById("total").value=tot;}
	}
	else
	{
		var qty=document.getElementById("qty_"+brk[1]).value;
		if(qty!=''){
		
		var tot=qty*str;
		document.getElementById("total_"+brk[1]).value=tot;}
	}
}


function calcValue23(str,i)
{

		var qty1=document.getElementById("manual_qty_"+i).value;
		if(qty1!='')
		{
		var tot=qty1*str;
		document.getElementById("manual_total_"+i).value=tot;
		}
}



function calcValue21(str,str1)
{
	
	var n=str1.split("_");
	i=n[1];
	if(i==undefined)
	{
		var qtyfirst=document.getElementById("price").value;
		var firstrowtot=str*qtyfirst;
		document.getElementById("total").value=firstrowtot;
	}
	else
	{
	var qty=document.getElementById("price_"+i).value;
	if(qty!=''){
	var tot=qty*str;
	document.getElementById("total_"+i).value=tot;}
	}
}

function deactivate(str)
{
	document.getElementById("itemid1_"+str).value='';
	//document.getElementById("active_"+str).style.display='block';
	document.getElementById("deactive_"+str).style.display='none';
	document.getElementById("hide_"+str).style.display='none';
}


</script>
<script type="text/javascript" language="javascript">
/*function validate()
{
	if(document.getElementById("formtype").value=='0')
	{
		alert("Please Select The Form Type First");
		document.getElementById("formtype").focus();
		return false;
	}
	if(document.getElementById("enquiry_date").value=='')
	{
		alert("Please Fill The Date First");
		document.getElementById("enquiry_date").focus();
		return false;
	}
	if(document.getElementById("customer").value=='0')
	{
		alert("Please Select The Customer First");
		document.getElementById("customer").focus();
		return false;
	}
	if(document.getElementById("customer_code").value=='0')
	{
		alert("Please Fill The Customer Code First");
		document.getElementById("customer_code").focus();
		return false;
	}
	if(document.getElementById("dealer1").value=='')
	{
		alert("Please Fill The Under Dealer First");
		document.getElementById("dealer1").focus();
		return false;
	}
	if(document.getElementById("areaname").value=='')
	{
		alert("Please Fill The Area Name First");
		document.getElementById("areaname").focus();
		return false;
	}
	if(document.getElementById("engineer_name").value=='')
	{
		alert("Please Fill The Engineer Name First");
		document.getElementById("engineer_name").focus();
		return false;
	}
	if(document.getElementById("areacode").value=='')
	{
		alert("Please Fill The Area Code First");
		document.getElementById("areacode").focus();
		return false;
	}
	if(document.getElementById("engineer_code").value=='')
	{
		alert("Please Fill The Engineer Code First");
		document.getElementById("engineer_code").focus();
		return false;
	}
	
	
	if(document.getElementById("pickeditems").style.display=='block')
	{
		var count=document.getElementById("hiditemcount").value;
		
		if(count=='')
		{
			if(document.getElementById("itemid").value=='')
			{
				alert("Please Add Items First");
				var data=open_items();
				return false;
			}
			
			if(document.getElementById("qty").value=='')
			{
				alert("Please Fill Req Qty First");
				document.getElementById("qty").focus();
				return false;
			}
		}
		else
		{
			
			if(document.getElementById("itemid").value=='')
			{
				alert("Please Add Items First");
				var data=open_items();
				return false;
			}
			
			if(document.getElementById("qty").value=='')
			{
				alert("Please Fill Req Qty First");
				document.getElementById("qty").focus();
				return false;
			}
			for(var i=1;i<=count;i++)
			{
				if(document.getElementById("itemid_"+i).value=='')
				{
					alert("Please Add Items First");
					var data=open_items();
					return false;
				}
				if(document.getElementById("qty_"+i).value=='')
				{
					alert("Please Fill Req Qty First");
					document.getElementById("qty_"+i).focus();
					return false;
				}
			}
		}
	}
	
	
	
	if(document.getElementById("manualitems").style.display=='block')
	{
		var count12=document.getElementById("hiditemcount11").value;
		var chk=0;
		for(var j=0;j<count12;j++)
		{
			if(document.getElementById("itemid1_"+j).value!='' && document.getElementById("itemname1_"+j).value!='' && document.getElementById("qty1_"+j).value!='' && document.getElementById("price1_"+j).value!='')
			{
				chk=1;
				break;
			}
		}
		
		if(chk==0)
		{
			alert("Please Fill At leat One Row");
			return false;
		}
	}
}*/


function calculateBillExcise(str)
{
	var value=document.getElementById("discount_Amt").value;
	if(str.length==0)
	{
	document.getElementById("totalDiscountedPrice").innerHTML="";
	return;
	}
	if(window.XMLHttpRequest)
	{
	xmlhttp=new XMLHttpRequest();
	}
	else
	{
	xmlhttp	=new ActiveXobject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	if(xmlhttp.readyState==4 && xmlhttp.status==200)
	{
	document.getElementById("totalDiscountedPrice").value=xmlhttp.responseText;
	}
	}
	xmlhttp.open("GET","calculateExcise.php?type=bill&id="+str+"&value="+value,true);
	xmlhttp.send();	
}

function calculateTotalExcise()
{
	var EDRate=document.getElementById("EDRate").value;
	if(EDRate==0){
	var totalExcise=0;
	var first_row=document.getElementById("excisevalue").value;
	//if(first_row==''){first_row=0;}
	var cnt=document.getElementById("hiditemcount").value;
	var newcount=parseInt(cnt)+1;
	for(var i=1;i<newcount;i++)
	{
	var totalExcise1=document.getElementById("excisevalue_"+i).value;
	var totalExcise=(parseFloat(totalExcise)+parseFloat(totalExcise1)).toFixed(2);
	}
	document.getElementById("totalDiscountedPrice").value=parseFloat(totalExcise)+parseFloat(first_row);
	}
	else{return false;}
}


function calculateVATCST(str)
{
	
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	if (xmlhttp.readyState==4 && xmlhttp.status==200)
	{
	var data=xmlhttp.responseText.split("__");
	document.getElementById("rate").value=data[0];
	document.getElementById("VatCstValue").value=data[1];
	}
	}
	var amt1=document.getElementById("totalDiscountedamount").value;
	xmlhttp.open("GET","calculateExcise.php?salesIdamount="+str+"&amt="+amt1,true);
	xmlhttp.send();
}


function calculateEditVATCST()
{
	var rate=document.getElementById("rate").value;
	var taxableAmount=document.getElementById("totalDiscountedamount").value;
	var vat_cst=taxableAmount*(rate/100);
	document.getElementById("VatCstValue").value=vat_cst.toFixed(2);
}

function caldiscountAmt()
{
	var basic=parseFloat(document.getElementById("basic_amt").value);
	var discount;
	if(document.getElementById("discount").value=='')
	{
	discount=0;
	}
	else
	{
	 discount=parseFloat(document.getElementById("discount").value);
	}
	if(discount==0)
	{
	document.getElementById("discountAmt").value=0;
	document.getElementById("discount_Amt").value=basic.toFixed(2);
	}
	else
	{
	var disAmt=(basic*discount)/100;
	document.getElementById("discountAmt").value=disAmt.toFixed(2);
	var amt=basic-parseFloat(disAmt);
	document.getElementById("discount_Amt").value=amt.toFixed(2);
	}
}


function calsurchrg()
{
	var salamt=parseFloat(document.getElementById("VatCstValue").value);
	var surchrg;
	if(document.getElementById("surcharge").value=='')
	{
		surchrg=0;
	}
	else
	{
		surchrg=parseFloat(document.getElementById("surcharge").value);
	}
	if(surchrg==0)
	{
		document.getElementById("surcharge_Amt").value=0;
	}
	else
	{
		var suramt=(salamt*surchrg)/100;
		document.getElementById("surcharge_Amt").value=suramt.toFixed(2);
	}
}


function calgrandTotal()
{    
    var  Freight=0;
	//var basicamt=document.getElementById("basic_amt").value;
	var discAmt=document.getElementById("discount_Amt").value;
	var ExciseAmt=document.getElementById("totalDiscountedPrice").value;
	var vatAmt=document.getElementById("VatCstValue").value;
	var SurAmt=document.getElementById("surcharge_Amt").value;
	if(document.getElementById("charge_count"))
	{
	var count1=document.getElementById("charge_count").value;
	if(count1!='')
	{
	for(var i=1;i<count1;i++)
	{
	 Freight=parseFloat(Freight)+parseFloat(document.getElementById("freight_Amt_"+i).value);
	}
	}
	}
	else
	{
	Freight=0;
	}
	
	/*var PF=document.getElementById("p_and_f_Amt").value;
	var IncChrg=document.getElementById("Inc_chrg_Amt").value;*/
	//var AddChrg=document.getElementById("additional_chrg").value;
	var ecess=document.getElementById("ECessValue").value;
	var sahcess=document.getElementById("SAHCessValue").value;	
	//if(basicamt==''){basicamt=0;}
	if(discAmt==''){discAmt=0;}
	if(ExciseAmt==''){ExciseAmt=0;}
	if(vatAmt==''){vatAmt=0;}
	if(SurAmt==''){SurAmt=0;}
	if(Freight==''){Freight=0;}
	/*if(PF==''){PF=0;}
	if(IncChrg==''){IncChrg=0;}*/
	//if(AddChrg==''){AddChrg=0;}
	if(ecess==''){ecess=0;}
    if(sahcess==''){sahcess=0;}

/*	var Total=parseFloat(discAmt)+parseFloat(ExciseAmt)+parseFloat(vatAmt)+parseFloat(SurAmt)+parseFloat(Freight)+parseFloat(PF)+parseFloat(IncChrg)+parseFloat(AddChrg)+parseFloat(ecess)+parseFloat(sahcess);
	*/
		
	var Total=parseFloat(discAmt)+parseFloat(ExciseAmt)+parseFloat(vatAmt)+parseFloat(SurAmt)+parseFloat(Freight)+parseFloat(ecess)+parseFloat(sahcess);
	
	document.getElementById("grand_tatal").value=Total.toFixed(2);
}



/*function calgrandTotal()
{
	//var basicamt=document.getElementById("basic_amt").value;
	var discAmt=document.getElementById("discount_Amt").value;
	var ExciseAmt=document.getElementById("totalDiscountedamount").value;
	var vatAmt=document.getElementById("VatCstValue").value;
	var SurAmt=document.getElementById("surcharge_Amt").value;
	var Freight=document.getElementById("freight_Amt").value;
	var PF=document.getElementById("p_and_f_Amt").value;
	var IncChrg=document.getElementById("Inc_chrg_Amt").value;
	var AddChrg=document.getElementById("additional_chrg").value;
	//if(basicamt==''){basicamt=0;}
	if(discAmt==''){discAmt=0;}
	if(ExciseAmt==''){ExciseAmt=0;}
	if(vatAmt==''){vatAmt=0;}
	if(SurAmt==''){SurAmt=0;}
	if(Freight==''){Freight=0;}
	if(PF==''){PF=0;}
	if(IncChrg==''){IncChrg=0;}
	if(AddChrg==''){AddChrg=0;}
	var Total=parseFloat(discAmt)+parseFloat(ExciseAmt)+parseFloat(vatAmt)+parseFloat(SurAmt)+parseFloat(Freight)+parseFloat(PF)+parseFloat(IncChrg)+parseFloat(AddChrg);
	document.getElementById("grand_tatal").value=Total.toFixed(2);
}*/


function calculateBasicAmt()
{
	var count=document.getElementById("hiditemcount").value;
	if(count!='' && count!=0)
	{
		firstrow=parseFloat(document.getElementById("total").value);
		var totalprice=0;
		for(var i=1;i<count;i++)
		{
		if(document.getElementById("total_"+i))
		{ 
		if(document.getElementById("total_"+i).value!='')
		totalprice=parseFloat(totalprice)+parseFloat(document.getElementById("total_"+i).value);
		else
		totalprice=0;
		}
		else
		{
		continue;
		}
		}
		var amt=totalprice+firstrow;
		document.getElementById("basic_amt").value=amt.toFixed(2);
	}
	else
	{
		var totalprice=0;
		var editcount=document.getElementById("edit_cnt").value;
		for(var j=1;j<editcount;j++)
		{
		if(document.getElementById("total_"+j))
		{
		if(document.getElementById("total_"+j).value!='')
		totalprice=parseFloat(totalprice)+parseFloat(document.getElementById("total_"+j).value);
		else
		totalprice=0;
		}
		else
		{
		continue;
		}
		}
		var amt=totalprice;
		document.getElementById("basic_amt").value=amt.toFixed(2);
	}
}



function calfreight(i)
{
    if(document.getElementById("basic_amt").value!='')
	var basic=parseFloat(document.getElementById("basic_amt").value);
	else
	var basic=0;
	if(document.getElementById("freight_"+i).value!='')
	{
	var freihgt=parseFloat(document.getElementById("freight_"+i).value);
	}
	else
	{
	var freihgt=0;
	}
	var totalfr=(basic*freihgt)/100;

	
	document.getElementById("freight_Amt_"+i).value=totalfr;
	
}

/*function calfreight()
{
    if(document.getElementById("basic_amt").value!='')
	var basic=parseFloat(document.getElementById("basic_amt").value);
	else
	var basic=0;
	if(document.getElementById("freight").value!='')
	var freihgt=parseFloat(document.getElementById("freight").value);
	else
	var freihgt=0;
	var totalfr=(basic*freihgt)/100;
	document.getElementById("freight_Amt").value=totalfr;
	
}*/

function calpnf()
{
	if(document.getElementById("basic_amt").value!='')
	var basic=parseFloat(document.getElementById("basic_amt").value);
	else
	var basic=0;
	if(document.getElementById("p_and_f").value!='')
	var pnf=parseFloat(document.getElementById("p_and_f").value);
	else
	var pnf=0;
	var totalfr=(basic*pnf)/100;
	document.getElementById("p_and_f_Amt").value=totalfr;
}

function calincchrg()
{
	if(document.getElementById("basic_amt").value!='')
	var basic=parseFloat(document.getElementById("basic_amt").value);
	else
	var basic=0;
	if(document.getElementById("Inc_chrg").value!='')
	var pnf=parseFloat(document.getElementById("Inc_chrg").value);
	else 
	var pnf=0;
	var totalfr=(basic*pnf)/100;
	document.getElementById("Inc_chrg_Amt").value=totalfr;
}

$.noConflict();	
	$(document).ready(function(){	
		$("#manualitemid").click(function(){
		var overlay = $("#setover");
baseBackground = overlay.css("background");
baseOpacity = overlay.css("opacity");
overlay.css("background", "#000").css("opacity", "1");
			$("#manualitems").dialog({
				height:320,
				width: 900,
				resizable: false,
				buttons: {
					Exit: function()
					{
						$(this).dialog("close");
						$("#setover").css("background", baseBackground).css("opacity", baseOpacity);
					}
				}
			});
			
		});
		
		var cnt=document.getElementById("cntyear").value;
		for(var i=0; i<cnt; i++){
		$("#open_edit_"+i).click(function(){
			$("#div_id").dialog({
				height: 200,
				width: 350,
				resizable: false,
				buttons: {
					Exit: function()
					{
						$(this).dialog("close");
					}
				}
			});
		});
		}
	});






function calculateECess1()
{
	var exciseValue=document.getElementById("totalDiscountedPrice").value;
	var ECessPercentage=document.getElementById("ECessPercentage").value;
	var total=exciseValue*(ECessPercentage/100);
	document.getElementById("ECessValue").value=total.toFixed(2);
}



function calculateSAHCess1()
{
	var exciseValue=document.getElementById("totalDiscountedPrice").value;
	var SAHCessPercentage=document.getElementById("SAHCessPercentage").value;
	var total=exciseValue*(SAHCessPercentage/100);
	document.getElementById("SAHCessValue").value=total.toFixed(2);
}


function caltotalexciseamt()
{
	if(document.getElementById("totalDiscountedPrice").value!='')
	var exciseValue=document.getElementById("totalDiscountedPrice").value;
	else
	var exciseValue=0;
	if(document.getElementById("ECessValue").value!='')
	var ecessvalue=document.getElementById("ECessValue").value;
	else
	var ecessvalue=0;
	if(document.getElementById("SAHCessValue").value!='')
	var SAHCessValue=document.getElementById("SAHCessValue").value;
	else
	var SAHCessValue=0;
	var amt=parseFloat(exciseValue)+parseFloat(ecessvalue)+parseFloat(SAHCessValue);
	document.getElementById("totalDiscountedamount").value=amt.toFixed(2);
}

function showdata(i)
{
var id=i.split("_");
var i=id[1];
if(id[1]==undefined)
{
if(document.getElementById("itemid1").value=='')
{
document.getElementById("itemid1").readOnly=false;
document.getElementById("itemcode1").readOnly=false;
document.getElementById("itemname1").readOnly=false;
document.getElementById("type2").readOnly=false;
document.getElementById("uom1").readOnly=false;
}
else
{
return false;
}

}
else
{
if(document.getElementById("itemid1_"+i).value=='')
{
alert("hello");
document.getElementById("itemid1_"+i).readOnly=false;
document.getElementById("itemcode1_"+i).readOnly=false;
document.getElementById("itemname1_"+i).readOnly=false;
document.getElementById("type2_"+i).readOnly=false;
document.getElementById("uom1_"+i).readOnly=false;
}
else
{
return false;
}

}


}

function addRowdata(tableID) 
{

	
	var table =document.getElementById(tableID);
	var rowCount = table.rows.length;	
	var row = table.insertRow(rowCount);
	document.getElementById("hiditemcount").value=rowCount;
	var colCount = table.rows[0].cells.length;
	for(var i=0; i<colCount; i++) {	
	
	var newcell = row.insertCell(i);
	//newcell.style.background='#e7e7e7';
	newcell.className='tabledata';
	newcell.innerHTML = table.rows[0].cells[i].innerHTML;
	switch(newcell.childNodes[0].type) 
	{
	case "text":
	newcell.childNodes[0].value = "";
	var nod_id = newcell.childNodes[0].id;
	newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;
	break;
	case "hidden":
	newcell.childNodes[0].value = "";
	var nod_id_hidden = newcell.childNodes[0].id;
	newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;
	break;
	case "button":
	var nod_id = newcell.childNodes[0].id;
	newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;
	break;
	case "checkbox":
	newcell.childNodes[0].checked = false;
	var nod_id_chk = newcell.childNodes[0].id;
	newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;
	break;
	case "select-one":
	newcell.childNodes[0].selectedIndex = 0;
	var nod_id = newcell.childNodes[0].id;
	newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;
	break;	
	}
		//document.getElementById("stock_perunit_"+rowCount).value=1;
	}
	
}

function showdata1(str,i)
{

if(document.getElementById(i).readOnly==false)
{
var id=i.split("_");
var i=id[1];
if(id[1]==undefined)
{
if(str=='e' || str=='E')
{
document.getElementById("type2").maxlength='';
document.getElementById("type2").value='exciable';
}
else if(str=='n' || str=='N')
{
document.getElementById("type2").maxlength='';
document.getElementById("type2").value='non exciable';
}

}
else
{
if(str=='e' || str=='E')
{
document.getElementById("type2_"+i).maxlength='';
document.getElementById("type2_"+i).value='exciable';
}
else if(str=='n' || str=='N')
{
document.getElementById("type2_"+i).maxlength='';
document.getElementById("type2_"+i).value='non exciable';
}

}
}
}

function showdata2(str,str1)
{
if(document.getElementById(str1).readOnly==false)
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function()
  {
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("lightbox").style.display='block';	
document.getElementById("lightbox").innerHTML=xmlhttp.responseText;	
}
  }
   xmlhttp.open("GET","showpopupforuom.php?site="+str+"&data="+str1,true);
	xmlhttp.send();
}

}

function getItemsList1(id,code,ctr)
{ 
    var ctr1=ctr.split("_");
    var i=ctr1[1]
	  
	if(ctr1[1]==undefined)
	{
	document.getElementById('uom1').value = code;
	}
	else
	{
	document.getElementById("uom1_"+i).value=code;
	
	}	
	document.getElementById("lightbox").style.display='none';
		
}
function hidedata()
{
document.getElementById("lightbox").style.display='none';
}

</script>
