コード例 #1
0
ファイル: AuthitemSearch.php プロジェクト: vovancho/yii2test
 public function searchforauthassignment($params)
 {
     $query = Authitem::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['description' => SORT_ASC]]]);
     $query->joinWith(['authassignments', 'authitemchildrenchild']);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['type' => $this->type, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     //      $query->where('auth_item.type = 1 and (authassignments.user_id <> :user_id or authassignments.user_id is null) and  (not auth_item.name in (select b.child from auth_item_child b))', [
     $query->where('auth_item.type = 1 and (authassignments.user_id <> :user_id or authassignments.user_id is null) and (not authitemchildrenchild.parent in (select a.item_name from auth_assignment a where a.user_id = :user_id) or authitemchildrenchild.parent is null)', ['user_id' => $params['id']]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'rule_name', $this->rule_name])->andFilterWhere(['like', 'data', $this->data]);
     $query->groupBy(['name']);
     return $dataProvider;
 }
コード例 #2
0
ファイル: Authrule.php プロジェクト: vovancho/yii2test
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAuthItems()
 {
     return $this->hasMany(AuthItem::className(), ['rule_name' => 'name'])->from(['authItems' => Authitem::tableName()]);
 }
コード例 #3
0
ファイル: Authassignment.php プロジェクト: vovancho/yii2test
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getitemname()
 {
     return $this->hasOne(Authitem::className(), ['name' => 'item_name'])->from(['itemname' => Authitem::tableName()]);
 }
コード例 #4
0
ファイル: Authuser.php プロジェクト: vovancho/yii2test
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getitemnames()
 {
     return $this->hasMany(Authitem::className(), ['name' => 'item_name'])->from(['itemnames' => Authitem::tableName()])->viaTable('auth_assignment', ['user_id' => 'auth_user_id']);
 }
コード例 #5
0
 /**
  * Finds the Authitem model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Authitem the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Authitem::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #6
0
ファイル: _form.php プロジェクト: vovancho/yii2test
    <?php 
echo $form->field($model, 'type')->widget(Select2::classname(), ['hideSearch' => true, 'data' => $model::VariablesValues('type'), 'options' => ['placeholder' => 'Выберете тип', 'class' => 'form-control setsession'], 'disabled' => !$model->isNewRecord, 'pluginOptions' => ['allowClear' => true]]);
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true, 'class' => 'form-control setsession', 'disabled' => !$model->isNewRecord]);
?>

    <?php 
ActiveForm::end();
?>

    <?php 
if (!$model->isNewRecord && $model->type == 1) {
    $type = \app\models\Config\Authitem::VariablesValues('type');
    echo DynaGrid::widget(Proc::DGopts(['options' => ['id' => 'authitemchildgrid'], 'columns' => Proc::DGcols(['columns' => ['children.description', ['attribute' => 'children.type', 'filter' => $type, 'value' => function ($model) use($type) {
        return isset($type[$model->children->type]) ? $type[$model->children->type] : '';
    }], 'children.name'], 'buttons' => ['deletecustom' => function ($url, $model) use($params) {
        $customurl = Yii::$app->getUrlManager()->createUrl(['Config/authitemchild/delete', 'parent' => $model->parent, 'child' => $model->child]);
        return Html::button('<i class="glyphicon glyphicon-trash"></i>', ['type' => 'button', 'title' => 'Удалить', 'class' => 'btn btn-xs btn-danger', 'onclick' => 'ConfirmDeleteDialogToAjax("Вы уверены, что хотите удалить запись?", "' . $customurl . '")']);
    }]]), 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'panel' => ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-paperclip"></i> Дочерние авторизационные единицы</h3>', 'before' => Html::a('<i class="glyphicon glyphicon-download"></i> Добавить дочернюю авторизационную единицу', ['Config/authitem/forauthitemchild', 'foreignmodel' => 'Authitemchild', 'url' => $this->context->module->requestedRoute, 'field' => 'child', 'id' => $model->primaryKey], ['class' => 'btn btn-success', 'data-pjax' => '0'])]]]));
}
?>

            <div class="panel panel-default">
                <div class="panel-heading">
                    
                    <?php 
echo Html::submitButton($model->isNewRecord ? '<i class="glyphicon glyphicon-plus"></i> Создать' : '<i class="glyphicon glyphicon-edit"></i> Обновить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary', 'form' => 'Authitemform']);
?>
コード例 #7
0
ファイル: Authitemchild.php プロジェクト: vovancho/yii2test
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getchildren()
 {
     return $this->hasOne(Authitem::className(), ['name' => 'child'])->from(['children' => Authitem::tableName()]);
 }