MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //home/cafsindia/refimac_cafsjobs_com/upd_details.php
<?php
include('dbconnect.php');
//session_start();
$user=$_SESSION['clid'];
$perm=$_SESSION['cper'];
$mid=$_REQUEST['mid'];
$smid=$_REQUEST['smid'];
$pid=$_REQUEST['pid'];
$comp_name=$_SESSION['comp_name'];

function rand_string($length) 
{
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return substr(str_shuffle($chars),0,$length);
}

function rand_image() 
{
$new_imgs=array();
$sql="select pic_name from etaapp_pics where status='Y'";
$qu=mysql_query($sql);
while($r=mysql_fetch_array($qu))array_push($new_imgs,$r['pic_name']);
shuffle($new_imgs);
return $new_imgs[0];
}

//Change Password Details
if($pid=="cpass")
{
	$opass=$_POST['opass'];
	$npass=$_POST['npass'];
	$rpass=$_POST['rpass'];
	$sqlt="select * from etaapp_login where user_name='".$user."' and status='Allowed'";
	$qut=mysql_query($sqlt);
	while($rt=mysql_fetch_array($qut))
	{
		$gopass=$rt['password'];
	}
	//echo $gopass;
	if($gopass===$opass)
	{
		if($npass===$rpass)
		{
			$sqlt="update etaapp_login set password='".$npass."' where user_name='".$user."' and status='Allowed'";
			if(mysql_query($sqlt)==1)
			{
			header("Location:home.php?pid=$pid&nav=0_4");
			}
			else
			{
			//echo mysql_error();
			header("Location:home.php?pid=$pid&nav=0_3");
			}
		}
		else
		{
			header("Location:home.php?pid=$pid&nav=0_2");
		}
	}
	else
	{
		header("Location:home.php?pid=$pid&nav=0_1");
	}
}


