<link rel="stylesheet" href="css/new_mxerp.css">
<?php $PageSecurity = 1;
$tabindex=0;
include('includes/DefinePaymentClass.php');
$title = _('Job Card Closing');
include('includes/SQL_CommonFunctions.inc');
if($_REQUEST['act']=='delitem' && $_REQUEST['id']!='')
{
	$update_del_status=DB_query("update trouble_ticket_jobcard set edit_status='1' where id='".$_REQUEST['id']."'",$db);
	echo "<script>location.href='index.php?route=service/jcEdit&action=Edit&jcid=".$_REQUEST['jcid']."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
}
if($_REQUEST['act']=='reset')
{
	$update_del_status=DB_query("update trouble_ticket_jobcard_details set edit_status='0' where jc_id='".$_REQUEST['jcid']."' and edit_status='1'",$db);
	echo "<script>location.href='index.php?route=service/jcEdit&action=Edit&jcid=".$_REQUEST['jcid']."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
}

if($_REQUEST['Save']){
	 echo $updatejc = "UPDATE trouble_ticket_jobcard SET
					client_remark='".$_REQUEST['client_remark']."',
					tech_remark='".$_REQUEST['tech_remark']."',
					visit_date='".FormatDateForSQL($_REQUEST['visit_date'])."',  
					jc_closedate='".FormatDateForSQL($_REQUEST['jc_closedate'])."', 
					prob_status='".$_REQUEST['prob_status']."',
					status='".$_REQUEST['jobcard_close']."',
					jc_payment='".$_REQUEST['jobcard_payment']."',
					other_remark='".$_REQUEST['other_remark']."'
					WHERE id = '".$_REQUEST['jcs_id']."'";die;
					
					$jc_update = DB_query($updatejc,$db);
						
						
						
			$_SESSION['session_msg']="Job Card Closed successfully";

			echo "<script>location.href='index.php?route=service/view_job_card_closing&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
 			?>
			
				<script type="text/javascript">alert("Sucessfully Updated");</script>
			<?php
			
	}
unset($_POST);
?>
<script type="text/javascript">

function getContactName(str)
{
	
if(str.length==0)
{
	document.getElementById("ContactName").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("ContactName").innerHTML=xmlhttp.responseText;
 	}
 }
xmlhttp.open("GET","getContact.php?Client="+str,true);
xmlhttp.send();	
	
	
} 
function getPhoneNo(str)
{
	
if(str.length==0)
{
	document.getElementById("PhoneNo").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("PhoneNo").innerHTML=xmlhttp.responseText;
		
	}
	
}
xmlhttp.open("GET","getPhone.php?Contact="+str,true);
xmlhttp.send();	
} 


function openPopupProfile1()
{
	window.open("clientname.php");
}
function openPopupProfile2()
{
	window.open("TelephonicItems.php?modid=<?php echo $_REQUEST['modid']?>&frmid=<?php echo $_REQUEST['frmid']?>");
}


function open_jobcard_payment(str)
{
window.open("ACJobcardPaymentDetails.php?modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'] ?>&action=<?php echo $_REQUEST['action']?>&cnp="+str,"itempopup_window","height=500,width=600,toolbar=no,menubar=no,dependent=yes,resizable =yes, scrollbars=yes");
}
 </script>
