/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = DcmdTaskTemplateServicePool::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'task_tmpt_id' => $this->task_tmpt_id, 'svr_pool_id' => $this->svr_pool_id, 'utime' => $this->utime, 'ctime' => $this->ctime, 'opr_uid' => $this->opr_uid]);
     return $dataProvider;
 }
Exemplo n.º 2
0
 public function actionSelectServicePool($task_id, $task_tmpt_id)
 {
     $task = DcmdTask::findOne($task_id);
     ///获取任务模板的服务池子
     $query = DcmdTaskTemplateServicePool::find()->andWhere(['task_tmpt_id' => $task_tmpt_id])->asArray()->all();
     $svr_pool = "svr_pool_id in (0";
     foreach ($query as $item) {
         $svr_pool .= "," . $item['svr_pool_id'];
     }
     $svr_pool .= ")";
     $query = DcmdServicePool::find()->where($svr_pool);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $searchModel = new DcmdServicePoolSearch();
     return $this->render('select_service_pool', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'task_id' => $task_id, 'task_name' => $task->task_name, 'task_cmd' => $task->task_cmd]);
 }
 /**
  * Deletes an existing DcmdTaskTemplate model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id, $svr_id = 0)
 {
     ////只有管理员可操作
     if (Yii::$app->user->getIdentity()->admin != 1) {
         Yii::$app->getSession()->setFlash('success', NULL);
         Yii::$app->getSession()->setFlash('error', "对不起,你没有权限!");
         return $this->redirect(array('dcmd-task-template/index'));
     }
     DcmdTaskTemplateServicePool::deleteAll('task_tmpt_id = ' . $id);
     $model = $this->findModel($id);
     $this->oprlog(3, "delete task template:" . $model->task_tmpt_name);
     $model->delete();
     Yii::$app->getSession()->setFlash('success', '删除成功!');
     if ($svr_id == 0) {
         return $this->redirect(['index']);
     } else {
         return $this->redirect(array('dcmd-service/view', 'id' => $svr_id));
     }
 }
 /**
  * Finds the DcmdTaskTemplateServicePool model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return DcmdTaskTemplateServicePool the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = DcmdTaskTemplateServicePool::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }