<?
ob_start();
session_start();
if(isset($_SESSION['ses_name']))
{
$user=$_SESSION['ses_name'];
}else{
header("location:index.php");
}
$tyrenum_veh='';

include("include/config.php");
require_once "include/Database_functions.php";
$sqlObj=new sqlclass();

//$tablename='cf_client';

		if(isset($_POST['cilentsubmit'])){
		
			/*if(isset($_POST['lab_date'])){
			$labdate= date(('Y-m-d'),strtotime($_POST['lab_date']));
			}
			
			if(isset($_POST['lab_bill_no'])){
			$lab_billno=addslashes($_POST['lab_bill_no']);
			}
			
			if(isset($_POST['lab_quantity'])){
			$labquantity=addslashes($_POST['lab_quantity']);
			}
			
			if(isset($_POST['lab_testing'])){
			$labamount=addslashes($_POST['lab_testing']);
			}
			
			if(isset($_POST['veh_no'])){
			$vehno=addslashes($_POST['veh_no']);
			}
			
			if(isset($_POST['company_name'])){
			$companyname=addslashes($_POST['company_name']);
			}
			
			if(isset($_POST['lab_agent_id'])){
			$labname=addslashes($_POST['lab_agent_id']);
			}
		   
		    $sql3 = mysql_query("insert into cf_lab (lab_date,lab_billnum,lab_qty,lab_bill_amt,lab_vehicle_no,lab_company,lab_name) values ('$labdate','$lab_billno','$labquantity','$labamount','$vehno','$companyname','$labname')");
			
			echo "insert into cf_lab (lab_date,lab_billnum,lab_qty,lab_bill_amt,lab_vehicle_no,lab_company,lab_name) values ('$labdate','$lab_billno','$labquantity','$labamount','$vehno','$companyname','$labname')";
								
				$addate = date('Y-m-d');*/
				
				
				
			/*	$lastid = mysql_insert_id();
			
				$ledgername=$clientname.'_'.$lastid;
			
				mysql_query("insert into cf_ledger (ledgername,ledgertype,empid,groupid,ledger_start_date) values('$ledgername','clientledger','$lastid','22','".date('Y-m-d')."')");	
			$lederid = mysql_insert_id();	
				
			mysql_query("insert into cf_accountsreceivable(clientid,ledgerid) values('$lastid','$lederid')");	*/				
			
			//header("location:client-list.php");
}
			
			
			
		/*if(empty($_REQUEST['clientid']))
		{
		$sqlclientauto = mysql_query("select max(client_code) as clientnewcode from cf_client");	
		$rows5 = mysql_fetch_array($sqlclientauto);	
		$clientautos =  $rows5['clientnewcode'];
		$newclientno = $clientautos + 1;	
		}
		else
		{
			$clientid = $_REQUEST['clientid'];
			$sqlclientauto = mysql_query("select max(client_code) as clientnewcode from cf_client where client_id =  $clientid");	
			$rows5 = mysql_fetch_array($sqlclientauto);	
			$newclientno =  $rows5['clientnewcode'];
		}*/
			
			$lab_date='';	
			$lab_billnum='';	
			$lab_qty='';	
			$lab_bill_amt='';	
			$lab_vehicle_no='';						
			$lab_company='';
			$lab_name='';	
			$purpasschg = '';
			$vehicle_type='';	
			$pass_agent_id='';	
			$passing_chg='';
			
		if(isset($_POST['labtestsubmit'])){
		
			if(isset($_POST['lab_date'])){
			$lab_date=date(('Y-m-d'),strtotime($_POST['lab_date']));
			}
			
			if(isset($_POST['lab_bill_no'])){
			$lab_bill_no=addslashes($_POST['lab_bill_no']);
			}	
					
			if(isset($_POST['lab_quantity'])){
			$lab_quantity=addslashes($_POST['lab_quantity']);
			}	
			
			if(isset($_POST['bill_amt'])){
			$bill_amt=addslashes($_POST['bill_amt']);
			}	
			
			if(isset($_POST['company_name'])){
			$company_name=addslashes($_POST['company_name']);
			}	
			
			if(isset($_POST['veh_no'])){
			$veh_no=addslashes($_POST['veh_no']);
			}	
			
			if(isset($_POST['lab_agent_id'])){
			$lab_agent_id=addslashes($_POST['lab_agent_id']);
			}	
			
			if(isset($_POST['vehicletype'])){
			$vehicletype=addslashes($_POST['vehicletype']);
			}	
			
			if(isset($_POST['pass_agent_id'])){
			$pass_agent_id=addslashes($_POST['pass_agent_id']);
			}	
			
			if(isset($_POST['passing_chg'])){
			$passing_chg=addslashes($_POST['passing_chg']);
			}	
			
			//$today = date('Y-m-d');
			$today = date('Y-m-d');
			
			$sql3 = mysql_query("insert into cf_lab (lab_date,lab_billnum,lab_qty,lab_bill_amt,lab_vehicle_no,lab_company,lab_name,vehicle_type,pass_agent_id,passing_chg) values ('$lab_date','$lab_bill_no','$lab_quantity','$bill_amt','$veh_no','$company_name','$lab_agent_id','$vehicletype','$pass_agent_id','$passing_chg')");
			  
		   /*$purid = mysql_insert_id();
		   
		   $acc_ref=mysql_query("select max(account_reference) as account_reference  from cf_purchase_account");
			 $acc_refrow=mysql_fetch_array($acc_ref);
			 if(mysql_num_rows($acc_ref) >0)
			 {
			 	$acc_reference=$acc_refrow['account_reference'];
			 }
			 else
			 {
			 	$acc_reference=0;
			 }
		
		$acc_reference=$acc_reference+1;
		
		$reslabres = mysql_query("select * from cf_ledger where ledgertype = 'labledger' and empid = '$passagent_id'");
		$reslabrw = mysql_fetch_array($reslabres);
		$lab_agent_id = $reslabrw['ledgerid'];
		
		   
		   $sql35 = mysql_query("insert into cf_purchase_account (purchaseid,acc_amount,account_type,ven_client_id,pay_date,add_date,account_reference) values ('$purid','$bill_amt','2','1040','$lab_date','$today','$acc_reference')");	
		   
		   $sql36 = mysql_query("insert into cf_purchase_account (purchaseid,acc_amount,account_type,ven_client_id,pay_date,add_date,account_reference) values ('$purid','$bill_amt','1','$lab_agent_id','$lab_date','$today','$acc_reference')");	*/
			  
		//$purid = mysql_insert_id();
		header("location:lab_test_list.php");
		}
		
		
		if(isset($_REQUEST['lab_id'])){
			$id=$_REQUEST['lab_id'];
			//$tablename='cf_lab';
			$sqlObj->tablename="cf_lab";
			$condition=" where lab_id='$id'";
			$sqlObj->condition=$condition;
			$sqlObj->fieldvalue="*";
			$fieldvalue=$sqlObj->fieldvalue;
			$sql=$sqlObj->SelectTable();

			$lab_date=date(('d-m-Y'),strtotime($sql['lab_date']));
			$lab_billnum=$sql['lab_billnum'];	
			$lab_qty=$sql['lab_qty'];	
			$lab_bill_amt=$sql['lab_bill_amt'];	
			$lab_vehicle_no=$sql['lab_vehicle_no'];					
			$lab_company=$sql['lab_company'];
			$lab_name=$sql['lab_name'];	
			$vehicle_type=$sql['vehicle_type'];	
			$pass_agent_id=$sql['pass_agent_id'];	
			$passing_chg=$sql['passing_chg'];	

		}
		
		
		if(isset($_POST['labtestedit']))
		{
			
			if(isset($_POST['lab_date'])){
			$lab_date=date(('Y-m-d'),strtotime($_POST['lab_date']));
			}
			
			if(isset($_POST['lab_bill_no'])){
			$lab_bill_no=addslashes($_POST['lab_bill_no']);
			}	
					
			if(isset($_POST['lab_quantity'])){
			$lab_quantity=addslashes($_POST['lab_quantity']);
			}	
			
			if(isset($_POST['bill_amt'])){
			$bill_amt=addslashes($_POST['bill_amt']);
			}	
			
			if(isset($_POST['company_name'])){
			$company_name=addslashes($_POST['company_name']);
			}	
			
			if(isset($_POST['veh_no'])){
			$veh_no=addslashes($_POST['veh_no']);
			}	
			
			if(isset($_POST['lab_agent_id'])){
			$lab_agent_id=addslashes($_POST['lab_agent_id']);
			}	
			
			if(isset($_POST['vehicletype'])){
			$vehicletype=addslashes($_POST['vehicletype']);
			}	
			
			if(isset($_POST['pass_agent_id'])){
			$pass_agent_id=addslashes($_POST['pass_agent_id']);
			}	
			
			if(isset($_POST['passing_chg'])){
			$passing_chg=addslashes($_POST['passing_chg']);
			}	
			
			//$today = date('Y-m-d');
			
			  $sql3 = mysql_query("update cf_lab set lab_date='$lab_date',lab_billnum='$lab_bill_no',lab_qty='$lab_quantity',lab_bill_amt='$bill_amt',lab_vehicle_no='$veh_no',lab_company='$company_name',lab_name='$lab_agent_id',vehicle_type='$vehicletype',pass_agent_id='$pass_agent_id',passing_chg='$passing_chg' where lab_id=$id");
			//$purid = mysql_insert_id();
		header("location:lab_test_list.php");
		}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>OIL FILL</title>