<div class="body_contain">
  <h1><?php echo $title; ?></h1>
  <?php $tt="SELECT * FROM trouble_ticket_jobcard WHERE id='".$_REQUEST['jcid']."'";
	  $tt_qry = DB_query($tt,$db);
	  $fetch_tt_qry = DB_fetch_array($tt_qry);
	  extract($fetch_tt_qry);
	?>
  <div class="insideclass">
    <div style="z-index:-1000em;">
      <div class="demo">
        <div id="tabs">
          <div id="tabs-1">
            <form action="" method="post" name="jobCardClose">
              <table width="100%" border="1" cellspacing="0" cellpadding="3" style="border:#999999 solid 1px;">
        <tr class="row1">
          <td class="tabledata1">Branch</td>
          <td><?php $location = DB_query("SELECT * FROM locations where CompanyId = '".$_SESSION['ACGCompanyId']."' AND loccode='".$fetch_tt_qry['branch']."'",$db);	  ?>
              <?php while($loc = DB_fetch_array($location)){?>
			  <input name="branch" value="<?php echo  $loc['locationname']?>" readonly="readonly" style="width:150px;" />
              <?php }	?>
           </td>
			<td colspan="2"></td>		

        </tr>
		<tr class="row1">
           <td class="tabledata1">Job Card No.</td>
          <td><input type="text" style="width:150px" name="jobcard_number" readonly="readonly" value="<?php echo $fetch_tt_qry['job_card_number'];?>" />          </td>
          <td class="tabledata1">Job Card Date & Time</td>
          <td><input type="text" style="width:150px" name="jobcard_date" readonly="readonly" value="<?php echo $fetch_tt_qry['job_card_date'];?>" />
		  <?php 
		  $timezone = "Asia/Calcutta";
			if(function_exists('date_default_timezone_set')) date_default_timezone_set($timezone);
			  $t=date("G:i", time());  ?>
		  <input type="text" style="width:60px" name="jobcard_time" readonly="readonly" value="<?php  if($_REQUEST['jobcard_time']!='') { echo $_REQUEST['jobcard_time'];}else{echo $t; }?>" /></td>
        </tr>
		
        <tr class="row1">
			<td class="tabledata1">TT No.</td>
          <td><?php 
	  $TTSQL="Select * from trouble_ticket_creation";
		$tt_No = DB_query($TTSQL,$db);
	?>
            
			<?php $ttnum = $s->GetFieldValue('trouble_ticket_creation', 'id="'.$fetch_tt_qry['ticket_number'].'"', 'ticket_number') ?>
			<input type="text" name="tt_no" id="ttId" value="<?php echo $ttnum; ?>" readonly="readonly" style="width:150px" />         </td>
          <td class="tabledata1">Party Name</td>
          <td>
		  <?php $ClientSQL= $s->GetFieldValue('clientmaster', 'id="'.$fetch_tt_qry['party_name'].'"','c_name');?>
            <input name="part_name1" id="partyId" style="width:150px" value="<?php echo $ClientSQL; ?>" readonly="readonly" />
			<input name="part_name" id="partyId1" style="visibility:hidden; height:1px; width:50px;" value="<?php echo $fetch_tt_qry['party_name']; ?>" />
		</td>
        </tr>
		<tr class="row1">
			<td class="tabledata1">Product Name</td>
          <td>
		  <?php $ProductSQL= $s->GetFieldValue('item_master', 'id="'.$fetch_tt_qry['product_name'].'"','item_name');?>
		    <input name="product_name1" id="productId" style="width:150px" value="<?php echo $ProductSQL; ?>" readonly="readonly" />
			<input name="product_name" id="productId1" style="visibility:hidden; height:1px; width:50px;" value="<?php echo $fetch_tt_qry['product_name']; ?>" />
         </td>
          <td class="tabledata1">Serial No.</td>
          <td><input name="serial_no" id="serialNo" value="<?php echo $fetch_tt_qry['serial_number']; ?>" style="width:150px" readonly="readonly" /></td>
        </tr>
		<tr class="row1">
			<td class="tabledata1">Technician Name</td>
			<?php $TechnicianSQL= $s->GetFieldValue('technicians', 'id="'.$fetch_tt_qry['technician'].'"','technician');?>
			<td><input name="technician_name1" id="technicianName" value="<?php echo $TechnicianSQL; ?>" readonly="readonly" style="width:150px" />
			<input name="technician_name" id="technicianName1" style="visibility:hidden; height:1px; width:50px;" value="<?php echo $fetch_tt_qry['technician'];?>" />
			</td>
			<td class="tabledata1">Scope of Service</td>
			<td>
			<?php 
			if($fetch_tt_qry['scope_compaint']=='1'){$ttscope="Complaint";}
			else if($fetch_tt_qry['scope_compaint']=='2'){$ttscope="Installation";}
			else if($fetch_tt_qry['scope_compaint']=='3'){$ttscope="De-Installation";}
			else if($fetch_tt_qry['scope_compaint']=='4'){$ttscope="Re-Installation";}
			else if($fetch_tt_qry['scope_compaint']=='5'){$ttscope="Preventive";}
			else if($fetch_tt_qry['scope_compaint']=='6'){$ttscope="Service";}
			else if($fetch_tt_qry['scope_compaint']=='7'){$ttscope="Site Survey";}
			else {$ttscope="";}
			?>
			<input name="scope_compaint1" id="scopeCompaint" value="<?php echo $ttscope; ?>" readonly="readonly" style="width:150px" />
			<input name="scope_compaint" id="scopeCompaint1" style="visibility:hidden; height:1px; width:50px;" value="<?php echo $fetch_tt_qry['scope_compaint']; ?>" readonly="readonly" />
			</td>
		</tr>
        <tr>
         <tr class="row1">
			<td class="tabledata1">Mode of Complaint</td>
			<td>
			<?php 
			if($fetch_tt_qry['mode_compaint']==1){$ttmode="By Call";}
			else if($fetch_tt_qry['mode_compaint']==2){$ttmode="By Mail";}
			else if($fetch_tt_qry['mode_compaint']==3){$ttmode="Internal Mail Request";}
			else if($fetch_tt_qry['mode_compaint']==4){$ttmode="Internal Request";}
			else {$ttmode="";}
			?>
			<input name="service_type1" id="serviceType" value="<?php echo $ttmode;?>" readonly="readonly" style="width:150px" />
			<input name="service_type" id="serviceType1" style="visibility:hidden; height:1px; width:50px;" value="<?php echo $fetch_tt_qry['mode_compaint'];?>" />
			</td>
			<td class="tabledata1">Mode of Contract</td>
			<?php 
			if($fetch_tt_qry['mode_contract']==1){$ttcontract="Lease";}
			else if($fetch_tt_qry['mode_contract']==2){$ttcontract="NA";}
			else if($fetch_tt_qry['mode_contract']==3){$ttcontract="Sold";}
			else {$ttcontract="";}
			?>
			<td><input name="mode_contract1" id="modeContract" value="<?php echo $ttcontract; ?>" readonly="readonly" style="width:150px" />
			<input name="mode_contract" id="modeContract1" style="visibility:hidden; height:1px; width:50px;" value="<?php echo $fetch_tt_qry['mode_contract']; ?>" />
			</td>
		</tr>
        </tr>
        <tr>
          <td class="tabledata1">Expected closing date</td>
          <td><input name="closer_date" id="closerDate" value="<?php echo $fetch_tt_qry['closing_date']; ?>" readonly="readonly"  style="width:150px" />
			</td>
          <td class="tabledata1" colspan="2">&nbsp;</td>
        </tr>
      </table>
	  <br />
	  <h3 align="center">Fault Descriptions</h3>
		<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
		<tr class="row1">
		<td class="tabledata1">Fault Details</td>
		<td colspan="3" id="FAULT"><input type="text" name="prob_desc" id="prob_desc" value="<?php echo $fetch_tt_qry['prob_desc']; ?>"  style="width:80%; height:50px;" readonly="readonly" /></td>
		</tr>
		<tr class="row1">
		<td class="tabledata1">Client Remarks</td>
		<td colspan="3">
		<?php $cli_remark = $s->GetFieldValue('technician_visit_entry', 'job_card_no="'.$_REQUEST['jcid'].'"', 'client_remark'); ?>
		<input type="text" name="client_remark" value="<?php echo $cli_remark; ?>" style="width:80%; height:50px;" readonly="readonly" /></td>
		</tr>
		<tr>
		<td class="tabledata1">Technician Remarks</td>
		<td colspan="3">
		<?php $tech_remark = $s->GetFieldValue('technician_visit_entry', 'job_card_no="'.$_REQUEST['jcid'].'"', 'remark_by_technician'); ?>
		<input type="text" name="tech_remark" value="<?php echo $tech_remark; ?>" style="width:80%; height:50px;" readonly="readonly" /></td>
		</tr>
		</table>
              <br />
              <div style="width:auto; overflow:auto; border:#006699 solid 2px;">
               
                <div style="width:auto; overflow:auto;">
                  <div id="showdata">
                    <table width="100%" border="1" cellspacing="0" cellpadding="3" style="border-collapse:collapse;">
                      <tr>
                        <td class="tabledata">S. No.</td>
                        <td class="tabledata">Item Name</td>
                        <td class="tabledata">Qty in Stock </td>
                        <td class="tabledata">Req. Qty.</td>
                        <td class="tabledata">Price</td>
                        <td class="tabledata">Total amount</td>
                      </tr>
                      <?php 
		 $i=0;
		$visit_id = $s->GetFieldValue('technician_visit_entry', 'job_card_no="'.$fetch_tt_qry['id'].'"', 'id');
		  $ItemSQL=DB_query("Select * from technician_visit_entry_details where parant_id='".$visit_id."'",$db);
		  while($item_row1=DB_fetch_array($ItemSQL))
		  {
			 //echo "select StockID,item_name,unit, make ,grade, color from item_master where StockID='".$itemlist[$i]."'" ;
			
				if($i%2==0)
				{$bg="#CCCCCC";}
				else
				$bg="#C8BECB";
			
			?>
                      <tr bgcolor="<?php //echo $bg;?>"  class="row1">
                        <td class="tabledata"><?php echo $i+1;?></td>
                        <td  class="tabledata">
                          <?php echo $s->GetFieldValue('item_master', 'id="'.$item_row1['item_name'].'"', 'item_name');?>
                        </td>
                        <td class="tabledata"><?php echo $item_row['item_name'];?> </td>
                        <td class="tabledata" ><input type="text"  value="<?php echo $item_row1['req_qty'];?>" id="rqty_<?php echo $i;?>" name="rqty[]" readonly="readonly" /></td>
                        <td class="tabledata" ><input type="text" style="width:50" name="price[]" id="price_<?php echo $i;?>" value="<?php echo $item_row1['price']?>" readonly="readonly"/></td>
                        <td class="tabledata" ><input type="text" name="amt[]" id="amt_<?php echo $i;?>" value="<?php echo $item_row1['tptal_amt']?>" size="6"  readonly="readonly" /></td>
                      </tr>
                      <?php $i++;}?>
                      <input type="hidden" name="" value="<?php echo $i;?>" id="edit_cnt" />
                    </table>
                  </div>
                </div>
                
                <input type="hidden" name="hiditemcount" id="hiditemcount" value="" />
				
				
<?php $ServiceSql = DB_query("Select * from technician_service_visit where parant_id='".$visit_id."'",$db);?>
<style>
#showdata {
	display: block;
	background: url(Default.png) no-repeat;
	top: 0px;
	left: 0px;
	width: 100%;
	min-height: 60px;
	z-index:0;
}
<?php if(DB_num_rows($ServiceSql)>0) {?>
#back {
	display:block;
	top: 0px;
	left: 0px;
	width: 100%;
	min-height: 60px;
	z-index:0;
}
<?php }else {  ?>

#back {
	display:none;
	top: 0px;
	left: 0px;
	width: 100%;
	min-height: 60px;
	z-index:0;
}

<?php } ?>
</style>
		<div style="width:auto; overflow:auto;">
			<div id="back">
				<table width="100%" border="1" cellspacing="0" cellpadding="0" style="border:#666666 solid 1px;">
               <tr>
                <td width="76" class="tabledata">S. No.</td>
				<td class="tabledata">Service</td>
                <td width="229" class="tabledata">Service Type</td>
                <td width="251" class="tabledata">Service Description</td>
				<td width="251" class="tabledata">Billable</td>
                <td width="240" class="tabledata">Service Amount</td>
              </tr>
			  <?php 
			  $k = 1;
			  $j=0; while($ServiceRow=DB_fetch_array($ServiceSql)) {
			  $k += $j;
			  ?>
			  <tr>
			  	<td class="tabledata"><?php echo $k; ?></td>
				<td class="tabledata">
				
				<input type="text" name="service1[<?php echo $j; ?>]" value="<?php echo $ServiceRow['service_name'];?>" id="service_<?php echo $j; ?>" size="40"  readonly="readonly"/></td>
				<td><?php $serv= DB_query("SELECT * FROM services_type WHERE id='".$ServiceRow['service_type']."'",$db);?>
						<?php while($getServe_type= DB_fetch_array($serv)){	   ?>
							   <input name="service_type1[<?php echo $j; ?>]" value="<?php echo $getServe_type['service_type']?>" readonly="readonly" />
							   <?php }	?>
				  </td>
				   <td>
				  	<?php $stype= DB_query("SELECT * FROM services_description WHERE id='".$ServiceRow['service_description']."'",$db);?>
				  		<?php while($getStype= DB_fetch_array($stype)){   ?>
						   <input name="service_desc1[<?php echo $j; ?>]" value="<?php echo $getStype['service_description']?>" readonly="readonly" />
						<?php }	?>
				  </td>
				  <td>
				  <input name="billable1[]" value="<?php echo $ServiceRow['billable'];?>" readonly="readonly" />
				  </td>
				  <td><input type="text" name="service_amt1[<?php echo $j; ?>]" id="service_amt_<?php echo $j; ?>" value="<?php echo $ServiceRow['service_amt']; ?>" size="20" readonly="readonly"/></td>
			  </tr>
			  <?php $j++;} ?>
			  
			   <input type="hidden" name="" value="<?php echo $j; ?>" id="edit_cnt1" />
			   
</table>
			</div>
		</div>
        <input type="hidden" name="hiditemcount1" id="hiditemcount1" value="" />
       
        
				
				
				<div style="width:68%; float:left;">
				<table width="100%" border="0" cellspacing="0" cellpadding="3" >
				<tr><td colspan="4">&nbsp;</td></tr>
				<tr class="row1">
					<td>Visiting Date<label><font color="#FF0000"> *</font></label></td>
					<td>
					<?php $vdate = $s->GetFieldValue('technician_visit_entry', 'job_card_no="'.$_REQUEST['jcid'].'"', 'visit_date')?>
					<input type="text" name="visit_date" value="<?php echo ConvertSQLDate($vdate); ?>" readonly="readonly" style="width:150px"  />
					</td>
					<td>Job Card Closing Date<label><font color="#FF0000"> *</font></label></td>
					<td><input type="text" value="<?php echo ConvertSQLDate($fetch_tt_qry['jc_closedate']); ?>" name="jc_closedate" id="jc_closedate" class="datepicker" readonly="readonly" style="width:150px"  /></td>
				</tr>
				<tr class="row1">
					<td>Problem Status<label><font color="#FF0000"> *</font></label></td>
					<td>
					<select name="prob_status" style="width:150px" >
						<option value="Resolved" <?php if($fetch_tt_qry['prob_status']=='Resolved') {echo "selected";}?>>Resolved</option>
						<option value="Pending" <?php if($fetch_tt_qry['prob_status']=='Pending') {echo "selected";}?>>Pending</option>
					</select>
					</td>
					<td>Want To Close This Job card<label><font color="#FF0000"> *</font></label></td>
					<td>
					<select name="jobcard_close" style="width:150px" >
						<option value="2" <?php if($fetch_tt_qry['jc_close']=='2') {echo "selected";}?>>NO</option>
						<option value="3" <?php if($fetch_tt_qry['jc_close']=='3') {echo "selected";}?>>YES</option>
					</select>
					</td>
				</tr>
				<tr class="row1">
				<td>Payment Received<label><font color="#FF0000"> *</font></label></td>
					<td>
					<select name="jobcard_payment" style="width:150px" >
						<option value="0" <?php if($fetch_tt_qry['jc_payment']=='0') {echo "selected";}?>>NO</option>
						<option value="1" <?php if($fetch_tt_qry['jc_payment']=='1') {echo "selected";}?> >YES</option>
					</select>
				</td>
				<td colspan="2" style="text-align:center;"><input type="button" name="profile_popup" value="Show Receiving Voucher" id="profile_popup"  onclick="open_jobcard_payment(<?php echo $fetch_tt_qry['id']; ?>)" class="search" /></td>
				</tr>
				<tr>
					<td>Other Remarks<label><font color="#FF0000"> *</font></label></td>
					<td colspan="3"><input type="text" name="other_remark" value="<?php echo $fetch_tt_qry['other_remark']; ?>" style="width:96%; height:50px;" /></td>
				</tr>
				</table>
				</div>
                <div style="width:32%; float:right;">
				<?php $tt1="SELECT * FROM technician_visit_entry WHERE job_card_no= '".$_REQUEST['jcid']."'";
				  $tt_qry1 = DB_query($tt1,$db);
				  $fetch_tt_qry1 = DB_fetch_array($tt_qry1);
				?>
                  <table width="100%" border="1" cellspacing="0" cellpadding="3" style="border:#999999 solid 1px;">
                    <tr class="row1">
                      <td class="tabledata" style="width:120px;">Material Total Amt.</td>
                      <td><input name="materialAmount" type="text" style="width:150px" id="materialAmount" value="<?php echo $fetch_tt_qry1['Total_material_Amt']?>" readonly="readonly"/></td>
                    </tr>
					<tr class="row1">
                      <td class="tabledata">Vat/Cst</td>
                      <td><?php 
					$salesSql=DB_query("Select * from sales_tax_master where salestax_id='".$fetch_tt_qry1['vat_cst']."'",$db);
					while($salesRow=DB_fetch_array($salesSql))	{?>
					<input name="VatCst" type="text" value="<?php echo $salesRow['tax_code'];?>" readonly="readonly" style="width:150px" />
                          <?php 	
					}
					?><br />
					<input name="VatCstValue" type="text" value="<?php echo $fetch_tt_qry1['VatCstValue'];?>" readonly="readonly" style="width:150px"  />
                        </td>
                    </tr>
					<tr class="row1">
                      <td class="tabledata">Service Total Amt.</td>
                      <td><input name="serviceAmount" type="text" style="width:150px"  id="serviceAmount" value="<?php echo $fetch_tt_qry1['service_total_amt']?>" readonly="readonly"/></td>
                    </tr>
					<tr class="row1">
                      <td class="tabledata">Service Tax</td>
                      <td><?php 
					$salesSql=DB_query("Select * from service_tax_master where id='".$fetch_tt_qry1['service_tax']."'",$db);
					while($salesRow=DB_fetch_array($salesSql))
					{?>
					<input name="serviceTax" type="text" value="<?php echo $salesRow['tax_code'];?>" readonly="readonly" style="width:150px"  />
                          <?php 	
					}
					?><br />
					<input name="serviceTaxValue" type="text" value="<?php echo $fetch_tt_qry1['service_tax_value'];?>" readonly="readonly" style="width:150px"  />
                      </td>
                    </tr>
					<tr class="row1">
                      <td class="tabledata">Other Amount</td>
                      <td><input name="otherAmount" id="otherAmount" type="text" style="width:150px"  value="<?php echo $fetch_tt_qry1['other_charges']?>" readonly="readonly"/></td>
                    </tr>
                    <tr class="row1">
                      <td class="tabledata">Grand Total</td>
                      <td><input name="grandTotal" id="grandTotal" type="text" style="width:150px"  readonly="readonly" value="<?php echo $fetch_tt_qry1['grand_total']?>"  /></td>
                    </tr>
                  </table>
                </div>
                <div class="cl"></div>
              </div>
              <p align="center">
			  	<input type="hidden" name="jcs_id" value="<?php echo $fetch_tt_qry['id']?>" /> 
                <input type="submit" name="Save" value="Save" onclick="return check_po()"/>
              </p>
            </form>
          </div>
         
        </div>
      </div>
    </div>
  </div>
  <!-- inside div close -->
