JezK
Edit File: AfterloginController.php
<?php App::uses('CakeEmail', 'Network/Email'); class AfterloginController extends AppController { public $helpers = array('Html', 'Form', 'Session'); public $components = array('Session', 'RequestHandler'); public $currentDateTime; public function index() { if ($this->Session->check('Student')) { $this->loadModel('Configuration'); $this->loadModel('Slide'); $slides = $this->Slide->find('all', array('conditions' => array('status' => 'Active'), 'order' => array('ordering' => 'DESC'))); $sysSetting = $this->Configuration->find('first'); $this->set('frontSlides', $sysSetting['Configuration']['slides']); $data = $this->Session->read('Student'); $this->Session->write('profilepic', $data['Student']['photo']); $this->Session->write('profilename', $data['Student']['name']); $this->set('slides', $slides); if ($this->request->is('post')) { $message = 'Name: '.$this->request->data['name'].' Email: '.$this->request->data['email'].' Phone number:'.$this->request->data['phoneNo'].' Message :'.$this->request->data['message']; $email = 'revathi@krify.net'; $Email = new CakeEmail(); $Email->transport($this->emailSettype); if ($this->emailSettype == "Smtp") { $Email->config($this->emailSettingsArr); } $Email->from(array($this->siteEmail => $this->siteName)); $Email->to($email); $Email->template('default'); $Email->emailFormat('html'); $Email->subject('NPTE contact us'); $Email->send($message); $this->Session->setFlash(__('message sent successfully'), 'flash', array('alert' => 'success')); //return $this->redirect(['action' => 'index']); } $this->loadModel('Exam'); $student = $this->Session->read('Student'); $tests = $this->Exam->getPurchasedExam('today',$student['Student']['id'],$this->currentDateTime); $newArray = array(); for($i=0;$i<count($tests);$i++){ $exam = $tests[$i]; if($i==0){ array_push($newArray,$exam); } else { $count = 0; $examsCount = $exam['Exam']['packages_count'] * $exam['Package']['no_of_tests']; foreach($newArray as $newExam){ if($exam['Package']['id'] == $newExam['Package']['id']){ $count++; } } if($count < $examsCount){ array_push($newArray,$exam); } } } // echo "<pre>"; // print_r($todayExam); // exit; $tests = $newArray; //$upcoming = $this->Exam->getPurchasedExam('upcoming',$student['Student']['id'],$this->currentDateTime); //$tests = array_merge($today,$upcoming); $this->set('tests', $tests); }else{ return $this->redirect(array('crm' => true, 'controller' => 'Users', 'action' => 'login')); } //$this->set('profilepic', $data['Student']['photo']); //$this->set('name', $data['Student']['name']); /*$data = $this->Session->read('Student'); if (strlen($data['Student']['photo']) > 0){ $std_img = $this->siteDomain . '/img/student_thumb/' . $data['Student']['photo']; }else{ $std_img = $this->siteDomain . '/img/User.png'; } $this->set('profilepic', $std_img); $this->set('name', $data['Student']['name']);*/ // $this->redirect(array('controller' => '')); } public function download() { try{ $filePath = WWW_ROOT .'files'. DS . 'npte.pdf'; $this->response->file($filePath, array('download'=> true, 'name'=> 'npte.pdf')); } catch(Exception $e){ echo $e->getMessage(); die(); } return $this->response; } }