Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Subcategoria::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'categoria' => $this->categoria]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre]);
     return $dataProvider;
 }
Пример #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSubtipo0()
 {
     return $this->hasOne(Subcategoria::className(), ['id' => 'subtipo']);
 }
Пример #3
0
 public function actionSubcategorias()
 {
     //'options' => ArrayHelper::map(PartesModelo::findAll(['TipoTramite_id'=>$model->TipoTramite_id]), 'vista', 'nombre'),
     $out = [];
     if (isset($_POST['depdrop_parents'])) {
         $parents = $_POST['depdrop_parents'];
         if ($parents != null) {
             $data = $parents[0];
             //$id_categoria = Comite::findOne(['id'=>$data])->tipo0->id;
             $list = Subcategoria::find()->where(['categoria' => $data])->asArray()->all();
             //$out = self::getSubCatList($paso_tipotramite_id);
             //$out = ArrayHelper::map(PartesModelo::findAll(['TipoTramite_id'=>$paso_tipotramite_id]), 'vista', 'nombre');
             foreach ($list as $i => $item) {
                 $out[] = ['id' => $item['id'], 'name' => $item['nombre']];
             }
             // the getSubCatList function will query the database based on the
             // cat_id and return an array like below:
             // [
             //    ['id'=>'<sub-cat-id-1>', 'name'=>'<sub-cat-name1>'],
             //    ['id'=>'<sub-cat_id_2>', 'name'=>'<sub-cat-name2>']
             // ]
             echo Json::encode(['output' => $out, 'selected' => '']);
             return;
         }
     }
     echo Json::encode(['output' => '', 'selected' => '']);
 }
Пример #4
0
 public function show($id)
 {
     try {
         $dados['imagens'] = Midia::imagens($this->tipo_midia, $id);
         $dados['destacada'] = Midia::destacada($this->tipo_midia, $id);
         $dados['put'] = true;
         $dados['subcategorias'] = Subcategoria::subs($this->tipo_categoria);
         $dados['dados'] = Noticia::findOrFail($id);
         $dados['route'] = 'admin/noticias/atualizar/' . $id;
         return view('admin/noticias/dados', $dados);
     } catch (\Exception $e) {
         LogR::exception('show noticias', $e);
         session()->flash('flash_message', 'Ops!! Ocorreu algum problema!. ' . $e->getMessage());
         return Redirect::back();
     }
 }
 public function getAll()
 {
     return \Response::json(array('datos' => Subcategoria::with(['Categoria'])->orderBy('ad_subcategoria.nombre_subcategoria')->get()));
 }
Пример #6
0
 public function updateStatus($status, $id)
 {
     try {
         $dado = Subcategoria::findOrFail($id);
         $dado->status = $status;
         $dado->save();
         session()->flash('flash_message', 'Status alterado com sucesso!');
     } catch (\Exception $e) {
         LogR::exception($dado, $e);
         session()->flash('flash_message', 'Ops!! Ocorreu algum problema!. ' . $e->getMessage());
     }
     return Redirect::back();
 }
Пример #7
0
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Create Comite'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'nombre', ['attribute' => 'fecha_inicio', 'filter' => DateControl::widget(['name' => 'fecha_inicio', 'attribute' => 'fecha_inicio', 'model' => $searchModel, 'type' => DateControl::FORMAT_DATE])], ['attribute' => 'tipo', 'value' => function ($model) {
    return Categoria::findOne(['id' => $model->tipo])->nombre;
}, 'filter' => Select2::widget(['name' => 'tipo', 'attribute' => 'tipo', 'model' => $searchModel, 'data' => ArrayHelper::map(Categoria::find()->all(), 'id', 'nombre'), 'options' => ['placeholder' => 'Categoría'], 'pluginOptions' => ['allowClear' => true]])], ['attribute' => 'subtipo', 'value' => function ($model) {
    return Subcategoria::findOne(['id' => $model->subtipo])->nombre;
}, 'filter' => Select2::widget(['name' => 'subtipo', 'attribute' => 'subtipo', 'model' => $searchModel, 'data' => ArrayHelper::map(Subcategoria::find()->all(), 'id', 'nombre'), 'options' => ['placeholder' => 'Subcategoría'], 'pluginOptions' => ['allowClear' => true]])], ['attribute' => 'convocatoria', 'value' => function ($model) {
    if (!empty(Convocatoria::findOne(['id' => $model->convocatoria]))) {
        return Convocatoria::findOne(['id' => $model->convocatoria])->descripcion;
    } else {
        return "N/A";
    }
}, 'filter' => Select2::widget(['name' => 'convocatoria', 'attribute' => 'convocatoria', 'model' => $searchModel, 'data' => ArrayHelper::map(Convocatoria::find()->all(), 'id', 'nombre'), 'options' => ['placeholder' => 'Convocatoria'], 'pluginOptions' => ['allowClear' => true]])], 'observaciones:ntext', ['attribute' => '', 'format' => 'raw', 'value' => function ($model) {
    return Html::a('Proyectos', ['/faer/index2', 'id' => $model->id], ['class' => 'btn btn-success btn-xs', 'style' => 'border-radius:4px;']);
}], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Пример #8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSubcategorias()
 {
     return $this->hasMany(Subcategoria::className(), ['categoria' => 'id']);
 }
Пример #9
0
 /**
  * Finds the Subcategoria model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Subcategoria the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Subcategoria::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }