Пример #1
0
 function display($tpl = null)
 {
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2store' . DS . 'library' . DS . 'prices.php';
     $mainframe = JFactory::getApplication();
     $option = 'com_k2store';
     $ns = $option . '.orders';
     $db = JFactory::getDBO();
     $uri = JFactory::getURI();
     $filter_order = $mainframe->getUserStateFromRequest($ns . 'filter_order', 'filter_order', 'a.id', 'cmd');
     $filter_order_Dir = $mainframe->getUserStateFromRequest($ns . 'filter_order_Dir', 'filter_order_Dir', '', 'word');
     $filter_orderstate = $mainframe->getUserStateFromRequest($ns . 'filter_orderstate', 'filter_orderstate', '', 'string');
     $search = $mainframe->getUserStateFromRequest($ns . 'search', 'search', '', 'string');
     if (strpos($search, '"') !== false) {
         $search = str_replace(array('=', '<'), '', $search);
     }
     $search = JString::strtolower($search);
     // Get data from the model
     $items = $this->get('Data');
     $total = $this->get('Total');
     $pagination = $this->get('Pagination');
     $javascript = 'onchange="document.adminForm.submit();"';
     require_once JPATH_ADMINISTRATOR . '/components/com_k2store/models/orderstatuses.php';
     $os_model = new K2StoreModelOrderstatuses();
     $statuses = $os_model->getOrderStatuses();
     $filter_orderstate_options[] = JHTML::_('select.option', 0, JText::_('K2STORE_ORDER_SELECT_STATE'));
     foreach ($statuses as $status) {
         //order state filter
         $filter_orderstate_options[] = JHTML::_('select.option', $status->orderstatus_id, JText::_($status->orderstatus_name));
     }
     $lists['orderstate'] = JHTML::_('select.genericlist', $filter_orderstate_options, 'filter_orderstate', $javascript, 'value', 'text', $filter_orderstate);
     // table ordering
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     // search filter
     $lists['search'] = $search;
     $this->assignRef('lists', $lists);
     $this->assignRef('items', $items);
     $this->assignRef('pagination', $pagination);
     //$model = $this->getModel();
     $params = JComponentHelper::getParams('com_k2store');
     $this->assignRef('params', $params);
     $this->addToolBar();
     $toolbar = new K2StoreToolBar();
     $toolbar->renderLinkbar();
     parent::display($tpl);
 }
Пример #2
0
 function orderstatesave()
 {
     $app = JFactory::getApplication();
     $id = $app->input->getInt('id', 0);
     $order_state_id = $app->input->getInt('order_state_id', 0);
     $notify_customer = $app->input->getInt('notify_customer', 0);
     // $status_values = array(1 => JText::_('K2STORE_Confirmed'), 3 => JText::_('K2STORE_Failed'), 4 => JText::_('K2STORE_Pending'));
     if (isset($order_state_id) && $order_state_id > 0) {
         require_once JPATH_ADMINISTRATOR . '/components/com_k2store/models/orderstatuses.php';
         $os_model = new K2StoreModelOrderstatuses();
         $order_state = $os_model->getOrderStateByID($order_state_id)->orderstatus_name;
         JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2store/tables');
         $order = JTable::getInstance('Orders', 'Table');
         $order->load($id);
         if ($order->id == $id) {
             //lets change the status
             $order->order_state = $order_state;
             $order->order_state_id = $order_state_id;
             if ($order->store()) {
                 $msg = JText::_('K2STORE_ORDER_STATUS_UPDATE_SUCCESSFUL');
                 if (isset($notify_customer) && $notify_customer == 1) {
                     require_once JPATH_SITE . '/components/com_k2store/helpers/orders.php';
                     K2StoreOrdersHelper::sendUserEmail($order->user_id, $order->order_id, $order->transaction_status, $order->order_state, $order->order_state_id);
                 } else {
                     require_once JPATH_ADMINISTRATOR . '/components/com_k2store/library/inventory.php';
                     K2StoreInventory::setInventory($order->id, $order_state_id);
                 }
             } else {
                 $msg = JText::_('K2STORE_ORDER_STATUS_UPDATE_FAILED');
             }
         } else {
             $msg = JText::_('K2STORE_ORDER_STATUS_UPDATE_FAILED');
         }
     } else {
         $msg = JText::_('K2STORE_CHOOSE_AN_ORDER_STATUS');
     }
     $link = 'index.php?option=com_k2store&view=orders&task=view&id=' . $order->id;
     $this->setRedirect($link, $msg);
 }