Пример #1
0
 public function indexAction()
 {
     if (($response = parent::indexAction()) instanceof Response) {
         return $response;
     }
     $form = new Form(package_path('Designs', 'Resources/forms/admin/index-filters.php'));
     $form->populate($this->view->filters);
     $this->view->assign('form', $form);
 }
Пример #2
0
 public function indexAction()
 {
     if (($response = parent::indexAction()) instanceof Response) {
         return $response;
     }
     $form = new Form(module_path('Brands', '/Resources/forms/admin/expired-filters.php'));
     $form->populate($this->view->filters);
     $this->view->assign('form', $form);
 }
Пример #3
0
 public function indexAction()
 {
     if (($response = parent::indexAction()) instanceof Response) {
         return $response;
     }
     if ($this->request->isPost()) {
         $post = $this->request->getPost();
         if (isset($post['btnWizzard'])) {
             return new RedirectResponse(route(\null, ['action' => 'wizzard', 'id' => \null, 'page' => \null]));
         }
     }
     $form = new Form(package_path('Brands', 'Resources/forms/admin/index-filters.php'));
     $form->populate($this->view->filters);
     $this->view->assign('form', $form);
 }
Пример #4
0
 public function brandsAction()
 {
     $filters = parent::handleFilters();
     if ($filters instanceof Response) {
         return $filters;
     }
     $form = new Form(package_path('Brands', 'Resources/forms/admin/reports-brands-filters.php'));
     $form->populate($filters);
     $brands = array();
     $brandImages = array();
     if (isset($filters['brandId'])) {
         $brandsModel = new Brands();
         $brandsModel->addWhere('name', $filters['brandId']);
         if (isset($filters['date']) && $filters['date']) {
             try {
                 $date = new \DateTime($filters['date']);
                 $statusDate = $date->format('Y-m-d');
                 //$brandsModel->addWhere(new Expr('statusDate <= "' . $brandsModel->getAdapter()->quote($statusDate) . '"'));
             } catch (\Exception $e) {
             }
         }
         $brandsRows = $brandsModel->getItems();
         foreach ($brandsRows as $brandRow) {
             if (!isset($brands[$brandRow['countryId']])) {
                 $brands[$brandRow['countryId']] = array();
             }
             $brands[$brandRow['countryId']][$brandRow['typeId']] = $brandRow;
             if (!isset($brandImages[$brandRow['typeId']])) {
                 if ($brandRow->getThumb()) {
                     $brandImages[$brandRow['typeId']] = array('path' => $brandRow->getThumb(), 'image' => 'uploads/brands/thumbs/' . $brandRow->getId() . '.' . pathinfo($brandRow->getImage(), PATHINFO_EXTENSION), 'real' => 'uploads/brands/' . $brandRow->getId() . '.' . pathinfo($brandRow->getImage(), PATHINFO_EXTENSION));
                 }
             }
         }
     }
     if (empty($brands)) {
         return ['form' => $form, 'brands' => $brands];
     }
     $currentCurrency = null;
     if (isset($filters['currency'])) {
         $currencyModel = new Currencies();
         $currentCurrency = $currencyModel->find((int) $filters['currency']);
     }
     $nomContinents = new Continents();
     $continents = $nomContinents->fetchCachedPairs(array('active' => 1), null, array('id' => 'ASC'));
     $nomTypes = new Types();
     $types = $nomTypes->fetchCachedPairs(['active' => 1], null, ['id' => 'ASC']);
     $nomCountries = new Countries();
     $nomCountries->addWhere('active', '1');
     $nomCountries->addOrder('name', 'ASC');
     $countriesRows = $nomCountries->getItems();
     $countries = array();
     $populations = array();
     foreach ($countriesRows as $countryRow) {
         if (empty($countryRow['continentId'])) {
             continue;
         }
         /**
          * Създаване на списъци от държави за континент
          */
         if (!isset($countries[$countryRow['continentId']])) {
             $countries[$countryRow['continentId']] = array();
         }
         $countries[$countryRow['continentId']][$countryRow['id']] = $countryRow;
         /**
          * Изчисляване на популацията за континент
          */
         if (!isset($populations[$countryRow['continentId']])) {
             $populations[$countryRow['continentId']] = 0;
         }
         $populations[$countryRow['continentId']] += $countryRow['population'];
     }
     $nomStatus = new Statuses();
     $statuses = $nomStatus->fetchCachedPairs();
     $nomStatus->resetSelect(true);
     $statusesColors = $nomStatus->fetchCachedPairs(null, array('id', 'color'));
     return ['form' => $form, 'continents' => $continents, 'populations' => $populations, 'types' => $types, 'countries' => $countries, 'brands' => $brands, 'brandImages' => $brandImages, 'statuses' => $statuses, 'statusesColors' => $statusesColors, 'filters' => $filters, 'currentCurrency' => $currentCurrency];
 }