</div>
<!-- Main div close -->
<script language="javascript" type="text/javascript">

function check_po()
{
if(document.jobCardClose.branch.value=='')
{
	alert("Please Select Branch First");
	return false;
}
else if(document.jobCardClose.visit_date.value=='')
{
	alert("Please Enter Visit Date");
	return false;
}
else if(document.jobCardClose.visit_date.value.length<10)
{
	alert("Please Enter Visit Date");
	return false;
}
else if(document.jobCardClose.jc_closedate.value=='')
{
	alert("Please Enter Job Card Close Date");
	return false;
}
else if(document.jobCardClose.jc_closedate.value.length<10)
{
	alert("Please Enter Job Card Close Date");
	return false;
}
else if(document.jobCardClose.prob_status.value=='')
{
	alert("Please Enter Problem Status");
	return false;
}
else if(document.jobCardClose.jobcard_close.value=='')
{
	alert("Please Select Close Option");
	return false;
}
else if(document.jobCardClose.jobcard_payment.value=='0')
{
	alert("Please Select Payment Option");
	return false;
}
else if(document.jobCardClose.other_remark.value=='')
{
	alert("Please Enter Other Remark");
	return false;
}

var r=confirm("Are you want to save this entry!")
if (r)
  {
  return true;
  }
else
  {
  return false;
  }
}