<link href="css/styles.css" rel="stylesheet"  />
<link type="text/css" href="css_date/ui-lightness/jquery-ui-1.7.2.custom.css" rel="stylesheet" />
<script type="text/javascript" src="scripts_date/jquery.js"></script>
<script type="text/javascript" src="scripts_date/jquery-calendar-1.7.2.js"></script>




<script type="text/javascript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
function validation(){
if(document.frmname.lab_date.value==''){
alert("Select a Date");
document.frmname.lab_date.focus();
return false;
}
if(document.frmname.lab_bill_no.value==''){
alert("Enter the Bill No");
document.frmname.lab_bill_no.focus();
return false;
}
/*if(document.frmname.lab_quantity.value==''){
alert("Enter the Quantity");
document.frmname.lab_quantity.focus();
return false;
}*/

if(document.frmname.bill_amt.value==''){
alert("Enter the Bill Amount");
document.frmname.bill_amt.focus();
return false;
}

if(document.frmname.company_name.value==''){
alert("Enter the Company Name");
document.frmname.company_name.focus();
return false;
}

if(document.frmname.veh_no.value==''){
alert("Enter the Vehicle No");
document.frmname.veh_no.focus();
return false;
}



if(document.frmname.lab_agent_id.value==''){
alert("Select the Lab Name");
document.frmname.lab_agent_id.focus();
return false;
}
/*var cnt=document.getElementById('divcnt').value;chasisnum1 enginenum1
for(i=1;i<=cnt;i++){alert(document.getElementById('vehiclenum'+i).value);
if(document.getElementById('vehiclenum'+i)){
if(document.getElementById('vehiclenum'+i).value==''){
alert("Enter the Vehicle Number");
document.getElementById('vehiclenum'+i).focus();
return false;
}
}
}*/
}

