<?php
class FreightServicesController extends AppController {

	var $name = 'FreightServices';
	var $helpers = array('Html', 'Form');

	function index() {
		$this->FreightService->recursive = 0;
		$this->set('freightServices', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid FreightService.', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->set('freightService', $this->FreightService->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->FreightService->create();
			if ($this->FreightService->save($this->data)) {
				$this->Session->setFlash(__('The FreightService has been saved', true));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->Session->setFlash(__('The FreightService could not be saved. Please, try again.', true));
			}
		}
		$freightForwarders = $this->FreightService->FreightForwarder->find('list');
		$this->set(compact('freightForwarders'));
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid FreightService', true));
			$this->redirect(array('action'=>'index'));
		}
		if (!empty($this->data)) {
			if ($this->FreightService->save($this->data)) {
				$this->Session->setFlash(__('The FreightService has been saved', true));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->Session->setFlash(__('The FreightService could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->FreightService->read(null, $id);
		}
		$freightForwarders = $this->FreightService->FreightForwarder->find('list');
		$this->set(compact('freightForwarders'));
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for FreightService', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->FreightService->del($id)) {
			$this->Session->setFlash(__('FreightService deleted', true));
			$this->redirect(array('action'=>'index'));
		}
	}

}
?>