/** * @param array $args * @return string */ public function renderAdminPosition($args = array()) { // init vars $elements = array(); $output = array(); $style = isset($args['style']) ? $args['style'] : 'adminedit'; $layout = $this->_layout; $this->_order = isset($args['order']) ? $args['order'] : $this->_order; $fields = $this->_order->getFields(); // render elements foreach ($fields as $identifier => $data) { if ($element = $this->_order->getFieldElement($identifier)) { $element->bindData($data); $data['_layout'] = $this->_layout; $data['_index'] = $identifier; // set params $params = array_merge((array) $data, $args); // check value $elements[] = compact('element', 'params'); } } foreach ($elements as $i => $data) { $output[$i] = parent::render('element.' . $style, array('element' => $data['element'], 'params' => array_merge(array('first' => $i == 0, 'last' => $i == count($elements) - 1), $data['params']))); } // restore layout $this->_layout = $layout; return implode(PHP_EOL, $output); }
/** * @param JBCartOrder $order * @param bool|false $silentMode * @return int|mixed */ public function save(JBCartOrder $order, $silentMode = false) { $this->app->jbtables->checkOrder(); $currencies = $order->getCurrencyList(); $params = $order->getParams(); $params->set(JBCart::CONFIG_CURRENCIES, $currencies); $cartConfig = $order->params->find('config'); if (!$cartConfig) { $cartConfig = JBModelConfig::model()->getGroup('cart.config'); } $params->set('config', (array) $cartConfig); $total = $order->getTotalSum()->data(); $data = array('id' => $order->id, 'status' => $order->getStatus()->getCode(), 'status_payment' => $order->getPaymentStatus(), 'status_shipping' => $order->getShippingStatus(), 'created' => $order->created, 'created_by' => $order->created_by, 'total' => $total[0], 'items' => $order->getItems(false), 'fields' => $order->getFields(), 'shippingfields' => $order->getShippingFields(), 'modifiers' => $order->getModifiersData(), 'params' => $params, 'comment' => $order->comment); if ($shipping = $order->getShipping()) { $data['shipping'] = $shipping->data(); } if ($payment = $order->getPayment()) { $data['payment'] = $payment->data(); } if (!$silentMode) { $this->app->jbevent->fire($order, 'basket:beforeSave'); } if ($data['id'] <= 0) { unset($data['id']); $order->id = $this->_insert($data, ZOO_TABLE_JBZOO_ORDER); //TODO hardcoded $order->setItemsData((string) $data['items']); if (!$silentMode) { $this->app->jbevent->fire($order, 'basket:saved'); } } else { $data['modified'] = $this->app->jbdate->toMySql(); $this->_update($data, ZOO_TABLE_JBZOO_ORDER); if (!$silentMode) { $this->app->jbevent->fire($order, 'basket:updated'); } } if ($order->id && !$silentMode) { $this->app->jbevent->fire($order, 'basket:afterSave'); } return $order->id; }