$(document).ready(function(){
$('#lab_date').datepicker({
showOn: 'both',
buttonImage: 'icons_date/calendar.gif',
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
dateFormat: 'dd-mm-yy'
});
});	
</script>


<style>
.lableentrytext{
font-size: 12px;
color: #505050;
clear: both;
margin-bottom: 5px;
text-transform: capitalize;
}
</style>
</head>

<body>
<div class="wrapper">
  <div>
<?php 
	include("header.php");
?>
 
</div>
 
 
 <div class="tabbedArea">
  
  <div class="tabBody">
   <h1>Add Lab Test </h1>
   <form name="frmname" method="post" action="">
   <div class="addEmp" style="margin-bottom:0px; border-bottom:0px solid;width:1000px;">
        <table width="70%" border="0" cellspacing="0" cellpadding="10">
          <tr>
            <td valign="top">
           
        <div class="form1" >
            
         <div  class="select1">
        
        <h3>Passing Charge</h3>  {
				   <input type="radio" name="vehicletype" id="vehicletype" value="1" <?php if($vehicle_type==1){?> checked <?php } ?>> Big Vehicle ||
				  <input type="radio" name="vehicletype" id="vehicletype" value="2" <?php if($vehicle_type==2){?> checked <?php } ?>> Smail Vehicle }
         </div>
            
       <div>     
            <p class="input1">Passing Charge <span style="color:#FF3300">*</span></p>
            <select class="input1" name="pass_agent_id" id="pass_agent_id" >
     			<option value="">Passing Agent</option>
     			<?php 
					$sq_pass="select * from cf_passing";
					$arrpass=mysql_query($sq_pass);
					while($respass=mysql_fetch_array($arrpass))
					{
					?>     	
        				<option value="<?=$respass['pass_id']?>" <?php if($pass_agent_id==$respass['pass_id']){?> selected <?php } ?>><?=$respass['passname']?></option>
               		<?php
					}
	 				?>
     		</select>    
				
                  <input type="text" name="passing_chg" id="passing_chg" class="input1" style="width:75px;" value="<?=$passing_chg?>" >Rs
       </div>
       <br/>
	<div>     
	<p class="input1"><h3>Lab Result</h3></p>
	</div>
