/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id, $idTree) { $model = $this->loadModel($id, $idTree); $model->id_tree = $idTree; $model->author = Yii::app()->user->name; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Telephone'])) { $model->attributes = $_POST['Telephone']; $model->log_change = LogChange::setLog($model->log_change, 'изменение'); $tempFile = CUploadedFile::getInstance($model, 'tel_file'); if ($tempFile != null) { try { unlink(Yii::app()->params['pathTelephones'] . '/' . $model->telephone_file); } catch (exception $e) { } $file_name = $model->ifns_code . '_' . date('Ymd_His') . '.' . pathinfo($tempFile->getName(), PATHINFO_EXTENSION); $model->telephone_file = $file_name; $tempFile->saveAs(Yii::app()->params['pathTelephones'] . '/' . $file_name); } if ($model->save()) { $this->redirect(array('view', 'id' => $model->id, 'idTree' => $idTree)); } } $this->render('update', array('model' => $model, 'idTree' => $idTree)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate($idTree) { $modelTree = Tree::model()->find('id=:id AND module=:module AND organization=:organization', array(':id' => $idTree, ':module' => 'news', ':organization' => Yii::app()->session['code_no'])); if ($modelTree === null) { throw new CHttpException(404, 'Страница не найдена.'); } if (!(Yii::app()->user->admin || Access::model()->checkAccessUserForTree($idTree))) { throw new CHttpException(403, 'Доступ запрещен.'); } $model = new News(); $model->id_tree = $idTree; $model->flag_enable = true; $model->date_start_pub = date('d.m.Y'); $model->date_end_pub = date('01.m.Y', PHP_INT_MAX); $model->author = Yii::app()->user->name; $model->general_page = 0; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['News'])) { $model->attributes = $_POST['News']; $model->log_change = LogChange::setLog($model->log_change, 'создание'); if ($model->save()) { // сохраняем файлы $model->saveFiles($model->id, $idTree); // сохраняем изображения $model->saveImages($model->id, $idTree); // сохраняем миниатюра изображения $model->saveThumbailForNews($model); $this->redirect(array('view', 'id' => $model->id, 'idTree' => $idTree)); } } $this->render('create', array('model' => $model, 'idTree' => $idTree)); }
protected function beforeSave() { if ($this->isNewRecord) { $this->date_create = new CDbExpression('NOW()'); $this->author = Yii::app()->user->name; } $this->log_change = LogChange::setLog($this->log_change, $this->isNewRecord ? 'создание' : 'изменение'); return parent::beforeSave(); }
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id, $idTree) { if (Yii::app()->request->isPostRequest) { if (!Yii::app()->user->admin) { $model = $this->loadModel($id, $idTree); $model->date_delete = new CDbExpression('getdate()'); $model->log_change = LogChange::setLog($model->log_change, 'удаление'); $model->save(); } else { // we only allow deletion via POST request $this->loadModel($id, $idTree)->delete(); } // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if (!isset($_GET['ajax'])) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin', 'idTree' => $idTree)); } } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } }
protected function beforeSave() { $this->ifns_ufns_date = $this->ifns_ufns_date == '' ? new CDbExpression('NULL') : new CDbExpression("STR_TO_DATE('" . $this->ifns_ufns_date . "','%d.%m.%Y')"); $this->ufns_fns_date = $this->ufns_fns_date == '' ? new CDbExpression('NULL') : new CDbExpression("STR_TO_DATE('" . $this->ufns_fns_date . "','%d.%m.%Y')"); $this->fns_ufns_date = $this->fns_ufns_date == '' ? new CDbExpression('NULL') : new CDbExpression("STR_TO_DATE('" . $this->fns_ufns_date . "','%d.%m.%Y')"); $this->ufns_ifns_date = $this->ufns_ifns_date == '' ? new CDbExpression('NULL') : new CDbExpression("STR_TO_DATE('" . $this->ufns_ifns_date . "','%d.%m.%Y')"); $this->date_execution = $this->date_execution == '' ? new CDbExpression('NULL') : new CDbExpression("STR_TO_DATE('" . $this->date_execution . "','%d.%m.%Y')"); /* if ($this->ifns_ufns_date=='') $this->ifns_ufns_date = new CDbExpression('NULL'); if ($this->ufns_fns_date=='') $this->ufns_fns_date = new CDbExpression('NULL'); if ($this->fns_ufns_date=='') $this->fns_ufns_date = new CDbExpression('NULL'); if ($this->ufns_ifns_date=='') $this->ufns_ifns_date = new CDbExpression('NULL'); if ($this->date_execution=='') $this->date_execution = new CDbExpression('NULL'); */ if ($this->isNewRecord) { $this->date_create = new CDbExpression('NOW()'); } $this->log_change = LogChange::setLog($this->log_change, $this->isNewRecord ? 'создание' : 'изменение'); return parent::beforeSave(); }
<?php $this->breadcrumbs = array('ВКС УФНС' => array('admin', 'idTree' => $idTree), $model->id); $this->menu = array(array('label' => 'Создать', 'url' => array('create', 'idTree' => $idTree), 'icon' => 'asterisk'), array('label' => 'Изменить', 'url' => array('update', 'id' => $model->id, 'idTree' => $idTree), 'icon' => 'pencil'), array('label' => 'Удалить', 'url' => '#', 'icon' => 'trash', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id, 'idTree' => $idTree), 'confirm' => 'Вы уверены что хотите удалить "' . $model->theme . '"?')), array('label' => 'Управление', 'url' => array('admin', 'idTree' => $idTree), 'icon' => 'user')); ?> <h1>ВКС УФНС #<?php echo $model->id; ?> </h1> <?php $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array('id', 'theme', 'responsible', 'members_people', 'members_organization', array('name' => 'date_start', 'value' => $model->_tempDateStart . ' ' . $model->_tempTimeStart), 'duration', 'date_create', array('name' => 'log_change', 'value' => LogChange::getLog($model->log_change), 'type' => 'raw'))));
<?php $this->breadcrumbs = array('Модули' => array('index'), $model->name); $this->menu = array(array('label' => 'Список', 'url' => array('index'), 'icon' => 'list'), array('label' => 'Создать', 'url' => array('create'), 'icon' => 'asterisk'), array('label' => 'Изменить', 'url' => array('update', 'id' => $model->name), 'icon' => 'pencil'), array('label' => 'Удалить', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->name), 'confirm' => 'Вы уверены, что хотите удалить эту запись?'), 'icon' => 'trash'), array('label' => 'Управление', 'url' => array('admin'), 'icon' => 'user')); ?> <h1>Просмотр <?php echo $model->name; ?> </h1> <?php $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array('name', 'description', array('name' => 'date_create', 'value' => date('d.m.Y H:i:s', strtotime($model->date_create))), 'author', array('name' => 'only_one', 'value' => $model->only_one ? 'Да' : 'Нет'), array('name' => 'log_change', 'type' => 'raw', 'value' => LogChange::getLog($model->log_change))))); ?>
<strong>Данная запись была удалена <?php echo date('d.m.Y H:i:s', strtotime($model->date_delete)); ?> </strong> <?php $this->widget('bootstrap.widgets.TbButton', array('url' => array('restore', 'id' => $model->id, 'idTree' => $idTree), 'type' => 'primary', 'label' => 'Восстановить')); ?> <?php $this->widget('bootstrap.widgets.TbButton', array('url' => array('delete', 'id' => $model->id, 'idTree' => $idTree), 'type' => 'danger', 'label' => 'Удалить безвозвратно', 'htmlOptions' => array('confirm' => 'Вы уверены, что хотите удалить эту запись?'))); ?> </div> <?php } ?> <script type="text/javascript"> $(document).ready(function() { if ($('.fancybox').length) { $('.fancybox').fancybox(); } }); </script> <?php $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array('id', array('name' => 'id_tree', 'value' => Tree::model()->findByPk($idTree)->name), 'title', 'author', 'date_start_pub', 'date_end_pub', array('name' => 'date_create', 'value' => date('d.m.Y H:i:s', strtotime($model->date_create))), array('name' => 'flag_enable', 'value' => $model->flag_enable ? "Да" : "Нет"), array('name' => 'Миниатюра', 'type' => 'raw', 'value' => $model->thumbail_image !== '' ? '<a href="' . Yii::app()->baseUrl . $model->thumbail_image . '" class="fancybox">' . $model->thumbail_image . '</a>' : 'нет'), array('name' => 'Файлы', 'type' => 'raw', 'value' => '<div id="preview">' . $model->getListFiles($model->id, $idTree) . '</div>'), array('name' => 'Изображения', 'type' => 'raw', 'value' => $model->getListImages($model->id, $idTree)), array('name' => 'log_change', 'type' => 'raw', 'value' => LogChange::getLog($model->log_change))))); ?>
>Просмотр новости #<?php echo $model->id; ?> </h1> <?php // скрипты для просмотра изображений // Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/extension/fancybox/lib/jquery.mousewheel-3.0.6.pack.js'); Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/extension/fancybox/jquery.fancybox.js?v=2.1.5'); Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/extension/fancybox/helpers/jquery.fancybox-buttons.js?v=1.0.5'); /*Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/extension/fancybox/helpers/jquery.fancybox-thumbs.css?v=1.0.7');*/ Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/extension/fancybox/helpers/jquery.fancybox-thumbs.js?v=1.0.7'); Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/extension/fancybox/helpers/jquery.fancybox-media.js?v=1.0.6'); Yii::app()->getClientScript()->registerCssFile(Yii::app()->baseUrl . '/extension/fancybox/jquery.fancybox.css?v=2.1.5'); ?> <script type="text/javascript"> $(document).ready(function() { if ($('.fancybox').length) { $('.fancybox').fancybox(); } }); </script> <?php $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array('id', array('name' => 'id_tree', 'value' => Tree::model()->findByPk($idTree)->name), 'title', 'author', 'date_start_pub', 'date_end_pub', 'date_create', array('name' => 'flag_enable', 'value' => $model->flag_enable ? "Да" : "Нет"), array('name' => 'Файлы', 'type' => 'raw', 'value' => '<div id="preview">' . $model->getListFiles($model->id, $idTree) . '</div>'), array('name' => 'Изобоажения', 'type' => 'raw', 'value' => $model->getListImages($model->id, $idTree)), array('name' => 'log_change', 'type' => 'raw', 'value' => LogChange::getLog($model->log_change))))); ?>
<?php $this->breadcrumbs = array('Обновление СЭОД' => array('admin', 'idTree' => $idTree), $model->name); $this->menu = array(array('label' => 'Создать', 'url' => array('create', 'idTree' => $idTree), 'icon' => 'asterisk'), array('label' => 'Изменить', 'url' => array('update', 'id' => $model->id, 'idTree' => $idTree), 'icon' => 'pencil'), array('label' => 'Удалить', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id, 'idTree' => $idTree), 'confirm' => 'Вы уверены что хотите удалить запись?'), 'icon' => 'trash'), array('label' => 'Управление', 'url' => array('admin', 'idTree' => $idTree), 'icon' => 'user')); ?> <h1>Просмотр записи #<?php echo $model->id; ?> </h1> <?php $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array('id', 'support', 'name', 'path', array('name' => 'date_update', 'value' => date('d.m.Y', strtotime($model->date_update))), array('name' => 'date_create', 'value' => date('d.m.Y H:i:s', strtotime($model->date_create))), array('name' => 'log_change', 'type' => 'raw', 'value' => LogChange::getLog($model->log_change)))));
<?php $this->breadcrumbs = array('Структура сайта' => array('admin'), $model->name); $this->menu = array(array('label' => 'Создать', 'url' => array('create'), 'icon' => 'asterisk'), array('label' => 'Изменить', 'url' => array('update', 'id' => $model->id), 'icon' => 'pencil'), array('label' => 'Удалить', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Вы уверены что хотите удалить "' . $model->name . '"? Все дочерние подразделы будут удалены!'), 'icon' => 'trash'), array('label' => 'Управление', 'url' => array('admin'), 'icon' => 'user')); ?> <h1>Просмотр #<?php echo $model->id; ?> </h1> <?php $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array('id', array('label' => $model->getAttributeLabel('id_parent'), 'value' => $model->getNameById($model->id_parent)), 'name', 'sort', 'author', 'module', array('label' => $model->getAttributeLabel('use_tape'), 'value' => $model->use_tape ? 'Да' : 'Нет'), 'date_create', array('label' => 'Доступ', 'type' => 'raw', 'value' => $model->getListGroupUser($model->id)), array('name' => 'log_change', 'type' => 'raw', 'value' => LogChange::getLog($model->log_change))))); ?> <?php /*if ($model->use_organization): ?> <div class="well" style="background-color: white;"> <?php $this->widget('CTreeView', array( 'data'=>$model->getListOrganization(0, $model->id, true), )); ?> <?php endif;*/ ?> <!--/div-->
<?php $this->breadcrumbs = array('Журнал заявок' => array('admin', 'idTree' => $idTree), '#' . $model->id); $this->menu = array(array('label' => 'Созадать', 'url' => array('create', 'idTree' => $idTree), 'icon' => 'asterisk'), array('label' => 'Изменить', 'url' => array('update', 'id' => $model->id, 'idTree' => $idTree), 'icon' => 'pencil'), array('label' => 'Удалить', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id, 'idTree' => $idTree), 'confirm' => 'Вы уверены, что хотите удалить эту запись?'), 'icon' => 'trash'), array('label' => 'Управление', 'url' => array('admin', 'idTree' => $idTree), 'icon' => 'user')); ?> <h1>Просмотр заявки #<?php echo $model->id; ?> </h1> <?php $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array('id', 'code_no', array('name' => 'Наименование НО', 'value' => Organization::model()->findByPk($model->code_no)->name), 'ifns_ufns_date', 'ifns_ufns_number', 'ufns_fns_date', 'ufns_fns_number', 'fns_ufns_date', 'fns_ufns_number', 'ufns_ifns_date', 'ufns_ifns_number', 'date_execution', 'description', array('name' => 'status', 'value' => $model->status ? 'Завершено' : 'На исполнении'), array('name' => 'date_create', 'value' => date('d.m.Y H:i:s', strtotime($model->date_create))), array('name' => 'log_change', 'type' => 'raw', 'value' => LogChange::getLog($model->log_change)))));
/** Восстановление записи **/ public function actionRestore($id, $idTree) { if (!Yii::app()->user->admin) { return; } $model = $this->loadModel($id, $idTree); $model->date_delete = new CDbExpression('NULL'); $model->log_change = LogChange::setLog($model->log_change, 'восстановление'); $model->save(); $this->redirect(array('view', 'id' => $model->id, 'idTree' => $idTree)); }
<?php $this->breadcrumbs = array('Телефонный справочник' => array('admin', 'idTree' => $idTree), $model->id . ' (' . $model->telephone_file . ')'); $this->menu = array(array('label' => 'Создать', 'url' => array('create', 'idTree' => $idTree), 'icon' => 'asterisk'), array('label' => 'Изменить', 'url' => array('update', 'id' => $model->id, 'idTree' => $idTree), 'icon' => 'pencil'), array('label' => 'Удалить', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id, 'idTree' => $idTree), 'confirm' => 'Вы уверены, что хотите удалить эту запись?'), 'icon' => 'trash'), array('label' => 'Управление', 'url' => array('admin', 'idTree' => $idTree), 'icon' => 'user')); ?> <h1>Телефонный справочник #<?php echo $model->id; ?> </h1> <?php $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array('id', array('name' => 'ifns_code', 'value' => $model->org->code . ' - ' . $model->org->name), array('name' => 'telephone_file', 'value' => CHtml::link($model->telephone_file, Yii::app()->baseUrl . '/files/telephones/' . $model->telephone_file, array('target' => '_blank')), 'type' => 'raw'), 'author', 'dop_text', 'date_create', 'sort', array('name' => 'log_change', 'value' => LogChange::getLog($model->log_change), 'type' => 'raw'))));