First commit this side of the pacific
This commit is contained in:
parent
5a5561a8a1
commit
26452cd1a0
|
|
@ -1,82 +1,82 @@
|
||||||
<?php
|
<?php
|
||||||
class ProductsController extends AppController {
|
class ProductsController extends AppController {
|
||||||
|
|
||||||
var $name = 'Products';
|
var $name = 'Products';
|
||||||
var $components = array('RequestHandler');
|
var $components = array('RequestHandler');
|
||||||
var $helpers = array('Html', 'Form', 'Ajax', 'Number');
|
var $helpers = array('Html', 'Form', 'Ajax', 'Number');
|
||||||
|
|
||||||
function index() {
|
function index() {
|
||||||
$this->Product->recursive = 0;
|
$this->Product->recursive = 0;
|
||||||
$this->set('products', $this->paginate());
|
$this->set('products', $this->paginate());
|
||||||
}
|
}
|
||||||
|
|
||||||
function view($id = null) {
|
function view($id = null) {
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
$this->Session->setFlash(__('Invalid Product.', true));
|
$this->Session->setFlash(__('Invalid Product.', true));
|
||||||
$this->redirect(array('action'=>'index'));
|
$this->redirect(array('action'=>'index'));
|
||||||
}
|
}
|
||||||
$this->set('product', $this->Product->read(null, $id));
|
$this->set('product', $this->Product->read(null, $id));
|
||||||
|
|
||||||
//$this->set('product', $this->Product->find('first', array('conditions' => array('Product.id'=>$id), 'recursive' => 1)));
|
//$this->set('product', $this->Product->find('first', array('conditions' => array('Product.id'=>$id), 'recursive' => 1)));
|
||||||
|
|
||||||
$this->set('options', $this->Product->ProductOptionsCategory->find('all', array('conditions' => array('ProductOptionsCategory.product_id'=>$id), 'order'=>'ProductOptionsCategory.location ASC')));
|
$this->set('options', $this->Product->ProductOptionsCategory->find('all', array('conditions' => array('ProductOptionsCategory.product_id'=>$id), 'order'=>'ProductOptionsCategory.location ASC')));
|
||||||
|
|
||||||
$this->set('files', $this->Product->ProductAttachment->findAllByProductId($id));
|
|
||||||
$this->set('number_of_files', $this->Product->ProductAttachment->find('count', array('conditions' => array('ProductAttachment.product_id'=>$id))));
|
|
||||||
}
|
|
||||||
|
|
||||||
function add() {
|
$this->set('files', $this->Product->ProductAttachment->findAllByProductId($id));
|
||||||
if (!empty($this->data)) {
|
$this->set('number_of_files', $this->Product->ProductAttachment->find('count', array('conditions' => array('ProductAttachment.product_id'=>$id))));
|
||||||
$this->Product->create();
|
}
|
||||||
|
|
||||||
if ($this->Product->save($this->data)) {
|
|
||||||
$this->Session->setFlash(__('The Product has been saved', true));
|
|
||||||
$id = $this->Product->id;
|
|
||||||
$this->redirect(array('action'=>'view/'.$id));
|
|
||||||
} else {
|
|
||||||
$this->Session->setFlash(__('The Product could not be saved. Please, try again.', true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$principles = $this->Product->Principle->find('list');
|
|
||||||
|
|
||||||
$this->set(compact('principles', 'product_categories'));
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_costing() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function edit($id = null) {
|
function add() {
|
||||||
if (!$id && empty($this->data)) {
|
if (!empty($this->data)) {
|
||||||
$this->Session->setFlash(__('Invalid Product', true));
|
$this->Product->create();
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
}
|
|
||||||
if (!empty($this->data)) {
|
|
||||||
if ($this->Product->save($this->data)) {
|
|
||||||
$this->Session->setFlash(__('The Product has been saved', true));
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
} else {
|
|
||||||
$this->Session->setFlash(__('The Product could not be saved. Please, try again.', true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (empty($this->data)) {
|
|
||||||
$this->data = $this->Product->read(null, $id);
|
|
||||||
$this->set('description', $this->data['Product']['description']);
|
|
||||||
}
|
|
||||||
$principles = $this->Product->Principle->find('list');
|
|
||||||
$this->set(compact('principles'));
|
|
||||||
}
|
|
||||||
|
|
||||||
function delete($id = null) {
|
if ($this->Product->save($this->data)) {
|
||||||
if (!$id) {
|
$this->Session->setFlash(__('The Product has been saved', true));
|
||||||
$this->Session->setFlash(__('Invalid id for Product', true));
|
$id = $this->Product->id;
|
||||||
$this->redirect(array('action'=>'index'));
|
$this->redirect(array('action'=>'view/'.$id));
|
||||||
}
|
} else {
|
||||||
if ($this->Product->del($id)) {
|
$this->Session->setFlash(__('The Product could not be saved. Please, try again.', true));
|
||||||
$this->Session->setFlash(__('Product deleted', true));
|
}
|
||||||
$this->redirect(array('action'=>'index'));
|
}
|
||||||
}
|
$principles = $this->Product->Principle->find('list');
|
||||||
}
|
|
||||||
|
$this->set(compact('principles', 'product_categories'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_costing() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function edit($id = null) {
|
||||||
|
if (!$id && empty($this->data)) {
|
||||||
|
$this->Session->setFlash(__('Invalid Product', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
}
|
||||||
|
if (!empty($this->data)) {
|
||||||
|
if ($this->Product->save($this->data)) {
|
||||||
|
$this->Session->setFlash(__('The Product has been saved', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
} else {
|
||||||
|
$this->Session->setFlash(__('The Product could not be saved. Please, try again.', true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($this->data)) {
|
||||||
|
$this->data = $this->Product->read(null, $id);
|
||||||
|
$this->set('description', $this->data['Product']['description']);
|
||||||
|
}
|
||||||
|
$principles = $this->Product->Principle->find('list');
|
||||||
|
$this->set(compact('principles'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete($id = null) {
|
||||||
|
if (!$id) {
|
||||||
|
$this->Session->setFlash(__('Invalid id for Product', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
}
|
||||||
|
if ($this->Product->del($id)) {
|
||||||
|
$this->Session->setFlash(__('Product deleted', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,6 @@ class ProductOption extends AppModel {
|
||||||
* that are already default == 1 , to be false.
|
* that are already default == 1 , to be false.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function beforeSave() {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ class ProductOptionsCategory extends AppModel {
|
||||||
var $validate = array(
|
var $validate = array(
|
||||||
'product_id' => array('numeric'),
|
'product_id' => array('numeric'),
|
||||||
'name' => array('notempty'),
|
'name' => array('notempty'),
|
||||||
'location' => array('numeric'),
|
'location' => array('numeric' => array('allowEmpty' => true)),
|
||||||
'exclusive' => array('notempty')
|
'exclusive' => array('boolean')
|
||||||
);
|
);
|
||||||
|
|
||||||
//The Associations below have been created with all possible keys, those that are not needed can be removed
|
//The Associations below have been created with all possible keys, those that are not needed can be removed
|
||||||
|
|
|
||||||
13
models/quote_product_option.php
Normal file
13
models/quote_product_option.php
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?
|
||||||
|
class QuoteProductOption extends AppModel {
|
||||||
|
|
||||||
|
var $name = 'QuoteProductOption';
|
||||||
|
|
||||||
|
|
||||||
|
var $belongsTo = array('ProductOptionsCategory', 'QuoteProduct');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="products index">
|
<div class="products index">
|
||||||
<h2><?php __('Products');?></h2>
|
<h2><?php __('Product Index');?></h2>
|
||||||
<p>
|
<p>
|
||||||
<?php
|
<?php
|
||||||
echo $paginator->counter(array(
|
echo $paginator->counter(array(
|
||||||
|
|
|
||||||
|
|
@ -1,57 +1,57 @@
|
||||||
<?
|
<?
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($options as $opt) {
|
foreach ($options as $opt) {
|
||||||
|
|
||||||
$default_option = '';
|
$default_option = '';
|
||||||
foreach($opt['ProductOption'] as $prodopt) {
|
foreach($opt['ProductOption'] as $prodopt) {
|
||||||
|
|
||||||
|
|
||||||
/* Make it the default selected if it's the default option
|
/* Make it the default selected if it's the default option
|
||||||
* Logic that enforces only 1 default option to be added to the product_options controller
|
* Logic that enforces only 1 default option to be added to the product_options controller
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
if($prodopt['model_number'] != null) {
|
if($prodopt['model_number'] != null) {
|
||||||
$drop_options[$prodopt['id']] = $prodopt['model_number'].": ".$prodopt['title'];
|
$drop_options[$prodopt['id']] = $prodopt['model_number'].": ".$prodopt['title'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$drop_options[$prodopt['id']] = $prodopt['title'];
|
$drop_options[$prodopt['id']] = $prodopt['title'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($prodopt['default'] == 1) {
|
if($prodopt['default'] == 1) {
|
||||||
$default_option = $prodopt['id'];
|
$default_option = $prodopt['id'];
|
||||||
|
|
||||||
$drop_options[$prodopt['id']] .= " (Default)";
|
$drop_options[$prodopt['id']] .= " (Default)";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If it's an exclusive category, display a drop down box. Otherwise, check boxes
|
* If it's an exclusive category, display a drop down box. Otherwise, check boxes
|
||||||
*/
|
*/
|
||||||
if($opt['ProductOptionsCategory']['exclusive'] == 1) {
|
if($opt['ProductOptionsCategory']['exclusive'] == 1) {
|
||||||
echo $form->input('ProductOption.'.$opt['ProductOptionsCategory']['name'],
|
echo $form->input('ProductOption.'.$opt['ProductOptionsCategory']['name'],
|
||||||
array('label' => $opt['ProductOptionsCategory']['name'],
|
array('label' => $opt['ProductOptionsCategory']['name'],
|
||||||
'options' => $drop_options, 'default' => $default_option));
|
'options' => $drop_options, 'default' => $default_option));
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
echo $form->input($opt['ProductOptionsCategory']['name'],
|
echo $form->input($opt['ProductOptionsCategory']['name'],
|
||||||
array('options' => $drop_options, 'default' => $default_option,
|
array('options' => $drop_options, 'default' => $default_option,
|
||||||
'multiple' => 'checkbox'));
|
'multiple' => 'checkbox'));
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($drop_options);
|
unset($drop_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//print_r($categories);
|
//print_r($categories);
|
||||||
|
|
||||||
//print_r($options);
|
print_r($options);
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ foreach ($quote['QuotePage'] as $quotePage):
|
||||||
|
|
||||||
<td><?php echo $quoteProduct['QuoteProduct']['quantity'];?></td>
|
<td><?php echo $quoteProduct['QuoteProduct']['quantity'];?></td>
|
||||||
<td><?php echo $quoteProduct['QuoteProduct']['title'];?></td>
|
<td><?php echo $quoteProduct['QuoteProduct']['title'];?></td>
|
||||||
<td><?php echo $quoteProduct['QuoteProduct']['description'];?></td>
|
<td class="leftAlign"><?php echo $quoteProduct['QuoteProduct']['description'];?></td>
|
||||||
<td><?php echo $quote['Currency']['symbol'].$quoteProduct['QuoteProduct']['unit_price'];?></td>
|
<td><?php echo $quote['Currency']['symbol'].$quoteProduct['QuoteProduct']['unit_price'];?></td>
|
||||||
<td><?php
|
<td><?php
|
||||||
|
|
||||||
|
|
@ -118,7 +118,7 @@ foreach ($quote['QuotePage'] as $quotePage):
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>SUB-TOTAL (Excluding GST)</td>
|
<td class="rightAlign">SUB-TOTAL (Excluding GST)</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td><?php echo $quote['Currency']['symbol'].$subTotal; ?></td>
|
<td><?php echo $quote['Currency']['symbol'].$subTotal; ?></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
|
@ -128,7 +128,7 @@ foreach ($quote['QuotePage'] as $quotePage):
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>GST (10%)</td>
|
<td class="rightAlign">GST (10%)</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td><?php
|
<td><?php
|
||||||
if($quote['Enquiry']['gst'] == 1 ) {
|
if($quote['Enquiry']['gst'] == 1 ) {
|
||||||
|
|
@ -151,7 +151,7 @@ foreach ($quote['QuotePage'] as $quotePage):
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>TOTAL PAYABLE</td>
|
<td class="rightAlign">TOTAL PAYABLE</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td><?php
|
<td><?php
|
||||||
$total = $subTotal + $gst;
|
$total = $subTotal + $gst;
|
||||||
|
|
|
||||||
|
|
@ -547,6 +547,15 @@ table.productoptions tr.defaultoption {
|
||||||
|
|
||||||
table.quoteproducts {
|
table.quoteproducts {
|
||||||
width: 70%;
|
width: 70%;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.leftAlign {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.rightAlign {
|
||||||
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue