71 lines
2 KiB
PHP
71 lines
2 KiB
PHP
<?php
|
|
class FreightForwardersController extends AppController {
|
|
|
|
var $name = 'FreightForwarders';
|
|
var $helpers = array('Html', 'Form');
|
|
|
|
function index() {
|
|
$this->FreightForwarder->recursive = 0;
|
|
$this->set('freightForwarders', $this->paginate());
|
|
}
|
|
|
|
function view($id = null) {
|
|
if (!$id) {
|
|
$this->Session->setFlash(__('Invalid FreightForwarder.', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
}
|
|
$this->set('freightForwarder', $this->FreightForwarder->read(null, $id));
|
|
}
|
|
|
|
function add() {
|
|
if (!empty($this->data)) {
|
|
$this->FreightForwarder->create();
|
|
if ($this->FreightForwarder->save($this->data)) {
|
|
$this->Session->setFlash(__('The FreightForwarder has been saved', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
} else {
|
|
$this->Session->setFlash(__('The FreightForwarder could not be saved. Please, try again.', true));
|
|
}
|
|
}
|
|
}
|
|
|
|
function edit($id = null) {
|
|
if (!$id && empty($this->data)) {
|
|
$this->Session->setFlash(__('Invalid FreightForwarder', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
}
|
|
if (!empty($this->data)) {
|
|
if ($this->FreightForwarder->save($this->data)) {
|
|
$this->Session->setFlash(__('The FreightForwarder has been saved', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
} else {
|
|
$this->Session->setFlash(__('The FreightForwarder could not be saved. Please, try again.', true));
|
|
}
|
|
}
|
|
if (empty($this->data)) {
|
|
$this->data = $this->FreightForwarder->read(null, $id);
|
|
}
|
|
}
|
|
|
|
|
|
function ajax_add() {
|
|
$this->layout = 'ajax';
|
|
if(!empty($this->data['Shipment']['newFreightForwarderName'])) {
|
|
$this->FreightForwarder->create();
|
|
$this->data['FreightForwarder']['name'] = trim($this->data['Shipment']['newFreightForwarderName']);
|
|
if($this->FreightForwarder->save($this->data['FreightForwarder'])) {
|
|
echo "SUCCESS";
|
|
}
|
|
else {
|
|
echo "FAIL";
|
|
}
|
|
}
|
|
}
|
|
|
|
function build_options() {
|
|
$this->layout = 'ajax';
|
|
$this->set('freight_forwarders',$this->FreightForwarder->find('list'));
|
|
}
|
|
|
|
}
|
|
?>
|