public function stationAction($reception = null, $item_id = null) { $this->view->setVar("TopMenuSelected", 'work'); $this->view->setVar("MenuSelected", 'stations'); $this->view->setVar("MenuItemActive", $reception); $messages = array(); if (!empty($reception)) { $view = $reception; switch ($reception) { case 'add': $this->view->setVar("CountriesAll", References::getCountries()); $this->view->setVar("StationsStatusAll", References::getStationsStatus()); $this->view->setVar("Stations", Stations::getStations()); break; case 'preview': if ($this->request->isPost()) { if ((bool) $this->request->getPost('add')) { View::addMessages($this, [Stations::addStation($this->request->getPost())]); } if ((bool) $this->request->getPost('delete')) { View::addMessages($this, [Stations::deleteStation($this->request->getPost('id'))]); } } $this->view->setVar("StationsAll", Stations::getStations()); break; case 'edit': if (empty($item_id)) { if ($this->request->isPost()) { $this->response->redirect('/administration/station/edit/' . $this->request->getPost('station_id'), '/'); } $messages[] = array('class' => 'alert-info', 'text' => "<p><b>Выберите</b> из выпадающего списка <b>станцию</b>, которую нужно изменить.</p>"); $this->view->setVar("StationsAll", Stations::getStations()); } else { if ($this->request->isPost()) { $messages[] = Stations::setStation($this->request->getPost()); } $this->view->setVar("Station", Stations::getStations($item_id)); $this->view->setVar("CountriesAll", References::getCountries()); $this->view->setVar("StationsStatusAll", References::getStationsStatus()); $this->view->setVar("Stations", Stations::getStations()); } break; } $this->view->pick('/administration/' . "station_" . $view); } $this->view->setVar("messages", $messages); }
public static function deleteStationsStatus($id) { $references = new References(); $links = References::getStationsStatus($id); if (count($links) > 0) { if ($links[0]['from_stations_list'] > 0) { return array('class' => 'alert-warning', 'text' => "<p>Запись <b> " . $links[0]['name'] . " не</b> может быть <b>удалена</b>, так как связана с одной или несколькими записями. Необходимо <b>переопределить</b> или <b>удалить</b> эти связи, после чего повторите попытку.</p>"); } else { $query = "DELETE FROM stations_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>"); }