示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProyectoAeMeta::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, 'id_proyecto_accion_especifica' => $this->id_proyecto_accion_especifica, 'enero' => $this->enero, 'febrero' => $this->febrero, 'marzo' => $this->marzo, 'abril' => $this->abril, 'mayo' => $this->mayo, 'junio' => $this->junio, 'julio' => $this->julio, 'agosto' => $this->agosto, 'septiembre' => $this->septiembre, 'octubre' => $this->octubre, 'noviembre' => $this->noviembre, 'diciembre' => $this->diciembre, 'status' => $this->status, 'fecha_creacion' => $this->fecha_creacion]);
     return $dataProvider;
 }
示例#2
0
 /**
  * Override afterSave.
  * @param boolean $insert Verificar si se inserta o actualiza.
  * @param array $changedAttributes Atributos que se van a guardar.
  * @return afterSave().
  */
 public function afterSave($insert, $changedAttributes)
 {
     if (!$insert) {
         //nada
     } else {
         //crear modelo relacionado
         $meta = new ProyectoAeMeta();
         //Llave foranea
         $meta->id_proyecto_accion_especifica = $this->id;
         //Colocar meses en cero
         $meta->enero = 0;
         $meta->febrero = 0;
         $meta->marzo = 0;
         $meta->abril = 0;
         $meta->mayo = 0;
         $meta->junio = 0;
         $meta->julio = 0;
         $meta->agosto = 0;
         $meta->septiembre = 0;
         $meta->octubre = 0;
         $meta->noviembre = 0;
         $meta->diciembre = 0;
         $meta->estatus = 1;
         //activo
         $meta->fecha_creacion = date('Y-m-d H:i:s');
         $meta->save(false);
     }
     return parent::afterSave($insert, $changedAttributes);
 }
示例#3
0
 /**
  * Finds the ProyectoAeMeta model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ProyectoAeMeta the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ProyectoAeMeta::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }