I have employee application where users standing can be resigned, active, 
new and transferred. What i would like to achieve is that when the standing 
of an employee is changed/edited from active (standing_id = 1) it should be 
able to send through an email but its not. I have put a email function in 
the EmployeeController. Below is my code. 

    function _sendNewEmployeeEditMail($id) {
    $Employee = $this->Employee->read(null,$id);
    $email = new CakeEmail();
    $email->from(array('no-re...@test.com' => 'Testing App'));
    $email->to(array('xxx...@gmail.com' => 'Name Surname'));
    $email->subject('New Employee');
    $email->template('employee_email');
    $email->viewVars(compact('Employee'));
    $email->emailFormat('html');
    $_sendNewEmployeeEditMail = true;    
    $current_status = $this->Employee->field('standing_id');
    if($current_status==1) {
    $_sendNewEmployeeEditMail = false;
    }
    }

and in my edit save function here is how i am trying to send the email

    public function edit($id = null) {
    $this->Employee->id = $id;
    if (!$this->Employee->exists()) {
    throw new NotFoundException(__('Invalid employee'));
    }
    if ($this->request->is('post') || $this->request->is('put')) {
    if ($this->Employee->save($this->request->data)) {
    $this->Session->setFlash(__('The employee has been 
saved'),'default',array('class' => 'notification'));
    $this->_sendNewEmployeeEditMail($this->Employee->getLastInsertID()  );
    $this->redirect(array('action' => 'index'));
    } else {
    $this->Session->setFlash(__('The employee could not be saved. Please, 
try again.'),'default',array('class' => 'error'));
    }
    } else {
    $this->request->data = $this->Employee->read(null, $id);
    }
    $standings = $this->Employee->Standing->find('list');
    $this->set(compact('standings'));

If anyone could help me out on this, that would be awesome

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to