Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = DcmdTaskCmdArg::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'task_cmd_id' => $this->task_cmd_id, 'optional' => $this->optional, 'arg_type' => $this->arg_type, 'utime' => $this->utime, 'ctime' => $this->ctime, 'opr_uid' => $this->opr_uid]);
     $query->andFilterWhere(['like', 'task_cmd', $this->task_cmd])->andFilterWhere(['like', 'arg_name', $this->arg_name]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 private function showTaskArg($arg_xml, $task_cmd_id)
 {
     $content = "";
     ///
     $ar = xml_to_array($arg_xml);
     $args = array();
     if (array_key_exists('env', $ar)) {
         $args = $ar['env'];
     }
     $query = DcmdTaskCmdArg::find()->andWhere(['task_cmd_id' => $task_cmd_id])->asArray()->all();
     if ($query) {
         ///获取模板参数
         $content = '<table class="table table-striped table-bordered detail-view">
                 <tr><td>参数名称</td>
                 <td>是否可选</td>
                 <td>值</td></tr>';
         foreach ($query as $item) {
             $content .= "<tr><td>" . $item['arg_name'] . '</td>';
             $content .= "<td>";
             if ($item['optional'] == 0) {
                 $content .= "否";
             } else {
                 $content .= "是";
             }
             $content .= "</td>";
             if (is_array($args) && array_key_exists($item['arg_name'], $args)) {
                 $content .= "<td><input name='Arg" . $item['arg_name'] . "' type='text'  value='" . $args[$item['arg_name']] . "' >";
             } else {
                 $content .= "<td><input name='Arg" . $item['arg_name'] . "' type='text'  value='' >";
             }
             $content .= "</td><tr>";
         }
         $content .= "</table>";
     }
     return $content;
 }
 public function actionGetTaskTypeArg($task_cmd_id, $arg = array(), $disabled = "")
 {
     $query = DcmdTaskCmdArg::find()->andWhere(['task_cmd_id' => $task_cmd_id])->asArray()->all();
     $content = "";
     if ($query) {
         $content .= '<table class="table table-striped table-bordered detail-view">
          <tr> <td>参数名称</td>
          <td>是否可选</td>
          <td>值</td>
          </tr>';
         foreach ($query as $item) {
             $content .= "<tr><td>" . $item['arg_name'] . '</td>';
             $content .= "<td>";
             if ($item['optional'] == 0) {
                 $content .= "否";
             } else {
                 $content .= "是";
             }
             $content .= "</td>";
             $content .= "<td style=\"display:none\">" . $item['arg_name'] . "</td>";
             ///$content .= "<td><input name='Arg".$item['arg_name']."' type='text' $disabled ";
             if (is_array($arg) && array_key_exists($item['arg_name'], $arg)) {
                 if ($disabled != "") {
                     $content .= "<td>" . $arg[$item['arg_name']];
                 } else {
                     $content .= "<td><input name='Arg" . $item['arg_name'] . "' type='text'  value='" . $arg[$item['arg_name']] . "' >";
                 }
             } else {
                 if ($disabled != "") {
                     $content .= "<td>";
                 } else {
                     $content .= "<td><input name='Arg" . $item['arg_name'] . "' type='text'  value='' >";
                 }
             }
             $content .= "</td><tr>";
         }
         $content .= "</table>";
     } else {
         $content .= "无参数设定";
     }
     return $content;
 }
 /**
  * Finds the DcmdTaskCmdArg model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return DcmdTaskCmdArg the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = DcmdTaskCmdArg::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 5
0
 /**
  * Deletes an existing DcmdTaskCmd model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     if (Yii::$app->user->getIdentity()->admin != 1) {
         Yii::$app->getSession()->setFlash('success', NULL);
         Yii::$app->getSession()->setFlash('error', "对不起,你没有权限!");
         return $this->redirect(array('dcmd-task-cmd/index'));
     }
     ///确定是否有任务模板使用
     $ret = DcmdTaskTemplate::findOne(['task_cmd_id' => $id]);
     if ($ret) {
         Yii::$app->getSession()->setFlash('error', '有任务模板使用该脚本, 删除失败!');
         return $this->redirect(['index']);
     }
     ///delete from dcmd_task_cmd_arg
     DcmdTaskCmdArg::deleteAll('task_cmd_id = ' . $id);
     $this->findModel($id)->delete();
     Yii::$app->getSession()->setFlash('success', '删除成功!');
     return $this->redirect(['index']);
 }