diff --git a/controllers/quotes_controller.php b/controllers/quotes_controller.php index 046a70f0..a226a4e1 100755 --- a/controllers/quotes_controller.php +++ b/controllers/quotes_controller.php @@ -38,6 +38,13 @@ class QuotesController extends AppController { $this->data['Quote']['revision'] = $number_of_revisions; $this->data['Quote']['enquiry_id'] = $enquiryid; $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)) { $quoteid = $this->Quote->id; @@ -84,7 +91,8 @@ class QuotesController extends AppController { $this->data = $quote; } $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); //$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('enquiry', $enquiry); + + $this->set('products', $quoteProducts); + // $this->set('customer', $customer); //$this->layout = 'pdf'; //$this->render(); } + } ?> \ No newline at end of file diff --git a/models/quote.php b/models/quote.php index bd0d3a9a..fb7bc848 100755 --- a/models/quote.php +++ b/models/quote.php @@ -18,7 +18,9 @@ class Quote extends AppModel { 'conditions' => '', 'fields' => '', 'order' => '' - ) + ), + + 'Currency' => array('className' => 'Currency', 'foreignKey' => 'currency_id') ); var $hasMany = array( diff --git a/vendors/shells/vault.php b/vendors/shells/vault.php index d1bbb5ee..cdc81626 100755 --- a/vendors/shells/vault.php +++ b/vendors/shells/vault.php @@ -24,7 +24,7 @@ class VaultShell extends Shell { $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); $number_of_messages = $MC->Nmsgs; diff --git a/vendors/xtcpdf.php b/vendors/xtcpdf.php index c035e24c..c7426702 100755 --- a/vendors/xtcpdf.php +++ b/vendors/xtcpdf.php @@ -1,8 +1,7 @@ xheadertext = 'YOUR ORGANIZATION'; - * set the fill color in the view using - * $fpdf->xheadercolor = array(0,0,100); (r, g, b) - * set the font in the view using - * $fpdf->setHeaderFont(array('YourFont','',fontsize)); - */ - function Page1Header() - { + * Overwrites the default header + * set the text in the view using + * $fpdf->xheadertext = 'YOUR ORGANIZATION'; + * set the fill color in the view using + * $fpdf->xheadercolor = array(0,0,100); (r, g, b) + * set the font in the view using + * $fpdf->setHeaderFont(array('YourFont','',fontsize)); + */ + function Page1Header() { list($r, $b, $g) = $this->xheadercolor; //$this->setY(10); // shouldn't be needed due to page margin, but helas, otherwise it's at the page top - + $this->SetFillColor(255, 255, 255); $this->SetTextColor(0 , 0, 152); //Set the Text Color to Blue - - // $this->Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $ismask, $imgmask, $border, $fitbox, $hidden) + + // $this->Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $ismask, $imgmask, $border, $fitbox, $hidden) $this->Image(K_PATH_IMAGES.'cmclogosmall.jpg', 10, 10, 30, 0, null, 'http://www.cmctechnologies.com.au', null, false, null, 'L'); $this->Cell(30); @@ -44,11 +42,11 @@ class XTCPDF extends TCPDF $this->SetY(22); $this->Cell(30); $this->Cell(0,0, "PTY LIMITED ACN: 47 085 991 224 ABN: 47 085 991 224", 0, 1, 'C', 1); - - - $this->Rect($this->GetX()+33, $this->GetY()+2, 157, 2, 'DF', array('width'=>0), array(0, 0, 0)); + + + $this->Rect($this->GetX()+33, $this->GetY()+2, 157, 2, 'DF', array('width'=>0), array(0, 0, 0)); /* Start the contact details */ - $this->SetTextColor(0); //Set the Text Color to Black + $this->SetTextColor(0); //Set the Text Color to Black $this->MultiCell(18, 0, "Phone:\nFax:\nEmail:\nWeb Site:\n", 0, 'L', 0, 0, 45, 32); @@ -61,19 +59,18 @@ class XTCPDF extends TCPDF $this->SetTextColor(0 , 0, 152); //Set the Text Color to Blue $this->SetFont('times', 'B'); $this->MultiCell(30, 20, "Engineering &\nIndustrial\nInstrumentation", 0, 'L', 0, 1, 10,37); - + } /** - * Overwrites the default footer - * set the text in the view using - * $fpdf->xfootertext = 'Copyright © %d YOUR ORGANIZATION. All rights reserved.'; - */ - function Page1Footer() - { + * Overwrites the default footer + * set the text in the view using + * $fpdf->xfootertext = 'Copyright © %d YOUR ORGANIZATION. All rights reserved.'; + */ + function Page1Footer() { $this->SetY(-20); $this->Image(K_PATH_IMAGES.'cmcfooter.jpg', null, 255, 200, 0, null, 'http://www.cmctechnologies.com.au', null, false, null, 'C'); } @@ -85,84 +82,62 @@ class XTCPDF extends TCPDF $this->SetTextColor(0); //Black Text - $boxYstart = 45; - $boxXstart = 10; - $firstColWidth = 40; - $secondColWidth = 70; - $thirdColWidth = 30; - $fourthColWidth = -10; + $boxYstart = 45; + $boxXstart = 10; + $firstColWidth = 40; + $secondColWidth = 70; + $thirdColWidth = 30; + $fourthColWidth = -10; - $pageNo = $this->PageNoFormatted(); - //$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"; - */ + $pageNo = $this->PageNoFormatted(); + //$pageOf = $this->getAliasNbPages(); - $this->SetXY($boxXstart, 55); - - $heightNeeded = $this->getNumLines($companyName, $secondColWidth); - echo "Height needed: $heightNeeded"; - - $lineHeight = 6.40997; //Size of a single line of text. If the company name is more, multiply this by the number of lines it needs. - - // $lineHeight = 0; - - // $this->MultiCell($w, $h, $txt, $border, $align, $fill, $ln, $x, $y, $reseth, $stretch, $ishtml); - - - $this->MultiCell($firstColWidth, $lineHeight*$heightNeeded, "QUOTATION TO:", 'LTR', 'L', 0, 0); - $this->MultiCell($secondColWidth, $lineHeight*$heightNeeded, $companyName, 'LTR', 'L', 0, 0); - - $this->MultiCell($thirdColWidth, $lineHeight*$heightNeeded, "FROM:", 'LT', 'L', 0, 0); - $this->MultiCell($fourthColWidth, $lineHeight*$heightNeeded, "$fromName", 'TR', 'L', 0, 1, null,null, true,0,true); //Start a new line after this. - // echo "Last height: ".$this->getLastH(); - - $this->MultiCell($firstColWidth, 0, "EMAIL TO:", 'LR', 'L', 0, 0); - $this->MultiCell($secondColWidth, 0, "$emailTo", 'LR','L', 0, 0, null, null, true, 0, true); - $this->MultiCell($thirdColWidth, 0, "CMC REF#:", 'L', 'L', 0, 0); - $this->MultiCell($fourthColWidth, 0, $enquiryNumber, 'R', 'L', 0, 1); //Start a new line after thi - - $this->MultiCell($firstColWidth, 0, "ATTENTION:", 'LRB', 'L', 0, 0); - $this->MultiCell($secondColWidth, 0, $attention, 'LRB', 'L', 0, 0); - $this->MultiCell($thirdColWidth, 0, "PAGE: ", 'LB', 'L', 0, 0); - $this->MultiCell($fourthColWidth, 0, "$pageNo of {nb}", 'BR', 'L', 0, 1); - - - $todaysDateString = date('l, j F Y'); - $this->MultiCell($firstColWidth + $secondColWidth, 0, "DATE: $todaysDateString", 'LRB', 'L', 0, 0); - $this->MultiCell($thirdColWidth, 0, "YOUR REF: ", 'LB', 'L', 0, 0); - $this->MultiCell($fourthColWidth, 0, $your_reference, 'BR', 'L', 0, 1); - $this->SetFontSize(6); + $this->SetXY($boxXstart, 55); - //Kinda lame that I cant seem to wrap this text nicer. But Whatever. - $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' + $heightNeeded = $this->getNumLines($companyName, $secondColWidth); + echo "Height needed: $heightNeeded"; + + $lineHeight = 6.40997; //Size of a single line of text. If the company name is more, multiply this by the number of lines it needs. + + // $lineHeight = 0; + + // $this->MultiCell($w, $h, $txt, $border, $align, $fill, $ln, $x, $y, $reseth, $stretch, $ishtml); + + + $this->MultiCell($firstColWidth, $lineHeight*$heightNeeded, "QUOTATION TO:", 'LTR', 'L', 0, 0); + $this->MultiCell($secondColWidth, $lineHeight*$heightNeeded, $companyName, 'LTR', 'L', 0, 0); + + $this->MultiCell($thirdColWidth, $lineHeight*$heightNeeded, "FROM:", 'LT', 'L', 0, 0); + $this->MultiCell($fourthColWidth, $lineHeight*$heightNeeded, "$fromName", 'TR', 'L', 0, 1, null,null, true,0,true); //Start a new line after this. + // echo "Last height: ".$this->getLastH(); + + $this->MultiCell($firstColWidth, 0, "EMAIL TO:", 'LR', 'L', 0, 0); + $this->MultiCell($secondColWidth, 0, "$emailTo", 'LR','L', 0, 0, null, null, true, 0, true); + $this->MultiCell($thirdColWidth, 0, "CMC REF#:", 'L', 'L', 0, 0); + $this->MultiCell($fourthColWidth, 0, $enquiryNumber, 'R', 'L', 0, 1); //Start a new line after thi + + $this->MultiCell($firstColWidth, 0, "ATTENTION:", 'LRB', 'L', 0, 0); + $this->MultiCell($secondColWidth, 0, $attention, 'LRB', 'L', 0, 0); + $this->MultiCell($thirdColWidth, 0, "PAGE: ", 'LB', 'L', 0, 0); + $this->MultiCell($fourthColWidth, 0, "$pageNo of {nb}", 'BR', 'L', 0, 1); + + + $todaysDateString = date('l, j F Y'); + $this->MultiCell($firstColWidth + $secondColWidth, 0, "DATE: $todaysDateString", 'LRB', 'L', 0, 0); + $this->MultiCell($thirdColWidth, 0, "YOUR REF: ", 'LB', 'L', 0, 0); + + + $this->MultiCell($fourthColWidth, 0, $your_reference, 'BR', 'L', 0, 1); + $this->SetFontSize(6); + + //Kinda lame that I cant seem to wrap this text nicer. But Whatever. + $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' ); -/* - * - * - $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) } @@ -171,15 +146,92 @@ class XTCPDF extends TCPDF $this->SetFontSize(10); $pageNo = $this->PageNoFormatted(); $this->MultiCell(0,13.6, "$cmcRef PAGE $pageNo OF {nb}", '', 'R'); - //$this->MultiCell($w, $h, $txt, $border, $align, $fill, $ln, $x, $y, $reseth, $stretch, $ishtml) - //$this->Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi) + //$this->MultiCell($w, $h, $txt, $border, $align, $fill, $ln, $x, $y, $reseth, $stretch, $ishtml) + //$this->Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi) } + /** + * + * @param $principleName + * @param $currency + * @param $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'].'
'.$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() { - } diff --git a/views/costings/add.ctp b/views/costings/add.ctp new file mode 100644 index 00000000..391f1805 --- /dev/null +++ b/views/costings/add.ctp @@ -0,0 +1,77 @@ +
+ + + +create('Costing');?> +
+ + 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 '
'; + 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 '
'; + + echo '
'; + echo $form->label('convert_to_aud', 'Convert to A$'); + echo $form->text('convert_to_aud', array('readonly'=>'readonly', 'id'=>'convert_to_aud')); + echo '
'; + + + 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'=>'

