<link rel="stylesheet" href="css/new_mxerp.css">
<?php
$PageSecurity = 2;
$title = _('Job Work List');
include('includes/SQL_CommonFunctions.inc');
$_SESSION['modid']=$_REQUEST['modid'];
$_SESSION['frmid']=$_REQUEST['frmid'];
$frmpermission= $px->GetFileAccess($_SESSION['modid'],$_SESSION['frmid'],$_SESSION['ACGRoleId']);
$_SESSION['frmAdd']=$frmpermission[0];
$_SESSION['frmEdit']=$frmpermission[1];
$_SESSION['frmDelete']=$frmpermission[2];
$_SESSION['frmView']=$frmpermission[3];
if(isset($_POST['Update']))
{
	$qty1=$_REQUEST['qty'];
	$update1="update job_work set
							 site='".$_REQUEST['site']."', 
							 vendor='".$_REQUEST['vendor']."',   
							 remarks='".$_REQUEST['remarks']."',  
							 basicAmount='".$_REQUEST['basicAmount']."',  
							 STaxPerc='".$_REQUEST['STaxPerc']."',  
							 STaxValue='".$_REQUEST['STaxValue']."',  
							 SEduPerc='".$_REQUEST['SEduPerc']."',  
							 SEduValue='".$_REQUEST['SEduValue']."',  
							 SShePerc='".$_REQUEST['SShePerc']."',  
							 SSheValue='".$_REQUEST['SSheValue']."',  
							 TDSPerc='".$_REQUEST['TDSPerc']."',  
							 TDSValue='".$_REQUEST['TDSValue']."',  
							 freight='".$_REQUEST['freight']."',  
							 grandTotal='".$_REQUEST['grandTotal']."',  
							 created_by='".$_SESSION['UserID']."'  
							 where id='".$_REQUEST['Id']."'";
							 $query=DB_query($update1,$db);
for($str=0;$str<count($qty1);$str++)
		{
			 $insertSql2="Update job_work_details set quantity='".$_REQUEST['quantity'][$str]."' where id='".$_REQUEST['qty'][$str]."'";   
																		
			$insertResult2=DB_query($insertSql2,$db); 
		}
	
}


if($_REQUEST['Id']!='' && $_REQUEST['act']=='del')
{
	$delete1=DB_query("Delete from job_work where id='".$_REQUEST['Id']."'",$db);
	$delete2=DB_query("Delete from job_work_details where masterId='".$_REQUEST['Id']."'",$db);
	prnMsg( _('Record Deleted Successfully'),'success');
	echo "<script>location.href='index.php?route=Inventory/transation/JobWorkList&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
}
?>
<?php 
if($_REQUEST['Id']=='' && $_REQUEST['act']==''){
?>
<style type="text/css">

a{
color: #171717;
text-decoration: none;

}
a:hover{
color: #fff;

text-decoration: none;
}

#wrapper{
width:98%;
margin:auto;
}
.box{
background: #fff;

}
.boxholder{
clear: both;
padding: 5px;
border:#737373 5px solid;
padding-bottom:15px;

}
.tab{
float:left;
height:32px;
width:125px;
margin:0 1px 0 0;
text-align: center;
background:url(images/greentab.jpg) no-repeat;
}
.tabtxt{
margin: 0;
color: #fff;
font-size: 12px;
font-weight: bold;
padding: 9px 0 0 0;d

}
</style>
<script type="text/javascript" src="js/prototype.lite.js"></script>
<script type="text/javascript" src="js/moo.fx.js"></script>
<script type="text/javascript" src="js/moo.fx.pack.js"></script>
<script type="text/javascript">
function init(){
	var stretchers = document.getElementsByClassName('box');
	var toggles = document.getElementsByClassName('tab');
	var myAccordion = new fx.Accordion(
		toggles, stretchers, {opacity: false, height: true, duration: 600}
	);
	//hash functions
	var found = false;
	toggles.each(function(h3, i){
		var div = Element.find(h3, 'nextSibling');
			if (window.location.href.indexOf(h3.title) > 0) {
				myAccordion.showThisHideOpen(div);
				found = true;
			}
		});
		if (!found) myAccordion.showThisHideOpen(stretchers[0]);
}
</script>
<div class="body_contain">
<div class="tab_div">

