Commit graph

143330 commits

Author SHA1 Message Date
w3houde
fe1386fa2d
Fix #38860 build valid ldap:// URI for scheme-less host on PHP 8.3+ (#39167)
Since PHP 8.3 ldap_connect() takes a single URI argument. connectBind()
concatenated host and port as "host:port", which is a malformed URI for a
scheme-less host (localhost, 192.168.0.2) since the host is then parsed as the
URI scheme, so the following bind returns false. It also appended ":port" to an
already qualified ldaps:// URI. Prefix scheme-less hosts with ldap:// and leave
ldap(s):// URIs untouched.

Signed-off-by: Dolicraft <clement@pixodeo.com>
2026-07-15 00:41:18 +02:00
TowyTowy
5c6e4f486d
FIX dol_string_nohtmltag() skips double-space collapsing when string starts with a double space (#39175)
The double-space removal loop guarded its condition with the truthiness
of strpos():

    while (strpos($temp, "  ")) {

strpos() returns int 0 when the first double space is at position 0 of
the string, and 0 is falsy, so the loop body never runs. As a result NO
double spaces are collapsed at all in that string, including interior
ones. This happens for any input that begins with two spaces, e.g. text
whose leading "<br><br>" is turned into two leading spaces by the
removelinefeed step just above. The trailing trim() hides the leading
spaces but the interior double spaces survive, producing wrong output
(e.g. "Total  amount  due" instead of "Total amount due").

Fix by comparing against false, the standard PHP idiom used elsewhere in
this codebase. Strings that do not start with a double space were already
handled correctly, so behaviour is unchanged for them. Also corrected the
neighbouring comment ("double quotes" -> "double spaces").

Signed-off-by: TowyTowy <towy@airreps.link>
Co-authored-by: Claude <noreply@anthropic.com>
2026-07-15 00:40:03 +02:00
GregcodeOhm
edc19593c9
FIX phan and phpstan errors on 21.0 static analysis (#39152)
Two errors were surfaced on the 21.0 branch by the automated pullmerge
from the 18.0 to 20.0 branches, and they make the phan and phpstan CI
jobs fail on every open pull request:

- htdocs/takepos/invoice.php: dol_htmloutput_errors() second argument
  must be an array, not null (phpstan).
- htdocs/societe/class/societe.class.php: the string parameter $remise
  must be cast to float before the multiplication, like the surrounding
  lines already do (phan PhanTypeInvalidLeftOperandOfNumericOp).

Signed-off-by: Gregory Aliot <greg.aliot@gmail.com>
Co-authored-by: Gregory Aliot <greg.aliot@gmail.com>
2026-07-14 00:42:54 +02:00
Laurent Destailleur
6cb5380087 Merge branch '20.0' of git@github.com:Dolibarr/dolibarr.git into 21.0 2026-07-13 16:33:26 +02:00
Laurent Destailleur
dc382c14aa Automated merge from 19.0 to 20.0 by tool pullmerge.sh 2026-07-13 16:28:07 +02:00
Laurent Destailleur
febbfc8207 Automated merge from 18.0 to 19.0 by tool pullmerge.sh 2026-07-13 16:16:47 +02:00
TowyTowy
21416a8275
FIX checkES loops past end of weights array (#39144)
The account-number checksum loop in checkES() used the condition
$i < 11 while $values holds only 10 weights (indexes 0..9) and
$InumCta is validated to be exactly 10 digits. On the final pass it
therefore read $values[10] and substr($InumCta, 10, 1), raising an
"Undefined array key 10" warning under PHP 8 every time a Spanish
(ES) bank account control key is computed (e.g. via checkBanForAccount()).

Both extra terms evaluate to 0, so the returned control key is
unchanged; this only removes the spurious warning. The bound is
aligned with the sibling loop above (which correctly uses $i < 10)
and with the size of $values and $InumCta.

Signed-off-by: TowyTowy <towy@airreps.link>
Co-authored-by: Claude <noreply@anthropic.com>
2026-07-13 14:26:53 +02:00
GregcodeOhm
ea507289a9
FIX #39038 Double quote in product label truncates the combo (#39051)
In select_produits_list() the product option data-html attribute is
built by concatenating $labeltoshowhtml, $outvalUnits and
$labeltoshowhtmlprice as raw strings. The variables that carry user
text are $labeltoshowhtml (ref, customer ref, barcode and product
label) and $outvalUnits (unit short label from the dictionary), so a
double quote typed there, for example an inch mark 1/2", closes the
data-html="..." attribute early and the rich dropdown (ajaxcombo)
shows the name truncated at the quote. $labeltoshowhtmlprice only
carries outputs of price() and transnoentities() and cannot contain a
double quote.

Sanitize the two user variables with dolPrintHTMLForAttribute(), as the
stock part of the same attribute already does. The tag 'strong' is
passed in the allowothertags parameter for the label so the search
highlight added around the typed filter key is kept in the rich label.

Base 21.0: the data-html attribute on the product option was introduced
in 21.0; on 20.0 the option carried only a class and select2 used the
plain option text where a quote is harmless. In develop the code was
reworked by PR #39057 which now escapes the whole value with
dol_escape_htmltag(), so this fix targets the maintained branches only.

Signed-off-by: Gregory Aliot <greg.aliot@gmail.com>
2026-07-10 19:42:17 +02:00
ATM-NicolasV
e26839247b
FIX: situation invoice mode setup uses a 3-value select instead of a yes/no toggle (#39098)
INVOICE_USE_SITUATION is a 3-state flag (0=off, 1=cumulative/legacy, 2=progressive;
see the comment in admin/invoice.php), but the situation setup page
(admin/invoice_situation.php) exposed it through a yes/no toggle. Through
ajax_constantonoff the toggle can only write 0 or 1 and deletes the constant when
turned off (dolibarr_del_const), so mode 2 could neither be selected nor preserved.

Replace the toggle with a 3-value select that writes the literal value via
dolibarr_set_const (FormSetup 'select' never calls dolibarr_del_const), with a
warning box explaining the two modes. INVOICE_USE_SITUATION_CREDIT_NOTE stays a
yes/no toggle (it is a genuine boolean).

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-10 17:24:07 +02:00
ThomasNgr-OpenDSI
d41fd4193b
FIX Odt generation : create missing temp directory (#39105) 2026-07-10 17:18:43 +02:00
lvessiller-opendsi
c49e834885
Merge pull request #38901 from Dolicraft/fix/37661-product-import-price-base-type-mandatory
Fix #37661 require price_base_type on product CSV import
2026-07-09 10:12:46 +02:00
lvessiller-opendsi
7cb02d0214
FIX #38958 - Supplier payment : multi-currency code/rate not saved on payment-invoice link when caller does not fill multicurrency arrays (#38972) 2026-07-09 09:25:30 +02:00
lvessiller-opendsi
2ab9bbf877
FIX #38959 - Supplier payment : multi-currency code/rate not saved on auto-created discount when a DEPOSIT supplier invoice is fully paid (#38973)
* FIX #38959 - Supplier payment : multi-currency code/rate not saved on auto-created discount when a DEPOSIT supplier invoice is fully paid

* Move set of multicurrency_code like in PR #38966 merged
2026-07-09 09:24:34 +02:00
w3houde
8992ce8704
Fix #38949 enforce takepos editlines permission on all line actions (#38999)
* Fix #38949 enforce takepos editlines permission on all line actions

addline, freezone, addnote, deleteline, updateqty, updateprice, updatereduction
and update_reduction_global all mutated the invoice content but only updateqty,
updateprice and updatereduction had a server-side editlines check. A user with
only takepos.run could therefore add free-text lines, change prices, delete
lines and apply discounts before payment, bypassing the editlines permission
that was supposed to gate exactly those operations. Refuse the request at the
top of the action dispatcher when editlines is missing. The editlines right
is enabled by default at module activation so existing setups are unaffected.

The editorderedlines per-line check kept by updateqty/updateprice/updatereduction
still applies after this gate, so the special_code = 4 override path is not
broken.

Signed-off-by: Dolicraft <contact@dolicraft.com>

* Fix #38949 move editlines guard after hook and use hasRight

Signed-off-by: Dolicraft <contact@dolicraft.com>

* Fix #38949 limit editlines guard to line-edit actions only

Adding a line, free zone or note stays under the run permission as in the
current stable branch, so a cashier without editlines can still ring up
sales. The guard now enforces editlines only on delete/qty/price/discount
actions, which is exactly what the report targets.

Signed-off-by: Dolicraft <contact@dolicraft.com>

---------

Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
2026-07-09 09:23:22 +02:00
ThomasNgr-OpenDSI
64ab2f006b
Fix sql injection in sqlfilters API param - reported by sangkilp (#38794) (#39070)
Switch four list endpoints that still used the legacy DolibarrApi::_checkFilters
+ bare preg_replace_callback path to the hardened forgeSQLFromUniversalSearchCriteria()
already used by the rest of the same files. The legacy path only validated
parenthesis balance and concatenated non-matching text verbatim into the WHERE
clause, while the hardened path applies the dummy-criteria syntax check first.

Endpoints touched:
- htdocs/api/class/api_setup.class.php getListOfRegions
- htdocs/api/class/api_setup.class.php getListOfIncoterms
- htdocs/api/class/api_setup.class.php getListOfVAT
- htdocs/multicurrency/class/api_multicurrencies.class.php index

See #38768 for the report.

Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: w3houde <clement@pixodeo.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
2026-07-09 09:20:16 +02:00
lvessiller-opendsi
96f5970729
Merge pull request #39077 from Dolicraft/fix/39063-user-note-idor-self-write
Fix #39063 enforce user write right on other users notes
2026-07-09 09:17:32 +02:00
Dolicraft
32d74594be Fix #39063 enforce user write right on other users notes
The note editor set $permissionnote from user->self->write only, so a user
holding user->user->read plus user->self->write (but not user->user->write)
could edit the public/private notes of any user, admins included: the
setnote actions are not in restrictedArea's write-check list, so
$permissionnote was the only remaining guard. It now requires user->user->write
to edit another user's notes, matching caneditfield in user/card.php.

Reported by Abderrahmane Aksoum.

Signed-off-by: Dolicraft <contact@dolicraft.com>
2026-07-07 23:19:58 +07:00
Laurent Destailleur
5bb3714ef7 Fix: use the same condition everywhere 2026-07-02 12:39:23 +02:00
reachsanjivbhagat-gif
dc2a01ff28
FIX #32909 Restrict salary/HR field edit to authorized users (#39033)
* FIX #32909 Restrict salary/HR field edit to authorized users

On the user card, a user with only "modify own info" (user->self->write)
could edit thm, tjm, salary, salaryextra and weeklyhours, even though the
display of these fields is gated on salaries->readall / hrm->employee->read.
Guard the write of these fields with the same permission used for display,
so self-service users can no longer change compensation data they are not
allowed to see.

Signed-off-by: Sanjiv Kumar Bhagat <reach.sanjiv.bhagat@gmail.com>

* Update card.php

* Update salary edit permissions logic

---------

Signed-off-by: Sanjiv Kumar Bhagat <reach.sanjiv.bhagat@gmail.com>
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2026-07-02 12:25:04 +02:00
w3houde
20b4edcf33
Fix #32407 translate prospection status libelle in dictionaries (#38923)
The dict.php renderer translated 'label' for some tables (c_units, c_product_nature,
c_productbatch_qcstatus) but left the 'libelle' column of c_stcomm and
c_stcommcontact as the raw English seed text. Map the row to its StatusProspect{id}
translation key when present so the French (or any other locale) shows the
expected label instead of 'Do not contact' / 'Never contacted' etc.

Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
2026-07-02 09:56:59 +02:00
lvessiller-opendsi
155a84d980
FIX #38957 - Supplier invoice : Multi-currency code/rate and amount not saved when converting EXCESS PAID, CREDIT_NOTE or DEPOSIT to discount (#38971)
* FIX #38957 - Supplier invoice :  Multi-currency code/rate and amount not saved when converting EXCESS PAID, CREDIT_NOTE or DEPOSIT to discount

* Add author
2026-07-02 09:53:10 +02:00
w3houde
9425b899f2
Fix #36238 keep supplier filter when sorting product list (#38915)
print_liste_field_titre signature is (name, file, field, begin, moreparam, ...)
but the seven calls in fourn/product/list.php passed $param at position 4
(begin) instead of 5 (moreparam), so the URL was rebuilt without the
fourn_id filter and the list reset when the user clicked a column header.
Swap to the correct slot, matching the fix already in the 22.0 line.

Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
2026-06-27 18:57:06 +02:00
w3houde
60db2cbfe4
Fix #34720 do not crash on duplicate bank_url link for same target (#38916)
* Fix #36238 keep supplier filter when sorting product list

print_liste_field_titre signature is (name, file, field, begin, moreparam, ...)
but the seven calls in fourn/product/list.php passed $param at position 4
(begin) instead of 5 (moreparam), so the URL was rebuilt without the
fourn_id filter and the list reset when the user clicked a column header.
Swap to the correct slot, matching the fix already in the 22.0 line.

Signed-off-by: Dolicraft <contact@dolicraft.com>

* Fix #34720 do not crash on duplicate bank_url link for same target

llx_bank_url has a UNIQUE key on (fk_bank, url_id, type) so dispatching two
distinct credit transfers for the same employee on the same bank line raised a
Duplicate entry crash that left the operation in an unfinished state. Pre-check
the row and reuse the existing rowid silently, keeping the historical link
without breaking the calling transaction.

Signed-off-by: Dolicraft <contact@dolicraft.com>

---------

Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
2026-06-27 18:28:39 +02:00
w3houde
429d3354e2
Fix #31471 translate CostPrice and PriceBaseType on import field list (#38922)
import.php loadLangs only loaded exports/compta/errors, so labels coming from
modProduct / modService import_fields_array that resolve to keys in
products.lang (PriceBaseType) and margins.lang (CostPrice) stayed in English
on a French install. Add 'products' and 'margins' to the loaded set so the
import field picker shows the translated label everywhere else the user sees
the product card.

Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
2026-06-27 18:24:32 +02:00
Laurent Destailleur
6e101143e0 Fix showunused option in sanity_check_trans_missing_unused.sh 2026-06-27 16:53:08 +02:00
ThomasNgr-OpenDSI
b726e3b853
SEC: Sanitize SQL query parameters (#38942) (#38955)
Sanitize SQL query parameters.
Replace urlencode with explicit type casting to int for fk_statut and signed_status parameters.

Co-authored-by: MDW <mdeweerd@users.noreply.github.com>
2026-06-23 20:45:50 +02:00
Eric - CAP-REL
95a5391732
fix adherent table name (#38873)
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2026-06-22 13:39:55 +02:00
Laurent Destailleur
47d72ce724 Automated merge from 20.0 to 21.0 by tool pullmerge.sh 2026-06-22 13:22:24 +02:00
Laurent Destailleur
998967c93a Automated merge from 19.0 to 20.0 by tool pullmerge.sh 2026-06-22 13:22:21 +02:00
Laurent Destailleur
50151e3ad3 Merge branch '19.0' of git@github.com:Dolibarr/dolibarr.git into 19.0 2026-06-22 13:04:36 +02:00
Laurent Destailleur
d713e62c26 Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into 19.0 2026-06-22 13:04:11 +02:00
Laurent Destailleur
9f6306bfeb Fix whitespace 2026-06-22 12:18:56 +02:00
atm-jonathan
058c2341ce
FIX : fix duplicate contact names in messaging timeline (#38855)
Cache key was using legacy fk_contact field instead of the current
contact id ($cid), causing all contacts after the first to resolve
to the same cached entry in show_actions_messaging().
2026-06-22 03:46:41 +02:00
MDW
957f117d09
SEC: Fix SQL injection vulnerability in contract list (#38941)
# SEC: Fix SQL injection vulnerability in contract list

- Update the SQL query to properly escape the search_signed_status parameter
2026-06-21 19:18:18 +02:00
MDW
edcde65dfc
SEC: Correct SQL escaping for signed_status (#38943)
* SEC: Correct SQL escaping for signed_status

# SEC: Correct SQL escaping for signed_status

Escape signed_status using $db->escape instead of urlencode.

* Update list.php

* Update list.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2026-06-21 16:52:51 +02:00
MDW
b5a8a01eae
SEC: Sanitize SQL query parameters (#38942)
# SEC: Sanitize SQL query parameters

Sanitize SQL query parameters.
Replace urlencode with explicit type casting to int for fk_statut and signed_status parameters.
2026-06-21 15:27:28 +02:00
Laurent Destailleur
e42d6883e5 ci 2026-06-21 15:26:05 +02:00
Dolicraft
b2927a68e0 Fix #37661 require price_base_type on product CSV import
The import_fields_array entry for p.price_base_type accepted a missing/empty
value because the CSV importer skips the regex check when newval is empty
(import_csv.modules.php:682). Marking the field as mandatory with the trailing
star forces the user to map a column and provide HT or TTC, so the row no
longer ends up with an empty/NULL value that breaks price displays.

Signed-off-by: Dolicraft <contact@dolicraft.com>
2026-06-19 09:42:53 +02:00
Laurent Destailleur
46f8d4434d Automated merge from 20.0 to 21.0 by tool pullmerge.sh 2026-06-19 04:01:49 +02:00
Eric - CAP-REL
d500b8ca62
fix adherent table name (#38872)
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2026-06-19 04:00:36 +02:00
Laurent Destailleur
d0091363b8 Fix regression. It was not possible to create an intervention on a
partner not customer.
2026-06-19 03:40:50 +02:00
Laurent Destailleur
f553ff53af Automated merge from 19.0 to 20.0 by tool pullmerge.sh 2026-06-19 03:34:30 +02:00
Laurent Destailleur
d7e92bcd50 Automated merge from 18.0 to 19.0 by tool pullmerge.sh 2026-06-19 03:34:19 +02:00
Laurent Destailleur
594129161d Automated merge from 17.0 to 18.0 by tool pullmerge.sh 2026-06-19 03:34:05 +02:00
Laurent Destailleur
50ceefb2a4 Automated merge from 16.0 to 17.0 by tool pullmerge.sh 2026-06-19 03:28:40 +02:00
Laurent Destailleur
6993c665bf Automated merge from 15.0 to 16.0 by tool pullmerge.sh 2026-06-19 03:28:31 +02:00
Laurent Destailleur
4b22126e44 Automated merge from 14.0 to 15.0 by tool pullmerge.sh 2026-06-19 03:28:24 +02:00
Laurent Destailleur
c72af785c9 Fix ci 2026-06-19 03:22:18 +02:00
Eric - CAP-REL
1b4ece48e2
fix adherent table name (#38871) 2026-06-19 03:19:40 +02:00
Pichinov-Jose
2653b1707a
FIX Multicurrency amount columns were hidden on discount screens (wrong module test) (#38825)
On the third party discount tabs (htdocs/comm/remx.php), the multicurrency amount columns
(MulticurrencyAmountHT / MulticurrencyAmountTTC) and their colspan adjustments were guarded by
isModEnabled('multicompany') instead of isModEnabled('multicurrency'). As a result the foreign
currency amounts of available and consumed discounts/down payments were never shown when the
Multicurrency module is enabled (and the Multi-company module disabled).

The wrong test was introduced in commit 3bb1a2387b (2022, 'FIX php8 compatibility') which converted
!empty($conf->multicurrency->enabled) into isModEnabled('multicompany'). Restore the correct module
test. Present from v17 to develop; fixed here on the oldest maintained LTS branch (18.0).
2026-06-18 09:55:17 +02:00