PricesetSync.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. require_once("DataBase_Net/Priceset_Net.php");
  3. require_once("DataBase/Priceset.php");
  4. // sync Priceset database
  5. $priceset = new Priceset();
  6. $priceset_net = new Priceset_Net();
  7. $new_priceset_count = 0;
  8. $del_priceset_count = 0;
  9. $remote_pricesets = $priceset_net->get('', array('priceset_id'));
  10. foreach($remote_pricesets as $tmp)
  11. {
  12. if($priceset->exists($tmp[0]) == false)
  13. {
  14. $priceset_net->delete($tmp[0]);
  15. $del_priceset_count++;
  16. }
  17. }
  18. $remote_pricesets = $priceset_net->get('', array('priceset_id'));
  19. $local_pricesets = $priceset->get('', array('priceset_id'));
  20. foreach($local_pricesets as $tmp)
  21. {
  22. $found = false;
  23. foreach($remote_pricesets as $remote_tmp)
  24. {
  25. if($remote_tmp[0] == $tmp[0])
  26. {
  27. $found = true;
  28. break;
  29. }
  30. }
  31. $tmp_data = $priceset->get($tmp[0], array( "name",
  32. "netto"));
  33. if(!$found)
  34. {
  35. $priceset_net->create($tmp[0], $tmp_data[0]);
  36. $new_priceset_count++;
  37. }
  38. else
  39. {
  40. $priceset_net->update($tmp[0], $tmp_data[0]);
  41. }
  42. }
  43. $main_box->add(new NTKLabel("", "neue Pricesets online: ".$new_priceset_count), 200, 0, "background-color: #dfe7f3;");
  44. $main_box->add(new NTKLabel("", "online Pricesets gel&ouml;scht: ".$del_priceset_count), 200, 0, "background-color: #dfe7f3;");
  45. ?>