<?php
class CustomerCategoriesController extends AppController {

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

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

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

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

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


}
?>
