cmc-sales/controllers/product_options_controller.php

66 lines
1.9 KiB
PHP

<?php
class ProductOptionsController extends AppController {
var $name = 'ProductOptions';
var $helpers = array('Html', 'Form');
function index() {
$this->ProductOption->recursive = 0;
$this->set('productOptions', $this->paginate());
}
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid ProductOption.', true));
$this->redirect(array('action'=>'index'));
}
$this->set('productOption', $this->ProductOption->read(null, $id));
}
function add() {
if (!empty($this->data)) {
$this->ProductOption->create();
if ($this->ProductOption->save($this->data)) {
$this->Session->setFlash(__('The ProductOption has been saved', true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('The ProductOption could not be saved. Please, try again.', true));
}
}
$products = $this->ProductOption->Product->find('list');
$this->set(compact('products'));
}
function edit($id = null) {
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid ProductOption', true));
$this->redirect(array('action'=>'index'));
}
if (!empty($this->data)) {
if ($this->ProductOption->save($this->data)) {
$this->Session->setFlash(__('The ProductOption has been saved', true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('The ProductOption could not be saved. Please, try again.', true));
}
}
if (empty($this->data)) {
$this->data = $this->ProductOption->read(null, $id);
}
$products = $this->ProductOption->Product->find('list');
$this->set(compact('products'));
}
function delete($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid id for ProductOption', true));
$this->redirect(array('action'=>'index'));
}
if ($this->ProductOption->del($id)) {
$this->Session->setFlash(__('ProductOption deleted', true));
$this->redirect(array('action'=>'index'));
}
}
}
?>