/** * Creates a new DcmdGroupRepeatCmd model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($gid) { if (Yii::$app->user->getIdentity()->admin != 1 || Yii::$app->user->getIdentity()->sa != 1) { Yii::$app->getSession()->setFlash('success', NULL); Yii::$app->getSession()->setFlash('error', "对不起,你没有权限!"); return $this->redirect(array('dcmd-group/index')); } $query = DcmdGroupRepeatCmd::find()->andWhere(['gid' => $gid])->asArray()->all(); $opr_cmd = " repeat_cmd_id not in(0"; foreach ($query as $item) { $opr_cmd .= "," . $item['repeat_cmd_id']; } $opr_cmd .= ")"; $searchModel = new DcmdOprCmdRepeatExecSearch(); $dataProvider = $searchModel->search(array(), $opr_cmd); return $this->render('create', ['gid' => Yii::$app->request->queryParams['gid'], 'gname' => Yii::$app->request->queryParams['gname'], 'searchModel' => $searchModel, 'dataProvider' => $dataProvider]); /*$model = new DcmdGroupRepeatCmd(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', [ 'model' => $model, ]); }*/ }
public function actionRepeatOpr() { if (!array_key_exists('selection', Yii::$app->request->post()) && !array_key_exists('ips', Yii::$app->request->post())) { Yii::$app->getSession()->setFlash('error', '未选择设备!'); return $this->redirect(['index']); } $ips = ""; if (array_key_exists('selection', Yii::$app->request->post())) { $select = Yii::$app->request->post()['selection']; if (count($select) < 1) { Yii::$app->getSession()->setFlash('error', '未选择设备!'); return $this->redirect(['index']); } $query = DcmdServicePoolNode::findAll($select); $hv = array(); foreach ($query as $item) { if (in_array($item->ip, $hv)) { continue; } $ips .= $item->ip . ";"; array_push($hv, $item->ip); } } else { $ips = Yii::$app->request->post()['ips']; } ///IP可替换的重复操作 $params = array("DcmdOprCmdRepeatExecSearch" => array("ip_mutable" => 1)); $searchModel = new DcmdOprCmdRepeatExecSearch(); $dataProvider = $searchModel->search($params); return $this->render('repeat_opr', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'ips' => $ips]); }
public function actionRepeatOpr($svr_pool_id) { $ips = $this->getSvrPoolNode($svr_pool_id); if ($ips == "") { Yii::$app->getSession()->setFlash('error', '未选择设备!'); return $this->redirect(['index']); } ///IP可替换的重复操作 $params = array("DcmdOprCmdRepeatExecSearch" => array("ip_mutable" => 1)); $searchModel = new DcmdOprCmdRepeatExecSearch(); $dataProvider = $searchModel->search($params); return $this->render('repeat_opr', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'ips' => $ips]); }
/** * Lists all DcmdOprCmdRepeatExec models. * @return mixed */ public function actionIndex() { $searchModel = new DcmdOprCmdRepeatExecSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }