/** * 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 NotaCredito the loaded model * @throws CHttpException */ public function loadModel($id) { $model = NotaCredito::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php //Datos de Contrato e Ingreso $elContrato = Contratos::model()->findByPk($_GET['idContrato']); if (isset($_GET['idIngreso'])) { $elIngreso = Ingresos::model()->findByPk($_GET['idIngreso']); } if (isset($_GET['idNota'])) { $elIngreso = NotaCredito::model()->findByPk($_GET['idNota']); } $this->menu = array(array('label' => 'Buscar Contratos', 'url' => array('admin'))); ?> <h1>Vincular Ingreso a Contrato</h1> <div class="row"> <div class="span12"></div> </div> <h5>Se dispone a vincular el ingreso de <span class="text-info">$ <?php echo number_format($elIngreso->valor, 2); ?> </span> a contrato con un saldo de <span class="text-error">$ <?php echo number_format($elContrato->saldo, 2); ?> </span>.</h5> <h3>Nuevo saldo despues de la vinculación: <span class="text-warning">$ <?php echo number_format($elContrato->saldo - $elIngreso->valor, 2); ?> </span></h3> <div class="row"> <div class="span2"></div>
echo $tratamientos_realizados->cita->personal->nombreCompleto; ?> </td> </tr> <?php } } ?> </table> <hr> <?php $detalleNotaCredito = NotaCredito::model()->findAll("paciente_id = {$model->paciente_id} and contrato_asociado_id is NULL"); if ($detalleNotaCredito) { ?> <!-- Notas de Crédito --> <h4 class="text-center">Notas de Crédito Disponible sin Contrato Vinculado</h4> <table class="table table-striped"> <tr> <th><small>Valor</small></th> <th><small>Realizado por</small></th> <th><small>Fecha</small></th> <th></th> </tr> <?php foreach ($detalleNotaCredito as $detalle_notaCredito) { ?> <tr>
public function actionVincularNota() { if (isset($_GET['confirmado'])) { //Vincular Ingreso a Contrato $elContrato = Contratos::model()->findByPk($_GET['idContrato']); $elIngreso = NotaCredito::model()->findByPk($_GET['idNota']); $nuevoIngreso = new Ingresos(); $nuevoIngreso->paciente_id = $elContrato->paciente_id; $nuevoIngreso->n_identificacion = $elContrato->n_identificacion; $nuevoIngreso->contrato_id = $elContrato->id; $nuevoIngreso->valor = $elIngreso->valor; $nuevoIngreso->descripcion = "Nota de Crédito N° " . $elIngreso->id; $nuevoIngreso->centro_costo_id = 60; $nuevoIngreso->forma_pago = "Nota de Crédito"; $nuevoIngreso->fecha_sola = date("Y-m-d"); $nuevoIngreso->fecha = date("Y-m-d H:i:s"); $nuevoIngreso->personal_id = Yii::app()->user->usuarioId; $nuevoIngreso->estado = "Activo"; $nuevoIngreso->vendedor_id = Yii::app()->user->usuarioId; if ($nuevoIngreso->save()) { //Descontar de Caja Personal $elContrato->saldo = $elContrato->saldo - $nuevoIngreso->valor; $elContrato->update(); $elIngreso->contrato_asociado_id = $elContrato->id; $elIngreso->update(); Yii::app()->user->setFlash('success', "Se ha vinculado."); $this->redirect(array('view', 'id' => $_GET['idContrato'])); } else { Yii::app()->user->setFlash('error', "No se ha vinculado."); $this->redirect(array('view', 'id' => $_GET['idContrato'])); } } else { $this->render('vincular', array()); } }