cmc-sales/controllers/emails_controller.php
2009-02-10 09:25:49 +11:00

66 lines
1.8 KiB
PHP

<?php
class EmailsController extends AppController {
var $name = 'Emails';
var $helpers = array('Html', 'Form');
function index() {
$this->Email->recursive = 0;
$this->set('emails', $this->paginate());
}
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid Email.', true));
$this->redirect(array('action'=>'index'));
}
$this->set('email', $this->Email->read(null, $id));
}
function add() {
if (!empty($this->data)) {
$this->Email->create();
if ($this->Email->save($this->data)) {
$this->Session->setFlash(__('The Email has been saved', true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('The Email could not be saved. Please, try again.', true));
}
}
$enquiries = $this->Email->Enquiry->find('list');
$this->set(compact('enquiries'));
}
function edit($id = null) {
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid Email', true));
$this->redirect(array('action'=>'index'));
}
if (!empty($this->data)) {
if ($this->Email->save($this->data)) {
$this->Session->setFlash(__('The Email has been saved', true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('The Email could not be saved. Please, try again.', true));
}
}
if (empty($this->data)) {
$this->data = $this->Email->read(null, $id);
}
$enquiries = $this->Email->Enquiry->find('list');
$this->set(compact('enquiries'));
}
function delete($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid id for Email', true));
$this->redirect(array('action'=>'index'));
}
if ($this->Email->del($id)) {
$this->Session->setFlash(__('Email deleted', true));
$this->redirect(array('action'=>'index'));
}
}
}
?>