The POST /documents endpoint with generateThumbs=1 called
image_format_supported() after requiring only files.lib.php, but that
function is defined in images.lib.php, which was never included on this
path. The call raised a fatal error and the request returned a bare
HTTP 500 with no JSON body. Add the missing require_once.
Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
In theme md, the rule in btn.inc.php that gives action buttons their
bottom margin only lists direct children of div.tabsAction and children
of div.divButAction. Dropdown action buttons are not in that list.
dolGetButtonAction() renders a dropdown button as
<div class="dropdown inline-block dropdown-holder"><a class="dropdown-toggle ... butAction">,
so the anchor is a grandchild of div.tabsAction and matches none of the
existing selectors. It therefore gets no bottom margin.
When the action bar wraps onto more than one line and a line is made of
dropdown buttons, the rows have no vertical spacing at all and the
buttons visually touch each other.
Theme eldy already fixes this with the same selector
(div.tabsAction > .dropdown > .dropdown-toggle in theme/eldy/btn.inc.php);
theme md was never aligned. This adds the identical selector to md.
Measured with the compiled md stylesheet, six dropdown buttons wrapping
onto two rows: gap between rows 0px before, 22px after, which matches
the 1.4em the plain buttons already get. Layout of rows that mix plain
and dropdown buttons is unchanged.
Signed-off-by: Florian Hödl <florian@hoedl.co>
Co-authored-by: Florian Hödl <florian@hoedl.co>
Contrat::doAutoRenewContracts() instantiates ActionComm to log the
RENEW_CONTRACT event, but contrat.class.php never loads
comm/action/class/actioncomm.class.php.
From a web request the class is usually already loaded by some other
include, so the problem stays hidden. When the method is run as a
scheduled job it is not: scripts/cron/cron_run_jobs.php loads only
master.inc.php, functionscli.lib.php, cronjob.class.php and
user.class.php, and cronjob.class.php then loads only the job class
itself via dol_include_once($this->classesname). ActionComm is not part
of that include closure, so the method fails with
"Class ActionComm not found".
The fatal error happens after the UPDATE on llx_contratdet has been
issued but before $this->db->commit(), so the transaction is never
committed and the renewal is lost. The job also aborts, so every
remaining contract line in the loop is left unprocessed and the failure
is only visible as a fatal error in the log.
Verified on 23.0.3: after the cron bootstrap, class_exists('Contrat')
is true while class_exists('ActionComm') is false. Adding the include
next to the existing html.formmail.class.php include makes it true.
Signed-off-by: Florian Hödl <florian@hoedl.co>
Co-authored-by: Florian Hödl <florian@hoedl.co>
The "Check NIE T" branch compared the control character of the TIN to the
return value of preg_match() instead of using preg_match() as the condition:
if ($num[8] == preg_match('/^[T]{1}[A-Z0-9]{8}$/', $str)) {
Since execution only reaches that branch when the string already matched the
format, preg_match() always returns 1, so the test collapsed to
$num[8] == 1. A NIE of type T therefore validated only when its last
character was literally "1", and every other one was reported as -3
(invalid control key). Out of the 36 possible control characters, 35 were
wrongly rejected.
A NIE starting with T has no control key algorithm, so matching the
documented syntax is the only check to perform.
Also fill in and enable the testIsValidTinForES() unit test that was left
commented out with empty input strings.
Co-authored-by: Claude <noreply@anthropic.com>
* FIX: Show error when clone order fail
* Fix missing variable
* Fix foreach loop to reference correct object
Updated foreach loop to use the correct object reference for lines.
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
With the MySQL 8 default sql_mode (which includes ONLY_FULL_GROUP_BY),
the supplier invoices query of the treasury journal fails with
DB_ERROR_1055 ("Expression #5 of SELECT list is not in GROUP BY clause
and contains nonaggregated column 'pff.amount' which is not
functionally dependent on columns in GROUP BY clause"). Supplier
payments are then missing from the journal view and from the transfer
into the ledger, while customer invoices still pass, so a treasury
ledger is produced with revenues only and no supplier expense, with no
other signal than one error line in the transfer report.
This is the MySQL counterpart of PostgreSQL error 42803 fixed on
develop by #38910, then simplified by commit 42840b47a which removed
the GROUP BY of the three queries entirely: they contain no aggregate
function, and the fetch loops already deduplicate rows (isset() guards
on the object/payment keys and the already_sum check on the detail
line id), so the GROUP BY is useless. This backports that resolution,
with lines identical to develop so the upward merge stays clean.
Verified on a 23.0.2 instance on MySQL 8 with factory sql_mode: the
vanilla supplier query returns error 1055, the same query without
GROUP BY succeeds and returns the same rows, row for row, as the
exhaustive GROUP BY variant of #38910; the full year transfer produces
balanced pieces and a re-transfer creates no duplicate.
Signed-off-by: Gregory Aliot <greg.aliot@gmail.com>
Co-authored-by: Gregory Aliot <greg.aliot@gmail.com>
* FIX EmailCollector: DateTime/Carbon object passed as timestamp when MAIN_IMAP_USE_PHPIMAP is enabled
When using the PHPIMAP driver, $overview['date'] is a Carbon/DateTime object,
not an integer timestamp. Passing it to dol_print_date() silently produces
a wrong date under PHP 8 (object-to-int cast warning + result 1) instead of
throwing, since the intended value is masked without any visible error.
Also guard the two strtotime($headers['Date']) calls against a missing
Date header, which raised a PHP 8 deprecation notice.
Fixes#39376
* FIX Phan: suppress PhanUndeclaredMethod on Carbon::toDate() after narrowing $overview['date'] to DateTimeInterface
The new instanceof DateTimeInterface check for $overview['date'] made
Phan narrow its inferred type for the rest of the scope, so the existing
->toDate() call (a Carbon-only method, not part of DateTimeInterface)
now also triggers PhanUndeclaredMethod in addition to the already
suppressed PhanPluginUnknownObjectMethodCall.
$search_societe is a standalone variable used to filter on the joined
llx_societe.nom (fk_soc is not a plain field usable by the generic
$search[...] purge loop), so it was missing from the list of extra
variables reset by the "Remove filter" button.
Fixes#39374
* Update expedition.class.php
In Expedition::addline_batch() (expedition.class.php:1284), the creation form submits all batch lines (even those with qty=0), because SHIPMENT_GETS_ALL_ORDER_PRODUCTS=1 forces their inclusion ($value['q'] == 0 && ...SHIPMENT_GETS_ALL_ORDER_PRODUCTS, line 1295). For each line included, the STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT control compared $prod_batch->qty < $linebatch->qty without verifying that $linebatch->qty (the actual quantity requested for this batch) is greater than 0.
Result: For the line in batch "azerty" (requested quantity = 0, stock = -10), the -10 < 0 test is true → the entire shipment is rejected with "insufficient stock," even though the batch actually chosen ("azerty123456789", requested quantity = 2, stock = 5) is more than sufficient.
* Update expedition.class.php
---------
Co-authored-by: Sylvain Legrand <sylvain.legrand@infras.fr>
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
In CommandeFournisseur::create(), the line insertion loop accepts lines provided as arrays, cast to stdClass on the fly (fournisseur.commande.class.php:1687-1689). When a cast line does not contain all the expected properties, the call to addline() reads 13 properties without guards, hence the repeated PHP Warning: Undefined property: stdClass::$...
Co-authored-by: Sylvain Legrand <sylvain.legrand@infras.fr>
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
commonobject.class.php:9398 — Undefined array key "options_pos": direct access to $this->array_options[$ef_name] without checking its existence → added an isset() with fallback to an empty string.
commonobject.class.php:9767 (getRights() method) — Undefined property: stdClass::$shipping: $user->rights->$element accessed without checking that the module has registered this property (e.g., shipping module not active for this user) → added an isset(), returns null otherwise.
html.form.class.php:6088-6091 — Undefined array key "value": the $input array passed to formconfirm/multiSelect may not contain a value key for a checkbox field → added an isset($input['value']) on both conditions.
html.form.class.php:6752 (method form_modes_reglement()) — Undefined array key 2 / access on null: $selected corresponds to a payment method not in the cache cache_types_paiements → add an isset().
supplier_proposal/index.php:362 — Undefined property: stdClass::$dfv: the SQL query in the block (line 316) does not select the field fin_validite/dfv (unlike comm/propal/index.php which selects p.fin_validite as dfv) — this field does not even exist in llx_supplier_proposal. In addition to the warning, this bug systematically displayed the "Delay" icon (PHP8 comparison '' < number always true) → addition of an isset($obj->dfv) which properly neutralizes the test as long as this field is not returned by the request.
Co-authored-by: Sylvain Legrand <sylvain.legrand@infras.fr>
get_default_tva() VATRULE 2 selects the VAT rate attached to the buyer
department (c_tva.fk_department_buyer) but filters only on the department id.
Unlike get_product_vat_for_country(), it omits t.active and t.entity, so a
disabled rate (or a rate from another entity) can be returned as the default,
and because of the taux DESC ordering an inactive higher rate wins over the
active one.
Add "AND t.active > 0" and "AND t.entity IN (getEntity('c_tva'))" to the query.
The ordering is unchanged, so the documented behaviour is preserved: the rate
flagged Default (use_default) wins, otherwise the highest active rate.
Add testGetDefaultTvaForBuyerState() covering VATRULE 2, which was previously
untested: it asserts the active department rate is selected and the inactive
one is ignored.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* fix date start and date end in massaction
* PR returns : change comment langs and restore comment mandatroty for travis
* Clarify permission check for date change action
Updated comment to clarify that permission check is not required for date change action.
* FIX : keep inline permission comment on changedateend action test
---------
Co-authored-by: atm-nicolasV <nicolas.vidal@atm-consulting.fr>
Co-authored-by: ATM-NicolasV <92087862+ATM-NicolasV@users.noreply.github.com>
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
* Update SQL queries to use getEntity for entity filtering
* Update file path handling for ficheinter module
* Refactor output directory handling in card.php
When creating the next situation invoice, the create-form extrafields were
saved AFTER createFromCurrent() had already fired BILL_CREATE, so triggers
listening to BILL_CREATE never saw them. Passing 'BILL_CREATE' to
insertExtraFields() (as first proposed) would fire the trigger a second time.
Instead, set the extrafields on $object before createFromCurrent() and let
create() insert them and fire BILL_CREATE once with the values present.
createFromCurrent() now skips its fetch_optionals() when array_options is
already set by the caller, so the form values are no longer overwritten by
the source invoice values. The two other createFromCurrent() callers do not
pre-set array_options, so their behaviour is unchanged.
Supersedes #32217.
Signed-off-by: Jam Balaya <jambalaya.pyoncafe@outlook.jp>
The "Unit" column of the consume/produce tables used
measuringUnitString(..., 2), which translates a <Label>Short key. Those
keys do not exist for most units (e.g. a Piece -> 'UnitPShort', kg ->
'WeightUnitkgShort'), so the raw untranslated key was displayed. Use
param 1 (the very-short DB short_label: 'p', 'kg', ...) like every other
unit column in this file and across the codebase.
Supersedes #31706.
Signed-off-by: Jam Balaya <jambalaya.pyoncafe@outlook.jp>
When the multicompany module is enabled, checkUserAccessToObject() (used
by restrictedArea(), e.g. from an ajax tooltip) ran the entity check
unconditionally in its default/custom-object branch, building
"AND dbt.entity IN (...)". For a custom object whose table has no entity
column (ismultientitymanaged = 0), that SQL fails, nb comes back 0 and
access is wrongly denied.
Guard the branch so the entity test only runs when the object is actually
multi-entity managed. Keep the test for legacy classes that never define
ismultientitymanaged (null/unset) and for a non-object $object, and skip
it only when a class explicitly sets ismultientitymanaged = 0.
Supersedes the stale #34667 (by @jyhere) and applies the condition
requested by @eldy in its review.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
CommonObject::isInt() decides whether a list-page column gets numeric
search mode and is also used when resolving $this->id. The regex
/(^int|int$)/ missed sized integer types such as tinyint(4) and
bigint(20): they neither start nor end with "int".
These types are not exotic: tinyint(4) is used in several core $fields
definitions (societe, contact, entrepot, companypaymentmode, ...) and
ModuleBuilder-generated tables use bigint(20) for rowid, so isInt()
should recognise them rather than requiring callers to change the
column type.
The new regex /^(?:tiny|small|medium|big)?int|int$/ also handles
smallint/mediumint with a size. Anchoring is preserved on purpose so
that strings which merely contain "int" (e.g. sellist:Table:...) are
still NOT matched, while the Dolibarr foreign-key syntax
"integer:Class:path" keeps being detected.
Signed-off-by: Jam Balaya <jambalaya.pyoncafe@outlook.jp>
* Sec: sql injection via api in POST of thirdparties/id/banckaccount - reported by MDnyn
* Sec: sql injection via api in POST of thirdparties/id/banckaccount -
reported by MDnyn
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
* FIX#39190 wrong unit price when invoicing time spent with one line per declaration
In projet/tasks/time.php, the 'onelineperperiod' mode (invoice generation option
"One line for each time spent declaration") computed the unit price as
$pu_ht = price2num($value['totalvaluetodivideby3600'] / 3600, 'MU');
but totalvaluetodivideby3600 is timespent_duration (seconds) * timespent_thm
(hourly rate), so dividing by 3600 yields "hours * hourly rate", which is the line
total and not a unit price. The quantity passed to addline() is the number of hours,
so the line was billed hours * (hours * rate) instead of hours * rate: the time is
over-billed by a factor equal to the number of hours.
The sibling modes are already correct: 'onelineperuser' and 'onelinepertask' divide
by the recorded number of seconds. Up to 16.0 'onelineperuser' had the same /3600
expression; it was fixed there and 'onelineperperiod' was left behind. Align it with
that reference implementation, including the same guard against a zero duration.
Also reset $pu_ht for each generated line. $pu_ht is initialized once before the loops
(with the price of the selected product/service, or 0) and this mode only had an
"if (empty($pu_ht))" test, so once a price was computed for the first line every
following line reused it, and lines of users with a different hourly rate got the rate
of the first line. The base price is saved before the loop and restored on each
iteration, so the product/service price path is preserved.
* Rename variable for clarity in time.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
* Fix#39020 avoid duplicate MO when BOM has a sub-BOM
When generating child MOs from a BOM with a sub-BOM line, the lookup of
the parent MO consume line used a substring filter
(origin_id LIKE '%id%') that was not scoped to the parent MO. It could
match an unrelated mrp_production row or none at all. When it matched
none, the child MO was still created from the leftover parent POST data,
producing a second MO identical to the parent instead of a real child.
Scope the lookup to the parent MO with an exact match on origin_id and
origin_type via customsql, and skip the iteration when no matching
consume line is found so no duplicate parent MO can be created.
Signed-off-by: Dolicraft <contact@dolicraft.com>
* Fix#39020 use exact-match filter keys instead of customsql per review
Add exact-match handling for fk_mo, origin_id and origin_type in
MoLine::fetchAll and call it with those keys instead of a customsql
clause, so the lookup stays valid on 18.0/19.0 where customsql would be
the only alternative to the buggy LIKE. The universal-search filter form
is handled separately on 20.0 and later.
Signed-off-by: Dolicraft <contact@dolicraft.com>
---------
Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
Typo $elementype vs $elementtype: extrafields were fetched for socpeople
but read under the stale key societe, so the contact extrafields section
rendered empty.
In compta/resultat/result.php and clientfourn.php the account number was cast to
(int) before being passed to AccountancyCategory::getSumDebitCredit(), which
compares it as a string (t.numero_compte = '...'). (int) '0510' -> 510 -> '510'
never matches the stored '0510' (numero_compte and account_number are varchar(32),
so leading zeros are significant). Accounts whose code starts with 0 were therefore
silently excluded from the current-year and per-month totals of a personalized
account group, while the previous-year column was already correct because it passes
a string array.
The (int) cast had no functional purpose: it was added to silence a phan notice in
"Qual: Fix phan notices" (#33484). Remove it and pass the raw string, and widen the
getSumDebitCredit() @param to string|int|array<?string> so the string argument is
accepted by static analysis and the cast is not reintroduced. Numeric codes are
unaffected (the callee already casts the scalar with (string)).
In a January that starts with week 52 or 53 of the previous year (for
example January 2022), getFirstDayOfEachWeek() wrongly shifted week 01
to the next year, and the $year++ inside the loop then also corrupted
all the following weeks of the month: every first day returned was the
one of the next year (02, 09, 16, 23, 30 instead of 03, 10, 17, 24, 31
for January 2022). getLastDayOfEachWeek() had no year handling at all,
so the trailing/leading weeks of the other year were resolved in the
wrong year too.
This made the per-month time spent view (projet/activity/permonth.php)
display wrong week date ranges, link to the wrong week and compute the
weekly holiday overlap on wrong date ranges for such months.
Co-authored-by: Claude <noreply@anthropic.com>
The day loop of num_public_holiday() advanced with
dol_time_plus_duree($timestampStart, 1, 'd'). On 21.0 and 22.0 that
function only forces UTC when MAIN_DATE_IN_MEMORY_ARE_GMT is set, so by
default it adds a wall-clock day in the server timezone. When the range
crosses a DST boundary (last Sunday of March in Europe), the GMT
timestamp advances by only 23 hours, the same GMT day is evaluated
twice, one day is counted as holiday twice and the working day after
the boundary is never examined.
For a leave request from Sat 28/03/2026 to Mon 30/03/2026 with a server
in Europe/Paris: 3 days between, 3 holidays counted (Sunday twice),
0 working days instead of 1.
Advance by exactly 86400 seconds instead. Inputs of this function are
GMT dates (enforced by the modulo check at the top of the function), so
a GMT day is always exactly 86400 seconds, in every timezone and conf.
This matches the behaviour that 23.0 and develop get by default since
dol_time_plus_duree() switched to UTC by default there.
Signed-off-by: Gregory Aliot <greg.aliot@gmail.com>
Co-authored-by: Gregory Aliot <greg.aliot@gmail.com>