Automated merge from 22.0 to 23.0 by tool pullmerge.sh

This commit is contained in:
Laurent Destailleur 2026-06-09 00:11:42 +02:00
commit e1eb9de6ef
26 changed files with 251 additions and 76 deletions

View file

@ -79,10 +79,10 @@ if (GETPOST('cancel', 'alpha')) {
if ($action == 'add' /* && $user->hasRight('accounting', 'chartofaccount') // already checked */) {
if (!$cancel) {
if (!$account_number) {
if ((string) $account_number === '') {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountNumber")), null, 'errors');
$action = 'create';
} elseif (!$label) {
} elseif ((string) $label === '') {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
$action = 'create';
} else {
@ -134,10 +134,10 @@ if ($action == 'add' /* && $user->hasRight('accounting', 'chartofaccount') // al
}
} elseif ($action == 'edit' /* && $user->hasRight('accounting', 'chartofaccount') // already checked */) {
if (!$cancel) {
if (!$account_number) {
if ((string) $account_number === '') {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountNumber")), null, 'errors');
$action = 'update';
} elseif (!$label) {
} elseif ((string) $label === '') {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
$action = 'update';
} else {

View file

@ -360,11 +360,22 @@ if (empty($reshook)) {
$nbcreated = 0;
$now = dol_now();
$amount = price2num(GETPOST('amount', 'alpha'));
// Honour MEMBER_SUBSCRIPTION_SUGGEST_END_OF_MONTH and
// MEMBER_SUBSCRIPTION_SUGGEST_END_OF_YEAR the same way as the
// single subscription form (adherents/subscription.php), otherwise
// the mass action falls back to a one-year duration in
// Adherent::subscription() and ignores the global setting.
$datesubend = 0;
if (getDolGlobalInt('MEMBER_SUBSCRIPTION_SUGGEST_END_OF_MONTH')) {
$datesubend = dol_get_last_day((int) dol_print_date($now, "%Y"), (int) dol_print_date($now, "%m"));
} elseif (getDolGlobalInt('MEMBER_SUBSCRIPTION_SUGGEST_END_OF_YEAR')) {
$datesubend = dol_get_last_day((int) dol_print_date($now, "%Y"));
}
$db->begin();
foreach ($toselect as $id) {
$res = $tmpmember->fetch($id);
if ($res > 0) {
$result = $tmpmember->subscription($now, (float) $amount);
$result = $tmpmember->subscription($now, (float) $amount, 0, '', '', '', '', '', $datesubend);
if ($result < 0) {
$error++;
} else {

View file

@ -29,6 +29,15 @@
use Luracast\Restler\Format\UploadFormat;
// API endpoints return JSON (or XML). A stray PHP warning or notice in the
// response body corrupts the parser on the caller side. Silence the display
// of PHP messages here while keeping them in the server log so that the
// problem is still observable to the operator (filefunc.inc.php only does
// this when dolibarr_main_prod is set, which leaves development setups
// emitting HTML into every API answer).
@ini_set('display_errors', '0');
@ini_set('log_errors', '1');
if (!defined('NOCSRFCHECK')) {
define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test
}

View file

@ -803,6 +803,10 @@ if (isModEnabled('project')) {
$formproject = new FormProjets($db);
}
// Same check as the email templates editor in admin/mails_templates.php so the
// local media browser is shown consistently in both places.
$acceptlocallinktomedia = (acceptLocalLinktoMedia() > 0 ? 1 : 0);
$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing';
llxHeader(
'',
@ -959,7 +963,7 @@ if ($action == 'create') { // aaa
print '<div style="padding-top: 10px">';
// wysiwyg editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('bodyemail', GETPOST('bodyemail', 'restricthtmlallowunvalid'), '', 600, 'dolibarr_mailings', '', true, -1, getDolGlobalInt('FCKEDITOR_ENABLE_MAILING'), 20, '100%');
$doleditor = new DolEditor('bodyemail', GETPOST('bodyemail', 'restricthtmlallowunvalid'), '', 600, 'dolibarr_mailings', '', true, $acceptlocallinktomedia, getDolGlobalInt('FCKEDITOR_ENABLE_MAILING'), 20, '100%');
$doleditor->Create();
print '</div>';
@ -1432,7 +1436,7 @@ if ($action == 'create') { // aaa
$readonly = 1;
// wysiwyg editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', false, -1, getDolGlobalInt('FCKEDITOR_ENABLE_MAILING'), 20, '100%', $readonly);
$doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', false, $acceptlocallinktomedia, getDolGlobalInt('FCKEDITOR_ENABLE_MAILING'), 20, '100%', $readonly);
$doleditor->Create();
} else {
print dol_htmlentitiesbr($object->body);
@ -1712,19 +1716,19 @@ if ($action == 'create') { // aaa
$object->body = '<div style="background-color: #'.$object->bgcolor.'; margin-bottom:-20px; margin-left:-10px; margin-right:-10px; margin-top:-10px; padding: 10px;">'.$object->body.'</div>';
}
}
$doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, -1, getDolGlobalInt('FCKEDITOR_ENABLE_MAILING'), 20, '100%');
$doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, $acceptlocallinktomedia, getDolGlobalInt('FCKEDITOR_ENABLE_MAILING'), 20, '100%');
$doleditor->Create();
}
if ($action == 'edittxt') {
// wysiwyg editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, -1, 0, 20, '100%');
$doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, $acceptlocallinktomedia, 0, 20, '100%');
$doleditor->Create();
}
if ($action == 'edithtml') {
// HTML source editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, -1, 'ace', 20, '100%');
$doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, $acceptlocallinktomedia, 'ace', 20, '100%');
$doleditor->Create(0, '', false, 'HTML Source', 'php');
}

View file

@ -373,6 +373,10 @@ if (empty($reshook)) {
$result = $object->closeProposal($user, $object::STATUS_SIGNED);
}
if ($result >= 0) {
$ret = $object->fetch($id); // Reload to get new records
if ($ret > 0) {
$object->fetch_thirdparty();
}
if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
$outputlangs = $langs;
$newlang = '';
@ -387,10 +391,6 @@ if (empty($reshook)) {
$outputlangs->setDefaultLang($newlang);
}
$model = $object->model_pdf;
$ret = $object->fetch($id); // Reload to get new records
if ($ret > 0) {
$object->fetch_thirdparty();
}
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

View file

@ -2743,10 +2743,16 @@ class Propal extends CommonObject
$this->db->commit();
return 1;
} else {
$this->statut = $this->oldcopy->status; // deprecated
$this->status = $this->oldcopy->status;
$this->date_signature = $this->oldcopy->date_signature;
$this->note_private = $this->oldcopy->note_private;
foreach ($this->errors as $errmsg) {
dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
if (!empty($this->oldcopy)) {
$this->statut = $this->oldcopy->status; // deprecated
$this->status = $this->oldcopy->status;
$this->date_signature = $this->oldcopy->date_signature;
$this->note_private = $this->oldcopy->note_private;
}
$this->db->rollback();
return -1;

View file

@ -20,6 +20,7 @@
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2025 Lenin Rivas <lenin.rivas777@gmail.com>
* Copyright (C) 2026 Joachim Küter <git-jk@bloxera.com>
*
* 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
@ -250,7 +251,7 @@ if (empty($reshook)) {
$objectutil->date = dol_mktime(12, 0, 0, GETPOSTINT('newdatemonth'), GETPOSTINT('newdateday'), GETPOSTINT('newdateyear'));
$objectutil->socid = $socid;
$result = $objectutil->createFromClone($user, $id);
$result = $objectutil->createFromClone($user, $id, (GETPOSTISSET('entity') ? GETPOSTINT('entity') : null));
if ($result > 0) {
$warningMsgLineList = array();
// check all product lines are to sell otherwise add a warning message for each product line is not to sell
@ -5492,15 +5493,23 @@ if ($action == 'create') {
print '</tr>';
if (getDolGlobalString('INVOICE_POINTOFTAX_DATE')) {
// Date invoice point of tax
// Date invoice point of tax (Leistungsdatum / service date for tax).
// Only editable while the invoice is a draft — once validated, the
// invoice is a legally issued document and date_pointoftax is the
// basis for the VAT-return period assignment under accrual taxation
// (Soll-Versteuerung). To correct, set the invoice back to draft or
// issue a credit note.
$editable = ($usercancreate && $object->status < Facture::STATUS_VALIDATED);
print '<tr><td>';
print '<table class="nobordernopadding centpercent"><tr><td>';
print $langs->trans('DatePointOfTax');
print '</td>';
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate_pointoftax&token='.newToken().'&facid='.$object->id.'">'.img_edit($langs->trans('SetDate'), 1).'</a></td>';
if ($editable) {
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate_pointoftax&token='.newToken().'&facid='.$object->id.'">'.img_edit($langs->trans('SetDate'), 1).'</a></td>';
}
print '</tr></table>';
print '</td><td>';
if ($action == 'editdate_pointoftax') {
if ($action == 'editdate_pointoftax' && $editable) {
$form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->date_pointoftax, 'date_pointoftax');
} else {
print '<span class="valuedate">'.dol_print_date($object->date_pointoftax, 'day').'</span>';

View file

@ -1269,9 +1269,10 @@ class Facture extends CommonInvoice
*
* @param User $user User that clone
* @param int $fromid Id of object to clone
* @param int $forceentity Entity id to force (used by multicompany to clone into another entity)
* @return int New id of clone
*/
public function createFromClone(User $user, $fromid = 0)
public function createFromClone(User $user, $fromid = 0, $forceentity = null)
{
global $conf, $hookmanager;
@ -1301,6 +1302,8 @@ class Facture extends CommonInvoice
// TODO Change product price if multi-prices
}
$object->entity = (!empty($forceentity) ? $forceentity : $object->entity);
$object->id = 0;
$object->statut = self::STATUS_DRAFT;
$object->status = self::STATUS_DRAFT;
@ -1800,6 +1803,10 @@ class Facture extends CommonInvoice
$amountdeposit = array();
$descriptions = array();
// Bucket lines by tva_tx + vat_src_code so addline below receives the rate in
// the "tva (CODE)" format that Facture::addline knows how to parse. Bucketing
// on tva_tx alone wipes out the dictionary Code on the generated deposit line
// and on every downstream document derived from it (see issue #38035).
if (getDolGlobalString('MAIN_DEPOSIT_MULTI_TVA')) {
$amount = $origin->total_ttc * ($origin->deposit_percent / 100);
@ -1808,7 +1815,7 @@ class Facture extends CommonInvoice
if (!empty($line->special_code)) {
continue;
}
$key = $line->tva_tx;
$key = $line->tva_tx . ($line->vat_src_code ? ' ('.$line->vat_src_code.')' : '');
if (!array_key_exists($key, $TTotalByTva)) {
$TTotalByTva[$key] = 0;
$descriptions[$key] = '';
@ -1821,10 +1828,11 @@ class Facture extends CommonInvoice
}
foreach ($TTotalByTva as $tva => &$total) {
$tva_rate_only = preg_replace('/\s*\(.*\)/', '', (string) $tva);
$coef = $total / $origin->total_ttc; // Calc coef
$am = $amount * $coef;
$amount_ttc_diff += $am;
$amountdeposit[$tva] += $am / (1 + $tva / 100); // Convert into HT for the addline
$amountdeposit[$tva] += $am / (1 + ((float) $tva_rate_only) / 100); // Convert into HT for the addline
}
} else {
$totalamount = 0;
@ -1839,19 +1847,23 @@ class Facture extends CommonInvoice
}
$totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ?
$tva_tx = $lines[$i]->tva_tx;
$amountdeposit[$tva_tx] += ((float) $lines[$i]->total_ht * (float) $origin->deposit_percent) / 100;
$descriptions[$tva_tx] .= '<li>' . (!empty($lines[$i]->product_ref) ? $lines[$i]->product_ref . ' - ' : '');
$descriptions[$tva_tx] .= (!empty($lines[$i]->product_label) ? $lines[$i]->product_label . ' - ' : '');
$descriptions[$tva_tx] .= $langs->trans('Qty') . ' : ' . $lines[$i]->qty;
$descriptions[$tva_tx] .= ' - ' . $langs->trans('TotalHT') . ' : ' . price($lines[$i]->total_ht) . '</li>';
$tva_key = $lines[$i]->tva_tx . ($lines[$i]->vat_src_code ? ' ('.$lines[$i]->vat_src_code.')' : '');
if (!isset($amountdeposit[$tva_key])) {
$amountdeposit[$tva_key] = 0;
$descriptions[$tva_key] = '';
}
$amountdeposit[$tva_key] += ((float) $lines[$i]->total_ht * (float) $origin->deposit_percent) / 100;
$descriptions[$tva_key] .= '<li>' . (!empty($lines[$i]->product_ref) ? $lines[$i]->product_ref . ' - ' : '');
$descriptions[$tva_key] .= (!empty($lines[$i]->product_label) ? $lines[$i]->product_label . ' - ' : '');
$descriptions[$tva_key] .= $langs->trans('Qty') . ' : ' . $lines[$i]->qty;
$descriptions[$tva_key] .= ' - ' . $langs->trans('TotalHT') . ' : ' . price($lines[$i]->total_ht) . '</li>';
}
if ($totalamount == 0) {
$amountdeposit[0] = 0;
}
$amount_ttc_diff = $amountdeposit[0];
$amount_ttc_diff = $amountdeposit[0] ?? 0;
}
foreach ($amountdeposit as $tva => $amount) {
@ -1907,6 +1919,9 @@ class Facture extends CommonInvoice
$deposit->fetch_lines();
$subprice_diff = $deposit->lines[0]->subprice - $diff / (1 + $deposit->lines[0]->tva_tx / 100);
// Pass tva_tx in the "rate (CODE)" form so updateline preserves the vat_src_code
// it received from addline; passing the bare rate would wipe the code.
$tva_tx_with_code = $deposit->lines[0]->tva_tx . ($deposit->lines[0]->vat_src_code ? ' ('.$deposit->lines[0]->vat_src_code.')' : '');
$updatelineResult = $deposit->updateline(
$deposit->lines[0]->id,
$deposit->lines[0]->desc,
@ -1915,7 +1930,7 @@ class Facture extends CommonInvoice
$deposit->lines[0]->remise_percent,
$deposit->lines[0]->date_start,
$deposit->lines[0]->date_end,
$deposit->lines[0]->tva_tx,
$tva_tx_with_code,
0,
0,
'HT',

View file

@ -173,6 +173,9 @@ if ($action == 'add' && !empty($permissiontoadd)) {
if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') {
$value = ''; // This is an explicit foreign key field
}
if (preg_match('/^sellist:/i', $object->fields[$key]['type']) && $value == '0') {
$value = ''; // sellist blank option posts "0"; normalize to '' so notnull check works on PHP 8.0+ (see github.com/Dolibarr/dolibarr/issues/38199)
}
//var_dump($key.' '.$value.' '.$object->fields[$key]['type'].' '.$object->fields[$key]['notnull']);
@ -335,6 +338,9 @@ if ($action == 'update' && !empty($permissiontoadd)) {
if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') {
$value = ''; // This is an explicit foreign key field
}
if (preg_match('/^sellist:/i', $object->fields[$key]['type']) && $value == '0') {
$value = ''; // sellist blank option posts "0"; normalize to '' so notnull check works on PHP 8.0+ (see github.com/Dolibarr/dolibarr/issues/38199)
}
$object->$key = $value;

View file

@ -208,7 +208,13 @@ class CUnits extends CommonDict
$this->code = $obj->code;
$this->label = $obj->label;
$this->short_label = $obj->short_label;
$this->scale = $obj->scale ? (int) $obj->scale : null;
// Preserve scale=0 (e.g. the kg row). A truthy test on $obj->scale would
// collapse the legitimate scale of "0" into null and, downstream, the
// "weight unit" dropdown comparison in selectMeasuringUnits would no
// longer match the stored value under PHP 8 strict numeric-string
// rules, silently switching saved products to the first option (see
// issue #38497).
$this->scale = isset($obj->scale) ? (int) $obj->scale : null;
$this->unit_type = $obj->unit_type;
$this->active = (int) $obj->active;
}
@ -302,7 +308,8 @@ class CUnits extends CommonDict
$record->label = $obj->label;
$record->short_label = $obj->short_label;
$record->unit_type = $obj->unit_type;
$record->scale = $obj->scale ? (int) $obj->scale : null;
// Same scale-preservation as in fetch(): see issue #38497.
$record->scale = isset($obj->scale) ? (int) $obj->scale : null;
$record->active = (int) $obj->active;
$this->records[$record->id] = $record;

View file

@ -488,7 +488,10 @@ class Form
}
$extralanguages->fetch_name_extralanguages('societe');
if (!is_array($extralanguages->attributes[$object->element]) || empty($extralanguages->attributes[$object->element][$fieldname])) {
// ExtraLanguages::fetch_name_extralanguages() leaves $this->attributes empty
// when MAIN_USE_ALTERNATE_TRANSLATION_FOR is not configured, so PHP 8 raises
// 'Undefined array key' on the read below if we do not guard it (issue #34596).
if (empty($extralanguages->attributes[$object->element]) || !is_array($extralanguages->attributes[$object->element]) || empty($extralanguages->attributes[$object->element][$fieldname])) {
return ''; // No extralang field to show
}
@ -10998,7 +11001,9 @@ class Form
}
$extralanguages->fetch_name_extralanguages('societe');
if (!empty($extralanguages->attributes['societe']['name'])) {
// Guard against PHP 8 'Undefined array key' when MAIN_USE_ALTERNATE_TRANSLATION_FOR
// is not configured and fetch_name_extralanguages() leaves attributes empty (issue #34596).
if (!empty($extralanguages->attributes['societe']) && !empty($extralanguages->attributes['societe']['name'])) {
$object->fetchValuesForExtraLanguages();
$htmltext = '';

View file

@ -1042,7 +1042,7 @@ class FormMail extends Form
$defaultlines = $arraydefaultmessage->content_lines;
if (isset($defaultlines)) {
foreach ($this->substit_lines as $lineid => $substit_line) {
$lines .= make_substitutions($defaultlines, $substit_line)."\n";
$lines .= make_substitutions($defaultlines, $substit_line, $outputlangs)."\n";
}
}
$this->substit['__LINES__'] = $lines;
@ -1087,7 +1087,10 @@ class FormMail extends Form
if (GETPOSTISSET("message") && !GETPOST('modelselected')) {
$defaultmessage = GETPOST("message", "restricthtml");
} else {
$defaultmessage = make_substitutions($defaultmessage, $this->substit);
// Pass $outputlangs so __(TranslationKey)__ in the template body is resolved
// in the language of the selected email template, not the operator's language
// (see issue #34540).
$defaultmessage = make_substitutions($defaultmessage, $this->substit, $outputlangs);
// Clean first \n and br (to avoid empty line when CONTACTCIVNAME is empty)
$defaultmessage = preg_replace("/^(<br>)+/", "", $defaultmessage);
$defaultmessage = preg_replace("/^\n+/", "", $defaultmessage);
@ -1468,7 +1471,7 @@ class FormMail extends Form
*/
public function getHtmlForTopic($arraydefaultmessage, $helpforsubstitution)
{
global $langs, $form;
global $conf, $langs, $form;
$defaulttopic = GETPOST('subject', 'restricthtml');
@ -1480,7 +1483,17 @@ class FormMail extends Form
}
}
$defaulttopic = make_substitutions($defaulttopic, $this->substit);
// Resolve __(TranslationKey)__ in the language of the selected template
// (see issue #34540). Falls back to the caller's language when the template
// has no explicit language pinned.
$outputlangs = $langs;
if (is_object($arraydefaultmessage) && !empty($arraydefaultmessage->lang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($arraydefaultmessage->lang);
$outputlangs->load('other');
}
$defaulttopic = make_substitutions($defaulttopic, $this->substit, $outputlangs);
$out = '<tr>';
$out .= '<td class="fieldrequired">';

View file

@ -825,26 +825,26 @@ class Notify
case 'FICHINTER_ADD_CONTACT':
$link = '<a href="'.$urlwithroot.'/fichinter/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
$dir_output = $conf->ficheinter->dir_output;
$object_type = 'ficheinter';
$object_type = 'fichinter';
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionAddedContact", $link);
break;
case 'FICHINTER_VALIDATE':
$link = '<a href="'.$urlwithroot.'/fichinter/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
$dir_output = $conf->ficheinter->dir_output;
$object_type = 'ficheinter';
$object_type = 'fichinter';
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionValidated", $link);
break;
case 'FICHINTER_MODIFY':
$link = '<a href="'.$urlwithroot.'/fichinter/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
$context_info = array_key_exists('signature', $object->context) ? $object->getLibSignedStatus() : '';
$dir_output = $conf->ficheinter->dir_output;
$object_type = 'ficheinter';
$object_type = 'fichinter';
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionModified", $link, $context_info);
break;
case 'FICHINTER_CLOSE':
$link = '<a href="'.$urlwithroot.'/fichinter/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
$dir_output = $conf->ficheinter->dir_output;
$object_type = 'ficheinter';
$object_type = 'fichinter';
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionClosed", $link);
break;
case 'ORDER_SUPPLIER_VALIDATE':
@ -1150,26 +1150,26 @@ class Notify
case 'FICHINTER_ADD_CONTACT':
$link = '<a href="'.$urlwithroot.'/fichinter/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
$dir_output = $conf->ficheinter->dir_output;
$object_type = 'ficheinter';
$object_type = 'fichinter';
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionAddedContact", $link);
break;
case 'FICHINTER_VALIDATE':
$link = '<a href="'.$urlwithroot.'/fichinter/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
$dir_output = $conf->facture->dir_output;
$object_type = 'ficheinter';
$object_type = 'fichinter';
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated", $link);
break;
case 'FICHINTER_MODIFY':
$link = '<a href="'.$urlwithroot.'/fichinter/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
$context_info = array_key_exists('signature', $object->context) ? $object->getLibSignedStatus() : '';
$dir_output = $conf->ficheinter->dir_output;
$object_type = 'ficheinter';
$object_type = 'fichinter';
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionModified", $link, $context_info);
break;
case 'FICHINTER_CLOSE':
$link = '<a href="'.$urlwithroot.'/fichinter/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
$dir_output = $conf->facture->dir_output;
$object_type = 'ficheinter';
$object_type = 'fichinter';
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionClosed", $link);
break;
case 'ORDER_SUPPLIER_CANCEL':

View file

@ -1009,6 +1009,9 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
if ($feature == 'member') {
$feature = 'adherent';
}
if ($feature == 'category') {
$feature = 'categorie';
}
if ($feature == 'project') {
$feature = 'projet';
}

View file

@ -989,6 +989,16 @@ if (!empty($usemargins) && $user->hasRight('margins', 'creer')) {
$('#tva_tx').val(tva_tx);
}
// Sync the measuring unit dropdown with the product's default fk_unit
// (issue #34610). Without this, the dropdown keeps the static initial
// value (the first c_units row, typically "Kg") regardless of what
// the selected product is configured with.
if (typeof data.fk_unit != 'undefined' && data.fk_unit != null && $("#units").length) {
$("#units").val(data.fk_unit).trigger('change');
} else if (typeof data.default_unit != 'undefined' && data.default_unit != null && $("#units").length) {
$("#units").val(data.default_unit).trigger('change');
}
<?php
if (getDolGlobalInt('PRODUIT_AUTOFILL_DESC') == 1) {
if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) { ?>

View file

@ -773,6 +773,7 @@ if (empty($reshook)) {
if ($action == 'settracking_url') { // Test on permission not required
$object->tracking_url = trim(GETPOST('tracking_url', 'restricthtml'));
}
if ($action == 'settrueWeight') { // Test on permission not required
$object->trueWeight = GETPOSTFLOAT('trueWeight');
$object->weight_units = GETPOSTINT('weight_units');
@ -1756,8 +1757,9 @@ if ($action == 'create' && $usercancreate) {
print $langs->trans("Weight");
print '</td><td colspan="3">';
print img_picto('', 'fa-balance-scale', 'class="pictofixedwidth"');
print '<input name="weight" size="4" value="' . GETPOST('weight') . '"> '; // Do not use GETPOSTINT here, we must accept '' also.
$text = $formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units'), 0, 2);
print '<input name="weight" size="4" value="' . dol_escape_htmltag(GETPOST('weight')) . '"> '; // Do not use GETPOSTINT here, we must accept '' also.
$text = $formproduct->selectMeasuringUnits("weight_units", "weight", (string) GETPOST('weight_units'), 0, 2);
$htmltext = $langs->trans("KeepEmptyForAutoCalculation");
print $form->textwithpicto($text, $htmltext);
print '</td></tr>';
@ -2068,8 +2070,8 @@ if ($action == 'create' && $usercancreate) {
// Quantity to send
print '<td class="center">';
if ($line->product_type == Product::TYPE_PRODUCT || getDolGlobalString('STOCK_SUPPORTS_SERVICES') || ($line->product_type == Product::TYPE_SERVICE && getDolGlobalString('SHIPMENT_SUPPORTS_SERVICES'))) {
if (GETPOSTINT('qtyl' . $indiceAsked)) {
$deliverableQty = GETPOSTINT('qtyl' . $indiceAsked);
if (GETPOSTISSET('qtyl'.$indiceAsked) && GETPOST('qtyl'.$indiceAsked) !== '') {
$deliverableQty = GETPOSTFLOAT('qtyl'.$indiceAsked, 'MS');
}
print '<input name="idl' . $indiceAsked . '" type="hidden" value="' . $line->id . '">';
$qtylValue = $deliverableQty;

View file

@ -754,8 +754,10 @@ if (empty($reshook)) {
$result = $objectline->update($user);
if ($result < 0) {
dol_print_error($db);
exit;
// Surface validation errors (e.g. mandatory extrafield left empty) as an
// event message on the same page instead of breaking with a full Dolibarr
// error screen that loses the user's edit context.
setEventMessages($objectline->error, $objectline->errors, 'errors');
}
// Define output language

View file

@ -1011,7 +1011,7 @@ if ($action == 'create') {
$projectid = GETPOST('projectid') ? GETPOST('projectid') : $object->fk_project;
$langs->load('projects');
print '<tr><td>' . $langs->trans('Project') . '</td><td>';
$numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, '');
$numprojet = $formproject->select_projects((!getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ? $object->thirdparty->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, '');
print ' &nbsp; <a href="' . DOL_URL_ROOT . '/projet/card.php?socid=' . $object->thirdparty->id . '&action=create&status=1&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?action=create&socid=' . $object->thirdparty->id . (!empty($id) ? '&id=' . $id : '')) . '">' . $langs->trans("AddProject") . '</a>';
print '</td></tr>';
}
@ -1039,7 +1039,7 @@ if ($action == 'create') {
print "<tr><td>" . $langs->trans('Model') . "</td><td>";
include_once DOL_DOCUMENT_ROOT . '/core/modules/supplier_invoice/modules_facturefournisseur.php';
$list = ModelePDFSuppliersInvoices::liste_modeles($db);
print $form->selectarray('modelpdf', $list, $conf->global->INVOICE_SUPPLIER_ADDON_PDF);
print $form->selectarray('modelpdf', $list, getDolGlobalString('INVOICE_SUPPLIER_ADDON_PDF'));
print "</td></tr>";
// Public note
@ -1202,7 +1202,7 @@ if ($action == 'create') {
$morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="' . newToken() . '">';
$morehtmlref .= $formproject->select_projects($object->socid, (string) $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= $formproject->select_projects((!getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ? $object->socid : -1), (string) $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
$morehtmlref .= '</form>';
} else {

View file

@ -216,7 +216,11 @@ if (!defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) >
}
// Clean parameters
$dolibarr_main_data_root = isset($dolibarr_main_data_root) ? trim($dolibarr_main_data_root) : DOL_DOCUMENT_ROOT.'/../documents';
// isset() is true on an empty string, which would let DOL_DATA_ROOT
// resolve to '' and the lock file to /install.lock (rejected by a
// restrictive open_basedir). Use !empty() so an empty value falls
// back to the default relative documents path.
$dolibarr_main_data_root = !empty($dolibarr_main_data_root) ? trim($dolibarr_main_data_root) : DOL_DOCUMENT_ROOT.'/../documents';
$dolibarr_main_url_root = isset($dolibarr_main_url_root) ? trim($dolibarr_main_url_root) : '';
$dolibarr_main_url_root_alt = isset($dolibarr_main_url_root_alt) ? trim($dolibarr_main_url_root_alt) : '';
$dolibarr_main_document_root = isset($dolibarr_main_document_root) ? trim($dolibarr_main_document_root) : '';
@ -268,7 +272,7 @@ if (!isset($dolibarr_main_db_prefix) || !$dolibarr_main_db_prefix) {
define('MAIN_DB_PREFIX', (isset($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : ''));
define('DOL_CLASS_PATH', 'class/'); // Filesystem path to class dir
define('DOL_DATA_ROOT', (isset($dolibarr_main_data_root) ? $dolibarr_main_data_root : DOL_DOCUMENT_ROOT.'/../documents'));
define('DOL_DATA_ROOT', (!empty($dolibarr_main_data_root) ? $dolibarr_main_data_root : DOL_DOCUMENT_ROOT.'/../documents'));
define('DOL_MAIN_URL_ROOT', (isset($dolibarr_main_url_root) ? $dolibarr_main_url_root : '')); // URL relative root
$uri = preg_replace('/^http(s?):\/\//i', '', constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http*
$suburi = strstr($uri, '/'); // $suburi contains url without domain

View file

@ -295,9 +295,10 @@ if ($action == 'fetch' && !empty($id)) {
'qty' => $outqty,
'discount' => $outdiscount,
'mandatory_period' => $mandatory_period,
'array_options' => $object->array_options,
'default_unit'=>$default_unit
'default_unit' => $default_unit
);
}

View file

@ -1053,6 +1053,19 @@ class Product extends CommonObject
$this->accountancy_code_sell_intra = trim((string) $this->accountancy_code_sell_intra);
$this->accountancy_code_sell_export = trim((string) $this->accountancy_code_sell_export);
// Normalize the accountancy codes the way the admin dropdown does it, so an API client that
// sends '606111000' ends up with the same '606111' value the GUI stores (see issue #32343).
// When ACCOUNTING_MANAGE_ZERO is on, trailing zeros are part of the code and must be kept.
if (!getDolGlobalString('ACCOUNTING_MANAGE_ZERO')) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
$this->accountancy_code_buy = clean_account($this->accountancy_code_buy);
$this->accountancy_code_buy_intra = clean_account($this->accountancy_code_buy_intra);
$this->accountancy_code_buy_export = clean_account($this->accountancy_code_buy_export);
$this->accountancy_code_sell = clean_account($this->accountancy_code_sell);
$this->accountancy_code_sell_intra = clean_account($this->accountancy_code_sell_intra);
$this->accountancy_code_sell_export = clean_account($this->accountancy_code_sell_export);
}
// Barcode value
$this->barcode = trim($this->barcode);
$this->mandatory_period = empty($this->mandatory_period) ? 0 : $this->mandatory_period;
@ -1488,6 +1501,19 @@ class Product extends CommonObject
$this->accountancy_code_sell_intra = trim($this->accountancy_code_sell_intra);
$this->accountancy_code_sell_export = trim($this->accountancy_code_sell_export);
// Normalize the accountancy codes the way the admin dropdown does it, so an API client that
// sends '606111000' ends up with the same '606111' value the GUI stores (see issue #32343).
// When ACCOUNTING_MANAGE_ZERO is on, trailing zeros are part of the code and must be kept.
if (!getDolGlobalString('ACCOUNTING_MANAGE_ZERO')) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
$this->accountancy_code_buy = clean_account($this->accountancy_code_buy);
$this->accountancy_code_buy_intra = clean_account($this->accountancy_code_buy_intra);
$this->accountancy_code_buy_export = clean_account($this->accountancy_code_buy_export);
$this->accountancy_code_sell = clean_account($this->accountancy_code_sell);
$this->accountancy_code_sell_intra = clean_account($this->accountancy_code_sell_intra);
$this->accountancy_code_sell_export = clean_account($this->accountancy_code_sell_export);
}
$this->db->begin();
$result = 0;

View file

@ -126,7 +126,14 @@ $type = GETPOST("type", 'alpha');
// Show/hide child product variants
$show_childproducts = 0;
if (isModEnabled('variants')) {
$show_childproducts = GETPOST('search_show_childproducts');
// An HTML checkbox does not submit anything when unchecked, so a hidden
// "search_show_childproducts=0" companion field is emitted next to the
// checkbox (see below). GETPOSTISSET() then let's us distinguish a
// resubmission with the checkbox off from a request that does not carry
// the filter at all, and the value is read as a strict 0/1 flag.
if (GETPOSTISSET('search_show_childproducts')) {
$show_childproducts = GETPOSTINT('search_show_childproducts');
}
}
$diroutputmassaction = $conf->product->dir_output.'/temp/massgeneration/'.$user->id;
@ -400,7 +407,7 @@ if (empty($reshook)) {
$search_finished = '';
//$search_type=''; // There is 2 types of list: a list of product and a list of services. No list with both. So when we clear search criteria, we must keep the filter on type.
$show_childproducts = '';
$show_childproducts = 0;
$search_import_key = '';
$search_stockable_product = '';
$search_accountancy_code_sell = '';
@ -827,7 +834,7 @@ if ($fourn_id > 0) {
$param .= "&fourn_id=".urlencode((string) ($fourn_id));
}
if ($show_childproducts) {
$param .= ($show_childproducts ? "&search_show_childproducts=".urlencode($show_childproducts) : "");
$param .= "&search_show_childproducts=".urlencode((string) $show_childproducts);
}
if ($type != '') {
$param .= '&type='.urlencode((string) ($type));
@ -984,7 +991,11 @@ if (isModEnabled('category') && $user->hasRight('categorie', 'read')) {
// Show/hide child variant products
if (isModEnabled('variants')) {
$moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= '<input type="checkbox" id="search_show_childproducts" name="search_show_childproducts"'.($show_childproducts ? 'checked="checked"' : '').'>';
// Companion hidden field ensures search_show_childproducts is always
// posted, even when the checkbox below is unchecked, so the unchecked
// state survives the filter/pagination submit and is parsed as 0/1.
$moreforfilter .= '<input type="hidden" name="search_show_childproducts" value="0">';
$moreforfilter .= '<input type="checkbox" id="search_show_childproducts" name="search_show_childproducts" value="1"'.($show_childproducts ? ' checked="checked"' : '').'>';
$moreforfilter .= ' <label for="search_show_childproducts">'.$langs->trans('ShowChildProducts').'</label>';
$moreforfilter .= '</div>';
}

View file

@ -1684,6 +1684,16 @@ class Task extends CommonObjectLine
$ret = -1;
}
// Propagate trigger handler messages from $this->errors (plural array)
// to $this->error (singular string) so callers like the REST API can
// surface a useful message instead of an empty error tail.
if ($ret <= 0 && empty($this->error) && !empty($this->errors)) {
foreach ($this->errors as $errmsg) {
dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
}
if ($ret > 0) {
// Recalculate amount of time spent for task and update denormalized field
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task";
@ -2146,6 +2156,16 @@ class Task extends CommonObjectLine
$ret = -1;
}
// Propagate trigger handler messages from $this->errors (plural array)
// to $this->error (singular string) so callers like the REST API can
// surface a useful message instead of an empty error tail.
if ($ret < 0 && empty($this->error) && !empty($this->errors)) {
foreach ($this->errors as $errmsg) {
dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
}
if ($ret == 1 && (($this->timespent_old_duration != $this->timespent_duration) || getDolGlobalString('TIMESPENT_ALWAYS_UPDATE_THM'))) {
if ($this->timespent_old_duration != $this->timespent_duration) {
// Recalculate amount of time spent for task and update denormalized field

View file

@ -375,7 +375,7 @@ class Recruitments extends DolibarrApi
}
// Check mandatory fields
$result = $this->_validate($request_data);
$result = $this->_validate($request_data, $this->jobposition);
foreach ($request_data as $field => $value) {
if ($field === 'caller') {
@ -414,8 +414,10 @@ class Recruitments extends DolibarrApi
throw new RestException(403);
}
// Check mandatory fields
$result = $this->_validate($request_data);
// Check mandatory fields. Validate against the candidature model so the API
// rejects with the actual missing candidature fields (e.g. email) instead of
// the unrelated job position fields (see issue #38429).
$result = $this->_validate($request_data, $this->candidature);
foreach ($request_data as $field => $value) {
if ($field === 'caller') {
@ -686,25 +688,26 @@ class Recruitments extends DolibarrApi
* Validate fields before create or update object
*
* @param ?array<string,mixed> $data Array of data to validate
* @param CommonObject $object Object to validate against
* @return array<string,mixed>
*
* @throws RestException
*/
private function _validate($data)
private function _validate($data, $object)
{
if ($data === null) {
$data = array();
}
$jobposition = array();
foreach ($this->jobposition->fields as $field => $propfield) {
$result = array();
foreach ($object->fields as $field => $propfield) {
if (in_array($field, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat')) || empty($propfield['notnull']) || $propfield['notnull'] != 1) {
continue; // Not a mandatory field
}
if (!isset($data[$field])) {
throw new RestException(400, "$field field missing");
}
$jobposition[$field] = $data[$field];
$result[$field] = $data[$field];
}
return $jobposition;
return $result;
}
}

View file

@ -406,14 +406,19 @@ if (getDolGlobalString('TAKEPOS_TICKET_VAT_GROUPPED')) {
// Now show local taxes if company uses them
if (price2num($object->total_localtax1, 'MU') || $mysoc->useLocalTax(1)) { ?>
// $mysoc->useLocalTax(N) is a country-wide flag (true as soon as the country has a
// matching c_tva row with a localtaxN_type), so on its own it always prints the line
// for Spanish companies even when the company is "No sujeto a RE / IRPF". Mirror the
// pattern used by compta/facture/card.php, card-rec.php and prelevement.php and gate
// the country check on $mysoc->localtaxN_assuj == "1".
if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || price2num($object->total_localtax1, 'MU')) { ?>
<tr>
<th class="right"><?php if ($gift != 1) {
echo ''.$langs->trans("TotalLT1").'</th><td class="right">'.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency)."\n";
} ?></th>
</tr>
<?php } ?>
<?php if (price2num($object->total_localtax2, 'MU') || $mysoc->useLocalTax(2)) { ?>
<?php if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || price2num($object->total_localtax2, 'MU')) { ?>
<tr>
<th class="right"><?php if ($gift != 1) {
echo ''.$langs->trans("TotalLT2").'</th><td class="right">'.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency)."\n";

View file

@ -472,7 +472,7 @@ if (empty($reshook)) {
$object->pass = GETPOST("password", 'password');
}
if ($permissiontoeditpasswordandsee || $user->hasRight("api", "apikey", "generate")) {
$object->api_key = (GETPOST("api_key", 'alphanohtml')) ? GETPOST("api_key", 'alphanohtml') : $object->api_key;
$object->api_key = (GETPOSTISSET("api_key", 'alphanohtml')) ? GETPOST("api_key", 'alphanohtml') : $object->api_key;
}
if (!empty($user->admin) && $user->id != $id) {
// admin flag can only be set/unset by an admin user and not four ourself
@ -561,6 +561,9 @@ if (empty($reshook)) {
$isimage = image_format_supported($_FILES['photo']['name']);
if ($isimage > 0) {
$object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
if ($object->id == $user->id) {
$user->photo = $object->photo;
}
} else {
$error++;
$langs->load("errors");