di = $di; } /** * @return mixed */ public function getDi() { return $this->di; } public function fetchNavigation() { return [ 'group' => [ 'index' => 300, 'location' => 'order', 'label' => __trans('Orders'), 'uri' => $this->di['url']->adminLink('order'), 'class' => 'orders', 'sprite_class' => 'dark-sprite-icon sprite-basket', ], 'subpages' => [ [ 'location' => 'order', 'index' => 100, 'label' => __trans('Overview'), 'uri' => $this->di['url']->adminLink('order'), 'class' => '', ], [ 'location' => 'order', 'index' => 200, 'label' => __trans('Advanced search'), 'uri' => $this->di['url']->adminLink('order', ['show_filter' => 1]), 'class' => '', ], ], ]; } public function register(\Box_App &$app) { $app->get('/order', 'get_index', [], static::class); $app->get('/order/', 'get_index', [], static::class); $app->get('/order/index', 'get_index', [], static::class); $app->get('/order/manage/:id', 'get_order', ['id' => '[0-9]+'], static::class); $app->post('/order/new', 'get_new', [], static::class); } public function get_index(\Box_App $app) { $this->di['is_admin_logged']; return $app->render('mod_order_index'); } public function get_new(\Box_App $app) { $api = $this->di['api_admin']; $product = $api->product_get(['id' => $_POST['product_id'] ?? null]); $client = $api->client_get(['id' => $_POST['client_id'] ?? null]); return $app->render('mod_order_new', ['product' => $product, 'client' => $client]); } public function get_order(\Box_App $app, $id) { $api = $this->di['api_admin']; $data = [ 'id' => $id, ]; $order = $api->order_get($data); $set = ['order' => $order]; if (isset($order['plugin']) && !empty($order['plugin'])) { $set['plugin'] = 'plugin_' . $order['plugin'] . '_manage.html.twig'; } return $app->render('mod_order_manage', $set); } }