Making changes to Vault. Hopefully it will work

This commit is contained in:
Karl Cordes 2009-11-19 10:23:21 +11:00
parent b1cac9e89d
commit 7f08e9e53b
16 changed files with 666 additions and 113 deletions

View file

@ -39,6 +39,13 @@ class QuotesController extends AppController {
$this->data['Quote']['enquiry_id'] = $enquiryid; $this->data['Quote']['enquiry_id'] = $enquiryid;
$this->data['Quote']['date_issued'] = date('Y-m-d'); $this->data['Quote']['date_issued'] = date('Y-m-d');
$this->data['Quote']['currency_id'] = 2;
/**
* @todo Fix this hard coded default currency. Currently set to '2' for AUD.
*/
if ($this->Quote->save($this->data)) { if ($this->Quote->save($this->data)) {
$quoteid = $this->Quote->id; $quoteid = $this->Quote->id;
@ -84,7 +91,8 @@ class QuotesController extends AppController {
$this->data = $quote; $this->data = $quote;
} }
$enquiry = $this->Quote->Enquiry->findById($quote['Quote']['enquiry_id']); $enquiry = $this->Quote->Enquiry->findById($quote['Quote']['enquiry_id']);
$this->set(compact('enquiry', 'quote')); $currencies = $this->Quote->Currency->find('list');
$this->set(compact('enquiry', 'quote', 'currencies'));
} }
@ -96,15 +104,24 @@ class QuotesController extends AppController {
} }
$quote = $this->Quote->findById($id); $quote = $this->Quote->findById($id);
//$customer = $this->Quote->Enquiry->Customer->read(null, $quote['Enquiry']['customer_id']); //$customer = $this->Quote->Enquiry->Customer->read(null, $quote['Enquiry']['customer_id']);
$enquiry = $this->Quote->Enquiry->findById($quote['Quote']['enquiry_id']); $enquiry = $this->Quote->Enquiry->find('first', array('conditions' => array('Enquiry.id' => $quote['Quote']['enquiry_id'])));
$quoteProducts = $this->Quote->QuoteProduct->find('all', array('recursive' => 0, 'conditions' => array('QuoteProduct.quote_id' => $id),
'order' => array('QuoteProduct.item_number ASC'))
);
$this->set('quote', $quote); $this->set('quote', $quote);
$this->set('enquiry', $enquiry); $this->set('enquiry', $enquiry);
$this->set('products', $quoteProducts);
// $this->set('customer', $customer); // $this->set('customer', $customer);
//$this->layout = 'pdf'; //$this->layout = 'pdf';
//$this->render(); //$this->render();
} }
} }
?> ?>

View file

