72 lines
1.8 KiB
PHP
Executable file
72 lines
1.8 KiB
PHP
Executable file
<?php
|
|
class BoxesController extends AppController {
|
|
|
|
var $name = 'Boxes';
|
|
var $helpers = array('Html', 'Form');
|
|
|
|
function index() {
|
|
$this->Box->recursive = 0;
|
|
$this->set('boxes', $this->paginate());
|
|
}
|
|
|
|
|
|
function buildForm($count = 0) {
|
|
$this->layout = 'ajax';
|
|
$this->set('count', $count);
|
|
}
|
|
|
|
function view($id = null) {
|
|
if (!$id) {
|
|
$this->Session->setFlash(__('Invalid Box.', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
}
|
|
$this->set('box', $this->Box->read(null, $id));
|
|
}
|
|
|
|
function add() {
|
|
if (!empty($this->data)) {
|
|
$this->Box->create();
|
|
if ($this->Box->save($this->data)) {
|
|
$this->Session->setFlash(__('The Box has been saved', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
} else {
|
|
$this->Session->setFlash(__('The Box could not be saved. Please, try again.', true));
|
|
}
|
|
}
|
|
$shipments = $this->Box->Shipment->find('list');
|
|
$this->set(compact('shipments'));
|
|
}
|
|
|
|
function edit($id = null) {
|
|
if (!$id && empty($this->data)) {
|
|
$this->Session->setFlash(__('Invalid Box', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
}
|
|
if (!empty($this->data)) {
|
|
if ($this->Box->save($this->data)) {
|
|
$this->Session->setFlash(__('The Box has been saved', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
} else {
|
|
$this->Session->setFlash(__('The Box could not be saved. Please, try again.', true));
|
|
}
|
|
}
|
|
if (empty($this->data)) {
|
|
$this->data = $this->Box->read(null, $id);
|
|
}
|
|
$shipments = $this->Box->Shipment->find('list');
|
|
$this->set(compact('shipments'));
|
|
}
|
|
|
|
function delete($id = null) {
|
|
if (!$id) {
|
|
$this->Session->setFlash(__('Invalid id for Box', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
}
|
|
if ($this->Box->del($id)) {
|
|
$this->Session->setFlash(__('Box deleted', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
}
|
|
}
|
|
|
|
}
|
|
?>
|