<?php
class FeedbacksController extends AppController{
var $helpers = array('Form', 'Html', 'Text','Javascript', 'Time', 'Number', 'Session', 'Paginator', 'Ajax', 'Cache');
	
		//Use the functions defined in the following models just in case you need them.
	    var $uses=array('Feedback');
		var $name = 'Feedbacks';
		var $components = array('Session');

	    function index(){	
		$this->paginate['limit'] = 50;
		$this->paginate['order'] = array('id' => 'desc');
		$this->set('listitem', $this->paginate('Feedback'));
		  }
		  
	    function userFeedback(){
        $this->paginate['limit'] = 50;
        $this->paginate['order'] = array('date' => 'desc');
        $this->set('feedback_info', $this->paginate('UserFeedback'));
        }
		
    	function userViewMore(){
		$id=$this->params['url']['id'];
		$feedback=$this->Feedback->getSpecificInfo($id);
		$this->set('page_info',$this->Feedback->getSpecificInfo($id));
		}
	
		function userDelete(){
		$id = $this->params['url']['id'];
		$this->Feedback->delete($id);		
		$goTo = '/feedbacks/index';		
		$this->redirect($goTo);
		}	
	
		function replyMessage(){
		$id = $this->params['url']['id'];	
		$this->set('tothisperson', $this->Feedback->find('all', array('conditions' => array('id' => $id))));	
		}
	
 		function sendreply(){
		 	if (!empty($this->data)){
			$from = 'info@alphaafrique.com';
    		$to = $this->data['Feedback']['email_address'];
    		$message = $this->data['Feedback']['message'];
			$this->Email->from    = $from;
			$this->Email->to      = $to;
			$this->Email->subject = 'Your Reply from ............';
			$this->Email->send($message);
			$goTo = '/feedbacks/index';		
			$this->redirect($goTo);
		 	}
		}
   }
?>