<?php $lab_year=date('Y',strtotime($lab_date));
          if($lab_year=="1970")$lab_date=""; ?>
	<div>     
	<p class="input1">Date<span style="color:#FF3300">*</span></p>
	<input type="text" name="lab_date" id="lab_date" style="width:100px;" maxlength="100" class="input1" value="<?=$lab_date?>" />
	</div> 

	<div>     
	<p class="input1">Bill No<span style="color:#FF3300">*</span></p>
	<input type="text" name="lab_bill_no" id="lab_bill_no" class="input1" value="<?=$lab_billnum?>" >
	</div>  


	<div>     
	<p class="input1">Quantity</p><input type="text" name="lab_quantity" id="lab_quantity" class="input1" value="<?=$lab_qty?>" >
	</div>




	</div>
	</td>
	<td valign="top"><div class="form1">
	<div>     
	<p class="input1">Bill Amount<span style="color:#FF3300">*</span></p>
	<input type="text" name="bill_amt" id="bill_amt" class="input1" value="<?=$lab_bill_amt?>" >
	</div>    

	<div>     
	<p class="input1">Company Name<span style="color:#FF3300">*</span></p>
	<input type="text" name="company_name" id="company_name" class="input1" value="<?=$lab_company?>" >
	</div> 

	<div>     
	<p class="input1">Vehicle No<span style="color:#FF3300">*</span></p>
	<input type="text" name="veh_no" id="veh_no" class="input1"  value="<?=$lab_vehicle_no?>" >
	</div> 

	<div>     
	<p class="input1">Lab Name<span style="color:#FF3300">*</span></p>
	<select class="input1" name="lab_agent_id" id="lab_agent_id" >
	<option value="">Lab Name</option>
	<?php 
	$sq_lab="select * from cf_lab_agent";
	$arrlab=mysql_query($sq_lab);
	while($reslab=mysql_fetch_array($arrlab))
	{
	?>     	
	<option value="<?=$reslab['lab_agent_id']?>" <?php if($lab_name==$reslab['lab_agent_id']){?> selected <?php } ?>><?=$reslab['labagent_name']?></option>
	<?php
	}
	?>
	</select>
	</div> 
		 
           <div>
            &nbsp;
            </div>
            </div></td>
          </tr>
           <tr>
            <td colspan="2"><div class="searchField1">
        
           
                <?php 
                 	if(empty($_REQUEST['lab_id']))
					{ ?>
					  <input type="submit" name="labtestsubmit" value="submit" class="submit-btn" onClick="return validation_1()"  >
                <?php } else { ?>
                	  <input type="submit" name="labtestedit" value="update" class="submit-btn" onClick="return validation_1()"  >
                <?php } ?>               
        </div>
        </td>
          </tr>
        </table>
 

<div class="mand"><p>Fields marked <span style="color:#FF3300">*</span> are Mandatory</p></div>
</div>
   </form>
   </div>
 </div>
 <div class="footer"><p>Powered by <a href="http://www.aadhocc.co.uk/" target="_blank">Aadhocc</a></p></div>
 
</div>
<div class="quicLInksCover">
 <?php 
	include("leftlink.php");
?>

</div>
</body>
</html>


		






