Changing the refresh hack to an AJAX call to rebuild the product table

This commit is contained in:
Karl Cordes 2010-02-25 11:00:42 +11:00
parent 207b45a720
commit e4c8a242bb
4 changed files with 108 additions and 88 deletions

View file

@ -21,7 +21,6 @@ class QuotesController extends AppController {
$quote = $this->Quote->read(null, $id); $quote = $this->Quote->read(null, $id);
$this->data = $quote; $this->data = $quote;
$this->set('quote', $quote); $this->set('quote', $quote);
} }

10
vendors/xtcpdf.php vendored
View file

@ -78,9 +78,9 @@ class XTCPDF extends TCPDF {
//$this->ln(); //$this->ln();
//$this->ln(); //$this->ln();
$this->SetFontSize(12); $this->SetFontSize(12);
$this->MultiCell(120, 2, "<span style=\"color: #B40404; font-weight: bold\">EXPLOSION PREVENTION AND PROTECTION</span>", 0, 'L', null, 0, null, null, true, 0, true, false); $this->MultiCell(120, 2, "<span style=\"color: #B40404; font-weight: bold\">EXPLOSION PREVENTION</span>", 0, 'L', null, 0, null, null, true, 0, true, false);
$this->MultiCell(0, 2, "<span style=\"color: #DF0101; font-weight: bold\">PRESSURE RELIEF</span>", 0, 'R', null, 1, null, null, true, 0, true, false); $this->MultiCell(0, 2, "<span style=\"color: #DF0101; font-weight: bold\">PRESSURE RELIEF</span>", 0, 'R', null, 1, null, null, true, 0, true, false);
// $this->ln(); $this->MultiCell(120, 2, "<span style=\"color: #B40404; font-weight: bold\">EXPLOSION PROTECTION</span>", 0, 'L', null, 0, null, null, true, 0, true, false);
$this->MultiCell(0, 2, "<span style=\"color: #088A4B; font-weight: bold\">VISION IN THE PROCESS</span>", 0, 'R', null, 1, null, null, true, 0, true, false); $this->MultiCell(0, 2, "<span style=\"color: #088A4B; font-weight: bold\">VISION IN THE PROCESS</span>", 0, 'R', null, 1, null, null, true, 0, true, false);
// $this->ln(); // $this->ln();
$this->MultiCell(80, 2, "<span style=\"color: #0000FF; font-weight: bold\">FLOW MEASUREMENT</span>", 0, 'L', null, 0, null, null, true, 0, true, false); $this->MultiCell(80, 2, "<span style=\"color: #0000FF; font-weight: bold\">FLOW MEASUREMENT</span>", 0, 'L', null, 0, null, null, true, 0, true, false);
@ -105,10 +105,6 @@ class XTCPDF extends TCPDF {
$pageNo = $this->PageNoFormatted(); $pageNo = $this->PageNoFormatted();
$this->SetXY($boxXstart, 55); $this->SetXY($boxXstart, 55);
$heightNeeded = $this->getNumLines($companyName, $secondColWidth); $heightNeeded = $this->getNumLines($companyName, $secondColWidth);
@ -486,8 +482,6 @@ ENDHTMLCONTENTS;
$this->MultiCell(0, 0, "Signed: ____________________________", 0, 'L'); $this->MultiCell(0, 0, "Signed: ____________________________", 0, 'L');
$this->MultiCell(0, 0, " ".$details["salesEngineer"], 0, 'L'); $this->MultiCell(0, 0, " ".$details["salesEngineer"], 0, 'L');
} }

View file

