67 lines
2 KiB
PHP
Executable file
67 lines
2 KiB
PHP
Executable file
<?php
|
|
class PrinciplesController extends AppController {
|
|
|
|
var $name = 'Principles';
|
|
var $helpers = array('Html', 'Form');
|
|
|
|
var $paginate = array(
|
|
'Principle' => array('order' => array('Principle.id' => 'asc')),
|
|
'Enquiry' => array('limit' => 200, 'order' => array('Enquiry.id' => 'desc'))
|
|
);
|
|
|
|
function index() {
|
|
$this->Principle->recursive = 0;
|
|
$this->set('principles', $this->paginate());
|
|
$this->set('enquiries', $this->paginate());
|
|
}
|
|
|
|
function view($id = null) {
|
|
if (!$id) {
|
|
$this->Session->setFlash(__('Invalid Principle.', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
}
|
|
$this->set('principle', $this->Principle->read(null, $id));
|
|
$this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.principle_id' => $id)));
|
|
}
|
|
|
|
function add() {
|
|
if (!empty($this->data)) {
|
|
$this->Principle->create();
|
|
if ($this->Principle->save($this->data)) {
|
|
$this->Session->setFlash(__('The Principle has been saved', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
} else {
|
|
$this->Session->setFlash(__('The Principle could not be saved. Please, try again.', true));
|
|
}
|
|
}
|
|
$countries = $this->Principle->Country->find('list');
|
|
$currencies = $this->Principle->Currency->find('list');
|
|
$this->set(compact('countries', 'currencies'));
|
|
}
|
|
|
|
function edit($id = null) {
|
|
if (!$id && empty($this->data)) {
|
|
$this->Session->setFlash(__('Invalid Principle', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
}
|
|
if (!empty($this->data)) {
|
|
if ($this->Principle->save($this->data)) {
|
|
$this->Session->setFlash(__('The Principle has been saved', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
} else {
|
|
$this->Session->setFlash(__('The Principle could not be saved. Please, try again.', true));
|
|
}
|
|
}
|
|
if (empty($this->data)) {
|
|
$this->data = $this->Principle->read(null, $id);
|
|
}
|
|
$countries = $this->Principle->Country->find('list');
|
|
$currencies = $this->Principle->Currency->find('list');
|
|
$this->set(compact('countries','currencies'));
|
|
}
|
|
|
|
|
|
|
|
}
|
|
?>
|