From c4e0d8da42696410089d4dca02f611cb60d6ec33 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 4 May 2021 17:28:20 +0200 Subject: [PATCH 1/2] FIX: merge thirparty also work for bank URL entry --- htdocs/compta/bank/class/account.class.php | 22 ++++++++++++++++++++++ htdocs/societe/card.php | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 0002dbcb8ed..c59e768f6dc 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1676,6 +1676,28 @@ class Account extends CommonObject $this->owner_address = 'Owner address'; $this->country_id = 1; } + + /** + * Function used to replace a thirdparty id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool + */ + public static function replaceThirdparty($db, $origin_id, $dest_id) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'bank_url SET url_id = '.$dest_id.' WHERE url_id = '.$origin_id.' AND type=\'company\''; + + if (!$db->query($sql)) + { + //if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B. + //$this->errors = $db->lasterror(); + return false; + } else { + return true; + } + } } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 66b5f68564e..1fbb1ad6082 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -254,7 +254,8 @@ if (empty($reshook)) 'Product' => '/product/class/product.class.php', 'Project' => '/projet/class/project.class.php', 'Ticket' => '/ticket/class/ticket.class.php', - 'User' => '/user/class/user.class.php' + 'User' => '/user/class/user.class.php', + 'Account' => '/compta/bank/class/account.class.php', ); //First, all core objects must update their tables From 7386a223e80572284bf833b170d85974c9592564 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 6 May 2021 16:38:34 +0200 Subject: [PATCH 2/2] Update account.class.php --- htdocs/compta/bank/class/account.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index c59e768f6dc..75738abc3d4 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1687,7 +1687,7 @@ class Account extends CommonObject */ public static function replaceThirdparty($db, $origin_id, $dest_id) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.'bank_url SET url_id = '.$dest_id.' WHERE url_id = '.$origin_id.' AND type=\'company\''; + $sql = "UPDATE ".MAIN_DB_PREFIX."bank_url SET url_id = ".((int) $dest_id)." WHERE url_id = ".((int) $origin_id)." AND type='company'"; if (!$db->query($sql)) {