/** * Lists all Permission models. * @return mixed */ public function actionIndex($category) { Permission::setMenus($category); $searchModel = new PermissionSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $message = LsYii::getGetValue('message', ''); $type = LsYii::getGetValue('type', 1); if ($message) { if ($type == 1) { LsYii::setSuccessMessage($message); } else { if ($type == 2) { LsYii::setErrorMessage($message); } } } return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }
/** * Lists all Modularity models. * @return mixed */ public function actionIndex() { $this->setMenus(12, "Modularity Setting"); $modules = $this->modularityService->getAllModules(); // VarDumper::dump($modules , 10 , true , false); $dataProvider = new ArrayDataProvider(['allModels' => $modules, 'pagination' => ['pageSize' => 10]]); $message = LsYii::getGetValue('message', null); $msgType = LsYii::getGetValue('msgType', 1); if ($message) { if ($msgType == 1) { LsYii::setSuccessMessage($message); } else { if ($msgType == 2) { LsYii::setErrorMessage($message); } } } return $this->render('index', ['dataProvider' => $dataProvider]); }
/** * Creates a new Category model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $this->setMenus(30, "添加新分类"); $model = new Category(); $id = LsYii::getGetValue('id', null); if ($id) { $model->pid = $id; } if ($model->load(LsYii::getRequest()->post())) { $pid = $model->pid; if ($pid) { $c = Category::findOne(['`id`' => $pid]); $rgt = $c->rgt; $model->root = $c->root; $model->pid = $c->id; $model->level = $c->level + 1; $model->lft = $rgt; $model->rgt = $rgt + 1; } else { $maxRgt = Category::getMaxRgt(); $model->lft = $maxRgt + 1; $model->rgt = $maxRgt + 2; $model->pid = 0; $model->level = 1; } if ($model->save()) { if (!$pid) { $menu = Category::findOne(['`id`' => $model->id]); $menu->root = $model->id; $menu->save(); } else { Category::updateAllCounters(['rgt' => 2], "`lft`<{$rgt} AND `rgt`>={$rgt}"); Category::updateAllCounters(['rgt' => 2, 'lft' => 2], "`lft`>{$rgt}"); } } return $this->redirect(['index']); } else { $model->if_show = \source\libs\Constants::Category_Status_Show; return $this->render('create', ['model' => $model]); } }
<?php use source\helpers\Html; use source\LsYii; use source\modules\rbac\models\Role; /* @var $this yii\web\View */ /* @var $model source\modules\rbac\models\Role */ $category = LsYii::getGetValue('category'); $this->title = "新建" . Role::getCategoryItems($category); echo source\libs\Message::getMessage(); ?> <div class="page-header"> <h3> <strong><?php echo Html::encode($this->title); ?> </strong> </h3> </div> <div class="role-create"> <?php echo $this->render('_form', ['model' => $model]); ?> </div>
/** * Deletes an existing Role model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param string $id * @return mixed */ public function actionDelete($id) { $category = LsYii::getGetValue('category'); Role::setMenus($category); $model = $this->findModel($id); if ($model->is_system) { return $this->redirect(['index', 'category' => $category, 'message' => LsYii::gT('该分类还有子项,不能被删除'), 'type' => 2]); } else { $model->delete(); return $this->redirect(['index', 'category' => $category, 'message' => LsYii::gT('删除成功')]); } }
/** * Deletes an existing Dict model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $category_id = LsYii::getGetValue('category_id', 'sex'); $this->findModel($id)->delete(); return $this->redirect(['index', 'category_id' => $category_id]); }
<div class="role-form"> <?php $form = ActiveForm::begin(['id' => 'role-form', 'options' => ['class' => 'form-horizontal']]); ?> <?php echo $form->field($model, 'id')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'description')->textarea(['rows' => 6]); ?> <?php $submitText = $model->isNewRecord ? "新建" : "修改"; $closeLink = Url::to(['/rbac/role/index', 'category' => LsYii::getGetValue('category')]); Html::SubmitButtons($submitText, $closeLink); ?> <?php ActiveForm::end(); ?> </div>
?> </strong> <small><?php echo Html::encode(DictCategory::getDictCategoryName($category_id)); ?> </small> <div class="pull-right"> <?php echo Html::a('<span class="glyphicon glyphicon-plus"></span> ' . LsYii::gT('添加字典'), ['/dict/dict/create', 'category_id' => $category_id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a('<span class="glyphicon glyphicon-share-alt"></span> ' . LsYii::gT('Return'), ['/dict/dictcategory/index'], ['class' => 'btn btn-primary']); ?> </div> </h3> </div> <div class="dict-index"> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'layout' => '{items} {summary} {pager}', 'tableOptions' => ['class' => 'table table-hover'], 'columns' => [['attribute' => 'name'], ['attribute' => 'value'], ['attribute' => 'status', 'filter' => \source\libs\Constants::getDictStatus(), 'content' => function ($model, $key, $index, $gridView) { return \source\libs\Constants::getDictStatus($model->status); }], ['attribute' => 'sort', 'filter' => Html::activeInput('text', $searchModel, 'sort', ['class' => 'form-control'])], ['class' => 'source\\core\\grid\\ActionColumn', 'template' => '{update} {delete}', 'buttons' => ['view' => function ($url, $model) { return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', ['/dict/dict/view', 'id' => $model->id, 'category_id' => LsYii::getGetValue('category_id')], []); }, 'update' => function ($url, $model) { return Html::a('<span class="glyphicon glyphicon-edit"></span>', ['/dict/dict/update', 'id' => $model->id, 'category_id' => LsYii::getGetValue('category_id')], []); }, 'delete' => function ($url, $model) { return Html::a('<span class="glyphicon glyphicon-trash"></span>', ['/dict/dict/delete', 'id' => $model->id, 'category_id' => LsYii::getGetValue('category_id')], ['data-method' => 'post', 'data-confirm' => LsYii::gT('Are you sure you want to delete this item?')]); }]]]]); ?> </div>
echo $form->field($model, 'form')->radioList(Permission::getFormItems()); ?> <?php echo $form->field($model, 'default_value')->textarea(['rows' => 6]); ?> <?php echo $form->field($model, 'rule')->dropDownList(Rule::getRules(), ['prompt' => '请选择']); ?> <?php echo $form->field($model, 'description')->textarea(['rows' => 6]); ?> <?php echo $form->field($model, 'sort_num')->textInput(); ?> <?php $submitText = $model->isNewRecord ? "新建" : "修改"; $closeLink = Url::to(['/rbac/permission/index', 'category' => LsYii::getGetValue('category')]); Html::SubmitButtons($submitText, $closeLink); ?> <?php ActiveForm::end(); ?> </div>