added blank items. bugs need to be fixed

This commit is contained in:
Karl Cordes 2010-03-31 16:50:22 +11:00
parent b00db6a009
commit 67680e8e2f
4 changed files with 52 additions and 23 deletions

View file

@ -29,12 +29,15 @@ class LineItemsController extends AppController {
if (!empty($this->data)) {
$this->LineItem->create();
$product = $this->LineItem->Product->findById($this->data['LineItem']['product_id']);
if(isset($this->data['LineItem']['product_id'])) {
$product = $this->LineItem->Product->findById($this->data['LineItem']['product_id']);
/* Copy all the data from the Product to the new LineItem */
/* Copy all the data from the Product to the new LineItem */
$this->data['LineItem']['description'] = $product['Product']['description'];
$this->data['LineItem']['title'] = $product['Product']['title'];
}
$this->data['LineItem']['description'] = $product['Product']['description'];
$this->data['LineItem']['title'] = $product['Product']['title'];
// $numberOfItems = $this->LineItem->find('count',
@ -65,7 +68,7 @@ class LineItemsController extends AppController {
}
/* Process the Line Item and add it to a quote */
/* Process the Line Item and add it to a quote */
function ajaxSave() {
@ -73,11 +76,17 @@ class LineItemsController extends AppController {
if (!empty($this->data)) {
$this->LineItem->create();
$product = $this->LineItem->Product->findById($this->data['LineItem']['product_id']);
/* Copy all the data from the Product to the new LineItem */
$this->data['LineItem']['description'] = $product['Product']['description'];
$this->data['LineItem']['title'] = $product['Product']['title'];
if(isset($this->data['LineItem']['product_id'])) {
$product = $this->LineItem->Product->findById($this->data['LineItem']['product_id']);
/* Copy all the data from the Product to the new LineItem */
$this->data['LineItem']['description'] = $product['Product']['description'];
$this->data['LineItem']['title'] = $product['Product']['title'];
}
if($this->LineItem->save($this->data)) {
@ -91,7 +100,7 @@ class LineItemsController extends AppController {
exit();
/* Need to find a way to append Product Option data to the description / model number title */
/* Need to find a way to append Product Option data to the description / model number title */
}
@ -105,7 +114,7 @@ class LineItemsController extends AppController {
}
/* Display a list of Products for a given principle. Used for the add() method */
/* Display a list of Products for a given principle. Used for the add() method */
function principle_products() {
if (empty($this->data['LineItem']['principle_id'])) {
}
@ -115,16 +124,16 @@ class LineItemsController extends AppController {
}
/* Display a list of Options (if any) for a given Product. Used for the add() method */
/* Display a list of Options (if any) for a given Product. Used for the add() method */
function product_options() {
/*$this->set('categories', $this->LineItem->Product->ProductOptionsCategory->find('list'),
/*$this->set('categories', $this->LineItem->Product->ProductOptionsCategory->find('list'),
array('conditions' => array('ProductOptionsCategory.product_id'=>$this->data['LineItem']['product_id']),
'order'=>'ProductOptionsCategory.location ASC') );*/
$this->set('options', $this->LineItem->Product->ProductOptionsCategory->find('all',
array('conditions' => array('ProductOptionsCategory.product_id'=>$this->data['LineItem']['product_id']),
'order'=>'ProductOptionsCategory.location ASC')));
array('conditions' => array('ProductOptionsCategory.product_id'=>$this->data['LineItem']['product_id']),
'order'=>'ProductOptionsCategory.location ASC')));
}
@ -182,8 +191,8 @@ class LineItemsController extends AppController {
$quoteid = $this->data['LineItem']['quote_id'];
$lineItems = $this->LineItem->find('all', array('recursive' => 0, 'conditions' => array('LineItem.quote_id' => $quoteid),
'order' => array('LineItem.item_number ASC'))
);
'order' => array('LineItem.item_number ASC'))
);
$quote = $this->LineItem->Quote->read(null, $quoteid);
$this->set('quote', $quote);
@ -192,7 +201,7 @@ class LineItemsController extends AppController {
}
}
else {
//Was POSTed with no data.
//Was POSTed with no data.
$this->set('lineItems', 'Something has broken. Requesting a LineItem table without POSTing a quote or job ID');
}
}

View file

@ -108,6 +108,13 @@ $tcpdf->productPage($quote['Currency'], $enquiry['Enquiry']['gst'], $products, '
$output_dir = '/Users/karlcordes/Sites/quotenik/app/webroot/pdf/';
$debuglevel = Configure::read('debug');
if($debuglevel == 0) {
$output_dir = '/var/www/cakephp/app/webroot/pdf/';
}
if($quote['Quote']['revision'] > 0) {
$filename = $enquiry['Enquiry']['title'].'rev'.$quote['Quote']['revision'].'.pdf';
}

View file

@ -136,13 +136,19 @@ foreach ($quote['QuotePage'] as $quotePage):
?>
<button id="addBlankItem">Add Blank Item</button>
<?php
echo $form->input('title', array('div'=>'blankItem'));
echo $form->input('description', array('div'=>'blankItem'));
?>
<div id="productBox"></div>
<div id="productOptionsBox"></div>
<? echo $form->input('unit_price', array('id'=>"unitPrice", 'div'=>'nocosting', 'class'=>'nocostinput')); ?>
<? echo $form->input('discount_percent', array('id'=>'discountPercent', 'div'=>'nocosting', 'class'=>'nocostinput'));
<? echo $form->input('unit_price', array('id'=>"unitPrice", 'div'=>'nocosting', 'class'=>'nocostinput'));
echo $form->input('discount_percent', array('id'=>'discountPercent', 'div'=>'nocosting', 'class'=>'nocostinput'));
echo $form->input('discount_amount_each', array('id'=>'discountAmountEach', 'readonly'=>'readonly', 'div'=>'nocosting'));
echo $form->input('net_price_each', array('id'=>'net_price_each', 'readonly'=>'readonly', 'div'=>'nocosting'));
echo $form->input('total_discount_amount', array('id'=>'total_discountAmount', 'readonly'=>'readonly', 'div'=>'nocosting'));

View file

@ -19,7 +19,7 @@ $(function() {
$(".nocosting").hide();
$(".blankItem").hide();
$("#addLineItem-form").dialog({
@ -33,7 +33,8 @@ $(function() {
$.post("/line_items/ajaxSave", $("#LineItemAddForm").serialize(), function(data) {
fetchTable();
}
$('#mydebug').html(data);
}
);
$("#LineItemAddForm").resetForm();
@ -80,7 +81,13 @@ $(function() {
});
$('#addBlankItem').button().click(function () {
$("#LineItemPrincipleId").hide();
$(".blankItem").show();
$(".nocosting").show();
return false;
});
});