')); + echo $form->input('misc_costs'); + echo $form->input('gross_sell_price'); + echo $form->input('sale_discount_percent'); + echo $form->input('net_sell_price'); + + echo '
'; + echo $form->label('total_landed_cost', 'Total Landed Cost'); + echo $form->text('total_landed_cost', array('readonly'=>'readonly', 'id'=>'total_landed_cost')); + echo '
'; + echo $form->input('sellprice_each', array('label' => 'Sell Price Each', 'id'=>'sellprice_each')); + echo '
'; + echo $form->label('gross_profit_dollars', 'Gross Profit $'); + echo $form->text('gross_profit_dollars', array('readonly'=>'readonly', 'id'=>'gross_profit_dollars')); + echo '
'; + echo '
'; + echo $form->label('gross_profit_percent', 'Gross Profit %'); + echo $form->text('gross_profit_prercent', array('readonly'=>'readonly', 'id'=>'gross_profit_percent')); + echo '
'; + + + //echo $ajax->observeForm('CostingAddForm', array('frequency' => 0.5, 'complete'=>'buildup()')); + + + ?> +
+end('Submit');?> + + link('quotenik/add_costing', true); ?> + +
+
+
    +
  • link(__('List Costings', true), array('action' => 'index'));?>
  • +
  • link(__('List Products', true), array('controller' => 'products', 'action' => 'index')); ?>
  • +
  • link(__('New Product', true), array('controller' => 'products', 'action' => 'add')); ?>
  • +
  • link(__('List Quote Products', true), array('controller' => 'quote_products', 'action' => 'index')); ?>
  • +
  • link(__('New Quote Product', true), array('controller' => 'quote_products', 'action' => 'add')); ?>
  • +
  • link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?>
  • +
  • link(__('New Purchase Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?>
  • +
+
diff --git a/views/costings/edit.ctp b/views/costings/edit.ctp new file mode 100644 index 00000000..bf207890 --- /dev/null +++ b/views/costings/edit.ctp @@ -0,0 +1,42 @@ +
+create('Costing');?> +
+ + 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'); + ?> +
+end('Submit');?> +
+
+
    +
  • 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'))); ?>
  • +
  • link(__('List Costings', true), array('action' => 'index'));?>
  • +
  • link(__('List Products', true), array('controller' => 'products', 'action' => 'index')); ?>
  • +
  • link(__('New Product', true), array('controller' => 'products', 'action' => 'add')); ?>
  • +
  • link(__('List Quote Products', true), array('controller' => 'quote_products', 'action' => 'index')); ?>
  • +
  • link(__('New Quote Product', true), array('controller' => 'quote_products', 'action' => 'add')); ?>
  • +
  • link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?>
  • +
  • link(__('New Purchase Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?>
  • +
+
diff --git a/views/costings/index.ctp b/views/costings/index.ctp new file mode 100644 index 00000000..d7c67ab3 --- /dev/null +++ b/views/costings/index.ctp @@ -0,0 +1,134 @@ +
+

+

+counter(array( +'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true) +)); +?>

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + > + + + + + + + + + + + + + + + + + + + + + + + + + +
sort('id');?>sort('created');?>sort('product_id');?>sort('quote_product_id');?>sort('order_product_id');?>sort('invoice_product_id');?>sort('purchase_currency_id');?>sort('sale_currency_id');?>sort('quantity');?>sort('unit_cost_price');?>sort('exchange_rate');?>sort('our_discount_percent');?>sort('packing');?>sort('shipping_weight');?>sort('shipping_cost');?>sort('duty_percent');?>sort('customs');?>sort('finance_percent');?>sort('misc_costs');?>sort('gross_sell_price');?>sort('sale_discount_percent');?>sort('net_sell_price');?>
+ + + + + link($costing['Product']['title'], array('controller' => 'products', 'action' => 'view', $costing['Product']['id'])); ?> + + link($costing['QuoteProduct']['title'], array('controller' => 'quote_products', 'action' => 'view', $costing['QuoteProduct']['id'])); ?> + + + + + + link($costing['PurchaseCurrency']['name'], array('controller' => 'currencies', 'action' => 'view', $costing['PurchaseCurrency']['id'])); ?> + + link($costing['SaleCurrency']['name'], array('controller' => 'currencies', 'action' => 'view', $costing['SaleCurrency']['id'])); ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + link(__('View', true), array('action' => 'view', $costing['Costing']['id'])); ?> + link(__('Edit', true), array('action' => 'edit', $costing['Costing']['id'])); ?> + link(__('Delete', true), array('action' => 'delete', $costing['Costing']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $costing['Costing']['id'])); ?> +
+
+
+ prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?> + | numbers();?> + next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?> +
+
+
    +
  • link(__('New Costing', true), array('action' => 'add')); ?>
  • +
  • link(__('List Products', true), array('controller' => 'products', 'action' => 'index')); ?>
  • +
  • link(__('New Product', true), array('controller' => 'products', 'action' => 'add')); ?>
  • +
  • link(__('List Quote Products', true), array('controller' => 'quote_products', 'action' => 'index')); ?>
  • +
  • link(__('New Quote Product', true), array('controller' => 'quote_products', 'action' => 'add')); ?>
  • +
  • link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?>
  • +
  • link(__('New Purchase Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?>
  • +
+
diff --git a/views/costings/view.ctp b/views/costings/view.ctp new file mode 100644 index 00000000..70b8219d --- /dev/null +++ b/views/costings/view.ctp @@ -0,0 +1,129 @@ +
+

+
+ > + > + +   + + > + > + +   + + > + > + link($costing['Product']['title'], array('controller' => 'products', 'action' => 'view', $costing['Product']['id'])); ?> +   + + > + > + link($costing['QuoteProduct']['title'], array('controller' => 'quote_products', 'action' => 'view', $costing['QuoteProduct']['id'])); ?> +   + + > + > + +   + + > + > + +   + + > + > + link($costing['PurchaseCurrency']['name'], array('controller' => 'currencies', 'action' => 'view', $costing['PurchaseCurrency']['id'])); ?> +   + + > + > + link($costing['SaleCurrency']['name'], array('controller' => 'currencies', 'action' => 'view', $costing['SaleCurrency']['id'])); ?> +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + + > + > + +   + +
+
+
+
    +
  • link(__('Edit Costing', true), array('action' => 'edit', $costing['Costing']['id'])); ?>
  • +
  • link(__('Delete Costing', true), array('action' => 'delete', $costing['Costing']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $costing['Costing']['id'])); ?>
  • +
  • link(__('List Costings', true), array('action' => 'index')); ?>
  • +
  • link(__('New Costing', true), array('action' => 'add')); ?>
  • +
  • link(__('List Products', true), array('controller' => 'products', 'action' => 'index')); ?>
  • +
  • link(__('New Product', true), array('controller' => 'products', 'action' => 'add')); ?>
  • +
  • link(__('List Quote Products', true), array('controller' => 'quote_products', 'action' => 'index')); ?>
  • +
  • link(__('New Quote Product', true), array('controller' => 'quote_products', 'action' => 'add')); ?>
  • +
  • link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?>
  • +
  • link(__('New Purchase Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?>
  • +
+
diff --git a/views/elements/quote_table.ctp b/views/elements/quote_table.ctp index ed2ab838..b2a5ad33 100755 --- a/views/elements/quote_table.ctp +++ b/views/elements/quote_table.ctp @@ -2,7 +2,9 @@ - + + + > + diff --git a/views/enquiries/view.ctp b/views/enquiries/view.ctp index 673bd239..3d920687 100755 --- a/views/enquiries/view.ctp +++ b/views/enquiries/view.ctp @@ -136,3 +136,6 @@ $boxdata['enquirynumber'] = $enquiry['Enquiry']['title'];

element('quote_table', $quotes); ?> + + + \ No newline at end of file diff --git a/views/quote_products/add.ctp b/views/quote_products/add.ctp index 58435c67..7add3153 100755 --- a/views/quote_products/add.ctp +++ b/views/quote_products/add.ctp @@ -35,6 +35,8 @@ echo $ajax->divEnd('productoptions'); + echo $form->input('unit_price'); + //echo '
'; //echo $form->select('QuoteProduct.product_id', null, null, array('id'=>'products')); //*/ diff --git a/views/quotes/edit.ctp b/views/quotes/edit.ctp index b7e56dd3..7c4aabd6 100755 --- a/views/quotes/edit.ctp +++ b/views/quotes/edit.ctp @@ -14,10 +14,11 @@ echo $form->input('enquiry_id', array('type'=>'hidden', 'value' => $enquiry['Enquiry']['id'])); echo $form->input('delivery_time'); - echo $form->input('payment_terms'); + echo $this->element('payment_terms_box'); echo $form->input('date_issued'); echo $form->input('days_valid'); echo $form->input('valid_until'); + echo $form->input('currency_id', array('label' => 'Sale Currency')); ?> end('Submit');?> diff --git a/views/quotes/pdf.ctp b/views/quotes/pdf.ctp index 43b11eec..74aa0314 100755 --- a/views/quotes/pdf.ctp +++ b/views/quotes/pdf.ctp @@ -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(); diff --git a/views/quotes/view.ctp b/views/quotes/view.ctp index 51405d3e..259ce26d 100755 --- a/views/quotes/view.ctp +++ b/views/quotes/view.ctp @@ -11,7 +11,7 @@ __('Quote: '.$enquirynumber_link. ' for '. $customer_link); } else { - __('Quote: '.$enquirynumber_link.' Revision '.$quote['Quote']['revision'].' for'. $customer_link); + __('Quote: '.$enquirynumber_link.' Revision '.$quote['Quote']['revision'].' for '. $customer_link); } ?> @@ -65,12 +65,19 @@ foreach ($quote['QuotePage'] as $quotePage): + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
nice($quote['Quote']['created']);?> - link(__('View', true), array('controller'=> 'quotes', 'action'=>'view', $quote['Quote']['id'])); ?> + + link(__('View', true), array('controller'=> 'quotes', 'action'=>'view', $quote['Quote']['id'])); ?> + link(__('Edit', true), array('controller'=>'quotes', 'action'=>'edit', $quote['Quote']['id'])); ?> +
Unit Price () ()
link(__('View', true), array('controller'=> 'quote_products', 'action'=>'view', $quoteProduct['QuoteProduct']['id'])); ?> @@ -98,6 +113,59 @@ foreach ($quote['QuotePage'] as $quotePage):
SUB-TOTAL (Excluding GST)
GST (10%)
TOTAL PAYABLE +
diff --git a/webroot/css/quotenik.css b/webroot/css/quotenik.css index 1868100b..d46a0777 100755 --- a/webroot/css/quotenik.css +++ b/webroot/css/quotenik.css @@ -380,6 +380,11 @@ table tr.customer-customer td { background: #63D463; } +table tr.divider td { + border-top: 2px solid black; +} + + td.actions { text-align: center; white-space: nowrap; @@ -387,6 +392,13 @@ td.actions { td.actions a { margin: 0px 6px; } + +td.PriceSummary { + + background: #ff9900; + +} + .cake-sql-log table { background: #f4f4f4; } @@ -534,7 +546,7 @@ table.productoptions tr.defaultoption { } table.quoteproducts { - width: 50%; + width: 70%; } diff --git a/webroot/js/quotenik/add_costing.js b/webroot/js/quotenik/add_costing.js index 14581693..4f60316e 100644 --- a/webroot/js/quotenik/add_costing.js +++ b/webroot/js/quotenik/add_costing.js @@ -1,12 +1,13 @@ function buildup() { + //Fetch all the relevent inputs from the form quantity = +($F('CostingQuantity')); costprice = +($F('CostingUnitCostPrice')); -ourdiscount_percentage = +($F('OurDiscountPercent')); +ourdiscount_percentage = +($F('CostingOurDiscountPercent')); packing_each = +($F('CostingPacking')); exchange_rate = +($F('CostingExchangeRate')); shipping_cost = +($F('CostingShippingCost')); @@ -31,7 +32,7 @@ net_foreign_price = costprice - discountamount; 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; $('convert_to_aud').value = domestic_cost.toFixed(2); dutyamount = (duty / 100) * domestic_cost; @@ -44,9 +45,13 @@ $('financeamount').update('Finance amount: ' + financeamount); total_landed_cost += (+financeamount); total_landed_cost = total_landed_cost.toFixed(2); $('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_percent').value = ((gross_profit_dollars / sellprice_each)*100).toFixed(2); } +new Form.Observer('CostingAddForm', 0.5, buildup()); + + +