K. api / vista-carrito.php

1
<?php
2
3
require_once __DIR__ . "/../libservidorphp/manejaErrores.php";
4
require_once __DIR__ . "/../libservidorphp/devuelveJson.php";
5
require_once __DIR__ . "/../libservidorphp/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::conexion();
12
13
$venta = ventaEnCapturaBusca($bd);
14
$venta = validaEntidadObligatoria("Venta en captura",  $venta);
15
16
$detalles = detVentaConsulta($bd, $venta["VNT_ID"]);
17
18
$renderDetalles = "";
19
foreach ($detalles as $detVenta) {
20
 $prodId = $detVenta["DTV_PRD_ID"];
21
 $query = htmlentities(http_build_query(["prodId" => $prodId]));
22
 $urlModifica = "modifica.html?$query";
23
 $prodNombre = htmlentities($detVenta["PRD_NOMBRE"]);
24
 $precio = htmlentities("$" . number_format($detVenta["PRD_PRECIO"], 2));
25
 $cantidad = htmlentities(number_format($detVenta["DTV_CANTIDAD"], 2));
26
 $renderDetalles .=
27
  "<dt>$prodNombre</dt>
28
    <dd>
29
     <a href= '$urlModifica'>Modificar o eliminar</a>
30
    </dd>
31
    <dd>
32
     <dl>
33
      <dt>Cantidad</dt>
34
      <dd>$cantidad</dd>
35
      <dt>Precio</dt>
36
      <dd>$precio</dd>
37
     </dl>
38
    </dd>";
39
}
40
41
devuelveJson([
42
 "folio" => ["value" => $venta["VNT_ID"]],
43
 "detalles" => ["innerHTML" => $renderDetalles]
44
]);
45
skip_previous skip_next