/** * Init controller */ protected function _init() { $this->app->jbdoc->noindex(); $this->_orderModel = JBModelOrder::model(); $this->_jbmoney = $this->app->jbmoney; $this->_orderInfo = $this->app->jbcartpayment->getInfoByRequest(); $orderId = $this->_orderInfo->get('id'); if ($orderId > 0) { $this->order = $this->_orderModel->getById($orderId); } else { $this->_error('Variable name with order ID was not found'); } if (empty($this->order)) { $this->_error('Order #' . $orderId . ' not found'); } $application = $this->app->zoo->getApplication(); $this->template = $application->getTemplate(); }
/** * Order list */ public function order() { $this->init(); $orderId = $this->app->jbrequest->get('order_id'); $this->order = JBModelOrder::model()->getById($orderId); $this->formRenderer = $this->app->jbrenderer->create('Order'); $this->shippingRenderer = $this->app->jbrenderer->create('Shipping'); $this->shippingFieldsRenderer = $this->app->jbrenderer->create('ShippingFields'); if (!$this->order || $this->_user->id != $this->order->created_by) { $this->app->jbnotify->error('JBZOO_CLIENTAREA_ORDER_NOT_FOUND'); } $this->getView('clientarea_order')->addTemplatePath($this->template->getPath())->setLayout('clientarea_order')->display(); }
/** * @return array */ public function getExistsUsers() { $rows = JBModelOrder::model()->getUserList(); $result = array(); if (!empty($rows)) { foreach ($rows as $row) { if ($row->user_id > 0) { $result[$row->user_id] = $row->user_name; } else { $result[$row->created_by] = 'undefined id:' . $row->created_by; } } } return $result; }
/** * Convert order to new format * @param $page * @return bool */ public function convertItems($page) { $this->_migrate = $this->app->jbmigrate; $params = $this->_migrate->getParams(); $this->_fields = $this->_migrate->getOrderFields(); $this->_statusList = $this->_getStatusList(); $realStep = $page - $params->find('steps.system_steps'); $size = $params->find('steps.step'); if ($realStep <= 0) { return -1; } $orders = JBModelItem::model()->getList($params->get('app'), null, $params->get('type'), array('limit' => array(($realStep - 1) * $size, $size), 'published' => 0, 'state' => -1, 'order' => 'id')); if (count($orders) > 0) { foreach ($orders as $order) { if ($newOrder = $this->_convertOrder($order)) { JBModelOrder::model()->save($newOrder, true); } } return $page + 1; } return false; }
/** * Method using to take data from element with ajax */ public function callElement() { // get request $group = $this->app->request->getCmd('group', ''); $elementId = $this->app->request->getCmd('element', ''); $orderId = $this->app->request->getInt('order_id', ''); $method = $this->app->request->getCmd('method', ''); $args = $this->app->request->getVar('args', array(), 'default', 'array'); if ($orderId > 0) { $order = JBModelOrder::model()->getById($orderId); } else { $order = JBCart::getInstance()->newOrder(); } if (empty($order)) { return $this->app->error->raiseError(404, JText::_('Order not found')); } // get element if ($group == JBCart::CONFIG_SHIPPINGS) { // custom init with session data $element = $order->getShippingElement($elementId); } elseif ($group == JBCart::CONFIG_MODIFIER_ORDER_PRICE) { // custom init with session data $element = $order->getModifierOrderPriceElement($elementId); } else { $element = $order->getElement($elementId, $group); } if (empty($element)) { return $this->app->error->raiseError(404, JText::_('Element not forund')); } if (!$element->canAccess($this->app->user->get())) { return $this->app->error->raiseError(403, JText::_('Unable to access item')); } $element->callback($method, $args); }
/** * @return array */ protected function _getOrdersList() { $result = array(); $model = JBModelOrder::model(); $list = $model->getList(array('limit' => 10)); if (!empty($list)) { foreach ($list as $id => $order) { $result[$id] = JText::sprintf('JBZOO_EMAILTMPL_PREVIEW_ORDERNAME', $order->getName()); } } return $result; }
/** * @param bool $isLink * @return JBCartOrder|string */ protected function _getRelatedOrder($isLink = false) { $order = JBModelOrder::model()->getById($this->get('order_id', 0)); if ($isLink) { $orderLink = JText::sprintf('JBZOO_JBDVERT_ORDER_UNDEFINED', $this->get('order_id', 0)); if ($order && $order->id) { $orderLink = $order->getUrl(null, 'full'); } return $orderLink; } return $order; }
<?php /** * JBZoo App is universal Joomla CCK, application for YooTheme Zoo component * @package jbzoo * @version 2.x Pro * @author JBZoo App http://jbzoo.com * @copyright Copyright (C) JBZoo.com, All rights reserved. * @license http://jbzoo.com/license-pro.php JBZoo Licence * @coder Denis Smetannikov <*****@*****.**> */ // no direct access defined('_JEXEC') or die('Restricted access'); $graphRows = JBModelOrder::model()->countByDate(); ?> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1.1", {packages: ["calendar"]}); google.setOnLoadCallback(drawChart); function drawChart() { var dataTable = new google.visualization.DataTable(); dataTable.addColumn({type: 'date', id: 'date'}); dataTable.addColumn({type: 'number', id: 'sales'}); dataTable.addRows([ <?php foreach ($graphRows as $row) { ?> [new Date(<?php echo $row->year;
/** * Get exists status list * @param string $group * @param JBCartOrder $order * @return array */ public function getExistsList($group = JBCart::STATUS_ORDER, JBCartOrder $order = null) { $rows = JBModelOrder::model()->getStatusList($group); $result = array(); if (!empty($rows)) { foreach ($rows as $row) { if ($element = $this->getByCode($row->status, JBCart::STATUS_ORDER, $order)) { $result[$row->status] = $element->getName(); } else { $result[$row->status] = $row->status; } } } return $result; }
/** * Remove orders */ public function remove() { //$this->app->session->checkToken() or jexit('Invalid Token'); // TODO fix token $cid = $this->app->request->get('cid', 'array', array()); if (count($cid) < 1) { $this->app->jbnotify->error('JBZOO_ADMIN_ORDER_NO_SELECTED'); } try { // delete items foreach ($cid as $id) { JBModelOrder::model()->removeById($id); } $msg = JText::_('JBZOO_ADMIN_ORDER_REMOVED'); } catch (AppException $e) { // raise notice on exception $this->app->jbnotify->warning(JText::_('JBZOO_ADMIN_ORDER_DELET_ERROR') . ' (' . $e . ')'); $msg = null; } $redirectUrl = $this->app->jbrouter->admin(array('controller' => 'jborder', 'task' => 'index')); $this->setRedirect($redirectUrl, $msg); }
/** * Set success payment status to order */ public function setSuccess() { $order = $this->getOrder(); $payment = $order->getPayment(); $cart = JBCart::getInstance(); if ($payment) { $successStatus = $cart->getPaymentSuccess(); $payment->setStatus($successStatus); JBModelOrder::model()->save($order); } }