/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AdmMenuItems::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $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(['id' => $this->id, 'visible' => $this->visible, 'parent_id' => $this->parent_id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'label', $this->label])->andFilterWhere(['like', 'icon', $this->icon])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'options', $this->options]);
     return $dataProvider;
 }
Example #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAdmMenuItems()
 {
     return $this->hasOne(AdmMenuItems::className(), ['id' => 'subcat_id']);
 }
Example #3
0
    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>

    <?php 
// $form->field($model, 'subcat_id')->textInput()
?>
    <?php 
// $form->field($model, 'subcat_id')->dropDownList(ArrayHelper::map(AdmMenuItems::find()->where(['visible' => 1, 'parent_id' => null])->orderBy("label ASC")->all(), 'id', 'label'),['prompt'=>'-- Selecione --'])
?>
    <?php 
//Html::dropDownList('Admregulations[AdmMenuItems]', $model->admMenuItems, app\models\AdmMenuItems::getHierarchy(), [ 'class'=>'form-control required','prompt' => 'Selecione'] );
?>
    <?php 
echo $form->field($model, 'subcat_id', ['inputOptions' => ['class' => 'selectpicker ']])->dropDownList(app\models\AdmMenuItems::getHierarchy(), ['prompt' => 'Selecione', 'class' => 'form-control required', 'style' => 'width:300px']);
?>
    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => 40, 'style' => 'width:300px']);
?>

    <?php 
echo $form->field($model, 'description')->textInput(['maxlength' => 100, 'style' => 'width:600px']);
?>

    <?php 
echo $form->field($model, 'file')->fileInput();
?>

    <?php 
echo $form->field($model, 'is_active')->radioList(['1' => 'Sim', '0' => 'Não'], ['itemOptions' => ['class' => 'radio-inline', 'labelOptions' => array('style' => 'padding:5px;')]])->label('Ativo');
Example #4
0
//echo $form->field($model, 'icon')->textInput(['maxlength' => true])
?>

    <?php 
//echo $form->field($model, 'url')->textInput(['maxlength' => true])
?>

    <?php 
//echo $form->field($model, 'url')->dropDownList(ArrayHelper::map(AdmMenuItems::find()->where(['parent_id' => null])->orderBy("name ASC")->all(), 'id', 'id'),['prompt'=>'Nenhum','style'=>'width:300px'])->hint('Ao selecionar uma categoria, o item criado será considerado uma subcategoria')
?>

    <?php 
echo $form->field($model, 'visible')->radioList(['1' => 'Sim', '0' => 'Não'], ['itemOptions' => ['class' => 'radio-inline', 'labelOptions' => array('style' => 'padding:5px;')]])->label('Ativo');
?>

    <?php 
echo $form->field($model, 'parent_id')->dropDownList(ArrayHelper::map(AdmMenuItems::find()->where(['parent_id' => null])->orderBy("name ASC")->all(), 'id', 'label'), ['prompt' => 'Nenhum', 'style' => 'width:300px'])->hint('Ao selecionar uma categoria, o item criado será considerado uma subcategoria');
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Gravar' : 'Gravar Alteração', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-success']);
?>
    </div>

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

</div>
 /**
  * Finds the AdmMenuItems model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return AdmMenuItems the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = AdmMenuItems::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #6
0
<div class="admregulations-index">

    <h1><span><?php 
echo Html::encode($this->title);
?>
</span>
    <?php 
echo Html::a('<i class="fa fa-plus"></i> Adicionar', ['create'], ['class' => 'btn btn-success grid-button pull-right']);
?>
    </h1>
    <hr/>

    <div class="col-xs-6 col-md-3">

        <?php 
echo $this->render('_menu');
?>
    </div>
    <div class="col-xs-12 col-sm-6 col-md-9">
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'tableOptions' => ['class' => 'table table-striped table-hover '], 'emptyText' => '</br><p class="text-info">Nenhum documento encontrado!</p>', 'summary' => "<p class=\"text-info pull-right\"><h5>Exibindo {begin} a {end} de {totalCount} documento(s) em {pageCount} pagina(s)</h5></p>", 'columns' => [['attribute' => 'id', 'enableSorting' => true, 'contentOptions' => ['style' => 'width: 5%;text-align:center']], ['attribute' => 'subcat_id', 'format' => 'raw', 'enableSorting' => true, 'value' => function ($model) {
    return $model->admMenuItems->label;
}, 'filter' => ArrayHelper::map(AdmMenuItems::find()->orderBy('label')->asArray()->all(), 'id', 'label'), 'contentOptions' => ['style' => 'width: 20%;text-align:left']], ['attribute' => 'name', 'enableSorting' => true, 'contentOptions' => ['style' => 'width: 40%;text-align:left']], ['attribute' => 'is_active', 'format' => 'raw', 'value' => function ($model) {
    //return $model->status->name;
    return $model->is_active == 1 ? '<span style="color:green" class="glyphicon glyphicon-ok" aria-hidden="true"></span>' : '<span style="color:red" class="glyphicon glyphicon-remove" aria-hidden="true"></span>';
}, 'contentOptions' => ['style' => 'width: 5%;text-align:center']], ['class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['style' => 'width: 10%;text-align:right']]]]);
?>
    
    </div>
</div>