cmc-sales/controllers/shipments_controller.php
2011-04-21 17:38:01 +10:00

68 lines
1.5 KiB
PHP

<?php
class ShipmentsController extends AppController {
var $name = 'Shipments';
var $helpers = array('Html', 'Form');
var $paginate = array(
'contain' => false,
'limit' => 100,
'order'=>array('Shipment.id' => 'desc'),
'recursive' => 1
);
function index() {
$this->Shipment->recursive = 0;
$this->set('shipments', $this->paginate());
}
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid Shipment.', true));
$this->redirect(array('action'=>'index'));
}
$this->set('shipment', $this->Shipment->read(null, $id));
}
function add($action = 'add') {
$jobs = $this->Shipment->Job->find('list');
$principles = $this->Shipment->Principle->find('list');
$purchaseOrders = $this->Shipment->PurchaseOrder->find('list');
$freightForwarders = $this->Shipment->FreightForwarder->find('list');
$shipmentType = $this->typeOptions();
$this->set(compact('jobs', 'principles', 'purchaseOrders', 'freightForwarders', 'shipmentType'));
}
function typeOptions() {
$options = array('','Import to CMC','Direct: Principle to Customer','Export','Local');
return $options;
}
function delete($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid id for Shipment', true));
$this->redirect(array('action'=>'index'));
}
if ($this->Shipment->del($id)) {
$this->Session->setFlash(__('Shipment deleted', true));
$this->redirect(array('action'=>'index'));
}
}
}
?>