public function fullAction($reception = null)
 {
     $this->view->setVar("TopMenuSelected", 'work');
     $this->view->setVar("MenuSelected", 'search');
     $this->view->setVar("MenuItemActive", $reception);
     if (!empty($reception)) {
         switch ($reception) {
             case 'package':
                 $this->view->setVar("StationsAll", Stations::getStations());
                 $this->view->setVar("PackageStatusAll", References::getPackageStatus());
                 $this->view->setVar("CountriesAll", References::getCountries());
                 $this->view->setVar("result_search", Package::getAll());
                 if ($this->request->get('submit')) {
                     $this->view->setVar("result_search", Package::findPackages($this->request->get(), Users::getStationId($this)));
                     $this->view->setVar("post", $this->request->get());
                     $view = 'form_' . $reception;
                 } else {
                     $view = 'form_' . $reception;
                 }
                 View::addJs($this, ['/js/async/jquery.mb.browser.js', '/js/async/jquery.mousewheel.js', '/js/async/calendar_date-time.js']);
                 View::addCss($this, ['/css/calendar_date-time.css']);
                 break;
         }
     }
     $this->view->pick('/search/' . $view);
 }
 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');
 }
Ejemplo n.º 3
0
 public static function deletePackageStatus($id)
 {
     $references = new References();
     $links = References::getPackageStatus($id);
     if (count($links) > 0) {
         if ($links[0]['from_package_transport_history'] > 0) {
             return array('class' => 'alert-warning', 'text' => "<p>Запись <b> " . $links[0]['name'] . " не</b> может быть <b>удалена</b>, так как связана с одной или несколькими записями. Необходимо <b>переопределить</b> или <b>удалить</b> эти связи, после чего повторите попытку.</p>");
         } else {
             $query = "DELETE FROM package_status_list WHERE id = {$id}";
             $res = new Phalcon\Mvc\Model\Resultset\Simple(null, $references, $references->getReadConnection()->query($query));
             return array('class' => 'alert-success', 'text' => "<p>Удаление записи <b>" . $links[0]['name'] . "</b> произошло успешно.</p>");
         }
     }
     return array('class' => 'alert-danger', 'text' => "<p>Запись не найдена.</p>");
 }