Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Typeperson::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'desc', $this->desc]);
     return $dataProvider;
 }
 /**
  * Finds the Typeperson model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Typeperson the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Typeperson::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #3
0
        </div>
        <div class="col-md-4">
            <?php 
echo $form->field($model, 'user_id')->dropDownList(ArrayHelper::map(User::find()->where(['role_id' => 2])->orderBy("username ASC")->all(), 'id', 'username'), ['prompt' => 'Todos']);
?>
        </div>
        <div class="col-md-4">
            <?php 
echo $form->field($model, 'location_id')->dropDownList(ArrayHelper::map(Location::find()->where(['is_active' => 1])->orderBy("fullname ASC")->all(), 'id', 'fullname'), ['prompt' => 'Todos']);
?>
        </div>
    </div>
    <div class="row">
        <div class="col-md-4">
            <?php 
echo $form->field($model, 'typeperson_id')->dropDownList(ArrayHelper::map(Typeperson::find()->orderBy("name ASC")->all(), 'id', 'name'), ['prompt' => 'Todos']);
?>
        </div>
        <div class="col-md-4">
            <?php 
echo $form->field($model, 'typesolicitation_id')->dropDownList(ArrayHelper::map(Typesolicitation::find()->orderBy("name ASC")->all(), 'id', 'name'), ['prompt' => 'Todos']);
?>
        </div>
        <div class="col-md-4">
            <?php 
echo $form->field($model, 'status_id')->dropDownList(ArrayHelper::map(Status::find()->orderBy("name ASC")->all(), 'id', 'name'), ['prompt' => 'Todos']);
?>
        </div>        
    </div>

    <?php 
Example #4
0
</h2>
    <hr/>
    <?php 
echo $this->render('_search', ['model' => $searchModel]);
?>
    <hr/>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'tableOptions' => ['class' => 'table table-striped table-hover'], 'emptyText' => '</br><p class="text-danger">Nenhuma solicitação encontrada!</p>', 'summary' => "<p class=\"text-primary \">Você possui {totalCount} solicitações</p>", 'filterModel' => $searchModel, 'rowOptions' => function ($model) {
    if ($model->status_id == 98) {
        return ['class' => 'text-muted'];
    }
}, 'columns' => [['attribute' => 'id', 'enableSorting' => true, 'contentOptions' => ['style' => 'width: 6%;text-align:left']], ['attribute' => 'created', 'enableSorting' => true, 'contentOptions' => ['style' => 'width: 7%;text-align:center'], 'format' => ['date', 'php:d/m/Y']], ['attribute' => 'location_id', 'format' => 'raw', 'enableSorting' => true, 'value' => function ($model) {
    return $model->location->nickname;
}, 'filter' => ArrayHelper::map(Location::find()->orderBy('nickname')->asArray()->all(), 'id', 'nickname'), 'contentOptions' => ['style' => 'width: 7%;text-align:left']], ['attribute' => 'cpf_cnpj', 'enableSorting' => true, 'contentOptions' => ['style' => 'width: 15%;text-align:left']], ['attribute' => 'typeperson_id', 'enableSorting' => true, 'value' => function ($model) {
    return $model->typeperson->name;
}, 'filter' => ArrayHelper::map(Typeperson::find()->orderBy('name')->asArray()->all(), 'id', 'name'), 'contentOptions' => ['style' => 'width: 12%;text-align:left']], ['attribute' => 'typesolicitation_id', 'enableSorting' => true, 'value' => function ($model) {
    return $model->typesolicitation->name;
}, 'filter' => ArrayHelper::map(Typesolicitation::find()->orderBy('name')->asArray()->all(), 'id', 'name'), 'contentOptions' => ['style' => 'width: 15%;text-align:left']], ['attribute' => 'status_id', 'format' => 'raw', 'enableSorting' => true, 'value' => function ($model) {
    //return $model->status->name;
    return '<span style="color:' . $model->status->color . '"><i class="fa fa-circle"></i> ' . $model->status->name . '</span>';
}, 'filter' => ArrayHelper::map(Status::find()->orderBy('name')->asArray()->all(), 'id', 'name'), 'contentOptions' => ['style' => 'width: 15%;text-align:left']], ['attribute' => 'analyst_id', 'format' => 'raw', 'enableSorting' => true, 'value' => function ($model) {
    return $model->analyst ? $model->analyst->username : '******';
}, 'contentOptions' => ['style' => 'width: 15%;text-align:left']], ['class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['style' => 'width: 10%;text-align:right'], 'template' => '{view} {update}', 'buttons' => ['view' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-eye-open" ></span>', $url, ['title' => 'Visualizar']);
}, 'update' => function ($url, $model) {
    return $model->status_id < 98 ? Html::a('<span class="glyphicon glyphicon-pencil" ></span>', $url, ['title' => 'Alterar']) : Html::a('<span class="glyphicon glyphicon-ban-circle" ></span>', "#", ['title' => 'Alteração não permitida!']);
}, 'upload' => function ($url, $model) {
    return $model->status_id != 98 ? Html::a('<span class="glyphicon glyphicon-upload" ></span>', $url, ['title' => 'Anexar Arquivo']) : '';
}]]]]);
?>
Example #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTypeperson()
 {
     return $this->hasOne(Typeperson::className(), ['id' => 'typeperson_id']);
 }