db_action.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. require_once("DataBase/Bill.php");
  3. require_once("DataBase/Bill_Product.php");
  4. require_once("DataBase/Tour.php");
  5. require_once("DataBase/Assistant.php");
  6. require_once("DataBase/Product.php");
  7. require_once("DataBase/Customer.php");
  8. require_once("DataBase/Price.php");
  9. require_once("DataBase/Tax.php");
  10. $db_action = var_get_post("db_action", "");
  11. $bill = new Bill();
  12. $tour = new Tour();
  13. $assistant = new Assistant();
  14. $bill_product = new Bill_Product();
  15. $product = new Product();
  16. $customer = new Customer();
  17. $price = new Price();
  18. $tax = new Tax();
  19. switch($db_action)
  20. {
  21. case "new":
  22. $customer_data = $customer->get(var_post("customer_id", ""));
  23. if(count($customer_data) > 0)
  24. {
  25. $tour_data = $tour->getByAssistant($customer_data[0][12]);
  26. if(count($tour_data) > 0)
  27. {
  28. $bill_id = $bill->create(var_post("bill_id", ""), array(var_post("customer_id", ""), $customer_data[0][12], var_post("date", ""), $tour_data[0][2], -1, 0));
  29. }
  30. else
  31. {
  32. $bill_id = $bill->create(var_post("bill_id", ""), array(var_post("customer_id", ""), $customer_data[0][12], var_post("date", ""), 1, -1, 0));
  33. }
  34. }
  35. else
  36. $bill_id = $bill->create(var_post("bill_id", ""), array(var_post("customer_id", ""), '', var_post("date", ""), var_post("assistant_id", "1"), -1, 0));
  37. $action = "edit";
  38. break;
  39. case "edit":
  40. $bill->update(var_post("bill_id", ""), array(var_post("customer_id", ""), var_post("tour_id", ""), var_post("date", ""), var_post("assistant_id", ""), var_post("bill_number", "")));
  41. if($fp_tour_id != "")
  42. $onload .= "location.href = 'tour.php?action=list_tour&tour_id=".$fp_tour_id."&date=".$fp_date."';";
  43. break;
  44. case "set_number":
  45. $bill->setNumber(var_get("bill_id", ""));
  46. $bill_product->fix(var_get("bill_id", ""));
  47. global $onload;
  48. $onload .= "window.open('print_bill.php?bill_id=".var_get("bill_id", "")."', '', '');";
  49. break;
  50. case "delete":
  51. $bill->delete(var_get("bill_id", ""));
  52. if($fp_tour_id != "")
  53. $onload .= "location.href = 'tour.php?action=list_tour&tour_id=".$fp_tour_id."&date=".$fp_date."';";
  54. break;
  55. case "position_add":
  56. $bill_data = $bill->get(var_post("bill_id", ""));
  57. /* autoset anmerkung vom produkt, wenn nichts als anmerkung gegeben */
  58. $details = var_post("details", "");
  59. if($details == "")
  60. {
  61. $product_data = $product->get(var_post("product_id", ""));
  62. $details = $product_data[0][8];
  63. }
  64. if($bill_data[0][5] == -1)
  65. $bill_product->create(array(var_post("bill_id", ""), var_post("product_id", ""), var_post("amount", ""), $details, var_post("rabatt", ""), 0, 0));
  66. else
  67. {
  68. $customer_data = $customer->get($bill_data[0][1]);
  69. $price_data = $price->getPrice($customer_data[0][11], var_post("product_id", ""));
  70. $product_data = $product->get(var_post("product_id", ""));
  71. $tax_data = $tax->get($product_data[0][4]);
  72. $bill_product->create(array(var_post("bill_id", ""), var_post("product_id", ""), var_post("amount", ""), $details, var_post("rabatt", ""), $price_data[0][3], $tax_data[0][2]));
  73. }
  74. break;
  75. case "position_delete":
  76. $bill_product->delete(var_get("bill_product_id", ""));
  77. break;
  78. case "position_edit":
  79. $bill_product->update(var_post("bill_product_id", ""), array(var_post("bill_id", ""), var_post("product_id", ""), var_post("amount", ""), var_post("details", ""), var_post("rabatt", ""), var_post("price", ""), var_post("tax", "")));
  80. break;
  81. }
  82. ?>