public function indexAction() { $this->_helper->getHelper('layout')->disableLayout(); $invoiceid = $this->_getParam('invoiceid', 0); $locale = Zend_Registry::get('Zend_Locale'); //Get invoice $invoiceDb = new Sales_Model_DbTable_Invoice(); $invoice = $invoiceDb->getInvoice($invoiceid); //Get positions $positions = $this->getPositions($invoiceid); //Get units of measurements $uoms = $this->_helper->Uom->getUoms(); $uoms = array_combine($uoms, $uoms); //Get tax rates $taxRates = $this->_helper->TaxRate->getTaxRates($locale); $forms = array(); $orderings = array(); foreach ($positions as $position) { $orderings[$position->ordering] = $position->ordering; } foreach ($positions as $position) { $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' => 2, 'locale' => $locale)); $form = new Sales_Form_Invoicepos(); $forms[$position->id] = $form->populate($position->toArray()); $forms[$position->id]->uom->addMultiOptions($uoms); $forms[$position->id]->taxrate->addMultiOptions($taxRates); $forms[$position->id]->ordering->addMultiOptions($orderings); } $invoice['subtotal'] = $this->_currency->toCurrency($invoice['subtotal']); $invoice['taxes'] = $this->_currency->toCurrency($invoice['taxes']); $invoice['total'] = $this->_currency->toCurrency($invoice['total']); $this->view->forms = $forms; $this->view->invoice = $invoice; $this->view->toolbar = new Sales_Form_ToolbarPositions(); }
public function lockAction() { header('Content-type: application/json'); $this->_helper->viewRenderer->setNoRender(); $this->_helper->getHelper('layout')->disableLayout(); $id = $this->_getParam('id', 0); $invoiceDb = new Sales_Model_DbTable_Invoice(); $invoice = $invoiceDb->getInvoice($id); if ($this->isLocked($invoice['locked'], $invoice['lockedtime'])) { $userDb = new Users_Model_DbTable_User(); $user = $userDb->getUser($invoice['locked']); echo Zend_Json::encode(array('message' => $this->view->translate('MESSAGES_ACCESS_DENIED_%1$s', $user['name']))); } else { $invoiceDb->lock($id, $this->_user['id'], $this->_date); } }