From b8455430af0ea2f137db3dd758dc9f09a40cf9ff Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 7 Sep 2023 16:47:57 +0200 Subject: [PATCH 1/8] fix sql query for external users --- htdocs/commande/class/commandestats.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index ca20b879e65..4a82edfd0c6 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -245,13 +245,14 @@ class CommandeStats extends Stats global $user; $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; - $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; + $sql .= " FROM ".$this->from; + $sql .= " LEFT JOIN ".$this->from_line." ON c.rowid = tl.fk_commande "; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as product ON tl.fk_product = product.rowid"; if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; $sql .= " WHERE ".$this->where; - $sql .= " AND c.rowid = tl.fk_commande AND tl.fk_product = product.rowid"; $sql .= " AND c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; $sql .= " GROUP BY product.ref"; $sql .= $this->db->order('nb', 'DESC'); From aa34f800c20ab639ba10dd845334d2f6f45d79e8 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Fri, 8 Sep 2023 11:18:59 +0200 Subject: [PATCH 2/8] user inner join --- htdocs/commande/class/commandestats.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index 4a82edfd0c6..a339c87f569 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -246,8 +246,8 @@ class CommandeStats extends Stats $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; $sql .= " FROM ".$this->from; - $sql .= " LEFT JOIN ".$this->from_line." ON c.rowid = tl.fk_commande "; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as product ON tl.fk_product = product.rowid"; + $sql .= " INNER JOIN ".$this->from_line." ON c.rowid = tl.fk_commande "; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."product as product ON tl.fk_product = product.rowid"; if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } From b543454855fa4b6248e6c192c96330f0bfcd8877 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2023 14:14:59 +0200 Subject: [PATCH 3/8] Fix warning --- htdocs/main.inc.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index b97312859b9..d541f3abce5 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -754,6 +754,8 @@ if (!defined('NOLOGIN')) { $login = ''; } + $dol_authmode = ''; + if ($login) { $dol_authmode = $conf->authmode; // This properties is defined only when logged, to say what mode was successfully used $dol_tz = $_POST["tz"]; From 9923331ac146ada07487c9b1f43380916db22297 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2023 14:16:31 +0200 Subject: [PATCH 4/8] Better backward compatibility of modules --- htdocs/core/lib/functions.lib.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3f25d9cdfd0..0514624fb6b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -68,6 +68,17 @@ function getDolGlobalInt($key, $default = 0) return (int) (empty($conf->global->$key) ? $default : $conf->global->$key); } +/** + * Is Dolibarr module enabled + * @param string $module module name to check + * @return int + */ +function isModEnabled($module) +{ + global $conf; + return !empty($conf->$module->enabled); +} + /** * Return a DoliDB instance (database handler). * From 4fabc22624752ddb56d8c04ab29fc8bfd9ecfb02 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 17 Sep 2023 07:38:03 +0200 Subject: [PATCH 5/8] FIX Accountancy - Update Quadra export format --- .../accountancy/class/accountancyexport.class.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 4ba8a076540..4816d06b95f 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -518,7 +518,7 @@ class AccountancyExport /** * Export format : Quadratus (Format ASCII) * Format since 2015 compatible QuadraCOMPTA - * Last review for this format : 2023/01/28 Alexandre Spangaro (aspangaro@open-dsi.fr) + * Last review for this format : 2023/09/16 Alexandre Spangaro (aspangaro@open-dsi.fr) * * Help : https://docplayer.fr/20769649-Fichier-d-entree-ascii-dans-quadracompta.html * In QuadraCompta | Use menu : "Outils" > "Suivi des dossiers" > "Import ASCII(Compta)" @@ -538,10 +538,17 @@ class AccountancyExport foreach ($TData as $data) { // Clean some data $data->doc_ref = dol_string_unaccent($data->doc_ref); + + $data->label_operation = str_replace(array("\t", "\n", "\r"), " ", $data->label_operation); + $data->label_operation = str_replace(array("- ", "…", "..."), "", $data->label_operation); $data->label_operation = dol_string_unaccent($data->label_operation); + $data->numero_compte = dol_string_unaccent($data->numero_compte); $data->label_compte = dol_string_unaccent($data->label_compte); $data->subledger_account = dol_string_unaccent($data->subledger_account); + + $data->subledger_label = dol_string_unaccent($data->subledger_label); + $data->subledger_label = str_replace(array("- ", "…", "..."), "", $data->subledger_label); $data->subledger_label = dol_string_unaccent($data->subledger_label); $code_compta = $data->numero_compte; @@ -557,11 +564,11 @@ class AccountancyExport $Tab['lib_compte'] = str_pad(self::trunc($data->subledger_label, 30), 30); if ($data->doc_type == 'customer_invoice') { - $Tab['lib_alpha'] = strtoupper(str_pad('C'.self::trunc($data->subledger_label, 6), 6)); + $Tab['lib_alpha'] = strtoupper(str_pad('C'.self::trunc($data->subledger_label, 6), 7)); $Tab['filler'] = str_repeat(' ', 52); $Tab['coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, 8), 8); } elseif ($data->doc_type == 'supplier_invoice') { - $Tab['lib_alpha'] = strtoupper(str_pad('F'.self::trunc($data->subledger_label, 6), 6)); + $Tab['lib_alpha'] = strtoupper(str_pad('F'.self::trunc($data->subledger_label, 6), 7)); $Tab['filler'] = str_repeat(' ', 52); $Tab['coll_compte'] = str_pad(self::trunc($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, 8), 8); } else { From 7b76188816f2cc3af803ff26d55afbea87f0c073 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 19 Sep 2023 11:32:48 +0200 Subject: [PATCH 6/8] fix: contact export s.client and s.fournisseur must be numric as in thirdparty export (filter >0) --- htdocs/core/modules/modSociete.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 03ca9aa8502..f96f9a0ea79 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -385,7 +385,7 @@ class modSociete extends DolibarrModules 'c.statut'=>"Status", 's.rowid'=>"List:societe:nom::thirdparty", 's.nom'=>"Text", 's.status'=>"Status", 's.code_client'=>"Text", 's.code_fournisseur'=>"Text", 's.code_compta'=>"Text", 's.code_compta_fournisseur'=>"Text", - 's.client'=>"Text", 's.fournisseur'=>"Text", + 's.client'=>"Numeric", 's.fournisseur'=>"Numeric", 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 's.phone'=>"Text", 's.email'=>"Text", 't.libelle'=>"Text" ); From a3dd68dab4475e085656dc7b99e5f962bb4b21dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Tue, 19 Sep 2023 16:01:12 +0200 Subject: [PATCH 7/8] FIX: Save user modif id when changing a contact status --- htdocs/contact/class/contact.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 97c6075e6bf..28d907c303e 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1658,6 +1658,7 @@ class Contact extends CommonObject // Desactive utilisateur $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople"; $sql .= " SET statut = ".((int) $this->statut); + $sql .= ", fk_user_modif = ".((int) $user->id); $sql .= " WHERE rowid = ".((int) $this->id); $result = $this->db->query($sql); From 08bb3c1a842f3af34ad6020b45a6836ad7b333df Mon Sep 17 00:00:00 2001 From: tnegre Date: Thu, 21 Sep 2023 14:16:00 +0200 Subject: [PATCH 8/8] FIX : could not delete a fourn commande row if a commande ligne is linked --- htdocs/fourn/class/fournisseur.commande.class.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 112708a92b7..49948ebba06 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3892,10 +3892,17 @@ class CommandeFournisseurLigne extends CommonOrderLine return -1; } - $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande_fournisseurdet WHERE rowid=".((int) $this->id); + $sql1 = 'UPDATE '.MAIN_DB_PREFIX."commandedet SET fk_commandefourndet = NULL WHERE rowid=".((int) $this->id); + $resql = $this->db->query($sql1); + if (!$resql) { + $this->db->rollback(); + return -1; + } + + $sql2 = 'DELETE FROM '.MAIN_DB_PREFIX."commande_fournisseurdet WHERE rowid=".((int) $this->id); dol_syslog(__METHOD__, LOG_DEBUG); - $resql = $this->db->query($sql); + $resql = $this->db->query($sql2); if ($resql) { if (!$notrigger) { // Call trigger