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))); } } }
?> </table> </div> </div> <?php } ?> <div class="row"> <div class="span1"></div> <div class="span10"> <?php $losSucesos = PacienteSucesos::model()->findAll("paciente_id = {$model->id}"); if ($losSucesos) { ?> <h3 class="text-center">Sucesos Registrados</h3> <table class="table table-striped"> <tr> <th>Fecha</th> <th>Suceso</th> <th>Registrado por:</th> <th></th> </tr> <?php foreach ($losSucesos as $los_sucesos) { ?> <tr> <td><small><?php
/** * 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 $id the ID of the model to be loaded * @return PacienteSucesos the loaded model * @throws CHttpException */ public function loadModel($id) { $model = PacienteSucesos::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }