| 1 | <?php |
| 2 | |
| 3 | require_once __DIR__ . "/lib/manejaErrores.php"; |
| 4 | require_once __DIR__ . "/lib/devuelveJson.php"; |
| 5 | require_once __DIR__ . "/lib/validaEntidadObligatoria.php"; |
| 6 | require_once __DIR__ . "/Bd.php"; |
| 7 | require_once __DIR__ . "/ventaEnCapturaBusca.php"; |
| 8 | require_once __DIR__ . "/detVentaConsulta.php"; |
| 9 | require_once __DIR__ . "/Bd.php"; |
| 10 | |
| 11 | $bd = Bd::pdo(); |
| 12 | |
| 13 | $venta = ventaEnCapturaBusca($bd); |
| 14 | $venta = validaEntidadObligatoria("Venta en captura", $venta); |
| 15 | |
| 16 | $detalles = detVentaConsulta($bd, $venta["VENT_ID"]); |
| 17 | |
| 18 | $renderDetalles = ""; |
| 19 | foreach ($detalles as $detVenta) { |
| 20 | $encodeProdId = urlencode($detVenta["PROD_ID"]); |
| 21 | $prodId = htmlentities($encodeProdId); |
| 22 | $prodNombre = htmlentities($detVenta["PROD_NOMBRE"]); |
| 23 | $precio = htmlentities("$" . number_format($detVenta["PROD_PRECIO"], 2)); |
| 24 | $cantidad = htmlentities(number_format($detVenta["DTV_CANTIDAD"], 2)); |
| 25 | $renderDetalles .= |
| 26 | "<dt>$prodNombre</dt> |
| 27 | <dd> |
| 28 | <a href= 'modifica.html?prodId=$prodId'>Modificar o eliminar</a> |
| 29 | </dd> |
| 30 | <dd> |
| 31 | <dl> |
| 32 | <dt>Cantidad</dt> |
| 33 | <dd>$cantidad</dd> |
| 34 | <dt>Precio</dt> |
| 35 | <dd>$precio</dd> |
| 36 | </dl> |
| 37 | </dd>"; |
| 38 | } |
| 39 | |
| 40 | devuelveJson([ |
| 41 | "folio" => ["value" => $venta["VENT_ID"]], |
| 42 | "detalles" => ["innerHTML" => $renderDetalles] |
| 43 | ]); |
| 44 | |