Extrafield labels are stored HTML encoded in llx_extrafields.label
because they are saved through Translate::trans(), which runs the
string through htmlentities(). write_title() wrote the label as-is,
so the CSV header line showed raw entities (Données instead of
Données) while the data cells were fine. With a ; separator the
trailing ; of each entity also wrapped the label in double quotes.
Decode entities and remove HTML with dol_string_nohtmltag() before
csvClean(), consistent with the TSV and Excel export drivers. For the
derived _label column of Select extrafields, append the suffix before
csvClean() so the column stays valid CSV when the decoded label
contains the separator or a quote.
Signed-off-by: Gregory Aliot <greg.aliot@gmail.com>
Co-authored-by: Gregory Aliot <greg.aliot@gmail.com>
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>
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>
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>
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>
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>
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>
* 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
* 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>
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>
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>
* 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>
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>
* FIX#38957 - Supplier invoice : Multi-currency code/rate and amount not saved when converting EXCESS PAID, CREDIT_NOTE or DEPOSIT to discount
* Add author
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>
* 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>
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>
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>
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().
# SEC: Sanitize SQL query parameters
Sanitize SQL query parameters.
Replace urlencode with explicit type casting to int for fk_statut and signed_status parameters.
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>