<?php namespace App\Controllers;

class Our_customers extends FrontController
{
	public function index(){
		$data['meta_data']['title'] = "Our Customers";
		$data['meta_data']['description'] = "Our Customers";
		$data['meta_data']['keywords'] = "Our Customers";
		$data['client_list'] = $this->get_client_list();
		echo $this->view_inner_template('our_customers',$data);
	}

	private function get_client_list(){
		$builder = $this->cmObj->get_table_builder('client AS c');
		$builder->join('property_type AS pt',"c.property_type_id=pt.property_type_id",'left')
			->select('c.client_id,
				c.title,
				c.logo,
				c.city,
				pt.title AS property_type_title')
			->where('c.status','Active')
			->where('c.is_deleted','No')
			->orderBy('c.title','ASC');
		if($this->request->getPost('city')){
			$builder->where('c.city',$this->request->getPost('city'));
		}
		if($this->request->getPost('property_type_id')){
			$builder->where('c.property_type_id',$this->request->getPost('property_type_id'));
		}
		$query = $builder->get();
		return $query->getResultArray();
	}
}