1. $id_customer = Tools::getValue('id_customer');
  2. $prefixt = Tools::getValue('prefixt');
  3.  
  4. $tatabase = _DB_NAME_;
  5. $show_tables = "SHOW TABLES FROM ".$tatabase;
  6. $list_tables = Db::getInstance()->ExecuteS($show_tables);
  7.  
  8. foreach ($list_tables as $k => $v)
  9. {
  10. $sql = 'SELECT (COLUMN_NAME) AS "'.$v['Tables_in_'.$tatabase].'"
  11. FROM INFORMATION_SCHEMA.COLUMNS
  12. WHERE table_name = "'.$v['Tables_in_'.$tatabase].'"
  13. AND (`COLUMN_NAME` = "id_customer")
  14. GROUP BY `'.$v['Tables_in_'.$tatabase].'`
  15. ORDER BY `'.$v['Tables_in_'.$tatabase].'`';
  16. $list_column = Db::getInstance()->ExecuteS($sql);
  17.  
  18. foreach ($list_column as $k2 => $v2)
  19. {
  20. if ($v['Tables_in_'.$tatabase] == _DB_PREFIX_.'address')
  21. {
  22. $sql = 'SELECT * FROM '.$v['Tables_in_'.$tatabase].' WHERE id_customer NOT IN (0,1,2)';
  23. $ps = Db::getInstance()->ExecuteS($sql);
  24. $a = $v['Tables_in_'.$tatabase];
  25. $b = _DB_PREFIX_;
  26. $bodytag = str_replace($b, $prefixt, $a);
  27. $liste = 'INSERT IGNORE INTO `'.$bodytag.'` VALUES <br />';
  28. $c = $c1 = $id_customer;
  29. foreach ($ps as $k3 => $v3)
  30. {
  31. $liste .= '(';
  32. foreach ($v3 as $k4 => $v4)
  33. {
  34. if ($k4 == 'id_customer')
  35. {
  36. $c = $c+1;
  37. $v4 = $c ;
  38. }
  39. if ($k4 == 'id_address')
  40. {
  41. $c1 = $c1+1;
  42. $v4 = $c1 ;
  43. }
  44. $liste .= '"'.$v4.'",';
  45. }
  46. $liste = substr($liste, 0, -1);
  47. $liste .= '),<br />';
  48. }
  49. $liste = substr($liste, 0, -7);
  50. $liste .= ';';
  51. echo $liste.'<br /><br />';
  52. }
  53.  
  54. if ($v['Tables_in_'.$tatabase] == _DB_PREFIX_.'customer')
  55. {
  56. $sql = 'SELECT * FROM '.$v['Tables_in_'.$tatabase].' WHERE id_customer NOT IN (0,1,2)';
  57. $ps = Db::getInstance()->ExecuteS($sql);
  58. $a = $v['Tables_in_'.$tatabase];
  59. $b = _DB_PREFIX_;
  60. $bodytag = str_replace($b, $prefixt, $a);
  61. $liste = 'INSERT IGNORE INTO `'.$bodytag.'` VALUES <br />';
  62. $c = $c1 = $id_customer;
  63. foreach ($ps as $k3 => $v3)
  64. {
  65. $liste .= '(';
  66. foreach ($v3 as $k4 => $v4)
  67. {
  68. if ($k4 == 'id_customer')
  69. {
  70. $c = $c+1;
  71. $v4 = $c ;
  72. }
  73.  
  74. $liste .= '"'.$v4.'",';
  75. }
  76. $liste = substr($liste, 0, -1);
  77. $liste .= '),<br />';
  78. }
  79. $liste = substr($liste, 0, -7);
  80. $liste .= ';';
  81. echo $liste.'<br /><br />';
  82. }
  83.  
  84. if ($v['Tables_in_'.$tatabase] == _DB_PREFIX_.'customer_group')
  85. {
  86. $sql = 'SELECT * FROM '.$v['Tables_in_'.$tatabase].' WHERE id_customer NOT IN (0,1,2) AND id_group = 1';
  87. $ps = Db::getInstance()->ExecuteS($sql);
  88. $a = $v['Tables_in_'.$tatabase];
  89. $b = _DB_PREFIX_;
  90. $bodytag = str_replace($b, $prefixt, $a);
  91. $liste = 'INSERT IGNORE INTO `'.$bodytag.'` VALUES <br />';
  92. $c = $c1 = $id_customer;
  93. foreach ($ps as $k3 => $v3)
  94. {
  95. $liste .= '(';
  96. foreach ($v3 as $k4 => $v4)
  97. {
  98. if ($k4 == 'id_customer')
  99. {
  100. $c = $c+1;
  101. $v4 = $c ;
  102. }
  103.  
  104. $liste .= '"'.$v4.'",';
  105. }
  106. $liste = substr($liste, 0, -1);
  107. $liste .= '),<br />';
  108. }
  109. $liste = substr($liste, 0, -7);
  110. $liste .= ';';
  111. echo $liste.'<br /><br />';
  112. }
  113. }
  114. }