<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<?php
session_start(); 
//var_dump($_POST);
//echo "total:". count($_POST["dtype"]);
//die();
include '../db_con.php';
include 'methodlist.php';

      
	@$salut = mysqli_real_escape_string($con,$_REQUEST['salut']);
	@$sname = strtoupper(mysqli_real_escape_string($con,$_REQUEST['surname']));
	@$gname = strtoupper(mysqli_real_escape_string($con,$_REQUEST['gname']));
	@$bdate =  date("Y-m-d", strtotime(str_replace('/', '-', $_REQUEST['dob'])) ); 
	//date("Y-m-d", strtotime($_REQUEST['dob']) );
	@$birthplace = strtoupper(mysqli_real_escape_string($con,$_REQUEST['pob']));
	//@$counbirth = mysqli_real_escape_string($con,$_REQUEST['cob']);
	@$national = strtoupper(mysqli_real_escape_string($con,$_REQUEST['nation']));
	@$passtype = mysqli_real_escape_string($con,$_REQUEST['passtype']);
	@$passport = strtoupper(mysqli_real_escape_string($con,$_REQUEST['passport']));
	if($_REQUEST['pissue_date']!=NULL){
	    @$pissdate = date("Y-m-d", strtotime(str_replace('/', '-', $_REQUEST['pissue_date'])) ); 
	}
	else @$pissdate="NULL";
	//date("Y-m-d", strtotime($_REQUEST['pissue_date']) );
	@$pexdate = date("Y-m-d", strtotime(str_replace('/', '-', $_REQUEST['pexp_date'])) );
	@$gend = mysqli_real_escape_string($con,$_REQUEST['gender']);
	@$email = mysqli_real_escape_string($con,$_REQUEST['email']);
	@$phone = mysqli_real_escape_string($con,$_REQUEST['phone']);
	//@$mobile = mysqli_real_escape_string($con,$_REQUEST['mobile']);
	@$address = strtoupper(mysqli_real_escape_string($con,$_REQUEST['haddress']));
//	@$delvcenter = mysqli_real_escape_string($con,$_REQUEST['delcenter']);
    $userid=get_session_user_id($con);
	@$delvcenter = get_user_deliverycenter_id($userid,$con);
	//@$delvcenter = $_SESSION["delcenter"];
	@$visatype = mysqli_real_escape_string($con,$_REQUEST['visatype']);
	@$paymode = mysqli_real_escape_string($con,$_REQUEST['paymode']);
	
	@$agenttype = mysqli_real_escape_string($con,$_REQUEST['agstatus']);
	if($agenttype==2) @$agentname = strtoupper(mysqli_real_escape_string($con,$_REQUEST['agentname']));
	if($agenttype==3) @$agentname = strtoupper(mysqli_real_escape_string($con,$_REQUEST['companyname']));
	if($agenttype==1) @$agentname ='';
	
