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