function display($tpl = null) { require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_j2store' . DS . 'library' . DS . 'prices.php'; $mainframe = JFactory::getApplication(); $option = 'com_j2store'; $ns = $option . '.orders'; $db = JFactory::getDBO(); $uri = JFactory::getURI(); $task = $mainframe->input->getWord('task', ''); $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_j2store/models/orderstatuses.php'; $os_model = new J2StoreModelOrderstatuses(); $statuses = $os_model->getOrderStatuses(); $filter_orderstate_options[] = JHTML::_('select.option', 0, JText::_('J2STORE_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); //get the select list; require_once JPATH_ADMINISTRATOR . '/components/com_j2store/models/orderstatuses.php'; $os_model = new J2StoreModelOrderstatuses(); $statuses = $os_model->getOrderStatuses(); $options = array(); $options[] = JHTML::_('select.option', '', JText::_('J2STORE_ORDER_SELECT_STATE')); foreach ($statuses as $status) { $options[] = JHTML::_('select.option', $status->orderstatus_id, JText::_($status->orderstatus_name)); } $this->assign('orderstate_options', $options); $this->params = $params = JComponentHelper::getParams('com_j2store'); $this->addToolBar(); if ($task != 'printOrder' && $task != 'viewtxnlog') { $toolbar = new J2StoreToolBar(); $toolbar->renderLinkbar(); } parent::display($tpl); }
public function getInput() { require_once JPATH_ADMINISTRATOR . '/components/com_j2store/models/orderstatuses.php'; $model = new J2StoreModelOrderstatuses(); $orderlist = $model->getItems(); //generate country filter list $orderstatus_options = array(); $orderstatus_options[] = JHTML::_('select.option', '*', JText::_('JALL')); foreach ($orderlist as $row) { $orderstatus_options[] = JHTML::_('select.option', $row->orderstatus_id, JText::_($row->orderstatus_name)); } return JHTML::_('select.genericlist', $orderstatus_options, $this->name, 'onchange=', 'value', 'text', $this->value); }
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); if (isset($order_state_id) && $order_state_id > 0) { require_once JPATH_ADMINISTRATOR . '/components/com_j2store/models/orderstatuses.php'; $os_model = new J2StoreModelOrderstatuses(); $order_state = $os_model->getOrderStateByID($order_state_id)->orderstatus_name; JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/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::_('J2STORE_ORDER_STATUS_UPDATE_SUCCESSFUL'); if (isset($notify_customer) && $notify_customer == 1) { require_once JPATH_SITE . '/components/com_j2store/helpers/orders.php'; J2StoreOrdersHelper::sendUserEmail($order->user_id, $order->order_id, $order->transaction_status, $order->order_state, $order->order_state_id); } else { require_once JPATH_ADMINISTRATOR . '/components/com_j2store/library/inventory.php'; J2StoreInventory::setInventory($order->id, $order_state_id); } } else { $msg = JText::_('J2STORE_ORDER_STATUS_UPDATE_FAILED'); } } else { $msg = JText::_('J2STORE_ORDER_STATUS_UPDATE_FAILED'); } } else { $msg = JText::_('J2STORE_CHOOSE_AN_ORDER_STATUS'); } $link = 'index.php?option=com_j2store&view=orders&task=view&id=' . $order->id; $return = $app->input->getString('return'); if (isset($return) && !empty($return)) { $json = array(); $json['success']['link'] = 'index.php?option=com_j2store&view=orders'; echo json_encode($json); $app->close(); } else { $this->setRedirect($link, $msg); } }