$venta->setCliente($sessionCliente['rut']); $hoy = getdate(); $dia = $hoy['mday'] - 1; $fecha = $hoy['year'] . '-' . $hoy['mon'] . '-' . $dia; $venta->setFecha($fecha); $venta->setCarrito($carroDal->countCarrito() - 1); $venta->setDespacho($despachoDal->countDespacho() - 1); echo $venta->getCarrito(); //SET VENTA $insertVenta = $ventaDAl->insertVenta($venta); switch ($insertVenta) { case 1: //Descuenta todos los stock que estan en la lista for ($i = 0; $i < count($listCarro); $i++) { $idProducto = $listCarro[$i]['idProducto']; $stock = $productoDal->stockProducto($idProducto) - $listCarro[$i]['stock']; $productoDal->updateProductoStock($stock, $idProducto); } break; default: echo "Venta: " . $ventaDAl->insertVenta($venta); break; } header("Location: procesar_venta_producto.php"); } else { header("Location: ../index.php"); } } catch (Exception $e) { //Error Genérico: header("Location: ../index.php"); }