72 lines
2.1 KiB
PHP
72 lines
2.1 KiB
PHP
<?php
|
|
class JobsController extends AppController {
|
|
|
|
var $name = 'Jobs';
|
|
var $helpers = array('Html', 'Form');
|
|
|
|
function index() {
|
|
$this->Job->recursive = 0;
|
|
$this->set('jobs', $this->paginate());
|
|
}
|
|
|
|
function view($id = null) {
|
|
if (!$id) {
|
|
$this->flash(__('Invalid Job', true), array('action'=>'index'));
|
|
}
|
|
$this->set('job', $this->Job->read(null, $id));
|
|
}
|
|
|
|
function add() {
|
|
if (!empty($this->data)) {
|
|
$this->Job->create();
|
|
if ($this->Job->save($this->data)) {
|
|
$this->flash(__('Job saved.', true), array('action'=>'index'));
|
|
} else {
|
|
}
|
|
}
|
|
else {
|
|
if(isset($this->params['named']['enquiryid'])) {
|
|
|
|
$enquiry = $this->Job->Enquiry->findById($this->params['named']['enquiryid']);
|
|
|
|
$this->set(compact('enquiry'));
|
|
}
|
|
else {
|
|
$this->Session->setFlash(__('Invalid Enquiry ID', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
function edit($id = null) {
|
|
if (!$id && empty($this->data)) {
|
|
$this->flash(__('Invalid Job', true), array('action'=>'index'));
|
|
}
|
|
if (!empty($this->data)) {
|
|
if ($this->Job->save($this->data)) {
|
|
$this->flash(__('The Job has been saved.', true), array('action'=>'index'));
|
|
} else {
|
|
}
|
|
}
|
|
if (empty($this->data)) {
|
|
$this->data = $this->Job->read(null, $id);
|
|
}
|
|
$states = $this->Job->State->find('list');
|
|
$customers = $this->Job->Customer->find('list');
|
|
$enquiries = $this->Job->Enquiry->find('list');
|
|
$contacts = $this->Job->Contact->find('list');
|
|
$this->set(compact('states','customers','enquiries','contacts'));
|
|
}
|
|
|
|
function delete($id = null) {
|
|
if (!$id) {
|
|
$this->flash(__('Invalid Job', true), array('action'=>'index'));
|
|
}
|
|
if ($this->Job->del($id)) {
|
|
$this->flash(__('Job deleted', true), array('action'=>'index'));
|
|
}
|
|
}
|
|
|
|
}
|
|
?>
|