From ce0f46a48395032d70b37d477523add3e26c6ef4 Mon Sep 17 00:00:00 2001 From: lvessiller-opendsi Date: Tue, 3 Jun 2025 17:03:15 +0200 Subject: [PATCH 01/10] FIX local taxes text in PDF (#34343) --- htdocs/core/lib/pdf.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index cb7114032dc..4170b0fe4f6 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1901,7 +1901,7 @@ function pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails = 0) $tmpresult .= vatrate($object->lines[$i]->tva_tx, 0, $object->lines[$i]->info_bits, -1); if (empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) { - if ($object->lines[$i]->total_localtax1 != 0) { + if (price2num($object->lines[$i]->localtax1_tx)) { if (preg_replace('/[\s0%]/', '', $tmpresult)) { $tmpresult .= '/'; } else { @@ -1911,7 +1911,7 @@ function pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails = 0) } } if (empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) { - if ($object->lines[$i]->total_localtax2 != 0) { + if (price2num($object->lines[$i]->localtax2_tx)) { if (preg_replace('/[\s0%]/', '', $tmpresult)) { $tmpresult .= '/'; } else { From 6202f614a44b20409240a2a06d595d97305b37dc Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 3 Jun 2025 17:04:19 +0200 Subject: [PATCH 02/10] FIX: accountancy sales/purchases journal: sql error logged when no invoice in journal (#34339) * FIX: accountancy sales/purchases journal: sql error logged when no invoice in journal * FIX: accountancy sales journal: correctly check unbounded lines --- .../accountancy/journal/purchasesjournal.php | 45 +++++++++--------- htdocs/accountancy/journal/sellsjournal.php | 46 ++++++++++--------- 2 files changed, 48 insertions(+), 43 deletions(-) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 21a624194ca..b1781a5a1e5 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -361,29 +361,32 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice } */ // New way, single query, load all unbound lines -$sql = " -SELECT - fk_facture_fourn, - COUNT(fd.rowid) as nb -FROM - llx_facture_fourn_det as fd -WHERE - fd.product_type <= 2 - AND fd.fk_code_ventilation <= 0 - AND fd.total_ttc <> 0 - AND fk_facture_fourn IN (".$db->sanitize(join(",", array_keys($tabfac))).") -GROUP BY fk_facture_fourn -"; -$resql = $db->query($sql); -$num = $db->num_rows($resql); -$i = 0; -while ($i < $num) { - $obj = $db->fetch_object($resql); - if ($obj->nb > 0) { - $errorforinvoice[$obj->fk_facture_fourn] = 'somelinesarenotbound'; +if (!empty($tabfac)) { + $sql = " + SELECT + fk_facture_fourn, + COUNT(fd.rowid) as nb + FROM + llx_facture_fourn_det as fd + WHERE + fd.product_type <= 2 + AND fd.fk_code_ventilation <= 0 + AND fd.total_ttc <> 0 + AND fk_facture_fourn IN (".$db->sanitize(join(",", array_keys($tabfac))).") + GROUP BY fk_facture_fourn + "; + $resql = $db->query($sql); + + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $obj = $db->fetch_object($resql); + if ($obj->nb > 0) { + $errorforinvoice[$obj->fk_facture_fourn] = 'somelinesarenotbound'; + } + $i++; } - $i++; } //var_dump($errorforinvoice);exit; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 727c5e13e95..7876415715d 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -390,29 +390,31 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice */ // New way, single query, load all unbound lines -$sql = " -SELECT - fk_facture, - COUNT(fd.rowid) as nb -FROM - ".MAIN_DB_PREFIX."facturedet as fd -WHERE - fd.product_type <= 2 - AND fd.fk_code_ventilation <= 0 - AND fd.total_ttc <> 0 - AND fk_facture IN (".$db->sanitize(join(",", array_keys($tabfac))).") -GROUP BY fk_facture -"; -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $obj = $db->fetch_object($resql); - if ($obj->nb > 0) { - $errorforinvoice[$obj->fk_facture_fourn] = 'somelinesarenotbound'; +if (!empty($tabfac)) { + $sql = " + SELECT + fk_facture, + COUNT(fd.rowid) as nb + FROM + ".MAIN_DB_PREFIX."facturedet as fd + WHERE + fd.product_type <= 2 + AND fd.fk_code_ventilation <= 0 + AND fd.total_ttc <> 0 + AND fk_facture IN (".$db->sanitize(join(",", array_keys($tabfac))).") + GROUP BY fk_facture + "; + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $obj = $db->fetch_object($resql); + if ($obj->nb > 0) { + $errorforinvoice[$obj->fk_facture] = 'somelinesarenotbound'; + } + $i++; } - $i++; } } //var_dump($errorforinvoice);exit; From 8853bfd51a347f9bad1e8e97668cda7aa4426edb Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Wed, 4 Jun 2025 14:09:03 +0200 Subject: [PATCH 03/10] fix: ref_client GETPOST facture/card.php should be alpha (#34311) * fix: ref_client GETPOST facture/card.php should be alpha * Update card.php --------- Co-authored-by: Laurent Destailleur --- htdocs/compta/facture/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 90555b00b0c..bdb92bad66f 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -98,7 +98,7 @@ $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility $fac_rec = GETPOST('fac_rec', 'int'); $facid = GETPOST('facid', 'int'); -$ref_client = GETPOST('ref_client', 'int'); +$ref_client = GETPOST('ref_client', 'alpha'); $rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; $projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : 0); @@ -643,7 +643,7 @@ if (empty($reshook)) { $object->setValueFrom('ref', GETPOST('ref'), '', null, '', '', $user, 'BILL_MODIFY'); } elseif ($action == 'setref_client' && $usercancreate) { $object->fetch($id); - $object->set_ref_client(GETPOST('ref_client')); + $object->set_ref_client(GETPOST('ref_client', 'alpha')); } elseif ($action == 'confirm_valid' && $confirm == 'yes' && $usercanvalidate) { // Classify to validated $idwarehouse = GETPOST('idwarehouse', 'int'); From 35528a5885406a0409571272afdc43becd56ccc3 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 5 Jun 2025 18:29:12 +0200 Subject: [PATCH 04/10] FIX: prevent log warning with online signature url (#34361) --- htdocs/comm/propal/card.php | 2 +- htdocs/contrat/card.php | 2 +- htdocs/core/lib/functions.lib.php | 6 +++--- htdocs/fichinter/card.php | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 63dd1ae7436..715c16026e9 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -3137,7 +3137,7 @@ if ($action == 'create') { if ($object->statut != Propal::STATUS_DRAFT && $useonlinesignature) { print '
'; require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; - print showOnlineSignatureUrl('proposal', $object->ref).'
'; + print showOnlineSignatureUrl('proposal', $object->ref, $object).'
'; } print '
'; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 2ed1d9b5763..41d1ad36de1 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -2240,7 +2240,7 @@ if ($action == 'create') { print '
'; require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; - print showOnlineSignatureUrl('contract', $object->ref).'
'; + print showOnlineSignatureUrl('contract', $object->ref, $object).'
'; } print '
'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 25ee75bbd15..1ea0b5744b5 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8281,7 +8281,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if (is_object($object) && $object->element == 'propal') { $substitutionarray['__URL_PROPOSAL__'] = DOL_MAIN_URL_ROOT."/comm/propal/card.php?id=".$object->id; require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; - $substitutionarray['__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0, 'proposal', $object->ref); + $substitutionarray['__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0, 'proposal', $object->ref, 1, $object); } if (is_object($object) && $object->element == 'commande') { $substitutionarray['__URL_ORDER__'] = DOL_MAIN_URL_ROOT."/commande/card.php?id=".$object->id; @@ -8292,12 +8292,12 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if (is_object($object) && $object->element == 'contrat') { $substitutionarray['__URL_CONTRACT__'] = DOL_MAIN_URL_ROOT."/contrat/card.php?id=".$object->id; require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; - $substitutionarray['__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0, 'contract', $object->ref); + $substitutionarray['__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0, 'contract', $object->ref, 1, $object); } if (is_object($object) && $object->element == 'fichinter') { $substitutionarray['__URL_FICHINTER__'] = DOL_MAIN_URL_ROOT."/fichinter/card.php?id=".$object->id; require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; - $substitutionarray['__ONLINE_SIGN_FICHINTER_URL__'] = getOnlineSignatureUrl(0, 'fichinter', $object->ref); + $substitutionarray['__ONLINE_SIGN_FICHINTER_URL__'] = getOnlineSignatureUrl(0, 'fichinter', $object->ref, 1, $object); } if (is_object($object) && $object->element == 'supplier_proposal') { $substitutionarray['__URL_SUPPLIER_PROPOSAL__'] = DOL_MAIN_URL_ROOT."/supplier_proposal/card.php?id=".$object->id; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 90cadeb1de6..261b5e4ffaa 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1731,7 +1731,7 @@ if ($action == 'create') { print '
'; require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; - print showOnlineSignatureUrl('fichinter', $object->ref).'
'; + print showOnlineSignatureUrl('fichinter', $object->ref, $object).'
'; } print '
'; From f8f31daa169150e61dfad8ef79e4fc7205f00516 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 5 Jun 2025 18:29:33 +0200 Subject: [PATCH 05/10] FIX: accountancy fec export: remove dol_print_date warning (#34363) --- htdocs/accountancy/class/bookkeeping.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 0e50bc607d3..eff8db4c522 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -967,7 +967,7 @@ class BookKeeping extends CommonObject $line->multicurrency_amount = $obj->multicurrency_amount; $line->multicurrency_code = $obj->multicurrency_code; $line->lettering_code = $obj->lettering_code; - $line->date_lettering = $obj->date_lettering; + $line->date_lettering = $this->db->jdate($obj->date_lettering); $line->fk_user_author = $obj->fk_user_author; $line->import_key = $obj->import_key; $line->code_journal = $obj->code_journal; @@ -1119,7 +1119,7 @@ class BookKeeping extends CommonObject $line->amount = $obj->amount; $line->sens = $obj->sens; $line->lettering_code = $obj->lettering_code; - $line->date_lettering = $obj->date_lettering; + $line->date_lettering = $this->db->jdate($obj->date_lettering); $line->fk_user_author = $obj->fk_user_author; $line->import_key = $obj->import_key; $line->code_journal = $obj->code_journal; From f137074a9894f26d9b9c159fba92299f087402ae Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 5 Jun 2025 18:30:06 +0200 Subject: [PATCH 06/10] FIX: cash control report: php warning (#34358) --- htdocs/compta/cashcontrol/report.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index c3d625c01e4..85e613d9a65 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -253,7 +253,7 @@ if ($resql) { // Date ope print ''; - print ''.dol_print_date($db->jdate($objp->do), "day").""; + print ''.dol_print_date($db->jdate($objp->do), "day").""; print "\n"; if (!$i) { $totalarray['nbfield']++; From dcc433476811c088e50f9539f7b55b5c6ae6a513 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 5 Jun 2025 18:34:56 +0200 Subject: [PATCH 07/10] FIX: warnings when printing start/end date on line tpl (#34359) --- htdocs/fourn/class/fournisseur.facture-rec.class.php | 8 ++++---- htdocs/fourn/class/fournisseur.facture.class.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index 9562890c80e..723928dc052 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -754,8 +754,8 @@ class FactureFournisseurRec extends CommonInvoice $line->total_localtax2 = $objp->total_localtax2; $line->total_ttc = $objp->total_ttc; $line->product_type = $objp->product_type; - $line->date_start = $objp->date_start; - $line->date_end = $objp->date_end; + $line->date_start = $this->db->jdate($objp->date_start); + $line->date_end = $this->db->jdate($objp->date_end); $line->info_bits = $objp->info_bits ; $line->special_code = $objp->special_code; $line->rang = $objp->rang; @@ -2122,8 +2122,8 @@ class FactureFournisseurLigneRec extends CommonObjectLine $this->total_localtax2 = $objp->total_localtax2; $this->total_ttc = $objp->total_ttc; $this->product_type = $objp->product_type; - $this->date_start = $objp->date_start; - $this->date_end = $objp->date_end; + $this->date_start = $this->db->jdate($objp->date_start); + $this->date_end = $this->db->jdate($objp->date_end); $this->info_bits = $objp->info_bits; $this->special_code = $objp->special_code; $this->rang = $objp->rang; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 7939e10b9a2..5d2e55c3b9b 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1072,8 +1072,8 @@ class FactureFournisseur extends CommonInvoice $line->id = $obj->rowid; $line->rowid = $obj->rowid; $line->description = $obj->description; - $line->date_start = $obj->date_start; - $line->date_end = $obj->date_end; + $line->date_start = $this->db->jdate($obj->date_start); + $line->date_end = $this->db->jdate($obj->date_end); $line->product_ref = $obj->product_ref; $line->ref = $obj->product_ref; @@ -3657,8 +3657,8 @@ class SupplierInvoiceLine extends CommonObjectLine $this->rowid = $obj->rowid; $this->fk_facture_fourn = $obj->fk_facture_fourn; $this->description = $obj->description; - $this->date_start = $obj->date_start; - $this->date_end = $obj->date_end; + $this->date_start = $this->db->jdate($obj->date_start); + $this->date_end = $this->db->jdate($obj->date_end); $this->product_ref = $obj->product_ref; $this->ref_supplier = $obj->ref_supplier; $this->product_desc = $obj->product_desc; From 4096b00bd535b26df5e269a609a61755d4adcdb3 Mon Sep 17 00:00:00 2001 From: noec764 <58433943+noec764@users.noreply.github.com> Date: Sun, 8 Jun 2025 14:26:44 +0200 Subject: [PATCH 08/10] FIX: Too heavy sql query (#34371) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Noé --- htdocs/user/class/user.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 7a2fadb4757..9bc17654722 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -3958,10 +3958,9 @@ class User extends CommonObject if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) { $sql .= " WHERE t.entity IS NOT NULL"; // Show all users } else { - $sql .= ",".$this->db->prefix()."usergroup_user as ug"; - $sql .= " WHERE ((ug.fk_user = t.rowid"; - $sql .= " AND ug.entity IN (".getEntity('usergroup')."))"; - $sql .= " OR t.entity = 0)"; // Show always superadmin + $sql .= " WHERE t.entity = 0 OR EXISTS ("; + $sql .= " SELECT ug.rowid FROM " . $this->db->prefix() . "usergroup_user as ug"; + $sql .= " WHERE ug.fk_user = t.rowid AND ug.entity IN (" . getEntity('usergroup') . "))"; } } else { $sql .= " WHERE t.entity IN (".getEntity('user').")"; From 58bd0ed0f6ebd7c07d4e25b4f2a751a57878e5ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NASSIET?= <109105553+comaiteseb@users.noreply.github.com> Date: Sun, 8 Jun 2025 14:29:36 +0200 Subject: [PATCH 09/10] Use DOL_DATA_ROOT instead of DOL_DOCUMENT_ROOT for upload_dir_tmp in CMailFile (#34367) --- htdocs/takepos/send.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/send.php b/htdocs/takepos/send.php index 8164c4bae96..bd38ff40b7a 100644 --- a/htdocs/takepos/send.php +++ b/htdocs/takepos/send.php @@ -81,7 +81,7 @@ if ($action == "send") { $msg = "".$arraydefaultmessage->content."
".$receipt.""; $sendto = $email; $from = $mysoc->email; - $mail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', '', '', '', '', DOL_DOCUMENT_ROOT.'/documents/takepos/temp'); + $mail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', '', '', '', '', DOL_DATA_ROOT.'/documents/takepos/temp'); if ($mail->error || !empty($mail->errors)) { setEventMessages($mail->error, $mail->errors, 'errors'); } else { From 1aaa29ad9e356792cb36e4e07fc7b80a159c65c7 Mon Sep 17 00:00:00 2001 From: William Mead Date: Sun, 8 Jun 2025 14:37:23 +0200 Subject: [PATCH 10/10] Fixed expense report permission. Added contributor details. (#34368) --- htdocs/api/class/api_documents.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index b8320b35df3..c37e8db9f6b 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2016 Laurent Destailleur * Copyright (C) 2016 Jean-François Ferry * Copyright (C) 2023 Romain Neil + * Copyright (C) 2025 William Mead * * 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 @@ -481,7 +482,7 @@ class Documents extends DolibarrApi } elseif ($modulepart == 'expensereport') { require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; - if (!DolibarrApiAccess::$user->rights->expensereport->read && !DolibarrApiAccess::$user->rights->expensereport->read) { + if (!DolibarrApiAccess::$user->rights->expensereport->lire) { throw new RestException(401); }