Exemplo n.º 1
0
 public static function deleteStation($id)
 {
     $stations = new Stations();
     $links = Stations::getStations($id);
     if (count($links) > 0) {
         if ($links['from_users'] > 0 || $links['from_package_transport_history'] > 0 || $links['from_registry'] > 0 || $links['from_manifests'] > 0 || $links['from_persons_cache'] > 0) {
             return array('class' => 'alert-warning', 'text' => "<p>Запись <b> " . $links['name'] . " не</b> может быть <b>удалена</b>, так как связана с одной или несколькими записями. Необходимо <b>переопределить</b> или <b>удалить</b> эти связи, после чего повторите попытку.</p>");
         } else {
             $query = "DELETE FROM stations_list WHERE id = {$id}";
             $res = new Phalcon\Mvc\Model\Resultset\Simple(null, $stations, $stations->getReadConnection()->query($query));
             return array('class' => 'alert-success', 'text' => "<p>Удаление записи <b>" . $links['name'] . "</b> произошло успешно.</p>");
         }
     }
     return array('class' => 'alert-danger', 'text' => "<p>Запись не найдена.</p>");
 }
 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);
 }
Exemplo n.º 3
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Stations::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 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);
 }
Exemplo n.º 5
0
echo $form->labelEx($model, 'name');
?>
		<?php 
echo $form->textField($model, 'name', array('size' => 60, 'maxlength' => 255));
?>
		<?php 
echo $form->error($model, 'name');
?>
	</div>
	
	<div class="row">
        <?php 
echo $form->labelEx($model, 'stations');
?>
		<?php 
$data = CHtml::listData(Stations::model()->findAll(), "id", "name");
echo $form->dropDownList($model, 'stations', $data, array('multiple' => 'multiple', 'size' => '5'));
?>
		<?php 
echo $form->error($model, 'stations');
?>
	</div>

	<div class="row buttons">
		<?php 
echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save');
?>
	</div>

<?php 
$this->endWidget();
Exemplo n.º 6
0
echo $form->labelEx($model, 'seat_id');
?>
		<?php 
echo $form->dropDownList($model, 'seat_id', CHtml::listData(Seats::model()->findAll(), 'id', 'name'), array('prompt' => 'Select a seat'));
?>
		<?php 
echo $form->error($model, 'seat_id');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'station_id');
?>
		<?php 
echo $form->dropDownList($model, 'station_id', CHtml::listData(Stations::model()->findAll(), 'id', 'name'), array('prompt' => 'Select a station'));
?>
		<?php 
echo $form->error($model, 'station_id');
?>
	</div>

	<div class="row buttons">
		<?php 
echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save');
?>
	</div>

<?php 
$this->endWidget();
?>