Exemple #1
0
 public function allBrandsAction()
 {
     $filters = parent::handleFilters();
     if ($filters instanceof Response) {
         return $filters;
     }
     $ipp = max($this->ipp, $this->request->getParam('ipp', $this->ipp));
     $page = max(1, $this->request->getParam('page', 1));
     $selectedBrands = isset($filters['brands']) ? json_decode($filters['brands'], \true) : [];
     $form = new Form(package_path('Brands', 'Resources/forms/admin/reports-all-brands-filters.php'));
     $form->populate($filters);
     $brandsModel = new Brands();
     if (!empty($selectedBrands)) {
         $brandsModel->addWhere('name', $selectedBrands);
     }
     $brandsModel->addOrder('name');
     $brandsSelect = $brandsModel->getJoinSelect();
     $brandsSelect->joinInner('NomCountries', 'NomCountries.id = Brands.countryId', []);
     if (isset($filters['countryId']) && !empty($filters['countryId'])) {
         $brandsSelect->where('Brands.countryId IN(?)', $filters['countryId']);
     }
     if (isset($filters['continentId']) && !empty($filters['continentId'])) {
         $brandsSelect->where('NomCountries.continentId IN(?)', $filters['continentId']);
     }
     $grid = new Grid($brandsModel, package_path('Brands', 'Resources/grids/admin/reports/all-brands.php'));
     $grid->getRenderer()->setView($this->view);
     $grid->setIpp($ipp);
     $grid->setPageNumber($page);
     $nomStatuses = new \Nomenclatures\Model\Statuses();
     $this->view->assign('nomStatuses', $nomStatuses->fetchCachedPairs());
     return ['form' => $form, 'selectedBrands' => $selectedBrands, 'grid' => $grid];
 }
Exemple #2
0
 public function indexAction()
 {
     if ($this->request->isPost()) {
         $post = $this->request->getPost();
         if (isset($post['btnAdd'])) {
             return new RedirectResponse(route(\null, ['action' => 'add', 'id' => \null, 'page' => \null]));
         }
     }
     $model = new Users();
     $grid = new Grid($model, package_path('UserManagement', '/Resources/grids/admin/index.php'));
     $grid->getRenderer()->setView($this->view);
     return new View('admin/index/index', ['grid' => $grid]);
 }
Exemple #3
0
 /**
  * @return RedirectResponse|View
  */
 public function indexAction()
 {
     $module = $this->request->getParam('module');
     $controller = $this->request->getParam('controller');
     if ($this->request->isPost()) {
         if ($this->request->getPost('btnAdd')) {
             return new RedirectResponse(route(\null, ['action' => 'add', 'id' => \null, 'page' => \null]));
         }
     }
     if (($filters = $this->handleFilters()) instanceof Response) {
         return $filters;
     }
     $model = $this->getModel();
     if ($this->container->has('language') && ($language = $this->container->get('language')) instanceof LanguageInterface) {
         $model->addJoinCondition('languageId', $language->getId());
     }
     $model->addFilters($filters);
     // hook
     $this->modifyModel($filters);
     $ipp = max($this->ipp, $this->request->getParam('ipp', $this->ipp));
     $page = max(1, $this->request->getParam('page', 1));
     $sort = $this->request->getParam('sort', $model->getIdentifier() . '_DESC');
     $sortParts = explode('_', $sort);
     $orderField = array_shift($sortParts);
     $orderField = $orderField ?: $model->getIdentifier();
     $orderDir = array_shift($sortParts);
     $orderDir = $orderDir ? strtoupper($orderDir) : 'DESC';
     $model->addOrder($orderField, $orderDir);
     $grid = new Grid\Grid($model, module_path(ucfirst(Utils::camelize($module)), '/Resources/grids/' . ($this->scope ? $this->scope . '/' : '') . $controller . '.php'));
     $grid->getRenderer()->setView($this->view);
     $column = $grid->getColumn($orderField);
     if ($column instanceof Grid\Column) {
         $column->setSorted($orderDir);
     }
     $grid->setIpp($ipp);
     $grid->setPageNumber($page);
     $this->view->setTemplate(($this->scope ? $this->scope . '/' : '') . $controller . '/index');
     return $this->view->assign(['grid' => $grid, 'filters' => $filters]);
 }