コード例 #1
0
 public function personAction($reception = null, $item_id = null)
 {
     $this->view->setVar("TopMenuSelected", 'work');
     $this->view->setVar("MenuSelected", 'persons');
     $this->view->setVar("MenuItemActive", $reception);
     $messages = array();
     if (!empty($reception)) {
         $view = $reception;
         switch ($reception) {
             case 'add':
                 $this->view->setVar("CountriesAll", References::getCountries());
                 break;
             case 'preview-cache-station':
                 if ($this->request->isPost()) {
                     if ((bool) $this->request->getPost('add')) {
                         View::addMessages($this, [References::addPersonNew($this->request->getPost('full_name'), $this->request->getPost('address'), $this->request->getPost('country_id'), 3, $this->request->getPost('code'), 1, $this->request->getPost('phone'), Users::getStationId($this))]);
                     }
                 }
                 View::addMessages($this, [array('class' => 'alert-info', 'text' => "<p>Перечень записей Адресной книги кэшированных только для этой станции.</p>")]);
                 $this->view->setVar("PersonsCacheAll", References::getPersonsCache(Users::getStationId($this)));
                 break;
             case 'preview-cache':
                 if ($this->request->isPost()) {
                 }
                 View::addMessages($this, [array('class' => 'alert-info', 'text' => "<p>Перечень часто использующихся записей Адресной книги всех станций.</p>")]);
                 $this->view->setVar("PersonsCacheAll", References::getPersonsHot());
                 break;
             case 'preview':
                 if ($this->request->isPost()) {
                     //$messages[] = Users::addUser($this->request->getPost());
                     //$messages[] = Users::deleteUser($this->request->getPost('id'));
                 }
                 View::addMessages($this, [array('class' => 'alert-info', 'text' => "<p>Полный перечень записей Адресной книги всех станций.</p>")]);
                 $this->view->setVar("PersonsCacheAll", References::getPersonsAll());
                 break;
             case 'edit':
                 if (empty($item_id)) {
                     if ($this->request->isPost()) {
                         $this->response->redirect('/administration/user/edit/' . $this->request->getPost('user_id'), '/');
                     }
                     $messages[] = array('class' => 'alert-info', 'text' => "<p><b>Выберите</b> из выпадающего списка <b>профиль пользователя</b>, который нужно изменить.</p>");
                     $this->view->setVar("UsersAll", Users::getUsers());
                 } else {
                     if ($this->request->isPost()) {
                         $messages[] = Users::setUser($this->request->getPost());
                     }
                     $this->view->setVar("User", Users::getUsers($item_id));
                     $this->view->setVar("StationsAll", Stations::getStations());
                     $this->view->setVar("RolesAll", Roles::getRoles());
                     $this->view->setVar("LanguagesAll", References::getLanguages());
                     $this->view->setVar("CurrencyAll", References::getCurrency());
                     $this->view->setVar("Units1", References::getUnits(NULL, array(1))['units']);
                     $this->view->setVar("Units2", References::getUnits(NULL, array(3))['units']);
                     $this->view->setVar("Units3", References::getUnits(NULL, array(4))['units']);
                 }
                 break;
             case 'settings':
                 if ($this->request->isPost()) {
                     $messages[] = Users::addUser($this->request->getPost());
                     //$messages[] = Users::deleteUser($this->request->getPost('id'));
                 }
                 $this->view->setVar("UsersAll", Users::getUsers());
                 break;
         }
         $this->view->pick('/administration/' . "person_" . $view);
     }
     //$this->view->setVar("messages", $messages);
 }