Adding product page to PDF functionality
This commit is contained in:
parent
265ff9354b
commit
b1cac9e89d
|
|
@ -1,38 +1,72 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class CostingsController extends AppController {
|
class CostingsController extends AppController {
|
||||||
|
|
||||||
var $name = 'Costings';
|
var $name = 'Costings';
|
||||||
var $helpers = array('Html', 'Form','Ajax');
|
var $helpers = array('Html', 'Form');
|
||||||
var $components = array('RequestHandler');
|
|
||||||
|
|
||||||
|
function index() {
|
||||||
|
$this->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() {
|
function add() {
|
||||||
$this->Costings->recursive = 0;
|
if (!empty($this->data)) {
|
||||||
$this->set('costings', $this->paginate());
|
$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'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete($id = null) {
|
||||||
/**
|
if (!$id) {
|
||||||
* Add a costing to a product. It's either being added to a product, quote_product etc.
|
$this->Session->setFlash(__('Invalid id for Costing', true));
|
||||||
*
|
$this->redirect(array('action'=>'index'));
|
||||||
*
|
}
|
||||||
* @param int $id
|
if ($this->Costing->del($id)) {
|
||||||
* @param string $target
|
$this->Session->setFlash(__('Costing deleted', true));
|
||||||
*/
|
$this->redirect(array('action'=>'index'));
|
||||||
function add($id, $target) {
|
}
|
||||||
|
}
|
||||||
if (!$id && empty($this->data)) {
|
|
||||||
$this->Session->setFlash(__('Invalid Quote ID', true));
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
?>
|
|
||||||
|
|
@ -1,103 +1,211 @@
|
||||||
<?php
|
<?php
|
||||||
class QuotePagesController extends AppController {
|
class QuotePagesController extends AppController {
|
||||||
|
|
||||||
var $name = 'QuotePages';
|
var $name = 'QuotePages';
|
||||||
var $helpers = array('Html', 'Form', 'Ajax', 'Number', 'Fck');
|
var $helpers = array('Html', 'Form', 'Ajax', 'Number', 'Fck');
|
||||||
|
|
||||||
var $components = array('RequestHandler');
|
var $components = array('RequestHandler');
|
||||||
|
|
||||||
function index() {
|
function index() {
|
||||||
$this->QuotePage->recursive = 0;
|
$this->QuotePage->recursive = 0;
|
||||||
$this->set('quotePages', $this->paginate());
|
$this->set('quotePages', $this->paginate());
|
||||||
}
|
}
|
||||||
|
|
||||||
function view($id = null) {
|
function view($id = null) {
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
$this->Session->setFlash(__('Invalid QuotePage.', true));
|
$this->Session->setFlash(__('Invalid QuotePage.', true));
|
||||||
$this->redirect(array('action'=>'index'));
|
$this->redirect(array('action'=>'index'));
|
||||||
}
|
}
|
||||||
$this->set('quotePage', $this->QuotePage->read(null, $id));
|
$this->set('quotePage', $this->QuotePage->read(null, $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
function add($id = null) {
|
function add($id = null) {
|
||||||
|
|
||||||
if (!$id && empty($this->data)) {
|
if (!$id && empty($this->data)) {
|
||||||
$this->Session->setFlash(__('Invalid Quote ID', true));
|
$this->Session->setFlash(__('Invalid Quote ID', true));
|
||||||
$this->redirect(array('controller' => 'quotes', 'action'=>'index'));
|
$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 (!empty($this->data)) {
|
||||||
|
$this->QuotePage->create();
|
||||||
if (!$id && empty($this->data)) {
|
if ($this->QuotePage->save($this->data)) {
|
||||||
$this->Session->setFlash(__('Invalid QuotePage', true));
|
$this->Session->setFlash(__('The Quote Page has been saved', true));
|
||||||
$this->redirect(array('action'=>'index'));
|
$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)) {
|
function edit($id = null) {
|
||||||
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 && empty($this->data)) {
|
||||||
if (!$id) {
|
$this->Session->setFlash(__('Invalid QuotePage', true));
|
||||||
$this->Session->setFlash(__('Invalid id for QuotePage', true));
|
$this->redirect(array('action'=>'index'));
|
||||||
$this->redirect(array('action'=>'index'));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$quotepage = $this->QuotePage->findById($id);
|
if (!empty($this->data)) {
|
||||||
$quoteid = $quotepage['QuotePage']['quote_id'];
|
if ($this->QuotePage->save($this->data)) {
|
||||||
|
$this->Session->setFlash(__('The QuotePage has been saved', true));
|
||||||
if ($this->QuotePage->del($id)) {
|
$id = $this->data['QuotePage']['quote_id'];
|
||||||
|
$this->redirect(array('controller' => 'quotes', 'action'=>'view/'.$id));
|
||||||
|
} else {
|
||||||
$this->Session->setFlash(__('Quote Page deleted', true));
|
$this->Session->setFlash(__('The QuotePage could not be saved. Please, try again.', true));
|
||||||
$this->redirect(array('controller' => 'quotes' , 'action'=>'view', $quoteid));
|
}
|
||||||
}
|
}
|
||||||
}
|
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->Session->setFlash(__('Quote Page deleted', true));
|
||||||
$this->layout = 'ajax';
|
$this->redirect(array('controller' => 'quotes' , 'action'=>'view', $quoteid));
|
||||||
$this->set('quotePage', $this->QuotePage->read(null, $id));
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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 .= <<<ENDROW
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
$optionText
|
||||||
|
$itemNumber
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
$title
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
ENDROW;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$this->data['QuotePage']['content'] = <<<ENDCONTENT
|
||||||
|
|
||||||
|
<p>Dear $contactFirstName, </p>
|
||||||
|
<p> </p>
|
||||||
|
|
||||||
|
<p> Thank for your recent enquiry. Please see the following quotation for: </p>
|
||||||
|
|
||||||
|
<table border="0" cellpadding="1" cellspacing="1" style="width: 100%; ">
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th><b>Item</b></th>
|
||||||
|
<th><b>Product</b></th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
$productRows
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table
|
||||||
|
|
||||||
|
<p> </p>
|
||||||
|
|
||||||
|
<p>Regards, </p>
|
||||||
|
|
||||||
|
<p>$salesEngineerName</p>
|
||||||
|
|
||||||
|
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 "<hr>";
|
||||||
|
debug ($quoteProducts);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,14 @@ class Costing extends AppModel {
|
||||||
'order' => ''
|
'order' => ''
|
||||||
),
|
),
|
||||||
|
|
||||||
'QuoteProduct' => array('className'=>'QuoteProduct',
|
'QuoteProduct' => array('className'=>'QuoteProduct','foreignKey' => 'quote_product_id'
|
||||||
'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'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
<?php
|
|
||||||
class QuotedProduct extends AppModel {
|
|
||||||
|
|
||||||
var $name = 'QuotedProduct';
|
|
||||||
|
|
||||||
//The Associations below have been created with all possible keys, those that are not needed can be removed
|
|
||||||
var $belongsTo = array(
|
|
||||||
'Principle' => 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' => ''
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
8
vendors/xtcpdf.php
vendored
8
vendors/xtcpdf.php
vendored
|
|
@ -178,6 +178,14 @@ class XTCPDF extends TCPDF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function productPage() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ foreach ($quote['QuotePage'] as $page) {
|
||||||
$tcpdf->SetFont('times', '', 12);
|
$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 */
|
/* 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)
|
//DetailsBox($companyName, $emailTo, $attention, $fromName, $fromEmail, $enquiryNumber)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,43 @@
|
||||||
<div class="quotes view">
|
<div class="quotes view">
|
||||||
<h2><?php
|
<h2><?php
|
||||||
|
|
||||||
$enquirynumber_link = $html->link($quote['Enquiry']['title'],
|
$enquirynumber_link = $html->link($quote['Enquiry']['title'],
|
||||||
array('controller'=>'enquiries', 'action'=>'view', $quote['Enquiry']['id']));
|
array('controller'=>'enquiries', 'action'=>'view', $quote['Enquiry']['id']));
|
||||||
|
|
||||||
|
$customer_link = $html->link( $customer['Customer']['name'], array('controller'=>'customers', 'action' => 'view', $customer['Customer']['id']));
|
||||||
|
|
||||||
|
|
||||||
|
if($quote['Quote']['revision'] == 0) {
|
||||||
|
__('Quote: '.$enquirynumber_link. ' for '. $customer_link);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
__('Quote: '.$enquirynumber_link.' Revision '.$quote['Quote']['revision'].' for'. $customer_link);
|
||||||
|
}
|
||||||
|
?></h2>
|
||||||
|
|
||||||
|
|
||||||
if($quote['Quote']['revision'] == 0) {
|
|
||||||
__('Quote: '.$enquirynumber_link);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
__('Quote: '.$enquirynumber_link.' Revision '.$quote['Quote']['revision']);
|
|
||||||
}
|
|
||||||
?></h2>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($quote['QuotePage'] as $quotePage):
|
foreach ($quote['QuotePage'] as $quotePage):
|
||||||
$class = null;
|
$class = null;
|
||||||
if ($i++ % 2 == 0) {
|
if ($i++ % 2 == 0) {
|
||||||
$class = ' class="altrow"';
|
$class = ' class="altrow"';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="related">
|
<div class="related">
|
||||||
<h3>Page <?php echo $i; ?> </h3>
|
<h3>Page <?php echo $i; ?> </h3>
|
||||||
<div class="quotepageview">
|
<div class="quotepageview">
|
||||||
<?php echo $quotePage['content']; ?>
|
<?php echo $quotePage['content']; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php echo $html->link(__('Edit', true), array('controller'=>'quote_pages', 'action'=>'edit',$quotePage['id']));?>
|
<?php echo $html->link(__('Edit', true), array('controller'=>'quote_pages', 'action'=>'edit',$quotePage['id']));?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php echo $html->link(__('Delete', true), array('controller'=> 'quote_pages', 'action'=>'delete', $quotePage['id']), null, sprintf(__('Are you ABSOLUTELY sure you want to delete Page # %s? This cannot be undone.', true), $i)); ?>
|
|
||||||
|
<?php echo $html->link(__('Delete', true), array('controller'=> 'quote_pages', 'action'=>'delete', $quotePage['id']), null, sprintf(__('Are you ABSOLUTELY sure you want to delete Page # %s? This cannot be undone.', true), $i)); ?>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -43,65 +47,65 @@ else {
|
||||||
|
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<ul>
|
<ul>
|
||||||
<li><?php echo $html->link(__('New Cover Page', true), array('controller'=> 'quote_pages', 'action'=>'add/'.$quote['Quote']['id']));?> </li>
|
<li><?php echo $html->link(__('Add Cover Page', true), array('controller'=> 'quote_pages', 'action'=>'add/'.$quote['Quote']['id']));?> </li>
|
||||||
</ul>
|
<li> <?php echo $html->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)); ?></li>
|
||||||
</div>
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="related">
|
<div class="related">
|
||||||
<h3><?php __('Products in this Quote');?></h3>
|
<h3><?php __('Products in this Quote');?></h3>
|
||||||
<?php if (!empty($quoteProducts)):?>
|
<?php if (!empty($quoteProducts)):?>
|
||||||
<table cellpadding = "0" cellspacing = "0">
|
<table cellpadding = "0" cellspacing = "0" class="quoteproducts">
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php __('Item Number'); ?></th>
|
<th><?php __('Item Number'); ?></th>
|
||||||
<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 class="actions"><?php __('Actions');?></th>
|
<th class="actions"><?php __('Actions');?></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($quoteProducts as $quoteProduct):
|
foreach ($quoteProducts as $quoteProduct):
|
||||||
$class = null;
|
$class = null;
|
||||||
if ($i++ % 2 == 0) {
|
if ($i++ % 2 == 0) {
|
||||||
$class = ' class="altrow"';
|
$class = ' class="altrow"';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<tr<?php echo $class;?>>
|
<tr<?php echo $class;?>>
|
||||||
|
|
||||||
<td><?php
|
<td><?php
|
||||||
if($quoteProduct['QuoteProduct']['option'] == 1 ) {
|
if($quoteProduct['QuoteProduct']['option'] == 1 ) {
|
||||||
echo 'Option <br>';
|
echo 'Option <br>';
|
||||||
}
|
}
|
||||||
echo number_format($quoteProduct['QuoteProduct']['item_number'], 1, '.', '');?></td>
|
echo number_format($quoteProduct['QuoteProduct']['item_number'], 1, '.', '');?></td>
|
||||||
|
|
||||||
|
<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 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'])); ?>
|
<?php echo $html->link(__('Edit', true), array('controller'=> 'quote_products', 'action'=>'edit', $quoteProduct['QuoteProduct']['id'])); ?>
|
||||||
<?php echo $html->link(__('Edit', true), array('controller'=> 'quote_products', 'action'=>'edit', $quoteProduct['QuoteProduct']['id'])); ?>
|
<?php echo $html->link(__('Delete', true), array('controller'=> 'quote_products', 'action'=>'delete', $quoteProduct['QuoteProduct']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $quoteProduct['QuoteProduct']['id'])); ?>
|
||||||
<?php echo $html->link(__('Delete', true), array('controller'=> 'quote_products', 'action'=>'delete', $quoteProduct['QuoteProduct']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $quoteProduct['QuoteProduct']['id'])); ?>
|
</td>
|
||||||
</td>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</table>
|
</table>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<ul>
|
<ul>
|
||||||
<li><?php echo $html->link(__('Add Product to this Quote', true), array('controller'=> 'quote_products', 'action'=>'add', $quote['Quote']['id']));?> </li>
|
<li><?php echo $html->link(__('Add Product to this Quote', true), array('controller'=> 'quote_products', 'action'=>'add', $quote['Quote']['id']));?> </li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue