<?php 
//error_reporting(E_ALL); 
//error_reporting('~E_notice'); 
class Agency extends Controller {
	/*
	Function Name: Agency() 
	Function Details: Constructor 
	*/

	function Agency()
	{
		parent::Controller();	
	}
	
	
	/*
	Function Name: index()
	Function Details: Default page
	*/
	function index($ses_id, $ses_user_type){	
		
//		$ses_id = $this->session->userdata('id');
//		$ses_user_type = $this->session->userdata('type');

		if($ses_id >0 &&  $ses_user_type == 0 ) {
			$this->show_agency_homePage('');
		}else{
			$this->agency_access_control_error_page();
		}//endif ==> if($ses_id >0) 
	}

/*
	Function Name: agency_edit_ownProfile()
	Function Details: edit agency profile
	Status:  100% done
*/
//	function agency_edit_ownProfile($ses_id, $ses_user_type){
	function agency_edit_ownProfile(){
		
		$ses_id = $this->session->userdata('id');
		$ses_user_type = $this->session->userdata('type');
//*****************Alex
echo "AAAAAsec_idAAA".$ses_id.'<br />';
echo "BBBBBses_user_typeBBB".$ses_user_type.'<br />';
//********Should be fixed later
$ses_user_type=0;
$ses_id=44;
//*****************Alex
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();

		if($ses_id >0 &&  $ses_user_type == 0 ) 
                  {
			$login_user_name=$this->session->userdata('name');
			$this->show_header_2();			
			$data['message']='';
			$data['agencyName'] = $login_user_name;
			//===fetch suburb list
			$this->load->helper('url');
			$this->load->model('Common_mod','',TRUE);
			$suburb_list = $this->Common_mod->load_suburb_list();
			$data['suburb_list']=$suburb_list;
			$this->load->vars($data);
			$this->load->helper('url');
			$this->load->model('Agency_mod','',TRUE);
			$agency_info = $this->Agency_mod->show_agencyProfile_mod($ses_id);
			
			$agencyInfo ['formValueName'] = $agency_info['ag_name'];
			$agencyInfo ['formValuePContact'] = $agency_info['ag_primary_contact'];
			$agencyInfo ['formValueAddress1'] = $agency_info['ag_address1'];
			$agencyInfo ['formValueAddress2'] = $agency_info['ag_address2'];
			$agencyInfo ['formValuePostcode'] = $agency_info['ag_postcode'];
			$agencyInfo ['formValuePhn'] = $agency_info['ag_phone'];
			$agencyInfo ['formValueABN'] = $agency_info['ag_abn_name'];
			$agencyInfo ['formValueFax'] = $agency_info['ag_fax'] ;
			$agencyInfo ['formValueEmail'] = $agency_info['ag_email'];
//Added by ALex
                        $country_id = $this->input->xss_clean($this->input->post('country'));
                        include ('admin/config.php');
                        $link = mysql_connect(hostname,username,password);
                        if (!$link) 
                           die('Could not connect: ' . mysql_error());
                        mysql_select_db(databasename, $link); 
                        $query="SELECT cd_country_name FROM code_country WHERE country_id='$country_id'";
                        $result=mysql_query($query);
                        while($row=mysql_fetch_array($result)) {
                        $agencyInfo['ag_country_name'] = $row['cd_country_name'];
                     }
		$agencyInfo['ag_country_id'] = $this->input->xss_clean($this->input->post('country'));
                $agencyInfo['ag_state_id'] = $this->input->xss_clean($this->input->post('state'));
	        $state_id = $this->input->xss_clean($this->input->post('state'));
                $query="SELECT cds_state_name FROM code_state WHERE state_id='$state_id'";
                $result=mysql_query($query);
                while($row=mysql_fetch_array($result)) 
                     {
                       $agencyInfo['ag_state_name'] = $row['cds_state_name'];
                     }
                $agencyInfo['ag_suburb_id'] = $this->input->xss_clean($this->input->post('city'));
                $suburb_id = $this->input->xss_clean($this->input->post('city'));
                $query="SELECT ps_suburb FROM postcode WHERE postcode_id='$suburb_id'";
                $result=mysql_query($query);
                while($row=mysql_fetch_array($result)) 
                     {
                       $agencyInfo['ag_suburb_name'] = $row['ps_suburb'];
                     }
                mysql_close($link);
//End added by ALex
//			$agencyInfo ['ag_suburb_id'] = $agency_info['ag_suburb_id'];
			$us_image_id_2 = $agency_info['ag_image_id_2'];
			if($us_image_id_2=='')
                           {
			     $agencyInfo ['us_image_id_2']='system/application/css/images/agent_photo_03.jpg';
			   }
                        else
                           {
			      $agencyInfo ['us_image_id_2']='uploads/people/'.$us_image_id_2;
			   }
echo "SSSIn agency.php".'<br />';

			$this->load->vars($agencyInfo);
echo "SSSIn agency.php-1".'<br />';
			$this->load->view('agency_agencyAdmin_editOwnProfile',$data,$agencyInfo);
echo "SSSIn agency.php-2".'<br />';
			$this->load->view('footer');
echo "SSSIn agency.php-3".'<br />';
//exit;		
		}
                else
                {
		  $this->agency_access_control_error_page();
		}//endif ==> if($ses_id >0)
        }

/*
	Function Name: agency_update_ownProfile_mod()
	Function Details: edit agency profile
	Status: 100% done
*/
	function agency_update_ownProfile_mod($ses_id, $ses_user_type){
echo "In Agency after function agency_update_ownProfile".'<br />';
echo "ses_id=".$ses_id.'<br />';
echo "ses_user_type=".$ses_user_type.'<br />';
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();
//		$ses_id = $this->session->userdata('id');
//		$ses_user_type = $this->session->userdata('type');

//*****************Alex
$data['ses_user_type']=$ses_user_type;
$data['ses_id']=$ses_id;
//**************Should be fixed
$ses_id=32;
$ses_user_type=0;
//****************Alex


		if($ses_id >0 &&  $ses_user_type == 0 ) {

		
			$this->show_header_2();
			$this->load->helper('url');
			$this->load->model('Common_mod','',TRUE);
			$suburb_list = $this->Common_mod->load_suburb_list();
			$data['suburb_list']=$suburb_list;
			//upload image
			$config['upload_path'] = './uploads/people/';
			$config['allowed_types'] = 'gif|jpg|png';
			$config['max_size']	= '2048';
			$config['max_width']  = '0';
			$config['max_height']  = '0';
			$this->load->helper(array('form', 'url'));
			$this->load->library('upload', $config);
			$image_up = $this->upload->do_upload('image');
		
			if($_FILES['image']['name'] != ''){//pic is request for upload
				if($_FILES['image']['error'] == 0)
					$image_up_result = 'up';
				elseif($_FILES['image']['error']>0)
					$image_up_result = 'bigPic';
			}else
				$image_up_result = 'samePic';
			
			
			//===========
			if($image_up_result == 'bigPic'){	
				$update_info= -1;
			}
			else{
				if($image_up_result == 'up' || $image_up_result == 'samePic'){
					$image_data = array('upload_data' => $this->upload->data());
					
					$full_path = $image_data['upload_data']['full_path'];
					$file_path = $image_data['upload_data']['file_path'];
					$file_name = $image_data['upload_data']['file_name'];
					$raw_name = $image_data['upload_data']['raw_name'];
					$file_ext = $image_data['upload_data']['file_ext'];
					$orig_name = $image_data['upload_data']['orig_name'];
					//-- image resize
					$config['image_library'] = 'gd2';
					$config['source_image'] = $full_path;
					$config['create_thumb'] = TRUE;
					$config['maintain_ratio'] = TRUE;
					$config['width'] = 75;
					$config['height'] = 50;
					//$config['new_image'] = $full_path;
					//$config['thumb_marker']= '_thumb';
					$this->load->library('image_lib', $config);
					$thumb_result = $this->image_lib->resize();
					
					if($thumb_result){
						$orig_name_thumb = $raw_name.'_thumb'.$file_ext;
					
					}else{
						$orig_name_thumb='';
						$orig_name='';
					}//end thumb_result
				}else{
						$orig_name_thumb='';
						$orig_name='';
				}//end image_up_result	
				$this->load->model('Agency_mod','',TRUE);
				$update_info = $this->Agency_mod->update_agencyProfile_mod($ses_id,$orig_name,$orig_name_thumb);
				
			}
			$login_user_name=$this->session->userdata('name');
			if($update_info == 1){
				$data['message']='Update Successful';
				$data['agencyName'] = $login_user_name;

				$this->load->vars($data);
				$this->load->view('agency_agencyAdmin_homePage',$data);
echo "IN agency.php-4".'<br />';
			}
			elseif($update_info == -1 ){
echo "IN agency.php-5".'<br />';			
				$data['message']='Please upload a image of size less the 2MB.';
				$data['agencyName'] = $login_user_name;
				$this->load->vars($data);
				$this->load->view('agency_agencyAdmin_editOwnProfile',$data);
			}
			elseif($update_info == 'pass'){
echo "IN agency.php-6".'<br />';				
				$data['message']='Wrong Old Password. Update was not Successful';
				$data['agencyName'] = $login_user_name;
				$this->load->vars($data);
				$this->load->view('agency_agencyAdmin_editOwnProfile',$data);
			}else{
				$data['message']='Update was not successful.';
				$data['agencyName'] = $login_user_name;
				$this->load->vars($data);
				$this->load->view('agency_agencyAdmin_homePage',$data);
			}
			$this->load->view('footer');
echo "In Agency after function agency_update_ownProfile-1".'<br />';
		
		}else{
			$this->agency_access_control_error_page();
		}//endif ==> if($ses_id >0) 
	}

/*
	Function Name: agency_manage_agentProfile()
	Function Details: Manage Agent profile List for edit
	Status: 100%
*/
	function agency_manage_agentProfile($agency_id, $agent_id, $agencyName){

//******************Alex
// ($_GET['$agencyName']!="")
//     $agencyNames=$_GET['$agencyName'];
echo "In agency.php-agency_id=".$agency_id.'<br />';				
echo "In agency.php-agent_id=".$agent_id.'<br />';
echo "In agency.php-agencyName=".$agencyName.'<br />';
$data['agency_id']=$agency_id;
$data['agent_id']=$agent_id;
$data['agencyName']=$agencyName;
//session_start();
//$this->session->sess_create();
		$ses_id = $this->session->userdata('id');
echo "In agency.php-ses_id=".$ses_id.'<br />';				
		$ses_user_type = $this->session->userdata('type');
echo "In agency.php-ses_user_type=".$ses_user_type.'<br />';				
		$ses_id = $agent_id;
		$ses_user_type = 0;
//******************Alex	


		$ses_id = $agency_id;
 //               $ses_user_type=$agent_type;

$ses_user_type=0;


		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();

		if($ses_id >0 &&  $ses_user_type == 0 ) {
			$login_user_name=$this->session->userdata('name');
			$this->show_header_2();			
			$data['agencyName'] = $login_user_name;
			$this->load->vars($data);
			//get agency details
			$this->load->model('Agency_mod','',TRUE);
			//$agencyAddressDetails = $this->Agency_mod->get_agencyDetails_mod($ses_id);
			//$this->load->vars($agencyAddressDetails);
			//get agent list
			$this->load->model('Agency_mod','',TRUE);
			$agent_list = $this->Agency_mod->get_agentList_mod($ses_id);
			
			if($agent_list=='no'){
				$data['message'] ='Sorry.You didn\'t create any agent yet.';
				$this->load->vars($data);
				$this->load->view('agency_agencyAdmin_homePage',$data);

			}else{
			//echo $agent_list;
//				$this->load->view('agency_agencyAdmin_manageAgentProfile_top',$data);
				for($i = 0 ; $i < count( $agent_list ); $i++){
				
					$data2['agent_id'] = $agent_list[$i]['user_id'];
					$data2['us_activated'] = $agent_list[$i]['us_activated'];
					$us_image_id_2 = $agent_list[$i]['us_image_id_2'];
					if($i%2==0){
						$data2['bgcolor']='oddRowbg';
					}else{
						$data2['bgcolor']='evenRowbg';
					}
					
					if($us_image_id_2==''){
						$data2['us_image_id_2']='system/application/css/images/agent_photo_03.jpg';
					}else{
						$data2['us_image_id_2']='uploads/people/'.$us_image_id_2;
					}
					$data2['us_first_name']=$agent_list[$i]['us_first_name'];
					$data2['us_surname']=$agent_list[$i]['us_surname'];
					$data2['us_phn_num']=$agent_list[$i]['us_phn_num'];
					$data2['us_fax_num']=$agent_list[$i]['us_fax_num'];
					$data2['us_email']=$agent_list[$i]['us_email']; 

//************Alex
$data2['agency_id']=$agency_id; 
$agent_id=$agent_list[$i]['user_id'];
$data2['agent_id']=$agent_id;
$data2['agent_type']=$agent_type;
$data2['agencyName']=$agencyName;
//************Alex

					$this->load->vars($data2);
					$this->load->view('agency_agencyAdmin_manageAgentProfile_whiteLine');
					$this->load->view('agency_agencyAdmin_manageAgentProfile_showAgent',$data2);
					
				}//end for loop
				$this->load->view('agency_agencyAdmin_manageAgentProfile_whiteLine');
				$this->load->view('agency_agencyAdmin_manageAgentProfile_whiteLine');
				$this->load->view('agency_agencyAdmin_manageAgentProfile_bottom');
				
			}//end if	if($agent_list=='no')
			$this->load->view('footer');
		}else{
			$this->agency_access_control_error_page();
		}//endif ==> if($ses_id >0) 

	}	
/*
	Function Name: agency_add_agentProfile()
	Function Details: Add Agent profile by Agency
	Status: 100% done
*/
	function agency_add_agentProfile($ses_id, $ses_user_type){

//*************Alex		
//		$ses_id = $this->session->userdata('id');
//		$ses_user_type = $this->session->userdata('type');
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();
		$this->load->model('Common_mod','',TRUE);
			$suburb_list = $this->Common_mod->load_suburb_list();
			$data['suburb_list']=$suburb_list;
		if($ses_id >0 &&  $ses_user_type == 0 ) {
			$login_user_name=$this->session->userdata('name');
			$this->show_header_2();
			$data['uemailError']='';
			$data['image_error']='';
			$data['agencyName'] = $login_user_name;
			$this->load->vars($data);
			$this->load->view('agency_agencyAdmin_addAgentProfile',$data);
			$this->load->view('footer');
		}else{
			$this->agency_access_control_error_page();
		}//endif ==> if($ses_id >0) 
		
	
	}
/*
	Function Name: agency_add_agentProfile_mod()
	Function Details: Add Agent profile by Agency -MOD
	Status: 100% done
*/
	function agency_add_agentProfile_mod($ses_id, $ses_user_type){

//************Alex			
//              $ses_id = $this->session->userdata('id');
//              $ses_user_type = $this->session->userdata('type');
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();
		$this->load->model('Common_mod','',TRUE);
			$suburb_list = $this->Common_mod->load_suburb_list();
			$data['suburb_list']=$suburb_list;

		if($ses_id >0 &&  $ses_user_type == 0 ) {
			$login_user_name=$this->session->userdata('name');
			$this->show_header_2();
			$this->load->helper('url');
			$data['agencyName'] = $login_user_name;
			//upload image
			$config['upload_path'] = './uploads/people/';
			$config['allowed_types'] = 'gif|jpg|png';
			$config['max_size']	= '2048';
			//$config['max_width']  = '0';
			//$config['max_height']  = '0';
			$this->load->helper(array('form', 'url'));
			$this->load->library('upload', $config);
			$image_up = $this->upload->do_upload('image');
			
			//--  upload image end
			$error='';
			if($_FILES['image']['name'] != ''){//pic is request for upload
				if($_FILES['image']['error'] == 0)
					$image_up_result = 1; //'up'
				elseif($_FILES['image']['error']>0)
					$image_up_result = -1; //'bigPic';
			}else{
				$image_up_result = 0; //'noPic';
			}
			
			if($image_up_result == 0){
					$data['uemailError']='';
					$data['image_error']=' 	**Please upload an image';
					$this->load->vars($data);
					$this->load->view('agency_agencyAdmin_addAgentProfile',$data);
			}
			elseif($image_up_result == -1){
				$data['uemailError']='';
				$data['image_error']=' ** Please upload a image of size less the 2MB.';
				$this->load->vars($data);
				$this->load->view('agency_agencyAdmin_addAgentProfile',$data);

			}
			elseif($image_up_result == 1){
				$image_data = array('upload_data' => $this->upload->data());
				$full_path = $image_data['upload_data']['full_path'];
				$file_path = $image_data['upload_data']['file_path'];
				$file_name = $image_data['upload_data']['file_name'];
				$raw_name = $image_data['upload_data']['raw_name'];
				$file_ext = $image_data['upload_data']['file_ext'];
				$orig_name = $image_data['upload_data']['orig_name'];
				//-- image resize
				$config['image_library'] = 'gd2';
				$config['source_image'] = $full_path;
				$config['create_thumb'] = TRUE;
				$config['maintain_ratio'] = TRUE;
				$config['width'] = 70;
				$config['height'] = 88;
				$this->load->library('image_lib', $config);
				$thumb_result = $this->image_lib->resize();
				if($thumb_result){
					
					$orig_name_thumb = $raw_name.'_thumb'.$file_ext;
					$this->load->model('Agency_mod','',TRUE);
					$error = $this->Agency_mod->createAgent_mod($ses_id,$orig_name,$orig_name_thumb);
				}
			//-- image resize end
			
				if($error['result']==1){
				
					$this->account_activation_email($error['data']);
					$data['message'] ='Agent created successfully.';
					$this->load->vars($data);
					$this->load->view('agency_agencyAdmin_homePage',$data);
				}
				elseif($error=='uemail'){
					$data['uemailError']='** This Email is already used. Please try with another one.';
					$data['image_error']='';
					$this->load->vars($data);
					$this->load->view('agency_agencyAdmin_addAgentProfile',$data);
				}
			}
		$this->load->view('footer');
		}else{
			$this->agency_access_control_error_page();
		}//endif ==> if($ses_id >0) 

	}
/*
	Function Name: agency_edit_agentProfile()
	Function Details: show agent profile
	Status: 100% done
*/
	function agency_edit_agentProfile($agency_id, $agent_id, $agencyName){

//******************Alex				
//		$ses_id = $this->session->userdata('id');
//		$ses_user_type = $this->session->userdata('type');
		$ses_id = $agency_id;
		$ses_user_type = $agent_type;
echo "LLLLLagency_id=".$agency_id.'<br />';
echo "MMMMMagent_id=".$agent_id.'<br />';
echo "NNNNNagencyName=".$agencyName.'<br />';
//******************Alex				
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();

		if($ses_id >0 &&  $ses_user_type == 0 ) {
			$login_user_name=$this->session->userdata('name');
			$this->show_header_2();
			$data['agencyName'] = $login_user_name;
			$this->load->model('Common_mod','',TRUE);
			$suburb_list = $this->Common_mod->load_suburb_list();
			$data['suburb_list']=$suburb_list;
			$this->load->vars($data);

			// show agent details
			$this->load->model('Agency_mod','',TRUE);
			$agent_info = $this->Agency_mod->show_AgentProfile_mod($agent_id);
			
			$agent_info ['agent_id'] =	$agent_id;
			$agent_info ['formValueName'] = $agent_info['us_first_name'];
			$agent_info ['formValueAddress1'] = $agent_info['us_address'];
			$agent_info ['formValueAddress2'] = $agent_info['us_address2'] ;
			//$agent_info ['formValuePostcode'] = $agent_info['us_post_code'];
			$agent_info ['us_suburb_id'] = $agent_info['us_suburb_id'];
			$agent_info ['formValuePhn'] = $agent_info['us_phn_num'];
			$agent_info ['formValueMobile'] = $agent_info['us_mobile_num'];
			$agent_info ['formValueFax'] = $agent_info['us_fax_num'] ;
			$agent_info ['formValueEmail'] = $agent_info['us_email'];

			$us_image_id_2 = $agent_info['us_image_id_2'];
			if($us_image_id_2==''){
				$agent_info ['us_image_id_2']='system/application/css/images/agent_photo_03.jpg';
			}else{
				$agent_info ['us_image_id_2']='uploads/people/'.$us_image_id_2;
			}
			$this->load->vars($agent_info);

//***********************Alex
$data = array('agency_id' => '', 'agent_id' => '', 'agent_type' => '');
$data['agency_id']=$agent_id;  //this needs to be changed later
$data['agent_id']=$agency_id;  //This needs to be changed later
//$data['agent_type']=$agent_type;
//$data['agencyName']=$agencyName;
$this->load->vars($data);

echo "DDDDDDDagency_id=".$agency_id.'<br />';
echo "EEEEEEEWagent_id=".$agent_id.'<br />';
echo "FFFFFFFagencyName=".$agencyName.'<br />';



//***********************Alex

		
			$this->load->view('agency_agencyAdmin_editAgentProfile', $data);
			$this->load->view('footer');
		}else{
			$this->agency_access_control_error_page();
		}//endif ==> if($ses_id >0) 

	}
/*
	Function Name: agency_update_AgentProfile_mod($agency_id, $agent_id, $agencyName)
	Function Details: update agent profile
	Status: 100%
*/

function agency_update_AgentProfile_mod($agency_id, $agent_id, $agencyName){
//******************Alex				
		$ses_id = $this->session->userdata('id');
		$ses_user_type = $this->session->userdata('type');
//		$ses_id = $agent_id;
//		$ses_user_type = $agent_type;

//***********Swap agency_id with agent_id
$dummy=$agency_id;
$agency_id=$agent_id;
$agent_id=$dummy;

echo "In Agency.php-agency_id=".$agency_id.'<br />';
echo "In Agency.php-agent_id=".$agent_id.'<br />';
echo "In Agency.php-agencyName=".$agencyName.'<br />';



		$data['agency_id'] =$agency_id;
		$data['agent_id'] =$agent_id;
		$data['agencyName'] =$agencyName;
//******************Alex				

		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();
$ses_id=32;
$ses_user_type=0;
		if($ses_id >0 &&  $ses_user_type == 0 ) {
			$this->show_header_2();
			$login_user_name=$this->session->userdata('name');
			$data['agencyName'] = $login_user_name;
			$this->load->vars($data);
			//upload image
			$config['upload_path'] = './uploads/people/';
			$config['allowed_types'] = 'gif|jpg|png';
			$config['max_size']	= '2048';
			//$config['max_width']  = '0';
			//$config['max_height']  = '0';
			$this->load->helper(array('form', 'url'));
			$this->load->library('upload', $config);
			$image_up = $this->upload->do_upload('image');
			//--  upload image end
			if($_FILES['image']['name'] != ''){//pic is request for upload
				if($_FILES['image']['error'] == 0)
					$image_up_result = 'up';
				elseif($_FILES['image']['error']>0)
					$image_up_result = 'bigPic';
			}else
				$image_up_result = 'samePic';
			
			
			//===========
				//----- IMAGE UP ---
			if($image_up_result == 'bigPic'){	
				$update_info= -1;
			}
			else{
				if($image_up_result == 'up' || $image_up_result == 'samePic'){
					$image_data = array('upload_data' => $this->upload->data());
					$full_path = $image_data['upload_data']['full_path'];
					$file_path = $image_data['upload_data']['file_path'];
					$file_name = $image_data['upload_data']['file_name'];
					$raw_name = $image_data['upload_data']['raw_name'];
					$file_ext = $image_data['upload_data']['file_ext'];
					$orig_name = $image_data['upload_data']['orig_name'];
					//-- image resize
					$config['image_library'] = 'gd2';
					$config['source_image'] = $full_path;
					$config['create_thumb'] = TRUE;
					$config['maintain_ratio'] = TRUE;
					$config['width'] = 75;
					$config['height'] = 50;
					//$config['new_image'] = $full_path;
					//$config['thumb_marker']= '_thumb';
					$this->load->library('image_lib', $config);
					$thumb_result = $this->image_lib->resize();
					if($thumb_result){
						$orig_name_thumb = $raw_name.'_thumb'.$file_ext;
					}else{
						$orig_name_thumb='';
						$orig_name='';
					}//end thumb_result
				}else{
						$orig_name_thumb='';
						$orig_name='';
				}//end image_up	
				$this->load->model('Agency_mod','',TRUE);
				$update_info = $this->Agency_mod->update_agentProfile_mod($agent_id,$orig_name,$orig_name_thumb);
			}
			
			if($update_info == 1){


echo "prprprpr111111agency_id=".$agency_id.'<br />';
echo "prprprpr222222gent_id=".$agent_id.'<br />';
echo "prprprpr333333agencyName=".$agencyName.'<br />';
		$data['agency_id'] =$agency_id;
		$data['agent_id'] =$agent_id;
		$data['agencyName'] =$agencyName;


					$data['message']='Update Successful';
					$this->load->vars($data);
					$this->load->view('agency_agencyAdmin_homePage',$data);
					$this->load->view('footer');
			}
			elseif($update_info == -1){
				$this->load->model('Common_mod','',TRUE);
				$suburb_list = $this->Common_mod->load_suburb_list();
				$data['suburb_list']=$suburb_list;
				$data['message']='Please upload a image of size less the 2MB.';
				$this->load->vars($data);
				$this->load->view('agency_agencyAdmin_editAgentProfile',$data);
			}
			elseif($update_info == 'pass'){
				$this->load->model('Common_mod','',TRUE);
				$suburb_list = $this->Common_mod->load_suburb_list();
				$data['suburb_list']=$suburb_list;
				$data['message']='Old password not match. Update was not successful. ';
				$this->load->vars($data);
				$this->load->view('agency_agencyAdmin_editAgentProfile',$data);
			}
			else{
					$data['message']='Update was not successful.';
					
					$this->load->vars($data);
					$this->load->view('agency_agencyAdmin_homePage',$data);
					$this->load->view('footer');
			}
			
		}else{
			$this->agency_access_control_error_page();
		}//endif ==> if($ses_id >0) 

}	
/*
	Function Name: agency_remove_agentProfile()
	Function Details: show the details before delete agent profile
	Status: 100% done
*/
	function agency_remove_agentProfile($ses_id, $ses_user_type){
//			$ses_id = $this->session->userdata('id');
//		$ses_user_type = $this->session->userdata('type');
			$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();

		if($ses_id >0 &&  $ses_user_type == 0 ) {
			$this->show_header_2();
			$login_user_name=$this->session->userdata('name');
			$data['agencyName'] = $login_user_name;
			$this->load->vars($data);
			// show agent details
			$this->load->model('Agency_mod','',TRUE);
			$agent_info = $this->Agency_mod->show_AgentProfile_mod($agent_id);
			$agent_info ['agent_id'] =	$agent_id;
			$agent_info ['formValueName'] = $agent_info['us_first_name'];
			$agent_info ['formValueAddress1'] = $agent_info['us_address'];
			$agent_info ['formValueAddress2'] = $agent_info['us_address2'] ;
			//$agent_info ['formValuePostcode'] = $agent_info['us_post_code'];
			$agent_info ['formValuePhn'] = $agent_info['us_phn_num'];
			$agent_info ['formValueMobile'] = $agent_info['us_mobile_num'];
			$agent_info ['formValueFax'] = $agent_info['us_fax_num'] ;
			$agent_info ['formValueEmail'] = $agent_info['us_email'];
			$this->load->vars($agent_info);
			
			$this->load->view('agency_agencyAdmin_removeAgentProfile',$data);
			$this->load->view('footer');
		}else{
			$this->agency_access_control_error_page();
		}//endif ==> if($ses_id >0) 

	}
/*
	Function Name: agency_remove_agentProfile()
	Function Details: delete agent profile
	Status: 100% done
*/
	function agency_remove_agentProfile_mod($ses_id, $ses_user_type){
	
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();
//		$ses_id = $this->session->userdata('id');
//		$ses_user_type = $this->session->userdata('type');
		
		if($ses_id >0 &&  $ses_user_type == 0 ) {
			$this->show_header_2();
			$login_user_name=$this->session->userdata('name');
			
			$data['agencyName'] = $login_user_name;
			$this->load->vars($data);
			// show agent details
			$this->load->model('Agency_mod','',TRUE);
			$result = $this->Agency_mod->deleteAgent_mod($agent_id);
			if($result)
				$data['message']='Agent profile deleted successfully';
			else{
				$data['message']='Agent profile can\'t delete';
			}
			$this->load->vars($data);
			$this->load->view('agency_agencyAdmin_homePage',$data);
			$this->load->view('footer');
		}else{
			$this->agency_access_control_error_page();
		}//endif ==> if($ses_id >0) 

	}


/*
	Function Name: agency_manage_agentProperty()
	Function Details: Show all Property List for edit
	Status: 100% done
*/
	function agency_manage_agentProperty($ses_id, $ses_user_type){
	
//		$ses_id = $this->session->userdata('id');
//		$ses_user_type = $this->session->userdata('type');
		$login_user_name=$this->session->userdata('name');
		$data['agencyName'] = $login_user_name;
		$this->load->vars($data);
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();
		
		$totalProperty = 0;

		if($ses_id >0 &&  $ses_user_type == 0 ) {
		$this->load->model('Agency_mod','',TRUE);
	
			if (isset($_POST['btnSatus'])){
				$status = $this->input->post('statusCombo');
				if($status == 1){
					$this->agency_manage_active_property();
				}
				else if($status == 0){
					$this->agency_manage_inactive_property();
				}else{
					$this->agency_manage_block_property();
				}
				
			}
			else{
				$activation_option = '= 1' ;
				$total_active_property = $this->Agency_mod->count_propertyList_mod( $ses_id, $activation_option );
			
				if($total_active_property <= 0){
					$activation_option = '= 0' ;
					$total_inactive_property = $this->Agency_mod->count_propertyList_mod( $ses_id, $activation_option );
					//echo 'in the property inactive1';
					if($total_inactive_property<=0){
						$activation_option = '>= 2' ;
						$total_block_property = $this->Agency_mod->count_propertyList_mod( $ses_id, $activation_option );
						
						if($total_block_property<=0){
							$totalProperty = -1;
							
						}else{
							$this->agency_manage_block_property();
							
						}
					}else{
						$this->agency_manage_inactive_property();
						
					}
				}else{
					$this->agency_manage_active_property();
					
				}
				
			}
			
			if($totalProperty == -1){
				$message='No Result found under Active/Inactive/Block Status.';
				$this->show_agency_homePage($message);
			}
			
		}else{
			$this->member_access_control_error_page();
		}//endif ==> if($ses_id >0) 

	}



/*
	Manage ACTIVE property
*/
	function agency_manage_active_property($ses_id, $ses_user_type){
		
//		$ses_id = $this->session->userdata('id');
//		$ses_user_type = $this->session->userdata('type');
		$login_user_name=$this->session->userdata('name');
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();
		$data['agencyName']=$login_user_name;
		$this->load->vars($data);
		$this->load->model('Agency_mod','',TRUE);
		
		$activation_option = '= 1' ;
		$totalProperty = $this->Agency_mod->count_propertyList_mod( $ses_id, $activation_option );
		if($totalProperty<=0)
			$totalProperty = -1;
		if($totalProperty != -1){
				
			$this->load->library('pagination');
			$config['base_url'] = base_url().'index.php/admin/agency/agency_manage_active_property/';
			$config['total_rows'] = $totalProperty;
			$config['per_page'] = '15';
			$config['num_links'] = '3';
			$config['uri_segment'] = 4;
			$config['full_tag_open'] = '<div >';
			$config['full_tag_close']= '</div>';
			$config['last_link'] = 'Last Page&gt;';
			$config['first_link'] = '&lt; First Page';
			$config['next_link'] = 'Next Page';
			$config['prev_link'] = 'Previous Page';
			$config['link_css'] = 'class="link_green"';
			$this->pagination->initialize($config);	
			$property_details_active = $this->Agency_mod->show_propertyList_mod( $ses_id, $activation_option,$config['per_page'],$this->uri->segment(4) );
			
			if($property_details_active !='no'){
				$this->show_header_2();

                                $this->load->view('heading_7');				

				$this->load->view('agency_agencyAdmin_manageAgentProperty_top',$data);
			
				$data1['head_value'] ='Activated Property';
				$bgcolor['bgcolor'] = '#65848A';
				$this->load->view('sell_members_manageProperty_whiteLine');
				$this->load->view('sell_members_manageProperty_borderLine',$bgcolor);
				$this->load->view('sell_members_manageProperty_whiteLine');
				$this->load->view('sell_members_manageProperty_activeInactive_header',$data1);
				for ($i = 0 ; $i < count($property_details_active); $i++){
					$single_pr_details = $property_details_active[$i];
					$single_pr_details['ses_user_type'] = $ses_user_type;
				$this->load->view('sell_members_manageProperty_whiteLine');
				$this->load->view('agency_agencyAdmin_manageAgentProperty_propertyInfo',$single_pr_details);
				}		
				$this->load->view('sell_members_manageProperty_whiteLine');
				$this->load->view('sell_members_manageProperty_bottom');
				$this->load->view('footer');
			}
			else if($property_details_active =='no' ){
				//----------if not get data---
				$message='No Result found under `Active` Status.';
				$this->show_agency_homePage($message);
			}
				
		}else{
			$message='No Result found under `Active` Status.';
			$this->show_agency_homePage($message);
		}
	}
/*
	Manage InACTIVE property
*/
	function agency_manage_inactive_property($ses_id, $ses_user_type){
		
//		$ses_id = $this->session->userdata('id');
//		$ses_user_type = $this->session->userdata('type');
		$login_user_name=$this->session->userdata('name');
		
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();
		$data['agencyName']=$login_user_name;
		$this->load->vars($data);
		$this->load->model('Agency_mod','',TRUE);
		
		$activation_option = '= 0' ;
		$totalProperty = $this->Agency_mod->count_propertyList_mod( $ses_id, $activation_option );
		if($totalProperty<=0)
			$totalProperty = -1;
		if($totalProperty != -1){
				
			$this->load->library('pagination');
			$config['base_url'] = base_url().'index.php/admin/agency/agency_manage_inactive_property/';
			$config['total_rows'] = $totalProperty;
			$config['per_page'] = '15';
			$config['num_links'] = '3';
			$config['uri_segment'] = 4;
			$config['full_tag_open'] = '<div >';
			$config['full_tag_close']= '</div>';
			$config['last_link'] = 'Last Page&gt;';
			$config['first_link'] = '&lt; First Page';
			$config['next_link'] = 'Next Page';
			$config['prev_link'] = 'Previous Page';
			$config['link_css'] = 'class="link_green"';
			$this->pagination->initialize($config);	
			$property_details_active = $this->Agency_mod->show_propertyList_mod( $ses_id, $activation_option,$config['per_page'],$this->uri->segment(4) );

//echo "activation_option" . $property_details_active;		
			if($property_details_active !='no'){
				$this->show_header_2();
        $this->load->view('heading_7');				
				$this->load->view('agency_agencyAdmin_manageAgentProperty_top');
				$data['head_value'] ='Inactive Properties';
				$bgcolor['bgcolor'] = '#65848A';
				$this->load->view('sell_members_manageProperty_whiteLine');
				$this->load->view('sell_members_manageProperty_borderLine',$bgcolor);
				$this->load->view('sell_members_manageProperty_whiteLine');
				$this->load->view('sell_members_manageProperty_activeInactive_header',$data);
				for ($i = 0 ; $i < count($property_details_active); $i++){
					$single_pr_details = $property_details_active[$i];
					$single_pr_details['ses_user_type'] = $ses_user_type;
				$this->load->view('sell_members_manageProperty_whiteLine');
				$this->load->view('agency_agencyAdmin_manageAgentProperty_propertyInfo',$single_pr_details);
				}		
				$this->load->view('sell_members_manageProperty_whiteLine');
				$this->load->view('sell_members_manageProperty_bottom');
				$this->load->view('footer');
			}
			else if($property_details_active =='no' ){
				//----------if not get data---
				$message='No Result found under `Inactive` Status.';
				$this->show_agency_homePage($message);
			}
				
		}else{
			$message='No Result found under `Inactive` Status.';
			$this->show_agency_homePage($message);
		}
	}
	
/*
	Manage block property
*/
	function agency_manage_block_property($ses_id, $ses_user_type){
		
//		$ses_id = $this->session->userdata('id');
//		$ses_user_type = $this->session->userdata('type');
		$login_user_name=$this->session->userdata('name');
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();
		$data['agencyName']=$login_user_name;
		$this->load->vars($data);
		$this->load->model('Agency_mod','',TRUE);
		
		$activation_option = '>= 2' ;
		$totalProperty = $this->Agency_mod->count_propertyList_mod( $ses_id, $activation_option );
		if($totalProperty<=0)
			$totalProperty = -1;
		if($totalProperty != -1){
				
			$this->load->library('pagination');
			$config['base_url'] = base_url().'index.php/admin/agency/agency_manage_block_property/';
			$config['total_rows'] = $totalProperty;
			$config['per_page'] = '15';
			$config['num_links'] = '3';
			$config['uri_segment'] = 4;
			$config['full_tag_open'] = '<div >';
			$config['full_tag_close']= '</div>';
			$config['last_link'] = 'Last Page&gt;';
			$config['first_link'] = '&lt; First Page';
			$config['next_link'] = 'Next Page';
			$config['prev_link'] = 'Previous Page';
			$config['link_css'] = 'class="link_green"';
			$this->pagination->initialize($config);	
			$property_details_active = $this->Agency_mod->show_propertyList_mod( $ses_id, $activation_option,$config['per_page'],$this->uri->segment(4) );
		
			if($property_details_active !='no'){
				$this->show_header_2();
                                $this->load->view('heading_7');				
				$this->load->view('agency_agencyAdmin_manageAgentProperty_top');
				$data['head_value'] ='Block Property';
				$bgcolor['bgcolor'] = '#65848A';
				$this->load->view('sell_members_manageProperty_whiteLine');
				$this->load->view('sell_members_manageProperty_borderLine',$bgcolor);
				$this->load->view('sell_members_manageProperty_whiteLine');
				$this->load->view('sell_members_manageProperty_activeInactive_header',$data);
				for ($i = 0 ; $i < count($property_details_active); $i++){
					$single_pr_details = $property_details_active[$i];
					$single_pr_details['ses_user_type'] = $ses_user_type;
				$this->load->view('sell_members_manageProperty_whiteLine');
				$this->load->view('agency_agencyAdmin_manageAgentProperty_propertyInfo',$single_pr_details);
				}		
				$this->load->view('sell_members_manageProperty_whiteLine');
				$this->load->view('sell_members_manageProperty_bottom');
				$this->load->view('footer');
			}
			else if($property_details_active =='no' ){
				//----------if not get data---
			$message='No Result found under `Block` Status.';
				$this->show_agency_homePage($message);
			}
				
		}else{
			$message='No Result found under `Block` Status.';
			$this->show_agency_homePage($message);
		}
	}
/*
	Active Inactive property 
*/
	function agency_activeInactive_property( $activation_option,$property_id ){
		//$this->make_http_to_https();
		$this->load->model('Sell_mod','',TRUE);
		$result = $this->Sell_mod->update_property_activation($activation_option,$property_id);
		if($result){
			if($activation_option == 1){
				 redirect('admin/agency/agency_manage_inactive_property','refresh');
				//$this->sell_manage_active_property();
			}
			elseif($activation_option == 0){
				redirect('admin/agency/agency_manage_active_property','refresh');
			}
		
		}	
	}
	
/*
	Function Name: agency_edit_AgentProperty()
	Function Details: Edit a perticular Property 
	Status: not!
*/	
	function agency_edit_AgentProperty($ses_id, $ses_user_type){
//		$ses_id = $this->session->userdata('id');
		$this->session->set_userdata('property_photos', false);
		$this->session->set_userdata('profilePhoto','');
//		$ses_user_type = $this->session->userdata('type');
		$login_user_name=$this->session->userdata('name');
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();

		if($ses_id >0 &&  $ses_user_type == 0 ) {
			
			$this->show_header_2();
$this->load->view('heading_7');
			
			$data['agencyName'] = $login_user_name;
			$data['property_id']=$property_id;
			$this->load->model('Common_mod','',TRUE);
			$suburb_list = $this->Common_mod->load_suburb_list();
			$data['suburb_list']=$suburb_list;
			$street_list = $this->Common_mod->load_street_name();
			$data['street_list']=$street_list;
			//---end suburb list
			$this->load->vars($data);
			$this->load->model('Agency_mod','',TRUE);
			$property_details = $this->Agency_mod->get_property_details_forAgency($property_id,$ses_id);
			if($property_details=='noAgent'){
				$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
				$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
				$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();
				$message='Property Agent Has been deleted.';
				$this->load->view('agency_agencyAdmin_homePage',$message);
				$this->load->view('footer');
			}else{
				//----------Profile PICTURE
				//$ses_profile_photos[$property_id] = $property_details['pr_profile_pic'];
				//$this->session->set_userdata('profilePhoto', $ses_profile_photos);
				//print_r($this->session->userdata);
				//----------Profile PICTURE
				if($property_details['edit_counter'] == 2){
						$emailData['user_id'] = $ses_id;
						$emailData['user_type'] = $ses_user_type;
						$emailData['user_name'] = $login_user_name;
						$emailData['pr_id'] = $property_id;
						$this->sendEmail_toAdmin_forPropertyEdit($emailData);
					}
				$this->load->vars($property_details);
				$this->load->view('agency_agencyAdmin_editAgentProperty',$data,$property_details);
				$this->load->view('footer');
			}
		}else{
			$this->agency_access_control_error_page();
		}//endif ==> if($ses_id >0) 

	}
/*
	Function Name: agency_update_AgentProperty()
	Function Details: Edit a perticular Property 
	Status: not!
*/	
	function agency_update_AgentProperty($agency_id, $agent_id, $agencyNmae){
//		$ses_id = $this->session->userdata('id');
//		$ses_user_type = $this->session->userdata('type');
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();
//*************************Alex
$ses_user_type=0;
$ses_id=$agent_id;

echo "wwwwwwwwagency_id=".$agency_id.'<br />';
echo "xxxxxxxxagent_id=".$agent_id.'<br />';
echo "yyyyyyyyagencyName=".$agencyName.'<br />';
//******************Alex


		if($ses_id >0 &&  $ses_user_type == 0 ) {
			$this->show_header_2();
			$login_user_name=$this->session->userdata('name');
			$data['agencyName'] = $login_user_name;
			$data['property_id']=$property_id;
			$this->load->vars($data);
			$this->load->model('Agency_mod','',TRUE);
			$update_result = $this->Agency_mod->update_property_details_forAgency($property_id,$ses_id);
			if($update_result){
					$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
					$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
					$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();
					$data['message']='Update Successful';
				}


//************Alex
$data['agency_id']=$agency_id; 
$data['agent_id']=$agent_id;
$data['agencyName']=$agencyName;
echo "PPPPPPagency_id=".$agency_id.'<br />';
echo "QQQQQQagent_id=".$agent_id.'<br />';
echo "RRRRRRagencyName=".$agencyName.'<br />';

//************Alex


			$this->load->view('agency_agencyAdmin_homePage',$data);
			$this->load->view('footer');
		}else{
			$this->agency_access_control_error_page();
		}//endif ==> if($ses_id >0) 

	}	
/*
	Function Name: agency_remove_agentProperty()
	Function Details: show the details before delete agent property
	Status: 100% done
*/
	function agency_remove_agentProperty($ses_id, $ses_user_type){
//		$ses_id = $this->session->userdata('id');
//		$ses_user_type = $this->session->userdata('type');
		
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();

		if($ses_id >0 &&  $ses_user_type == 0 ) {
			$this->show_header_2();
			$login_user_name=$this->session->userdata('name');
			$data['agencyName'] = $login_user_name;
			$data['property_id']=$property_id;
			$this->load->vars($data);
			// show agent details
			$this->load->model('Agency_mod','',TRUE);
			$property_details = $this->Agency_mod->get_property_details_forAgency($property_id,$ses_id);
			//print_r($property_details);
			$this->load->vars($property_details);
			$this->load->view('agency_agencyAdmin_removeAgentProperty',$data);
			$this->load->view('footer');
		}else{
			$this->agency_access_control_error_page();
		}//endif ==> if($ses_id >0) 

	}

/*
	Function Name: agency_remove_AgentProperty_mod()
	Function Details: Edit profile
	Status: not!
*/
	function agency_remove_AgentProperty_mod($ses_id, $ses_user_type, $property_id){
	
//		$ses_id = $this->session->userdata('id');
//		$ses_user_type = $this->session->userdata('type');
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();

		if($ses_id >0 &&  $ses_user_type == 0 ) {
			$this->show_header_2();
			$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
			$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
			$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();
			$login_user_name=$this->session->userdata('name');
			
			$data['agencyName'] = $login_user_name;
			$this->load->vars($data);
			// show agent details
			$this->load->helper('url');
			$this->load->model('Agency_mod','',TRUE);
			$result = $this->Agency_mod->remove_property_byAgency($property_id);
			//$result = $this->Agency_mod->remove_property_byAgency($property_id);

			if($result)
				$data['message']='Agent property deleted successfully';
			else{
				$data['message']='Agent property can\'t delete';
			}
			$this->load->vars($data);
			$this->load->view('agency_agencyAdmin_homePage',$data);
			$this->load->view('footer');
		}else{
			$this->agency_access_control_error_page();
		}//endif ==> if($ses_id >0) 

	}


/*
	Function Name: agency_manage_agentAccount()
	Function Details: Show all Property List for edit
	Status: not!
*/
	function agency_manage_agentAccount($ses_id, $ses_user_type){
//		$ses_id = $this->session->userdata('id');
//		$ses_user_type = $this->session->userdata('type');
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();

		if($ses_id >0 &&  $ses_user_type == 0 ) {
			$this->show_header_2();
			$member_type=0;
			$this->load->model('Package_mod','',TRUE);
			$packageList = $this->Package_mod->get_package_list($member_type);
			$data['packageList']= $packageList;
			$remainPropertyList = $this->Package_mod->load_property_listing($ses_id,0);
			$data['remainPropertyList']=$remainPropertyList;
			$login_user_name=$this->session->userdata('name');
			$data['agencyName'] = $login_user_name;
			$this->load->vars($data);
			$this->load->view('agency_agencyAdmin_accountManage',$data);
			$this->load->view('footer');
		}else{
			$this->agency_access_control_error_page();
		}//endif ==> if($ses_id >0) 
	}
	
//----------------- Common Functions -----------

/*
	show_agency_homePage
*/
	function show_agency_homePage($message){
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();
		$login_user_name=$this->session->userdata('name');
		$this->show_header_2();
		$data['message']=$message;
		$data['agencyName'] = $login_user_name;
		$this->load->vars($data);
		$this->load->view('agency_agencyAdmin_homePage',$data);
		$this->load->view('footer');
	}
/*
	agency_access_control_error_page
*/
	function agency_access_control_error_page(){
		$this->show_header_2();
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();
		$news = $this-> show_SiteNews();

		if ($news!=-1){
			$data['siteNews'] =$news;
		}else{
		$data['siteNews']='';
		}
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['uemailError']='';
		$data['loginErrorMsg']='**Please do login to access this page';
		$this->load->vars($data);
		$this->load->view('sell_home',$data);
		$this->load->view('footer');

	}
/*
Agency activation Email send
*/
	function account_activation_email($data){
		$user_name = $data['us_first_name'];
		$pass = $data['pass'];
		$email = $data['us_email'];
		$message ='';
		$message = $message. '<div style="border:1px solid #CCCCFF; background-color::#CCFFFF;width:700px;padding:20px;">';
		$message = $message. '<table width="100%" bgcolor="#FFFFFF" cellpadding="3" cellspacing="3" style="margin:0px auto;text-align:center; font-size:12px; font-weight:normal; font-family:verdana,arial;">';		
		$message = $message. '<tr><td style="color:#FFFFFF" align="center" bgcolor="#00CCCC">';
		$message = $message. '<h2> localhost/cairns/public_html </h2>';
		$message = $message. '<div style="background-color:#666666; font-size:11px; text-align:right; color:#FFCCFF;">'. date('m/d/Y H:i:s A') .'&nbsp; </div>';
  	        $message = $message. '</td></tr><tr><td align="left"><p>Dear3 '.$user_name.', </p>';

		$message = $message. '<p> Congratulations! Your account has been created & activated by your Agency.</p><br/>';
		$message = $message. '<p>Your login id: '.$email.' and password is:'.$pass. '. </p>Thanks for being with us. <br><br>';
		$message = $message. '<p>localhost/cairns/public_html will provide you with the exposure to the right target audience at an affordable price. Wtih a quick and easy search function, you will have the maximum rate of views for your property. </p>';
		$message = $message. '<p>localhost/cairns/public_html will provide you with the exposure to the right target audience at an affordable price. Wtih a quick and easy search function, you will have the maximum rate of views for your property.localhost/cairns/public_html will provide you with the exposure to the right target audience at an affordable price. Wtih a quick and easy search function, you will have the maximum rate of views for your property. </p> ';
		$message = $message. '<p style="padding:0px 10px 20px 0px;margin:0px;">&nbsp;</p></td></tr>';
		$message = $message. '<tr><td align="left"><p>Thanks <br />';
		$message = $message. 'localhost/cairns/public_html </p>';
		$message = $message. '<p><a href="http://www.localhost/cairns/public_html/index.php">http://www.localhost/cairns/public_html/index.php </a> </p></td></tr>';
		$message = $message. '<tr bgcolor="#D6E0C7" height="5"><td align="left"></td></tr></table></div>';

			
		$recipient = $data['us_email'];
		$sender = 'info@localhost/cairns/public_html';
		$subject ='Dear,'.$user_name.' your account activation email';
		$this->load->library('email');
		$config['mailtype']= 'html';
		$this->email->initialize($config);
		
		$this->email->from( $sender, 'Golden Fleece International Real Estate and Finance Team');
		$this->email->to($recipient);
		$this->email->subject($subject);
		$this->email->message($message);
		$this->email->send();
		//print_r($this->email->print_debugger());
		
	}







/*
Sell Report For Agent
*/	
	function agency_showPropertyList_AgentSell($user_id){
	
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();
		$report_type='sell';
		$agency_id='NULL';
		$this->show_header_2();
		$this->load->helper('url');
		$data['agent_id']=$user_id;
		$login_user_name=$this->session->userdata('name');
			$data['agencyName'] = $login_user_name;
		$this->load->vars($data);	
		
		$this->load->model('Agency_mod','',TRUE);
		//-------------
		$this->load->library('pagination');
		$config['base_url'] = base_url().'index.php/admin/agency/agency_showPropertyList_AgentSell/'.$user_id.'/';
		$config['total_rows'] = $this->Agency_mod->count_sellRental_propertyList($agency_id, $user_id, $report_type);
		$config['per_page'] = '10';
		$config['num_links'] = '3';
		$config['uri_segment'] = 4;
		$config['full_tag_open'] = '<div>';
		$config['full_tag_close']= '</div>';
		$config['last_link'] = 'Last Page&gt;';
		$config['first_link'] = '&lt; First Page';
		$config['next_link'] = 'Next Page';
		$config['prev_link'] = 'Previous Page';
		$this->pagination->initialize($config);
		if($this->uri->segment(4) =='')
			$offset =0;
		else	
			$offset = $this->uri->segment(4);
		//load the model and get results
	
		$sell_property = $this->Agency_mod->sellRental_propertyList_show($agency_id, $user_id, $report_type);
		
		if($sell_property!=-1){
			$data3['sub_title']='Sale Property List';
			$this->load->view('agency_agencyAdmin_manageAgentSellRentProperty_top',$data3);
			for($i = 0; $i < count($sell_property) ; $i++){
				$sell_property_report = $sell_property[$i];
				//print_r($sell_property[$i]);
				//echo '<br/>';
				if($i%2 == 0)
					$data2['bgcolor'] ='oddRowbg';
				else	
					$data2['bgcolor'] ='bgcolor="#EFEFEF"';
				$this->load->vars($data2);	
				$this->load->view('sell_members_manageProperty_whiteLine');
				//$this->load->view('agency_agencyAdmin_sellRentAgentProperty_propertyInfo',$sell_property_report);
				$this->load->view('agency_agencyAdmin_manageAgentProperty_propertyInfo',$sell_property_report);
				$this->load->view('sell_members_manageProperty_whiteLine');
			}	
			$this->load->view('sell_members_manageProperty_whiteLine');
			$this->load->view('sell_members_manageProperty_bottom');
		}
		else{
			//$this->load->view('agencySearch_searchResult_rentSell_propertyList_top');
			$data3['sub_title']='Sale Property List';
			$this->load->view('agency_agencyAdmin_manageAgentSellRentProperty_top',$data3);
			$data2['msg']='Agent Has no Sell Property';
			$data2['bgcolor'] ='bgcolor="#d2d2d2"';
			$this->load->vars($data2);	
			$this->load->view('sell_members_manageProperty_whiteLine');
			$this->load->view('agency_agencyAdmin_manageAgentProperty_propertyInfo_noResult',$data2);
			$this->load->view('sell_members_manageProperty_whiteLine');
			$this->load->view('sell_members_manageProperty_bottom');
		}
		
		
		$this->load->view('footer');
	}
/*
Rent List for Agent
*/
	function agency_showPropertyList_AgentRent($user_id){
		$data['sell_left_ads_banner'] = $this->show_sell_left_ads();
		$data['sell_mid_ads_banner'] = $this->show_sell_mid_ads();
		$data['sell_rite_ads_banner'] = $this->show_sell_rite_ads();
		$report_type='rent';
		$agency_id='NULL';
		$this->show_header_2();
		//===fetch suburb list
		$login_user_name=$this->session->userdata('name');
			$data['agencyName'] = $login_user_name;
		$this->load->vars($data);	
		$this->load->model('Agency_mod','',TRUE);
		//-------------
		$this->load->library('pagination');
		$config['base_url'] = base_url().'index.php/admin/agency/agency_showPropertyList_AgentRent/'.$user_id.'/';
		$config['total_rows'] = $this->Agency_mod->count_sellRental_propertyList($agency_id, $user_id, $report_type);
		print_r($config['total_rows']);
		$config['per_page'] = '10';
		$config['num_links'] = '3';
		$config['uri_segment'] = 4;
		$config['full_tag_open'] = '<div>';
		$config['full_tag_close']= '</div>';
		$config['last_link'] = 'Last Page&gt;';
		$config['first_link'] = '&lt; First Page';
		$config['next_link'] = 'Next Page';
		$config['prev_link'] = 'Previous Page';
		$this->pagination->initialize($config);
		if($this->uri->segment(4) =='')
			$offset =0;
		else	
			$offset = $this->uri->segment(4);
		//load the model and get results
	
		$sell_property = $this->Agency_mod->sellRental_propertyList_show($agency_id, $user_id, $report_type);
		if($sell_property!=-1){
			$data3['sub_title']='Sale Property List';
			$this->load->view('agency_agencyAdmin_manageAgentSellRentProperty_top',$data3);
			for($i = 0; $i < count($sell_property) ; $i++){
				$sell_property_report = $sell_property[$i];
				//print_r($sell_property[$i]);
				//echo '<br/>';
				if($i%2 == 0)
					$data2['bgcolor'] ='bgcolor="#d2d2d2"';
				else	
					$data2['bgcolor'] ='bgcolor="#A9A9A9"';
				$this->load->vars($data2);	
				$this->load->view('sell_members_manageProperty_whiteLine');
				//$this->load->view('agency_agencyAdmin_sellRentAgentProperty_propertyInfo',$sell_property_report);
				$this->load->view('agency_agencyAdmin_manageAgentProperty_propertyInfo',$sell_property_report);
				$this->load->view('sell_members_manageProperty_whiteLine');
					
				
			}	
			$this->load->view('sell_members_manageProperty_whiteLine');
			$this->load->view('sell_members_manageProperty_bottom');
		}
		else{
			$data3['sub_title']='Rent Property List';
			$this->load->view('agency_agencyAdmin_manageAgentSellRentProperty_top',$data3);
			$data2['msg']='Agent Has no Rent Property';
			$data2['bgcolor'] ='bgcolor="#d2d2d2"';
			$this->load->vars($data2);	
			$this->load->view('sell_members_manageProperty_whiteLine');
			$this->load->view('agency_agencyAdmin_manageAgentProperty_propertyInfo_noResult',$data2);
			$this->load->view('sell_members_manageProperty_whiteLine');
			$this->load->view('sell_members_manageProperty_bottom');
		}
		
		
		$this->load->view('footer');
	}
	