//update machine details
elseif($pid=="1_1_2")
{
$comp_id=$_POST['comp_id'];
$reg_id=$_POST['reg_id'];

$option_type=$_POST['option_type'];
$option1=explode(",",$option_type);
$brand_name=$option1[0];
$product_name=$option1[1];
$odu_model=$option1[2];
$odu_serialno=$option1[3];
$idu_model=$option1[4];
$idu_serialno=$option1[5];
$purchase_date=date("Y-m-d",strtotime($option1[6]));
$install_date=date("Y-m-d",strtotime($option1[7]));
$warranty_status=$option1[8];
$mac_warranty=$option1[9];
$comp_warranty=$option1[10];
$dealer_invoice=$option1[11];
$mac_status=$option1[12];


$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql1="update etaapp_callreg set brand_name='".$brand_name."',product_type='".$product_name."',model_desc='".$odu_model."' where  reg_id='".$reg_id."'";


$sql="update etaapp_callcomp set  odu_modelno='".$odu_model."' ,odu_serialno='".$odu_serialno."',idu_modelno='".$idu_model."',idu_serialno='".$idu_serialno."',purchase_date='".$purchase_date."',install_date='".$install_date."',warranty_status='".$warranty_status."',mac_warranty='".$mac_warranty."',comp_warranty='".$comp_warranty."',dealer_invoice='".$dealer_invoice."',mac_status='".$mac_status."', macupdate_user='".$user."', macupdate_time='".$update_time."' where comp_id='".$comp_id."'";
//echo $sql;

if(mysql_query($sql)==1)
{

mysql_query($sql1);
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=$opt");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}


//Block / UnBlock Users
elseif($pid=="6_1_3")
{
$access_user=$_POST['access_user'];
$access_st1=$_POST['access_st1'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

if($access_st1=="Allowed") {$status="Denied"; $opt=2;}
elseif($access_st1=="Denied") {$status="Allowed";$opt=1;}

$sql="update serviceapp_login set status='".$status."', update_user='".$user."', update_time='".$update_time."' where user_name='".$access_user."'";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:landing.php?mid=$mid&smid=$smid&pid=$pid&nav=1");
}
else
{
//echo mysql_error();
header("Location:landing.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}


//Recovery User Password
elseif($pid=="6_1_4")
{
$access_user=$_POST['access_user'];
$access_st1=$_POST['access_st1'];
$password=$_POST['pass'];


$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update serviceapp_login set password='".$password."', img_auth='".$img_auth."', update_user='".$user."', update_time='".$update_time."' where user_name='".$access_user."'";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:landing.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}

//Page Master
elseif($pid=="6_1_5")
{
$page_id=$_POST['page_id'];
$menu=$_POST['menu'];
$menu1=$_POST['menu1'];
$submenu=$_POST['submenu'];
$submenu1=$_POST['submenu1'];
$page_name=$_POST['page_name'];
$but_add=$_POST['but_add'];
$but_upd=$_POST['but_upd'];
$but_del=$_POST['but_del'];
$but_view=$_POST['but_view'];
$but_admin=$_POST['but_admin'];
$refer=$_POST['refer'];
$ap_id=$_POST['ap_id'];
$remarks=$_POST['remarks'];
$open_date=date("Y-m-d",strtotime($_POST['open_date']));

if($menu=="Other") $menu_name=$menu1;else $menu_name=$menu;
if($submenu=="Other") $submenu_name=$submenu1;else $submenu_name=$submenu;

$ava_trans=$but_add."|".$but_upd."|".$but_del."|".$but_view."|".$but_admin;

$time_now=time(date('h')+5,date('i')+30,date('s')); 
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update serviceapp_pages set menu_name='".$menu_name."', submenu_name='".$submenu_name."', page_name='".$page_name."', ava_trans='".$ava_trans."', refer_name='".$refer."', ap_id='".$ap_id."', remarks='".$remarks."', update_by='".$user."', update_date='".date("Y-m-d")."' where page_id=".$page_id."";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:landing.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
//echo mysql_error();
header("Location:landing.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}

//User Creation
elseif($pid=="6_1_2")
{

$user_name=$_POST['user_name'];
$password=$_POST['password'];
$permission=$_POST['permission'];
//$img_auth=$_POST['img_auth'];
//$permission1=$_POST['permission1'];

if($_POST['permission']=="Others") $perm=$_POST['permission1']; else $perm=$_POST['permission'];

/*$company=$_POST['brand'];
$companys="";
$count=count($company);
for($i=0;$i<$count;$i++)
{
if($company[$i]!=="on")
{
if($companys!="") $companys=$companys.",".$company[$i]; else $companys=$company[$i];
}
}

$etacompany=$_POST['etacomp'];
$etacompanys="";
$count=count($etacompany);
for($i=0;$i<$count;$i++)
{
if($etacompany[$i]!=="on")
{
if($etacompanys!="") $etacompanys=$etacompanys.",".$etacompany[$i]; else $etacompanys=$etacompany[$i];
}
}

$branch=$_POST['branch'];
$branchs="";
$count=count($branch);
for($i=0;$i<$count;$i++)
{
if($branch[$i]!=="on")
{
if($branchs!="") $branchs=$branchs.",".$branch[$i]; else $branchs=$branch[$i];
}
}*/




$pids=$_POST['pids'];
$pid1="";
$trans="";
foreach($pids as $key=>$value)
{
	//Collect the Page Ids
	if($pid1!="") $pid1=$pid1.",".$value; else $pid1=$value;
	
	//Collect the Page Transactions
	$con1="opt".$value;
	$t1=$_POST[$con1];
	if(count($t1)>0)
	{
	foreach($t1 as $key1=>$value1)
	{$product=$_POST['product'];
$products="";
$count=count($product);
for($i=0;$i<$count;$i++)
{
if($product[$i]!=="on")
{
if($products!="") $products=$products.",".$product[$i]; else $products=$product[$i];
}
}
		if($trans!="") $trans=$trans.",".$value1; else $trans=$value1;
	}
	}
	$con2="opt".$value."1";
	$t2=$_POST[$con2];
	if(count($t2)>0)
	{
	foreach($t2 as $key1=>$value1)
	{
		if($trans!="") $trans=$trans.",".$value1; else $trans=$value1;
	}
	}
}

$restrict=$_POST['restrict'];

if($restrict=="Denied") $status1='Denied'; else $status1='Allowed';

//echo $pid1;
$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update serviceapp_login set password='".$password."', pid='".$pid1."', trans='".$trans."', per='".$perm."', status='".$status1."', update_user='".$user."', update_date='".date("Y-m-d")."', update_time='".$update_time."' where user_name='".$user_name."'";
//echo $sql;


if(mysql_query($sql)==1)
{
header("Location:landing.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
//echo mysql_error();
header("Location:landing.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}

//Access Level Creation
elseif($pid=="6_1_1")
{

$per1=$_POST['per1'];

$pids=$_POST['pids'];
$pid1="";
$trans="";
foreach($pids as $key=>$value)
{
	//Collect the Page Ids
	if($pid1!="") $pid1=$pid1.",".$value; else $pid1=$value;
	
	//Collect the Page Transactions
	$con1="opt".$value;
	$t1=$_POST[$con1];
	if(count($t1)>0)
	{
	foreach($t1 as $key1=>$value1)
	{
		if($trans!="") $trans=$trans.",".$value1; else $trans=$value1;
	}
	}
	$con2="opt".$value."1";
	$t2=$_POST[$con2];
	if(count($t2)>0)
	{
	foreach($t2 as $key1=>$value1)
	{
		if($trans!="") $trans=$trans.",".$value1; else $trans=$value1;
	}
	}
}
//echo $pid1;
$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update serviceapp_levels set pid='".$pid1."', trans='".$trans."', update_by='".$user."', update_time='".$update_time."' where level_name='".$per1."'";
//echo $sql;


if(mysql_query($sql)==1)
{
header("Location:landing.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
//echo mysql_error();
header("Location:landing.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}


//Branch Master
elseif($pid=="7_1_1")
{
$branch_id=$_POST['branch_id'];
$branch_code=$_POST['branch_code'];
$branch_name=$_POST['branch_name'];
$oper_incharge=$_POST['oper_incharge'];
$district=$_POST['district'];
$address=$_POST['address'];
$area_name=$_POST['area_name'];
$pincode=$_POST['pincode'];
$state_name=$_POST['state_name'];
$mobile_no=$_POST['mobile_no'];
$phone_no=$_POST['phone_no'];
$fax_no=$_POST['fax_no'];
$email_id=$_POST['email_id'];
$region_name=$_POST['region_name'];
$clint_id=$_POST['clint_id'];
$zone_id=$_POST['zone_id'];
$internal_zonecode=$_POST['internal_zonecode'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_branchs set branch_code='".$branch_code."', branch_name='".$branch_name."', oper_incharge='".$oper_incharge."', district='".$district."', address='".$address."', area_name='".$area_name."', pincode='".$pincode."', state_name='".$state_name."', mobile_no='".$mobile_no."', phone_no='".$phone_no."', fax_no='".$fax_no."', email_id='".$email_id."', region_name='".$region_name."', clint_id='".$clint_id."', zone_id='".$zone_id."', internal_zonecode='".$internal_zonecode."', update_by='".$user."', update_time='".$update_time."' where branch_id=".$branch_id."";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}

//Employee Master
elseif($pid=="7_1_2")
{
$employee_id=$_POST['emp_id1'];
$emp_name=$_POST['emp_name'];
$region=$_POST['oper_incharge'];
$branch=$_POST['store_incharge'];
$dob=date("Y-m-d",strtotime($_POST['dob']));
$doj=date("Y-m-d",strtotime($_POST['doj']));
$department=$_POST['department'];
$designation=$_POST['designation'];
$address=$_POST['address'];
$area_name=$_POST['area_name'];
$pincode=$_POST['pincode'];
$state_name=$_POST['state_name'];
$mobile=$_POST['mobile'];
$email_id=$_POST['email_id'];
$norms=$_POST['norms'];
$bike_status=$_POST['bike_status'];
$group_leader=$_POST['group_leader'];
$emp_status=$_POST['emp_status'];
$sms_status=$_POST['sms_status'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_employee set emp_name='".$emp_name."', region_name='".$region_name."', branch_name='".$branch_name."', dob='".$dob."', doj='".$doj."', department='".$department."', designation='".$designation."', address='".$address."', area_name='".$area_name."', pincode='".$pincode."', state_name='".$state_name."', mobile='".$mobile."', email_id='".$email_id."', norms='".$norms."', bike_status='".$bike_status."', group_leader='".$group_leader."', act_status='".$act_status."', sms_status='".$sms_status."', update_by='".$user."', update_time='".$update_time."' where emp_id=".$employee_id."";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
echo mysql_error();
//header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}


//Area Master
elseif($pid=="7_1_3")
{
$area_id=$_POST['area_id'];
$area_code=$_POST['area_code'];
$town_name=$_POST['town_name'];
$area_name=$_POST['area_name'];
$pincode=$_POST['pincode'];
$subarea=$_POST['subarea'];
$district=$_POST['district'];
$branch_code=$_POST['branch_code'];
$distance=$_POST['distance'];
$area_status=$_POST['area_status'];
$state_code=$_POST['state_code'];
$country=$_POST['country'];
$std_code=$_POST['std_code'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_areamaster set area_code=".$area_code.", town_name='".$town_name."', area_name='".$area_name."', pincode='".$pincode."', subarea='".$subarea."', district='".$district."', branch_code=".$branch_code.", distance=".$distance.", area_status='".$area_status."', state_code=".$state_code.", country='".$country."', std_code='".$std_code."', update_by='".$user."', update_time='".$update_time."' where area_id=".$area_id."";
echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=1");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=2");
}
}


//SF Master
elseif($pid=="7_1_4")
{
$sf_id=$_POST['sf_id'];
$branch_code=$_POST['branch_code'];
$employee_id=$_POST['employee_id'];
$employee_name=$_POST['employee_name'];
$address=$_POST['address'];
$category=$_POST['category'];
$emp_telno=$_POST['emp_telno'];
$dob=date("Y-m-d",strtotime($_POST['dob']));
$doj=date("Y-m-d",strtotime($_POST['doj']));
$wbike=$_POST['wbike'];
$active_status=$_POST['active_status'];
$area_id=$_POST['area_id'];
$norms=$_POST['norms'];
$qualification=$_POST['qualification'];
$mobile_no=$_POST['mobile_no'];
$groupleader_status=$_POST['groupleader_status'];
$group_name=$_POST['group_name'];
$dealer_code=$_POST['dealer_code'];
$allow_sms=$_POST['allow_sms'];
$license_no=$_POST['license_no'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_sfmaster set branch_code='".$branch_code."', employee_id='".$employee_id."', employee_name='".$employee_name."', address='".$address."', category='".$category."', emp_telno='".$emp_telno."', dob='".$dob."', doj='".$doj."', wbike='".$wbike."', active_status='".$active_status."', area_id='".$area_id."', norms='".$norms."', qualification='".$qualification."', mobile_no='".$mobile_no."', groupleader_status='".$groupleader_status."', group_name='".$group_name."', dealer_code='".$dealer_code."', allow_sms='".$allow_sms."', license_no='".$license_no."', update_by='".$user."', update_time='".$update_time."' where sf_id=".$sf_id."";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}


//Dealer Master
elseif($pid=="7_1_5")
{

$dealer_id=$_POST['dealer_id'];
$company_name=$_POST['company_name'];
$dealer_code=$_POST['dealer_code'];
$region_name=$_POST['region_name'];
$branch_name=$_POST['branch_name'];
$brand_name=$_POST['brand_name'];
$dealer_product=$_POST['dealer_product'];
$cfa_id=$_POST['cfa_id'];
$dealer_type=$_POST['dealer_type'];
$dealer_name=$_POST['dealer_name'];
$address=$_POST['address'];
$city=$_POST['city'];
$pincode=$_POST['pincode'];
$phone_no=$_POST['phone_no'];
$fax_no=$_POST['fax_no'];
$email_id=$_POST['email_id'];
$person_name=$_POST['person_name'];
$mobile_no=$_POST['mobile_no'];
$pan_no=$_POST['pan_no']; 
$self_agent=$_POST['self_agent'];	
$rev_dealer_type=$_POST['rev_dealer_type'];
$sms=$_POST['sms'];
$service_tax=$_POST['service_tax'];
$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_dealer set company_name='".$company_name."', dealer_code='".$dealer_code."', region_name='".$region_name."', branch_name='".$branch_name."', brand_name='".$brand_name."', dealer_product='".$dealer_product."', cfa_id='".$cfa_id."', dealer_type='".$dealer_type."',rev_dealer_type='".$rev_dealer_type."',dealer_name='".$dealer_name."', address='".$address."', city='".$city."', pincode='".$pincode."', phone_no='".$phone_no."', fax_no='".$fax_no."', email_id='".$email_id."', person_name='".$person_name."', mobile_no='".$mobile_no."', pan_no='".$pan_no."', self_agent='".$self_agent."', update_by='".$user."', update_time='".$update_time."',sms='".$sms."',service_tax='".$service_tax."' where dealer_id=".$dealer_id."";
echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}



//Region Master
elseif($pid=="7_1_6")
{
$region_id=$_POST['region_id'];
$region_code=$_POST['region_code'];
$region_name=$_POST['region_name'];
$oper_incharge=$_POST['oper_incharge'];
$store_incharge=$_POST['store_incharge'];
$address=$_POST['address'];
$area_name=$_POST['area_name'];
$pincode=$_POST['pincode'];
$state_name=$_POST['state_name'];
$mobile_no=$_POST['mobile_no'];
$tele_no=$_POST['tele_no'];
$fax_no=$_POST['fax_no'];
$email_id=$_POST['email_id'];
$zone_name=$_POST['zone_name'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_region set region_code='".$region_code."', region_name='".$region_name."', oper_incharge='".$oper_incharge."', store_incharge='".$store_incharge."', address='".$address."', area_name='".$area_name."', pincode='".$pincode."', state_name='".$state_name."', mobile_no='".$mobile_no."', tele_no='".$tele_no."', fax_no='".$fax_no."', email_id='".$email_id."', zone_name='".$zone_name."', update_by='".$user."', update_time='".$update_time."' where region_id=".$region_id."";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
echo mysql_error();
//header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}

//SF Allocation Master
elseif($pid=="7_1_7")
{
$dealer_id=$_POST['dealer_id'];
$served_pincodes=$_POST['served_pincodes'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_dealer set served_pincodes='".$served_pincodes."' where dealer_id=".$dealer_id."";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}


//Customer Master
elseif($pid=="7_1_8")
{
$reg_id=$_POST['reg_id'];
$call_type=$_POST['call_type1'];
$region_name=$_POST['region_name'];
$state_name=$_POST['state_name'];
$branch_name=$_POST['branch_name'];
$complaint_no=$_POST['complaint_no'];
$complaint_date=date("Y-m-d",strtotime($_POST['complaint_date']));
$cust_code=$_POST['cust_code'];
$invoice_no=$_POST['invoice_no'];
$cust_name=$_POST['cust_name'];
$title_name=$_POST['title_name'];
$reg_mobile=$_POST['reg_mobile'];
$alt_mobile=$_POST['alt_mobile'];
$address=$_POST['address'];
$address1=$_POST['address1'];
$city_name=$_POST['city_name'];
$area_name=$_POST['area_name'];
$district_name=$_POST['district'];
$pincode=$_POST['pincode'];
$landmark=$_POST['landmark'];
$spl_instruction=$_POST['spl_instruction'];
$email_id=$_POST['email_id'];
$brand_name=$_POST['brand_name'];
$product_type=$_POST['product_type'];
$model_no=$_POST['model_no'];
$model_desc=$_POST['model_desc'];
$purchase_from=$_POST['purchase_from'];
if($purchase_from=="Others")$purchase_from=$_POST['purchase_from1'];
$allocate=$_POST['allocate'];
if($allocate=="SF")$allocate_to=$_POST['allocate_to1'];
elseif($allocate=="SSD")$allocate_to=$_POST['allocate_to2'];
elseif($allocate=="Sub Dealer")$allocate_to=$_POST['allocate_to3'];
$srequest_date=$_POST['srequest_date'];
$install_date=$_POST['install_date'];
$warranty_status=$_POST['warranty_status'];
$amc_no=$_POST['amc_no'];
$amc_date=$_POST['amc_date'];
$call_option=$_POST['call_option'];
$fault_report=$_POST['fault_report'];
$cust_spares=$_POST['cust_spares'];
$repeat_type=$_POST['repeat_type'];
$remarks=$_POST['remarks'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");

$update_time=$from1.", ".$time;

//$sql="update etaapp_customers set cust_code='".$cust_code."', sap_code='".$sap_code."', cust_name='".$cust_name."', title_name='".$title_name."', reg_mobileno='".$reg_mobileno."', alt_mobileno='".$alt_mobileno."', address1='".$address1."', address2='".$address2."', address3='".$address3."', address4='".$address4."', landmark='".$landmark."', area_name='".$area_name."', district='".$district."', pincode='".$pincode."', branch_name='".$branch_name."', state_name='".$state_name."', email_id='".$email_id."', spl_instruction='".$spl_instruction."', update_by='".$user."', update_time='".$update_time."' where reg_id='".$reg_id."'";

//$sql="update etaapp_callreg set  region_name='".$region_name."', state_name='".$state_name."', branch_name='".$branch_name."', cust_name='".$cust_name."', title_name='".$title_name."', reg_mobile='".$reg_mobile."', alt_mobile='".$alt_mobile."', address='".$address."', address1='".$address1."', area_name='".$area_name."', district_name='".$district_name."', pincode='".$pincode."', landmark='".$landmark."',email_id='".$email_id."',update_by1='".$user."', update_time1='".$update_time."' where cust_code=".$cust_code." and reg_mobile='".$reg_mobile."'";

$sql="update etaapp_callreg set  region_name='".$region_name."', state_name='".$state_name."', branch_name='".$branch_name."', cust_name='".$cust_name."', title_name='".$title_name."', update_by1='".$user."', update_time1='".$update_time."' where cust_code='".$cust_code."' and reg_mobile='".$reg_mobile."'";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}


//Symptom Master
elseif($pid=="7_1_10")
{
$symptom_id=$_POST['symptom_id'];
$product_type=$_POST['product_type'];
$symptom_type=$_POST['symptom_type'];
$symptom_code=$_POST['symptom_code'];
$symptom_name=$_POST['symptom_name'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_symptom set product_type='".$product_type."', symptom_type='".$symptom_type."', symptom_code='".$symptom_code."', symptom_name='".$symptom_name."', update_by='".$user."', update_time='".$update_time."' where symptom_id=".$symptom_id."";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
echo mysql_error();
//header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}


//Dealer Type Master
elseif($pid=="7_1_12")
{
$dtype_id=$_POST['dtype_id'];
$dealer_type=$_POST['dealer_type'];
$sap_dealer=$_POST['sap_dealer'];
$remarks=$_POST['remarks'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_dealertype set dealer_type='".$dealer_type."',sap_dealer='".$sap_dealer."',remarks='".$remarks."', update_by='".$user."', update_time='".$update_time."' where dtype_id=".$dtype_id."";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
echo mysql_error();
//header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}

//Item Master
/*
elseif($pid=="7_1_13")
{

$item_id=$_POST['item_id'];
$item_code=$_POST['item_code'];
$item_name=$_POST['item_name'];
$brand_name=$_POST['brand_name'];
$product_type=$_POST['product_type'];
$model_code=$_POST['model_code'];
$item_group=$_POST['item_group'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_items set item_code='".$item_code."', item_name='".$item_name."', brand_name='".$brand_name."', product_type='".$product_type."', model_code='".$model_code."', item_group='".$item_group."', update_by='".$user."', update_time='".$update_time."' where item_id=".$item_id."";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=1");
}
else
{
echo mysql_error();
//header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=2");
}
}
*/

//Spare Master
elseif($pid=="7_1_13")
{
$spare_id=$_POST['spare_id'];
$brand_name=$_POST['brand_name'];
$product_type=$_POST['product_type'];
$unit_type=$_POST['unit_type'];
$series_type=$_POST['series_type'];
$model_no=$_POST['model_no'];
$spare_name=$_POST['spare_name'];
$mfg_partcode=$_POST['mfg_partcode'];
$sap_partcode=$_POST['sap_partcode'];
$altmfg_partcode=$_POST['altmfg_partcode'];
$altsap_partcode=$_POST['altsap_partcode'];
$spare_class=$_POST['spare_class'];
$dealer_price=$_POST['dealer_price'];
$cust_price=$_POST['cust_price'];
$lead_time=$_POST['lead_time'];

if($dealer_price=="")$dealer_price=0;
if($cust_price=="")$cust_price=0;
if($lead_time=="")$lead_time=0;

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_sparemaster set brand_name='".$brand_name."', product_type='".$product_type."', unit_type='".$unit_type."', model_no='".$model_no."', spare_name='".$spare_name."', series_type='".$series_type."', mfg_partcode='".$mfg_partcode."', sap_partcode='".$sap_partcode."',altmfg_partcode='".$altmfg_partcode."',altsap_partcode='".$altsap_partcode."',spare_class='".$spare_class."', dealer_price='".$dealer_price."', cust_price='".$cust_price."', lead_time='".$lead_time."', update_by='".$user."', update_time='".$update_time."' where spare_id='".$spare_id."'";
echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=1");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=2");
}
}



//Zone Master
elseif($pid=="7_1_14")
{
$model_id=$_POST['model_id'];
$series=$_POST['series'];
$model_no=$_POST['model_no'];
$collin_kw=$_POST['collin_kw'];
$gascharge_qty=$_POST['gascharge_qty'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etapp_vrfmaster set series='".$series."', model_no='".$model_no."', collin_kw='".$collin_kw."', gascharge_qty='".$gascharge_qty."',update_by='".$user."', update_time='".$update_time."' where model_id=".$model_id."";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}

//Location master
elseif($pid=="7_1_15")
{
$loc_id=$_REQUEST['loc_id'];
$country="India";
$state=$_POST['state'];
$district=$_POST['district'];
$location=$_POST['location'];
$pincode=$_POST['pincode'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;
$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update location_master set country='".$country."', state='".$state."', district='".$district."', location='".$location."', pincode='".$pincode."',status='Y' where loc_id='".$loc_id."'";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}


//Company Master
elseif($pid=="7_1_16")
{
$comp_id=$_POST['comp_id'];
$comp_name=$_POST['comp_name'];

$brand=$_POST['brand'];
$brands="";
$count=count($brand);
for($i=0;$i<$count;$i++)
{
if($brand[$i]!=="on")
{
if($brands!="") $brands=$brands.",".$brand[$i]; else $brands=$brand[$i];
}
}

$remarks=$_POST['remarks'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_company set comp_name='".$comp_name."', brand_name='".$brands."', remarks='".$remarks."', update_by='".$user."', update_time='".$update_time."' where comp_id=".$comp_id."";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
echo mysql_error();
//header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}






//Brand Name Master
elseif($pid=="7_2_1")
{
$brand_id=$_POST['brand_id'];
$brand_name=$_POST['brand_name'];

$product=$_POST['product'];
$products="";
$count=count($product);
for($i=0;$i<$count;$i++)
{
if($product[$i]!=="on")
{
if($products!="") $products=$products.",".$product[$i]; else $products=$product[$i];
}
}

$remarks=$_POST['remarks'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_brand set brand_name='".$brand_name."', product_type='".$products."', remarks='".$remarks."', update_by='".$user."', update_time='".$update_time."' where brand_id=".$brand_id."";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
echo mysql_error();
//header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}

//Product Type Master
elseif($pid=="7_2_2")
{
$product_id=$_POST['product_id'];
$product_name=$_POST['product_name'];
$remarks=$_POST['remarks'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_products set product_name='".$product_name."', remarks='".$remarks."', update_by='".$user."', update_time='".$update_time."' where product_id=".$product_id."";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}

//MODEL MASTER
elseif($pid=="7_2_3")
{
$comp_id=$_POST['comp_id'];
$brand_name=$_POST['brand_name'];
$product_type=$_POST['product_type'];
$idu_modelno=$_POST['idu_modelno'];
$odu_modelno=$_POST['odu_modelno'];
$mfg_at=$_POST['mfg_at'];
$comp_type=$_POST['comp_type'];
$sap_code1=$_POST['sap_code1'];
$comp_make1=$_POST['comp_make1'];
$comp_model1=$_POST['comp_model1'];
$sap_code2=$_POST['sap_code2'];
$comp_make2=$_POST['comp_make2'];
$comp_model2=$_POST['comp_model2'];
$sap_code3=$_POST['sap_code3'];
$comp_make3=$_POST['comp_make3'];
$comp_model3=$_POST['comp_model3'];
$mac_warranty=$_POST['mac_warranty'];
$comp_warranty=$_POST['comp_warranty'];
$warrcomm_ssd=$_POST['warrcomm_ssd'];
$warrcomm_sf=$_POST['warrcomm_sf'];
$warrno_services=$_POST['warrno_services'];
$amc_labourrate=$_POST['amc_labourrate'];
$nonamc_comprrate=$_POST['nonamc_comprrate'];
$amc_comprrate=$_POST['amc_comprrate'];
$amcno_services=$_POST['amcno_services'];
$serial_len=$_POST['serial_len'];
$tonnage=$_POST['tonnage'];
$sap_labourcode=$_POST['sap_labourcode'];
$sap_noncomprcode=$_POST['sap_noncomprcode'];
$sap_comprcode=$_POST['sap_comprcode'];


$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_compressormaster set brand_name='".$brand_name."',product_type='".$product_type."',idu_modelno='".$idu_modelno."',odu_modelno='".$odu_modelno."',mfg_at='".$mfg_at."',comp_type='".$comp_type."',sap_code1='".$sap_code1."',comp_make1='".$comp_make1."',comp_model1='".$comp_model1."',sap_code2='".$sap_code2."',comp_make2='".$comp_make2."',comp_model2='".$comp_model2."',sap_code3='".$sap_code3."',comp_make3='".$comp_make3."',comp_model3='".$comp_model3."',mac_warranty='".$mac_warranty."',comp_warranty='".$comp_warranty."',warrcomm_ssd='".$warrcomm_ssd."',warrcomm_sf='".$warrcomm_sf."',warrno_services='".$warrno_services."',amc_labourrate='".$amc_labourrate."',nonamc_comprrate='".$nonamc_comprrate."',amc_comprrate='".$amc_comprrate."',amcno_services='".$amcno_services."',serial_len='".$serial_len."',tonnage='".$tonnage."', sap_labourcode='".$sap_labourcode."',sap_noncomprcode='".$sap_noncomprcode."',sap_comprcode='".$sap_comprcode."',update_by='".$user."', update_time='".$update_time."' where comp_id=".$comp_id."";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}




elseif($pid=="7_2_4")
{
$vrf_srid=$_POST['vrf_srid'];
$vrf_series=$_POST['vrf_series'];
$unit_type=$_POST['unit_type'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_vrftypes set vrf_series='".$vrf_series."', unit_types='".$unit_type."', update_by='".$user."', update_time='".$update_time."' where vrf_srid=".$vrf_srid."";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=1");
}
else
{
echo mysql_error();
//header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=2");
}
}


elseif($pid=="7_2_5")
{
$odu_modelno=$_POST['odu_modelno'];
$odu_serialno=$_POST['odu_serialno'];

$sql124="select * from customerproductmaster where Model_ID='".$odu_modelno."' and  Serial_No='".$odu_serialno."'";
//echo $sql124;
$qu124=mysql_query($sql124);
$rows=mysql_num_rows($qu124);
//echo $rows;
if($rows==1)
{
$r124=mysql_fetch_assoc($qu124);
$cust_code=$r124['Customer_Code'];
$f_date=str_replace('/','-',$r124['Inst_Dt']);
$inst_date=date('Y-m-d', strtotime($f_date));
$p_date=str_replace('/','-',$r124['Purchase_Date']);
$obj->purchase_date=date('Y-m-d', strtotime($p_date));
$purchase_date=date('Y-m-d', strtotime($p_date));
$pur_date=date("Y-m-d",strtotime($purchase_date));
$odu_model=$r124['Model_ID'];
$sqlpur="select mac_warranty,comp_warranty,brand_name from etaapp_compressormaster where odu_modelno='".$odu_model."'";
$qupur=mysql_query($sqlpur);
while ($rpur=mysql_fetch_assoc($qupur))
{
$obj->mac=$rpur['mac_warranty'];
$mac=$rpur['mac_warranty'];
$obj->comp=$rpur['comp_warranty'];
$comp=$rpur['comp_warranty'];
$obj->brand_name=$rpur['brand_name'];
$brand_name=$rpur['brand_name'];
}
$m_days=($mac * 365)-1;
$c_days=($comp * 365)-1;
$m_days=$m_days." ".'days';
$c_days=$c_days." ".'days';
$value="";
$mac_date1=str_replace('-','/',$pur_date);
if((date('Y-m-d', strtotime($pur_date. '+' .$m_days))) > date("Y-m-d"))
$warranty_status="In Warranty"; 
else 
$warranty_status="Out Of Warranty";
$mac_date1=str_replace('-','/',$pur_date);
$mac_date=date("d-m-Y",strtotime($mac_date1.  '+' .$m_days));
echo $mac_date;
$obj->mac_warranty=$mac_date;
$comp_date=date('d-m-Y', strtotime($mac_date1. '+' .$c_days ));
echo $comp_date;
$obj->comp_warranty=$comp_date;

//$sql1="SELECT * FROM etaapp_callcomp inner join  etaapp_callreg on etaapp_callcomp.reg_id=etaapp_callreg.reg_id WHERE odu_modelno='".$odu_modelno."' and  odu_serialno='".$odu_serialno."' and cust_code='".$cust_code."'";
$sql1="SELECT * FROM etaapp_callcomp inner join  etaapp_callreg on etaapp_callcomp.reg_id=etaapp_callreg.reg_id WHERE odu_modelno='".$odu_modelno."' and  odu_serialno='".$odu_serialno."' ";

//echo $sql1;
$qu1=mysql_query($sql1);

$r12=mysql_fetch_array($qu1);

$comp_id=$r12['comp_id'];

$sql13="update etaapp_callcomp set purchase_date='".$pur_date."',install_date='".$inst_date."',mac_warranty='".$mac_date."',comp_warranty='".$comp_date."',warranty_status='".$warranty_status."'
 where  comp_id='".$comp_id."'";

//echo $sql13;
if(mysql_query($sql13)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=1");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=2");
}
}
else
{
echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=2");
}

}


//vrf basic info ii
elseif($pid=="7_3_2")
{
$vrf_basicid=$_POST['vrf_basicid'];
$vrf_header1=$_POST['vrf_header1'];
$vrf_header2=$_POST['vrf_header2'];
$vrf_series=$_POST['vrf_series'];

$time=date('h:i:s');
$from1=date("d-M-Y");
$update_time=$from1." ".$time;

$sql="update etaapp_vrfbasic set vrf_header1='".$vrf_header1."', vrf_header2='".$vrf_header2."',vrf_series='".$vrf_series."', update_by='".$user."', update_time='".$update_time."' where vrf_basicid='".$vrf_basicid."'";
//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}


//Call Registration Details
elseif($pid=="2_1_1")
{
$reg_id=$_POST['reg_id'];
$call_type=$_POST['call_type1'];
$region_name=$_POST['region_name'];
$state_name=$_POST['state_name'];
$branch_name=$_POST['branch_name'];
$complaint_no=$_POST['complaint_no'];
$complaint_date=date("Y-m-d",strtotime($_POST['complaint_date']));
$cust_code=$_POST['cust_code'];
$invoice_no=$_POST['invoice_no'];
$cust_name=$_POST['cust_name'];
$title_name=$_POST['title_name'];
$reg_mobile=$_POST['reg_mobile'];
$alt_mobile=$_POST['alt_mobile'];
$address=$_POST['address'];
$address1=$_POST['address1'];
$city_name=$_POST['city_name'];
$area_name=$_POST['area_name'];
$district_name=$_POST['district'];
$pincode=$_POST['pincode'];
$landmark=$_POST['landmark'];
$spl_instruction=$_POST['spl_instruction'];
$email_id=$_POST['email_id'];
$brand_name=$_POST['brand_name'];
$product_type=$_POST['product_type'];
$model_no=$_POST['model_no'];
$model_desc=$_POST['model_desc'];
$purchase_from=$_POST['purchase_from'];
if($purchase_from=="Others")$purchase_from=$_POST['purchase_from1'];
$allocate=$_POST['allocate'];
if($allocate=="SF")$allocate_to=$_POST['allocate_to1'];
elseif($allocate=="SSD")$allocate_to=$_POST['allocate_to2'];
elseif($allocate=="Sub Dealer")$allocate_to=$_POST['allocate_to3'];
$srequest_date=$_POST['srequest_date'];
$install_date=$_POST['install_date'];
$warranty_status=$_POST['warranty_status'];
$amc_no=$_POST['amc_no'];
$amc_date=$_POST['amc_date'];
$call_option=$_POST['call_option'];
$fault_report=$_POST['fault_report'];
$cust_spares=$_POST['cust_spares'];
$repeat_type=$_POST['repeat_type'];
$remarks=$_POST['remarks'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_callreg set call_type='".$call_type."', region_name='".$region_name."', state_name='".$state_name."', branch_name='".$branch_name."', complaint_no='".$complaint_no."', complaint_date='".$complaint_date."', complaint_time='".$complaint_time."', cust_code='".$cust_code."', cust_name='".$cust_name."', title_name='".$title_name."', reg_mobile='".$reg_mobile."', alt_mobile='".$alt_mobile."', address='".$address."', address1='".$address1."', area_name='".$area_name."', district_name='".$district_name."', pincode='".$pincode."', landmark='".$landmark."', spl_instruction='".$spl_instruction."', email_id='".$email_id."', brand_name='".$brand_name."', product_type='".$product_type."', model_desc='".$model_desc."', purchase_from='".$purchase_from."', allocate='".$allocate."', allocate_to='".$allocate_to."', srequest_date='".$srequest_date."', warranty_status='".$warranty_status."', fault_report='".$fault_report."', remarks='".$remarks."', update_by='".$user."', update_time='".$update_time."' where reg_id=".$reg_id."";

//$sql="update etaapp_callreg set call_type='".$call_type."',alt_mobile='".$alt_mobile."', address1='".$address1."', area_name='".$area_name."', district_name='".$district_name."', pincode='".$pincode."', landmark='".$landmark."', spl_instruction='".$spl_instruction."', email_id='".$email_id."', product_type='".$product_type."', model_desc='".$model_desc."', purchase_from='".$purchase_from."', allocate='".$allocate."', allocate_to='".$allocate_to."', fault_report='".$fault_report."', repeat_type='".$repeat_type."', remarks='".$remarks."', update_by1='".$user."', update_time1='".$update_time."' where reg_id=".$reg_id." ";

//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}


//Call Technician Allocation
elseif($pid=="2_1_5")
{
$allocate_to=$_POST['allocate_to'];
$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$allocate_id=$_POST[allocate_id];
//print_r($allocate_id);
$count1=count($allocate_id);
if($count1>0)
{
	foreach($allocate_id as $value1)
	{
	$sql="update etaapp_callreg set tech_allocate='".$allocate_to."', tech_update='".$user."', update_time1='".$update_time."', status='A' where reg_id=".$value1."";
	//echo $sql;
	$qu=mysql_query($sql);
	
	$sql1="insert etaapp_reallocate (reg_id, allocate, allocate_to, allocate_time, update_by, update_time, status) values (".$value1.", 'Technician', '".$allocate_to."', '".$update_time."', '".$user."', '".$update_time."', 'Y')";
	//echo $sql1;
	$qu1=mysql_query($sql1);
	}
}

header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=1&count=$count1");
}

//Call SF / Dealer Reallocation
elseif($pid=="2_1_2")
{
$reg_id=$_POST['reg_id'];
$allocate=$_POST['allocate'];
if($allocate=="SF")$allocate_to=$_POST['allocate_to1'];
elseif($allocate=="SSD")$allocate_to=$_POST['allocate_to2'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_callreg set allocate='".$allocate."', allocate_to='".$allocate_to."', update_by1='".$user."', update_time1='".$update_time."' where reg_id=".$reg_id."";
//echo $sql;
$qu=mysql_query($sql);

$sql1="insert etaapp_reallocate (reg_id, allocate, allocate_to, allocate_time, update_by, update_time, status) values (".$reg_id.", '".$allocate."', '".$allocate_to."', '".$update_time."', '".$user."', '".$update_time."', 'Y')";
//echo $sql1;
$qu1=mysql_query($sql1);

header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=1");
}


//Actual Serial No Updation
elseif($pid=="2_7_3")
{
$f_id=$_POST['f_id'];
$actual_serial=$_POST['actual_serial'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_factorysno set actual_serial='".$actual_serial."' where f_id=".$f_id."";
//echo $sql;
$qu=mysql_query($sql);

header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=1");
}

elseif($pid=="7_3_4")
{
$vrf_iduid=$_POST['vrf_iduid'];
$brand_name=$_POST['brand_name'];
$vrf_series=$_POST['vrf_series'];
$vrf_unittype=$_POST['vrf_unittype'];
$vrf_idumodel=$_POST['vrf_idumodel'];
$vrf_iducooling=$_POST['vrf_iducooling'];
$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update vrf_modelidukw set vrf_brandname='".$brand_name."',vrf_series='".$vrf_series."',vrf_unittype='".$vrf_unittype."',vrf_idumodel='".$vrf_idumodel."',vrf_iducooling='".$vrf_iducooling."' where vrf_iduid=".$vrf_iduid."";
//echo $sql;
$qu=mysql_query($sql);

header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=1");
}




//Call Spare Indent Entry
elseif($pid=="2_4_12")
{
$spareind_id=$_POST['spareind_id'];
$reg_id=$_POST['reg_id'];
$indent_type=$_POST['indent_type'];
$spare_type=$_POST['spare_type'];
$indent_date=$_POST['indent_date'];
$warranty_card=$_POST['warranty_card'];
$def_serialno=$_POST['def_serialno'];
$def_modelno=$_POST['def_modelno'];
$nature_defect=$_POST['nature_defect'];
$etainvoice_no=$_POST['etainvoice_no'];
if($etainvoice_no=="")$etainvoice_no="NIL";
$etainvoice_date=date("Y-m-d",strtotime($_POST['etainvoice_date']));
$custinvoice_no=$_POST['custinvoice_no'];
if($custinvoice_no=="")$custinvoice_no="NIL";
$custinvoice_date=date("Y-m-d",strtotime($_POST['custinvoice_date']));
$spares=$_POST['spares'];
$no_entry=$_POST['no_entry'];
$total_qty=$_POST['total_qty'];
$total_amount=$_POST['total_amount'];
$indent_date1=date("Y-m-d");

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_spareindent set indent_type='".$indent_type."', warranty_card='".$warranty_card."', spare_type='".$spare_type."', defcomp_serial='".$def_serialno."', defcomp_model='
".$def_modelno."', nature_defect='".$nature_defect."', eta_invoiceno='".$etainvoice_no."', eta_invoicedate='".$etainvoice_date."', cust_invoiceno='".$custinvoice_no."', cust_invoicedate='".$custinvoice_date."', no_entry=".$no_entry.", total_qty=".$total_qty.", total_amount=".$total_amount.", update_by='".$user."', update_time='".$update_time."' where spareind_id=".$spareind_id."";
//echo $sql;

if(mysql_query($sql)==1)
{

//Delete Previous Entry (Now Deleted Only)
$new_spares=array();
for($i=1;$i<=$no_entry;$i++)
{
$indspare_id=$_POST["indspare_id$i"];
array_push($indspare_id,$new_spares);
}

$ext_spares=array();
$sql3="select * from etaapp_spareinfo where spareind_id=".$spareind_id." and status='Y'";
$qu3=mysql_query($sql3);
while($qu3=mysql_fetch_array($qu3))
{
if(in_array($r3['spare_id'],$new_spares))
{
}
else
{
$sql2="update etaapp_spareinfo set status='N' where spareind_id=".$spareind_id." and spare_id=".$r3['spare_id']."";
$qu2=mysql_query($sql2);
}
}


for($i=1;$i<=$no_entry;$i++)
{

$indspare_id=$_POST["indspare_id$i"];
$ind_type=$_POST["ind_type$i"];
$idu_serial=$_POST["idu_serial$i"];
//$odu_serial=$_POST["odu_serial$i"];
$ind_qty=$_POST["ind_qty$i"];
$unit_price=$_POST["unit_price$i"];
$tot_amount=$_POST["tot_amount$i"];

	$sql3="select * from etaapp_spareinfo where spareind_id=".$spareind_id." and spare_id=".$indspare_id." and status='Y'";
	$qu3=mysql_query($sql3);
	if(mysql_num_rows($qu3)==1)
	{
	$sql2="update etaapp_spareinfo set idu_serial='".$idu_serial."', odu_serial='', ind_type='".$ind_type."', ind_qty=".$ind_qty.", unit_price=".$unit_price.", tot_amount=".$tot_amount.", update_by='".$user."', update_time='".$update_time."' where spareind_id=".$spareind_id." and spare_id=".$indspare_id."";
	$qu2=mysql_query($sql2);
	
	}
	else
	{
	$sql2="insert into etaapp_spareinfo (spareind_id, serial_no, spare_id, idu_serial, odu_serial, ind_type, ind_qty, unit_price, tot_amount, infoapp_status, infoapp_by, infoapp_time, update_by, update_time, status) values (".$spareind_id.", ".$i.", ".$indspare_id.", '".$idu_serial."', '', '".$ind_type."', ".$ind_qty.", ".$unit_price.", ".$tot_amount.", '', '', '', '".$user."', '".$update_time."', 'Y')";
	$qu2=mysql_query($sql2);
	}
//echo $sql2;
}
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}

// Spare Indent Branch Approval Entry
elseif($pid=="2_4_4")
{
$spareind_id=$_POST['spareind_id'];
$app_status=$_POST['app_status'];
if($app_status=="")$app_status="Updated";
$no_entry=$_POST['no_entry'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_spareindent set app_status='".$app_status."', app_by='".$user."', app_time='".$update_time."' where spareind_id=".$spareind_id."";
//echo $sql;

if(mysql_query($sql)==1)
{
$hold_entry=0;
$app_entry=0;
	for($i=1;$i<=$no_entry;$i++)
	{
	$spareinfo_id=$_POST["spareinfo_id$i"];
	$app_status1=$_POST["app_status1$i"];
	$app_status2=$_POST["app_status2$i"];
	$app_remarks1=$_POST["app_remarks1$i"];
	
	$sql2="update etaapp_spareinfo set infoapp_status='".$app_status1."',infoapp_status2='".$app_status2."', infoapp_remarks='".$app_remarks1."', infoapp_by='".$user."', infoapp_time='".$update_time."' where spareinfo_id=".$spareinfo_id." and spareind_id=".$spareind_id."";
	$qu2=mysql_query($sql2);
	if($app_status1=="Hold")
	{
	$hold_entry++;
	
	}
	else
	{
	$app_entry++;
	}
	
	
	//echo $sql2;
	//echo $sql3;
	}
	if($hold_entry!=0)
	{
	$sql3="update etaapp_spareindent set app_hold='Y' where spareind_id=".$spareind_id."";
	$qu3=mysql_query($sql3);
	}
	if($hold_entry==0)
	{
	$sql3="update etaapp_spareindent set app_hold='N' where spareind_id=".$spareind_id."";
	$qu3=mysql_query($sql3);
	}
	
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}

// Spare Indent HO Approval Entry
elseif($pid=="2_4_3")
{


$spareind_id=$_POST['spareind_id'];
$hoapp_status=$_POST['hoapp_status'];
$no_entry=$_POST['no_entry'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_spareindent set hoapp_status='".$hoapp_status."', hoapp_by='".$user."', hoapp_time='".$update_time."' where spareind_id=".$spareind_id."";
//echo $sql;

if(mysql_query($sql)==1)
{
$hold_entry=0;
$app_entry=0;
	for($i=1;$i<=$no_entry;$i++)
	{
	$spareinfo_id=$_POST["spareinfo_id$i"];
	$app_status1=$_POST["app_status1$i"];
	echo $app_status1;
	$app_remarks1=$_POST["app_remarks1$i"];
	
	$sql2="update etaapp_spareinfo set infohoapp_status='".$app_status1."', infohoapp_remarks='".$app_remarks1."', infohoapp_by='".$user."', infohoapp_time='".$update_time."' where spareinfo_id=".$spareinfo_id." and spareind_id=".$spareind_id."";
	
	//echo $sql2;
	
	if($app_status1=="Hold")
	{
	$hold_entry=$hold_entry+1;
	
	}
	else
	{
	$app_entry=$app_entry+1;
	}
	
	$qu2=mysql_query($sql2);
	}
	if($hold_entry!=0)
	{
	$sql3="update etaapp_spareindent set hoapp_hold='Y' where spareind_id=".$spareind_id."";
	//echo $sql;
	$qu3=mysql_query($sql3);
	}
	if($hold_entry==0)
	{
	$sql3="update etaapp_spareindent set hoapp_hold='N' where spareind_id=".$spareind_id."";
	$qu3=mysql_query($sql3);
	}
	
	 //echo $sql2;
	  //echo $sql3;
	  header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}

// Spare Indent HO Approval Entry
elseif($pid=="2_4_10")
{
$spareind_id=$_POST['spareind_id'];
$no_entry=$_POST['no_entry'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;
for($i=1;$i<=$no_entry;$i++)
{
$spareinfo_id=$_POST["spareinfo_id$i"];
$repapp_status1=$_POST["repapp_status1$i"];
$repapp_remarks1=$_POST["repapp_remarks1$i"];

$sql2="update etaapp_spareinfo set repapp_status='".$repapp_status1."', repapp_remarks='".$repapp_remarks1."', defapp_by='".$user."', defapp_time='".$update_time."' where spareinfo_id=".$spareinfo_id." and spareind_id=".$spareind_id."";
$qu2=mysql_query($sql2);
//echo $sql2;

}
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}


// Spare Factory Dispatch Entry
elseif($pid=="2_4_6")
{
$spareind_id=$_POST['spareind_id'];
$no_entry=$_POST['no_entry'];

$obd_number=$_POST['obd_number'];
$obd_date=date("Y-m-d",strtotime($_POST['obd_date']));
$finvoice_no=$_POST['finvoice_no'];
$finvoice_date=date("Y-m-d",strtotime($_POST['finvoice_date']));
$courier_name=$_POST['courier_name'];
$docket_no=$_POST['docket_no'];
$courier_date=date("Y-m-d",strtotime($_POST['courier_date']));

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;
//echo $no_entry;


$sql="insert into etaapp_facdispatch (spareind_id,obd_number,obd_date,finvoice_no,finvoice_date,courier_name,docket_no,courier_date,fupdate_by,fupdate_time,status) values (".$spareind_id.", '".$obd_number."', '".$obd_date."', '".$finvoice_no."','".$finvoice_date."','".$courier_name."','".$docket_no."','".$courier_date."','".$user."','".$update_time."','Y')";
//echo $sql;

if(mysql_query($sql)==1)
{
$dispatch_id=mysql_insert_id();
for($i=1;$i<=$no_entry;$i++)
{
$spareinfo_id=$_POST["spareinfo_id$i"];
$fac_status=$_POST["fac_status$i"];
$fac_remarks=$_POST["fac_remarks$i"];
if($fac_status=="Dispatch") $dispatch_id1=$dispatch_id; else $dispatch_id1="0";

	$sql4="select * from etaapp_spareinfo where spareinfo_id=".$spareinfo_id." and spareind_id=".$spareind_id." and status='Y' and fac_status!='Dispatch'";
	$qu4=mysql_query($sql4);
	if(mysql_num_rows($qu4)==1)
	{
	$sql2="update etaapp_spareinfo set fac_status='".$fac_status."', fac_remarks='".$fac_remarks."', facapp_by='".$user."', facapp_time='".$update_time."', dispatch_id=".$dispatch_id1." where spareinfo_id=".$spareinfo_id." and spareind_id=".$spareind_id."";
	$qu2=mysql_query($sql2);
	//echo $sql2;
	}
	}
	
	for($i=1;$i<=$no_entry;$i++)
{
$spareinfo_id=$_POST["spareinfo_id$i"];
$fac_status=$_POST["fac_status$i"];
$def_status=$_POST["def_status$i"];
$comp_serial=$_POST["comp_serial$i"];
$fac_remarks=$_POST["fac_remarks$i"];
if($def_status=="") $def_status="Not Required"; 


$sql5="select * from etaapp_spareinfo where spareinfo_id=".$spareinfo_id." and spareind_id=".$spareind_id." and status='Y'";
$qu5=mysql_query($sql5);
	if(mysql_num_rows($qu5)==1)
	{
	$sql6="update etaapp_spareinfo set def_status='".$def_status."',comp_serial='".$comp_serial."', defapp_by='".$user."', defapp_time='".$update_time."' where spareinfo_id=".$spareinfo_id." and spareind_id=".$spareind_id."";
	$qu6=mysql_query($sql6);
	echo $sql6;
	}

}

header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
echo mysql_error();
//header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}

// Spare branch Dispatch Entry
elseif($pid=="2_4_5")
{
$spareind_id=$_POST['spareind_id'];
$no_entry=$_POST['no_entry'];

$obd_number=$_POST['obd_number'];
$obd_date=date("Y-m-d",strtotime($_POST['obd_date']));
$finvoice_no=$_POST['finvoice_no'];
$finvoice_date=date("Y-m-d",strtotime($_POST['finvoice_date']));
$courier_name=$_POST['courier_name'];
$docket_no=$_POST['docket_no'];
$courier_date=date("Y-m-d",strtotime($_POST['courier_date']));

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;
//echo $no_entry;


$sql="insert into etaapp_brdispatch (spareind_id,obd_number,obd_date,finvoice_no,finvoice_date,courier_name,docket_no,courier_date,fupdate_by,fupdate_time,status) values (".$spareind_id.", '".$obd_number."', '".$obd_date."', '".$finvoice_no."','".$finvoice_date."','".$courier_name."','".$docket_no."','".$courier_date."','".$user."','".$update_time."','Y')";
echo $sql;

if(mysql_query($sql)==1)
{
$dispatch_id=mysql_insert_id();
for($i=1;$i<=$no_entry;$i++)
{
$spareinfo_id=$_POST["spareinfo_id$i"];
$br_dispatch=$_POST["br_dispatch$i"];
$br_remarks=$_POST["br_remarks$i"];
if($br_dispatch=="Dispatch") $dispatch_id1=$dispatch_id; else $dispatch_id1="0";

	$sql4="select * from etaapp_spareinfo where spareinfo_id=".$spareinfo_id." and spareind_id=".$spareind_id." and status='Y' and br_dispatch!='Dispatch'";
	$qu4=mysql_query($sql4);
	if(mysql_num_rows($qu4)==1)
	{
	$sql2="update etaapp_spareinfo set br_dispatch='".$br_dispatch."', br_remarks='".$br_remarks."', brapp_by='".$user."', brapp_time='".$update_time."', br_dispatchid=".$dispatch_id1." where spareinfo_id=".$spareinfo_id." and spareind_id=".$spareind_id."";
	$qu2=mysql_query($sql2);
	echo $sql2;
	}
	}
	
	for($i=1;$i<=$no_entry;$i++)
{
$spareinfo_id=$_POST["spareinfo_id$i"];
$doc_status=$_POST["doc_status$i"];
if($def_status=="") $def_status="Not Required"; 


$sql5="select * from etaapp_spareinfo where spareinfo_id=".$spareinfo_id." and spareind_id=".$spareind_id." and status='Y'";
$qu5=mysql_query($sql5);
	if(mysql_num_rows($qu5)==1)
	{
	$sql6="update etaapp_spareinfo set doc_status='".$doc_status."', docapp_by='".$user."', docapp_time='".$update_time."' where spareinfo_id=".$spareinfo_id." and spareind_id=".$spareind_id."";
	$qu6=mysql_query($sql6);
	echo $sql6;
	}

}

header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
echo mysql_error();
//header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}



//account Process
elseif($pid=="2_4_7")
{
$spareind_id=$_POST['spareind_id'];
$no_entry=$_POST['no_entry'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;
for($i=1;$i<=$no_entry;$i++)
{
$spareinfo_id=$_POST["spareinfo_id$i"];
$acc_status=$_POST["acc_status$i"];
$debit_note=$_POST["debit_note$i"];
$sap_docno=$_POST["sap_docno$i"];

//if($doc_status=="") $doc_status="Not Required";
//if($sap_docno=="") $sap_docno="Not Required";

$sql2="update etaapp_spareinfo set acc_status='".$acc_status."', debit_note='".$debit_note."',sap_docno='".$sap_docno."',accapp_by='".$user."', accapp_time='".$update_time."' where spareinfo_id=".$spareinfo_id." and spareind_id=".$spareind_id."";
$qu2=mysql_query($sql2);
echo $sql2;

}
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}


//new updation
//Call Technician Allocation live 8
elseif($pid=="2_1_8")
{
$allocate_to=$_POST['allocate_to'];
$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$allocate_id=$_POST[allocate_id];
//print_r($allocate_id);
$count1=count($allocate_id);
if($count1>0)
{
	foreach($allocate_id as $value1)
	{
	$sql="update etaapp_callreg set tech_allocate='".$allocate_to."', tech_update='".$user."', update_time1='".$update_time."', status='A' where reg_id=".$value1."";
	//echo $sql;
	$qu=mysql_query($sql);
	if($qu==1)
	{
	$sqld="select employee_name,dealer_code,mobile_no from `etaapp_sfmaster` where sf_id=".$allocate_to."";
	$sqld=mysql_query($sqld);
	$rd=mysql_fetch_assoc($sqld);
	$tech_name=$rd['employee_name'];
	$dealer_code=$rd['dealer_code'];
	$tech_mobile_no=$rd['mobile_no'];
	$sqldc="select mobile_no from `etaapp_dealer` where dealer_code=".$dealer_code." and status='Y'";
	$sqldc=mysql_query($sqldc);
	$rc=mysql_fetch_assoc($sqldc);
	$mobile_no=$rc['mobile_no'];
	
	$sqls="select complaint_no,brand_name,reg_mobile,call_type,cust_name,area_name,landmark from etaapp_callreg where reg_id=".$value1."";
	$sql=mysql_query($sqls);
	$r=mysql_fetch_assoc($sql);
	$complaint_no=$r['complaint_no'];
	$call_type=$r['call_type'];
	$brand_name=$r['brand_name'];
	$reg_mobile=$r['reg_mobile'];
	$cust_name=$r['cust_name'];
	$area_name=$r['area_name'];
	$landmark=$r['landmark'];
$username = urlencode('ETA');
$password= urlencode('eta1234');
$numbers = urlencode($reg_mobile);
$route= urlencode(T);
echo $numbers; 
//sender id
if($brand_name=="GENERAL")
{
$sender = urlencode('GENRAL');
$product="AC";
}
if($brand_name=="VESTAR")
{
$product="Product";
$sender = urlencode('VESTAR');
}
if($brand_name=="SANYO")
{
$product="Product";
$sender = urlencode('SANYO');
}
if($brand_name=="INDESIT")
{
$product="Product";
$sender = urlencode('INDESIT');
}
if($brand_name=="ELTECH")
{
$product="Product";
$sender = urlencode('ELTECH');
}

$message = urlencode('Service Call No.'.$complaint_no.'Address:'.$cust_name.','.$area_name.',Mobile No.:'.$reg_mobile.','.$call_type.'');
//echo $message;
$data = 'uname='.$username.'&pwd='.$password.'&senderid='.$sender.'&to='.$tech_mobile_no.'&msg='.$message.'&route='.$route;
echo $data;
$ch = curl_init('http://smslabel.co.in/sendsms?'. $data);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // For HTTPS
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // For HTTPS
curl_exec($ch);
//$response = curl_exec($ch);
echo "page return";
curl_close($ch);
//}

$message = urlencode('Service Call No. '.$complaint_no.' will be attended by '.$tech_name.'-'.$mobile_no.'');
//echo $message;
$data = 'uname='.$username.'&pwd='.$password.'&senderid='.$sender.'&to='.$numbers.'&msg='.$message.'&route='.$route;
echo $data;
$ch = curl_init('http://smslabel.co.in/sendsms?'. $data);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // For HTTPS
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // For HTTPS
curl_exec($ch);
//$response = curl_exec($ch);
echo "page return";
curl_close($ch);
$mobile_no="";
$numbers="";
$tech_mobile_no="";
	}
	
	
	
	$sql1="insert etaapp_reallocate (reg_id, allocate, allocate_to, allocate_time, update_by, update_time, status) values (".$value1.", 'Technician', '".$allocate_to."', '".$update_time."', '".$user."', '".$update_time."', 'Y')";
	//echo $sql1;
	$qu1=mysql_query($sql1);
	}
}

header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=1&count=$count1");
}

//Call SF / Dealer Reallocation live7
elseif($pid=="2_1_7")
{
$reg_id=$_POST['reg_id'];
$allocate=$_POST['allocate'];
if($allocate=="SF")$allocate_to=$_POST['allocate_to1'];
elseif($allocate=="SSD")$allocate_to=$_POST['allocate_to2'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_callreg set allocate='".$allocate."', allocate_to='".$allocate_to."', update_by1='".$user."', update_time1='".$update_time."' where reg_id=".$reg_id."";
//echo $sql;
$qu=mysql_query($sql);

$sql1="insert etaapp_reallocate (reg_id, allocate, allocate_to, allocate_time, update_by, update_time, status) values (".$reg_id.", '".$allocate."', '".$allocate_to."', '".$update_time."', '".$user."', '".$update_time."', 'Y')";
//echo $sql1;
$qu1=mysql_query($sql1);

header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=1");
}


//new Call Registration Details
elseif($pid=="2_1_6")
{
$reg_id=$_POST['reg_id'];
$call_type=$_POST['call_type1'];
$region_name=$_POST['region_name'];
$state_name=$_POST['state_name'];
$branch_name=$_POST['branch_name'];
$complaint_no=$_POST['complaint_no'];
$complaint_date=date("Y-m-d",strtotime($_POST['complaint_date']));
$cust_code=$_POST['cust_code'];
$invoice_no=$_POST['invoice_no'];
$cust_name=$_POST['cust_name'];
$title_name=$_POST['title_name'];
$reg_mobile=$_POST['reg_mobile'];
$alt_mobile=$_POST['alt_mobile'];
$address=$_POST['address'];
$address1=$_POST['address1'];
$city_name=$_POST['city_name'];
$area_name=$_POST['area_name'];
$district_name=$_POST['district'];
$pincode=$_POST['pincode'];
$landmark=$_POST['landmark'];
$spl_instruction=$_POST['spl_instruction'];
$email_id=$_POST['email_id'];
$brand_name=$_POST['brand_name'];
$product_type=$_POST['product_type'];
$model_no=$_POST['model_no'];
$model_desc=$_POST['model_desc'];
$purchase_from=$_POST['purchase_from'];
if($purchase_from=="Others")$purchase_from=$_POST['purchase_from1'];
$allocate=$_POST['allocate'];
if($allocate=="SF")$allocate_to=$_POST['allocate_to1'];
elseif($allocate=="SSD")$allocate_to=$_POST['allocate_to2'];
elseif($allocate=="Sub Dealer")$allocate_to=$_POST['allocate_to3'];
$srequest_date=$_POST['srequest_date'];
$install_date=$_POST['install_date'];
$warranty_status=$_POST['warranty_status'];
$amc_no=$_POST['amc_no'];
$amc_date=$_POST['amc_date'];
$call_option=$_POST['call_option'];
$fault_report=$_POST['fault_report'];
$cust_spares=$_POST['cust_spares'];
$repeat_type=$_POST['repeat_type'];
$remarks=$_POST['remarks'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_callreg set call_type='".$call_type."', region_name='".$region_name."', state_name='".$state_name."', branch_name='".$branch_name."', complaint_no='".$complaint_no."', complaint_date='".$complaint_date."', complaint_time='".$complaint_time."', cust_code='".$cust_code."', cust_name='".$cust_name."', title_name='".$title_name."', reg_mobile='".$reg_mobile."', alt_mobile='".$alt_mobile."', address='".$address."', address1='".$address1."', area_name='".$area_name."', district_name='".$district_name."', pincode='".$pincode."', landmark='".$landmark."', spl_instruction='".$spl_instruction."', email_id='".$email_id."', brand_name='".$brand_name."', product_type='".$product_type."', model_desc='".$model_desc."', purchase_from='".$purchase_from."', allocate='".$allocate."', allocate_to='".$allocate_to."', srequest_date='".$srequest_date."', warranty_status='".$warranty_status."', fault_report='".$fault_report."', remarks='".$remarks."',repeat_type='".$repeat_type."',  update_by='".$user."', update_time='".$update_time."' where reg_id=".$reg_id."";

//$sql="update etaapp_callreg set call_type='".$call_type."',alt_mobile='".$alt_mobile."', address1='".$address1."', area_name='".$area_name."', district_name='".$district_name."', pincode='".$pincode."', landmark='".$landmark."', spl_instruction='".$spl_instruction."', email_id='".$email_id."', product_type='".$product_type."', model_desc='".$model_desc."', purchase_from='".$purchase_from."', allocate='".$allocate."', allocate_to='".$allocate_to."', fault_report='".$fault_report."', repeat_type='".$repeat_type."', remarks='".$remarks."', update_by1='".$user."', update_time1='".$update_time."' where reg_id=".$reg_id." ";

//echo $sql;

if(mysql_query($sql)==1)
{
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=3&cid=$complaint_no&ccode=$cust_code");
}
else
{
//echo mysql_error();
header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}
//New Call Technician Allocation
elseif($pid=="2_1_8")
{
$allocate_to=$_POST['allocate_to'];
$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$allocate_id=$_POST[allocate_id];
//print_r($allocate_id);
$count1=count($allocate_id);
if($count1>0)
{
	foreach($allocate_id as $value1)
	{
	$sql="update etaapp_callreg set tech_allocate='".$allocate_to."', tech_update='".$user."', update_time1='".$update_time."', status='A' where reg_id=".$value1."";
	//echo $sql;
	$qu=mysql_query($sql);
	
	$sql1="insert etaapp_reallocate (reg_id, allocate, allocate_to, allocate_time, update_by, update_time, status) values (".$value1.", 'Technician', '".$allocate_to."', '".$update_time."', '".$user."', '".$update_time."', 'Y')";
	//echo $sql1;
	$qu1=mysql_query($sql1);
	}
}

header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=1&count=$count1");
}


//New Call SF / Dealer Reallocation
elseif($pid=="2_1_7")
{
$reg_id=$_POST['reg_id'];
$allocate=$_POST['allocate'];
if($allocate=="SF")$allocate_to=$_POST['allocate_to1'];
elseif($allocate=="SSD")$allocate_to=$_POST['allocate_to2'];

$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;

$sql="update etaapp_callreg set allocate='".$allocate."', allocate_to='".$allocate_to."', update_by1='".$user."', update_time1='".$update_time."' where reg_id=".$reg_id."";
//echo $sql;
$qu=mysql_query($sql);

$sql1="insert etaapp_reallocate (reg_id, allocate, allocate_to, allocate_time, update_by, update_time, status) values (".$reg_id.", '".$allocate."', '".$allocate_to."', '".$update_time."', '".$user."', '".$update_time."', 'Y')";
//echo $sql1;
$qu1=mysql_query($sql1);

header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=1");
}


elseif($pid=="2_1_9")
{
$complaint_no=$_POST['comp_no2'];
$time_now=time(date('h')+5,date('i')+30,date('s'));
$time=date('h:i:s A',$time_now);
$from1=date("d-M-Y");
$update_time=$from1.", ".$time;
$call_status="completed";

$sql2="select  upload_file,dealer_upload from etaapp_callcomp where complaint_no='".$complaint_no."'";
//echo $sql2;
$qu2=mysql_query($sql2);
$r2=mysql_fetch_assoc($qu2);
$upload=$r2['upload_file'];
$dupload=$r2['dealer_upload'];

	$file_upload="";
	$target_path = "SRUpload/";
	$filename=$_FILES['uploadfile']['name'];
	echo "hai".$filename;
	$base1=basename($filename);
	$exts = explode(".", $base1);
	$target = $exts[1];
	if($target!="")
	{
	$target_path.=$complaint_no.".".$target; 
	echo $target_path;
	if(move_uploaded_file($_FILES["uploadfile"]["tmp_name"],$target_path))
	{
	$file_upload="Y";
	}
	}
	else
	{
	$target_path=$upload;
	}
	$file_upload="";
	$target_path1 = "DEUpload/";
	$filename=$_FILES['uploadfile1']['name'];
	echo "hai".$filename;
	$base1=basename($filename);
	$exts = explode(".", $base1);
	$target = $exts[1];
	 if($target!="")
	{
	$target_path1.=$complaint_no.".".$target; 
	//echo $target_path1;
	if(move_uploaded_file($_FILES["uploadfile1"]["tmp_name"],$target_path1))
	{
	$file_upload="Y";
	}
	}
	else
	{
    $target_path1=$dupload;
	}
//echo  $target_path1;
$sql="update etaapp_callcomp set upload_file='".$target_path."',dealer_upload='".$target_path1."', update_by1='".$user."', update_time1='".$update_time."',upload_status='Y' where complaint_no='".$complaint_no."'";
//echo $sql;
$qu=mysql_query($sql);

header("Location:home.php?mid=$mid&smid=$smid&pid=$pid&nav=1");

}


elseif($pid=="7_1_11")
{
	//echo $pid; die;
	$id=$_GET['id'];
	//echo $id; die;
	$model_name=$_POST['model_name'];
	$MAKE_ID=$_POST['MAKE_ID'];
	$product_name=$_POST['product_name'];
	$tonage=$_POST['tonage'];
	$lamount=$_POST['lamount'];
	$excomp=$_POST['excomp'];
	$comp=$_POST['comp'];
	$wlamount=$_POST['wlamount'];
	$wexamount=$_POST['wexamount'];

	$time_now=time(date('h')+5,date('i')+30,date('s'));
	$time=date('Y-m-d h:i:s',$time_now);

$sql="update amc_model_list set model_no='".$model_name."', make='".$MAKE_ID."', product='".$product_name."', tonage='".$tonage."',
 lamount='".$lamount."', excomp='".$excomp."', comp='".$comp."', wlamount='".$wlamount."', wexamount='".$wexamount."',status='Y',updated_by='".$user."', updated_date='".$time."' where model_list_id=".$id."";
//echo $sql; die;

if(mysql_query($sql)==1)
{
header("Location:landing.php?mid=$mid&smid=$smid&pid=$pid&nav=3");
}
else
{
//echo mysql_error();
header("Location:landing.php?mid=$mid&smid=$smid&pid=$pid&nav=4");
}
}

?>