cmc-sales/app/controllers/freight_forwarders_controller.php

71 lines
2 KiB
PHP
Raw Normal View History

<?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);
}
}
2011-05-08 18:11:23 -07:00
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";
}
2011-05-08 18:11:23 -07:00
else {
echo "FAIL";
}
2011-05-08 18:11:23 -07:00
}
}
function build_options() {
$this->layout = 'ajax';
$this->set('freight_forwarders',$this->FreightForwarder->find('list'));
}
}
?>