Example #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];
 }
Example #2
0
<?php

use Nomenclatures\Model;
$nomTypes = new Model\Types();
$nomNotifiers = new Model\Notifiers();
$nomStatuses = new Model\Statuses();
$nomClasses = new Model\BrandClasses();
$nomCountries = new Model\Countries();
return array('elements' => array('name' => array('type' => 'text', 'options' => array('label' => 'Име', 'labelClass' => 'control-label', 'required' => 1, 'class' => 'form-control')), 'countryId' => array('type' => 'select', 'options' => array('label' => 'Държава', 'labelClass' => 'control-label', 'required' => 1, 'class' => 'form-control selectpicker', 'emptyOption' => 'Избери', 'multiOptions' => $nomCountries->fetchCachedPairs(null, null, array('name' => 'asc')))), 'typeId' => array('type' => 'select', 'options' => array('label' => 'Тип на марката', 'labelClass' => 'control-label', 'required' => 1, 'class' => 'form-control', 'emptyOption' => 'Избери', 'multiOptions' => $nomTypes->fetchCachedPairs())), 'statusId' => array('type' => 'select', 'options' => array('label' => 'Статус на марката', 'labelClass' => 'control-label', 'class' => 'form-control', 'emptyOption' => 'Избери', 'multiOptions' => $nomStatuses->fetchCachedPairs())), 'statusDate' => array('type' => 'datepicker', 'options' => array('format' => 'd.m.Y', 'label' => 'Дата за статуса', 'labelClass' => 'control-label', 'class' => 'datepicker form-control')), 'statusNote' => array('type' => 'textarea', 'options' => array('label' => 'Пояснение', 'labelClass' => 'control-label', 'class' => 'form-control', 'attributes' => array('rows' => 5))), 'notifierId' => array('type' => 'select', 'options' => array('label' => 'Заявител', 'labelClass' => 'control-label', 'required' => 1, 'class' => 'form-control', 'emptyOption' => 'Избери', 'multiOptions' => $nomNotifiers->fetchCachedPairs())), 'classes' => array('type' => 'select', 'options' => array('label' => 'Класове', 'labelClass' => 'control-label', 'required' => 1, 'isArray' => 1, 'class' => 'form-control', 'multiOptions' => $nomClasses->fetchCachedPairs(), 'attributes' => array('style' => 'height: 200px'))), 'active' => array('type' => 'checkbox', 'options' => array('label' => 'Активност', 'labelClass' => 'control-label')), 'requestNum' => array('type' => 'text', 'options' => array('required' => 1, 'label' => 'Номер на заяваване', 'labelClass' => 'control-label', 'class' => 'form-control')), 'requestDate' => array('type' => 'datepicker', 'options' => array('format' => 'd.m.Y', 'required' => 1, 'label' => 'Дата на заявяване', 'labelClass' => 'control-label', 'class' => 'datepicker form-control')), 'registerNum' => array('type' => 'text', 'options' => array('label' => 'Номер на регистрация', 'labelClass' => 'control-label', 'class' => 'form-control')), 'registerDate' => array('type' => 'datepicker', 'options' => array('format' => 'd.m.Y', 'label' => 'Дата на регистрация', 'labelClass' => 'control-label', 'class' => 'datepicker form-control')), 'description' => array('type' => 'textarea', 'options' => array('label' => 'Информация', 'labelClass' => 'control-label', 'class' => 'form-control summernote', 'attributes' => array('rows' => 5))), 'price' => array('type' => 'text', 'options' => array('label' => 'Цена', 'labelClass' => 'control-label', 'class' => 'form-control')), 'btnSave' => ['type' => 'submit', 'options' => ['value' => 'Запазване', 'class' => 'btn btn-primary']], 'btnApply' => ['type' => 'submit', 'options' => ['value' => 'Прилагане', 'class' => 'btn btn-success']], 'btnBack' => ['type' => 'submit', 'options' => ['value' => 'Назад', 'class' => 'btn btn-default']]));
Example #3
0
<?php

use Nomenclatures\Model;
$nomTypes = new Model\Types();
$nomNotifiers = new Model\Notifiers();
$nomStatuses = new Model\Statuses();
$nomClasses = new Model\BrandClasses();
$nomCountries = new Model\Countries();
return array('elements' => array('name' => array('type' => 'text', 'options' => array('label' => 'Име', 'labelClass' => 'control-label', 'class' => 'form-control', 'belongsTo' => 'filters')), 'countryId' => array('type' => 'select', 'options' => array('label' => 'Държава', 'labelClass' => 'control-label', 'isArray' => 1, 'class' => 'form-control selectpicker', 'belongsTo' => 'filters', 'multiOptions' => $nomCountries->fetchCachedPairs(null, null, array('name' => 'asc')))), 'typeId' => array('type' => 'select', 'options' => array('label' => 'Тип', 'labelClass' => 'control-label', 'class' => 'form-control', 'emptyOption' => 'Избери', 'belongsTo' => 'filters', 'multiOptions' => $nomTypes->fetchCachedPairs())), 'statusId' => array('type' => 'select', 'options' => array('label' => 'Статус', 'labelClass' => 'control-label', 'class' => 'form-control', 'emptyOption' => 'Избери', 'belongsTo' => 'filters', 'multiOptions' => $nomStatuses->fetchCachedPairs())), 'notifierId' => array('type' => 'select', 'options' => array('label' => 'Заявител', 'labelClass' => 'control-label', 'class' => 'form-control', 'emptyOption' => 'Избери', 'belongsTo' => 'filters', 'multiOptions' => $nomNotifiers->fetchCachedPairs())), 'classes' => array('type' => 'select', 'options' => array('label' => 'Класове', 'labelClass' => 'control-label', 'class' => 'form-control', 'emptyOption' => 'Избери', 'belongsTo' => 'filters', 'multiOptions' => $nomClasses->fetchCachedPairs())), 'requestNum' => array('type' => 'text', 'options' => array('belongsTo' => 'filters', 'label' => 'Номер на заяваване', 'labelClass' => 'control-label', 'class' => 'form-control')), 'registerNum' => array('type' => 'text', 'options' => array('belongsTo' => 'filters', 'label' => 'Номер на регистрация', 'labelClass' => 'control-label', 'class' => 'form-control')), 'months' => array('type' => 'text', 'options' => array('belongsTo' => 'filters', 'label' => 'Брой месеци до изтичане', 'labelClass' => 'control-label', 'class' => 'form-control'))));
Example #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];
 }