public function actionAnular() { $id = $_GET['idCompra']; if ($_POST['clave'] == "super") { $laCompra = ProductoCompras::model()->findByPk($id); $laCompra->comentario_anulado = $_POST['observaciones']; $laCompra->total_compra = $laCompra->total_compra * -1; $laCompra->estado = "Anulada"; if ($laCompra->update()) { $compraDetalle = ProductoCompraDetalle::model()->findAll("producto_compra_id = " . $laCompra->id); foreach ($compraDetalle as $compra_detalle) { $InventarioProducto = ProductoInventario::model()->findByPk($compra_detalle->producto_id); $InventarioProducto->cantidad = $InventarioProducto->cantidad - $compra_detalle->cantidad; $InventarioProducto->update(); } Yii::app()->user->setFlash('success', "Se ha realizado con éxito la anulación"); $this->redirect(array('view', 'id' => $id)); } } else { Yii::app()->user->setFlash('error', "Usted no esta autorizado para realizar esta anulación"); $this->redirect(array('view', 'id' => $id)); } }
<?php //Detalles $numCompra = $_GET['id']; $laCompra = ProductoCompras::model()->findByPk($numCompra); $detalleCompra = ProductoCompraDetalle::model()->findAll("producto_compra_id={$laCompra->id}"); ?> <style type="text/css"> p{ margin: 2px 0px; } </style> <body> <table> <tr> <td width="80"> <img src="images/logo_menbrete1.jpg" alt="" height="90"> </td> <td width="250"> <p style="text-align: center;">CALLE 87 No 47 – 47</p> <p style="text-align: center;">PBX 3177190</p> <p style="text-align: center;">BARRANQUILLA - COLOMBIA</p> </td> </tr> <tr> <td> <!-- columna izquierda --> <p>GENERADO: <?php
?> </td> <td><?php echo Yii::app()->dateformatter->format("dd-MM-yyyy", $producto_inventario->productoCompras->fecha); ?> </td> <td><?php echo $producto_inventario->lote; ?> </td> <td><?php echo $producto_inventario->cantidad_compra; ?> </td> <td><?php echo $producto_inventario->existencia; ?> </td> <td><?php $resultado_costo = ProductoCompraDetalle::model()->find("producto_compra_id = {$producto_inventario->compra_id} and producto_id = {$producto_inventario->producto_inventario_id}"); echo '$ ' . $resultado_costo->valor; ?> </td> </tr> <?php } ?> </table> </div> <div class="span3"></div> </div>
<div class="span12"> <table class="table table-striped"> <tr> <th width="8%"><small>Codigo</small></th> <th width="25%"><small>Producto</small></th> <th width="12%"><small>Presentación</small></th> <th width="6%"><small>Cant.</small></th> <th width="8%"><small>Unidad Medida</small></th> <th width="7%"><small>Lote.</small></th> <th width="8%"><small>Vence</small></th> <th width="7%"><small>Valor</small></th> <th width="9%"><small>IVA</small></th> <th width="15%"><small>Total</small></th> </tr> <?php $losProductos = ProductoCompraDetalle::model()->findAll("producto_compra_id = {$model->id}"); ?> <?php foreach ($losProductos as $los_productos) { if ($los_productos->fecha_vencimiento == '0000-00-00') { $fecha_vencimiento = '--------'; } else { $fecha_vencimiento = $los_productos->fecha_vencimiento = date('d-m-Y', strtotime($los_productos->fecha_vencimiento)); } ?> <tr> <td><?php echo $los_productos->producto->producto_referencia; ?> </td> <td><?php