From f3460eae482ca6c8a382b85704463336fd52fc3e Mon Sep 17 00:00:00 2001 From: IC-Mathieu <95343351+IC-Mathieu@users.noreply.github.com> Date: Tue, 21 May 2024 20:01:36 +0200 Subject: [PATCH 01/18] FIX REPLENISH MANY FOURN WHEN ORDER ALREADY CREATE (#29710) --- htdocs/product/stock/replenish.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 66ad0889b31..e3f27476488 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -273,6 +273,7 @@ if ($action == 'order' && GETPOST('valid')) { } else { $id = $result; } + $i++; } else { $order->socid = $suppliersid[$i]; $order->fetch_thirdparty(); From 26e09f85d2c0ac57ec4a6344a040ab43e1ca0d32 Mon Sep 17 00:00:00 2001 From: Yannis Hoareau <93135242+YannisHoareau@users.noreply.github.com> Date: Tue, 4 Jun 2024 10:52:29 +0200 Subject: [PATCH 02/18] FIX: Unsigned propal having signing date (#29825) * FIX propal dates: setting sign date only if signed * FIX propal dates: clearing sign date when reopenning a propal * FIX propal dates: reworked + not clearing sign date Not clearing the sign date anymore because of 17.0 configuration that allow the user to choose if he wants to keep the previous sign date or the current date. * FIX propal dates: move comma to fix sql syntax error * FIX propal dates: add SQL request to update database This SQL request is meant to set the sign date and the signing user to null to match the fix * Update 15.0.0-16.0.0.sql --------- Co-authored-by: Laurent Destailleur --- htdocs/comm/propal/class/propal.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 29987531925..a33d0864a6c 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2629,7 +2629,10 @@ class Propal extends CommonObject $newprivatenote = dol_concatdesc($this->note_private, $note); $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; - $sql .= " SET fk_statut = ".((int) $status).", note_private = '".$this->db->escape($newprivatenote)."', date_signature='".$this->db->idate($now)."', fk_user_signature=".$user->id; + $sql .= " SET fk_statut = ".((int) $status).", note_private = '".$this->db->escape($newprivatenote)."'"; + if ($status == self::STATUS_SIGNED) { + $sql .= ", date_signature='".$this->db->idate($now)."', fk_user_signature=".$user->id; + } $sql .= " WHERE rowid = ".((int) $this->id); $resql = $this->db->query($sql); From 7249e3a4d184d01d8a02a4c013fe49aa7e1637bb Mon Sep 17 00:00:00 2001 From: lvessiller-opendsi Date: Thu, 6 Jun 2024 15:33:35 +0200 Subject: [PATCH 03/18] FIX init total amounts in margin module (#29854) --- htdocs/margin/agentMargins.php | 4 +++- htdocs/margin/customerMargins.php | 3 +++ htdocs/margin/productMargins.php | 3 +++ htdocs/margin/tabs/productMargins.php | 4 ++-- htdocs/margin/tabs/thirdpartyMargins.php | 3 +++ 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index f369f1889c2..e0687a59811 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -226,7 +226,9 @@ if (!empty($enddateyear)) { $param .= "&enddateyear=".urlencode($enddateyear); } - +$totalMargin = 0; +$marginRate = ''; +$markRate = ''; dol_syslog('margin::agentMargins.php', LOG_DEBUG); $result = $db->query($sql); if ($result) { diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 93850b8ec10..9009b9f8800 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -297,6 +297,9 @@ if (is_array($listofcateg)) { } } +$totalMargin = 0; +$marginRate = ''; +$markRate = ''; dol_syslog('margin::customerMargins.php', LOG_DEBUG); $result = $db->query($sql); if ($result) { diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 32cb3c9292d..bd8ab227559 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -247,6 +247,9 @@ if (is_array($listofcateg)) { } } +$totalMargin = 0; +$marginRate = ''; +$markRate = ''; dol_syslog('margin::productMargins.php', LOG_DEBUG); $result = $db->query($sql); if ($result) { diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 1bda53b5c5d..e01252d2add 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -75,8 +75,8 @@ $invoicestatic = new Facture($db); $form = new Form($db); $totalMargin = 0; -$marginRate = 0; -$markRate = 0; +$marginRate = ''; +$markRate = ''; if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 3202dcb93ce..dfb080126d0 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -93,6 +93,9 @@ if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); +$totalMargin = 0; +$marginRate = ''; +$markRate = ''; if ($socid > 0) { $object = new Societe($db); $object->fetch($socid); From bd2313354303baa47dcb8c58a942f6d95a6f34c7 Mon Sep 17 00:00:00 2001 From: lvessiller-opendsi Date: Thu, 6 Jun 2024 15:36:52 +0200 Subject: [PATCH 04/18] FIX group by qty in product margin tab (#29853) --- htdocs/margin/tabs/productMargins.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index e01252d2add..99c55de1e80 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -164,7 +164,7 @@ if ($id > 0 || !empty($ref)) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if (!empty($socid)) { - $sql .= " AND f.fk_soc = $socid"; + $sql .= " AND f.fk_soc = ".((int) $socid); } $sql .= " AND d.buy_price_ht IS NOT NULL"; // We should not use this here. Option ForceBuyingPriceIfNull should have effect only when inserting data. Once data is recorded, it must be used as it is for report. @@ -198,7 +198,7 @@ if ($id > 0 || !empty($ref)) { print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&id=".$object->id, '', $sortfield, $sortorder, 'left '); print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("BuyingPrice", $_SERVER["PHP_SELF"], "buying_price", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "qty", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); From a3e7151633a0d098e0263b4b68cb25cff8647daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Champlon?= <85104766+Kazimir42@users.noreply.github.com> Date: Fri, 7 Jun 2024 16:20:25 +0200 Subject: [PATCH 05/18] fix restrictedArea on selectobject (#29882) --- htdocs/core/ajax/selectobject.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/ajax/selectobject.php b/htdocs/core/ajax/selectobject.php index c8c3e13ea3d..c4010731ccb 100644 --- a/htdocs/core/ajax/selectobject.php +++ b/htdocs/core/ajax/selectobject.php @@ -84,7 +84,11 @@ if (!is_object($objecttmp)) { $searchkey = (($id && GETPOST($id, 'alpha')) ? GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ? GETPOST($htmlname, 'alpha') : '')); // Add a security test to avoid to get content of all tables -restrictedArea($user, $objecttmp->element, $id); +if (!empty($objecttmp->module)) { + restrictedArea($user, $objecttmp->module, $id, $objecttmp->table_element, $objecttmp->element); +}else { + restrictedArea($user, $objecttmp->element, $id); +} $arrayresult = $form->selectForFormsList($objecttmp, $htmlname, '', 0, $searchkey, '', '', '', 0, 1); From ee75ffe823f3a36360d51eb2c386e6b49d76aa91 Mon Sep 17 00:00:00 2001 From: UltraViolet33 <93035200+UltraViolet33@users.noreply.github.com> Date: Fri, 7 Jun 2024 18:06:31 +0200 Subject: [PATCH 06/18] FIX update date_echeance of supplier invoices when we update invoice date in the past (#29886) When we update the date of supplier invoices in the past, the date_echeance was not updated if the new calculated date_echeance is before the current date_echeance. The same goes if we update the payment term of supplier invoice, the date echeance is not updated if the new calculted date_echeance is before the current date_echeance. With this PR, when we update the supplier invoice date or payment term, the date_echeance is updated even if the new calculated date_echeance is before the current date_echeance. Co-authored-by: Ulysse Valdenaire --- htdocs/fourn/facture/card.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index a9418197592..f3c153271d5 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -389,9 +389,8 @@ if (empty($reshook)) { } if (!$error) { - $old_date_echeance = $object->date_echeance; $new_date_echeance = $object->calculate_date_lim_reglement(); - if ($new_date_echeance > $old_date_echeance) { + if ($new_date_echeance) { $object->date_echeance = $new_date_echeance; } if ($object->date_echeance < $object->date) { @@ -455,7 +454,7 @@ if (empty($reshook)) { $object->date = $newdate; $date_echence_calc = $object->calculate_date_lim_reglement(); - if (!empty($object->date_echeance) && $object->date_echeance < $date_echence_calc) { + if (!empty($object->date_echeance)) { $object->date_echeance = $date_echence_calc; } if ($object->date_echeance && $object->date_echeance < $object->date) { From 72a2a96063dae6a50e2ee56516f6716d43e341fd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 7 Jun 2024 23:46:21 +0200 Subject: [PATCH 07/18] Fix travis --- htdocs/core/ajax/selectobject.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/ajax/selectobject.php b/htdocs/core/ajax/selectobject.php index c4010731ccb..37a0e6e32e3 100644 --- a/htdocs/core/ajax/selectobject.php +++ b/htdocs/core/ajax/selectobject.php @@ -85,9 +85,9 @@ $searchkey = (($id && GETPOST($id, 'alpha')) ? GETPOST($id, 'alpha') : (($htmlna // Add a security test to avoid to get content of all tables if (!empty($objecttmp->module)) { - restrictedArea($user, $objecttmp->module, $id, $objecttmp->table_element, $objecttmp->element); -}else { - restrictedArea($user, $objecttmp->element, $id); + restrictedArea($user, $objecttmp->module, $id, $objecttmp->table_element, $objecttmp->element); +} else { + restrictedArea($user, $objecttmp->element, $id); } $arrayresult = $form->selectForFormsList($objecttmp, $htmlname, '', 0, $searchkey, '', '', '', 0, 1); From 040e9083da39a03bcbb0eddbc74ae78ebbf64866 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 7 Jun 2024 23:56:14 +0200 Subject: [PATCH 08/18] Fix : expense report reapproval email, wrong date format + missing parameter (#29874) --- htdocs/expensereport/card.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 0201dfdd7f6..44cd66ff0c5 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -502,8 +502,7 @@ if (empty($reshook)) { // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; $link = ''.$link.''; - $dateRefusEx = explode(" ", $object->date_refuse); - $message = $langs->transnoentities("ExpenseReportWaitingForReApprovalMessage", $dateRefusEx[0], $object->detail_refuse, $expediteur->getFullName($langs), $link); + $message = $langs->transnoentities("ExpenseReportWaitingForReApprovalMessage", dol_print_date($object->date_refuse, 'day'), $object->detail_refuse, $expediteur->getFullName($langs), get_date_range($object->date_debut, $object->date_fin, '', $langs), $link); // Rebuild pdf /* From 5989ee9cf03fbcc3d8f41a1661d3d8dd4f4f6ec7 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 8 Jun 2024 00:09:30 +0200 Subject: [PATCH 09/18] Fix : SQL error on stock transfer deletion (#29902) --- .../stock/stocktransfer/class/stocktransfer.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php index a2f6707ad40..e5d0f8eb197 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php @@ -57,6 +57,15 @@ class StockTransfer extends CommonObject */ public $isextrafieldmanaged = 1; + /** + * @var int Name of subtable line + */ + public $table_element_line = 'stocktransfer_stocktransferline'; + + /** + * @var int Field with ID of parent key if this object has a parent + */ + public $fk_element = 'fk_stocktransfer'; /** * @var array List of child tables. To know object to delete on cascade. From b0e825c1230827e8462c89cc4c408c73d9324f2e Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Sat, 8 Jun 2024 12:01:22 +0200 Subject: [PATCH 10/18] FIX: PHP 8 warning on output of successful cronjob (#29922) --- htdocs/cron/class/cronjob.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index b89d7ea3cb7..569364a4dfd 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1275,7 +1275,7 @@ class Cronjob extends CommonObject $error++; } else { dol_syslog(get_class($this)."::run_jobs END"); - $this->lastoutput = dol_substr((empty($object->output) ? "" : $object->output."\n").$errmsg, 0, $this::MAXIMUM_LENGTH_FOR_LASTOUTPUT_FIELD, 'UTF-8', 1); + $this->lastoutput = dol_substr((empty($object->output) ? "" : $object->output."\n"), 0, $this::MAXIMUM_LENGTH_FOR_LASTOUTPUT_FIELD, 'UTF-8', 1); $this->lastresult = var_export($result, true); $retval = $this->lastresult; } From 956d1b025a4a4096e143ba226c7f943058d5b749 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 8 Jun 2024 23:35:01 +0200 Subject: [PATCH 11/18] Fix : product price by quantity was removing default price (#29899) --- htdocs/product/price.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index d93fdbe9b17..8ef9398cefe 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -503,7 +503,9 @@ if (empty($reshook)) { if ($action == 'activate_price_by_qty') { // Activating product price by quantity add a new price line with price_by_qty set to 1 $level = GETPOST('level', 'int'); - $ret = $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 1); + $basePrice = ($object->price_base_type == 'HT') ? $object->price : $object->price_ttc; + $basePriceMin = ($object->price_base_type == 'HT') ? $object->price_min : $object->price_min_ttc; + $ret = $object->updatePrice($basePrice, $object->price_base_type, $user, $object->tva_tx, $basePriceMin, $level, $object->tva_npr, 1); if ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -513,7 +515,9 @@ if (empty($reshook)) { if ($action == 'disable_price_by_qty') { // Disabling product price by quantity add a new price line with price_by_qty set to 0 $level = GETPOST('level', 'int'); - $ret = $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 0); + $basePrice = ($object->price_base_type == 'HT') ? $object->price : $object->price_ttc; + $basePriceMin = ($object->price_base_type == 'HT') ? $object->price_min : $object->price_min_ttc; + $ret = $object->updatePrice($basePrice, $object->price_base_type, $user, $object->tva_tx, $basePriceMin, $level, $object->tva_npr, 0); if ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); From c5bb1856c2f0806d7da4a9f7ea44a71e29a3b831 Mon Sep 17 00:00:00 2001 From: lvessiller-opendsi Date: Sat, 15 Jun 2024 15:02:19 +0200 Subject: [PATCH 12/18] FIX modification date from label in accounting bookkeeping list (#30038) --- htdocs/accountancy/bookkeeping/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 0ec53018a21..56a9a0916cf 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -919,7 +919,7 @@ if (!empty($arrayfields['t.tms']['checked'])) { print $form->selectDate($search_date_modification_start, 'search_date_modification_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); print ''; print '
'; - print $form->selectDate($search_date_modification_end, 'search_date_modification_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); + print $form->selectDate($search_date_modification_end, 'search_date_modification_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); print '
'; print ''; } From cbba014355f6395468670ea6d7f021697b581446 Mon Sep 17 00:00:00 2001 From: Eric - CAP-REL <1468823+rycks@users.noreply.github.com> Date: Sat, 15 Jun 2024 16:27:54 +0200 Subject: [PATCH 13/18] =?UTF-8?q?fk=5Fproduct=20could=20be=20=3D=20-1=20th?= =?UTF-8?q?en=20line=20added=20is=20not=20linked=20to=20selected=20pr?= =?UTF-8?q?=E2=80=A6=20(#30013)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fk_product could be = -1 then line added is not linked to selected product * more clear conditions * idprod could be set if prev dropdown menu was used --- htdocs/projet/tasks/time.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 58995267410..99eb3b01b36 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -499,8 +499,9 @@ if ($action == 'confirm_generateinvoice') { if (getDolGlobalInt('PROJECT_USE_REAL_COST_FOR_TIME_INVOICING')) { // We set unit price to 0 to force the use of the rate saved during recording $pu_ht = 0; - } else { + } elseif ($idprod <= 0) { // We want to sell all the time spent with the last hourly rate of user + // -> but what about choice user selected ? add idprod test $pu_ht = $fuser->thm; } @@ -520,7 +521,7 @@ if ($action == 'confirm_generateinvoice') { $localtax2line = $localtax2; // If a particular product/service was defined for the task - if (!empty($fk_product) && $fk_product !== $idprod) { + if (!empty($fk_product) && ($fk_product > 0) && ($fk_product !== $idprod)) { if (!array_key_exists($fk_product, $product_data_cache)) { $result = $tmpproduct->fetch($fk_product); if ($result < 0) { From 9c6a1eac945b1acadaa024384df66e039dbe4cf0 Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Mon, 24 Jun 2024 23:47:34 +0200 Subject: [PATCH 14/18] fix: bad errors variable for error return (#30145) * fix: bad errors variable for error return * fix: bad errors variable for error return * Update contrat.class.php fix review --- htdocs/contrat/class/contrat.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 65e5249bf82..3718c2740e0 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1621,7 +1621,8 @@ class Contrat extends CommonObject $contractline->id = $contractlineid; $result = $contractline->insertExtraFields(); if ($result < 0) { - $this->error[] = $contractline->error; + $this->errors = array_merge($this->errors, $contractline->errors); + $this->error = $contractline->error; $error++; } } From fdf5fe0f267fb40a8cda945d801bf48dea674cf6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 29 Jun 2024 19:28:30 +0200 Subject: [PATCH 15/18] FIX broken pdf preview when multicompany sharing (#30188) * FIX broken pdf preview when multicompany sharing * Update html.formmail.class.php --------- Co-authored-by: Laurent Destailleur --- htdocs/core/class/html.formmail.class.php | 7 ++++--- htdocs/core/tpl/card_presend.tpl.php | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index aa35fa988d1..c3139bb3c78 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -844,8 +844,9 @@ class FormMail extends Form foreach ($listofpaths as $key => $val) { $relativepathtofile = substr($val, (strlen(DOL_DATA_ROOT) - strlen($val))); - if ($conf->entity > 1) { - $relativepathtofile = str_replace('/'.$conf->entity.'/', '/', $relativepathtofile); + $entity = (isset($this->param['object_entity']) ? $this->param['object_entity'] : $conf->entity); + if ($entity > 1) { + $relativepathtofile = str_replace('/'.$entity.'/', '/', $relativepathtofile); } // Try to extract data from full path $formfile_params = array(); @@ -855,7 +856,7 @@ class FormMail extends Form // Preview of attachment $out .= img_mime($listofnames[$key]).' '.$listofnames[$key]; - $out .= $formfile->showPreview(array(), $formfile_params[2], $formfile_params[4]); + $out .= $formfile->showPreview(array(), $formfile_params[2], $formfile_params[4], 0, ($entity == 1 ? '' : 'entity='.((int) $entity)); if (!$this->withfilereadonly) { $out .= ' '; //$out.= ' '.img_delete($langs->trans("Delete").''; diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 039f4e2a96a..9f8b7ab95b7 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -387,6 +387,7 @@ if ($action == 'presend') { $formmail->param['id'] = $object->id; $formmail->param['returnurl'] = $_SERVER["PHP_SELF"].'?id='.$object->id; $formmail->param['fileinit'] = array($file); + $formmail->param['object_entity'] = $object->entity; // Show form print $formmail->get_form(); From 42d9b384d4400272f5a00648ee898c0d27de1c5a Mon Sep 17 00:00:00 2001 From: noec764 <58433943+noec764@users.noreply.github.com> Date: Sat, 29 Jun 2024 19:29:14 +0200 Subject: [PATCH 16/18] FIX: Bad calculation of $nbtotalofrecord (#30183) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Noé --- htdocs/user/group/list.php | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/htdocs/user/group/list.php b/htdocs/user/group/list.php index d0998329fa0..11b5165f48b 100644 --- a/htdocs/user/group/list.php +++ b/htdocs/user/group/list.php @@ -174,6 +174,9 @@ $morecss = array(); // Build and execute select // -------------------------------------------------------------------- $sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec, g.tms, COUNT(DISTINCT ugu.fk_user) as nb, COUNT(DISTINCT ugr.fk_id) as nbpermissions"; + +$sqlfields = $sql; + $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_rights as ugr ON ugr.fk_usergroup = g.rowid"; @@ -190,11 +193,29 @@ if ($search_all) { } $sql .= " GROUP BY g.rowid, g.nom, g.note, g.entity, g.datec, g.tms"; +// Count total nb of records +$nbtotalofrecords = ''; +if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } + + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than paging size (filtering), goto and load page 0 + $page = 0; + $offset = 0; + } + $db->free($resql); +} + // Complete request and execute it with limit $sql .= $db->order($sortfield, $sortorder); -if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); -} $resql = $db->query($sql); if (!$resql) { @@ -204,9 +225,6 @@ if (!$resql) { $num = $db->num_rows($resql); - -$nbtotalofrecords = $num; - $i = 0; From 2e6af8782385775dbfc58e96a37f9a582d96ce8e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 29 Jun 2024 19:30:06 +0200 Subject: [PATCH 17/18] FIX User List - Function is show in wrong column when module HRM enabled (#30186) --- htdocs/user/list.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/user/list.php b/htdocs/user/list.php index c7a10b2c3cb..e5ca8d9cf72 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -1,9 +1,9 @@ - * Copyright (C) 2004-2021 Laurent Destailleur - * Copyright (C) 2005-2017 Regis Houssin - * Copyright (C) 2015 Alexandre Spangaro - * Copyright (C) 2016 Marcos García +/* Copyright (C) 2002-2005 Rodolphe Quiedeville + * Copyright (C) 2004-2021 Laurent Destailleur + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2015-2024 Alexandre Spangaro + * Copyright (C) 2016 Marcos García * * 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 @@ -134,9 +134,9 @@ $arrayfields = array( 'u.email'=>array('label'=>"EMail", 'checked'=>1, 'position'=>35), 'u.api_key'=>array('label'=>"ApiKey", 'checked'=>0, 'position'=>40, "enabled"=>(isModEnabled('api') && $user->admin)), 'u.fk_soc'=>array('label'=>"Company", 'checked'=>($contextpage == 'employeelist' ? 0 : 1), 'position'=>45), - 'u.ref_employee'=>array('label'=>"RefEmployee", 'checked'=>-1, 'position'=>60, 'enabled'=>(isModEnabled('hrm') && $permissiontoreadhr)), - 'u.national_registration_number'=>array('label'=>"NationalRegistrationNumber", 'checked'=>-1, 'position'=>61, 'enabled'=>(isModEnabled('hrm') && $permissiontoreadhr)), - 'u.job'=>array('label'=>"PostOrFunction", 'checked'=>-1, 'position'=>50), + 'u.ref_employee'=>array('label'=>"RefEmployee", 'checked'=>-1, 'position'=>50, 'enabled'=>(isModEnabled('hrm') && $permissiontoreadhr)), + 'u.national_registration_number'=>array('label'=>"NationalRegistrationNumber", 'checked'=>-1, 'position'=>51, 'enabled'=>(isModEnabled('hrm') && $permissiontoreadhr)), + 'u.job'=>array('label'=>"PostOrFunction", 'checked'=>-1, 'position'=>60), 'u.salary'=>array('label'=>"Salary", 'checked'=>-1, 'position'=>80, 'enabled'=>(isModEnabled('salaries') && $user->hasRight("salaries", "readall")), 'isameasure'=>1), 'u.datelastlogin'=>array('label'=>"LastConnexion", 'checked'=>1, 'position'=>100), 'u.datepreviouslogin'=>array('label'=>"PreviousConnexion", 'checked'=>0, 'position'=>110), @@ -897,10 +897,6 @@ if (!empty($arrayfields['u.entity']['checked'])) { print_liste_field_titre($arrayfields['u.entity']['label'], $_SERVER['PHP_SELF'], "u.entity", $param, "", "", $sortfield, $sortorder); $totalarray['nbfield']++; } -if (!empty($arrayfields['u.job']['checked'])) { - print_liste_field_titre($arrayfields['u.job']['label'], $_SERVER['PHP_SELF'], "u.job", $param, "", "", $sortfield, $sortorder); - $totalarray['nbfield']++; -} if (!empty($arrayfields['u.ref_employee']['checked'])) { print_liste_field_titre("RefEmployee", $_SERVER['PHP_SELF'], "u.ref_employee", $param, "", "", $sortfield, $sortorder); $totalarray['nbfield']++; @@ -909,6 +905,10 @@ if (!empty($arrayfields['u.national_registration_number']['checked'])) { print_liste_field_titre("NationalRegistrationNumber", $_SERVER['PHP_SELF'], "u.national_registration_number", $param, "", "", $sortfield, $sortorder); $totalarray['nbfield']++; } +if (!empty($arrayfields['u.job']['checked'])) { + print_liste_field_titre($arrayfields['u.job']['label'], $_SERVER['PHP_SELF'], "u.job", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; +} if (!empty($arrayfields['u.salary']['checked'])) { print_liste_field_titre("Salary", $_SERVER['PHP_SELF'], "u.salary", $param, "", "", $sortfield, $sortorder, 'right '); $totalarray['nbfield']++; From 6cd3d7943d95f9cbbd5cf2200654e7add2e2f7fd Mon Sep 17 00:00:00 2001 From: lvessiller-opendsi Date: Sat, 29 Jun 2024 19:31:08 +0200 Subject: [PATCH 18/18] FIX orders to bill menu (#30179) * FIX orders to bill menu * only fix url menu * FIX orders supplier to bill menu --- htdocs/core/menus/standard/eldy.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 6e03224a306..dcaead425ef 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1494,7 +1494,7 @@ function get_left_menu_billing($mainmenu, &$newmenu, $usemenuhider = 1, $leftmen if (isModEnabled('commande')) { $langs->load("orders"); if (isModEnabled('facture')) { - $newmenu->add("/commande/list.php?leftmenu=orders&search_status=-3&billed=0&contextpage=billableorders", $langs->trans("MenuOrdersToBill2"), 0, $user->hasRight('commande', 'lire'), '', $mainmenu, 'orders', 0, '', '', '', img_picto('', 'order', 'class="paddingright pictofixedwidth"')); + $newmenu->add("/commande/list.php?leftmenu=orders&search_status=-3&search_billed=0&contextpage=billableorders", $langs->trans("MenuOrdersToBill2"), 0, $user->hasRight('commande', 'lire'), '', $mainmenu, 'orders', 0, '', '', '', img_picto('', 'order', 'class="paddingright pictofixedwidth"')); } //if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->hasRight('commande', 'lire')); } @@ -1503,7 +1503,7 @@ function get_left_menu_billing($mainmenu, &$newmenu, $usemenuhider = 1, $leftmen if (isModEnabled('supplier_invoice')) { if (!empty($conf->global->SUPPLIER_MENU_ORDER_RECEIVED_INTO_INVOICE)) { $langs->load("supplier"); - $newmenu->add("/fourn/commande/list.php?leftmenu=orders&search_status=5&billed=0", $langs->trans("MenuOrdersSupplierToBill"), 0, $user->hasRight('commande', 'lire'), '', $mainmenu, 'orders', 0, '', '', '', img_picto('', 'supplier_order', 'class="paddingright pictofixedwidth"')); + $newmenu->add("/fourn/commande/list.php?leftmenu=orders&search_status=5&search_billed=0", $langs->trans("MenuOrdersSupplierToBill"), 0, $user->hasRight('commande', 'lire'), '', $mainmenu, 'orders', 0, '', '', '', img_picto('', 'supplier_order', 'class="paddingright pictofixedwidth"')); //if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->hasRight('commande', 'lire')); } }