/** * 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); }
/** * Delete multiple existing PartidaPartida model. * For ajax request will return json object * and for non-ajax request if deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionBulkDelete() { $request = Yii::$app->request; $pks = $request->post('pks'); // Array or selected records primary keys foreach (PartidaPartida::findAll(json_decode($pks)) as $model) { $model->delete(); } if ($request->isAjax) { /* * Process for ajax request */ Yii::$app->response->format = Response::FORMAT_JSON; return ['forceClose' => true, 'forceReload' => 'true']; } else { /* * Process for non-ajax request */ return $this->redirect(['index']); } }