	function show_header_2(){
		
		$header = array(
       	'title' => 'Welcome to Golden Fleece International Property Guide',
		'onload'=> false  ,'googleMap'=> false                            
          );
		//-------show banner----
		$this->load->model('Banner_articles_mod','',TRUE); 
		$bannerAry = $this->Banner_articles_mod->banner_show('Header');
		if($bannerAry!=-1){
			if($bannerAry['type']== 'swf'){
				$header['header_banner'] ='';	
				$buy_ads_banner ='';
				$buy_ads_banner=$buy_ads_banner.'<object width="300" height="90">';
				$buy_ads_banner=$buy_ads_banner.'<param name="movie" value="'.$this->config->slash_item('secure_base_url').'uploads/banners/'.$bannerAry['image'].'"></param>';
				$buy_ads_banner=$buy_ads_banner.'<param name="allowFullScreen" value="true"></param>';
				$buy_ads_banner=$buy_ads_banner.'<param name="allowscriptaccess" value="always"></param>';
				$buy_ads_banner=$buy_ads_banner.'<embed src="'.$this->config->slash_item('secure_base_url').'uploads/banners/'.$bannerAry['image'].'" type="application/x-shockwave-flash" ';
				$buy_ads_banner=$buy_ads_banner.'allowscriptaccess="always" allowfullscreen="true" width="290"'; 
				$buy_ads_banner=$buy_ads_banner.'height="90"></embed></object>';
				$header['header_banner'] =$buy_ads_banner;
			}else{
				$header['header_banner'] ='';
				$header['header_banner']  = $header['header_banner'] . ' <a href="'.$bannerAry['url'].'"';
				if($bannerAry['new_window']==1)
					$header['header_banner']  = $header['header_banner'] . ' target="_blank" ';
				$header['header_banner']  = $header['header_banner'] . ' >';
				$header['header_banner'] = $header['header_banner']. ' <img';
				if($bannerAry['title']!='')
					$header['header_banner'] = $header['header_banner']. ' title= "'. $bannerAry['title'] .'" ';
				$header['header_banner'] = $header['header_banner']. ' src="'.$this->config->slash_item('secure_base_url').'uploads/banners/'.$bannerAry['image'].'" ';
				$header['header_banner'] = $header['header_banner']. ' width="300" height="90" style="border:1px solid green;" ';
				if($bannerAry['alt']!='')
					$header['header_banner'] = $header['header_banner']. ' alt="'.$bannerAry['alt'].'" ';
				$header['header_banner'] = $header['header_banner']. ' /></a>';
			}
		}else{
			$header['header_banner']  = '<a href="#"><img title="no banner" alt="no banner" src="'.$this->config->slash_item('secure_base_url').'system/application/css/images/no_banner_adv_08.jpg" style="border:2px outset #327F7F;" width="300" height="90"/></a>';
		}		
		$header['baseUrlType']='secure_base_url';	 	 
		$this->load->view('header_2', $header);
		
	}
	
