_setMessage($message, static::MSG_LOCKED); return parent::_init(); } protected function _initAction() { parent::_initAction(); $this->_initMessageTemplates(); $param = $this->getRestParam(1); $action = $this->getRestParam(0); if (null !== Qs_Request::getRequestValue('action')) { $action = Qs_Request::getRequestValue('action'); } if (count($this->getRestParams()) == 2 && filter_var($param, FILTER_VALIDATE_INT)) { if (!$this->_getDataObj()->setPrimaryKeyByTransaction($param)) { $this->_setBackUrl(Qs_SiteMap::findFirst(null, array('type' => 'ECommerce_Order_Admin_'), null, 'url')); $this->_setBackError(static::MSG_DATA_UNAVAILABLE); $this->_doBack(); } if (!$this->getPreviewMode()) { $this->setAction($action); } $this->_getDataObj()->clearData(); } else { $this->_setBackUrl(Qs_SiteMap::findFirst(null, array('type' => 'ECommerce_Order_Admin_'), null, 'url')); $this->_setBackError(static::MSG_DATA_UNAVAILABLE); $this->_doBack(); } if (!$this->getPreviewMode()) { App_ECommerce_Order_Admin_View::getTabs()->addTabs(); $session = new Qs_Session_Namespace(App_ECommerce_Order_Admin_Payment_View::PAYMENT_SESSION_NAME); $session->{$this->getRestParam(1)} = null; } return $this; } protected function _doNew() { return $this->_doList(); } protected function _lock() { $result = parent::_lock(); if (!$result) { $this->_setBackUrl($this->_getBackUrl(PARENT_PAGE_FINAL)); } return $result; } protected function _isLocked() { $result = parent::_isLocked(); if ($result) { $this->_setBackUrl($this->_getBackUrl(PARENT_PAGE_FINAL)); } return $result; } protected function _doEdit() { if (!$this->_lock()) { $this->_setBackAttention($this->_createMessage(static::MSG_LOCKED, $this->_getLocker())); $this->_doBack(); } return $this->_doList(); } protected function _doRemoveItem() { if ($this->_isLocked()) { $this->_setBackAttention($this->_createMessage(static::MSG_LOCKED, $this->_getLocker())); $this->_doBack(); } return parent::_doRemoveItem(); } protected function _doUpdateItemAjax() { if ($this->_isLocked()) { $response = array( 'success' => false, 'isLocked' => true, 'error' => $this->_createMessage(static::MSG_LOCKED, $this->_getLocker()) ); $this->_displayJson($response); } parent::_doUpdateItemAjax(); } protected function _initMessageTemplates() { $this->_messageTemplates[self::ERR_EMPTY_CART] = 'The Shopping Cart must have products.'; return $this; } protected function _getDefaultLinks() { $links = array(); if (!$this->getPreviewMode()) { if (false !== array_search('new', $this->_actions)) { $links['new'] = array( 'title' => '+ Add Products', 'attribs' => array( 'onclick' => 'return false;', 'id' => 'add-products-link', 'class' => 'btn' ), 'url' => '#' ); } } return $links; } protected function _doList() { $this->_addScript(); return parent::_doList(); } protected function _addScript() { $this->_doc->addStylesheet('css/thirdpart/jquery-ui.css'); $this->_doc->addScript('js/jquery.blockUI.js'); $this->_doc->addScript('js/jquery-autoNumeric.js'); $this->_doc->addScript('js/jquery-ui.js'); $this->_doc->addScript('js/app/ECommerce/order/admin.js'); $params = array( 'addToCartUrl' => Qs_SiteMap::findFirst('', 'url'), 'url' => Qs_SiteMap::findFirst('', 'url') . '?action=init', 'cartId' => $this->_getDataObj()->getPrimaryKey() ); $this->_doc->addInitObject('App_ECommerce_Order_Admin', array($params)); return $this; } /** * Get list item. Add cart summary info. * * @internal param null $list * @return array|null */ protected function _getListItem() { $list = parent::_getListItem(); $orderObj = new App_ECommerce_Order_Obj(); $orderObj->setPrimaryKey($this->_getDataObj()->getData('transactionId')); $list['shoppingCartSummary'] = $orderObj->getData('subtotal'); return $list; } protected function _postList() { if (!$this->getPreviewMode()) { $form = $this->_getControlForm(); if (!(bool) $this->_getDataObj()->getItemsCount()) { $form->removeElement('btnSubmit'); } $this->_addFormItem($form); } return parent::_postList(); } protected function _getControlForm(array $options = array()) { return $this->_getFormInstance('control', $options); } protected function _doNext() { if ($this->_isLocked()) { $this->_setBackAttention($this->_createMessage(static::MSG_LOCKED, $this->_getLocker())); $this->_doBack(); } $form = $this->_getControlForm(); $tabs = App_ECommerce_Order_Admin_View::getTabs(); if ($this->_validateStep($form)) { $url = BASE_URL_LANGUAGE . '/' . $tabs->getNextTabAlias(); $this->redirect($url); } else { $this->_setBackUrl($this->url()); $this->_setBackError(self::ERR_EMPTY_CART); $this->_doBack(); } return $this; } protected function _validateStep(App_ECommerce_Order_Admin_Product_Form_Control $form) { $result = $form->validate(); if ($this->_getDataObj()->getItemsCount() == 0) { $result = false; } return $result; } protected function _doCancel() { $orderUrl = Qs_SiteMap::findFirst('', 'url'); if ($this->getRestParam(0) == 'new') { $orderUrl .= '?action=cancelOrder&id=' . $this->getRestParam(1); } $this->_setBackUrl($orderUrl); parent::_doCancel(); } }