示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PartidaPartida::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(['cuenta' => $this->cuenta, 'partida' => $this->partida, 'estatus' => $this->estatus]);
     $query->andFilterWhere(['estatus' => $this->nombreEstatus]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre]);
     return $dataProvider;
 }
示例#2
0
 /**
  * Guardar en la tabla proyecto_distribucion_presupuestaria
  * @return \yii\db\ActiveQuery
  */
 public function afterSave($insert, $changedAttributes)
 {
     $partidas = PartidaPartida::find()->all();
     if (!$insert) {
         //nada
     } else {
         foreach ($partidas as $key => $value) {
             $distribucion = new ProyectoDistribucionPresupuestaria();
             $distribucion->id_accion_especifica = $this->id;
             $distribucion->id_partida = $value->id;
             $distribucion->cantidad = 0;
             $distribucion->save(false);
         }
     }
     return parent::afterSave($insert, $changedAttributes);
 }
示例#3
0
 public function getpartidaPartida()
 {
     return $this->hasOne(PartidaPartida::className(), ['cuenta' => 'cuenta', 'partida' => 'partida']);
 }
示例#4
0
 /**
  * Finds the PartidaPartida model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return PartidaPartida the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($cuenta, $partida)
 {
     if (($model = PartidaPartida::findOne(['cuenta' => $cuenta, 'partida' => $partida])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }