Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 27, 2019 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/4b42f7b394f2066cf57851e783ea2d43 to your computer and use it in GitHub Desktop.
Save parzibyte/4b42f7b394f2066cf57851e783ea2d43 to your computer and use it in GitHub Desktop.
<div class="row">
<div class="col-xs-12">
<table class="table table-condensed table-bordered table-striped">
<thead>
<tr>
<th>Descripción</th>
<th>Cantidad</th>
<th>Precio unitario</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<?php
$subtotal = 0;
foreach ($productos as $producto) {
$totalProducto = $producto["cantidad"] * $producto["precio"];
$subtotal += $totalProducto;
?>
<tr>
<td><?php echo $producto["descripcion"] ?></td>
<td><?php echo number_format($producto["cantidad"], 2) ?></td>
<td>$<?php echo number_format($producto["precio"], 2) ?></td>
<td>$<?php echo number_format($totalProducto, 2) ?></td>
</tr>
<?php }
$subtotalConDescuento = $subtotal - $descuento;
$impuestos = $subtotalConDescuento * ($porcentajeImpuestos / 100);
$total = $subtotalConDescuento + $impuestos;
?>
</tbody>
<tfoot>
<tr>
<td colspan="3" class="text-right">Subtotal</td>
<td>$<?php echo number_format($subtotal, 2) ?></td>
</tr>
<tr>
<td colspan="3" class="text-right">Descuento</td>
<td>$<?php echo number_format($descuento, 2) ?></td>
</tr>
<tr>
<td colspan="3" class="text-right">Subtotal con descuento</td>
<td>$<?php echo number_format($subtotalConDescuento, 2) ?></td>
</tr>
<tr>
<td colspan="3" class="text-right">Impuestos</td>
<td>$<?php echo number_format($impuestos, 2) ?></td>
</tr>
<tr>
<td colspan="3" class="text-right">
<h4>Total</h4></td>
<td>
<h4>$<?php echo number_format($total, 2) ?></h4>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment