/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Obras(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Obras'])) { $model->attributes = $_POST['Obras']; if (empty($model->fech_fin)) { $fecha_pedazos = explode("-", $model->fech_ini); $fecha_pedazos[0] += 5; $model->fech_fin = implode("-", $fecha_pedazos); } if ($model->save()) { date_default_timezone_set('America/Caracas'); } $auditoria = new Auditoria(); $auditoria->id_user = Yii::app()->user->getId(); $auditoria->accion = 2; $auditoria->modelo = $this->modelo; $auditoria->id_registro = $model->id; $auditoria->fecha = date("Y-m-d h:i:s"); $auditoria->save(false); $this->redirect(array('view', 'id' => $model->id)); } $this->render('create', array('model' => $model)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Obras(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Obras'])) { $model->attributes = $_POST['Obras']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->idobra)); } } $this->render('create', array('model' => $model)); }