<?php
require_once("../include/config.php");
require_once("../include/startup.php");
	
if($G_memberid > 0)
{
	

$objinfo  		= new AllTables();
$company			=	new Company();
$AllStatesList 	= getAllStates();
$memberid	   = $G_memberid;
$companyid 	   = (int)($_GET['companyid']);

//$Company_obj					=	new Company();	
		$memberid = $G_memberid;
		$membercompanyid = $_GET['companyid'];
	
		
			
	if($_POST['SUBMIT'])
	{
		 //Information
		//echo"<pre>";
		//print_r($_POST);
		//die();
	  $operation_company = $_POST['operation_company'];
					$memberid 									= $_POST['txtmemberid'];
					  $edit_membercompanyid = $_POST['txtmembercompanyid'];
	 			$NewProduct['memberid']					= $memberid;
				//$NewProduct['memberid']	    				= $_POST['txtmemberid'];
				$NewProduct['membercompanyid']	    		= $edit_membercompanyid;
					
				$NewProduct['memberid']	    				= $_POST['txtmemberid'];
				$NewProduct['membercompanyid']	    		= $_POST['txtmembercompanyid'];
					
				$NewProduct['user_companyname']	    				= $_POST['txturcompany_name'];
				$NewProduct['MemberName']	    				= $_POST['txtcustomerName'];
				$NewProduct['MemberSurName']	    				= $_POST['txtcustomerlastName'];
				$NewProduct['head_Email']			    			= $_POST['txtcustomerEmail'];
				$NewProduct['head_Mob_no']		 				= $_POST['txtcustomerMobileno'];
				$NewProduct['user_password']		 				= $_POST['txtpassword'];
					$NewProduct['head_TelNo']		 				= $_POST['txtcustomerTelephoneno'];
				$NewProduct['last_edit_date']		 		= date("Y-m-d");
				$NewProduct['last_edited_by']		 		='1';
				//$NewProduct['dateofbirth']		    		= date("Y-m-d",strtotime($_POST['txtDOB']));
				$NewProduct['Addline1']		    		= $_POST['txtaddline'];
				$NewProduct['Addline2']		    		= $_POST['txtAddline1'];
							
				$NewProduct['head_CityName']		    		= $_POST['txthead_CityName'];
				$NewProduct['head_Pin']		    		= $_POST['txtpincode'];
				/*$city 		= explode("-", $_POST['txthead_CityName']);
				$state 		= explode("-", $_POST['txtstate']);
				$country 	= explode("-", $_POST['txtcountry']);
				
				$NewProduct['head_CityName']			 	= $city[1];
				$NewProduct['head_Stateid']		 			= $state[0];
				$NewProduct['head_StateName']		 		= $state[1];
			
				$NewProduct['Country']		 			= $country[1];	*/
	 	

			$wherecondition = "membercompanyid = ".$edit_membercompanyid;
			$edit = $objinfo -> EditInfo($NewProduct,$wherecondition,"trnuser_company");		
			//echo $edit;
			//die();
		//$whereclient = "clientcompanyid = ".$companyid."";
		//$editData	= $obj -> EditClient($NewProduct,$whereclient);
		if($edit)
		{
				$redirect_url = DOC_ROOT."admin/manage_user_company-details.php?companyid=$edit_membercompanyid";
				header("Location: $redirect_url");
    			exit;
		}
		
	}	
	else 
	{
			
$stetelist = '<option value="">Select State</option>'.getAllStateListForCombo('','','',$AllStatesList);

	$sqllist	=$company->getCompany("","","select * from trnuser_company a where a.membercompanyid = $companyid");
	//echo $sqllist;
	//print_r($sqllist);
	//die();
			//if(is_array($factorylist))
			//{
					 $rowcount			=		count($sqllist);
				for($i=0;$i<$rowcount;$i++)
	{	
		//$companyname 								= $sqllist[$i]['user_companyname'];
		$companyname 								= $sqllist[$i]['user_companyname'];
		$MemberName 								= $sqllist[$i]['MemberName'];
		$MemberSurName 								= $sqllist[$i]['MemberSurName'];
		$password 								= $sqllist[$i]['user_password'];
		$Name=$MemberName." ".$MemberSurName;
 	    $memberid									= $sqllist[$i]['memberid'];
		$membercompanyid							= $sqllist[$i]['membercompanyid'];
		$Addline1									= $sqllist[$i]['Addline1'];
		$Addline2									= $sqllist[$i]['Addline2'];
		$dateofbirth									= $sqllist[$i]['dateofbirth'];
		$gender									= $sqllist[$i]['gender'];
		$head_CityName								= $sqllist[$i]['head_CityName'];
		
		$head_TelNo	   = $sqllist[$i]['head_TelNo'];
		$head_mobNo	   = $sqllist[$i]['head_Mob_no'];
		$head_FaxNo	   = $sqllist[$i]['head_FaxNo'];
		$head_Email	   = $sqllist[$i]['head_Email'];
	  
		$head_Pin      = $sqllist[$i]['head_Pin'];
	   $Country  		= $sqllist[$i]['Country'];
		//$head_TelNo    = $sqllist[$i]['head_TelNo'];

		$BankName = $sqllist[$i]['Bankname'];
		$Bank_ACno      = $sqllist[$i]['BankAC'];
	   $Branch  		= $sqllist[$i]['Branch'];
		$IFSC_Code    = $sqllist[$i]['IFSC_Code'];

		$Address	 	   =	$sqllist[$i]['Addline1']."<br>".$sqllist[$i]['Addline2']."<br>".$sqllist[$i]['head_CityName']."<br>".$sqllist[$i]['head_Stateid'].'-'.$sqllist[$i]['head_Pin']."<br>".$sqllist[$i]['Country'];
		$status		   = $sqllist[$i]['memberapprovalstatus'];
		 $memberapprovalstatus					= $sqllist[$i]['memberapprovalstatus'];
		      if($memberapprovalstatus == '1')
		      {
					$valselect1      = "selected";
		      }
		      elseif($memberapprovalstatus == '0')
		      {
					$valselect0      = "selected";
		      }
		
		      
		   $head_Stateid1								= $sqllist[$i]['head_Stateid'];
		   $head_StateidName							= $sqllist[$i]['head_StateName'];
			
			$selected_country 						= getAllCountryListForCombo($Country); 
	//		$selected_state  							=	getAllStateListForComboEdit($head_Stateid1);
		
			$variable_tocallfunction 				= getState($Country,$head_Stateid1);


}






		require_once("header1.html");
		require_once("leftnav.html");
		require_once("edit-user1.html");
		
		     
	

	}
		
	


}
else if (!headers_sent($filename, $linenum)) 
{
				$redirect_url = DOC_ROOT."login.php";
				header("Location: $redirect_url");
    				exit;
					// You would most likely trigger an error here.
}
else 
{
				echo "Headers already sent in $filename on line $linenum\n" .
          			"Cannot redirect, for now please click this <a ";
    				exit;
}   

	
	
?>

