Guest User

Untitled

a guest
Mar 22nd, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. <?php
  2. include_once "encabezado.php";
  3. session_start();
  4. if(!isset($_SESSION["carrito"])) $_SESSION["carrito"] = [];
  5. $granTotal = 0;
  6. ?>
  7. <div class="col-xs-12">
  8. <h1>Vender</h1>
  9. <?php
  10. if(isset($_GET["status"])){
  11. if($_GET["status"] === "1"){
  12. ?>
  13. <div class="alert alert-success">
  14. <strong>¡Correcto!</strong> Venta realizada correctamente
  15. </div>
  16. <?php
  17. }else if($_GET["status"] === "2"){
  18. ?>
  19. <div class="alert alert-info">
  20. <strong>Venta cancelada</strong>
  21. </div>
  22. <?php
  23. }else if($_GET["status"] === "3"){
  24. ?>
  25. <div class="alert alert-info">
  26. <strong>Ok</strong> Producto quitado de la lista
  27. </div>
  28. <?php
  29. }else if($_GET["status"] === "4"){
  30. ?>
  31. <div class="alert alert-warning">
  32. <strong>Error:</strong> El producto que buscas no existe
  33. </div>
  34. <?php
  35. }else if($_GET["status"] === "5"){
  36. ?>
  37. <div class="alert alert-danger">
  38. <strong>Error: </strong>El producto está agotado
  39. </div>
  40. <?php
  41. }else{
  42. ?>
  43. <div class="alert alert-danger">
  44. <strong>Error:</strong> Algo salió mal mientras se realizaba la venta
  45. </div>
  46. <?php
  47. }
  48. }
  49. ?>
  50. <br>
  51. <form method="post" action="agregarAlCarrito.php">
  52. <label for="codigo">Código de barras:</label>
  53. <input autocomplete="off" autofocus class="form-control" name="codigo" required type="text" id="codigo" placeholder="Escribe el código">
  54. </form>
  55. <br><br>
  56. <table class="table table-bordered">
  57. <thead>
  58. <tr>
  59. <th>ID</th>
  60. <th>Código</th>
  61. <th>Descripción</th>
  62. <th>Precio de venta</th>
  63. <th>Cantidad</th>
  64. <th>Total</th>
  65. <th>Quitar</th>
  66. </tr>
  67. </thead>
  68. <tbody>
  69. <?php foreach($_SESSION["carrito"] as $indice => $producto){
  70. $granTotal += $producto->total;
  71. ?>
  72. <tr>
  73. <td><?php echo $producto->id ?></td>
  74. <td><?php echo $producto->codigo ?></td>
  75. <td><?php echo $producto->descripcion ?></td>
  76. <td><?php echo $producto->precioVenta ?></td>
  77. <td><?php echo $producto->cantidad ?></td>
  78. <td><?php echo $producto->total ?></td>
  79. <td><a class="btn btn-danger" href="<?php echo "quitarDelCarrito.php?indice=" . $indice?>"><i class="fa fa-trash"></i></a></td>
  80. </tr>
  81. <?php } ?>
  82. </tbody>
  83. </table>
  84.  
  85. <h3>Total: <?php echo $granTotal; ?></h3>
  86. <form action="./terminarVenta.php" method="POST">
  87. <input name="total" type="hidden" value="<?php echo $granTotal;?>">
  88. <button type="submit" class="btn btn-success">Terminar venta</button>
  89. <a href="./cancelarVenta.php" class="btn btn-danger">Cancelar venta</a>
  90. </form>
  91. </div>
  92. <?php include_once "pie.php" ?>
Add Comment
Please, Sign In to add comment