_getDataObj()->setFormDataFields($form); $this->_getDataObj()->clearData(); // verify if data exist and remove userId field $billingClearData = array(); foreach ($this->_getDataObj()->getData('billing') as $field => $value) { if (!empty($value)) { $billingClearData[$field] = $value; } } if (!empty($billingClearData)) { $form->removeElement('userId'); } return $form; } protected function _doNew() { $session = $this->_getSession(App_ECommerce_Order_Admin_Payment_View::PAYMENT_SESSION_NAME); $session->{$this->_getDataObj()->getPrimaryKey()} = null; $form = $this->_getNewForm(); $data = $this->_getDataObj()->getData(); $form->setDefaults($data); $this->_addFormItem($form); $this->_postNew(); return $this; } protected function _doAutocompleteUsers() { $this->_doc->display404(); } protected function _doAutocompleteUsersAjax() { $term = trim(Qs_Request::getRequestValue('term')); $result = array(); if (!empty($term)) { $result = $this->_getDataObj()->getUsers4Autocomplete($term); } $this->_displayJson($result); } protected function _doGetUserData() { $this->_doc->display404(); } protected function _doGetUserDataAjax() { $userId = Qs_Request::getRequestValue('userId'); $result = array( 'success' => false ); if ($userId) { $userObj = new App_User_Admin_Obj(); $userObj->setPrimaryKey($userId); if (($data = $userObj->getData()) !== null) { unset( $data['id'], $data['added'], $data['changed'], $data['salt'], $data['password'], $data['recoverCode'], $data['recoverCodeExpirationDate'], $data['autologinCode'] ); $result = array( 'success' => true, 'data' => $data ); } } $this->_displayJson($result); } protected function _doNext() { if ($this->_isLocked()) { $this->_setBackAttention($this->_createMessage(static::MSG_LOCKED, $this->_getLocker())); $this->_doBack(); } $form = $this->_getNewForm(); if ($form->validate()) { $data = $form->getValues(); $orderData = $this->_prepareShippingPaymentData($data); $this->_getDataObj()->initFromForm($orderData); if (false === $this->_getDataObj()->update()) { $this->_setBackUrl(Qs_SiteMap::findFirst(null, array('type' => 'ECommerce_Order_Admin_'), null, 'url')); $this->_setBackErrors($this->_getDataObj()->getErrors()); $this->_doBack(); } else { $this->_postInsert(); } if (!empty($data['userId'])) { $this->_getCart()->update(array('userId' => $data['userId'])); } $url = BASE_URL_LANGUAGE . '/' . App_ECommerce_Order_Admin_View::getTabs()->getNextTabAlias(); $this->redirect($url); } $this->_addFormItem($form); return $this; } }