diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 392d3b44788..b5587505581 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -3019,7 +3019,7 @@ if ($action == 'create') { // Thirdparty $morehtmlref .= '
' . $soc->getNomUrl(1, 'customer'); if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $soc->id > 0) { - $morehtmlref .= ' (' . $langs->trans("OtherProposals") . ')'; + $morehtmlref .= ' (' . $langs->trans("OtherProposals") . ')'; } // Project if (isModEnabled('project')) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 6b7248864a1..3e87657e2c8 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2968,7 +2968,7 @@ if ($action == 'create' && $usercancreate) { // Thirdparty $morehtmlref .= '
' . $soc->getNomUrl(1, 'customer'); if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' (' . $langs->trans("OtherOrders") . ')'; + $morehtmlref .= ' (' . $langs->trans("OtherOrders") . ')'; } // Project if (isModEnabled('project')) { diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 7ac4efb09e5..ef4b0962216 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -5308,7 +5308,7 @@ if ($action == 'create') { // Thirdparty $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1, 'customer'); if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherBills").')'; + $morehtmlref .= ' ('.$langs->trans("OtherBills").')'; } // Project if (isModEnabled('project')) { diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index c67ac46b3ab..47b8f475177 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -372,11 +372,11 @@ if ($object->id > 0) { $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); if ($type == 'bank-transfer') { if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= '
('.$langs->trans("OtherBills").')
'; + $morehtmlref .= '
('.$langs->trans("OtherBills").')
'; } } else { if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= '
('.$langs->trans("OtherBills").')
'; + $morehtmlref .= '
('.$langs->trans("OtherBills").')
'; } } // 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 .= ' '; + $morehtmlref .= ' '; } // Project if (isModEnabled('project')) { diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index a6a84423404..c38e45dfe6b 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -161,7 +161,7 @@ if ($id > 0 || !empty($ref)) { // Thirdparty $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' '; + $morehtmlref .= ' '; } // Project if (isModEnabled('project')) { diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index 8ffa1b39f9d..3f85085d570 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -125,7 +125,7 @@ if ($object->id > 0 && $upload_dir !== null) { // Thirdparty $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' '; + $morehtmlref .= ' '; } // Project if (isModEnabled('project')) { diff --git a/htdocs/fourn/facture/info.php b/htdocs/fourn/facture/info.php index 1e5d66e0906..693149d943e 100644 --- a/htdocs/fourn/facture/info.php +++ b/htdocs/fourn/facture/info.php @@ -92,7 +92,7 @@ $morehtmlref .= $form->editfieldval("RefSupplierBill", 'ref_supplier', $object-> // Thirdparty $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' '; + $morehtmlref .= ' '; } // Project if (isModEnabled('project')) { diff --git a/htdocs/fourn/facture/note.php b/htdocs/fourn/facture/note.php index 829de10e14f..c4c97d8bd3c 100644 --- a/htdocs/fourn/facture/note.php +++ b/htdocs/fourn/facture/note.php @@ -120,7 +120,7 @@ if ($object->id > 0) { // Thirdparty $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' '; + $morehtmlref .= ' '; } // Project if (isModEnabled('project')) { diff --git a/htdocs/mrp/mo_agenda.php b/htdocs/mrp/mo_agenda.php index 5067c0260a5..ccfd6ccac1b 100644 --- a/htdocs/mrp/mo_agenda.php +++ b/htdocs/mrp/mo_agenda.php @@ -172,7 +172,7 @@ if ($object->id > 0) { if (is_object($object->thirdparty)) { $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; } } // Project diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 75164a24bff..e1c7a211426 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -674,7 +674,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (is_object($object->thirdparty)) { $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; } } // Project diff --git a/htdocs/mrp/mo_document.php b/htdocs/mrp/mo_document.php index 53944f77e15..0ba064e3ea7 100644 --- a/htdocs/mrp/mo_document.php +++ b/htdocs/mrp/mo_document.php @@ -144,7 +144,7 @@ if ($object->id && $upload_dir !== null) { if (is_object($object->thirdparty)) { $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; } } // Project diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index 5588eb3b88d..5a23604bae8 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -330,7 +330,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (is_object($object->thirdparty)) { $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; } } // Project diff --git a/htdocs/mrp/mo_note.php b/htdocs/mrp/mo_note.php index 422a8e0b71c..008fdaa9ba6 100644 --- a/htdocs/mrp/mo_note.php +++ b/htdocs/mrp/mo_note.php @@ -120,7 +120,7 @@ if ($id > 0 || !empty($ref)) { if (is_object($object->thirdparty)) { $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; } } // Project diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index a31ab3a6d3e..5b5aecca496 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -712,7 +712,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (is_object($object->thirdparty)) { $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer'); if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; } } diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_card.php b/htdocs/product/stock/stocktransfer/stocktransfer_card.php index 065ff54dd51..6810a28a29d 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_card.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_card.php @@ -618,7 +618,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Thirdparty $morehtmlref .= empty($object->thirdparty) ? '' : $object->thirdparty->getNomUrl(1, 'customer'); if (!getDolGlobalInt('MAIN_DISABLE_OTHER_LINK') && !empty($object->thirdparty) && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; } // Project if (isModEnabled('project')) { diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_contact.php b/htdocs/product/stock/stocktransfer/stocktransfer_contact.php index 015700af5a1..a3e2c68da72 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_contact.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_contact.php @@ -162,7 +162,7 @@ if ($object->id > 0) { // Thirdparty $morehtmlref .= empty($object->thirdparty) ? '' : $object->thirdparty->getNomUrl(1, 'customer'); if (!getDolGlobalInt('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; } // Project if (isModEnabled('project')) { diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index dd54234df19..87ef8242cd5 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1683,7 +1683,7 @@ if ($action == 'create') { // Thirdparty $morehtmlref .= $object->thirdparty->getNomUrl(1, 'supplier'); if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherProposals").')'; + $morehtmlref .= ' ('.$langs->trans("OtherProposals").')'; } // Project if (isModEnabled('project')) {