From f757f9c4cc6f34f5ae884100dcbbcf72e140d252 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Wed, 15 Jan 2025 20:01:40 +0100 Subject: [PATCH 01/16] accounting: fix num_rows without call from $db $res->num_rows will not work on PostgreSQL. $db->num_rows() must be used instead to execute the correct procedure depending on the database backend. --- htdocs/core/lib/accounting.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index e3876491055e3..ff23193441e50 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -295,7 +295,7 @@ function getDefaultDatesForTransfer() $sql .= " WHERE date_start < '".$db->idate(dol_now())."' AND date_end > '".$db->idate(dol_now())."'"; $sql .= $db->plimit(1); $res = $db->query($sql); - if ($res->num_rows > 0) { + if ($db->num_rows($res) > 0) { $obj = $db->fetch_object($res); $date_start = $db->jdate($obj->date_start); From d5584f4e3213f2ce5769910d1c82d74bd71daa0a Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Wed, 15 Jan 2025 20:01:40 +0100 Subject: [PATCH 02/16] api_thirdparties: fix num_rows typo $res->num_rows will not work on PostgreSQL. $db->num_rows() must be used instead to execute the correct procedure depending on the database backend. But the call was not written properly and both were mixed up in commit 25741a618ebc162af25ede4936b8087f580e85bf which used $db->num_rows, and then fixed in 72c443868c235c31cb192c1202d277b6df4cd380 which used $db->num_rows($result) where suited, except this location. --- htdocs/societe/class/api_thirdparties.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 4461bb644e3de..9f1049544cfde 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1865,7 +1865,7 @@ public function putSocieteAccount($id, $site, $request_data = null) $result = $this->db->query($sql); // We do not found an existing SocieteAccount entity for this fk_soc and site ; we then create a new one. - if ($result && $this->db->num_rows == 0) { + if ($result && $this->db->num_rows($result) == 0) { if (!isset($request_data['key_account'])) { throw new RestException(422, 'Unprocessable Entity: You must pass the key_account attribute in your request data !'); } From 16b28e4d165ce88e7b910f2b15c40131b50d4fa0 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 15 Jan 2025 21:19:18 +0100 Subject: [PATCH 03/16] Debug v21 --- htdocs/societe/class/societe.class.php | 18 +++++++++++++----- htdocs/societe/list.php | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index fa785fc230c63..a1a3b9306bb11 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2913,7 +2913,7 @@ public function getTooltipContentArray($params) $datas['status'] = ' '.$this->getLibStatut(5); } if (isset($this->client) && isset($this->fournisseur)) { - $datas['type'] = '   ' . $this->getTypeUrl(1); + $datas['type'] = '   ' . $this->getTypeUrl(1, '', 0, 'span'); } $datas['name'] = '
'.$langs->trans('Name').': '.dol_escape_htmltag(dol_string_nohtmltag($this->name)); if (!empty($this->name_alias) && empty($noaliasinname)) { @@ -3075,7 +3075,8 @@ public function getNomUrl($withpicto = 0, $option = '', $maxlen = 0, $notooltip } else { $label = implode($this->getTooltipContentArray($params)); } - + print "\n"; + //var_dump($label);exit; $linkstart = ''; $linkend = ''; @@ -3183,19 +3184,26 @@ public function getTypeUrl($withpicto = 0, $option = '', $notooltip = 0, $tag = $s = ''; if (empty($option) || preg_match('/prospect/', $option)) { if (($this->client == 2 || $this->client == 3) && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')) { - $s .= '<'.$tag.' class="customer-back opacitymedium" title="'.$langs->trans("Prospect").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Prospect"), 0, 1).''; + $s .= '<'.$tag.' class="customer-back opacitymedium" title="'.dolPrintHTMLForAttribute($langs->trans("Prospect")).'"'; + $s .= $tag == 'a' ? ' href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id.'"' : ''; + $s .= '>'.dol_substr($langs->trans("Prospect"), 0, 1).''; } } if (empty($option) || preg_match('/customer/', $option)) { if (($this->client == 1 || $this->client == 3) && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) { - $s .= '<'.$tag.' class="customer-back" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Customer"), 0, 1).''; + $s .= '<'.$tag.' class="customer-back" title="'.dolPrintHTMLForAttribute($langs->trans("Customer")).'"'; + $s.= $tag == 'a' ? ' href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id.'"' : ''; + $s .= '>'.dol_substr($langs->trans("Customer"), 0, 1).''; } } if (empty($option) || preg_match('/supplier/', $option)) { if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $this->fournisseur) { - $s .= '<'.$tag.' class="vendor-back" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Supplier"), 0, 1).''; + $s .= '<'.$tag.' class="vendor-back" title="'.dolPrintHTMLForAttribute($langs->trans("Supplier")).'"'; + $s .= $tag == 'a' ? ' href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$this->id.'"' : ''; + $s .= '>'.dol_substr($langs->trans("Supplier"), 0, 1).''; } } + return $s; } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index ec7e8ba23a529..cce3e430b6c64 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -2009,6 +2009,7 @@ $userstatic->job = $val['job']; $userstatic->gender = $val['gender']; $userstatic->statut = $val['statut']; + $userstatic->status = $val['statut']; print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); $j++; if ($j < $nbofsalesrepresentative) { From a41fe4637dd9c108f8a4c5db384b6f90cb693a8a Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 16 Jan 2025 01:58:13 +0100 Subject: [PATCH 04/16] Debug v21 --- htdocs/website/index.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index b69a1697d3f6b..7a8acf4e21bbd 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2905,7 +2905,7 @@ print "\n"; print ''."\n"; -print '
'; +print ''."\n"; print ''; print ''; print ''; @@ -2947,7 +2947,7 @@ print ''; } -print '
'; +print '
'."\n"; // Add a margin under toolbar ? $style = ''; @@ -2991,7 +2991,7 @@ //var_dump($objectpage);exit; - print '
'; + print '
'."\n"; // // Toolbar for websites @@ -3291,10 +3291,10 @@ // if ($websitekey && $websitekey != '-1' && (!in_array($action, array('editcss', 'editmenu', 'importsite', 'file_manager', 'replacesite', 'replacesiteconfirm'))) && (!in_array($mode, array('replacesite'))) && !$file_manager) { - print '
'; // Close current websitebar to open a new one + print '
'."\n"; // Close current websitebar to open a new one print ''; - print '
'; + print '
'."\n"; print '
'; print $langs->trans("PageContainer").': '; @@ -3854,7 +3854,7 @@ function switchEditorOnline(forceenable) } } - print '
'; // end current websitebar + print '
'."\n"; // end current websitebar } @@ -5537,7 +5537,8 @@ function switchEditorOnline(forceenable) */ $out .= "\n"; - $out .= "\n"; + $out .= "\n"; + $out .= "\n"; $out .= '
'."\n"; @@ -5618,9 +5619,9 @@ function switchEditorOnline(forceenable) $out .= dolWebsiteReplacementOfLinks($object, $newcontent, 0, 'html', $objectpage->id)."\n"; //$out.=$newcontent; - $out .= '
'; + $out .= '
'."\n"; - $out .= '
'; + $out .= '
'."\n"; /*if ($includepageintoaframeoradiv == 'iframe') { From 0f0617f8f8e23b88dc7b8fe2c8181fe8cd2d343d Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 16 Jan 2025 02:09:34 +0100 Subject: [PATCH 05/16] Debug v21 --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 4f25f02093c10..08dd5e94151c3 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -3873,7 +3873,7 @@ function archiveOrBackupFile($srcfile, $max_versions = 5, $archivedir = '', $suf if (count($sorted_files) >= $max_versions) { $oldest_files = array_slice($sorted_files, $max_versions - 1); foreach ($oldest_files as $oldest_file) { - dol_delete_file($oldest_file); + dol_delete_file($oldest_file, 0, 0, 0, null, false, 0); } } From f88cfae08fa79f28a99f4d7c419145569183756d Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 16 Jan 2025 02:50:23 +0100 Subject: [PATCH 06/16] Debug v21 --- htdocs/categories/class/categorie.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index f8c77afa6c0b3..d8df3b686555b 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1228,7 +1228,7 @@ public function get_full_arbo($type, $fromid = 0, $include = 0) } $sql .= " FROM ".MAIN_DB_PREFIX."categorie as c"; if (getDolGlobalInt('MAIN_MULTILANGS')) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$this->db->escape($current_lang)."'"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang = '".$this->db->escape($current_lang)."'"; } $sql .= " WHERE c.entity IN (".getEntity('category').")"; $sql .= " AND c.type = ".(int) $type; From a82da1cc6cb031c89be880e0937f7ee72954e9bc Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 16 Jan 2025 02:55:00 +0100 Subject: [PATCH 07/16] Must be able to force lang --- htdocs/categories/class/categorie.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index d8df3b686555b..6e1b908321033 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1187,9 +1187,10 @@ protected function load_motherof() * - string (categories ids separated by comma) * - array (list of categories ids) * @param int<0,1> $include [=0] Removed or 1=Keep only + * @param string $forcelangcode Lang code to force ('fr_FR', 'en_US', ...) * @return int<-1,-1>|array Array of categories. this->cats and this->motherof are set, -1 on error */ - public function get_full_arbo($type, $fromid = 0, $include = 0) + public function get_full_arbo($type, $fromid = 0, $include = 0, $forcelangcode = '') { // phpcs:enable global $langs; @@ -1219,7 +1220,12 @@ public function get_full_arbo($type, $fromid = 0, $include = 0) // Init this->motherof that is array(id_son=>id_parent, ...) $this->load_motherof(); - $current_lang = $langs->getDefaultLang(); + + if ($forcelangcode) { + $current_lang = $forcelangcode; + } else { + $current_lang = $langs->getDefaultLang(); + } // Init $this->cats array $sql = "SELECT DISTINCT c.rowid, c.label, c.ref_ext, c.description, c.color, c.position, c.fk_parent, c.visible"; // Distinct reduce pb with old tables with duplicates From 162b3b1d82e018c6104d2373c2e7c4852e2ce431 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 16 Jan 2025 05:13:34 +0100 Subject: [PATCH 08/16] Debug v21 --- htdocs/public/payment/paymentok.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 3ddf784f0e1cb..cbfaae760799c 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -2140,7 +2140,7 @@ } else { $ext_urlok = DOL_URL_ROOT.'/public/website/index.php?website='.urlencode($ws).'&pageref=paymentok&fulltag='.$FULLTAG; } - print ""; + print ""; } else { // Redirect to an error page // Paymentko page must be created for the specific website @@ -2149,6 +2149,6 @@ } else { $ext_urlko = DOL_URL_ROOT.'/public/website/index.php?website='.urlencode($ws).'&pageref=paymentko&fulltag='.$FULLTAG; } - print ""; + print ""; } } From 540329340912b56763813e22519d977374306be2 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 16 Jan 2025 06:19:22 +0100 Subject: [PATCH 09/16] Remove inappropriate --- htdocs/accountancy/journal/purchasesjournal.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 437b436b73395..afe272ba7d91b 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -3,7 +3,7 @@ * Copyright (C) 2007-2010 Jean Heimburger * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2013-2024 Alexandre Spangaro + * Copyright (C) 2013-2025 Alexandre Spangaro * Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2018-2024 Frédéric France @@ -1276,12 +1276,10 @@ function writebookkeeping() { // Subledger account print ""; print ''; - print ""; $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ? '' : $arrayofvat[$key][$k]) : implode(', ', $def_tva[$key][$k])); $labelvatrate = $langs->trans("Taxes").' '.$tmpvatrate.' %'; $labelvatrate .= ($numtax ? ' - Localtax '.$numtax : ''); print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $labelvatrate) . ""; - print ""; print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; print ""; From c01e3faea4aa0a73497586f1141d918796cbc584 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 16 Jan 2025 12:09:13 +0100 Subject: [PATCH 10/16] Update eclipse rules --- dev/setup/eclipse/PSR-12 [built-in].xml | 455 +++++++++++++----------- 1 file changed, 243 insertions(+), 212 deletions(-) diff --git a/dev/setup/eclipse/PSR-12 [built-in].xml b/dev/setup/eclipse/PSR-12 [built-in].xml index 47925209682ec..b55c081837c22 100644 --- a/dev/setup/eclipse/PSR-12 [built-in].xml +++ b/dev/setup/eclipse/PSR-12 [built-in].xml @@ -1,215 +1,246 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 05a7c16422e15a800dc8e203e966a0ccb60c2968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Fali=C3=A8re?= Date: Thu, 16 Jan 2025 12:09:27 +0100 Subject: [PATCH 11/16] ENH: accessibility on ticket admin page --- htdocs/admin/ticket.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index 1ae98d5a5ec1d..3feb6223eda01 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -1,11 +1,11 @@ - * Copyright (C) 2016 Christophe Battarel - * Copyright (C) 2022-2023 Udo Tamm - * Copyright (C) 2023 Alexandre Spangaro - * Copyright (C) 2024 MDW - * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 Benjamin Falière +/* Copyright (C) 2013-2018 Jean-François FERRY + * Copyright (C) 2016 Christophe Battarel + * Copyright (C) 2022-2023 Udo Tamm + * Copyright (C) 2023 Alexandre Spangaro + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024-2025 Benjamin Falière * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -563,7 +563,7 @@ // Auto assign ticket to user who created it print ''; -print ''.$langs->trans("TicketsAutoAssignTicket").''; +print ''; print ''; print ''; print ''; @@ -598,9 +598,9 @@ print ''; print ''; -print ''.$langs->trans("TicketsDelayBeforeFirstAnswer").""; +print '"; print ' - + '; print ''; print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBeforeFirstAnswerHelp"), 1, 'help'); @@ -608,9 +608,9 @@ print ''; print ''; -print ''.$langs->trans("TicketsDelayBetweenAnswers").""; +print '"; print ' - + '; print ''; print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBetweenAnswersHelp"), 1, 'help'); @@ -655,18 +655,18 @@ // TODO Use module notification instead... // Email to send notifications -print ''.$langs->trans("TicketEmailNotificationFrom").''; +print ''; print ''; -print ''; +print ''; print ''; print $formcategory->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"), 1, 'help'); print ''; print ''; // Email for notification of TICKET_CREATE -print ''.$langs->trans("TicketEmailNotificationTo").''; +print ''; print ''; -print ''; +print ''; print ''; print $formcategory->textwithpicto('', $langs->trans("TicketEmailNotificationToHelp"), 1, 'help'); print ''; From 2ae7549563413cb5146868b95bed84922880328c Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 16 Jan 2025 14:02:08 +0100 Subject: [PATCH 12/16] Debug v21 --- htdocs/install/mysql/migration/20.0.0-21.0.0.sql | 4 ++++ htdocs/install/mysql/tables/llx_societe_account.key.sql | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/20.0.0-21.0.0.sql b/htdocs/install/mysql/migration/20.0.0-21.0.0.sql index 2ea5cf7a51ef8..189922844e21d 100644 --- a/htdocs/install/mysql/migration/20.0.0-21.0.0.sql +++ b/htdocs/install/mysql/migration/20.0.0-21.0.0.sql @@ -403,3 +403,7 @@ ALTER TABLE llx_societe_rib DROP INDEX uk_societe_rib; ALTER TABLE llx_societe_rib ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid; -- select entity, label, fk_soc, default_rib, MIN(iban_prefix), MAX(iban_prefix), MIN(rowid), MAX(rowid), COUNT(rowid) from llx_societe_rib GROUP BY entity, label, fk_soc, default_rib HAVING COUNT(rowid) > 1; ALTER TABLE llx_societe_rib ADD UNIQUE INDEX uk_societe_rib(entity, label, fk_soc); + + +ALTER TABLE llx_societe_account DROP INDEX uk_societe_account_login_website_soc; +ALTER TABLE llx_societe_account ADD UNIQUE INDEX uk_societe_account_login_website(entity, login, site, fk_website); diff --git a/htdocs/install/mysql/tables/llx_societe_account.key.sql b/htdocs/install/mysql/tables/llx_societe_account.key.sql index e889a38d5277d..a98272dbce761 100644 --- a/htdocs/install/mysql/tables/llx_societe_account.key.sql +++ b/htdocs/install/mysql/tables/llx_societe_account.key.sql @@ -22,11 +22,13 @@ ALTER TABLE llx_societe_account ADD INDEX idx_societe_account_fk_website (fk_web ALTER TABLE llx_societe_account ADD INDEX idx_societe_account_fk_soc (fk_soc); -- END MODULEBUILDER INDEXES -ALTER TABLE llx_societe_account ADD UNIQUE INDEX uk_societe_account_login_website_soc(entity, fk_soc, login, site, fk_website); +-- Only one unique login in the same website (note: we can still have the same login in database for 2 different companies if fk_website is null) +ALTER TABLE llx_societe_account ADD UNIQUE INDEX uk_societe_account_login_website(entity, login, site, fk_website); +-- Only one unique login in the same external account in the same company ALTER TABLE llx_societe_account ADD UNIQUE INDEX uk_societe_account_key_account_soc(entity, fk_soc, key_account, site, fk_website); + -- Table website does not always exists --ALTER TABLE llx_societe_account ADD CONSTRAINT llx_societe_account_fk_website FOREIGN KEY (fk_website) REFERENCES llx_website(rowid); ALTER TABLE llx_societe_account ADD CONSTRAINT llx_societe_account_fk_societe FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid); - From 6f26816185a62f02bfac07770dfcd46779d44d6c Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 16 Jan 2025 14:02:43 +0100 Subject: [PATCH 13/16] Migration --- htdocs/install/mysql/migration/21.0.0-22.0.0.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql index 5af4f5bd7a928..a629c3c313e89 100644 --- a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql +++ b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql @@ -37,6 +37,9 @@ ALTER TABLE llx_societe_rib MODIFY COLUMN label varchar(180); ALTER TABLE llx_societe_rib MODIFY COLUMN iban_prefix varchar(100); +ALTER TABLE llx_societe_account DROP INDEX uk_societe_account_login_website_soc; +ALTER TABLE llx_societe_account ADD UNIQUE INDEX uk_societe_account_login_website(entity, login, site, fk_website); + -- V22 migration From d85c39e77ba9f4852f134ed23e52e3837540a59e Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 16 Jan 2025 14:47:03 +0100 Subject: [PATCH 14/16] Fix CI --- htdocs/core/lib/functions.lib.php | 2 +- .../interface_50_modNotification_Notification.class.php | 3 --- htdocs/loan/card.php | 2 +- htdocs/user/bank.php | 4 ++-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bffc520abb0df..4c9a5d4cedd0b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9185,7 +9185,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, } elseif (property_exists($object, 'delivery_date')) { $date_delivery = $object->delivery_date; } - $substitutionarray['__DATE_DELIVERY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, 'day', 0, $outputlangs) : ''); + $substitutionarray['__DATE_DELIVERY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, 'day', false, $outputlangs) : ''); $substitutionarray['__DATE_DELIVERY_DAY__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%d") : ''); $substitutionarray['__DATE_DELIVERY_DAY_TEXT__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%A") : ''); $substitutionarray['__DATE_DELIVERY_MON__'] = (isset($date_delivery) ? dol_print_date($date_delivery, "%m") : ''); diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index c3bdc97132888..86bf821cd365a 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -99,9 +99,6 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf $notify = new Notify($this->db); $resultSend = $notify->send($action, $object); if ($resultSend < 0) { - if (!isset($this->errors)) { - $this->errors = []; - } $this->errors = array_merge($this->errors, $notify->errors); return $resultSend; } diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index f0025e642a65e..aefbc83ca9225 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -205,7 +205,7 @@ $object->capital = $capital; $object->nbterm = GETPOSTINT("nbterm"); - $object->rate = price2num(GETPOST("rate", 'alpha')); + $object->rate = GETPOSTFLOAT("rate"); $object->insurance_amount = GETPOSTFLOAT('insurance_amount'); $accountancy_account_capital = GETPOST('accountancy_account_capital'); diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 0a9a378fb35bf..edd8ff48472f5 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -125,7 +125,7 @@ if ($user->hasRight('hrm', 'read')) { $ok = true; } -if ($user->hasRight('expensereport', 'readall') || ($user->hasRight('expensereport', 'readall') && in_array($object->id, $childids))) { +if ($user->hasRight('expensereport', 'readall') || ($user->hasRight('expensereport', 'read') && in_array($object->id, $childids))) { $ok = true; } if ($user->hasRight('holiday', 'readall') || ($user->hasRight('holiday', 'read') && in_array($object->id, $childids))) { @@ -778,7 +778,7 @@ // Latest expense report if (isModEnabled('expensereport') && - ($user->hasRight('expensereport', 'readall') || ($user->hasRight('expensereport', 'lire') && $object->id == $user->id)) + ($user->hasRight('expensereport', 'readall') || ($user->hasRight('expensereport', 'read') && $object->id == $user->id)) ) { $exp = new ExpenseReport($db); From eaa51fed7b4e18d494d47fd9db8061aa5c95518b Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Wed, 15 Jan 2025 20:01:40 +0100 Subject: [PATCH 15/16] accounting: fix num_rows without call from $db $res->num_rows will not work on PostgreSQL. $db->num_rows() must be used instead to execute the correct procedure depending on the database backend. --- htdocs/core/lib/accounting.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index e3876491055e3..ff23193441e50 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -295,7 +295,7 @@ function getDefaultDatesForTransfer() $sql .= " WHERE date_start < '".$db->idate(dol_now())."' AND date_end > '".$db->idate(dol_now())."'"; $sql .= $db->plimit(1); $res = $db->query($sql); - if ($res->num_rows > 0) { + if ($db->num_rows($res) > 0) { $obj = $db->fetch_object($res); $date_start = $db->jdate($obj->date_start); From 63c991413ee7db10a44ff7458a13b58f0881b662 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Wed, 15 Jan 2025 20:01:40 +0100 Subject: [PATCH 16/16] api_thirdparties: fix num_rows typo $res->num_rows will not work on PostgreSQL. $db->num_rows() must be used instead to execute the correct procedure depending on the database backend. But the call was not written properly and both were mixed up in commit 25741a618ebc162af25ede4936b8087f580e85bf which used $db->num_rows, and then fixed in 72c443868c235c31cb192c1202d277b6df4cd380 which used $db->num_rows($result) where suited, except this location. --- htdocs/societe/class/api_thirdparties.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 4461bb644e3de..9f1049544cfde 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1865,7 +1865,7 @@ public function putSocieteAccount($id, $site, $request_data = null) $result = $this->db->query($sql); // We do not found an existing SocieteAccount entity for this fk_soc and site ; we then create a new one. - if ($result && $this->db->num_rows == 0) { + if ($result && $this->db->num_rows($result) == 0) { if (!isset($request_data['key_account'])) { throw new RestException(422, 'Unprocessable Entity: You must pass the key_account attribute in your request data !'); }