diff --git a/controllers/costings_controller.php b/controllers/costings_controller.php index 7b5181dc..35a73843 100644 --- a/controllers/costings_controller.php +++ b/controllers/costings_controller.php @@ -1,38 +1,72 @@ Costing->recursive = 0; + $this->set('costings', $this->paginate()); + } + function view($id = null) { + if (!$id) { + $this->Session->setFlash(__('Invalid Costing.', true)); + $this->redirect(array('action'=>'index')); + } + $this->set('costing', $this->Costing->read(null, $id)); + } - function index() { - $this->Costings->recursive = 0; - $this->set('costings', $this->paginate()); - } + function add() { + if (!empty($this->data)) { + $this->Costing->create(); + if ($this->Costing->save($this->data)) { + $this->Session->setFlash(__('The Costing has been saved', true)); + $this->redirect(array('action'=>'index')); + } else { + $this->Session->setFlash(__('The Costing could not be saved. Please, try again.', true)); + } + } + $products = $this->Costing->Product->find('list'); + $quoteProducts = $this->Costing->QuoteProduct->find('list'); + $purchaseCurrencies = $this->Costing->PurchaseCurrency->find('list'); + $saleCurrencies = $this->Costing->SaleCurrency->find('list'); + $this->set(compact('products', 'quoteProducts', 'purchaseCurrencies', 'saleCurrencies')); + } + function edit($id = null) { + if (!$id && empty($this->data)) { + $this->Session->setFlash(__('Invalid Costing', true)); + $this->redirect(array('action'=>'index')); + } + if (!empty($this->data)) { + if ($this->Costing->save($this->data)) { + $this->Session->setFlash(__('The Costing has been saved', true)); + $this->redirect(array('action'=>'index')); + } else { + $this->Session->setFlash(__('The Costing could not be saved. Please, try again.', true)); + } + } + if (empty($this->data)) { + $this->data = $this->Costing->read(null, $id); + } + $products = $this->Costing->Product->find('list'); + $quoteProducts = $this->Costing->QuoteProduct->find('list'); + $purchaseCurrencies = $this->Costing->PurchaseCurrency->find('list'); + $saleCurrencies = $this->Costing->SaleCurrency->find('list'); + $this->set(compact('products','quoteProducts','purchaseCurrencies','saleCurrencies')); + } - - /** - * Add a costing to a product. It's either being added to a product, quote_product etc. - * - * - * @param int $id - * @param string $target - */ - function add($id, $target) { - - if (!$id && empty($this->data)) { - $this->Session->setFlash(__('Invalid Quote ID', true)); - $this->redirect(array('action'=>'index')); - } - - - } - + function delete($id = null) { + if (!$id) { + $this->Session->setFlash(__('Invalid id for Costing', true)); + $this->redirect(array('action'=>'index')); + } + if ($this->Costing->del($id)) { + $this->Session->setFlash(__('Costing deleted', true)); + $this->redirect(array('action'=>'index')); + } + } } - -?> +?> \ No newline at end of file diff --git a/controllers/quote_pages_controller.php b/controllers/quote_pages_controller.php index 2478faaf..198a0416 100755 --- a/controllers/quote_pages_controller.php +++ b/controllers/quote_pages_controller.php @@ -1,103 +1,211 @@ QuotePage->recursive = 0; - $this->set('quotePages', $this->paginate()); - } + function index() { + $this->QuotePage->recursive = 0; + $this->set('quotePages', $this->paginate()); + } - function view($id = null) { - if (!$id) { - $this->Session->setFlash(__('Invalid QuotePage.', true)); - $this->redirect(array('action'=>'index')); - } - $this->set('quotePage', $this->QuotePage->read(null, $id)); - } + function view($id = null) { + if (!$id) { + $this->Session->setFlash(__('Invalid QuotePage.', true)); + $this->redirect(array('action'=>'index')); + } + $this->set('quotePage', $this->QuotePage->read(null, $id)); + } - function add($id = null) { + function add($id = null) { - if (!$id && empty($this->data)) { - $this->Session->setFlash(__('Invalid Quote ID', true)); - $this->redirect(array('controller' => 'quotes', 'action'=>'index')); - } + if (!$id && empty($this->data)) { + $this->Session->setFlash(__('Invalid Quote ID', true)); + $this->redirect(array('controller' => 'quotes', 'action'=>'index')); + } - - if (!empty($this->data)) { - $this->QuotePage->create(); - if ($this->QuotePage->save($this->data)) { - $this->Session->setFlash(__('The Quote Page has been saved', true)); - $this->redirect(array('controller'=>'quotes', 'action'=>'view/'.$this->data['QuotePage']['quote_id'])); - } else { - $this->Session->setFlash(__('The Quote Page could not be saved. Please, try again.', true)); - } - } - $quotes = $this->QuotePage->Quote->find('list'); - $this->set(compact('quotes')); - $this->set('quoteid', $id); - $number_of_pages = $this->QuotePage->find('count', array('conditions' => array('QuotePage.quote_id'=>$id))); - $number_of_pages++; - $this->set('pagenumber', $number_of_pages); - } - function edit($id = null) { - - if (!$id && empty($this->data)) { - $this->Session->setFlash(__('Invalid QuotePage', true)); - $this->redirect(array('action'=>'index')); - } + if (!empty($this->data)) { + $this->QuotePage->create(); + if ($this->QuotePage->save($this->data)) { + $this->Session->setFlash(__('The Quote Page has been saved', true)); + $this->redirect(array('controller'=>'quotes', 'action'=>'view/'.$this->data['QuotePage']['quote_id'])); + } else { + $this->Session->setFlash(__('The Quote Page could not be saved. Please, try again.', true)); + } + } + $quotes = $this->QuotePage->Quote->find('list'); + $this->set(compact('quotes')); + $this->set('quoteid', $id); + $number_of_pages = $this->QuotePage->find('count', array('conditions' => array('QuotePage.quote_id'=>$id))); + $number_of_pages++; + $this->set('pagenumber', $number_of_pages); + } - if (!empty($this->data)) { - if ($this->QuotePage->save($this->data)) { - $this->Session->setFlash(__('The QuotePage has been saved', true)); - $id = $this->data['QuotePage']['quote_id']; - $this->redirect(array('controller' => 'quotes', 'action'=>'view/'.$id)); - } else { - $this->Session->setFlash(__('The QuotePage could not be saved. Please, try again.', true)); - } - } - if (empty($this->data)) { - $this->data = $this->QuotePage->read(null, $id); - $this->set('content', $this->data['QuotePage']['content']); - } - $quotes = $this->QuotePage->Quote->find('list'); - $this->set(compact('quotes')); - } + function edit($id = null) { - function delete($id = null) { - if (!$id) { - $this->Session->setFlash(__('Invalid id for QuotePage', true)); - $this->redirect(array('action'=>'index')); - } + if (!$id && empty($this->data)) { + $this->Session->setFlash(__('Invalid QuotePage', true)); + $this->redirect(array('action'=>'index')); + } - $quotepage = $this->QuotePage->findById($id); - $quoteid = $quotepage['QuotePage']['quote_id']; - - if ($this->QuotePage->del($id)) { - - - $this->Session->setFlash(__('Quote Page deleted', true)); - $this->redirect(array('controller' => 'quotes' , 'action'=>'view', $quoteid)); - } - } + if (!empty($this->data)) { + if ($this->QuotePage->save($this->data)) { + $this->Session->setFlash(__('The QuotePage has been saved', true)); + $id = $this->data['QuotePage']['quote_id']; + $this->redirect(array('controller' => 'quotes', 'action'=>'view/'.$id)); + } else { + $this->Session->setFlash(__('The QuotePage could not be saved. Please, try again.', true)); + } + } + if (empty($this->data)) { + $this->data = $this->QuotePage->read(null, $id); + $this->set('content', $this->data['QuotePage']['content']); + } + $quotes = $this->QuotePage->Quote->find('list'); + $this->set(compact('quotes')); + } + + function delete($id = null) { + if (!$id) { + $this->Session->setFlash(__('Invalid id for QuotePage', true)); + $this->redirect(array('action'=>'index')); + } + + $quotepage = $this->QuotePage->findById($id); + $quoteid = $quotepage['QuotePage']['quote_id']; + + if ($this->QuotePage->del($id)) { - function show($id = null) { - $this->layout = 'ajax'; - $this->set('quotePage', $this->QuotePage->read(null, $id)); - - } + $this->Session->setFlash(__('Quote Page deleted', true)); + $this->redirect(array('controller' => 'quotes' , 'action'=>'view', $quoteid)); + } + } - function frame($id = null) { - $this->layout = 'ajax'; - $this->set('id', $id); - } + function show($id = null) { + $this->layout = 'ajax'; + $this->set('quotePage', $this->QuotePage->read(null, $id)); + + } + + function frame($id = null) { + $this->layout = 'ajax'; + $this->set('id', $id); + } + + + function regeneratePage($id = null) { + if(!$id) { + $this->Session->setFlash(__('Invalid id for QuotePage', true)); + $this->redirect(array('action'=>'index')); + } + else { + $quotePage = $this->QuotePage->read(null, $id); + + //$enquiry = $this->QuotePage->Quote->Enquiry->find('all', array('conditions' => array('Enquiry.id' => $quotePage['Quote']['enquiry_id']))); + + $enquiry = $this->QuotePage->Quote->Enquiry->read(null, $quotePage['Quote']['enquiry_id']); + + // $quote = $this->QuotePage->Quote->find('all', array('conditions' => array('Quote.id' => $quotePage['Quote']['id']))); + +$quoteProducts = $this->QuotePage->Quote->QuoteProduct->find('all', array('recursive' => 0, 'conditions' => + array('QuoteProduct.quote_id' => $quotePage['Quote']['id']), + 'order' => array('QuoteProduct.item_number ASC')) + ); + +$contactFirstName = $enquiry['Contact']['first_name']; + +$salesEngineerName = $enquiry['User']['first_name'].' '.$enquiry['User']['last_name']; + +$productRows = ""; + + +foreach($quoteProducts as $quoteproduct) { + + $itemNumber = $quoteproduct['QuoteProduct']['item_number']; + $title = $quoteproduct['QuoteProduct']['title']; + + if($quoteproduct['QuoteProduct']['option'] == 1) { + $optionText = "Option "; + } + else { + $optionText = ""; + } + + $productRows .= << + +$optionText +$itemNumber + + +$title + + +ENDROW; + +} + + + $this->data['QuotePage']['content'] = <<Dear $contactFirstName,

+

 

+ +

Thank for your recent enquiry. Please see the following quotation for:

+ + + + + + + + + + +$productRows + + +
ItemProduct
 

+ +

Regards,

+ +

$salesEngineerName

+ +ENDCONTENT; + + + +if (!empty($this->data)) { + if ($this->QuotePage->save($this->data)) { + $this->Session->setFlash(__('The QuotePage has been saved', true)); + $id = $quotePage['Quote']['id']; + $this->redirect(array('controller' => 'quotes', 'action'=>'view/'.$id)); + } else { + $this->Session->setFlash(__('The QuotePage could not be saved. Please, try again.', true)); + } + } + + + + debug($quotePage); + + echo "
"; + debug ($quoteProducts); + + } + + + + } diff --git a/models/costing.php b/models/costing.php index 810afea8..84d03345 100755 --- a/models/costing.php +++ b/models/costing.php @@ -14,9 +14,14 @@ class Costing extends AppModel { 'order' => '' ), - 'QuoteProduct' => array('className'=>'QuoteProduct', - 'foreignKey' => 'quote_product_id' - ) + 'QuoteProduct' => array('className'=>'QuoteProduct','foreignKey' => 'quote_product_id' + ), + 'PurchaseCurrency' => array('className' => 'Currency', 'foreignKey' => 'purchase_currency_id'), + 'SaleCurrency' => array('className' => 'Currency', 'foreignKey' => 'sale_currency_id') + + //'ProductOption' => array('className' => 'ProductOption', 'foreignKey' => 'product_option_id'), + //'QuoteProductOption' + diff --git a/models/quoted_product.php b/models/quoted_product.php deleted file mode 100755 index 1391785e..00000000 --- a/models/quoted_product.php +++ /dev/null @@ -1,35 +0,0 @@ - array('className' => 'Principle', - 'foreignKey' => 'principle_id', - 'conditions' => '', - 'fields' => '', - 'order' => '' - ), - 'Currency' => array('className' => 'Currency', - 'foreignKey' => 'currency_id', - 'conditions' => '', - 'fields' => '', - 'order' => '' - ), - 'Quote' => array('className' => 'Quote', - 'foreignKey' => 'quote_id', - 'conditions' => '', - 'fields' => '', - 'order' => '' - ), - 'Product' => array('className' => 'Product', - 'foreignKey' => 'product_id', - 'conditions' => '', - 'fields' => '', - 'order' => '' - ) - ); - -} -?> \ No newline at end of file diff --git a/vendors/xtcpdf.php b/vendors/xtcpdf.php index 3c723a27..c035e24c 100755 --- a/vendors/xtcpdf.php +++ b/vendors/xtcpdf.php @@ -178,6 +178,14 @@ class XTCPDF extends TCPDF + function productPage() { + + + + } + + + diff --git a/views/quotes/pdf.ctp b/views/quotes/pdf.ctp index 60cea6a9..43b11eec 100755 --- a/views/quotes/pdf.ctp +++ b/views/quotes/pdf.ctp @@ -72,7 +72,7 @@ foreach ($quote['QuotePage'] as $page) { $tcpdf->SetFont('times', '', 12); - $tcpdf->writeHTMLCell(0, 0, $currentX, $currentY+5, $page['content'], 'LTRB', 1, 0, true, 'L', true); + $tcpdf->writeHTMLCell(0, 0, $currentX, $currentY+5, $page['content'], '', 1, 0, true, 'L', true); /* Only show the footer if it's the first page */ @@ -86,6 +86,9 @@ foreach ($quote['QuotePage'] as $page) { } + + + //DetailsBox($companyName, $emailTo, $attention, $fromName, $fromEmail, $enquiryNumber) diff --git a/views/quotes/view.ctp b/views/quotes/view.ctp index 3533a1a8..51405d3e 100755 --- a/views/quotes/view.ctp +++ b/views/quotes/view.ctp @@ -1,39 +1,43 @@
-

link($quote['Enquiry']['title'], -array('controller'=>'enquiries', 'action'=>'view', $quote['Enquiry']['id'])); + $enquirynumber_link = $html->link($quote['Enquiry']['title'], + array('controller'=>'enquiries', 'action'=>'view', $quote['Enquiry']['id'])); + $customer_link = $html->link( $customer['Customer']['name'], array('controller'=>'customers', 'action' => 'view', $customer['Customer']['id'])); + + + if($quote['Quote']['revision'] == 0) { + __('Quote: '.$enquirynumber_link. ' for '. $customer_link); + } + else { + __('Quote: '.$enquirynumber_link.' Revision '.$quote['Quote']['revision'].' for'. $customer_link); + } + ?>

+ -if($quote['Quote']['revision'] == 0) { - __('Quote: '.$enquirynumber_link); -} -else { - __('Quote: '.$enquirynumber_link.' Revision '.$quote['Quote']['revision']); -} -?>
+$i = 0; +foreach ($quote['QuotePage'] as $quotePage): + $class = null; + if ($i++ % 2 == 0) { + $class = ' class="altrow"'; + } + ?> @@ -43,65 +47,65 @@ else { -
-
    -
  • link(__('New Cover Page', true), array('controller'=> 'quote_pages', 'action'=>'add/'.$quote['Quote']['id']));?>
  • -
-
+
+
    +
  • link(__('Add Cover Page', true), array('controller'=> 'quote_pages', 'action'=>'add/'.$quote['Quote']['id']));?>
  • +
  • link(__('Regenerate First Page', true), array('controller'=> 'quote_pages', 'action'=>'regeneratePage', $quotePage['id']), null, sprintf(__('Are you sure you want to regenerate the first page? You will lose any changes you have made to it.', true), $i)); ?>
  • +
+
diff --git a/webroot/css/quotenik.css b/webroot/css/quotenik.css index d3463ac8..1868100b 100755 --- a/webroot/css/quotenik.css +++ b/webroot/css/quotenik.css @@ -27,297 +27,297 @@ * @modifiedby $LastChangedBy: gwoo $ * @lastmodified $Date: 2008-06-04 13:49:29 -0700 (Wed, 04 Jun 2008) $ * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ +*/ /* Quotenik.css - Modifed version of cake.generic.css - Karl Cordes 20 December 2008 */ * { - margin:0; - padding:0; + margin:0; + padding:0; } /* General Style Info */ body { - /* background: #E9E9E9; */ - /* background: #7B9AB6; */ - color: #000000; - font-family:'lucida grande',verdana,helvetica,arial,sans-serif; - font-size:90%; - margin: 0; + /* background: #E9E9E9; */ + /* background: #7B9AB6; */ + color: #000000; + font-family:'lucida grande',verdana,helvetica,arial,sans-serif; + font-size:90%; + margin: 0; } a { - - color: #003d4c; - text-decoration: underline; - font-weight: bold; + + color: #003d4c; + text-decoration: underline; + font-weight: bold; } a:hover { - - color: #003d4c; - text-decoration:none; + + color: #003d4c; + text-decoration:none; } a img { - border:none; + border:none; } h1, h2, h3, h4 { - font-weight: normal; + font-weight: normal; } h1 { - background:#fff; - color: #003d4c; - font-size: 100%; - margin: 0.1em 0; + background:#fff; + color: #003d4c; + font-size: 100%; + margin: 0.1em 0; } h2 { - background:#fff; - color: #e32; - font-family:'Gill Sans','lucida grande',helvetica, arial, sans-serif; - font-size: 190%; - margin: 0.3em 0; - /* padding-top: 0.8em; */ + background:#fff; + color: #e32; + font-family:'Gill Sans','lucida grande',helvetica, arial, sans-serif; + font-size: 190%; + margin: 0.3em 0; + /* padding-top: 0.8em; */ } h2 a { - color: #e32; - font-weight: normal; + color: #e32; + font-weight: normal; } a.headerlinks { - color: #EE3322; - font-weight:normal; + color: #EE3322; + font-weight:normal; } h3 { - color: #2C5FD5; - font-family:'Gill Sans','lucida grande',helvetica, arial, sans-serif; - font-size: 165%; - /* padding-top: 1.5em; */ + color: #2C5FD5; + font-family:'Gill Sans','lucida grande',helvetica, arial, sans-serif; + font-size: 165%; + /* padding-top: 1.5em; */ } h3#logo { - color: #FFFFFF; + color: #FFFFFF; } h4 { - color: #993; - font-weight: normal; - padding-top: 0.5em; + color: #993; + font-weight: normal; + padding-top: 0.5em; } ul, li { - margin: 0 12px; + margin: 0 12px; } ul.principle-emails { - list-style: none; - margin-left: 0; + list-style: none; + margin-left: 0; } #industrytaglist li { - display: inline; - list-style-type: none; - font-size: 120%; + display: inline; + list-style-type: none; + font-size: 120%; } /* Layout */ #container { - text-align: left; + text-align: left; } #header{ - - /* background: #E9E9E9 url(../img/top-gradient2.png) repeat-x bottom; */ - background: #7bf47b url(../img/gradient-blue4.png) repeat-x bottom; - /* background: #6BBA70; */ - padding-bottom: 2%; + + /* background: #E9E9E9 url(../img/top-gradient2.png) repeat-x bottom; */ + background: #7bf47b url(../img/gradient-blue4.png) repeat-x bottom; + /* background: #6BBA70; */ + padding-bottom: 2%; } #header h1 { - /* background: #003d4c url('../img/cmclogo.png') no-repeat left; */ - /* background: #E9E9E9; */ - color: #000000; - font-size: 200%; - padding: 0; - padding-bottom: 0.2em; + /* background: #003d4c url('../img/cmclogo.png') no-repeat left; */ + /* background: #E9E9E9; */ + color: #000000; + font-size: 200%; + padding: 0; + padding-bottom: 0.2em; } #header h1 a { - color: #000000; - /* background: #E5E5E5; */ - font-weight: normal; - text-decoration: none; + color: #000000; + /* background: #E5E5E5; */ + font-weight: normal; + text-decoration: none; } #header h1 a:hover { - color: #000000; - /* background: #E5E5E5; */ - text-decoration: underline; + color: #000000; + /* background: #E5E5E5; */ + text-decoration: underline; } #searchbox-appear { - display: none; - padding:0; + display: none; + padding:0; } #username { - position: absolute; - right:0; - width: 20%; - text-align: right; - color: #FFFFFF; - } - + position: absolute; + right:0; + width: 20%; + text-align: right; + color: #FFFFFF; +} + #username a { - color: #FFFFFF; - } + color: #FFFFFF; +} #nav { - width: 100%; + width: 100%; } - + #nav h3 { - font-size: 120%; - font-weight: bold; - color:#FFFFFF; - /* background: #E9E9E9; */ - padding-left: 0.1em; - padding-top: 0; - padding-right: 0; - padding-bottom: 0; + font-size: 120%; + font-weight: bold; + color:#FFFFFF; + /* background: #E9E9E9; */ + padding-left: 0.1em; + padding-top: 0; + padding-right: 0; + padding-bottom: 0; } #nav h3 a{ - font-size: 160%; - font-weight: normal; - color:#FFFFFF; - width: 100%; - /* background: #E9E9E9; */ - text-decoration:none; + font-size: 160%; + font-weight: normal; + color:#FFFFFF; + width: 100%; + /* background: #E9E9E9; */ + text-decoration:none; } #nav h3 a:hover { - /* background: #E9E9E9; */ + /* background: #E9E9E9; */ } - + #nav, #nav ul { /* all lists */ - padding: 0; - margin: 0; - list-style: none; - line-height: 1; + padding: 0; + margin: 0; + list-style: none; + line-height: 1; } #nav a { - padding-left: 0.5em; - padding-bottom:0.5em; - display: block; - width: 10em; - + padding-left: 0.5em; + padding-bottom:0.5em; + display: block; + width: 10em; + } #nav a:hover { - } +} #nav li { /* all list items */ - float: left; - width: 8em; /* width needed or else Opera goes nuts */ - + float: left; + width: 8em; /* width needed or else Opera goes nuts */ + } #nav li ul { /* second-level lists */ - position: absolute; - width: 10em; - left: -999em; /* using left instead of display to hide menus because display: none it read by screen readers */ + position: absolute; + width: 10em; + left: -999em; /* using left instead of display to hide menus because display: none it read by screen readers */ } #nav li:hover ul, #nav li.sfhover ul { /* lists nested under hovered list items */ - left: auto; + left: auto; } #nav li ul a { - background: #4687c3; - color: #FFFFFF; + background: #4687c3; + color: #FFFFFF; } #nav li ul a:hover { - background:#5d9cd7; - + background:#5d9cd7; + } - + #content{ - background: #fff; - clear: both; - color: #333; - padding: 10px; - overflow: auto; + background: #fff; + clear: both; + color: #333; + padding: 10px; + overflow: auto; } #footer { - clear: both; - padding: 6px 10px; - text-align: right; + clear: both; + padding: 6px 10px; + text-align: right; } #mailheaders { - width: 80%; - } + width: 80%; +} a#mailheaders { - color: #003d4c; - } + color: #003d4c; +} #viewemail { - text-align: left; - font-size: 80%; - - } + text-align: left; + font-size: 80%; + +} + - #printemailbody { - text-align: left; - font-size: 90%; - background-color: #FFFFFF; - color: #000000; - } + text-align: left; + font-size: 90%; + background-color: #FFFFFF; + color: #000000; +} + - #showemail { - padding-top:1em; - width: 100%; - } - + padding-top:1em; + width: 100%; +} + #emailframe { - float: left; - width: 50%; - } + float: left; + width: 50%; +} #emailattachments { - padding-right: 2em; - float: right; - } + padding-right: 2em; + float: right; +} dl#showemail { - line-height: 2em; - margin: 0em 0em; + line-height: 2em; + margin: 0em 0em; } /* Quote Cover Page Viewing */ #viewpage { - /*width: 400px; + /*width: 400px; height: 400px; */ - overflow: scroll; - border: black 1px solid; + overflow: scroll; + border: black 1px solid; } div.quotepageview { - overflow: scroll; - border: black 1px solid; - width: 60%; + overflow: scroll; + border: black 1px solid; + width: 60%; } .addressradio label { - display: block; - font-size: 110%; - padding-left: 2em; + display: block; + font-size: 110%; + padding-left: 2em; } .enquiries index { @@ -326,467 +326,471 @@ div.quotepageview { div.enquiriesindex { -padding: 0; -margin: 0; + padding: 0; + margin: 0; } /* Tables */ table { - background: #fff; - border:1px solid #ccc; - border-right:0; - clear: both; - color: #333; - margin-bottom: 10px; - width: 100%; + background: #fff; + border:1px solid #ccc; + border-right:0; + clear: both; + color: #333; + margin-bottom: 10px; + width: 100%; } th { - background: #f2f2f2; - border:1px solid #bbb; - border-top: 1px solid #fff; - border-left: 1px solid #fff; - text-align: center; + background: #f2f2f2; + border:1px solid #bbb; + border-top: 1px solid #fff; + border-left: 1px solid #fff; + text-align: center; } th a { - background:#f2f2f2; - display: block; - padding: 2px 4px; - text-decoration: none; + background:#f2f2f2; + display: block; + padding: 2px 4px; + text-decoration: none; } th a:hover { - background: #ccc; - color: #333; - text-decoration: none; + background: #ccc; + color: #333; + text-decoration: none; } table tr td { - background: #fff; - border-right: 1px solid #ccc; - text-align: center; - vertical-align: top; - padding: 1px; + background: #fff; + border-right: 1px solid #ccc; + text-align: center; + vertical-align: top; + padding: 1px; } table tr.altrow td { - background: #f4f4f4; + background: #f4f4f4; } table tr.customer-suspect td { - background: #65BFDC; - } + background: #65BFDC; +} table tr.customer-prospect td { - background: #F4F42F; - } + background: #F4F42F; +} table tr.customer-customer td { - background: #63D463; - } + background: #63D463; +} td.actions { - text-align: center; - white-space: nowrap; + text-align: center; + white-space: nowrap; } td.actions a { - margin: 0px 6px; + margin: 0px 6px; } .cake-sql-log table { - background: #f4f4f4; + background: #f4f4f4; } .cake-sql-log td { - padding: 4px 8px; - text-align: left; + padding: 4px 8px; + text-align: left; } /* Master Enquiry Register Styling */ table.mer { - background: #fff; - border:1px solid #ccc; - border-right:0; - color: #333; - margin-bottom: 10px; - - font-size: 85%; - padding-left: 0; - padding-right: 0; - overflow: auto; - } + background: #fff; + border:1px solid #ccc; + border-right:0; + color: #333; + margin-bottom: 10px; + + font-size: 85%; + padding-left: 0; + padding-right: 0; + overflow: auto; +} th.mer { - background: #f2f2f2; - border:1px solid #bbb; - border-top: 1px solid #fff; - border-left: 1px solid #fff; - text-align: center; + background: #f2f2f2; + border:1px solid #bbb; + border-top: 1px solid #fff; + border-left: 1px solid #fff; + text-align: center; } th.mer a { - background:#f2f2f2; - display: block; - padding: 2px 4px; - text-decoration: none; + background:#f2f2f2; + display: block; + padding: 2px 4px; + text-decoration: none; } th.mer a:hover { - background: #ccc; - color: #333; - text-decoration: none; + background: #ccc; + color: #333; + text-decoration: none; } table.mer tr td { - background: #fff; - border-right: 1px solid #ccc; - border-bottom: 1px solid #ccc; - text-align: center; - vertical-align: top; - padding: 1px; + background: #fff; + border-right: 1px solid #ccc; + border-bottom: 1px solid #ccc; + text-align: center; + vertical-align: top; + padding: 1px; } table.mer tr.altrow td { - background: #f4f4f4; + background: #f4f4f4; } table.mer tr.joblost td { - background: #FFC0CB; + background: #FFC0CB; } table.mer tr.jobwon td { - background: #55E055; + background: #55E055; } table.mer tr.information td { - background: #FFFFFF; + background: #FFFFFF; } table.mer tr.informationsent td { - background: #ADD8E6; + background: #ADD8E6; } table.mer tr.requestforquote td { - background: #FFFFFF; + background: #FFFFFF; } table.mer tr.quoted td { - background: #FFEC35; + background: #FFEC35; } table.mer tr td.posted { - padding: 0; - background: #55E055; + padding: 0; + background: #55E055; } table.mer tr td.notposted { - padding: 0; - background: #FFFFFF; + padding: 0; + background: #FFFFFF; } table.mer tr td.enqdate { - padding: 0; - font-size: x-small; + padding: 0; + font-size: x-small; } table.mer tr td.principlename { - padding: 0; - font-size: x-small; + padding: 0; + font-size: x-small; } table.mer tr td.comments { - font-size: xx-small; - text-align: left; + font-size: xx-small; + text-align: left; } table.mer tr td.status { - padding: 0; - font-size: x-small; - } + padding: 0; + font-size: x-small; +} table.mer tr td.contactemail { - padding: 0; - font-size: x-small; + padding: 0; + font-size: x-small; } table.mer tr td.contactname { - padding: 0; - font-size: small; + padding: 0; + font-size: small; } table.mer tr td.customername { - padding: 0; - font-size: small; + padding: 0; + font-size: small; } table.mer tr td.viewedit { - padding: 0; - font-size: x-small; - white-space: nowrap; + padding: 0; + font-size: x-small; + white-space: nowrap; } table.quotetable { - width: auto; - } + width: auto; +} table.quotetable tr.mostrecent td { - background: #ADD8E6; - } + background: #ADD8E6; +} table.quotetable tr.altrow td { - background: #f4f4f4; - } - + background: #f4f4f4; +} + table.emailtable { - font-size: small; + font-size: small; } /* Product Options Tables */ table.productoptions { - width: 40em; + width: 40em; } table.productoptions tr.defaultoption { - font-weight: bold; + font-weight: bold; +} + +table.quoteproducts { + width: 50%; } /* Paging */ div.paging { - background:#fff; - color: #ccc; - margin-bottom: 2em; + background:#fff; + color: #ccc; + margin-bottom: 2em; } div.paging div.disabled { - color: #ddd; - display: inline; + color: #ddd; + display: inline; } div.paging span { } div.paging span.current { - color: #000; + color: #000; } div.paging span a { } /* Scaffold View */ dl { - line-height: 2em; - margin: 0em 0em; - width: 60%; + line-height: 2em; + margin: 0em 0em; + width: 60%; } dl.mailheaders { - line-height: 2em; - margin: 0em 0em; - width: 100%; - color: #000000; + line-height: 2em; + margin: 0em 0em; + width: 100%; + color: #000000; } dl.altrow { - background: #f4f4f4; + background: #f4f4f4; } dt { - font-weight: bold; - padding-left: 4px; - vertical-align: top; + font-weight: bold; + padding-left: 4px; + vertical-align: top; } dt.altrow { - background: #E6F0F0; - } + background: #E6F0F0; +} dd.mailheaders { - margin-top: -2em; - vertical-align: top; + margin-top: -2em; + vertical-align: top; } dd.mailheaders-altrow { - margin-top: -2em; - vertical-align: top; - background: #E6F0F0; - } + margin-top: -2em; + vertical-align: top; + background: #E6F0F0; +} dd { - margin-left: 20em; - margin-top: -2em; - vertical-align: top; + margin-left: 20em; + margin-top: -2em; + vertical-align: top; } dd.altrow { - background: #E6F0F0; - } - + background: #E6F0F0; +} + /* Forms */ form { - clear: left; - margin-right: 20px; - padding: 0; - width: 60%; + clear: left; + margin-right: 20px; + padding: 0; + width: 60%; } form#searchbox { - clear:auto; - width: auto; - margin-right: 0px; - } + clear:auto; + width: auto; + margin-right: 0px; +} fieldset { - border: 1px solid #ccc; - margin-top: 30px; - padding: 16px 20px; + border: 1px solid #ccc; + margin-top: 30px; + padding: 16px 20px; } fieldset legend { - background:#fff; - color: #e32; - font-size: 160%; - font-weight: bold; - width: auto; + background:#fff; + color: #e32; + font-size: 160%; + font-weight: bold; + width: auto; } fieldset fieldset { - margin-top: 0px; - margin-bottom: 20px; - padding: 16px 0; + margin-top: 0px; + margin-bottom: 20px; + padding: 16px 0; } fieldset fieldset legend { - font-size: 120%; - font-weight: normal; - margin-left: 20px; + font-size: 120%; + font-weight: normal; + margin-left: 20px; } fieldset fieldset div { - clear: left; - margin: 0 20px; + clear: left; + margin: 0 20px; } form div { - clear: both; - margin-bottom: .05em; - padding: .5em; - vertical-align: text-top; + clear: both; + margin-bottom: .05em; + padding: .5em; + vertical-align: text-top; } form div#searchbox { - clear: right; - margin-right: 0px; + clear: right; + margin-right: 0px; } form div.input { - color: #444; + color: #444; } form div.required { - color: #333; - font-weight: bold; + color: #333; + font-weight: bold; } form div.submit { - border: 0; - clear: both; - margin-top: 10px; - margin-left: 140px; + border: 0; + clear: both; + margin-top: 10px; + margin-left: 140px; } form.MER-inplace-select { - float: left; - position: relative; - padding-right: 0; - margin: 0; - width: 100px; + float: left; + position: relative; + padding-right: 0; + margin: 0; + width: 100px; } select.MER-inplace-select { - width: 100px; - } + width: 100px; +} label { - display: block; - font-size: 110%; - + display: block; + font-size: 110%; + } input, textarea { - clear: both; - display: block; - font-size: 140%; - font-family: "frutiger linotype", "lucida grande", "verdana", sans-serif; - padding: 1px; - width: 100%; + clear: both; + display: block; + font-size: 140%; + font-family: "frutiger linotype", "lucida grande", "verdana", sans-serif; + padding: 1px; + width: 100%; } input#searchbox { - clear:auto; - display: inline; - margin-right:0; - display: auto; - width: 100px; + clear:auto; + display: inline; + margin-right:0; + display: auto; + width: 100px; } /* CSS from Easy Prototype Validation Script */ input.disabled { - border: 1px solid #F2F2F2; - background-color: #F2F2F2; + border: 1px solid #F2F2F2; + background-color: #F2F2F2; } input.required, textarea.required { - border: 1px solid #00A8E6; + border: 1px solid #00A8E6; } input.validation-failed, textarea.validation-failed { - border: 1px solid #FF3300; - color : #FF3300; + border: 1px solid #FF3300; + color : #FF3300; } input.validation-passed, textarea.validation-passed { - border: 1px solid #00CC00; - color : #000; + border: 1px solid #00CC00; + color : #000; } .validation-advice { - margin: 5px 0; - padding: 5px; - background-color: #FF3300; - color : #FFF; - font-weight: bold; + margin: 5px 0; + padding: 5px; + background-color: #FF3300; + color : #FFF; + font-weight: bold; } .custom-advice { - margin: 5px 0; - padding: 5px; - background-color: #C8AA00; - color : #FFF; - font-weight: bold; + margin: 5px 0; + padding: 5px; + background-color: #C8AA00; + color : #FFF; + font-weight: bold; } /* End CSS from that script */ select { - clear: both; - font-size: 120%; - vertical-align: text-bottom; + clear: both; + font-size: 120%; + vertical-align: text-bottom; } select[multiple=multiple] { - width: 100%; + width: 100%; } option { - font-size: 120%; - padding: 0 3px; + font-size: 120%; + padding: 0 3px; } input[type=checkbox] { - clear: left; - float: left; - margin: 0px 6px 7px 2px; - width: auto; + clear: left; + float: left; + margin: 0px 6px 7px 2px; + width: auto; } input[type=radio] { - clear: left; - float: left; - margin: 0px 6px 7px 2px; - width: auto; + clear: left; + float: left; + margin: 0px 6px 7px 2px; + width: auto; } input[type=submit] { - display: inline; - font-size: 110%; - padding: 2px 5px; - width: auto; - vertical-align: bottom; + display: inline; + font-size: 110%; + padding: 2px 5px; + width: auto; + vertical-align: bottom; } input[type=button].dateButton { - display: inline; - font-size: 110%; - padding: 2px 5px; - width: 20%; - vertical-align: bottom; + display: inline; + font-size: 110%; + padding: 2px 5px; + width: 20%; + vertical-align: bottom; } /* Costing Forms */ div.addproduct { - font-size: 80%; - + font-size: 80%; + } form.addproduct { - margin-right: 20px; - padding: 0; - width: 80%; + margin-right: 20px; + padding: 0; + width: 80%; } @@ -798,284 +802,284 @@ div.address-radio { /* Notices and Errors */ div.message { - clear: both; - color: #900; - font-size: 140%; - font-weight: bold; - margin: 1em 0; + clear: both; + color: #900; + font-size: 140%; + font-weight: bold; + margin: 1em 0; } div.error-message { - clear: both; - color: #900; - font-weight: bold; + clear: both; + color: #900; + font-weight: bold; } p.error { - background-color: #e32; - color: #fff; - font-family: Courier, monospace; - font-size: 120%; - line-height: 140%; - padding: 0.8em; - margin: 1em 0; + background-color: #e32; + color: #fff; + font-family: Courier, monospace; + font-size: 120%; + line-height: 140%; + padding: 0.8em; + margin: 1em 0; } p.error em { - color: #000; - font-weight: normal; - line-height: 140%; + color: #000; + font-weight: normal; + line-height: 140%; } .notice { - background: #ffcc00; - color: #000; - display: block; - font-family: Courier, monospace; - font-size: 120%; - line-height: 140%; - padding: 0.8em; - margin: 1em 0; + background: #ffcc00; + color: #000; + display: block; + font-family: Courier, monospace; + font-size: 120%; + line-height: 140%; + padding: 0.8em; + margin: 1em 0; } .success { - background: green; - color: #fff; + background: green; + color: #fff; } /* Actions */ div.actions ul { - margin: 0px 0; - padding: 0; + margin: 0px 0; + padding: 0; } div.actions li { - display: inline; - list-style-type: none; - line-height: 2em; - margin: 0 2em 0 0; - white-space: nowrap; + display: inline; + list-style-type: none; + line-height: 2em; + margin: 0 2em 0 0; + white-space: nowrap; } div.actions ul li a { - background:#fff; - color: #003d4c; - text-decoration: none; + background:#fff; + color: #003d4c; + text-decoration: none; } div.actions ul li a:hover { - color: #333; - text-decoration: underline; + color: #333; + text-decoration: underline; } /* Related */ div.related { - clear: both; - display: block; + clear: both; + display: block; } div.related h3 { - clear: none; + clear: none; } /* Debugging */ pre { - color: #000; - background: #f0f0f0; - padding: 1em; + color: #000; + background: #f0f0f0; + padding: 1em; } pre.cake-debug { - background: #ffcc00; - font-size: 120%; - line-height: 140%; - margin-top: 1em; - overflow: auto; - position: relative; + background: #ffcc00; + font-size: 120%; + line-height: 140%; + margin-top: 1em; + overflow: auto; + position: relative; } div.cake-stack-trace { - background: #fff; - border: 4px dotted #ffcc00; - color: #333; - margin: 0px; - padding: 6px; - font-size: 120%; - line-height: 140%; - overflow: auto; - position: relative; + background: #fff; + border: 4px dotted #ffcc00; + color: #333; + margin: 0px; + padding: 6px; + font-size: 120%; + line-height: 140%; + overflow: auto; + position: relative; } div.cake-code-dump pre { - position: relative; - overflow: auto; + position: relative; + overflow: auto; } div.cake-stack-trace pre, div.cake-code-dump pre { - color: #000; - background-color: #F0F0F0; - margin: 0px; - padding: 1em; - overflow: auto; + color: #000; + background-color: #F0F0F0; + margin: 0px; + padding: 1em; + overflow: auto; } div.cake-code-dump pre, div.cake-code-dump pre code { - clear: both; - font-size: 12px; - line-height: 15px; - margin: 4px 2px; - padding: 4px; - overflow: auto; + clear: both; + font-size: 12px; + line-height: 15px; + margin: 4px 2px; + padding: 4px; + overflow: auto; } div.cake-code-dump span.code-highlight { - background-color: #ff0; - padding: 4px; + background-color: #ff0; + padding: 4px; } div.code-coverage-results div.code-line { - padding-left:5px; - display:block; - margin-left:10px; + padding-left:5px; + display:block; + margin-left:10px; } div.code-coverage-results div.uncovered span.content { - background:#ecc; + background:#ecc; } div.code-coverage-results div.covered span.content { - background:#cec; + background:#cec; } div.code-coverage-results div.ignored span.content { - color:#aaa; + color:#aaa; } div.code-coverage-results span.line-num { - color:#666; - display:block; - float:left; - width:20px; - text-align:right; - margin-right:5px; + color:#666; + display:block; + float:left; + width:20px; + text-align:right; + margin-right:5px; } div.code-coverage-results span.line-num strong { - color:#666; + color:#666; } div.code-coverage-results div.start { - border:1px solid #aaa; - border-width:1px 1px 0px 1px; - margin-top:30px; - padding-top:5px; + border:1px solid #aaa; + border-width:1px 1px 0px 1px; + margin-top:30px; + padding-top:5px; } div.code-coverage-results div.end { - border:1px solid #aaa; - border-width:0px 1px 1px 1px; - margin-bottom:30px; - padding-bottom:5px; + border:1px solid #aaa; + border-width:0px 1px 1px 1px; + margin-bottom:30px; + padding-bottom:5px; } div.code-coverage-results div.realstart { - margin-top:0px; + margin-top:0px; } div.code-coverage-results p.note { - color:#bbb; - padding:5px; - margin:5px 0 10px; - font-size:10px; + color:#bbb; + padding:5px; + margin:5px 0 10px; + font-size:10px; } div.code-coverage-results span.result-bad { - color: #a00; + color: #a00; } div.code-coverage-results span.result-ok { - color: #fa0; + color: #fa0; } div.code-coverage-results span.result-good { - color: #0a0; + color: #0a0; } div.principle-emails { -float: right; -background: #ECF2F2; -border: 1px black dashed; -width: auto; -text-align: left; -font-size: 70%; -margin:0; -padding:0; + float: right; + background: #ECF2F2; + border: 1px black dashed; + width: auto; + text-align: left; + font-size: 70%; + margin:0; + padding:0; } div.enquiries-view { -float: left; -width: 80%; + float: left; + width: 80%; } div.auto_complete { - position :relative; - width :500x; - background-color :white; - border :1px solid #888; - margin :0px; - padding :0px; + position :relative; + width :500x; + background-color :white; + border :1px solid #888; + margin :0px; + padding :0px; } div.tipbox { - float: right; - width: 30%; - border: 1px dashed #000000; - background: #DBFFB4; + float: right; + width: 30%; + border: 1px dashed #000000; + background: #DBFFB4; } li.selected { background-color: #ffb; } span { - color: #2F782A; - font-weight: bold; - font-size: 110%; - } - + color: #2F782A; + font-weight: bold; + font-size: 110%; +} + span.note { - font-size: 85%; - } + font-size: 85%; +} span.warning { - font-size: 80%; - color: #FF0000; - } - + font-size: 80%; + color: #FF0000; +} + span.highlight { - background-color: #74DD63; + background-color: #74DD63; } span.principle-emails { - color: #000000; - padding-left: 2px; + color: #000000; + padding-left: 2px; } span.enquiry-view-comments { - color: #000000; - font-size: 100%; - text-align: left; - line-height: 1; + color: #000000; + font-size: 100%; + text-align: left; + line-height: 1; } - - + + span.tip { - color: #000000; - } + color: #000000; +} div#qTip { - padding: 3px; - border: 1px solid #666; - border-right-width: 2px; - border-bottom-width: 2px; - display: none; - background: #FFF9C1; - color: #000000; - font: bold 1em Verdana, Arial, sans-serif; - text-align: left; - position: absolute; - z-index: 1000; + padding: 3px; + border: 1px solid #666; + border-right-width: 2px; + border-bottom-width: 2px; + display: none; + background: #FFF9C1; + color: #000000; + font: bold 1em Verdana, Arial, sans-serif; + text-align: left; + position: absolute; + z-index: 1000; } div.categorylist { - padding-left: 0.5em; + padding-left: 0.5em; } div.categorylist h3 { - padding-top: 0.4em; + padding-top: 0.4em; } div.categorylist h3 a{ - color: #4CA5C1; - text-decoration: none; - padding-right: 0.5em; + color: #4CA5C1; + text-decoration: none; + padding-right: 0.5em; } div.categorylist h3 a:hover { - text-decoration: underline; + text-decoration: underline; } div#costingwrapper { - display: none; + display: none; } diff --git a/webroot/js/quotenik/add_costing.js b/webroot/js/quotenik/add_costing.js index a83c40ac..14581693 100644 --- a/webroot/js/quotenik/add_costing.js +++ b/webroot/js/quotenik/add_costing.js @@ -1,10 +1,52 @@ -/** - * Add costing to a product - * - * - * - */ + +function buildup() { +//Fetch all the relevent inputs from the form + + +quantity = +($F('CostingQuantity')); + +costprice = +($F('CostingUnitCostPrice')); +ourdiscount_percentage = +($F('OurDiscountPercent')); +packing_each = +($F('CostingPacking')); +exchange_rate = +($F('CostingExchangeRate')); +shipping_cost = +($F('CostingShippingCost')); +duty = +($F('CostingDutyPercent')); +sellprice_each = +($F('sellprice_each')); + +customs = +($F('CostingCustoms')); +misc_cost = +($F('CostingMiscCosts')); +finance = +($F('CostingFinancePercent')); +if(ourdiscount_percentage != 0) { + discount = ourdiscount_percentage / 100; +} +else { + discount = 0; +} +discountamount = discount * costprice; +net_foreign_price = costprice - discountamount; + +total_foreign_price = net_foreign_price + packing_each; + + +$('fob_country_of_export').value = total_foreign_price; +domestic_cost = total_foreign_price / exchange_rate; +$('convert_to_aud').value = domestic_cost.toFixed(2); +dutyamount = (duty / 100) * domestic_cost; + +total_landed_cost = domestic_cost + dutyamount + customs + misc_cost + shipping_cost; + +financeamount = (finance / 100) * domestic_cost; +financeamount = financeamount.toFixed(2); +$('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').value = gross_profit_dollars; +$('gross_profit_percent').value = ((gross_profit_dollars / sellprice_each)*100).toFixed(2); + +}