public function backendOrders() { $view = wa()->getView(); $plugin_model = new shopPluginModel(); $workflow = new shopWorkflow(); $view->assign('states', $workflow->getAvailableStates()); $view->assign('payments', $plugin_model->listPlugins(shopPluginModel::TYPE_PAYMENT)); $view->assign('shippings', $plugin_model->listPlugins(shopPluginModel::TYPE_SHIPPING)); return array('sidebar_section' => $view->fetch($this->path . '/templates/actions/backend/BackendOrders.html')); }
public function execute() { $model_settings = new waAppSettingsModel(); $settings = $model_settings->get($key = array('shop', 'orderstock')); $workflow = new shopWorkflow(); $state_names = array(); foreach ($workflow->getAvailableStates() as $state_id => $state) { $state_names[$state_id] = $state['name']; } $this->view->assign('state_names', $state_names); $this->view->assign('settings', $settings); }
public function execute() { $workflow = new shopWorkflow(); $modelNotifierConfig = new shopNotifierConfigModel(); $modelNotifierTemplate = new shopNotifierTemplateModel(); $state_names = array(); foreach ($workflow->getAvailableStates() as $state_id => $state) { $state_names[$state_id] = $state['name']; } $all_notifications = $modelNotifierConfig->getAll(); $templates = $modelNotifierTemplate->getAll(); // timestamp // $time = strtotime('2015-04-01 18:11:44'); // $day = strtotime('+20 minute', $time); // print_r(date('Y-m-d H:i:s', $day)); $this->view->assign('cron', array('command' => 'php ' . wa()->getConfig()->getRootPath() . '/cli.php shop notifierCheck')); $this->view->assign('state_names', $state_names); $this->view->assign('templates', $templates); $this->view->assign('all_notifications', $all_notifications); // $this->view->assign('settings', $settings); }
public function execute() { $config = $this->getConfig(); $default_view = $config->getOption('orders_default_view'); $view = waRequest::get('view', $default_view, waRequest::TYPE_STRING_TRIM); $orders = $this->getOrders(0, $this->getCount()); $action_ids = array_flip(array('process', 'pay', 'ship', 'complete', 'delete', 'restore')); $workflow = new shopWorkflow(); $actions = array(); foreach ($workflow->getAllActions() as $action) { if (isset($action_ids[$action->id])) { $actions[$action->id] = array('name' => $action->name, 'style' => $action->getOption('style')); } } $state_names = array(); foreach ($workflow->getAvailableStates() as $state_id => $state) { $state_names[$state_id] = $state['name']; } $counters = array('state_counters' => array('new' => $this->model->getStateCounters('new'))); $filter_params = $this->getFilterParams(); if (isset($filter_params['state_id'])) { $filter_params['state_id'] = (array) $filter_params['state_id']; sort($filter_params['state_id']); if ($filter_params['state_id'] == array('new', 'paid', 'processing')) { $total = 0; foreach ($filter_params['state_id'] as $st) { $total += (int) $this->model->getStateCounters($st); } $counters['common_counters'] = array('pending' => $total); } else { foreach ($filter_params['state_id'] as $st) { $counters['state_counters'][$st] = (int) $this->model->getStateCounters($st); } } } else { $counters['common_counters'] = array('all' => $this->model->countAll()); } $this->assign(array('orders' => array_values($orders), 'total_count' => $this->getTotalCount(), 'count' => count($orders), 'order' => $this->getOrder($orders), 'currency' => $this->getConfig()->getCurrency(), 'state_names' => $state_names, 'params' => $this->getFilterParams(), 'params_str' => $this->getFilterParams(true), 'view' => $view, 'timeout' => $config->getOption('orders_update_list'), 'actions' => $actions, 'counters' => $counters)); }
/** * @param int|null $state_id If null return counters for each state in assoc array * @return int|array */ public function getStateCounters($state_id = null) { $where = ""; if ($state_id !== null) { $where = "WHERE " . $this->getWhereByField('state_id', $state_id); } $sql = "\n SELECT state_id, COUNT(state_id) cnt FROM `{$this->table}`\n {$where} GROUP BY state_id"; $r = $this->query($sql); if ($state_id !== null) { $cnt = $r->fetchField('cnt'); return $cnt ? $cnt : 0; } $counters = array(); $workflow = new shopWorkflow(); foreach (array_keys($workflow->getAvailableStates()) as $state_id) { $counters[$state_id] = 0; } $counters = $r->fetchAll('state_id', true) + $counters; return $counters ? $counters : array(); }