/** * 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; }
/** * 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); }
public function getpartidaPartida() { return $this->hasOne(PartidaPartida::className(), ['cuenta' => 'cuenta', 'partida' => 'partida']); }
/** * 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.'); } }