/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new PacienteSucesos(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['PacienteSucesos'])) { $model->attributes = $_POST['PacienteSucesos']; $model->fecha = date("Y-m-d H:i:s"); $model->usuario_id = Yii::app()->user->usuarioId; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function actionView($id) { if (isset($_POST['SeguimientoComercial'])) { $model = new SeguimientoComercial(); $model->fecha_accion = Yii::app()->dateformatter->format("yyyy-MM-dd", $_POST['SeguimientoComercial']['fecha_accion']); $model->tema_id = $_POST['SeguimientoComercial']['tema_id']; $model->responsable_id = $_POST['SeguimientoComercial']['responsable_id']; $model->observaciones = $_POST['SeguimientoComercial']['observaciones']; $model->paciente_id = $_POST['SeguimientoComercial']['paciente_id']; $model->id_personal = Yii::app()->user->usuarioId; $model->fecha_registro = date("Y-m-d"); $model->tipo = "Paciente"; //Fecha de registro $model->estado = "Abierto"; $model->save(); //Redireccionar Yii::app()->user->setFlash('success', "Se creo el Seguimiento Comercial."); $this->render('view', array('model' => $this->loadModel($id))); } else { if (isset($_POST['PacienteSucesos'])) { $model = new PacienteSucesos(); $model->attributes = $_POST['PacienteSucesos']; $model->suceso = $_POST['PacienteSucesos']['suceso']; $model->fecha = date("Y-m-d H:i:s"); $model->usuario_id = Yii::app()->user->usuarioId; $model->save(); //Redireccionar Yii::app()->user->setFlash('success', "Se Registro el Suceso."); $this->render('view', array('model' => $this->loadModel($id))); } else { $this->render('view', array('model' => $this->loadModel($id))); } } }