@ -18,7 +18,9 @@ class Quote extends AppModel {
'conditions' => '', 'conditions' => '',
'fields' => '', 'fields' => '',
'order' => '' 'order' => ''
) ),
'Currency' => array('className' => 'Currency', 'foreignKey' => 'currency_id')
); );
var $hasMany = array( var $hasMany = array(

View file

@ -24,7 +24,7 @@ class VaultShell extends Shell {
$email_dir = '/var/www/quotenik1.2/app/emails/working'; $email_dir = '/var/www/quotenik1.2/app/emails/working';
} }
$mbox = imap_open("{saturn:143/novalidate-cert}INBOX", $username, $password) or die("can't connect: " . imap_last_error()); $mbox = imap_open("{neptune:143/novalidate-cert}INBOX", $username, $password) or die("can't connect: " . imap_last_error());
$MC = imap_check($mbox); $MC = imap_check($mbox);
$number_of_messages = $MC->Nmsgs; $number_of_messages = $MC->Nmsgs;

112
vendors/xtcpdf.php vendored
View file

@ -1,8 +1,7 @@
<?php <?php
App::import('Vendor','tcpdf/tcpdf'); App::import('Vendor','tcpdf/tcpdf');
class XTCPDF extends TCPDF class XTCPDF extends TCPDF {
{
var $xheadertext = 'PDF created using CakePHP and TCPDF'; var $xheadertext = 'PDF created using CakePHP and TCPDF';
var $xheadercolor = array(0,0,200); var $xheadercolor = array(0,0,200);
@ -21,8 +20,7 @@ class XTCPDF extends TCPDF
* set the font in the view using * set the font in the view using
* $fpdf->setHeaderFont(array('YourFont','',fontsize)); * $fpdf->setHeaderFont(array('YourFont','',fontsize));
*/ */
function Page1Header() function Page1Header() {
{
list($r, $b, $g) = $this->xheadercolor; list($r, $b, $g) = $this->xheadercolor;
@ -72,8 +70,7 @@ class XTCPDF extends TCPDF
* set the text in the view using * set the text in the view using
* $fpdf->xfootertext = 'Copyright © %d YOUR ORGANIZATION. All rights reserved.'; * $fpdf->xfootertext = 'Copyright © %d YOUR ORGANIZATION. All rights reserved.';
*/ */
function Page1Footer() function Page1Footer() {
{
$this->SetY(-20); $this->SetY(-20);
$this->Image(K_PATH_IMAGES.'cmcfooter.jpg', null, 255, 200, 0, null, 'http://www.cmctechnologies.com.au', null, false, null, 'C'); $this->Image(K_PATH_IMAGES.'cmcfooter.jpg', null, 255, 200, 0, null, 'http://www.cmctechnologies.com.au', null, false, null, 'C');
} }
@ -95,14 +92,7 @@ class XTCPDF extends TCPDF
$pageNo = $this->PageNoFormatted(); $pageNo = $this->PageNoFormatted();
//$pageOf = $this->getAliasNbPages(); //$pageOf = $this->getAliasNbPages();
/* Debugging Vars
$companyName = "LONG COMPANY NAME TRADING AS MR AWESOME PTY LTD LONG COMPANY NAME TRADING AS MR AWESOME PTY LTD ";
$emailTo = "theman@theman.com";
$attention = "Joe Bloggs";
$fromName = "Mr Sales Man";
$fromEmail = "SalesMan@cmctechnologies.com.au";
$enquiryNumber = "CMC1234NE22656-41";
*/
$this->SetXY($boxXstart, 55); $this->SetXY($boxXstart, 55);
@ -147,22 +137,7 @@ class XTCPDF extends TCPDF
$this->MultiCell(0, 0, 'The information in this document is confidential and may be privileged. If you are not the indended recipient then access, disclosure, copying or other dissemination of the contents of t his message is unauthorised and may be unlawful. Please inform the sender immediately if you are not the intended addressee.', $this->MultiCell(0, 0, 'The information in this document is confidential and may be privileged. If you are not the indended recipient then access, disclosure, copying or other dissemination of the contents of t his message is unauthorised and may be unlawful. Please inform the sender immediately if you are not the intended addressee.',
'', 'L' '', 'L'
); );
/*
*
*
$this->Cell($firstColWidth, 0, "ATTENTION:", 'LTRB', 0, 'L', 0, null, 0, false);
$this->Cell($secondColWidth, 0, $attention, 'LTRB', 0, 'L', 0, "mailto:$emailTo", 0, false);
$this->Cell($thirdColWidth, 0, "PAGE: ", 'LTB', 0, 'L', 0, null, 0, false);
$this->Cell($fourthColWidth, 0, "$pageNo of {nb}", 'TBR', 1, 'L', 0, null, 0, false); //Start a new line after thi
*/
// $this->lastPage();
//$this->Cell($w, $h, $txt, $border, $ln, $align, $fill, $link, $stretch, $ignore_min_height)
// $this->MultiCell($firstColWidth, 0, "QUOTATION TO:", 'LTRB', 'L', 0, 0, $boxXstart, $boxYstart, false, false, true, false, 0);
//Next Cell to the right.
//$this->MultiCell(50, 0, "COMPANY NAME", 'LTRB', 'L', 0, 0, $boxXstart, $boxYstart+$firstColWidth, true, false, true, true, 0);
//$this->MultiCell($w, $h, $txt, $border, $align, $fill, $ln, $x, $y, $reseth, $stretch, $ishtml, $autopadding, $maxh)
} }
@ -177,8 +152,85 @@ class XTCPDF extends TCPDF
} }
/**
*
* @param <type> $principleName
* @param <type> $currency
* @param <type> $products
* @param String $docType - the model name of the Products we want to put in the table. ie. QuoteProduct, or InvoiceProduct, etc
*/
function productPage($principleName, $currency, $products ,$docType) {
$this->SetFontSize(10);
$lineHeight = 8; //Size of a single line of text. If the company name is more, multiply this by the number of lines it needs
$itemColwidth = 15;
$qtyColwidth = 15;
$descColwidth = 130;
$unitpriceColwidth = 15;
$totalPricColwidth = -10;
$this->SetFillColor(240);
//$heightNeeded = $this->getNumLines("ITEM\NO.", $itemColwidth);
//echo "HEADER ROW HEIGHT IS $heightNeeded";
//Draw Header Rows
$pageNo = $this->PageNoFormatted();
$this->MultiCell(0, 0, "PRICING & SPECIFICATIONS (PAGE $pageNo OF {nb})", 0, "C", 0, 1);
$this->MultiCell($itemColwidth, 0, "ITEM\nNO.", 1, "C", 1, 0);
$heightNeeded = $this->getLastH();
/**
* @todo this seems like a cleaner way of doing it than I did in the detailsBox(). Revise at some point
*/
$this->MultiCell($qtyColwidth, $heightNeeded, "QTY", 1, "C", 1, 0);
$this->MultiCell($descColwidth, $heightNeeded, "DESCRIPTION", 1, "C", 1, 0);
$this->MultiCell($unitpriceColwidth, $heightNeeded, "UNIT\nPRICE", 1, "C", 1, 0);
$this->MultiCell($totalPricColwidth, $heightNeeded, "TOTAL\nPRICE", 1, "C", 1, 1);
//Header Line 2
$this->MultiCell($itemColwidth, 0, "", 1, "C", 1, 0);
$heightNeeded = $this->getLastH();
$this->MultiCell($qtyColwidth, $heightNeeded, "", 1, "C", 1, 0);
$this->MultiCell($descColwidth, $heightNeeded, $principleName, 1, "C", 1, 0);
$this->MultiCell($unitpriceColwidth, $heightNeeded, $currency, 1, "C", 1, 0);
$this->MultiCell($totalPricColwidth, $heightNeeded, $currency, 1, "C", 1, 1);
foreach ($products as $product) {
//Need to use the getNumLines method to figure out how big to make the cells before the description cell
$fullDesc = $product[$docType]['title'].'<br>'.$product[$docType]['description'];
$linesNeeded = $this->getNumLines($fullDesc, $descColwidth);
$this->MultiCell($itemColwidth, $linesNeeded*$lineHeight, number_format($product[$docType]['item_number'], 1, '.', ''), 1, "C", 0, 0);
$this->MultiCell($qtyColwidth, $linesNeeded*$lineHeight, $product[$docType]['quantity'], 1, "C", 0, 0);
$quoteProduct['QuoteProduct']['item_number'];
$this->MultiCell($descColwidth, $linesNeeded*$lineHeight, $fullDesc, 1, "L", 0, 0, null, null, true, 0, true);
$this->MultiCell($unitpriceColwidth, $linesNeeded*$lineHeight, "$1000", 1, "C", 0, 0);
$this->MultiCell($totalPricColwidth, $linesNeeded*$lineHeight, "$2000", 1, "C", 0, 1);
}
function productPage() {

77
views/costings/add.ctp Normal file
View file

@ -0,0 +1,77 @@
<div class="costings form">
<?php echo $form->create('Costing');?>
<fieldset>
<legend><?php __('Add Costing');?></legend>
<?php
echo $form->input('product_id');
echo $form->input('quote_product_id');
echo $form->input('order_product_id');
echo $form->input('invoice_product_id');
echo $form->input('purchase_currency_id');
echo $form->input('sale_currency_id');
echo $form->input('quantity');
echo $form->input('unit_cost_price');
echo $form->input('exchange_rate');
echo $form->input('our_discount_percent');
echo $form->input('packing');
echo '<div class="input text">';
echo $form->label('fob_country_of_export', 'F.O.B Country of Export');
echo $form->text('fob_country_of_export', array('readonly'=>'readonly', 'id'=>'fob_country_of_export'));
echo '</div>';
echo '<div class="input text">';
echo $form->label('convert_to_aud', 'Convert to A$');
echo $form->text('convert_to_aud', array('readonly'=>'readonly', 'id'=>'convert_to_aud'));
echo '</div>';
echo $form->input('shipping_weight');
echo $form->input('shipping_cost');
echo $form->input('duty_percent');
echo $form->input('customs');
echo $form->input('finance_percent', array('after'=>'<p id="financeamount"> </p>'));
echo $form->input('misc_costs');
echo $form->input('gross_sell_price');
echo $form->input('sale_discount_percent');
echo $form->input('net_sell_price');
echo '<div class="input text">';
echo $form->label('total_landed_cost', 'Total Landed Cost');
echo $form->text('total_landed_cost', array('readonly'=>'readonly', 'id'=>'total_landed_cost'));
echo '</div>';
echo $form->input('sellprice_each', array('label' => 'Sell Price Each', 'id'=>'sellprice_each'));
echo '<div class="input text">';
echo $form->label('gross_profit_dollars', 'Gross Profit $');
echo $form->text('gross_profit_dollars', array('readonly'=>'readonly', 'id'=>'gross_profit_dollars'));
echo '</div>';
echo '<div class="input text">';
echo $form->label('gross_profit_percent', 'Gross Profit %');
echo $form->text('gross_profit_prercent', array('readonly'=>'readonly', 'id'=>'gross_profit_percent'));
echo '</div>';
//echo $ajax->observeForm('CostingAddForm', array('frequency' => 0.5, 'complete'=>'buildup()'));
?>
</fieldset>
<?php echo $form->end('Submit');?>
<?php echo $javascript->link('quotenik/add_costing', true); ?>
</div>
<div class="actions">
<ul>
<li><?php echo $html->link(__('List Costings', true), array('action' => 'index'));?></li>
<li><?php echo $html->link(__('List Products', true), array('controller' => 'products', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Product', true), array('controller' => 'products', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Quote Products', true), array('controller' => 'quote_products', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Quote Product', true), array('controller' => 'quote_products', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Purchase Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?> </li>
</ul>
</div>

42
views/costings/edit.ctp Normal file
View file

@ -0,0 +1,42 @@
<div class="costings form">
<?php echo $form->create('Costing');?>
<fieldset>
<legend><?php __('Edit Costing');?></legend>
<?php
echo $form->input('id');
echo $form->input('product_id');
echo $form->input('quote_product_id');
echo $form->input('order_product_id');
echo $form->input('invoice_product_id');
echo $form->input('purchase_currency_id');
echo $form->input('sale_currency_id');
echo $form->input('quantity');
echo $form->input('unit_cost_price');
echo $form->input('exchange_rate');
echo $form->input('our_discount_percent');
echo $form->input('packing');
echo $form->input('shipping_weight');
echo $form->input('shipping_cost');
echo $form->input('duty_percent');
echo $form->input('customs');
echo $form->input('finance_percent');
echo $form->input('misc_costs');
echo $form->input('gross_sell_price');
echo $form->input('sale_discount_percent');
echo $form->input('net_sell_price');
?>
</fieldset>
<?php echo $form->end('Submit');?>
</div>
<div class="actions">
<ul>
<li><?php echo $html->link(__('Delete', true), array('action' => 'delete', $form->value('Costing.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('Costing.id'))); ?></li>
<li><?php echo $html->link(__('List Costings', true), array('action' => 'index'));?></li>
<li><?php echo $html->link(__('List Products', true), array('controller' => 'products', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Product', true), array('controller' => 'products', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Quote Products', true), array('controller' => 'quote_products', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Quote Product', true), array('controller' => 'quote_products', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Purchase Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?> </li>
</ul>
</div>

134
views/costings/index.ctp Normal file
View file

@ -0,0 +1,134 @@
<div class="costings index">
<h2><?php __('Costings');?></h2>
<p>
<?php
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
<table cellpadding="0" cellspacing="0">
<tr>
<th><?php echo $paginator->sort('id');?></th>
<th><?php echo $paginator->sort('created');?></th>
<th><?php echo $paginator->sort('product_id');?></th>
<th><?php echo $paginator->sort('quote_product_id');?></th>
<th><?php echo $paginator->sort('order_product_id');?></th>
<th><?php echo $paginator->sort('invoice_product_id');?></th>
<th><?php echo $paginator->sort('purchase_currency_id');?></th>
<th><?php echo $paginator->sort('sale_currency_id');?></th>
<th><?php echo $paginator->sort('quantity');?></th>
<th><?php echo $paginator->sort('unit_cost_price');?></th>
<th><?php echo $paginator->sort('exchange_rate');?></th>
<th><?php echo $paginator->sort('our_discount_percent');?></th>
<th><?php echo $paginator->sort('packing');?></th>
<th><?php echo $paginator->sort('shipping_weight');?></th>
<th><?php echo $paginator->sort('shipping_cost');?></th>
<th><?php echo $paginator->sort('duty_percent');?></th>
<th><?php echo $paginator->sort('customs');?></th>
<th><?php echo $paginator->sort('finance_percent');?></th>
<th><?php echo $paginator->sort('misc_costs');?></th>
<th><?php echo $paginator->sort('gross_sell_price');?></th>
<th><?php echo $paginator->sort('sale_discount_percent');?></th>
<th><?php echo $paginator->sort('net_sell_price');?></th>
<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
$i = 0;
foreach ($costings as $costing):
$class = null;
if ($i++ % 2 == 0) {
$class = ' class="altrow"';
}
?>
<tr<?php echo $class;?>>
<td>
<?php echo $costing['Costing']['id']; ?>
</td>
<td>
<?php echo $costing['Costing']['created']; ?>
</td>
<td>
<?php echo $html->link($costing['Product']['title'], array('controller' => 'products', 'action' => 'view', $costing['Product']['id'])); ?>
</td>
<td>
<?php echo $html->link($costing['QuoteProduct']['title'], array('controller' => 'quote_products', 'action' => 'view', $costing['QuoteProduct']['id'])); ?>
</td>
<td>
<?php echo $costing['Costing']['order_product_id']; ?>
</td>
<td>
<?php echo $costing['Costing']['invoice_product_id']; ?>
</td>
<td>
<?php echo $html->link($costing['PurchaseCurrency']['name'], array('controller' => 'currencies', 'action' => 'view', $costing['PurchaseCurrency']['id'])); ?>
</td>
<td>
<?php echo $html->link($costing['SaleCurrency']['name'], array('controller' => 'currencies', 'action' => 'view', $costing['SaleCurrency']['id'])); ?>
</td>
<td>
<?php echo $costing['Costing']['quantity']; ?>
</td>
<td>
<?php echo $costing['Costing']['unit_cost_price']; ?>
</td>
<td>
<?php echo $costing['Costing']['exchange_rate']; ?>
</td>
<td>
<?php echo $costing['Costing']['our_discount_percent']; ?>
</td>
<td>
<?php echo $costing['Costing']['packing']; ?>
</td>
<td>
<?php echo $costing['Costing']['shipping_weight']; ?>
</td>
<td>
<?php echo $costing['Costing']['shipping_cost']; ?>
</td>
<td>
<?php echo $costing['Costing']['duty_percent']; ?>
</td>
<td>
<?php echo $costing['Costing']['customs']; ?>
</td>
<td>
<?php echo $costing['Costing']['finance_percent']; ?>
</td>
<td>
<?php echo $costing['Costing']['misc_costs']; ?>
</td>
<td>
<?php echo $costing['Costing']['gross_sell_price']; ?>
</td>
<td>
<?php echo $costing['Costing']['sale_discount_percent']; ?>
</td>
<td>
<?php echo $costing['Costing']['net_sell_price']; ?>
</td>
<td class="actions">
<?php echo $html->link(__('View', true), array('action' => 'view', $costing['Costing']['id'])); ?>
<?php echo $html->link(__('Edit', true), array('action' => 'edit', $costing['Costing']['id'])); ?>
<?php echo $html->link(__('Delete', true), array('action' => 'delete', $costing['Costing']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $costing['Costing']['id'])); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
<div class="paging">
<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
| <?php echo $paginator->numbers();?>
<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
</div>
<div class="actions">
<ul>
<li><?php echo $html->link(__('New Costing', true), array('action' => 'add')); ?></li>
<li><?php echo $html->link(__('List Products', true), array('controller' => 'products', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Product', true), array('controller' => 'products', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Quote Products', true), array('controller' => 'quote_products', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Quote Product', true), array('controller' => 'quote_products', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Purchase Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?> </li>
</ul>
</div>

129
views/costings/view.ctp Normal file
View file

@ -0,0 +1,129 @@
<div class="costings view">
<h2><?php __('Costing');?></h2>
<dl><?php $i = 0; $class = ' class="altrow"';?>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Id'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $costing['Costing']['id']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Created'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $costing['Costing']['created']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Product'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($costing['Product']['title'], array('controller' => 'products', 'action' => 'view', $costing['Product']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Quote Product'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($costing['QuoteProduct']['title'], array('controller' => 'quote_products', 'action' => 'view', $costing['QuoteProduct']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Order Product Id'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $costing['Costing']['order_product_id']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Invoice Product Id'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $costing['Costing']['invoice_product_id']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Purchase Currency'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($costing['PurchaseCurrency']['name'], array('controller' => 'currencies', 'action' => 'view', $costing['PurchaseCurrency']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Sale Currency'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($costing['SaleCurrency']['name'], array('controller' => 'currencies', 'action' => 'view', $costing['SaleCurrency']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Quantity'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $costing['Costing']['quantity']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Unit Cost Price'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $costing['Costing']['unit_cost_price']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Exchange Rate'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $costing['Costing']['exchange_rate']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Our Discount Percent'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $costing['Costing']['our_discount_percent']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Packing'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $costing['Costing']['packing']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Shipping Weight'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $costing['Costing']['shipping_weight']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Shipping Cost'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $costing['Costing']['shipping_cost']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Duty Percent'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $costing['Costing']['duty_percent']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Customs'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $costing['Costing']['customs']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Finance Percent'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $costing['Costing']['finance_percent']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Misc Costs'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $costing['Costing']['misc_costs']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Gross Sell Price'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $costing['Costing']['gross_sell_price']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Sale Discount Percent'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $costing['Costing']['sale_discount_percent']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Net Sell Price'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $costing['Costing']['net_sell_price']; ?>
&nbsp;
</dd>
</dl>
</div>
<div class="actions">
<ul>
<li><?php echo $html->link(__('Edit Costing', true), array('action' => 'edit', $costing['Costing']['id'])); ?> </li>
<li><?php echo $html->link(__('Delete Costing', true), array('action' => 'delete', $costing['Costing']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $costing['Costing']['id'])); ?> </li>
<li><?php echo $html->link(__('List Costings', true), array('action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Costing', true), array('action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Products', true), array('controller' => 'products', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Product', true), array('controller' => 'products', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Quote Products', true), array('controller' => 'quote_products', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Quote Product', true), array('controller' => 'quote_products', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Purchase Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?> </li>
</ul>
</div>

View file

@ -2,7 +2,9 @@
<table cellpadding = "0" cellspacing = "0" class="quotetable"> <table cellpadding = "0" cellspacing = "0" class="quotetable">
<tr> <tr>
<th><?php __('Revision'); ?></th> <th><?php __('Revision'); ?></th>
<th><?php __('Created'); ?></th> <th><?php __('Sale Currency'); ?></th>
<th><?php __('Date / Time Created'); ?></th>
<th class="actions"><?php __('Actions');?></th> <th class="actions"><?php __('Actions');?></th>
</tr> </tr>
<?php <?php
@ -20,9 +22,13 @@
?> ?>
<tr<?php echo $class;?>> <tr<?php echo $class;?>>
<td><?php echo $quote['Quote']['revision'];?></td> <td><?php echo $quote['Quote']['revision'];?></td>
<td><?php echo $quote['Currency']['iso4217'];?></td>
<td><?php echo $time->nice($quote['Quote']['created']);?></td> <td><?php echo $time->nice($quote['Quote']['created']);?></td>
<td class="actions"> <td class="actions">
<?php echo $html->link(__('View', true), array('controller'=> 'quotes', 'action'=>'view', $quote['Quote']['id'])); ?> <?php echo $html->link(__('View', true), array('controller'=> 'quotes', 'action'=>'view', $quote['Quote']['id'])); ?>
<?php echo $html->link(__('Edit', true), array('controller'=>'quotes', 'action'=>'edit', $quote['Quote']['id'])); ?>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>

View file

@ -136,3 +136,6 @@ $boxdata['enquirynumber'] = $enquiry['Enquiry']['title'];
<h3><?php __($number_of_quotes.' Quotes in this Enquiry');?></h3> <h3><?php __($number_of_quotes.' Quotes in this Enquiry');?></h3>
<?php echo $this->element('quote_table', $quotes); ?> <?php echo $this->element('quote_table', $quotes); ?>
</div> </div>
<?php debug($quotes); ?>

View file

@ -35,6 +35,8 @@
echo $ajax->divEnd('productoptions'); echo $ajax->divEnd('productoptions');
echo $form->input('unit_price');
//echo '<div id="productoptions"></div>'; //echo '<div id="productoptions"></div>';
//echo $form->select('QuoteProduct.product_id', null, null, array('id'=>'products')); //echo $form->select('QuoteProduct.product_id', null, null, array('id'=>'products'));
//*/ //*/

View file

@ -14,10 +14,11 @@
echo $form->input('enquiry_id', array('type'=>'hidden', 'value' => $enquiry['Enquiry']['id'])); echo $form->input('enquiry_id', array('type'=>'hidden', 'value' => $enquiry['Enquiry']['id']));
echo $form->input('delivery_time'); echo $form->input('delivery_time');
echo $form->input('payment_terms'); echo $this->element('payment_terms_box');
echo $form->input('date_issued'); echo $form->input('date_issued');
echo $form->input('days_valid'); echo $form->input('days_valid');
echo $form->input('valid_until'); echo $form->input('valid_until');
echo $form->input('currency_id', array('label' => 'Sale Currency'));
?> ?>
</fieldset> </fieldset>
<?php echo $form->end('Submit');?> <?php echo $form->end('Submit');?>

View file

@ -85,11 +85,14 @@ foreach ($quote['QuotePage'] as $page) {
} }
$tcpdf->AddPage();
print_r($products);
$principle_name = strtoupper($enquiry['Principle']['name']);
$tcpdf->productPage($principle_name, $quote['Currency']['iso4217'], $products, 'QuoteProduct');
//DetailsBox($companyName, $emailTo, $attention, $fromName, $fromEmail, $enquiryNumber)
$tcpdf->AliasNbPages(); $tcpdf->AliasNbPages();

View file

@ -65,12 +65,19 @@ foreach ($quote['QuotePage'] as $quotePage):
<th><?php __('Quantity'); ?></th> <th><?php __('Quantity'); ?></th>
<th><?php __('Title'); ?></th> <th><?php __('Title'); ?></th>
<th><?php __('Description'); ?></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> <th class="actions"><?php __('Actions');?></th>
</tr> </tr>
<?php <?php
$i = 0; $i = 0;
$subTotal = 0;
foreach ($quoteProducts as $quoteProduct): foreach ($quoteProducts as $quoteProduct):
$class = null; $class = null;
if ($i++ % 2 == 0) { if ($i++ % 2 == 0) {
@ -88,6 +95,14 @@ 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><?php echo $quoteProduct['QuoteProduct']['description'];?></td>
<td><?php echo $quote['Currency']['symbol'].$quoteProduct['QuoteProduct']['unit_price'];?></td>
<td><?php
$thisNetPrice = $quoteProduct['QuoteProduct']['unit_price']*$quoteProduct['QuoteProduct']['quantity'];
$subTotal += $thisNetPrice;
echo $quote['Currency']['symbol'].$thisNetPrice; ?></td>
<td class="actions"> <td class="actions">
<?php echo $html->link(__('View', true), array('controller'=> 'quote_products', 'action'=>'view', $quoteProduct['QuoteProduct']['id'])); ?> <?php echo $html->link(__('View', true), array('controller'=> 'quote_products', 'action'=>'view', $quoteProduct['QuoteProduct']['id'])); ?>
@ -98,6 +113,59 @@ foreach ($quote['QuotePage'] as $quotePage):
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
<tr class="divider">
<td></td>
<td></td>
<td></td>
<td>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>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>TOTAL PAYABLE</td>
<td></td>
<td><?php
$total = $subTotal + $gst;
echo $quote['Currency']['symbol'].$total;
?>
</td>
<td></td>
</tr>
</tr>
</table> </table>
<?php endif; ?> <?php endif; ?>

View file

@ -380,6 +380,11 @@ table tr.customer-customer td {
background: #63D463; background: #63D463;
} }
table tr.divider td {
border-top: 2px solid black;
}
td.actions { td.actions {
text-align: center; text-align: center;
white-space: nowrap; white-space: nowrap;
@ -387,6 +392,13 @@ td.actions {
td.actions a { td.actions a {
margin: 0px 6px; margin: 0px 6px;
} }
td.PriceSummary {
background: #ff9900;
}
.cake-sql-log table { .cake-sql-log table {
background: #f4f4f4; background: #f4f4f4;
} }
@ -534,7 +546,7 @@ table.productoptions tr.defaultoption {
} }
table.quoteproducts { table.quoteproducts {
width: 50%; width: 70%;
} }

View file

@ -1,12 +1,13 @@
function buildup() { function buildup() {
//Fetch all the relevent inputs from the form //Fetch all the relevent inputs from the form
quantity = +($F('CostingQuantity')); quantity = +($F('CostingQuantity'));
costprice = +($F('CostingUnitCostPrice')); costprice = +($F('CostingUnitCostPrice'));
ourdiscount_percentage = +($F('OurDiscountPercent')); ourdiscount_percentage = +($F('CostingOurDiscountPercent'));
packing_each = +($F('CostingPacking')); packing_each = +($F('CostingPacking'));
exchange_rate = +($F('CostingExchangeRate')); exchange_rate = +($F('CostingExchangeRate'));
shipping_cost = +($F('CostingShippingCost')); shipping_cost = +($F('CostingShippingCost'));
@ -31,7 +32,7 @@ net_foreign_price = costprice - discountamount;
total_foreign_price = net_foreign_price + packing_each; total_foreign_price = net_foreign_price + packing_each;
$('fob_country_of_export').value = total_foreign_price; $F('CostingFobCountryOfExport').value = total_foreign_price;
domestic_cost = total_foreign_price / exchange_rate; domestic_cost = total_foreign_price / exchange_rate;
$('convert_to_aud').value = domestic_cost.toFixed(2); $('convert_to_aud').value = domestic_cost.toFixed(2);
dutyamount = (duty / 100) * domestic_cost; dutyamount = (duty / 100) * domestic_cost;
@ -44,9 +45,13 @@ $('financeamount').update('Finance amount: ' + financeamount);
total_landed_cost += (+financeamount); total_landed_cost += (+financeamount);
total_landed_cost = total_landed_cost.toFixed(2); total_landed_cost = total_landed_cost.toFixed(2);
$('total_landed_cost').value = total_landed_cost; $('total_landed_cost').value = total_landed_cost;
gross_profit_dollars = sellprice_each - total_landed_cost gross_profit_dollars = sellprice_each - total_landed_cost;
$('gross_profit_dollars').value = gross_profit_dollars; $('gross_profit_dollars').value = gross_profit_dollars;
$('gross_profit_percent').value = ((gross_profit_dollars / sellprice_each)*100).toFixed(2); $('gross_profit_percent').value = ((gross_profit_dollars / sellprice_each)*100).toFixed(2);
} }
new Form.Observer('CostingAddForm', 0.5, buildup());