コード例 #1
0
 public function actionCreateNextGroup($id, $parent_group)
 {
     $roles = ['1', '3'];
     $role = \Yii::app()->user->role;
     if (array_intersect($role, $roles)) {
         $model = new Position();
         $listner = Listner::model()->findByPk($id)->branch_id;
         if (Yii::app()->getRequest()->getPost('Position') !== null) {
             $model->setAttributes(Yii::app()->getRequest()->getPost('Position'));
             $model->parent_group = $parent_group;
             if (in_array('3', $role) && !in_array('1', $role)) {
                 $model->branch_id = Yii::app()->user->branch->id;
             }
             if (isset($_POST['group'])) {
                 $model->group = $_POST['group'];
             } else {
                 $model->group = NULL;
             }
             if (isset($_POST['hui'])) {
                 $model->hui = $_POST['hui'];
             } else {
                 $model->hui = NULL;
             }
             $model->listner_id = $id;
             if (!$model->save()) {
                 die(var_dump($model->getErrors()));
                 Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('ListnerModule.listner', 'Запись добавлена!'));
                 $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id]));
             }
         }
         $this->render('create', ['model' => $model, 'listner' => $listner]);
     } else {
         throw new CHttpException(403, 'Ошибка прав доступа.');
     }
 }
コード例 #2
0
 /**
  * Управление Положениями.
  *
  * @return void
  */
 public function actionIndex()
 {
     $model = new Position('search');
     $model->unsetAttributes();
     // clear any default values
     if (Yii::app()->getRequest()->getParam('Position') !== null) {
         $model->setAttributes(Yii::app()->getRequest()->getParam('Position'));
     }
     $this->render('index', ['model' => $model]);
 }