shoppingcart.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. include("session_check.php");
  3. include("header.php");
  4. include("menu.php");
  5. ?>
  6. <!-- <a href="javascript: history.back();">Zur&uuml;ck</a> -->
  7. <form name="shoppingcart_set_template" action="shoppingcart_set_template.php" method="POST">
  8. <input type="hidden" value="set_template" name="action">
  9. <input type="submit" value="" class="invisible_submit">
  10. </form>
  11. <form name="shoppingcart_load_template" action="shoppingcart.php" method="POST">
  12. <input type="hidden" value="load_template" name="action">
  13. <input type="submit" value="" class="invisible_submit">
  14. </form>
  15. <div width="100%" align="center">
  16. <big> Warenkorb </big>
  17. <table border="0" width="80%">
  18. <tr class="table_header">
  19. <td width="80px" align="center">ProduktNr.</td>
  20. <td align="center">Bezeichnung</td>
  21. <td align="center">Zusatz</td>
  22. <td width="30px" align="center">Menge</td>
  23. <td align="center">Anmerkung</td>
  24. <td width="40px" align="center">Preis(EUR)</td>
  25. <td colspan="2" width="200px">&nbsp;</td>
  26. </tr>
  27. <tr>
  28. <td colspan="6">&nbsp;</td>
  29. </tr>
  30. <?php
  31. /* load or initialize the ShoppingCart */
  32. if(!isset($shopping_cart))
  33. {
  34. if(isset($_SESSION["cart_product_id_array"]))
  35. $shopping_cart = new ShoppingCart($_SESSION["username"], $_SESSION["cart_product_id_array"], $_SESSION["cart_product_amount_array"]);
  36. else
  37. $shopping_cart = new ShoppingCart($_SESSION["username"]);
  38. }
  39. $list = $shopping_cart->getItems();
  40. /* if there were any actions, set the focus to the next item */
  41. $prev_edit_product_id = "";
  42. $set_focus_next = false;
  43. if (var_get_post("action", "") == "edit_product_amount") {
  44. $prev_edit_product_id = var_get_post("product_id", "");
  45. }
  46. for($i = 0; $i < count($list); $i++)
  47. {
  48. echo "\t<tr class=\"list_normal\" onmouseover=\"javascript: this.className='list_hover';\" onmouseout=\"javascript: this.className='list_normal';\">\n";
  49. echo "\t<form name=\"edit_product_amount_".$list[$i][0]."\" action=\"shoppingcart.php\" method=\"POST\">\n";
  50. echo "\t<input type=\"hidden\" name=\"action\" value=\"edit_product_amount\">\n";
  51. echo "\t<input type=\"hidden\" name=\"product_id\" value=\"".$list[$i][0]."\">\n";
  52. echo "\t<input type=\"submit\" value=\"\" class=\"invisible_submit\">\n";
  53. echo "\t\t<td onclick=\"javascript: window.location.href = 'product_details.php?product_id=".$list[$i][0]."';\">".$list[$i][0]."</td>\n";
  54. echo "\t\t<td onclick=\"javascript: window.location.href = 'product_details.php?product_id=".$list[$i][0]."';\">".$list[$i][1]."</td>\n";
  55. echo "\t\t<td onclick=\"javascript: window.location.href = 'product_details.php?product_id=".$list[$i][0]."';\">".$list[$i][4]."</td>\n";
  56. echo "\t\t<td width=\"30px\"><input type=\"text\" name=\"product_amount\" id=\"product_amount_".$list[$i][0]."\" class=\"list_cell\" value=\"".$list[$i][2]."\"></td>\n";
  57. echo "\t\t<td width=\"100px\"><input type=\"text\" name=\"product_hint\" class=\"list_cell\" value=\"".$list[$i][5]."\"></td>\n";
  58. echo "\t\t<td align=\"right\" onclick=\"javascript: window.location.href = 'product_details.php?product_id=".$list[$i][0]."';\">".number_format($list[$i][3] * $list[$i][2], 2)."</td>\n";
  59. echo "\t\t<td width=\"100px\" align=\"center\"><a href=\"javascript: document.forms['edit_product_amount_".$list[$i][0]."'].submit();\">speichern</a></td>\n";
  60. echo "\t\t<td width=\"100px\" align=\"center\"><a href=\"javascript: window.location.href= ' shoppingcart.php?action=remove_product_from_cart&product_id=".$list[$i][0]."';\">entfernen</a></td>\n";
  61. echo "\t</form>\n\t</tr></a>\n";
  62. if ($set_focus_next == true) {
  63. echo "<script type=\"text/javascript\">\n";
  64. echo "document.getElementById('product_amount_".$list[$i][0]."').scrollIntoView(\"true\")\n";
  65. echo "document.getElementById('product_amount_".$list[$i][0]."').focus();\n";
  66. echo "document.getElementById('product_amount_".$list[$i][0]."').select();\n";
  67. echo "</script>\n";
  68. $set_focus_next = false;
  69. }
  70. /* check if the edited product id is the current */
  71. if ($prev_edit_product_id == $list[$i][0]) {
  72. $set_focus_next = true;
  73. }
  74. }
  75. ?>
  76. <tr>
  77. <td colspan="7">&nbsp;</td>
  78. </tr>
  79. <tr>
  80. <td colspan="7"><a href="javascript: document.forms['shoppingcart_load_template'].submit();">Artikel aus dem Standard Warenkorb hinzuf&uuml;gen</a></td>
  81. </tr>
  82. <tr class="table_header">
  83. <td colspan="5">&nbsp;</td>
  84. <td colspan="2" align="center" width="200px"><big><a href="shoppingcart_submit.php">weiter</a></big></td>
  85. </tr>
  86. <tr>
  87. <td colspan="7">&nbsp;</td>
  88. </tr>
  89. <tr>
  90. <td colspan="7" align="right"><a href="javascript: document.forms['shoppingcart_set_template'].submit();">diesen Warenkorb als Standard speichern</a></td>
  91. </tr>
  92. </table>
  93. </div>
  94. <?php
  95. include("footer.php");
  96. ?>