/*	@$desti = mysqli_real_escape_string($con,$_REQUEST['desti']);
	@$ddate =  date("Y-m-d", strtotime(mysqli_real_escape_string($con,$_REQUEST['dept_date'])) );
	@$ardate =  date("Y-m-d", strtotime(mysqli_real_escape_string($con,$_REQUEST['arrv_date'])) );
	@$paytype = mysqli_real_escape_string($con,$_REQUEST['paytype']);
*/
	@$totalfee = mysqli_real_escape_string($con,$_REQUEST['total']);

	

	$srs=@mysqli_query($con,"select * from setting_table");
	$srow=mysqli_fetch_array($srs);
	$servicefee=$srow["value"];


	if($_REQUEST['actionid']=='insert'){

	    $rs0=@mysqli_query($con,"select * from applicant_table where DATE(created_date) >= CURDATE()");
		//$rs0row=mysqli_fetch_array($rs0);
		$norow=mysqli_num_rows($rs0);
		$seqno=$norow+1;

		$prs0=@mysqli_query($con,"select * from applicant_table where parent=0 AND DATE(created_date) >= CURDATE()");
		//$rs0row=mysqli_fetch_array($rs0);
		$pnorow=mysqli_num_rows($prs0);
		$serialid=$pnorow+1;

		//echo $serialid;  

		$pidate = date('d-m-Y');
		$pidate = str_replace('-','',$pidate);
		$serialid = sprintf("%04d", $serialid);
		$seqid = sprintf("%02d", 1);
		$refno_pre=get_delivery_location_kword($delvcenter,$con).substr_replace($pidate, '', 4, 2)."-".$serialid;
		$refno=$refno_pre."-".$seqid;
	
			$sql = "INSERT INTO `applicant_table`(`surname`, `givenname`, `salu`, `phone_no`, `email`, `homeaddress`,`deliverycenter`,`paymode`,`passporttype`,`passport_no`, `passissuedate`,`passexpdate`,`gender`, nationality, created_date, takenby, total_fee, birth_date, placeofbirth, appstatus, paystatus, doc_position, visa_type, agent, agent_name, v_uid, refer_no, parent) 
					VALUES ('$sname','$gname','$salut','$phone','$email','$address','$delvcenter','$paymode','$passtype','$passport','$pissdate','$pexdate','$gend', '$national', NOW(), $userid, '$totalfee', '$bdate', '$birthplace', 1, 0, 1, '$visatype', '$agenttype', '$agentname', '$seqno', '$refno', 0)";
		
			 //var_dump($sql) or die();

			$result = @mysqli_query($con,$sql);

			$rs0=@mysqli_query($con,"select app_id from applicant_table where parent LIKE 0 ORDER BY app_id DESC LIMIT 1");
			$rs0row=mysqli_fetch_array($rs0);
			$parent=$rs0row["app_id"];
			

			ver_update_history('application created by', $parent,$con);

			// update doc position in doc log table 
			$sql ="insert into `docpos_log_table` (docpos_log_appid, docpos_log_dposid, docpos_log_userid) values ('$parent', 1, '$userid') ";
			mysqli_query($con,$sql);

			
			if ($result){


				if(count($_POST["child"])>0){

						//$rs0=@mysqli_query($con,"select app_id from applicant_table ORDER BY app_id DESC LIMIT 1");
						//$rs0row=mysqli_fetch_array($rs0);
					$parentid=$parent;

					for($i=0;$i<count($_POST["child"]);$i++){

						$chcounter="ch".$_POST["child"][$i];
				        $seqid = $seqid+1;
						$seqid = sprintf("%02d", $seqid);
						$refno=$refno_pre."-".$seqid;

						$seqno=$seqno+1;

						@$salut = mysqli_real_escape_string($con,$_REQUEST['salut'.$chcounter.'']);
						@$sname = strtoupper(mysqli_real_escape_string($con,$_REQUEST['surname'.$chcounter.'']));
						@$gname = strtoupper(mysqli_real_escape_string($con,$_REQUEST['gname'.$chcounter.'']));
						@$bdate =  date("Y-m-d", strtotime($_REQUEST['dob'.$chcounter.'']) );
						@$birthplace = strtoupper(mysqli_real_escape_string($con,$_REQUEST['pob'.$chcounter.'']));
						//@$counbirth = mysqli_real_escape_string($con,$_REQUEST['cob'.$chcounter.'']);
						@$national = strtoupper(mysqli_real_escape_string($con,$_REQUEST['nation'.$chcounter.'']));
						@$passtype = mysqli_real_escape_string($con,$_REQUEST['passtype'.$chcounter.'']);
						@$passport = strtoupper(mysqli_real_escape_string($con,$_REQUEST['passport'.$chcounter.'']));
						//@$pissdate =  date("Y-m-d", strtotime($_REQUEST['pissue_date'.$chcounter.'']) );
						if($_REQUEST['pissue_date'.$chcounter.'']!=NULL){
	                        @$pissdate =  date("Y-m-d", strtotime(str_replace('/', '-', $_REQUEST['pissue_date'.$chcounter.''])) ); 
                    	}
	                    else @$pissdate="NULL";
	                    @$pexdate =  date("Y-m-d", strtotime($_REQUEST['pexp_date'.$chcounter.'']) );
						@$gend = mysqli_real_escape_string($con,$_REQUEST['gender'.$chcounter.'']);
						@$visatype = mysqli_real_escape_string($con,$_REQUEST['visatype'.$chcounter.'']);
						//@$email = mysqli_real_escape_string($con,$_REQUEST['email'.$chcounter.'']);
						//@$phone = mysqli_real_escape_string($con,$_REQUEST['phone'.$chcounter.'']);
						//@$mobile = mysqli_real_escape_string($con,$_REQUEST['mobile'.$chcounter.'']);
						//@$address = mysqli_real_escape_string($con,$_REQUEST['haddress'.$chcounter.'']);
						//@$delvcenter = mysqli_real_escape_string($con,$_REQUEST['delcenter'.$chcounter.'']);
						// @$biostatus = mysqli_real_escape_string($con,$_REQUEST['biostatus'.$chcounter.'']);
						// if($biostatus==0) @$bionote = mysqli_real_escape_string($con,$_REQUEST['bionotes'.$chcounter.'']);
						// else @$bionote ='';
						
						
						$sql = "INSERT INTO `applicant_table`(`surname`, `givenname`, `salu`, `deliverycenter`, `passporttype`,`passport_no`, `passissuedate`,`passexpdate`,`gender`, nationality, created_date, takenby, total_fee, birth_date, placeofbirth, appstatus, paystatus, doc_position, visa_type, agent, agent_name, v_uid, refer_no, parent) 
								VALUES ('$sname','$gname','$salut', '$delvcenter', '$passtype','$passport','$pissdate','$pexdate','$gend', '$national', NOW(), '$userid', '$totalfee', '$bdate', '$birthplace', 1, 0, 1, '$visatype', '$agenttype', '$agentname', '$seqno', '$refno', '$parentid')";
						//echo $sql."<br><br>";
						// var_dump($sql) or die();
						$result = @mysqli_query($con,$sql);

						$rs0=@mysqli_query($con,"select app_id from applicant_table where parent NOT LIKE 0 ORDER BY app_id DESC LIMIT 1");
						$rs0row=mysqli_fetch_array($rs0);
						ver_update_history('application created by', $rs0row["app_id"],$con);

						// update doc position in doc log table 
						$sql ="insert into `docpos_log_table` (docpos_log_appid, docpos_log_dposid, docpos_log_userid) values ('$rs0row[app_id]', 1, '$userid') ";
						mysqli_query($con,$sql);

						///// insert child vas info to DB  //////////
						
						// $cvasrs = mysqli_query($con,"select * from vas_table where status=1 order by vas_name ASC");

						// while($cvasrow=mysqli_fetch_array($cvasrs)){ 

						// 	$cvasrr=$_POST["".$cvasrow["vas_id"]."_".$_POST["child"][$i]."_qty"];



						// 	if(isset($cvasrr)){

						// 		for($k=0; $k<count($cvasrr); $k++){
						// 			echo "id".$cvasrow["vas_id"]." AND ".$cvasrr[$k];
						// 			$vtype=$cvasrow["vas_id"];
						// 			$qty=$cvasrr[$k];
									
						// 			if($qty!=0){
									
						// 				$sql = "INSERT INTO `vas_app_table`(vas_id,quantity,app_id)	VALUES ('$vtype','$qty','$rs0row[app_id]')";							
						// 				@mysqli_query($con,$sql);
						// 			}
						// 		}
						// 	}
						   
						// }

						/////////////////

					}
				}

				
				header('Location: application.php');	
			}
			else {
				
				//header('Location: application.php?msg=2');
				echo "Some errors occured.";
			}	
			//$result = @mysqli_query($con,$sql);
			
			//if ($result){

			//	$rs1=@mysqli_query($con,"select app_id from applicant_table ORDER BY app_id DESC LIMIT 1");
			//	$rs1row=mysqli_fetch_array($rs1);
			//	$appid=$rs1row["app_id"];

				// for($i=0; $i<count($_POST["dtype"]); $i++){

				// 	$dtype=$_POST["dtype"][$i];
				// 	$qty=$_POST["qty"][$i];
				// 	$sql = "INSERT INTO `doc_app_table`(doc_id,quantity,app_id)	VALUES ('$dtype','$qty','$appid')";
				// 	@mysqli_query($con,$sql);


				// 	$feers=@mysqli_query($con,"select doc_fee from doc_table where doc_id='$dtype'");
				// 	$feerow=mysqli_fetch_array($feers);
				// 	$totalfee=$totalfee+$feerow["doc_fee"]*$qty;
					
				// }


				// $totalfee=$totalfee+$servicefee;
				// $sql = "update applicant_table set total_fee='$totalfee' where app_id='$appid'";
				// @mysqli_query($con,$sql);

				// var_dump($sql) or die();

		//	} 
		
			

		//}
	}

	if($_REQUEST['actionid']=='update'){

			$parent = intval($_REQUEST['parent']);
	 		$updatelist="";
		
			$sql = "update `applicant_table` set `surname`='$sname', `givenname`='$gname', `salu`='$salut', `phone_no`='$phone', `email`='$email', `homeaddress`='$address', `deliverycenter`='$delvcenter', `paymode`='$paymode', `passporttype`='$passtype', `passport_no`='$passport', `passissuedate`='$pissdate', `passexpdate`='$pexdate', `gender`='$gend', `nationality`='$national', `total_fee`='$totalfee', `birth_date`='$bdate',
					`placeofbirth`='$birthplace', agent='$agenttype',  agent_name='$agentname'  where app_id='".$parent ."'";

			 $result = @mysqli_query($con,$sql);
			
			if ($result){

			///// delete previous vas info and insert new info to DB  //////////

				$sql = "delete from vas_app_table where app_id='$parent'";
	 			@mysqli_query($con,$sql);

				$rs2 = mysqli_query($con,"select * from vas_table where status=1 order by vas_name ASC");

				while($row2=mysqli_fetch_array($rs2)){ 

					$vasrr=$_POST["".$row2["vas_id"]."_pqty"];



					if(isset($vasrr)){

						for($i=0; $i<count($vasrr); $i++){
							echo "id".$row2["vas_id"]." AND ".$vasrr[$i];
							$vtype=$row2["vas_id"];
							$qty=$vasrr[$i];
							
							if($qty!=0){
							
								$sql = "INSERT INTO `vas_app_table`(vas_id,quantity,app_id)	VALUES ('$vtype','$qty','$parent')";							
								@mysqli_query($con,$sql);
							}
						}
					}
				   
				}

				/////////////////


			 	if(count($_POST["child"])>0){


			 		for($i=0;$i<count($_POST["child"]);$i++){

			 			$chcounter="ch".$_POST["child"][$i];
			// 			$serialid=$serialid+1;

						@$salut = mysqli_real_escape_string($con,$_REQUEST['salut'.$chcounter.'']);
						@$sname = strtoupper(mysqli_real_escape_string($con,$_REQUEST['surname'.$chcounter.'']));
						@$gname = strtoupper(mysqli_real_escape_string($con,$_REQUEST['gname'.$chcounter.'']));
						@$bdate =  date("Y-m-d", strtotime(str_replace('/', '-', $_REQUEST['dob'.$chcounter.''])) ); 
						//date("Y-m-d", strtotime($_REQUEST['dob'.$chcounter.'']) );
						@$birthplace = strtoupper(mysqli_real_escape_string($con,$_REQUEST['pob'.$chcounter.'']));
						//@$counbirth = mysqli_real_escape_string($con,$_REQUEST['cob'.$chcounter.'']);
						@$national = strtoupper(mysqli_real_escape_string($con,$_REQUEST['nation'.$chcounter.'']));
						@$passtype = mysqli_real_escape_string($con,$_REQUEST['passtype'.$chcounter.'']);
						@$passport = strtoupper(mysqli_real_escape_string($con,$_REQUEST['passport'.$chcounter.'']));
					//	@$pissdate =  date("Y-m-d", strtotime(str_replace('/', '-', $_REQUEST['pissue_date'.$chcounter.''])) );
						if($_REQUEST['pissue_date'.$chcounter.'']!=NULL){
	                        @$pissdate =  date("Y-m-d", strtotime(str_replace('/', '-', $_REQUEST['pissue_date'.$chcounter.''])) ); 
                    	}
	                    else @$pissdate="NULL";
						//date("Y-m-d", strtotime($_REQUEST['pissue_date'.$chcounter.'']) );
						@$pexdate =  date("Y-m-d", strtotime(str_replace('/', '-', $_REQUEST['pexp_date'.$chcounter.''])) ); 
						//date("Y-m-d", strtotime($_REQUEST['pexp_date'.$chcounter.'']) );
						@$gend = mysqli_real_escape_string($con,$_REQUEST['gender'.$chcounter.'']);
						@$visatype = mysqli_real_escape_string($con,$_REQUEST['visatype'.$chcounter.'']);
						// @$email = mysqli_real_escape_string($con,$_REQUEST['email'.$chcounter.'']);
						// @$phone = mysqli_real_escape_string($con,$_REQUEST['phone'.$chcounter.'']);
						// @$mobile = mysqli_real_escape_string($con,$_REQUEST['mobile'.$chcounter.'']);
						// @$address = mysqli_real_escape_string($con,$_REQUEST['haddress'.$chcounter.'']);
						// @$delvcenter = mysqli_real_escape_string($con,$_REQUEST['delcenter'.$chcounter.'']);
						// @$biostatus = mysqli_real_escape_string($con,$_REQUEST['biostatus'.$chcounter.'']);
						// if($biostatus==0) @$bionote = mysqli_real_escape_string($con,$_REQUEST['bionotes'.$chcounter.'']);
						// else @$bionote ='';

						$sql = "update `applicant_table` set `surname`='$sname', `givenname`='$gname', `salu`='$salut', `deliverycenter`='$delvcenter', `passporttype`='$passtype', 
					`passport_no`='$passport', `passissuedate`='$pissdate', `passexpdate`='$pexdate', `gender`='$gend', `nationality`='$national', `total_fee`='$totalfee',
					 `birth_date`='$bdate', `placeofbirth`='$birthplace', agent='$agenttype', agent_name='$agentname' where parent='$parent' AND app_id='".$_POST["child"][$i]."'";
						
			 			$result = @mysqli_query($con,$sql);


						///// Delete child previous vas info and insert new to DB  //////////

						$sql = "delete from vas_app_table where app_id='".$_POST["child"][$i]."'";
			 			@mysqli_query($con,$sql);

						
						$cvasrs = mysqli_query($con,"select * from vas_table where status=1 order by vas_name ASC");

						while($cvasrow=mysqli_fetch_array($cvasrs)){ 

							$cvasrr=$_POST["".$cvasrow["vas_id"]."_".$_POST["child"][$i]."_qty"];



							if(isset($cvasrr)){

								for($k=0; $k<count($cvasrr); $k++){
									echo "id".$cvasrow["vas_id"]." AND ".$cvasrr[$k];
									$vtype=$cvasrow["vas_id"];
									$qty=$cvasrr[$k];
									
									if($qty!=0){
									
										$sql = "INSERT INTO `vas_app_table`(vas_id,quantity,app_id)	VALUES ('$vtype','$qty','".$_POST["child"][$i]."')";							
										@mysqli_query($con,$sql);
									}
								}
							}
						   
						}

						/////////////////

			 		}
			 	}

				
			 	header('Location: application.php');	
			 }
			 else {
				
			// 	header('Location: verification.php?msg=2');
			 	echo "Some errors occured.";
			 }	
			
	}

	// if($_REQUEST['actionid']=='updatefull'){

	// 		//$appid= mysqli_real_escape_string($con,$_REQUEST['appid']);
	// 		$appid = intval($_REQUEST['appid']);
	// 		$updatelist="";
			
			
	// 		$lastrs=@mysqli_query($con,"select name, mobile_no, email, passport_no, gender, nationality, birth_date from applicant_table where app_id='".$appid."'");
	// 		$lastrow=mysqli_fetch_array($lastrs);

	// 		if(strcmp($lastrow["name"],$app_name)!=0){

	// 			$updatelist=$updatelist."# Name updated from ".$lastrow["name"]." to ".$app_name." ";

	// 		}
	// 		elseif(strcmp($lastrow["mobile_no"],$mobile)!=0){

	// 			$updatelist=$updatelist."# Mobile no. updated from ".$lastrow["mobile_no"]." to ".$mobile." ";

	// 		}
	// 		if(strcmp($lastrow["email"],$email)!=0){

	// 			$updatelist=$updatelist."# Email updated from ".$lastrow["email"]." to ".$email." ";

	// 		}
	// 		if(strcmp($lastrow["passport_no"],$passport)!=0){

	// 			$updatelist=$updatelist."# Passport no. updated from ".$lastrow["passport_no"]." to ".$passport." ";

	// 		}
	// 		if(strcmp($lastrow["birth_date"],$bdate)!=0){

	// 			$updatelist=$updatelist."# Birth date updated from ".$lastrow["birth_date"]." to ".$bdate." ";

	// 		}
	// 		if(strcmp($lastrow["gender"],$gender)!=0){

	// 			$updatelist=$updatelist."# Gender updated from ".$lastrow["gender"]." to ".$gender." ";

	// 		}
	// 		if(strcmp($lastrow["nationality"],$national)!=0){

	// 			$updatelist=$updatelist."# Nationality updated from ".$lastrow["nationality"]." to ".$national." ";

	// 		}
				
	// 		$sql = "update `applicant_table` set `name`='$app_name', `mobile_no`='$mobile', `email`='$email', `passport_no`='$passport', `gender`='$gender', `nationality`='$national', `birth_date`='$bdate',`purpose_id`='$purpose' where app_id='".$appid ."'";
	// 		//echo $sql;

	// 		// var_dump($sql) or die();
	// 		$result = @mysqli_query($con,$sql);
			
	// 		if ($result){

			
	// 			$sql = "delete from doc_app_table where app_id='$appid'";
	// 			@mysqli_query($con,$sql);

	// 			for($i=0; $i<count($_POST["dtype"]); $i++){

	// 				$dtype=$_POST["dtype"][$i];
	// 				$qty=$_POST["qty"][$i];
	// 				$sql = "INSERT INTO `doc_app_table`(doc_id,quantity,app_id)	VALUES ('$dtype','$qty','$appid')";
	// 				@mysqli_query($con,$sql);


	// 				$feers=@mysqli_query($con,"select doc_fee from doc_table where doc_id='$dtype'");
	// 				$feerow=mysqli_fetch_array($feers);
	// 				$totalfee=$totalfee+$feerow["doc_fee"]*$qty;
	// 			}
	// 			$totalfee=$totalfee+$servicefee;
	// 			$sql = "update applicant_table set total_fee='$totalfee' where app_id='$appid'";
	// 			@mysqli_query($con,$sql);


	// 			// var_dump($sql) or die();
	// 			//var_dump($_SESSION);

	// 			// $adminuserid=get_session_user_id();
	// 			// $sql = "INSERT INTO `ver_his_table` (`vh_id`, `vh_notes`, `vh_datetime`, `app_id`, `user_id`) VALUES (NULL, 'verfication application updated by', NOW(), '$appid', '$adminuserid');";
	// 			// @mysqli_query($con,$sql);

	// 			ver_update_history("Updated: ".$updatelist." by ", $appid,$con);

	// 			header('Location: verification.php');
	// 		} 
	// 		else {
				
	// 			header('Location: verification.php?msg=2');
	// 			//echo "Some errors occured.";
	// 		}
			

	// 	//}
	// }

	// if($_REQUEST['actionid']=='update'){

	// 		//$appid= mysqli_real_escape_string($con,$_REQUEST['appid']);
	// 		$appid = intval($_REQUEST['appid']);
	// 		$updatelist="";
			
			
	// 		$lastrs=@mysqli_query($con,"select name, mobile_no, email, passport_no, birth_date, gender, nationality from applicant_table where app_id='".$appid."'");
	// 		$lastrow=mysqli_fetch_array($lastrs);

	// 		if(strcmp($lastrow["name"],$app_name)!=0){

	// 			$updatelist=$updatelist."# Name updated from ".$lastrow["name"]." to ".$app_name." ";

	// 		}
	// 		elseif(strcmp($lastrow["mobile_no"],$mobile)!=0){

	// 			$updatelist=$updatelist."# Mobile no. updated from ".$lastrow["mobile_no"]." to ".$mobile." ";

	// 		}
	// 		if(strcmp($lastrow["email"],$email)!=0){

	// 			$updatelist=$updatelist."# Email updated from ".$lastrow["email"]." to ".$email." ";

	// 		}
	// 		if(strcmp($lastrow["passport_no"],$passport)!=0){

	// 			$updatelist=$updatelist."# Passport no. updated from ".$lastrow["passport_no"]." to ".$passport." ";

	// 		}
	// 		if(strcmp($lastrow["birth_date"],$bdate)!=0){

	// 			$updatelist=$updatelist."# Birth date updated from ".$lastrow["birth_date"]." to ".$bdate." ";

	// 		}
	// 		if(strcmp($lastrow["gender"],$gender)!=0){

	// 			$updatelist=$updatelist."# Gender updated from ".$lastrow["gender"]." to ".$gender." ";

	// 		}
	// 		if(strcmp($lastrow["nationality"],$national)!=0){

	// 			$updatelist=$updatelist."# Nationality updated from ".$lastrow["nationality"]." to ".$national." ";

	// 		}

				
	// 		$sql = "update `applicant_table` set `name`='$app_name', `mobile_no`='$mobile', `email`='$email', `passport_no`='$passport', `gender`='$gender', `nationality`='$national', `birth_date`='$bdate' where app_id='".$appid ."'";
	// 		//echo $sql;

	// 		// var_dump($sql) or die();
	// 		$result = @mysqli_query($con,$sql);
			
	// 		if ($result){

			
	// 			// $sql = "delete from doc_app_table where app_id='$appid'";
	// 			// @mysqli_query($con,$sql);

	// 			// for($i=0; $i<count($_POST["dtype"]); $i++){

	// 			// 	$dtype=$_POST["dtype"][$i];
	// 			// 	$qty=$_POST["qty"][$i];
	// 			// 	$sql = "INSERT INTO `doc_app_table`(doc_id,quantity,app_id)	VALUES ('$dtype','$qty','$appid')";
	// 			// 	@mysqli_query($con,$sql);


	// 			// 	$feers=@mysqli_query($con,"select doc_fee from doc_table where doc_id='$dtype'");
	// 			// 	$feerow=mysqli_fetch_array($feers);
	// 			// 	$totalfee=$totalfee+$feerow["doc_fee"]*$qty;
	// 			// }
	// 			// $totalfee=$totalfee+$servicefee;
	// 			// $sql = "update applicant_table set total_fee='$totalfee' where app_id='$appid'";
	// 			// @mysqli_query($con,$sql);


	// 			// var_dump($sql) or die();
	// 			//var_dump($_SESSION);

	// 			// $adminuserid=get_session_user_id();
	// 			// $sql = "INSERT INTO `ver_his_table` (`vh_id`, `vh_notes`, `vh_datetime`, `app_id`, `user_id`) VALUES (NULL, 'verfication application updated by', NOW(), '$appid', '$adminuserid');";
	// 			// @mysqli_query($con,$sql);

	// 			ver_update_history("Updated: ".$updatelist." by ", $appid,$con);

	// 			header('Location: verification.php');
	// 		} 
	// 		else {
				
	// 			header('Location: verification.php?msg=2');
	// 			//echo "Some errors occured.";
	// 		}
			

	// 	//}
	// }

	
?>