<?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 delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for FreightForwarder', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->FreightForwarder->del($id)) {
			$this->Session->setFlash(__('FreightForwarder deleted', true));
			$this->redirect(array('action'=>'index'));
		}
	}

}
?>