	function show_SiteNews(){
		$this->load->model('Banner_articles_mod','',TRUE); 
		$news = $this->Banner_articles_mod->news_show('SP');
		return $news;
	}
	
	function show_sell_left_ads(){
		
		$this->load->model('Banner_articles_mod','',TRUE); 
		$bannerAry = $this->Banner_articles_mod->banner_show('Sell Left');
		if($bannerAry!=-1){
			if($bannerAry['type']== 'swf'){
				$buy_ads_banner ='';
				$buy_ads_banner=$buy_ads_banner.'<object width="290" height="240">';
				$buy_ads_banner=$buy_ads_banner.'<param name="movie" value="'.$this->config->slash_item('secure_base_url').'uploads/banners/'.$bannerAry['image'].'"></param>';
				$buy_ads_banner=$buy_ads_banner.'<param name="allowFullScreen" value="true"></param>';
				$buy_ads_banner=$buy_ads_banner.'<param name="allowscriptaccess" value="always"></param>';
				$buy_ads_banner=$buy_ads_banner.'<embed src="'.$this->config->slash_item('secure_base_url').'uploads/banners/'.$bannerAry['image'].'" type="application/x-shockwave-flash" ';
				$buy_ads_banner=$buy_ads_banner.'allowscriptaccess="always" allowfullscreen="true" width="290"'; 
				$buy_ads_banner=$buy_ads_banner.'height="240"></embed></object>';
			}else{
				$buy_ads_banner ='';
				$buy_ads_banner = $buy_ads_banner. ' <a href="'.$bannerAry['url'].'" >';
				$buy_ads_banner = $buy_ads_banner. '<img ';
				if( $bannerAry ['title' ] != '' )
					$buy_ads_banner = $buy_ads_banner. ' title= "'.$bannerAry['title'].'" ';
					
				$buy_ads_banner = $buy_ads_banner. ' src="'.$this->config->slash_item('secure_base_url').'uploads/banners/'.$bannerAry['image'].'" ';
				$buy_ads_banner = $buy_ads_banner. ' style="border:1px solid black;" width="290" height="240" ';
				if($bannerAry['alt'] !='')
					$buy_ads_banner = $buy_ads_banner. ' alt="'.$bannerAry['alt'].'" ';
				$buy_ads_banner = $buy_ads_banner . ' /></a>';
			}
		}else{
			$buy_ads_banner  = '<a href="#"><img title="no banner" alt="no banner" src="'.$this->config->slash_item('secure_base_url').'system/application/css/images/no_banner_adv_07.jpg" style="border:1px solid black;" width="290" height="240"/></a>';
		}		
		//-------show banner end----
		return 	$buy_ads_banner;
		
	}
	function show_sell_mid_ads(){
		
		$this->load->model('Banner_articles_mod','',TRUE); 
		$bannerAry = $this->Banner_articles_mod->banner_show('Sell Middle');
		if($bannerAry!=-1){
			if($bannerAry['type']== 'swf'){
				$buy_ads_banner ='';
				$buy_ads_banner=$buy_ads_banner.'<object width="290" height="240">';
				$buy_ads_banner=$buy_ads_banner.'<param name="movie" value="'.$this->config->slash_item('secure_base_url').'uploads/banners/'.$bannerAry['image'].'"></param>';
				$buy_ads_banner=$buy_ads_banner.'<param name="allowFullScreen" value="true"></param>';
				$buy_ads_banner=$buy_ads_banner.'<param name="allowscriptaccess" value="always"></param>';
				$buy_ads_banner=$buy_ads_banner.'<embed src="'.$this->config->slash_item('secure_base_url').'uploads/banners/'.$bannerAry['image'].'" type="application/x-shockwave-flash" ';
				$buy_ads_banner=$buy_ads_banner.'allowscriptaccess="always" allowfullscreen="true" width="290"'; 
				$buy_ads_banner=$buy_ads_banner.'height="240"></embed></object>';
			}else{
				$buy_ads_banner ='';
				$buy_ads_banner = $buy_ads_banner. ' <a href="'.$bannerAry['url'].'" >';
				$buy_ads_banner = $buy_ads_banner. '<img ';
				if( $bannerAry ['title' ] != '' )
					$buy_ads_banner = $buy_ads_banner. ' title= "'.$bannerAry['title'].'" ';
					
				$buy_ads_banner = $buy_ads_banner. ' src="'.$this->config->slash_item('secure_base_url').'uploads/banners/'.$bannerAry['image'].'" ';
				$buy_ads_banner = $buy_ads_banner. ' style="border:1px solid black;" width="290" height="240" ';
				if($bannerAry['alt'] !='')
					$buy_ads_banner = $buy_ads_banner. ' alt="'.$bannerAry['alt'].'" ';
				$buy_ads_banner = $buy_ads_banner . ' /></a>';
			}
		}else{
			$buy_ads_banner  = '<a href="#"><img title="no banner" alt="no banner" src="'.$this->config->slash_item('secure_base_url').'system/application/css/images/no_banner_adv_07.jpg" style="border:1px solid black;" width="290" height="240"/></a>';
		}		
		return 	$buy_ads_banner;
		
	}
	function show_sell_rite_ads(){
		
		$this->load->model('Banner_articles_mod','',TRUE); 
		$bannerAry = $this->Banner_articles_mod->banner_show('Sell Right');
		if($bannerAry!=-1){
			if($bannerAry['type']== 'swf'){
				$buy_ads_banner ='';
				$buy_ads_banner=$buy_ads_banner.'<object width="290" height="240">';
				$buy_ads_banner=$buy_ads_banner.'<param name="movie" value="'.$this->config->slash_item('secure_base_url').'uploads/banners/'.$bannerAry['image'].'"></param>';
				$buy_ads_banner=$buy_ads_banner.'<param name="allowFullScreen" value="true"></param>';
				$buy_ads_banner=$buy_ads_banner.'<param name="allowscriptaccess" value="always"></param>';
				$buy_ads_banner=$buy_ads_banner.'<embed src="'.$this->config->slash_item('secure_base_url').'uploads/banners/'.$bannerAry['image'].'" type="application/x-shockwave-flash" ';
				$buy_ads_banner=$buy_ads_banner.'allowscriptaccess="always" allowfullscreen="true" width="290"'; 
				$buy_ads_banner=$buy_ads_banner.'height="240"></embed></object>';
			}else{
				$buy_ads_banner ='';
				$buy_ads_banner = $buy_ads_banner. ' <a href="'.$bannerAry['url'].'" >';
				$buy_ads_banner = $buy_ads_banner. '<img ';
				if( $bannerAry ['title' ] != '' )
					$buy_ads_banner = $buy_ads_banner. ' title= "'.$bannerAry['title'].'" ';
					
				$buy_ads_banner = $buy_ads_banner. ' src="'.$this->config->slash_item('secure_base_url').'uploads/banners/'.$bannerAry['image'].'" ';
				$buy_ads_banner = $buy_ads_banner. ' style="border:1px solid black;" width="290" height="240" ';
				if($bannerAry['alt'] !='')
					$buy_ads_banner = $buy_ads_banner. ' alt="'.$bannerAry['alt'].'" ';
				$buy_ads_banner = $buy_ads_banner . ' /></a>';
			}
		}else{
			$buy_ads_banner  = '<a href="#"><img title="no banner" alt="no banner" src="'.$this->config->slash_item('secure_base_url').'system/application/css/images/no_banner_adv_07.jpg" style="border:1px solid black;" width="290" height="240"/></a>';
		}		
		return 	$buy_ads_banner;
		
	}

