cmc-sales/controllers/quote_products_controller.php
2009-01-27 12:46:00 +11:00

73 lines
2.3 KiB
PHP

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