You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
4.4 KiB

  1. <?php
  2. session_start();
  3. header('Content-Type: text/html; charset=UTF-8');
  4. $db = include("config.php");
  5. ?>
  6. <html>
  7. <head>
  8. <meta charset="utf-8">
  9. <meta name="viewport" content="width=device-width, initial-scale=1">
  10. <title>FutureBuilding Shop - Cart</title>
  11. <script src="https://code.jquery.com/jquery-3.5.0.min.js"></script>
  12. <script src="js/bootstrap.js"></script>
  13. <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
  14. <link rel="stylesheet" type="text/css" href="css/style.css">
  15. </head>
  16. <body>
  17. <nav class="navbar fixed-top navbar-light bg-light navbar-expand border">
  18. <a class="navbar-brand" href="index.php">FutureBuilding</a>
  19. <ul class="navbar-nav">
  20. <li class="nav-item dropdown">
  21. <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  22. Меню
  23. </a>
  24. <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
  25. <a class="nav-link" href="shop.php">Каталог товаров</a>
  26. <a class="nav-link" href="projects.php">Наши проекты</a>
  27. <a class="nav-link" href="brigade.php">Строительная бригада</a>
  28. </div>
  29. </li>
  30. <li class="nav-item">
  31. <a class="nav-link active" href="cart.php">Корзина</a>
  32. </li>
  33. </ul>
  34. </nav>
  35. <div class="container">
  36. <table class="table table-bordered">
  37. <tr>
  38. <th>Товар</th>
  39. <th>Кол.</th>
  40. <th>Итого</th>
  41. <th></th>
  42. </tr>
  43. <?php
  44. if (!empty($_SESSION["cart"])) {
  45. $total = 0;
  46. foreach ($_SESSION["cart"] as $keys => $values) {
  47. ?>
  48. <tr>
  49. <td><?php echo $values["item_name"] ?></td>
  50. <td><?php echo $values["item_quantity"] ?></td>
  51. <td><?php echo $values["item_price"] * $values["item_quantity"] ?> ₸</td>
  52. <td><button onclick="delitem(<?php echo $values['item_id'] ?>)" class="btn btn-danger">X </button></td>
  53. </tr>
  54. <?php
  55. $total = $total + ($values["item_price"] * $values["item_quantity"]);
  56. }
  57. ?>
  58. <tr>
  59. <td colspan="2" style="text-align:right">Итого</td>
  60. <td style="text-align:right"><?php echo $total ?> ₸</td>
  61. <td></td>
  62. </tr>
  63. <?php
  64. }
  65. ?>
  66. </table>
  67. <button onclick="destr()" class="btn btn-danger">Очистить корзину</button>
  68. <div class="send">
  69. <h3>Подать заявку</h3>
  70. <form action="submit.php" method="post">
  71. <input id="fname" required type="text" name="name" placeholder="Ваше полное имя" /> <br>
  72. <input id="fadress" required type="text" name="adress" placeholder="Ваш адрес" /> <br>
  73. <input id="fcontacts" required type="text" name="contacts" placeholder="Ваши контакты" /> <br>
  74. <input class="btn btn-success" type="submit" value="Подать заявку" />
  75. </form>
  76. </div>
  77. </div>
  78. <script>
  79. function delitem(idid) {
  80. jQuery(document).ready(function($) {
  81. $.ajax({
  82. type: 'GET',
  83. url: 'delete.php',
  84. data: {
  85. action: "delete",
  86. del: idid
  87. },
  88. success: function(res) {
  89. location.reload();
  90. }
  91. });
  92. });
  93. }
  94. function destr() {
  95. jQuery(document).ready(function($) {
  96. $.ajax({
  97. type: 'GET',
  98. url: 'destroy.php',
  99. data: {},
  100. success: function(res) {
  101. location.reload();
  102. }
  103. });
  104. });
  105. }
  106. </script>
  107. <footer class="page-footer font-small blue border">
  108. <div class="footer-copyright text-center py-3">
  109. ©FutureBuilding
  110. </div>
  111. </footer>
  112. </body>