public function support()
 {
     $this->layout = 'frontend_menu';
     if ($this->request->is('post') && !empty($this->data)) {
         $Mail = new MailController();
         $Mail->constructClasses();
         $arr = array();
         $arr['TO_EMAIL'] = '*****@*****.**';
         $arr['TO_NAME'] = 'Admin';
         $arr['NAME'] = $this->data['first_name'] . ' ' . $this->data['last_name'];
         $arr['EMAIL'] = $this->data['email'];
         $arr['PHONE'] = $this->data['phone'];
         $arr['MESSAGE'] = $this->data['message'];
         $Mail->individualMail('support_mail', $arr);
         die;
     }
     $this->render('support');
 }
 public function deny_agent($id = null)
 {
     $this->Access->checkRestaurantSession();
     if (!empty($id)) {
         $Mail = new MailController();
         $Mail->constructClasses();
         $this->AgentRestaurant->id = $id;
         $this->AgentRestaurant->save(array('status' => '2'));
         $this->AgentRestaurant->recursive = 2;
         $data = $this->AgentRestaurant->find('first', array('conditions' => array('AgentRestaurant.id' => $id)));
         $arr = array();
         $arr['TO_EMAIL'] = $data['Agent']['User']['email'];
         $arr['TO_NAME'] = $data['Agent']['name'];
         $arr['RESTAURANT_NAME'] = $data['Restaurant']['restaurant_name'];
         $arr['CONTACT'] = $data['Restaurant']['phone'];
         $Mail->sendMail($data['Agent']['User']['id'], 'denied_agent_request', $arr);
         $this->Session->setFlash(__('Agent request has been denied.'));
         $this->redirect(array('controller' => 'restaurants', 'action' => 'my_agents'));
     }
 }
 public function forget_pass()
 {
     if (!empty($this->data)) {
         $data = $this->data['ForgetPassForm'];
         if (!isset($this->Captcha)) {
             //if Component was not loaded throug $components array()
             App::import('Component', 'Captcha');
             //load it
             $this->Captcha = new CaptchaComponent();
             //make instance
             $this->Captcha->startup($this);
             //and do some manually calling
         }
         $cap = $this->Captcha->getVerCode();
         if ($cap == $data['code']) {
             $user = $this->User->find('first', array('conditions' => array('User.username' => $data['username'], 'User.user_role_id' => $data['user_role_id'])));
             if (!empty($user)) {
                 $Mail = new MailController();
                 $Mail->constructClasses();
                 $pass = random_password();
                 $this->User->id = $user['User']['id'];
                 $this->User->save(array('password' => encrypt($pass, SALT)));
                 $arr = array();
                 $arr['TO_EMAIL'] = $user['User']['email'];
                 $arr['TO_NAME'] = $user['User']['username'];
                 $arr['USERNAME'] = $user['User']['username'];
                 $arr['PASSWORD'] = $pass;
                 $Mail->sendMail($user['User']['id'], 'forgot_password', $arr);
                 echo 'success';
                 die;
             } else {
                 echo 'error';
             }
         } else {
             echo 'code';
             die;
         }
     }
     die;
 }