public function saveAction() { $this->_helper->getHelper('layout')->disableLayout(); $this->_helper->viewRenderer->setRender('pdf'); $id = $this->_getParam('id', 0); $locale = Zend_Registry::get('Zend_Locale'); $quoteDb = new Sales_Model_DbTable_Quote(); $quote = $quoteDb->getQuote($id); if ($quote['templateid']) { $templateDb = new Application_Model_DbTable_Template(); $template = $templateDb->getTemplate($quote['templateid']); if ($template['filename']) { $this->_helper->viewRenderer->setRender($template['filename']); } $this->view->template = $template; } $positions = $this->getPositions($id); if (!$quote['quoteid']) { //Get latest quote Id $latestQuote = $quoteDb->fetchRow($quoteDb->select()->where('clientid = ?', $this->_user['clientid'])->order('quoteid DESC')->limit(1)); //Set new quote Id $newQuoteId = $latestQuote['quoteid'] + 1; $quoteDb->saveQuote($id, $newQuoteId, $this->_date, 105, $this->_date, $this->_user['id']); $quote = $quoteDb->getQuote($id); } if (count($positions)) { foreach ($positions as $position) { $precision = floor($position->quantity) == $position->quantity ? 0 : 2; $position->total = $this->_currency->toCurrency($position->price * $position->quantity); $position->price = $this->_currency->toCurrency($position->price); $position->quantity = Zend_Locale_Format::toNumber($position->quantity, array('precision' => $precision, 'locale' => Zend_Registry::get('Zend_Locale'))); } $quote['taxes'] = $this->_currency->toCurrency($quote['taxes']); $quote['subtotal'] = $this->_currency->toCurrency($quote['subtotal']); $quote['total'] = $this->_currency->toCurrency($quote['total']); if ($quote['taxfree']) { $quote['taxrate'] = Zend_Locale_Format::toNumber(0, array('precision' => 2, 'locale' => $locale)); } else { $quote['taxrate'] = Zend_Locale_Format::toNumber($positions[0]->taxrate, array('precision' => 2, 'locale' => $locale)); } } $this->view->quote = $quote; $this->view->positions = $positions; $this->view->footers = $this->_helper->Footer->getFooters($quote['templateid'], $this->_user['clientid']); }