function calculateExcise(str,id)
{
	var id_brk=id.split('_');
	var i=id_brk[1];
	
	if(id_brk.length>1)
	{
		divid="excisevalue_"+i;
		var amount=document.getElementById("totalamt_"+i).value;
	}
	else
	{
		divid="excisevalue";
		var amount=document.getElementById("totalamt").value;
	}
	
	//alert(divid);
	
	if(str.length==0)
	{
		document.getElementById(divid).value="";
		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(divid).value=xmlhttp.responseText;
		
	}
	
}
xmlhttp.open("GET","calculateExcise.php?type=TELORD&amount="+amount+"&q="+str,true);
xmlhttp.send();	
	
	} 

function calculateBillExcise(str)
{
	var value=document.getElementById("basicAmount").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 totalExcise=0;
	var EDRate=document.getElementById("EDRate").value;
	if(EDRate==0)
	{
		var first_row=document.getElementById("excisevalue").value;
		if(first_row==''){first_row=0;}else{first_row=first_row;}
		var cnt=document.getElementById("hiditemcount").value;
		if(cnt==''){cnt=0;}
		var edit_cnt=document.getElementById("edit_cnt").value;
		var new_count=parseInt(edit_cnt)+parseInt(cnt); 
	for(var i=0;i<new_count;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 calculateEditVATCST()
{
	var rate=document.getElementById("rate").value;
	var taxableAmount=document.getElementById("taxableAmount").value;
	var vat_cst=taxableAmount*(rate/100);
	document.getElementById("VatCstValue").value=vat_cst.toFixed(2);
}*/

function calculateExcise1(str,id)	
{
var id_brk=id.split('_');
	var i=id_brk[1];
	if(id_brk.length>1)
	{
		divid="excisevalue_"+i;
		var amount=document.getElementById("totalassamt_"+i).value;
	}
	else
	{
		divid="excisevalue";
		var amount=document.getElementById("totalassamt").value;
	}
	if(str.length==0)
	{
		document.getElementById(divid).value="";
		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(divid).value=xmlhttp.responseText;
		
	}
	
}
xmlhttp.open("GET","calculateExcise.php?type=TELORD&amount="+amount+"&q="+str,true);
xmlhttp.send();	
	} 
	
	function calassprice(val,id)
{
	
		var id_brk=id.split('_');
		var i=id_brk[1];
		if(id_brk.length>1)
		{
			
			var tot_amt=(70*val)/100;
			document.getElementById("ass_price_"+i).value=tot_amt.toFixed(2);
		}
		else
		{
			
			var tot_amt=(70*val)/100;
			document.getElementById("ass_price").value=tot_amt.toFixed(2);
		}
}

function calass_amount(id)
{
	var id_brk=id.split('_');
		var i=id_brk[1];
		if(id_brk.length>1)
		{ 
			
			var qty=document.getElementById("qty_"+i).value;
			var ass_value=document.getElementById("ass_price_"+i).value;
			var tot_amt=ass_value*qty;
			document.getElementById("totalassamt_"+i).value=tot_amt.toFixed(2);
		}
		else
		{
			
			var qty=document.getElementById("qty").value;
			var ass_value=document.getElementById("ass_price").value;
			var tot_amt=ass_value*qty;
			
			document.getElementById("totalassamt").value=tot_amt.toFixed(2);
		}
	
}

function getorder(str)
{
	if(str!='Consolidate')
	document.getElementById("EDRate").setAttribute('disabled',true);
	else
	document.getElementById("EDRate").removeAttribute('disabled');
if(str.length==0)
	{
		document.getElementById("showdata").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("showdata").innerHTML=xmlhttp.responseText;
 	}
 }
 var sales=document.getElementById("salid").value;
xmlhttp.open("GET","gettelephoniceditdata.php?id="+str+"&SalesId="+sales,true);
xmlhttp.send();
	
	
}



</script>
