/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Convocatoria::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, 'fecha_inicio' => $this->fecha_inicio, 'fecha_fin' => $this->fecha_fin, 'tipo' => $this->tipo, 'activa' => $this->activa]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'descripcion', $this->descripcion]);
     return $dataProvider;
 }
 /**
  * Finds the Convocatoria model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Convocatoria the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Convocatoria::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getConvocatoria0()
 {
     return $this->hasOne(Convocatoria::className(), ['id' => 'convocatoria']);
 }
Example #4
0
 public function actionConvocatorias()
 {
     //'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) {
             $categoria = $parents[0];
             $subcategoria = $parents[1];
             if ($subcategoria == 4 || $subcategoria == 7) {
                 $list = Convocatoria::find()->where(['tipo' => $categoria])->asArray()->all();
             } else {
                 $list = [];
             }
             //$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['descripcion']];
             }
             // 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' => '']);
 }
 public function update(Request $request, $id)
 {
     try {
         AuthenticateController::checkUser('Supervisor');
         $convocatoria = Convocatoria::find($id);
         if ($convocatoria != null) {
             $convocatoria->fill($request->all());
             $convocatoria->save();
             return response()->json($convocatoria, 200);
         }
         return response()->json(['message' => 'convocatoria_not_found'], 404);
     } catch (QueryException $e) {
         return response()->json(['message' => 'server_error', 'exception' => $e->getMessage()], 500);
     } catch (Exceptions\TokenExpiredException $e) {
         return response()->json(['token_expired'], $e->getStatusCode());
     } catch (Exceptions\TokenInvalidException $e) {
         return response()->json(['token_invalid'], $e->getStatusCode());
     } catch (UnauthorizedException $e) {
         return response()->json(['unauthorized'], $e->getStatusCode());
     } catch (Exceptions\JWTException $e) {
         return response()->json(['token_absent'], $e->getStatusCode());
     }
 }
Example #6
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>
Example #7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getConvocatorias()
 {
     return $this->hasMany(Convocatoria::className(), ['tipo' => 'id']);
 }