	function sendEmail_toAdmin_forPropertyEdit( $emailData){
		
		if($emailData['user_type'] == 0)
			$emailData['user_type'] = 'AGENCY';
				
		$message ='';
		$message = $message. '<div style="border:1px solid #CCCCFF; background-color::#CCFFFF;width:700px;padding:20px;">';
		$message = $message. '<table width="100%" bgcolor="#FFFFFF" cellpadding="3" cellspacing="3" style="margin:0px auto;text-align:center; font-size:12px; font-weight:normal; font-family:verdana,arial;">';		
		$message = $message. '<tr><td style="color:#FFFFFF" align="center" bgcolor="#00CCCC">';
		$message = $message. '<h2> localhost/cairns/public_html </h2>';
		$message = $message. '<div style="background-color:#666666; font-size:11px; text-align:right; color:#FFCCFF;">'. date('m/d/Y H:i:s A') .'&nbsp; </div>';
		$message = $message. '</td></tr><tr><td align="left"><p>Dear Admin, </p>';
		$message = $message. '<p> Some one edited their property more than 2 times. Our System has locked that property\'s ';
		$message = $message. 'address fields successfully. This main is to notify you about this matter.</p><br/>';
		$message = $message.' <p>Please have a look on Property Details.</p> <br><br><hr/>';
		$message = $message. '<p> Property Owner Name:'.$emailData['user_name'].'</p>';
		$message = $message. '<p> Property Owner Type:'.$emailData['user_type'].'</p>';
		$message = $message. '<p> Property Owner ID:'.$emailData['user_id'].'</p>';
		$message = $message. '<p> Edited Property ID:'.$emailData['pr_id'].'</p>';
		$message = $message. '<p style="padding:0px 10px 20px 0px;margin:0px;">&nbsp;</p></td></tr>';
		$message = $message. '<tr><td align="left"><p>Thanks <br />';
		$message = $message. 'localhost/cairns/public_html </p>';
		$message = $message. '<p><a href="http://www.localhost/cairns/public_html/index.php">http://www.localhost/cairns/public_html/index.php </a> </p></td></tr>';
		$message = $message. '<tr bgcolor="#D6E0C7" height="5"><td align="left"></td></tr></table></div>';
			
		$recipient = 'admin@localhost/cairns/public_html';
		$sender = 'info@localhost/cairns/public_html';
		$subject ='Property Has Been Edit More Than 2 Times ';
		$this->load->library('email');
		$config['mailtype']= 'html';
		$this->email->initialize($config);
		
		$this->email->from( $sender, 'Golden Fleece International Real Estate and Finance Team');
		$this->email->to($recipient);
		$this->email->subject($subject);
		$this->email->message($message);
		$this->email->send();
	}
	
}
/* End of file Agency.php */
/* Location: ./system/application/controllers/Sell.php */