$id_customer = Tools::getValue('id_customer');
$prefixt = Tools::getValue('prefixt');
$tatabase = _DB_NAME_;
$show_tables = "SHOW TABLES FROM ".$tatabase;
$list_tables = Db::getInstance()->ExecuteS($show_tables);
foreach ($list_tables as $k => $v)
{
$sql = 'SELECT (COLUMN_NAME) AS "'.$v['Tables_in_'.$tatabase].'"
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = "'.$v['Tables_in_'.$tatabase].'"
AND (`COLUMN_NAME` = "id_customer")
GROUP BY `'.$v['Tables_in_'.$tatabase].'`
ORDER BY `'.$v['Tables_in_'.$tatabase].'`';
$list_column = Db::getInstance()->ExecuteS($sql);
foreach ($list_column as $k2 => $v2)
{
if ($v['Tables_in_'.$tatabase] == _DB_PREFIX_.'address')
{
$sql = 'SELECT * FROM '.$v['Tables_in_'.$tatabase].' WHERE id_customer NOT IN (0,1,2)';
$ps = Db::getInstance()->ExecuteS($sql);
$a = $v['Tables_in_'.$tatabase];
$b = _DB_PREFIX_;
$liste = 'INSERT IGNORE INTO `'.$bodytag.'` VALUES <br />';
$c = $c1 = $id_customer;
foreach ($ps as $k3 => $v3)
{
$liste .= '(';
foreach ($v3 as $k4 => $v4)
{
if ($k4 == 'id_customer')
{
$c = $c+1;
$v4 = $c ;
}
if ($k4 == 'id_address')
{
$c1 = $c1+1;
$v4 = $c1 ;
}
$liste .= '"'.$v4.'",';
}
$liste =
substr($liste,
0,
-1);
$liste .= '),<br />';
}
$liste =
substr($liste,
0,
-7);
$liste .= ';';
echo $liste.
'<br /><br />';
}
if ($v['Tables_in_'.$tatabase] == _DB_PREFIX_.'customer')
{
$sql = 'SELECT * FROM '.$v['Tables_in_'.$tatabase].' WHERE id_customer NOT IN (0,1,2)';
$ps = Db::getInstance()->ExecuteS($sql);
$a = $v['Tables_in_'.$tatabase];
$b = _DB_PREFIX_;
$liste = 'INSERT IGNORE INTO `'.$bodytag.'` VALUES <br />';
$c = $c1 = $id_customer;
foreach ($ps as $k3 => $v3)
{
$liste .= '(';
foreach ($v3 as $k4 => $v4)
{
if ($k4 == 'id_customer')
{
$c = $c+1;
$v4 = $c ;
}
$liste .= '"'.$v4.'",';
}
$liste =
substr($liste,
0,
-1);
$liste .= '),<br />';
}
$liste =
substr($liste,
0,
-7);
$liste .= ';';
echo $liste.
'<br /><br />';
}
if ($v['Tables_in_'.$tatabase] == _DB_PREFIX_.'customer_group')
{
$sql = 'SELECT * FROM '.$v['Tables_in_'.$tatabase].' WHERE id_customer NOT IN (0,1,2) AND id_group = 1';
$ps = Db::getInstance()->ExecuteS($sql);
$a = $v['Tables_in_'.$tatabase];
$b = _DB_PREFIX_;
$liste = 'INSERT IGNORE INTO `'.$bodytag.'` VALUES <br />';
$c = $c1 = $id_customer;
foreach ($ps as $k3 => $v3)
{
$liste .= '(';
foreach ($v3 as $k4 => $v4)
{
if ($k4 == 'id_customer')
{
$c = $c+1;
$v4 = $c ;
}
$liste .= '"'.$v4.'",';
}
$liste =
substr($liste,
0,
-1);
$liste .= '),<br />';
}
$liste =
substr($liste,
0,
-7);
$liste .= ';';
echo $liste.
'<br /><br />';
}
}
}