/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Facturas(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Facturas'])) { $model->attributes = $_POST['Facturas']; $model->proveedor_id = $_POST['proveedor_id']; $model->cierre_carga = false; $usuario = Usuarios::model()->findByPk(Yii::app()->user->getId()); $model->ente_organo_id = $usuario->ente_organo_id; $model->anho = Yii::app()->params['trimestresFechas'][Yii::app()->session['trimestreSeleccionado']]['anho']; //date("Y"); if ($model->save()) { $proveedores_eo = new ProveedoresEntesOrganos(); $proveedores_eo->proveedor_id = $model->proveedor_id; $proveedores_eo->ente_organo_id = $model->ente_organo_id; $proveedores_eo->save(); $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = ProveedoresEntesOrganos::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }