';
}
}
// Project
@@ -386,7 +386,7 @@ if ($object->id > 0) {
if (0) { // @phpstan-ignore-line
$morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
if ($action != 'classify') {
- $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' ';
+ $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' ';
}
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
} else {
diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php
index b0a7fa92d62..3dbd73f1aee 100644
--- a/htdocs/contrat/agenda.php
+++ b/htdocs/contrat/agenda.php
@@ -205,7 +205,7 @@ if ($object->id > 0) {
// Thirdparty
$morehtmlref .= ' '.$object->thirdparty->getNomUrl(1);
if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) {
- $morehtmlref .= ' ('.$langs->trans("OtherContracts").')';
+ $morehtmlref .= ' ('.$langs->trans("OtherContracts").')';
}
// Project
if (isModEnabled('project')) {
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 7eea9ca3b61..9443ea5058f 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -1522,7 +1522,7 @@ if ($action == 'create') {
// Thirdparty
$morehtmlref .= ' '.$object->thirdparty->getNomUrl(1);
if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) {
- $morehtmlref .= ' ('.$langs->trans("OtherContracts").')';
+ $morehtmlref .= ' ('.$langs->trans("OtherContracts").')';
}
// Project
if (isModEnabled('project')) {
@@ -1531,7 +1531,7 @@ if ($action == 'create') {
if ($permissiontoadd) {
$morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
if ($action != 'classify') {
- $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' ';
+ $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' ';
}
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
} else {
diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php
index cc715d1df00..128e11476b7 100644
--- a/htdocs/contrat/document.php
+++ b/htdocs/contrat/document.php
@@ -156,7 +156,7 @@ if ($object->id) {
// Thirdparty
$morehtmlref .= ' '.$object->thirdparty->getNomUrl(1);
if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) {
- $morehtmlref .= ' ('.$langs->trans("OtherContracts").')';
+ $morehtmlref .= ' ('.$langs->trans("OtherContracts").')';
}
// Project
if (isModEnabled('project')) {
@@ -165,7 +165,7 @@ if ($object->id) {
if (0) { // @phpstan-ignore-line
$morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
if ($action != 'classify') {
- $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' ';
+ $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' ';
}
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
} else {
diff --git a/htdocs/contrat/messaging.php b/htdocs/contrat/messaging.php
index c8140647354..c0dd3069a8c 100644
--- a/htdocs/contrat/messaging.php
+++ b/htdocs/contrat/messaging.php
@@ -194,7 +194,7 @@ $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_
// Thirdparty
$morehtmlref .= ' '.$object->thirdparty->getNomUrl(1);
if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) {
- $morehtmlref .= ' ('.$langs->trans("OtherContracts").')';
+ $morehtmlref .= ' ('.$langs->trans("OtherContracts").')';
}
// Project
if (isModEnabled('project')) {
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 7dccf56f726..5f829ab5565 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -7116,6 +7116,15 @@ abstract class CommonObject
// if the extrafields row already exists for the object, we update it
if ($linealreadyfound) {
array_shift($sqlColumnValues); // drop the 'fk_object' column because its value won't change
+ if (empty($sqlColumnValues)) {
+ // No column of the target element to update. This happens when the object was created from
+ // another element whose extrafields do not exist on this element (e.g. invoice created from a
+ // shipment: the source line extrafields are copied into array_options but none match facturedet).
+ // The existing row is already correct, so there is nothing to update: avoid an empty "SET" clause
+ // that would produce an invalid SQL statement.
+ $this->db->commit();
+ return 1;
+ }
$sqlColumnValueString = implode(
',',
/**
@@ -9476,10 +9485,12 @@ abstract class CommonObject
if (($mode == 'create') && !in_array(abs($visibility), array(1, 3))) {
continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list
} elseif (($mode == 'edit') && !in_array(abs($visibility), array(1, 3, 4))) {
- // We need to make sure, that the values of hidden extrafields are also part of $_POST. Otherwise, they would be empty after an update of the object. See also getOptionalsFromPost
+ // We need to make sure, that the values of hidden extrafields are also part of $_POST.
+ // Otherwise, they would be empty after an update of the object. See also getOptionalsFromPost
+ // TODO: We should not have this hidden field, and action='update' should be done only if field was POSTED by form.
$ef_name = 'options_' . $key;
$ef_value = $this->array_options[$ef_name] ?? '';
- $out .= '' . "\n"; // HTML-escape the value for safe output, but preserve its original content so it can be submitted and saved back unchanged. Do not use dol_escape_htmltag().
+ $out .= '' . "\n"; // If trouble to preserve content, we can try dol_htmlentities() instead, but real solution is to remove completely the hidden field (see previous TODO).
continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list and <> 4 = not visible at the creation
} elseif ($mode == 'view' && empty($visibility)) {
continue;
diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php
index 539fc6ee041..7eba84ac5ef 100644
--- a/htdocs/core/class/html.formsetup.class.php
+++ b/htdocs/core/class/html.formsetup.class.php
@@ -1694,7 +1694,7 @@ class FormSetupItem
/**
* Set type of input as a select list.
*
- * @param ?array $fieldOptions A table of field options
+ * @param ?array $fieldOptions A table of field options
* @return self
*/
public function setAsSelect($fieldOptions)
diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php
index d3e3f53cf57..42581a58673 100644
--- a/htdocs/core/lib/date.lib.php
+++ b/htdocs/core/lib/date.lib.php
@@ -1005,8 +1005,11 @@ function num_public_holiday($timestampStart, $timestampEnd, $countryCodeOrId = '
}
// Increase number of days (on go up into loop)
+ // Advance by exactly one GMT day. We can use += instead of dol_time_plus_duree() here because
+ // inputs of this function are GMT dates (checked above), so a day
+ // is always exactly 86400 seconds.
//var_dump("before ".$jour.' '.$mois.' '.$annee.' '.$timestampStart);
- $timestampStart = dol_time_plus_duree($timestampStart, 1, 'd');
+ $timestampStart += 86400;
//var_dump("after ".$jour.' '.$mois.' '.$annee.' '.$timestampStart);
$i++;
@@ -1455,7 +1458,7 @@ function getWeekNumbersOfMonth($month, $year)
{
$nb_days = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$TWeek = array();
- for ($day = 1; $day < $nb_days; $day++) {
+ for ($day = 1; $day <= $nb_days; $day++) {
$week_number = getWeekNumber($day, $month, $year);
$TWeek[$week_number] = $week_number;
}
diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php
index 401def34490..94226bea497 100644
--- a/htdocs/core/modules/modAccounting.class.php
+++ b/htdocs/core/modules/modAccounting.class.php
@@ -257,10 +257,11 @@ class modAccounting extends DolibarrModules
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'accounting_account as aa';
- $this->export_sql_end[$r] .= ' ,'.MAIN_DB_PREFIX.'accounting_system as ac';
- $this->export_sql_end[$r] .= ' ,'.MAIN_DB_PREFIX.'accounting_account as aa2';
- $this->export_sql_end[$r] .= ' WHERE ac.pcg_version = aa.fk_pcg_version AND aa.entity IN ('.getEntity('accounting').')';
- $this->export_sql_end[$r] .= ' AND aa2.rowid = aa.account_parent AND aa2.active = 1 AND ac.pcg_version = aa2.fk_pcg_version AND aa2.entity IN ('.getEntity('accounting').')';
+ $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as ac ON ac.pcg_version = aa.fk_pcg_version';
+ // LEFT JOIN on the parent account: keep accounts that have no parent (root accounts) or whose parent is
+ // inactive or belongs to another chart (common when a custom chart is derived from a base one).
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_account as aa2 ON aa2.rowid = aa.account_parent AND aa2.entity IN ('.getEntity('accounting').')';
+ $this->export_sql_end[$r] .= ' WHERE aa.entity IN ('.getEntity('accounting').')';
// Imports
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index 9c8e00490f6..6968b58dae1 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -2192,7 +2192,7 @@ if ($action == 'create') {
}
$morehtmlref .= $object->thirdparty->getNomUrl(1, 'supplier');
if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) {
- $morehtmlref .= ' ('.$langs->trans("OtherOrders").')';
+ $morehtmlref .= ' ('.$langs->trans("OtherOrders").')';
}
}
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index d119fe2bda3..289b461142f 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -3350,7 +3350,7 @@ if ($action == 'create') {
// Thirdparty
$morehtmlref .= ' '.$object->thirdparty->getNomUrl(1, 'supplier');
if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) {
- $morehtmlref .= '