@ -60,18 +60,109 @@ foreach ($quote['QuotePage'] as $quotePage):
<h3><?php __('Products in this Quote');?></h3> <h3><?php __('Products in this Quote');?></h3>
<?php if (!empty($quoteProducts)):?> <?php if (!empty($quoteProducts)):?>
<table cellpadding = "0" cellspacing = "0" id= "quoteTable" class="quoteproducts" "> <table cellpadding = "0" cellspacing = "0" id= "quoteTable" class="quoteproducts" ">
<tr> <thead>
<th><?php __('Item Number'); ?></th> <tr>
<th><?php __('Quantity'); ?></th> <th><?php __('Item Number'); ?></th>
<th><?php __('Title'); ?></th> <th><?php __('Quantity'); ?></th>
<th><?php __('Description'); ?></th> <th><?php __('Title'); ?></th>
<th>Unit Price (<?php echo $quote['Currency']['iso4217']; ?>)</th> <th><?php __('Description'); ?></th>
<th>Unit Price (<?php echo $quote['Currency']['iso4217']; ?>)</th>
<th><?php __('Total Price'); ?> (<?php echo $quote['Currency']['iso4217']; ?>)</th> <th><?php __('Total Price'); ?> (<?php echo $quote['Currency']['iso4217']; ?>)</th>
<th class="actions"><?php __('Actions');?></th> <th class="actions"><?php __('Actions');?></th>
</tr> </tr>
</thead>
<?
$dontTotal = 0; //if we encounter an optional item. Make Subtotal, GST and total payable to be $TBA
$subTotal = 0;
foreach ($quoteProducts as $quoteProduct) {
$thisNetPrice = $quoteProduct['LineItem']['unit_price']*$quoteProduct['LineItem']['quantity'];
$subTotal += $thisNetPrice;
if($quoteProduct['LineItem']['option'] == 1) {
$dontTotal = 1;
}
}
?>
<tfoot>
<tr class="divider">
<td></td>
<td></td>
<td></td>
<td class="rightAlign">SUB-TOTAL (Excluding GST)</td>
<td></td>
<td><?php
if($dontTotal == 0) {
echo $quote['Currency']['symbol'].$subTotal;
}
else {
echo "TBA";
}
?></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td class="rightAlign">GST (10%)</td>
<td></td>
<td><?php
if($dontTotal == 0) {
if($quote['Enquiry']['gst'] == 1 ) {
$gst = 0.1 * $subTotal;
echo $quote['Currency']['symbol'].$gst;
}
else {
$gst = 0;
echo "N/A";
}
}
else {
echo "TBA";
}
?></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td class="rightAlign">TOTAL PAYABLE</td>
<td></td>
<td><?php
if($dontTotal == 0) {
$total = $subTotal + $gst;
echo $quote['Currency']['symbol'].$total;
}
else {
echo "TBA";
}
?>
</td>
<td></td>
</tr>
</tfoot>
<?php <?php
$i = 0; $i = 0;
@ -98,7 +189,7 @@ foreach ($quote['QuotePage'] as $quotePage):
<td><?php echo $quote['Currency']['symbol'].$quoteProduct['LineItem']['unit_price']; <td><?php echo $quote['Currency']['symbol'].$quoteProduct['LineItem']['unit_price'];
?></td> ?></td>
<td><?php <td class="netPrice"><?php
$thisNetPrice = $quoteProduct['LineItem']['unit_price']*$quoteProduct['LineItem']['quantity']; $thisNetPrice = $quoteProduct['LineItem']['unit_price']*$quoteProduct['LineItem']['quantity'];
@ -116,56 +207,11 @@ foreach ($quote['QuotePage'] as $quotePage):
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
<tr class="divider">
<td></td>
<td></td>
<td></td>
<td class="rightAlign">SUB-TOTAL (Excluding GST)</td>
<td></td>
<td><?php echo $quote['Currency']['symbol'].$subTotal; ?></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td class="rightAlign">GST (10%)</td>
<td></td>
<td><?php
if($quote['Enquiry']['gst'] == 1 ) {
$gst = 0.1 * $subTotal;
echo $quote['Currency']['symbol'].$gst;
}
else {
$gst = 0;
echo "N/A";
}
?></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td class="rightAlign">TOTAL PAYABLE</td>
<td></td>
<td><?php
$total = $subTotal + $gst;
echo $quote['Currency']['symbol'].$total;
?>
</td>
<td></td>
</tr>
</table> </table>
@ -248,8 +294,6 @@ foreach ($quote['QuotePage'] as $quotePage):
<div id="productOptionsBox"></div> <div id="productOptionsBox"></div>
<div id="productTitle"></div>
<div id="addLineItem-form2"> <div id="addLineItem-form2">
<? <?
/* /*
@ -262,26 +306,12 @@ foreach ($quote['QuotePage'] as $quotePage):
echo $form->input('costing_id'); echo $form->input('costing_id');
echo $form->input('unit_price'); echo $form->input('unit_price');
*/ */
?> ?>
</div> </div>
<?php //echo $form->end('Submit'); <?php //echo $form->end('Submit');
?> ?>
</div> </div>
<?php // debug ($quoteProducts); ?>
<?php foreach ($quoteProducts as $quoteProduct) {
if($quoteProduct['Costing']) {
echo "YAY. We have a costing for: ".$quoteProduct['LineItem']['title'];
}
}
?>
<div id="mydebug"></div> <div id="mydebug"></div>

View file

@ -12,9 +12,6 @@
$(function() { $(function() {
$("#addLineItem-form").dialog({ $("#addLineItem-form").dialog({
autoOpen: false, autoOpen: false,
height: 800, height: 800,
@ -24,8 +21,8 @@ $(function() {
'Add Product': function() { 'Add Product': function() {
$.post("/line_items/ajaxSave", $("#LineItemAddForm").serialize(), function(data) { $.post("/line_items/ajaxSave", $("#LineItemAddForm").serialize(), function(data) {
$('#mydebug').html(data);
location.reload();
}); });
}, },