예제 #1
0
 public function actionAction()
 {
     if (User::hasRole('admin')) {
         //\Yii::trace('### ### ### Тест лога');
         //Проверяем был ли выбрана комманда
         $ids = Yii::$app->request->post('ActionForm');
         //\Yii::trace(Yii::$app->request->post('ActionForm'));
         //Проверяем, выбран ли пустой id, если да, то как будто только открыли
         if ($ids and ArrayHelper::isIn('', $ids)) {
             $ids = null;
         }
         //Для проверки отправки запроса получаем значение
         $page = Yii::$app->request->post('adr');
         if ($ids) {
             //Если выбран ID
             $model = $this->findModel($ids);
             return $this->render('action', ['model' => $model, 'ghide' => 1, 'gadr' => '10.24.2.188', 'guser' => '', 'gpass' => '', 'gid' => $model->id, 'gcommand' => $model->actionstring, 'gparams' => $model->params, 'pagein' => '', 'pageout' => '']);
         } elseif ($page) {
             //Если отправлен запрос
             $ids = Yii::$app->request->post('id');
             $model = $this->findModel($ids);
             $vagon = new Vagon();
             $pagein = 'http://' . Yii::$app->request->post('adr') . '/crq?req=' . Yii::$app->request->post('string') . '&' . Yii::$app->request->post('params');
             $user = Yii::$app->request->post('user');
             $pass = Yii::$app->request->post('pass');
             return $this->render('action', ['model' => $model, 'ghide' => 2, 'gadr' => Yii::$app->request->post('adr'), 'guser' => $user, 'gpass' => $pass, 'gid' => $model->id, 'gcommand' => Yii::$app->request->post('string'), 'gparams' => Yii::$app->request->post('params'), 'pagein' => $pagein, 'pageout' => $vagon->getCurlOut($pagein, $user, $pass)]);
         } else {
             //Если форму только открыли
             return $this->render('action', ['model' => new ActionForm(), 'ghide' => 0, 'gadr' => '', 'guser' => '', 'gpass' => '', 'gid' => '', 'gcommand' => '', 'gparams' => '', 'pagein' => '', 'pageout' => '']);
         }
     } else {
         throw new NotFoundHttpException('Страница не найдена.');
     }
 }
예제 #2
0
 /**
  * Updates an existing AnswerList model.
  * For ajax request will return json object
  * and for non-ajax request if update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $request = Yii::$app->request;
     $model = $this->findModel($id);
     $modelsQuestionList = QuestionList::find()->all();
     $questionLists = ArrayHelper::map($modelsQuestionList, 'id', 'title');
     $statusList = $model->statusList;
     $viewName = 'update';
     // коммерческий директор может только менять статус опросного листа
     if (!User::hasRole(['unicredQuestionListSystemAdmin'])) {
         $viewName = 'update_status';
         unset($statusList['answered']);
     }
     $modelsOffice = Office::find()->all();
     $DoList = ArrayHelper::map($modelsOffice, 'id', 'name');
     if ($request->isAjax) {
         /*
          *   Process for ajax request
          */
         Yii::$app->response->format = Response::FORMAT_JSON;
         if ($request->isGet) {
             return ['title' => "Update AnswerList #" . $id, 'content' => $this->renderAjax($viewName, ['model' => $model, 'questionLists' => $questionLists, 'DoList' => $DoList, 'statusList' => $statusList]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
         } else {
             if ($model->load($request->post())) {
                 $model->list_name = $model->questionList->title;
                 if ($model->save()) {
                     return $this->redirect(['index']);
                 }
                 /*if ($model->save()) return [
                       'forceReload'=>'#crud-datatable-pjax',
                       'title'=> "AnswerList #".$id,
                       'content'=>$this->renderAjax('view', [
                           'model' => $model,
                           'questionLists' => $questionLists,
                           'DoList' => $DoList,
                           'answersDataProvider' => new ArrayDataProvider([
                               'allModels' => $model->answers,
                           ]),
                       ]),
                       'footer'=> Html::button('Close',['class'=>'btn btn-default pull-left','data-dismiss'=>"modal"]).
                               Html::a('Edit',['update','id'=>$id],['class'=>'btn btn-primary','role'=>'modal-remote'])
                   ];*/
             } else {
                 return ['title' => "Update AnswerList #" . $id, 'content' => $this->renderAjax($viewName, ['model' => $model, 'questionLists' => $questionLists, 'DoList' => $DoList, 'statusList' => $statusList]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
             }
         }
     } else {
         /*
          *   Process for non-ajax request
          */
         if ($model->load($request->post())) {
             $model->list_name = $model->questionList->title;
             if ($model->save()) {
                 return $this->redirect(['view', 'id' => $model->id]);
             }
         } else {
             return $this->render($viewName, ['model' => $model, 'questionLists' => $questionLists, 'DoList' => $DoList, 'statusList' => $statusList]);
         }
     }
 }
예제 #3
0
파일: system.php 프로젝트: robky/tb
?>
      <title><?php 
echo Html::encode($this->title);
?>
</title>
      <?php 
$this->head();
?>
   </head>
   <body>          
      <div class="wrap">
         <?php 
$this->beginBody();
NavBar::begin(['brandLabel' => 'TisBOX', 'brandUrl' => Yii::$app->homeUrl, 'renderInnerContainer' => FALSE, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right', 'style' => 'padding-right: 40px'], 'items' => [User::hasRole('admin') ? ['label' => 'Админка', 'items' => [['label' => 'Test', 'url' => ['system/test']], ['label' => 'УСПД', 'url' => ['system/action']], ['label' => 'Данные', 'url' => ['system/out']], ['label' => 'Получить', 'url' => ['system/in']], ['label' => 'Дерево', 'url' => ['/tree']]]] : '', ['label' => Yii::$app->user->identity->username, 'items' => [['label' => 'Выход', 'url' => ['/user-management/auth/logout']]]]]]);
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right', 'style' => 'padding-right: 40px'], 'items' => [User::hasRole('admin') ? ['label' => 'Таблица', 'items' => [['label' => 'Сборщики', 'url' => ['/table/usd']], ['label' => 'Приборы', 'url' => ['/table/device']], ['label' => 'Каналы', 'url' => ['/table/data-list']]]] : '']]);
NavBar::end();
?>
         <div class="container-fluid" style="padding-top: 60px">
            <div class="row">
               <div class="sidebar col-md-2">
                  <?php 
/* Sidebar content */
echo Nav::widget(['encodeLabels' => false, 'options' => ['class' => 'nav-pills nav-stacked'], 'items' => [['label' => '<span class="glyphicon glyphicon-tasks"></span> &nbsp; Данные', 'url' => ['system/data']], ['label' => '<span class="glyphicon glyphicon-print"></span> &nbsp; Отчеты', 'url' => ['#']], ['label' => '<span class="glyphicon glyphicon-import"></span> &nbsp; Импорт', 'url' => ['system/import']], ['label' => '<span class="glyphicon glyphicon-export"></span> &nbsp; Экспорт', 'url' => ['system/export']], ['label' => '<span class="glyphicon glyphicon-wrench"></span> &nbsp; Настройки', 'url' => ['#']]]]);
?>
                  <p></p>

                  <?php 
/*
 //Строка поиска
 ActiveForm::begin(