<?php 
class ContactInfoController extends AppController{
	var $name='ContactInfo';
	var $uses=array('ContactInfo');
	var $helpers = array('Form', 'Html', 'Text','Javascript', 'Time', 'Number','Paginator','Cache','Ajax', 'Session');
	var $components=array('RequestHandler');
	
	
	
	function index(){
		
		
		
		
	}
	/*
function addImage(){
		$current_image=$this->ContactInfoImage->find('all',array('fields'=>'image_link'));
		
		if(!empty($current_image)){
		$current_image=$current_image[0]['ContactInfoImage']['image_link'];
		}
		else{
			$current_image='';
			
		}
		if(empty($this->data)){
		$id=$this->ContactInfoImage->find('all',array('fields'=>'id'));
		if(!empty($id)){
		$this->data=$id[0];
		}
		$this->set(compact('current_image'));
		
	}
	
	elseif(!empty($this->data)){
		$data=$this->data;
		
		
		if($data['ContactInfoImage']['image_link']['size']!=0) {
			
			
		$file = new File($data['ContactInfoImage']['image_link']['tmp_name']);
		$ext = $data['ContactInfoImage']['image_link']['name'];
		$point = strrpos($ext,".");
		
		$ext = substr($ext,$point+1,(strlen($ext)-$point));
		$ext=strtolower($ext);
	if ($ext != 'jpg' && $ext != 'jpeg' && $ext != 'gif' && $ext != 'png') {
		
		$data['Category']['category_image_link']='';
		
		
		} else {
		ini_set('date.timezone', 'Europe/London');   
        $now = date('Y-m-d-His');
        $name=str_replace(" ","-","contact_us_image");
		$filename = $name.'-'.$now.'.'.$ext;
		$data1 = $file->read();
		$file->close();
		$path=WWW_ROOT.'img/contact_us_images/'.$filename;
		$file = new File(WWW_ROOT.'img/contact_us_images/'.$filename,true);
		$file->write($data1);
		$filename='contact_us_images/'.$filename;
		
		$data['ContactInfoImage']['image_link']=$filename;
		}
	}
	else{
		
		if(array_key_exists('remove',$data['ContactInfoImage'])){
			
		if($data['ContactInfoImage']['remove']==0){
		$data['ContactInfoImage']['image_link']=$current_image;
		
		}
		elseif($data['ContactInfoImage']['remove']!=0){
			$data['ContactInfoImage']['image_link']='';
		}
		}
		else{
			$data['ContactInfoImage']['image_link']=$current_image;
			
		}				
	}			
	
			if($this->ContactInfoImage->validates()){
							
			if($this->ContactInfoImage->save($data)){
			//print_r($data);
				
				if(isset($file)){
				$file->close();
				}
				if($data['ContactInfoImage']['image_link']!=$current_image){
				$file=new File(WWW_ROOT.'img/'.$current_image,true);
				$file->close();
					$file->delete();
				}
				
			$this->redirect('/ContactInfo/saveImageResponse');
			}else{
			if(isset($file)){
					$file->close(); 
					$file->delete();
				}
				
				
				
			//print_r($this->data);			
		}
		}
		
		
	}
	}
	*/
function saveImageResponse(){
		
		
	}
function addContactLocation(){
		if(!empty($this->data)){
			
			if($this->ContactInfo->validates()){
				if($this->ContactInfo->save($this->data)){
					
					$this->redirect('/Contact_info/viewContactLocations');
					
				}
				
				
			}
			
			
			
			
		}
		
		
	}
	
	function addContactLocationResponse(){}
function editContactLocationResponse(){}
		
function editContactLocation($id=null){
		if(!empty($this->data)){
			
			if($this->ContactInfo->validates()){
				if($this->ContactInfo->save($this->data)){
					
					$this->redirect('/Contact_info/viewContactLocations');
					
				}
				
				
			}
			
			
			
			
		}
		else{
			$data=$this->ContactInfo->find('all',array('conditions'=>array('id'=>$id)));
			$this->data=$data[0];
			
			
		}
		
		
		
	}
function viewContactLocations(){
		$this->paginate['limit'] = 50;
   		$this->paginate['order'] = array('date' => 'desc');
   		//$this->paginate['fields'] = array('branch_name','status','id','date');
		$this->set('locations', $this->paginate('ContactInfo'));
}
function viewLocationDetails($id){
	$data=$this->ContactInfo->find('all',array('conditions'=>array('id'=>$id)));
	$this->set('locations',$data);
	
	
}
function viewEnabled(){
	$this->paginate['limit'] = 50;
   		$this->paginate['order'] = array('date' => 'desc');
   		$this->paginate['conditions'] = array('status'=>1);
		$this->set('locations', $this->paginate('ContactInfo'));
		$this->set('status',1);
		$this->render('viewContactLocations');
	
	
}

function viewDisabled(){
	$this->paginate['limit'] = 50;
   		$this->paginate['order'] = array('date' => 'desc');
   		$this->paginate['conditions'] = array('status'=>0);
		$this->set('locations', $this->paginate('ContactInfo'));
		$this->set('status',0);
		$this->render('viewContactLocations');
	
	
}

function enableContactLocation($id=null){
	$this->ContactInfo->updateAll(array('status'=>'1'),array('id'=>$id));
	$this->paginate['limit'] = 50;
   		$this->paginate['order'] = array('ContactInfo.date' => 'desc');
		$this->set('locations', $this->paginate('ContactInfo'));
	
	$this->redirect('viewContactLocations');
}

function disableContactLocation($id=null){
	$this->ContactInfo->updateAll(array('status'=>'0'),array('id'=>$id));
	$this->paginate['limit'] = 50;
   		$this->paginate['order'] = array('ContactInfo.date' => 'desc');
		$this->set('locations', $this->paginate('ContactInfo'));
	
	$this->redirect('viewContactLocations');
}
	
	
	
	
	
	
}





?>