<!-- Otra parte --> <div class="span8"> <h4 class="text-center">Detalles de la Venta</h4> <table class="table table-striped"> <tr> <th>Producto</th> <th>Presentacion</th> <th>Cantidad</th> <th>Valor</th> <th>IVA</th> <th>Total</th> </tr> <?php $losProductos = VentasDetalle::model()->findAll("venta_id = {$model->id}"); ?> <?php foreach ($losProductos as $los_productos) { ?> <tr> <td><?php echo $los_productos->producto->nombre_producto; ?> </td> <td><?php echo $los_productos->producto->productoPresentacion->presentacion; ?> </td> <td><?php echo $los_productos->cantidad;
<?php //Detalles $numVentas = $_GET['id']; $lasVentas = Ventas::model()->findByPk($numVentas); $detalleVenta = VentasDetalle::model()->findAll("venta_id={$numVentas}"); ?> <style type="text/css"> p{ margin: 2px 0px; } </style> <table> <tr> <td width="200"> <p>MARIA ANGELICA DIAZ</p> <br> <p>NIT: 39.017.694-2</p> <p>CALLE 87 N° 47 – 47</p> <p>PBX: 3177190</p> <p>RES. REGIMEN SIMPLIFICADO</p> <p>ORDEN DE PAGO N°: <?php echo $lasVentas->id; ?> </p> <p>FECHA: <?php echo $lasVentas->fecha; ?>
/** * 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 VentasDetalle the loaded model * @throws CHttpException */ public function loadModel($id) { $model = VentasDetalle::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionAnular($id) { $lasConfiguraciones = Configuraciones::model()->findByPk(1); if ($_POST['clave'] == $lasConfiguraciones->super_usuario) { if ($_POST['observacion_anular'] == "") { Yii::app()->user->setFlash('error', "Falta observación, no se realizo la anulación."); $this->redirect(array('view', 'id' => $id)); } $datosVenta = Ventas::model()->findByPk($id); $datosVenta->estado = "Anulada"; $datosVenta->total_venta = $datosVenta->total_venta; $datosVenta->fecha_anulada = date("Y-m-d H:i:s"); $datosVenta->comentario_anulada = $_POST['observacion_anular']; if ($datosVenta->update()) { //Verificar tipo de pago if ($datosVenta->forma_pago == "Efectivo") { $laCaja = CajaEfectivo::model()->findByPk($datosVenta->personal); //validar if ($datosVenta->total2 > 0) { $laCaja->total = $laCaja->total - $datosVenta->total1; } else { $laCaja->total = $laCaja->total - $datosVenta->total_venta; } $laCaja->update(); $datoCajaDetalle = CajaEfectivoDetalle::model()->find("venta_id = {$datosVenta->id}"); $datoCajaDetalle->tipo = "Venta Anulada"; $datoCajaDetalle->monto = $datoCajaDetalle->monto * -1; $datoCajaDetalle->update(); } //Regresar productos al inventario $productosVenta = VentasDetalle::model()->findAll("venta_id = {$datosVenta->id}"); foreach ($productosVenta as $producto_venta) { $elProducto = ProductoInventario::model()->findByPk($producto_venta->producto_id); $elProducto->cantidad = $elProducto->cantidad + $producto_venta->cantidad; $elProducto->update(); } Yii::app()->user->setFlash('success', "Se completo la anulación."); $this->redirect(array('view', 'id' => $datosVenta->id)); } } else { Yii::app()->user->setFlash('error', "Clave incorrecta, no se realizo la anulación."); $this->redirect(array('view', 'id' => $id)); } }