コード例 #1
0
 public function referenceAction($reception = null)
 {
     $this->view->setVar("TopMenuSelected", 'work');
     $this->view->setVar("MenuSelected", 'reference');
     $this->view->setVar("MenuItemActive", $reception);
     $this->view->setVar("reference", 'countries');
     View::addMessages($this, [array('class' => 'alert-info', 'text' => "<p>Возможность изменять (добовлять, редактировать, удалять) информацию \"справочных таблиц\" базы данных. Эта информация используется в выподающих списках (ед. измерения, валюта, страны и т.д. ) для согласованной работы системы, так называемая низкоуровневая информация.</p>")]);
     if ($this->request->isPost()) {
         $post = $this->request->getPost();
         switch ($post['reference']) {
             case 'countries':
                 if ((bool) $post['add']) {
                     View::addMessages($this, [References::addCountries($post['add'])]);
                 }
                 if ((bool) $post['edit']) {
                     View::addMessages($this, [References::setCountries($post['edit'])]);
                 }
                 if ((bool) $post['delete']) {
                     View::addMessages($this, [References::deleteCountry($post['id'])]);
                 }
                 break;
             case 'currency':
                 if ((bool) $post['add']['name'] && (bool) $post['add']['short_name']) {
                     View::addMessages($this, [References::addCurrency($post['add']['name'], $post['add']['short_name'])]);
                 }
                 if ((bool) $post['edit']) {
                     View::addMessages($this, [References::setCurrency($post['edit'])]);
                 }
                 if ((bool) $post['delete']) {
                     View::addMessages($this, [References::deleteCurrency($post['id'])]);
                 }
                 break;
             case 'units':
                 if ((bool) $post['add']['name'] && (bool) $post['add']['short_name'] && (bool) $post['add']['type_id']) {
                     View::addMessages($this, [References::addUnits($post['add']['name'], $post['add']['short_name'], $post['add']['type_id'])]);
                 }
                 if ((bool) $post['edit']) {
                     View::addMessages($this, [References::setUnits($post['edit'])]);
                 }
                 if ((bool) $post['delete']) {
                     View::addMessages($this, [References::deleteUnits($post['id'])]);
                 }
                 break;
             case 'languages':
                 if ((bool) $post['add']['name'] && (bool) $post['add']['short_name']) {
                     View::addMessages($this, [References::addLanguages($post['add']['name'], $post['add']['short_name'])]);
                 }
                 if ((bool) $post['edit']) {
                     View::addMessages($this, [References::setLanguages($post['edit'])]);
                 }
                 if ((bool) $post['delete']) {
                     View::addMessages($this, [References::deleteLanguages($post['id'])]);
                 }
                 break;
             case 'packages_status':
                 if ((bool) $post['add']['name'] && (bool) $post['add']['description']) {
                     View::addMessages($this, [References::addPackageStatus($post['add']['name'], $post['add']['description'])]);
                 }
                 if ((bool) $post['edit']) {
                     View::addMessages($this, [References::setPackageStatus($post['edit'])]);
                 }
                 if ((bool) $post['delete']) {
                     View::addMessages($this, [References::deletePackageStatus($post['id'])]);
                 }
                 break;
             case 'stations_status':
                 if ((bool) $post['add']['name'] && (bool) $post['add']['description']) {
                     View::addMessages($this, [References::addStationsStatus($post['add']['name'], $post['add']['description'])]);
                 }
                 if ((bool) $post['edit']) {
                     View::addMessages($this, [References::setStationsStatus($post['edit'])]);
                 }
                 if ((bool) $post['delete']) {
                     View::addMessages($this, [References::deleteStationsStatus($post['id'])]);
                 }
                 break;
         }
         $this->view->setVar("reference", $post['reference']);
     }
     $this->view->setVar("CountriesAll", References::getCountries());
     $this->view->setVar("CurrencyAll", References::getCurrency());
     $this->view->setVar("UnitsAll", References::getUnits());
     $this->view->setVar("LanguagesAll", References::getLanguages());
     $this->view->setVar("PackageStatusAll", References::getPackageStatus());
     $this->view->setVar("StationsStatusAll", References::getStationsStatus());
     $this->view->pick('/administration/reference_edit');
 }