From b8455430af0ea2f137db3dd758dc9f09a40cf9ff Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 7 Sep 2023 16:47:57 +0200 Subject: [PATCH 01/10] 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 02/10] 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 03/10] 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 04/10] 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 05/10] 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 f1ab8a1268100f3ebe244b5af5124e7f727997b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 18 Sep 2023 10:14:09 +0200 Subject: [PATCH 06/10] fix origin id of order_supplier when creating one invoice_supplier for many --- htdocs/fourn/commande/list.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 3080a184abb..5560f251e6f 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -362,6 +362,7 @@ if (empty($reshook)) { $validate_invoices = GETPOST('validate_invoices', 'int'); $TFact = array(); + /** @var FactureFournisseur[] $TFactThird */ $TFactThird = array(); $nb_bills_created = 0; @@ -380,7 +381,7 @@ if (empty($reshook)) { $objecttmp = new FactureFournisseur($db); if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) { - $objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order. + $objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created supplier invoice. } else { $objecttmp->socid = $cmd->socid; $objecttmp->type = $objecttmp::TYPE_STANDARD; @@ -505,7 +506,8 @@ if (empty($reshook)) { false, $lines[$i]->array_options, $lines[$i]->fk_unit, - $objecttmp->origin_id, + // we use the id of each order, not the id of the first one stored in $objecttmp->origin_id + $lines[$i]->fk_commande, $lines[$i]->pa_ht, $lines[$i]->ref_supplier, $lines[$i]->special_code, From 7b76188816f2cc3af803ff26d55afbea87f0c073 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 19 Sep 2023 11:32:48 +0200 Subject: [PATCH 07/10] 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 08/10] 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 09/10] 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 From fc4455e82ffff16a2ce244eb87e5645d042e9358 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Sep 2023 15:52:43 +0200 Subject: [PATCH 10/10] Fix responsive for edit contact --- htdocs/contact/card.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index e7dfdd4128b..b4fe96fee59 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -792,7 +792,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.$form->editfieldkey('PhonePerso', 'phone_perso', '', $object, 0).''; print ''; print img_picto('', 'object_phoning', 'class="pictofixedwidth"'); - print ''; + print ''; + print ''; print ''.$form->editfieldkey('PhoneMobile', 'phone_mobile', '', $object, 0).''; print ''; @@ -1055,6 +1056,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print img_picto('', 'object_phoning', 'class="pictofixedwidth"'); print ''; + if ($conf->browser->layout == 'phone') { + print ''; + } print ''.$form->editfieldkey('PhonePerso', 'fax', GETPOST('phone_perso', 'alpha'), $object, 0).''; print ''; print img_picto('', 'object_phoning', 'class="pictofixedwidth"'); @@ -1064,6 +1068,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print img_picto('', 'object_phoning_mobile', 'class="pictofixedwidth"'); print ''; + if ($conf->browser->layout == 'phone') { + print ''; + } print ''.$form->editfieldkey('Fax', 'fax', GETPOST('fax', 'alpha'), $object, 0).''; print ''; print img_picto('', 'object_phoning_fax', 'class="pictofixedwidth"'); @@ -1127,10 +1134,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Visibility print ''; $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); - print $form->selectarray('priv', $selectarray, $object->priv, 0); + print $form->selectarray('priv', $selectarray, $object->priv, 0, 0, 0,'', 0, 0, 0, '', 'maxwidth150'); print ''; - //Default language + // Default language if (getDolGlobalInt('MAIN_MULTILANGS')) { print ''.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).''."\n"; print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language(GETPOST('default_lang', 'alpha') ? GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone'); @@ -1239,7 +1246,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($maxmin > 0) { print ''; // MAX_FILE_SIZE must precede the field type=file } - print ''; + print ''; print ''; print '';