Exemplo n.º 1
0
 public function indexAction()
 {
     $this->_helper->getHelper('layout')->disableLayout();
     $quoteid = $this->_getParam('quoteid', 0);
     $locale = Zend_Registry::get('Zend_Locale');
     //Get quote
     $quoteDb = new Sales_Model_DbTable_Quote();
     $quote = $quoteDb->getQuote($quoteid);
     //Get positions
     $positions = $this->getPositions($quoteid);
     //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_Quotepos();
         $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);
     }
     $quote['subtotal'] = $this->_currency->toCurrency($quote['subtotal']);
     $quote['taxes'] = $this->_currency->toCurrency($quote['taxes']);
     $quote['total'] = $this->_currency->toCurrency($quote['total']);
     $this->view->forms = $forms;
     $this->view->quote = $quote;
     $this->view->toolbar = new Sales_Form_ToolbarPositions();
 }
Exemplo n.º 2
0
 public function lockAction()
 {
     header('Content-type: application/json');
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->getHelper('layout')->disableLayout();
     $id = $this->_getParam('id', 0);
     $quoteDb = new Sales_Model_DbTable_Quote();
     $quote = $quoteDb->getQuote($id);
     if ($this->isLocked($quote['locked'], $quote['lockedtime'])) {
         $userDb = new Users_Model_DbTable_User();
         $user = $userDb->getUser($quote['locked']);
         echo Zend_Json::encode(array('message' => $this->view->translate('MESSAGES_ACCESS_DENIED_%1$s', $user['name'])));
     } else {
         $quoteDb->lock($id, $this->_user['id'], $this->_date);
     }
 }