<h1><strong><?php echo $s->GetFieldValue("modules_form","id='".$_REQUEST['frmid']."' and moduleid='".$_REQUEST['modid']."'","frm_name"); ?> </strong></h1>
<?php if($_SESSION['frmAdd']=='1'){?>
<p align='left'><a href="index.php?route=Inventory/transation/JobWork&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>"><input type="button" class="search" value="Direct Job Work Order" /></a>
<a href="index.php?route=Inventory/transation/job_work_service_index<?php echo $rurl; ?>"><input type="button" value="Process Job Work Order" class="search"></a>
</p><?php } ?>




<div class="box">

<table width="99%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px; margin-bottom:5px;" align="center">
  <tr>
  	<td class="tabledata2"><strong>Branch</strong></td>
    <td class="tabledata2"><strong>Job Work No. </strong></td>
    <td class="tabledata2"><strong>Vendor</strong></td>
    <td class="tabledata2"><strong>Party Job No.</strong> </td>
    <td class="tabledata2"><strong>Date</strong></td>
    <td class="tabledata2"><strong>View</strong></td>
    <td class="tabledata2"><strong>Edit</strong></td>
    <td class="tabledata2"><strong>Delete</strong></td>
  </tr>
  <?php

  $SQL=DB_query("Select * from job_work where CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
  while($Myrow=DB_fetch_array($SQL))
  {
  ?>
<tr bgcolor="#dedede">
<td><?php 
	$sitename=$s->getField('locations','loccode',$Myrow['site'],'locationname');
	echo $sitename;?></td>
    <td><?php echo $Myrow['jobNumber'];?></td>
    
    <td><?php 
	$vendorname=$s->getField('suppliers','id',$Myrow['vendor'],'vendor_name');
	echo $vendorname;?></td>
    <td><?php echo $Myrow['partyJWNo'];?></td>
    <td><?php echo ConvertSQLDate($Myrow['jobDate']);?></td>
    <td><?php if($_SESSION['frmView']=='1'){?><a href="index.php?route=Inventory/transation/JobWorkList&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&Id=<?php echo $Myrow['id'];?>&act=view"><img src="images/search.gif" height="15" width="15"></a><?php }else{echo "No Permission";} ?></td>
    <td><?php if($_SESSION['frmEdit']=='1'){?><a href="index.php?route=Inventory/transation/JobWorkList&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&Id=<?php echo $Myrow['id'];?>&act=Edit"><img src="images/icon-edit.png" height="15" width="15"></a><?php }else{echo "No Permission";} ?></td>
    <td><?php if($_SESSION['frmDelete']=='1'){?><a href="index.php?route=Inventory/transation/JobWorkList&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&Id=<?php echo $Myrow['id'];?>&act=del" onclick="return confirm('This record will be deleted. Are you sure?')"><img src="images/Icon_Delete.png" height="15" width="15"></a><?php }else{echo "No Permission";} ?></td>
  </tr>
  <?php } ?>
</table>


</div>


    


</div>


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

</div></div>
  <script type="text/javascript">
	Element.cleanWhitespace('content');
	init();
</script>
<?php }
if($_REQUEST['Id']!='' && $_REQUEST['act']=='view')
{
	
$sql=DB_query("Select * from job_work where id='".$_REQUEST['Id']."' and CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
$myrow=DB_fetch_array($sql);
?>

<div class="body_contain">
<div class="tab_div">
<h1>View Job Work Order</h1>

<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
  <tr>
    <td class="tabledata1">Branch</td>
    <?php $sitename=$s->getField('locations','loccode',$myrow['site'],'locationname'); ?>
    <td><input type="text" value="<?php echo $sitename;?>" style="width:100%" readonly="true" /></td>
    <td class="tabledata1">JOB WORK NO.</td>
	<td><input name="jobWorkNo" type="text" id="jobWorkNo" value="<?php echo $myrow['jobNumber']; ?>" style="width:46%" readonly="true"/></td>
  </tr>
  <tr>
    <td class="tabledata1">Vendor</td>
    <?php $vendorname=$s->getField('suppliers','id',$myrow['vendor'],'vendor_name'); ?>
    <td><input type="text" value="<?php echo $vendorname;?>" style="width:100%" readonly="true" />
    </td>
    <td class="tabledata1">Job Work Date </td>
    <td><input type="text" name="jobDate" id="jobDate" value="<?php echo ConvertSQLDate($myrow['jobDate']);?>" class="datepicker" readonly="true" style="width:100%" />    </td>
  </tr>
  <tr>
    
    <td class="tabledata1">Job Type</td>
   <td><select name="jobtype" id="jobtype" style="width:46%">
     <option value='0'>Select</option>
     <option value='S' <?php if($myrow['job_type']=='S') { ?> selected="selected" <?php } ?>>Service</option>
     <option value='J' <?php if($myrow['job_type']=='J') { ?> selected="selected" <?php } ?>>Job Work Process</option>
    </select>
    
   </td> 
    <td class="tabledata1">Party Job Work No. </td>
	<td><input type="text" name="partyJWNo" id="partyJWNo" value="<?php echo $myrow['partyJWNo'];?>" readonly="true" style="width:100%" /></td>
  </tr>
</table>

<br>
<div style="overflow:auto; width:1280px; height:auto"> 
<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
<tr>
<td class="tabledata">Item Code </td>
<td class="tabledata">Item Name </td>
<td class="tabledata">Item Description </td>
<td class="tabledata">Uom</td>
<td class="tabledata">Quantity</td>
<td class="tabledata">Rate</td>
<td class="tabledata">Total Amount </td>
<td class="tabledata">Flexo/Offset</td>

</tr>
<?php 
$sql2=DB_query("Select * from job_work_details where masterId='".$_REQUEST['Id']."'",$db);
while($myrow2=DB_fetch_array($sql2))
{
	$item_sql="Select * from item_master where id='".$myrow2['mst_itemId']."'";
	$item_result=DB_query($item_sql,$db);
	$item_row=DB_fetch_array($item_result);
?>
<tr bgcolor="#c1c1c1">
<td><?php echo $item_row['StockID'];?></td>
<td><?php echo $item_row['item_name'];?></td>
<td><?php echo $item_row['item_desc'];?></td>
<td><?php 
$unitname=$s->getField('unitsofmeasure','unitid',$item_row['mst_unitid'],'unitname');
echo $unitname;?></td>
<td><input type="text" name="quantity[<?php echo $k;?>]" id="quantity_<?php echo $k;?>" value="<?php echo $myrow2['quantity'];?>" size="15" readonly="true" /></td>
<td><input type="text" name="rate[<?php echo $k;?>]" id="rate_<?php echo $k;?>" value="<?php echo $myrow2['rate'];?>" size="15" readonly="true"/></td>
<td><input type="text" name="totalAmount[<?php echo $k;?>]" id="totalAmount_<?php echo $k;?>" value="<?php echo $myrow2['totalAmount'];?>" size="15" readonly="true"/></td>


<td><select name="process[]" id="process" style="width:100px" >
	<option value="0">Select</option>
	<?php 
	$floor_sql=DB_query("select * from job_work_master",$db);
	while($floor_row=DB_fetch_array($floor_sql))
	{
	if($myrow2['process']==$floor_row['id']) { $t='selected'; } else { $t=''; }
	?>
	<option value="<?php echo $floor_row['id'];?>" <?php echo $t; ?>><?php echo $floor_row['jobwork_name'];?></option>
	<?php 	
	}
	?>
    </select></td>
</tr>
<?php }?>

</table>
</div>

<table width="100%" cellpadding="2" cellspacing="2">
<tr>
<td width="70%" valign="top">
<table width="100%">
<tr>
<th>REMARKS</th>
<td><textarea name="remarks" id="remarks" style="width:100%" readonly><?php echo $myrow['remarks'];?></textarea></td>
</tr>
</table>
</td>
<td width="27%">
<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
  <tr>
    <th>BASIC AMOUNT </th>
    <td><input type="text" name="basicAmount" id="basicAmount" value="<?php echo $myrow['basicAmount'];?>" readonly="true" /></td>
  </tr>
  <tr>
    <th>SERVICE TAX </th>
    <td><input type="text" id="STaxPerc" name="STaxPerc" value="<?php echo $myrow['STaxPerc'];?>" size="3" readonly="true"/><input name="STaxValue" type="text" id="STaxValue" value="<?php echo $myrow['STaxValue'];?>" size="14" readonly="true"/></td>
  </tr>
  <tr>
    <th>S. EDU TAX </th>
    <td><input name="SEduPerc" type="text" id="SEduPerc" value="<?php echo $myrow['SEduPerc'];?>" size="3" readonly="true"/><input name="SEduValue" type="text" id="SEduValue" value="<?php echo $myrow['SEduValue'];?>" size="14" readonly="true"/></td>
  </tr>
  <tr>
    <th>S. SHE TAX </th>
    <td><input name="SShePerc" type="text" id="SShePerc" value="<?php echo $myrow['SShePerc'];?>" size="3" readonly="true"/><input name="SSheValue" type="text" id="SSheValue" value="<?php echo $myrow['SSheValue'];?>" size="14" readonly="true"/></td>
  </tr>
  <tr>
    <th>TDS</th>
    <td><input name="TDSPerc" type="text" id="TDSPerc" value="<?php echo $myrow['TDSPerc'];?>" size="3" readonly="true"/><input name="TDSValue" type="text" id="TDSValue" value="<?php echo $myrow['TDSValue'];?>" size="14" readonly="true"/></td>
  </tr>
  <tr>
    <th>FREIGHT</th>
    <td><input type="text" name="freight" id="freight" value="<?php echo $myrow['freight'];?>" readonly="true"/></td>
  </tr>
  <tr>
    <th>GRAND TOTAL </th>
    <td><input type="text" name="grandTotal" id="grandTotal" value="<?php echo $myrow['grandTotal'];?>" readonly="true"	/></td>
  </tr>
</table>
</td>
</tr>
</table>

</div></div>
<?php 	
} 
?>
<?php 
if($_REQUEST['Id']!='' && $_REQUEST['act']=='Edit')
{
	
$sql=DB_query("Select * from job_work where id='".$_REQUEST['Id']."' and CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
$myrow=DB_fetch_array($sql);
?>
<form action="" method="post">

<div class="body_contain">
<div class="tab_div">

<h1>Edit Job Work Order</h1>
<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
  <tr>
    <td class="tabledata1">Branch</td>
    <td><select name="site" style="width:46%" id="site" onchange="generateJobNumber(this.value)">      
      <?php		
		$loc_sql=DB_query("Select loccode,locationname from locations where CompanyId='".$_SESSION['ACGCompanyId']."' and loccode in ('".$_SESSION['AssignedBranch']."')",$db); 
		while($loc_row=DB_fetch_array($loc_sql))
		{
		$k1='';
		if($loc_row['loccode']==$myrow['site'])
		{$k1="selected";}	
		?>
      <option value="<?php echo $loc_row['loccode'];?>"<?php echo $k1; ?>><?php echo $loc_row['locationname'];?></option>
      <?php }
	?>
    </select></td>
	<td class="tabledata1">JOB WORK NO.</td>
	<td><input name="jobWorkNo" type="text" id="jobWorkNo" value="<?php echo $myrow['jobNumber']; ?>" style="width:100%"  readonly="true" /></td>
  </tr>
  <tr>
    <td class="tabledata1">Vendor</td>
    
    <td><select name="vendor" style="width:46%" id="vendor" onchange="vendorname(this.value)">
        
        <?php 
	$vend_sql=DB_query("Select id,vendor_name from suppliers where CompanyId='".$_SESSION['ACGCompanyId']."' AND site IN ('".$_SESSION['AssignedBranch']."')",$db);
	while($vend_row=DB_fetch_array($vend_sql))
	{
	$j='';
	if($myrow['vendor']==$vend_row['vendor_code'])
	{
	$j="selected";	
	}	
		?>
        <option value="<?php echo $vend_row['vendor_code'];?>"<?php echo $j;?>><?php echo $vend_row['vendor_name'];?></option>
        <?php 	
	}
	?>
    </select>
    </td>
    <td class="tabledata1">Job Work Date </td>
    <td><input type="text" name="jobDate" id="jobDate" value="<?php echo ConvertSQLDate($myrow['jobDate']);?>" class="datepicker" readonly="true" style="width:100%" />    </td>
  </tr>
  <tr>
   <!-- <td class="tabledata1">Godown</td>
    <td>
      <select name="store" id="store" style="width:46%">
	  <?php
	//  $data1=''; 
      //  $sql_store ="SELECT id, StoreName,storecode FROM storetype where Store_Site IN ('".$_SESSION['AssignedBranch']."') and CompanyId='".$_SESSION['ACGCompanyId']."'";
		// $resultStkLocs = DB_query($sql_store,$db);
		 
		 
    //   $data1.='<option value="0">Select</option>';
	//	while ($myrow1=DB_fetch_array($resultStkLocs))
	//{
		//if($myrow['store']==$myrow1['id']) { $r='selected';} else { $r=''; }
       // $data1.='<option value="'.$myrow1['id'].'" '.$r.'>'.$myrow1['StoreName'].'</option>';
	//	}
		// $data1.='</select>';
		// echo $data1;
		 ?></td>-->
       <td class="tabledata1">Job Type</td>
   <td><select name="jobtype" id="jobtype" style="width:46%">
     <option value='0'>Select</option>
     <option value='S' <?php if($myrow['job_type']=='S') { ?> selected="selected" <?php } ?>>Service</option>
     <option value='J' <?php if($myrow['job_type']=='J') { ?> selected="selected" <?php } ?>>Job Work Process</option>
    </select>
    
   </td> 
    <td class="tabledata1">Party Job Work No. </td>
	<td><input type="text" name="partyJWNo" id="partyJWNo" value="<?php echo $myrow['partyJWNo'];?>" readonly="true" style="width:100%" /></td>
  </tr>
</table>

<div style="overflow:auto; width:1280px; height:auto"> 
<table border="1" width="100%" cellpadding="3" style="border:#666666 solid 1px;">
<tr>
<td class="tabledata">ITEM CODE </td>
<td class="tabledata">ITEM NAME </td>
<td class="tabledata">ITEM DESCRIPTION </td>
<td class="tabledata">UOM</td>
<td class="tabledata">QUANTITY</td>
<td class="tabledata">RATE</td>
<td class="tabledata">TOTAL AMOUNT </td>
<td class="tabledata">Job Work</td>

</tr>
<?php 
$k=0;
$sql2=DB_query("Select * from job_work_details where masterId='".$_REQUEST['Id']."'",$db);
while($myrow2=DB_fetch_array($sql2))
{
	$item_sql="Select * from item_master where id='".$myrow2['mst_itemId']."'";
	$item_result=DB_query($item_sql,$db);
	$item_row=DB_fetch_array($item_result);
?>
<tr bgcolor="#c1c1c1">
<td><?php echo $item_row['StockID'];?></td>
<td><?php echo $item_row['item_name'];?></td>
<td><?php echo $item_row['item_desc'];?></td>
<td><?php 
$unitname=$s->getField('unitsofmeasure','unitid',$item_row['mst_unitid'],'unitname');
echo $unitname;?></td>

<td><input type="hidden" name="qty[]" value="<?php echo $myrow2['id'];?>" /><input type="text" name="quantity[]"  value="<?php echo $myrow2['quantity'];?>" size="15" id="quantity_<?php echo $k;?>"/></td>
<td><input type="text" name="rate[<?php echo $k;?>]" id="rate_<?php echo $k;?>" value="<?php echo $myrow2['rate'];?>" size="15" readonly="true"/></td>
<td><input type="text" name="totalAmount[<?php echo $k;?>]" id="totalAmount_<?php echo $k;?>" value="<?php echo $myrow2['totalAmount'];?>" size="15" readonly="true" onfocus="calculateAmount(<?php echo $k;?>)"/></td>
<td><select name="process[]" id="process" style="width:100px" >
	<option value="0">Select</option>
	<?php 
	$floor_sql=DB_query("select * from job_work_master",$db);
	while($floor_row=DB_fetch_array($floor_sql))
	{
	if($myrow2['process']==$floor_row['id']) { $t='selected'; } else { $t=''; }
	?>
	<option value="<?php echo $floor_row['id'];?>" <?php echo $t; ?>><?php echo $floor_row['jobwork_name'];?></option>
	<?php 	
	}
	?>
    </select></td>
</tr>
<?php $k++; }?>

</table>
</div>

<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="70%" valign="top">
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<th>REMARKS</th>
<td><textarea name="remarks" id="remarks" style="width:100%"><?php echo $myrow['remarks'];?></textarea></td>
</tr>
</table>
</td>
<td width="27%">
<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
  <tr>
    <td class="tabledata">Basic Amount </td>
    <td><input type="text" name="basicAmount" id="basicAmount" value="<?php echo $myrow['basicAmount'];?>"  /></td>
  </tr>
  <tr>
    <td class="tabledata">Service Tax </td>
    <td><input type="text" id="STaxPerc" name="STaxPerc" value="<?php echo $myrow['STaxPerc'];?>" size="3" /><input name="STaxValue" type="text" id="STaxValue" value="<?php echo $myrow['STaxValue'];?>" size="14" readonly="true" onfocus="calculateServiceTax()"/></td>
  </tr>
  <tr>
    <td class="tabledata">S. Edu Tax </td>
    <td><input name="SEduPerc" type="text" id="SEduPerc" value="<?php echo $myrow['SEduPerc'];?>" size="3" /><input name="SEduValue" type="text" id="SEduValue" value="<?php echo $myrow['SEduValue'];?>" size="14" readonly="true"  onfocus="calculateSEdu()"/></td>
  </tr>
  <tr>
    <td class="tabledata">S. She Tax </td>
    <td><input name="SShePerc" type="text" id="SShePerc" value="<?php echo $myrow['SShePerc'];?>" size="3" /><input name="SSheValue" type="text" id="SSheValue" value="<?php echo $myrow['SSheValue'];?>" size="14" readonly="true" onfocus="calculateSShe()"/></td>
  </tr>
  <tr>
    <td class="tabledata">Tds</td>
    <td><input name="TDSPerc" type="text" id="TDSPerc" value="<?php echo $myrow['TDSPerc'];?>" size="3" /><input name="TDSValue" type="text" id="TDSValue" value="<?php echo $myrow['TDSValue'];?>" size="14" readonly="true" onfocus="calculateTDS()"/></td>
  </tr>
  <tr>
    <td class="tabledata">Freight</td>
    <td><input type="text" name="freight" id="freight" value="<?php echo $myrow['freight'];?>" readonly="true"/></td>
  </tr>
  <tr>
    <td class="tabledata">Grand Total </td>
    <td><input type="text" name="grandTotal" id="grandTotal" value="<?php echo $myrow['grandTotal'];?>" onfocus="calculateGrandTotal()"	/></td>
  </tr>
</table>
</td>
</tr>
</table>
<p align="center"><input type="submit" name="Update" value="Update" /></p>

</div></div>

</form>







<?php 	
} 
?>
<script language="javascript" type="text/javascript">
function open_items()
{
	window.open("JobWorkItems.php?action=add&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>","item_popup_window","height=500,width=900,toolbar=no,menubar=no,dependent=yes,resizable =yes, scrollbars=yes");
}
function calculateAmount(a)
{    
	var quantity = document.getElementById("quantity_"+a).value;
	var rate = document.getElementById("rate_"+a).value;
	var total=quantity*rate;
	document.getElementById("totalAmount_"+a).value=total;
}
function calculateBasic()
{
	var basic=0;
	var count=document.getElementById("itemCount").value;
	for(var b=0;b<count;b++)
	{
		var amount=document.getElementById("totalAmount_"+b).value;
		basic=parseFloat(basic)+parseFloat(amount);
	}
	document.getElementById("basicAmount").value=basic.toFixed(2);
}
function calculateServiceTax()
{
	var spercentage=document.getElementById("STaxPerc").value;
	var BasicAmt=document.getElementById("basicAmount").value;
	var totval=BasicAmt*(spercentage/100);
	document.getElementById("STaxValue").value=totval.toFixed(2);
}
function calculateSEdu()
{
	var STaxValue=document.getElementById("STaxValue").value;
	var SEduPerc=document.getElementById("SEduPerc").value;
	var totalval2=STaxValue*(SEduPerc/100);
	document.getElementById("SEduValue").value=totalval2.toFixed(2);
}
function calculateSShe()
{
	var STaxValue=document.getElementById("STaxValue").value;
	var SShePerc=document.getElementById("SShePerc").value;
	var totalval3=STaxValue*(SShePerc/100);
	document.getElementById("SSheValue").value=totalval3.toFixed(2);
}
function calculateTDS()
{
	var TDSPerc=document.getElementById("TDSPerc").value;
	var basicamt=document.getElementById("basicAmount").value;
	var totalval4=basicamt*(TDSPerc/100);
	document.getElementById("TDSValue").value=totalval4.toFixed(2);
}	
function calculateGrandTotal()
{
	var basicAmount=document.getElementById("basicAmount").value;
	var STax=document.getElementById("STaxValue").value;
	var SEdu=document.getElementById("SEduValue").value;
	var SShe=document.getElementById("SSheValue").value;
	var TDS=document.getElementById("TDSValue").value;
	var freight=document.getElementById("freight").value;
	if(basicAmount=='')basicAmount=0;
	if(STax=='')STax=0;
	if(SEdu=='')SEdu=0;
	if(SShe=='')SShe=0;
	if(TDS=='')TDS=0;
	if(freight=='')freight=0;
	var TOTAL=parseFloat(basicAmount)+parseFloat(STax)+parseFloat(SEdu)+parseFloat(SShe)-parseFloat(TDS)+parseFloat(freight);
	document.getElementById("grandTotal").value=TOTAL.toFixed(2);
}
function generateJobNumber(str)
{
	if (str.length==0)
  {
  document.getElementById("jobid").innerHTML="";
  return;
  }
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("jobid").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","JobNumber.php?q="+str,true);
xmlhttp.send();
}
</script>