db_action.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. require_once("util.php");
  3. require_once("../DataBase/Product.php");
  4. require_once("../DataBase/Tax.php");
  5. require_once("../DataBase/Category.php");
  6. require_once("../DataBase/Priceset.php");
  7. require_once("../DataBase/Group.php");
  8. require_once("../DataBase/Price.php");
  9. $db_action = var_get_post("db_action", "");
  10. $product = new Product();
  11. $tax = new Tax();
  12. $category = new Category();
  13. $priceset = new Priceset();
  14. $price = new Price();
  15. $group = new Group();
  16. switch($db_action)
  17. {
  18. case "new":
  19. $product->create(var_post("product_id", ""), array( var_post("name", ""),
  20. var_post("details", ""),
  21. var_post("category_id", ""),
  22. var_post("tax_id", ""),
  23. var_post("available", ""),
  24. var_post("group_id", ""),
  25. var_post("order_number", ""),
  26. var_post("anmerkung", "")));
  27. $priceset_list = $priceset->get();
  28. for($i = 0; $i < count($priceset_list); $i++)
  29. $price->create(var_post("priceset_id_".$i, ""), var_post("product_id", ""), var_post("priceset_price_".$i, ""));
  30. break;
  31. case "edit":
  32. $product->update(var_post("product_id", ""), array( var_post("name", ""),
  33. var_post("details", ""),
  34. var_post("category_id", ""),
  35. var_post("tax_id", ""),
  36. var_post("available", ""),
  37. var_post("group_id", ""),
  38. var_post("order_number", ""),
  39. var_post("anmerkung", "")));
  40. $priceset_list = $priceset->get();
  41. for($i = 0; $i < count($priceset_list); $i++)
  42. {
  43. if($price->exists(var_post("priceset_id_".$i, ""), var_post("product_id", "")))
  44. $price->update(var_post("priceset_id_".$i, ""), var_post("product_id", ""), array(var_post("priceset_price_".$i, "")));
  45. else
  46. $price->create(var_post("priceset_id_".$i, ""), var_post("product_id", ""), var_post("priceset_price_".$i, ""));
  47. }
  48. break;
  49. case "delete":
  50. $product->delete(var_get("product_id", ""));
  51. break;
  52. }
  53. ?>