Gotta refactor xtcpdf because of stupid spec changes. Need to turn on recursion which changes the datastructure format of the Products.. .GHUweghwegw

This commit is contained in:
Karl Cordes 2010-03-31 15:09:27 +11:00
parent 241724b8a3
commit e7a6c9ebfc
12 changed files with 291 additions and 347 deletions

View file

@ -27,11 +27,24 @@ class CostingsController extends AppController {
$this->Session->setFlash(__('The Costing could not be saved. Please, try again.', true));
}
}
$products = $this->Costing->Product->find('list');
$lineItems = $this->Costing->LineItem->find('list');
if(isset($this->params['named']['productid'])) {
$product = $this->Costing->Product->findById($this->params['named']['productid']);
$this->set('product', $product);
}
if(isset($this->params['named']['lineitemid'])) {
$line_item = $this->Costing->LineItem->findById($this->params['named']['lineitem']);
$this->set('line_item', $line_item);
}
$purchaseCurrencies = $this->Costing->PurchaseCurrency->find('list');
$saleCurrencies = $this->Costing->SaleCurrency->find('list');
$this->set(compact('products', 'lineItems', 'purchaseCurrencies', 'saleCurrencies'));
$this->set(compact('purchaseCurrencies', 'saleCurrencies'));
}
function edit($id = null) {

View file

@ -6,7 +6,7 @@ class PrinciplesController extends AppController {
var $paginate = array(
'Principle' => array('limit' => 50, 'order' => array('Principle.name' => 'asc')),
'Enquiry' => array('limit' => 200, 'order' => array('Enquiry.id' => 'desc'))
'Enquiry' => array('limit' => 150, 'order' => array('Enquiry.id' => 'desc'))
);
function index() {

View file

@ -189,7 +189,7 @@ class QuotesController extends AppController {
$this->set('quote', $quote);
$this->set('enquiry', $enquiry);
$this->set('principlesList', $this->Quote->Enquiry->Principle->find('list'));
$this->set('products', $quoteProducts);
@ -218,7 +218,7 @@ class QuotesController extends AppController {
$user = $this->Quote->Enquiry->User->find('first', array('conditions' => array('User.id' => $enquiry['Enquiry']['user_id'])));
$this->set('principlesList', $this->Quote->Enquiry->Principle->find('list'));
/**
@ -275,8 +275,8 @@ class QuotesController extends AppController {
$this->set('quote', $quote);
$this->set('enquiry', $enquiry);
$this->set('products', $quoteProducts);
}
@ -284,66 +284,6 @@ class QuotesController extends AppController {
}
function BROKENajaxpdf() {
Configure::write('debug',0);
if($this->RequestHandler->isAjax()) {
$quoteid = $this->data['Quote']['id'];
$quote = $this->Quote->findById($quoteid);
//$customer = $this->Quote->Enquiry->Customer->read(null, $quote['Enquiry']['customer_id']);
$enquiry = $this->Quote->Enquiry->find('first', array('conditions' => array('Enquiry.id' => $quote['Quote']['enquiry_id'])));
$quoteProducts = $this->Quote->LineItem->find('all', array('recursive' => 0, 'conditions' => array('LineItem.quote_id' => $id),
'order' => array('LineItem.item_number ASC'))
);
$user = $this->Quote->Enquiry->User->find('first', array('conditions' => array('User.id' => $enquiry['Enquiry']['user_id'])));
if($enquiry['Enquiry']['gst'] == 1) {
$gstPhrase = "10% EXTRA";
}
else {
$gstPhrase = "Not Applicable for Export";
}
$commercialDetails = array (
'deliveryTime' => strtoupper($quote['Quote']['delivery_time']),
'paymentTerms' => strtoupper($quote['Quote']['payment_terms']),
'dateIssued' => $quote['Quote']['date_issued'],
'validFor' => $quote['Quote']['days_valid'],
'deliveryPoint' => strtoupper($quote['Quote']['delivery_point']),
'exchangeRate' => strtoupper($quote['Quote']['exchange_rate']),
'customsDuty' => strtoupper($quote['Quote']['customs_duty']),
'gst' => strtoupper($gstPhrase),
'salesEngineer' => strtoupper($user['User']['first_name'].' '.$user['User']['last_name'])
);
$this->set('commercialDetails', $commercialDetails);
//debug($quote);
//debug($commercialDetails);
$this->set('quote', $quote);
$this->set('enquiry', $enquiry);
$this->set('products', $quoteProducts);
}
}
/**

View file

@ -49,7 +49,7 @@ class VaultShell extends Shell {
//echo "Checking msg number: $i \tSubject: ".$message['subject']."\n";
$enquiry = $this->checkIfValidEnquiry($message['subject'], $testing);
if($enquiry) {
echo "Found Enquiry number: ".$enquiry['Enquiry']['title']." Processing.\n";
//echo "Found Enquiry number: ".$enquiry['Enquiry']['title']." Processing.\n";
//Process it and store the message and its attachments.
//Generate a Uniqid for this email.
@ -127,17 +127,12 @@ class VaultShell extends Shell {
}
echo "Email stored in the DB under enquiry ".$enquiry['Enquiry']['title']." Will be moved to the stored folder\n";
$stored_msgs[] = imap_uid($mbox,$i);
// if($attachments != 1) {
// $this->clearEmailAttachmentDirs($email_dir, $temp_filename, $attachments);
//unlink($email_dir.'/'.$temp_filename); #remove the temp email. start again
// }
//$stored_msgs[] = imap_uid($mbox,$i);
if($testing == 0) {
imap_mail_move($mbox, $no, 'INBOX/Stored');
}
}
else {
@ -166,7 +161,7 @@ class VaultShell extends Shell {
if(isset($stored_msgs)) {
/* if(isset($stored_msgs)) {
foreach($stored_msgs as $msg) {
$no = imap_msgno($mbox,$msg);
@ -190,6 +185,8 @@ class VaultShell extends Shell {
}
}
* */
/* Finished working with the IMAP server. Make the changes and close the connection */
imap_expunge($mbox);
imap_close($mbox);

143
vendors/xtcpdf.php vendored
View file

@ -179,85 +179,6 @@ class XTCPDF extends TCPDF {
}
/**
* Product Pages, made using writeHTML Cell.
*
*
*
* @param <type> $principleName
* @param <type> $currency
* @param <type> $gst
* @param <type> $products
* @param <type> $docType
* @param <type> $commercialDetails
*/
function productPageHTML($principleName, $currency,$gst, $products ,$docType, $commercialDetails) {
$this->SetAutoPageBreak(true, 20);
$this->setPrintHeader(true);
$this->SetTopMargin(20);
$this->AddPage();
$currencyISOcode = $currency['iso4217'];
$item_width = 40;
$qty_width = 40;
$desc_width = 340;
$unitprice_width = 60;
$totalprice_width = 60;
$tbl = <<<EOD
<table align="center" border="1" cellspacing="0" cellpadding="2">
<thead>
<tr style="background-color:#F2F2F2;">
<td width="$item_width" align="center"><b>ITEM NO.</b></td>
<td width="$qty_width" align="center"><b>QTY</b></td>
<td width="$desc_width" align="center"><b>DESCRIPTION</b></td>
<td width="$unitprice_width" align="center"> <b>UNIT PRICE</b></td>
<td width="$totalprice_width" align="center"><b>TOTAL PRICE</b></td>
</tr>
<tr style="background-color:#F2F2F2;">
<td width="$item_width" align="center"></td>
<td width="$qty_width" align="center"></td>
<td width="$desc_width" align="center"></td>
<td width="$unitprice_width" align="center"> <b>$currencyISOcode</b></td>
<td width="$totalprice_width" align="center"><b>$currencyISOcode</b></td>
</tr>
</thead>
EOD;
foreach ($products as $product) {
$fullDesc = "<b>".$product[$docType]['title'].'</b><br />'.$product[$docType]['description'];
// echo $fullDesc;
$itemno = number_format($product[$docType]['item_number'], 1, '.', '');
$qty = $product[$docType]['quantity'];
$unit_price = $this->formatCurrency($currency['symbol'], $product[$docType]['unit_price']);
$thisTotalPrice = $product[$docType]['quantity']*$product[$docType]['unit_price'];
$total_price = $this->formatCurrency($currency['symbol'],$thisTotalPrice);
$tbl .= <<<ENDPRODUCT
<tr>
<td width="$item_width" align="center">$itemno</td>
<td width="$qty_width" align="center">$qty</td>
<td width="$desc_width" align="left">$fullDesc</td>
<td width="$unitprice_width" align="center">$unit_price</td>
<td width="$totalprice_width" align="center">$total_price</td>
</tr>
ENDPRODUCT;
}
$tbl .= "</table>";
$this->writeHTML($tbl, true, false, false, false, "");
}
/**
@ -269,7 +190,7 @@ ENDPRODUCT;
* @param <type> $docType
* @param <type> $commercialDetails
*/
function calculateProductPage($principleName, $currency,$gst, $products ,$docType, $commercialDetails) {
function calculateProductPage($principlesList, $currency,$gst, $products ,$docType, $commercialDetails) {
$itemColwidth = 12;
$qtyColwidth = 10;
@ -289,7 +210,7 @@ ENDPRODUCT;
$this->startTransaction();
$fullDesc = "<b>".$product[$docType]['title'].'GG</b><br>'.$product[$docType]['description'];
$fullDesc = "<b>".$principlesList[$product[$docType]['principle_id']]."</b><br>"."<b>".$product[$docType]['title'].'</b><br>'.$product[$docType]['description'];
$this->MultiCell($descColwidth, 0, $fullDesc, 1, "L", 0, 0, null, null, true, 0, true);
$lasth = $this->getLastH();
@ -298,18 +219,18 @@ ENDPRODUCT;
echo $product[$docType]['id']." needs ".$lasth." has $heightLeft left<br>";
//echo $product[$docType]['id']." needs ".$lasth." has $heightLeft left<br>";
$itemno = $product[$docType]['item_number'];
if($heightLeft - $lasth <= 0) {
echo "<br>OUT OF SPACE ON PAGE $pagesRequired making a new one<br>";
// echo "<br>OUT OF SPACE ON PAGE $pagesRequired making a new one<br>";
$pagesRequired++;
$heightLeft = $availableHeight; //Start checking the next page;
echo "<br>remaining height on new one = ".$heightLeft."<br>";
// echo "<br>remaining height on new one = ".$heightLeft."<br>";
$heightLeft -= $lasth;
$itemno = $product[$docType]['item_number'];
echo "<br>Using $lasth for $itemno so now have $heightLeft left<br>";
// echo "<br>Using $lasth for $itemno so now have $heightLeft left<br>";
$pageProducts[$pagesRequired][] = $product[$docType]['id'];
@ -336,12 +257,12 @@ ENDPRODUCT;
$this->rollbackTransaction($this);
echo "Currently have $heightLeft Comm details height is ".$commDetailsHeight." totals height is: ".$totalsHeight."<br>";
//echo "Currently have $heightLeft Comm details height is ".$commDetailsHeight." totals height is: ".$totalsHeight."<br>";
if($heightLeft - $totalsHeight <= 0) {
echo "<br>Need a new page for last item and totals";
// echo "<br>Need a new page for last item and totals";
array_pop($pageProducts[$pagesRequired]);
$pagesRequired++;
$heightLeft = $availableHeight;
@ -361,14 +282,15 @@ ENDPRODUCT;
/**
*
* @param <type> $principleName
* @param Map $principles - list of principles. A hack so we can show a products principle name on it, without rewriting
* lots of code.
* @param <type> $currency
* @param int $gst - 0 or 1 if GST is applicable.
* @param <type> $products
* @param String $docType - the model name of the Products we want to put in the table. ie. QuoteProduct, or InvoiceProduct, etc
* @param Map $commercialDetails - the details array/map - passed to commercialComments()
*/
function productPage($principleName, $currency,$gst, $products ,$docType, $commercialDetails, $pageProducts) {
function productPage($principlesList, $currency,$gst, $products ,$docType, $commercialDetails, $pageProducts) {
$this->SetFontSize(10);
@ -391,8 +313,8 @@ ENDPRODUCT;
$options = 0; //Toggled to 1 when we encounter an Optional product. Stops the totals being printed.
print_r($pageProducts);
// print_r($products);
echo "FUCK";
print_r($principlesList);
foreach ($pageProducts as $page) {
$this->AddPage();
@ -435,7 +357,7 @@ ENDPRODUCT;
foreach($page as $productID) {
$product = array_shift($products);
$fullDesc = "<b>".$product['Principle']['name']."</b><br>"."<b>".$product[$docType]['title'].'</b><br>'.$product[$docType]['description'];
$fullDesc = "<b>".$principlesList[$product[$docType]['id']]."</b><br>"."<b>".$product[$docType]['title'].'</b><br>'.$product[$docType]['description'];
if($product[$docType]['option'] == 1) {
$options = 1;
@ -456,13 +378,40 @@ ENDPRODUCT;
$this->SetX($endOfDesc);
$this->MultiCell($unitpriceColwidth, $heightNeeded, $this->formatCurrency($currency['symbol'], $product[$docType]['unit_price']), 1, "C", 0, 0);
$thisTotalPrice = $product[$docType]['quantity']*$product[$docType]['unit_price'];
$this->MultiCell($totalPricColwidth, $heightNeeded, $this->formatCurrency($currency['symbol'],$thisTotalPrice), 1, "C", 0, 1);
if($product[$docType]['discount_percent'] != 0) {
$unitPriceString = $this->formatCurrency($currency['symbol'], $product[$docType]['unit_price']);
$unitPriceString .= "<br>less ".$product[$docType]['discount_percent']."% discount<br>(-"
.$this->formatCurrency($currency['symbol'], $product[$docType]['discount_amount_each']).")<br>=<br>";
$unitPriceString .= $this->formatCurrency($currency['symbol'], $product[$docType]['net_price_each']);
$totalPriceString = $this->formatCurrency($currency['symbol'], $product[$docType]['gross_price']);
$totalPriceString .= "<br>less ".$product[$docType]['discount_percent']."% discount<br>(-"
.$this->formatCurrency($currency['symbol'], $product[$docType]['total_discount_amount']).")<br>=<br>";
$totalPriceString .= $this->formatCurrency($currency['symbol'], $product[$docType]['net_price']);
}
else {
$unitPriceString = $this->formatCurrency($currency['symbol'], $product[$docType]['unit_price']);
$totalPriceString = $this->formatCurrency($currency['symbol'], $product[$docType]['net_price']);
}
//Unit Price Column
$this->MultiCell($unitpriceColwidth, $heightNeeded, $unitPriceString , 1, "C", 0, 0, null, null, true, 0, true);
$subTotal += $thisTotalPrice;
//Net Price Column
$this->MultiCell($totalPricColwidth, $heightNeeded, $totalPriceString, 1, "C", 0, 1, null, null, true, 0, true);
$subTotal += $product[$docType]['net_price'];
$lastY = $this->GetY();
$lastX = $this->GetX();
//echo $product[$docType]['item_number']." Last X is $lastX, Last Y is $lastY <br>";
@ -610,7 +559,7 @@ ENDHTMLCONTENTS;
$totalPricColwidth = -10;
$totalHeight = 0;
echo "desc col wdith : ".$descColwidth;
// echo "desc col wdith : ".$descColwidth;
$this->MultiCell($itemColwidth, 6, "", 1, 'C', 0, 0);
$totalHeight += $this->getLastH();
$this->MultiCell($qtyColwidth, 6, "", 1, 'C', 0, 0);

View file

@ -3,12 +3,21 @@
<div class="costings form">
<?php echo $form->create('Costing', array('class'=>'cmxform'));?>
<?php __('Add Costing');?>
<?php if(isset($product)) {
$form->input('product_id', array('type'=>'hidden', 'value'=>$product['Product']['id']));
}
elseif(isset($line_item)) {
$form->input('line_item_id', array('type'=>'hidden', 'value'=>$line_item['LineItem']['id']));
}
?>
<?php __('Add Costing to');?>
<fieldset>
<legend>Quantity, Unit price, Packing costs</legend>
<?php
echo $form->input('product_id');
echo $form->input('line_item_id');
echo $form->input('purchase_currency_id');
echo $form->input('sale_currency_id', array('default'=>2));
echo $form->input('quantity');
@ -81,7 +90,6 @@
<?
?>
</fieldset>
<?php
echo $form->input('duty_amount', array('type'=>'hidden'));
echo $form->input('finance_amount', array('type'=>'hidden'));

View file

@ -1,151 +1,158 @@
<h3><?php __($quote['Quote']['line_item_count'].' Items in this Quote');?></h3>
<h3><?php __($quote['Quote']['line_item_count'].' Items in this Quote');?></h3>
<table cellpadding = "0" cellspacing = "0" id= "quoteTable" class="quoteproducts" ">
<thead>
<tr>
<th><?php __('Item Number'); ?></th>
<th><?php __('Quantity'); ?></th>
<th><?php __('Title'); ?></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 class="actions"><?php __('Actions');?></th>
</tr>
</thead>
<?
$dontTotal = 0; //if we encounter an optional item. Make Subtotal, GST and total payable to be $TBA
$subTotal = 0;
foreach ($lineItems as $lineItem) {
$thisNetPrice = $lineItem['LineItem']['unit_price']*$lineItem['LineItem']['quantity'];
$subTotal += $thisNetPrice;
if($lineItem['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
$i = 0;
$subTotal = 0;
foreach ($lineItems as $lineItem):
$class = null;
if ($i++ % 2 == 0) {
$class = ' class="altrow"';
}
?>
<tr<?php echo $class;?>>
<td><?php
if($lineItem['LineItem']['option'] == 1 ) {
echo 'Option <br>';
}
echo number_format($lineItem['LineItem']['item_number'], 1, '.', '');?></td>
<td><?php echo $lineItem['LineItem']['quantity'];?></td>
<td><?php echo $lineItem['LineItem']['title'];?></td>
<td class="leftAlign"><?php echo $lineItem['LineItem']['description'];?></td>
<td><?php echo $quote['Currency']['symbol'].$lineItem['LineItem']['unit_price'];
?></td>
<td class="netPrice"><?php
$thisNetPrice = $lineItem['LineItem']['unit_price']*$lineItem['LineItem']['quantity'];
$subTotal += $thisNetPrice;
echo $quote['Currency']['symbol'].$thisNetPrice; ?></td>
<td class="actions">
<?php echo $html->link(__('View', true), array('controller'=> 'line_items', 'action'=>'view', $lineItem['LineItem']['id'])); ?>
<?php echo $html->link(__('Edit', true), array('controller'=> 'line_items', 'action'=>'edit', $lineItem['LineItem']['id'])); ?>
<?php echo $html->link(__('Delete', true), array('controller'=> 'line_items', 'action'=>'delete', $lineItem['LineItem']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $lineItem['LineItem']['id'])); ?>
</td>
<thead>
<tr>
<th><?php __('Item Number'); ?></th>
<th><?php __('Quantity'); ?></th>
<th><?php __('Title'); ?></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 class="actions"><?php __('Actions');?></th>
</tr>
<?php endforeach; ?>
</thead>
</table>
<?
$dontTotal = 0; //if we encounter an optional item. Make Subtotal, GST and total payable to be $TBA
$subTotal = 0;
foreach ($lineItems as $lineItem) {
$thisNetPrice = $lineItem['LineItem']['net_price'];
$subTotal += $thisNetPrice;
if($lineItem['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
$i = 0;
$subTotal = 0;
foreach ($lineItems as $lineItem):
$class = null;
if ($i++ % 2 == 0) {
$class = ' class="altrow"';
}
?>
<tr<?php echo $class;?>>
<td><?php
if($lineItem['LineItem']['option'] == 1 ) {
echo 'Option <br>';
}
echo number_format($lineItem['LineItem']['item_number'], 1, '.', '');?></td>
<td><?php echo $lineItem['LineItem']['quantity'];?></td>
<td><?php echo $lineItem['LineItem']['title'];?></td>
<td class="leftAlign"><?php echo $lineItem['LineItem']['description'];?></td>
<td><?php echo $quote['Currency']['symbol'].$lineItem['LineItem']['unit_price'];
//If there's a costing, or a discount. Show it.
if($lineItem['LineItem']['discount_percent']) {
echo "<br>less ".$lineItem['LineItem']['discount_percent']."% discount (-".
$quote['Currency']['symbol'].$lineItem['LineItem']['discount_amount_each'].")<br>";
echo "=<br>".$quote['Currency']['symbol'].$lineItem['LineItem']['net_price_each'];
}
?></td>
<td class="netPrice"><?php
echo $quote['Currency']['symbol'].$lineItem['LineItem']['net_price']; ?></td>
<td class="actions">
<?php echo $html->link(__('View', true), array('controller'=> 'line_items', 'action'=>'view', $lineItem['LineItem']['id'])); ?>
<?php echo $html->link(__('Edit', true), array('controller'=> 'line_items', 'action'=>'edit', $lineItem['LineItem']['id'])); ?>
<?php echo $html->link(__('Delete', true), array('controller'=> 'line_items', 'action'=>'delete', $lineItem['LineItem']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $lineItem['LineItem']['id'])); ?>
</td>
</tr>
<?php endforeach; ?>
</table>

View file

@ -36,7 +36,9 @@
<div class="actions">
<ul>
<li><?php echo $html->link(__('Edit Product', true), array('action'=>'edit', $product['Product']['id'])); ?> </li>
<li><?php echo $html->link(__('Add Costing', true), array('controller'=>'costings', 'action'=>'add/productid:'.$product['Product']['id']));?></li>
<button id="addCostingDialog"></button>
</ul>
</div>
@ -103,6 +105,12 @@
</div>
<div id="costingdiv"></div>
<?php debug($product); ?>
<?php debug($options); ?>

View file

@ -26,7 +26,7 @@ $tcpdf->SetHeaderMargin(2);
$tcpdf->setPrintHeader(false);
$tcpdf->setPrintFooter(false);
$principle_name = strtoupper($enquiry['Principle']['name']);
$pageProducts = $tcpdf->calculateProductPage($principle_name, $quote['Currency'],
$enquiry['Enquiry']['gst'], $products, 'LineItem', $commercialDetails);
@ -100,7 +100,7 @@ foreach ($quote['QuotePage'] as $page) {
$tcpdf->productPage($principle_name, $quote['Currency'], $enquiry['Enquiry']['gst'], $products, 'LineItem', $commercialDetails,
$tcpdf->productPage($principlesList, $quote['Currency'], $enquiry['Enquiry']['gst'], $products, 'LineItem', $commercialDetails,
$pageProducts);

View file

@ -27,8 +27,8 @@ $tcpdf->SetHeaderMargin(2);
$tcpdf->setPrintHeader(false);
$tcpdf->setPrintFooter(false);
$principle_name = strtoupper($enquiry['Principle']['name']);
$pageProducts = $tcpdf->calculateProductPage($principle_name, $quote['Currency'], $enquiry['Enquiry']['gst'], $products, 'LineItem', $commercialDetails);
$pageProducts = $tcpdf->calculateProductPage($principlesList, $quote['Currency'], $enquiry['Enquiry']['gst'], $products, 'LineItem', $commercialDetails);
$page1done = false; //Have we already made the first page? If so, don't show the CMC header/footer
@ -90,7 +90,7 @@ foreach ($quote['QuotePage'] as $page) {
//print_r($products);
print_r($principlesList);
//debug($commercialDetails);
@ -100,10 +100,11 @@ foreach ($quote['QuotePage'] as $page) {
$tcpdf->productPage($principle_name, $quote['Currency'], $enquiry['Enquiry']['gst'], $products, 'LineItem', $commercialDetails,
$tcpdf->productPage($principlesList, $quote['Currency'], $enquiry['Enquiry']['gst'], $products, 'LineItem', $commercialDetails,
$pageProducts);
//print_r($products);
$output_dir = '/Users/karlcordes/Sites/quotenik/app/webroot/pdf/';

View file

@ -1,10 +1,11 @@
<?php echo $javascript->link('addLineItem'); ?>
<?php echo $javascript->link('lineItemPriceNoCosting'); ?>
<div class="quotes view">
<h2><?php
$enquirynumber_link = $html->link($quote['Enquiry']['title'],
array('controller'=>'enquiries', 'action'=>'view', $quote['Enquiry']['id']));
array('controller'=>'enquiries', 'action'=>'view', $quote['Enquiry']['id']));
$customer_link = $html->link( $customer['Customer']['name'], array('controller'=>'customers', 'action' => 'view', $customer['Customer']['id']));
@ -57,7 +58,7 @@ foreach ($quote['QuotePage'] as $quotePage):
<div class="quoteproducts">
<div id="productTable"></div>
@ -66,7 +67,7 @@ foreach ($quote['QuotePage'] as $quotePage):
<button id="addLineItem">Add a Product to this Quote</button>
<button id="generatePDF">Generate a PDF of this Quote</button>
</ul>
</div>
@ -130,7 +131,7 @@ foreach ($quote['QuotePage'] as $quotePage):
echo $form->input('item_number');
echo $form->input('option', array('label'=>'Optional Item'));
echo $form->input('quantity');
echo $form->input('quantity', array('class'=>'nocostinput'));
echo $form->input('principle_id', array('options'=>$principles, 'empty' =>'Select the Principle for this Product'));
@ -140,11 +141,18 @@ foreach ($quote['QuotePage'] as $quotePage):
<div id="productOptionsBox"></div>
<? echo $form->input('unit_price', array('id'=>"unitPrice")); ?>
<? 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'));
echo $form->input('gross_price', array('id'=>'grossPrice', 'readonly'=>'readonly', 'div'=>'nocosting'));
echo $form->input('net_price', array('id'=>'netPrice', 'readonly'=>'readonly', 'div'=>'nocosting'));
?>
<div id="addLineItem-form2">
<?
/*
/*
echo $form->input('title');
echo $form->input('description');
@ -153,7 +161,7 @@ foreach ($quote['QuotePage'] as $quotePage):
echo $form->input('product_id');
echo $form->input('costing_id');
echo $form->input('unit_price');
*/
*/
?>
</div>
@ -162,4 +170,6 @@ foreach ($quote['QuotePage'] as $quotePage):
?>
</div>
<div id="mydebug"></div>
<div id="mydebug"></div>
<? debug($principles); ?>

View file

@ -16,7 +16,12 @@ $(function() {
fetchTable();
var quoteID = $("#QuoteId").serialize();
$("#unitPrice").hide();
$(".nocosting").hide();
$("#addLineItem-form").dialog({
autoOpen: false,
height: 800,
@ -29,10 +34,10 @@ $(function() {
fetchTable();
}
);
);
$("#LineItemAddForm").resetForm();
$(this).dialog('close');
$("#LineItemAddForm").resetForm();
$(this).dialog('close');
},
Cancel: function() {
$(this).dialog('close');
@ -73,7 +78,11 @@ $(function() {
altField: '#QuoteDateIssued'
});
});
@ -105,7 +114,8 @@ function getProductOptions() {
});
$("#unitPrice").show();
$(".nocosting").show();
}
@ -120,3 +130,4 @@ function fetchTable() {
}