CustomerSync.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. require_once("DataBase_Net/Customer_Net.php");
  3. require_once("DataBase/Customer.php");
  4. // sync Customer database
  5. $customer = new Customer();
  6. $customer_net = new Customer_Net();
  7. $new_customer_count = 0;
  8. $del_customer_count = 0;
  9. // fetch all remote customers
  10. $remote_customers = $customer_net->get('', array('customer_id'));
  11. foreach($remote_customers as $tmp)
  12. {
  13. if($customer->exists($tmp[0]) == false)
  14. {
  15. $customer_net->delete($tmp[0]);
  16. $del_customer_count++;
  17. }
  18. }
  19. $remote_customers = $customer_net->get('', array('customer_id'));
  20. $local_customers = $customer->get('', array('customer_id'));
  21. foreach($local_customers as $tmp)
  22. {
  23. $found = false;
  24. foreach($remote_customers as $remote_tmp)
  25. {
  26. if($remote_tmp[0] == $tmp[0])
  27. {
  28. $found = true;
  29. break;
  30. }
  31. }
  32. $tmp_data = $customer->get($tmp[0], array( "password",
  33. "prename",
  34. "postname",
  35. "street",
  36. "streetnumber",
  37. "plz",
  38. "city",
  39. "telephone",
  40. "telefax",
  41. "email",
  42. "pricelist_id",
  43. "tour_id",
  44. "rabatt",
  45. "details",
  46. "bank_name",
  47. "bank_account",
  48. "blz"));
  49. if(!$found)
  50. {
  51. $customer_net->create($tmp[0], $tmp_data[0]);
  52. $new_customer_count++;
  53. }
  54. else
  55. {
  56. $customer_net->update($tmp[0], $tmp_data[0]);
  57. }
  58. }
  59. $main_box->add(new NTKLabel("", "neue Kunden online: ".$new_customer_count), 200, 0, "background-color: #dfe7f3;");
  60. $main_box->add(new NTKLabel("", "Kunden online gel&ouml;scht: ".$del_customer_count), 200, 0, "background-color: #dfe7f3;");
  61. ?>