db_action.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. require_once("util.php");
  3. require_once("NTK/NTK.php");
  4. require_once("../DataBase/Tour.php");
  5. require_once("../DataBase/Bill.php");
  6. require_once("../DataBase/Assistant.php");
  7. require_once("DataBase/Bill_Product.php");
  8. $db_action = var_get_post("db_action", "");
  9. $tour = new Tour();
  10. $bill = new Bill();
  11. $assistant = new Assistant();
  12. switch($db_action)
  13. {
  14. case "new":
  15. $tour->create(array(var_post("name", ""), var_post("assistant_id", "")));
  16. break;
  17. case "edit":
  18. $tour->update(var_post("tour_id", ""), array(var_post("name", ""), var_post("assistant_id", "")));
  19. break;
  20. case "delete":
  21. $tour->delete(var_get("tour_id", ""));
  22. break;
  23. case "tour_to_bill":
  24. $tour = new Tour();
  25. $tmp = $tour->get(var_get("tour_id", ""));
  26. $tour_data = $tmp[0];
  27. $bill = new Bill();
  28. $new_bill_id = $bill->create('', array(var_post("customer_id", ""), var_post("tour_id", ""), var_post("date", ""), var_post("assistant_id", ""), -1, 0));
  29. $bill_product = new Bill_Product();
  30. $product = new Product();
  31. $product_data = $product->get();
  32. $result = $bill_product->getTourZusammenfassung(var_post("current_tour_id", ""), var_post("date", ""));
  33. for($i = 0; $i < count($result); $i++)
  34. {
  35. $bill_product->create(array($new_bill_id, $result[$i][0], $result[$i][2], '', '', '', ''));
  36. }
  37. break;
  38. }
  39. ?>