From 8621eb21fa036df3ef7b4472e6b90ec17dca8cf6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 25 Nov 2025 14:58:33 +0100 Subject: [PATCH 01/11] FIX multicompany dictionary sharing --- htdocs/api/class/api_setup.class.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index db84049d46e..fbd951ba5b8 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1,13 +1,13 @@ - * Copyright (C) 2016 Laurent Destailleur - * Copyright (C) 2017 Regis Houssin - * Copyright (C) 2017 Neil Orley - * Copyright (C) 2018-2025 Frédéric France - * Copyright (C) 2018-2022 Thibault FOUCART - * Copyright (C) 2024 Jon Bendtsen +/* Copyright (C) 2016 Xebax Christy + * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2017-2025 Regis Houssin + * Copyright (C) 2017 Neil Orley + * Copyright (C) 2018-2025 Frédéric France + * Copyright (C) 2018-2022 Thibault FOUCART + * Copyright (C) 2024 Jon Bendtsen * Copyright (C) 2024-2025 MDW - * Copyright (C) 2025 Charlene Benke + * Copyright (C) 2025 Charlene Benke * * * This program is free software; you can redistribute it and/or modify @@ -1056,7 +1056,8 @@ class Setup extends DolibarrApi $sql = "SELECT rowid, code, label, affect, delay, newbymonth, fk_country"; $sql .= " FROM ".MAIN_DB_PREFIX."c_holiday_types as t"; - $sql .= " WHERE t.active = ".((int) $active); + $sql .= " WHERE t.entity IN (".getEntity('c_holiday_types').")"; + $sql .= " AND t.active = ".((int) $active); if ($fk_country) { $sql .= " AND (t.fk_country = ".((int) $fk_country); $sql .= " OR t.fk_country is null)"; @@ -1135,7 +1136,8 @@ class Setup extends DolibarrApi $sql = "SELECT id, code, dayrule, day, month, year, fk_country, code as label"; $sql .= " FROM ".MAIN_DB_PREFIX."c_hrm_public_holiday as t"; - $sql .= " WHERE t.active = ".((int) $active); + $sql .= " WHERE t.entity IN (".getEntity('c_hrm_public_holiday').")"; + $sql .= " AND t.active = ".((int) $active); if ($fk_country) { $sql .= " AND (t.fk_country = ".((int) $fk_country); $sql .= " OR t.fk_country is null)"; From 1da3e19bc23f7c2dd9c63d8ed4df0c0de3d75896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Tue, 25 Nov 2025 21:05:16 +0100 Subject: [PATCH 02/11] clean code trigger --- ...terface_50_modAgenda_ActionsAuto.class.php | 108 +++++++++--------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 3f2a1a87e0f..bf8024e5dae 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -419,7 +419,7 @@ class InterfaceActionsAuto extends DolibarrTriggers // Parameters $object->sendtoid defined by caller //$object->sendtoid = array(); - } elseif ($action == 'BILL_VALIDATE') { + } elseif ($action == 'BILL_VALIDATE' && $object instanceof Facture) { '@phan-var-force Facture $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills")); @@ -436,7 +436,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'BILL_UNVALIDATE') { + } elseif ($action == 'BILL_UNVALIDATE' && $object instanceof Facture) { '@phan-var-force Facture $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills")); @@ -453,7 +453,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'BILL_SENTBYMAIL') { + } elseif ($action == 'BILL_SENTBYMAIL' && $object instanceof Facture) { '@phan-var-force Facture $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills")); @@ -471,7 +471,7 @@ class InterfaceActionsAuto extends DolibarrTriggers // Parameters $object->sendtoid defined by caller //$object->sendtoid = array(); - } elseif ($action == 'BILL_PAYED') { + } elseif ($action == 'BILL_PAYED' && $object instanceof Facture) { '@phan-var-force Facture $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills")); @@ -489,7 +489,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'BILL_CANCEL') { + } elseif ($action == 'BILL_CANCEL' && $object instanceof Facture) { '@phan-var-force Facture $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills")); @@ -506,7 +506,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'FICHINTER_CREATE') { + } elseif ($action == 'FICHINTER_CREATE' && $object instanceof Fichinter) { '@phan-var-force Fichinter $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "interventions")); @@ -525,7 +525,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid = array(); $object->fk_element = 0; $object->elementtype = ''; - } elseif ($action == 'FICHINTER_VALIDATE') { + } elseif ($action == 'FICHINTER_VALIDATE' && $object instanceof Fichinter) { '@phan-var-force Fichinter $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "interventions")); @@ -544,7 +544,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid = array(); $object->fk_element = 0; $object->elementtype = ''; - } elseif ($action == 'FICHINTER_MODIFY') { + } elseif ($action == 'FICHINTER_MODIFY' && $object instanceof Fichinter) { '@phan-var-force Fichinter $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "interventions")); @@ -563,7 +563,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid = array(); $object->fk_element = 0; $object->elementtype = ''; - } elseif ($action == 'FICHINTER_SENTBYMAIL') { + } elseif ($action == 'FICHINTER_SENTBYMAIL' && $object instanceof Fichinter) { '@phan-var-force Fichinter $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "interventions")); @@ -581,7 +581,7 @@ class InterfaceActionsAuto extends DolibarrTriggers // Parameters $object->sendtoid defined by caller //$object->sendtoid = array(); - } elseif ($action == 'FICHINTER_CLASSIFY_BILLED') { + } elseif ($action == 'FICHINTER_CLASSIFY_BILLED' && $object instanceof Fichinter) { '@phan-var-force Fichinter $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "interventions")); @@ -598,7 +598,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED') { + } elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED' && $object instanceof Fichinter) { '@phan-var-force Fichinter $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "interventions")); @@ -615,7 +615,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'FICHINTER_CLOSE') { + } elseif ($action == 'FICHINTER_CLOSE' && $object instanceof Fichinter) { '@phan-var-force Fichinter $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "interventions")); @@ -634,7 +634,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid = array(); $object->fk_element = 0; $object->elementtype = ''; - } elseif ($action == 'FICHINTER_DELETE') { + } elseif ($action == 'FICHINTER_DELETE' && $object instanceof Fichinter) { '@phan-var-force Fichinter $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "interventions")); @@ -653,7 +653,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid = array(); $object->fk_element = 0; $object->elementtype = ''; - } elseif ($action == 'SHIPPING_VALIDATE') { + } elseif ($action == 'SHIPPING_VALIDATE' && $object instanceof Expedition) { '@phan-var-force Expedition $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "sendings")); @@ -671,7 +671,7 @@ class InterfaceActionsAuto extends DolibarrTriggers // Parameters $object->sendtoid defined by caller //$object->sendtoid = array(); - } elseif ($action == 'SHIPPING_SENTBYMAIL') { + } elseif ($action == 'SHIPPING_SENTBYMAIL' && $object instanceof Expedition) { '@phan-var-force Expedition $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "sendings")); @@ -689,7 +689,7 @@ class InterfaceActionsAuto extends DolibarrTriggers // Parameters $object->sendtoid defined by caller //$object->sendtoid = array(); - } elseif ($action == 'RECEPTION_VALIDATE') { + } elseif ($action == 'RECEPTION_VALIDATE' && $object instanceof Reception) { '@phan-var-force Reception $object'; $langs->load("agenda"); $langs->load("other"); @@ -708,7 +708,7 @@ class InterfaceActionsAuto extends DolibarrTriggers // Parameters $object->sendtoid defined by caller //$object->sendtoid = array(); - } elseif ($action == 'RECEPTION_SENTBYMAIL') { + } elseif ($action == 'RECEPTION_SENTBYMAIL' && $object instanceof Reception) { '@phan-var-force Reception $object'; $langs->load("agenda"); $langs->load("other"); @@ -727,7 +727,7 @@ class InterfaceActionsAuto extends DolibarrTriggers // Parameters $object->sendtoid defined by caller //$object->sendtoid = array(); - } elseif ($action == 'PROPOSAL_SUPPLIER_VALIDATE') { + } elseif ($action == 'PROPOSAL_SUPPLIER_VALIDATE' && $object instanceof SupplierProposal) { '@phan-var-force SupplierProposal $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "propal")); @@ -744,7 +744,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL') { + } elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL' && $object instanceof SupplierProposal) { '@phan-var-force SupplierProposal $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "propal")); @@ -762,7 +762,7 @@ class InterfaceActionsAuto extends DolibarrTriggers // Parameters $object->sendtoid defined by caller //$object->sendtoid = array(); - } elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_SIGNED') { + } elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_SIGNED' && $object instanceof SupplierProposal) { '@phan-var-force SupplierProposal $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "propal")); @@ -779,7 +779,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED') { + } elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED' && $object instanceof SupplierProposal) { '@phan-var-force SupplierProposal $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "propal")); @@ -796,7 +796,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'ORDER_SUPPLIER_CREATE') { + } elseif ($action == 'ORDER_SUPPLIER_CREATE' && $object instanceof CommandeFournisseur) { '@phan-var-force CommandeFournisseur $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "orders")); @@ -813,7 +813,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') { + } elseif ($action == 'ORDER_SUPPLIER_VALIDATE' && $object instanceof CommandeFournisseur) { '@phan-var-force CommandeFournisseur $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "orders")); @@ -830,7 +830,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'ORDER_SUPPLIER_APPROVE') { + } elseif ($action == 'ORDER_SUPPLIER_APPROVE' && $object instanceof CommandeFournisseur) { '@phan-var-force CommandeFournisseur $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "orders")); @@ -847,7 +847,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'ORDER_SUPPLIER_REFUSE') { + } elseif ($action == 'ORDER_SUPPLIER_REFUSE' && $object instanceof CommandeFournisseur) { '@phan-var-force CommandeFournisseur $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "orders", "main")); @@ -869,7 +869,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'ORDER_SUPPLIER_CANCEL') { + } elseif ($action == 'ORDER_SUPPLIER_CANCEL' && $object instanceof CommandeFournisseur) { '@phan-var-force CommandeFournisseur $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "orders", "main")); @@ -891,7 +891,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'ORDER_SUPPLIER_SUBMIT') { + } elseif ($action == 'ORDER_SUPPLIER_SUBMIT' && $object instanceof CommandeFournisseur) { '@phan-var-force CommandeFournisseur $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "orders")); @@ -913,7 +913,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'ORDER_SUPPLIER_RECEIVE') { + } elseif ($action == 'ORDER_SUPPLIER_RECEIVE' && $object instanceof CommandeFournisseur) { '@phan-var-force CommandeFournisseur $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "orders")); @@ -930,7 +930,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') { + } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL' && $object instanceof CommandeFournisseur) { '@phan-var-force CommandeFournisseur $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills", "orders")); @@ -948,7 +948,7 @@ class InterfaceActionsAuto extends DolibarrTriggers // Parameters $object->sendtoid defined by caller //$object->sendtoid = array(); - } elseif ($action == 'ORDER_SUPPLIER_CLASSIFY_BILLED') { + } elseif ($action == 'ORDER_SUPPLIER_CLASSIFY_BILLED' && $object instanceof CommandeFournisseur) { '@phan-var-force CommandeFournisseur $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills", "orders")); @@ -965,7 +965,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'BILL_SUPPLIER_CREATE') { + } elseif ($action == 'BILL_SUPPLIER_CREATE' && $object instanceof FactureFournisseur) { '@phan-var-force FactureFournisseur $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "orders")); @@ -982,7 +982,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'BILL_SUPPLIER_VALIDATE') { + } elseif ($action == 'BILL_SUPPLIER_VALIDATE' && $object instanceof FactureFournisseur) { '@phan-var-force FactureFournisseur $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills")); @@ -999,7 +999,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'BILL_SUPPLIER_UNVALIDATE') { + } elseif ($action == 'BILL_SUPPLIER_UNVALIDATE' && $object instanceof FactureFournisseur) { '@phan-var-force FactureFournisseur $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills")); @@ -1016,7 +1016,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') { + } elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL' && $object instanceof FactureFournisseur) { '@phan-var-force FactureFournisseur $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills", "orders")); @@ -1034,7 +1034,7 @@ class InterfaceActionsAuto extends DolibarrTriggers // Parameters $object->sendtoid defined by caller //$object->sendtoid = array(); - } elseif ($action == 'BILL_SUPPLIER_PAYED') { + } elseif ($action == 'BILL_SUPPLIER_PAYED' && $object instanceof FactureFournisseur) { '@phan-var-force FactureFournisseur $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills")); @@ -1051,7 +1051,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'BILL_SUPPLIER_CANCELED') { + } elseif ($action == 'BILL_SUPPLIER_CANCELED' && $object instanceof FactureFournisseur) { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills")); @@ -1067,7 +1067,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'MEMBER_VALIDATE') { + } elseif ($action == 'MEMBER_VALIDATE' && $object instanceof Adherent) { '@phan-var-force Adherent $object'; // Members // Load translation files required by the page @@ -1087,7 +1087,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'MEMBER_MODIFY') { + } elseif ($action == 'MEMBER_MODIFY' && $object instanceof Adherent) { '@phan-var-force Adherent $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "members")); @@ -1106,7 +1106,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE') { + } elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE' && $object instanceof Subscription) { '@phan-var-force Subscription $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "members")); @@ -1138,7 +1138,7 @@ class InterfaceActionsAuto extends DolibarrTriggers if (isset($object->fk_soc) && $object->fk_soc > 0) { $object->socid = $object->fk_soc; } - } elseif ($action == 'MEMBER_SUBSCRIPTION_MODIFY') { + } elseif ($action == 'MEMBER_SUBSCRIPTION_MODIFY' && $object instanceof Subscription) { '@phan-var-force Subscription $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "members")); @@ -1169,7 +1169,7 @@ class InterfaceActionsAuto extends DolibarrTriggers if (isset($object->fk_soc) && $object->fk_soc > 0) { $object->socid = $object->fk_soc; } - } elseif ($action == 'MEMBER_SUBSCRIPTION_DELETE') { + } elseif ($action == 'MEMBER_SUBSCRIPTION_DELETE' && $object instanceof Subscription) { '@phan-var-force Subscription $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "members")); @@ -1201,7 +1201,7 @@ class InterfaceActionsAuto extends DolibarrTriggers if (isset($object->fk_soc) && $object->fk_soc > 0) { $object->socid = $object->fk_soc; } - } elseif ($action == 'MEMBER_RESILIATE') { + } elseif ($action == 'MEMBER_RESILIATE' && $object instanceof Adherent) { '@phan-var-force Adherent $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "members")); @@ -1220,7 +1220,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'MEMBER_DELETE') { + } elseif ($action == 'MEMBER_DELETE' && $object instanceof Adherent) { '@phan-var-force Adherent $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "members")); @@ -1239,7 +1239,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'MEMBER_EXCLUDE') { + } elseif ($action == 'MEMBER_EXCLUDE' && $object instanceof Adherent) { '@phan-var-force Adherent $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "members")); @@ -1258,7 +1258,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'PROJECT_CREATE') { + } elseif ($action == 'PROJECT_CREATE' && $object instanceof Project) { '@phan-var-force Project $object'; // Projects // Load translation files required by the page @@ -1277,7 +1277,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'PROJECT_VALIDATE') { + } elseif ($action == 'PROJECT_VALIDATE' && $object instanceof Project) { '@phan-var-force Project $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "projects")); @@ -1295,7 +1295,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'PROJECT_MODIFY') { + } elseif ($action == 'PROJECT_MODIFY' && $object instanceof Project) { '@phan-var-force Project $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "projects")); @@ -1317,7 +1317,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'PROJECT_SENTBYMAIL') { + } elseif ($action == 'PROJECT_SENTBYMAIL' && $object instanceof Project) { '@phan-var-force Project $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "projects")); @@ -1335,7 +1335,7 @@ class InterfaceActionsAuto extends DolibarrTriggers // Parameters $object->sendtoid defined by caller //$object->sendtoid = array(); - } elseif ($action == 'PROJECT_DELETE') { + } elseif ($action == 'PROJECT_DELETE' && $object instanceof Project) { '@phan-var-force Project $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "projects")); @@ -1346,7 +1346,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("ProjectDeletedInDolibarr", $object->ref); $object->sendtoid = array(); - } elseif ($action == 'PROJECT_CLOSE') { + } elseif ($action == 'PROJECT_CLOSE' && $object instanceof Project) { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "projects")); @@ -1362,7 +1362,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'TASK_CREATE') { + } elseif ($action == 'TASK_CREATE' && $object instanceof Task) { '@phan-var-force Task $object'; // Project tasks // Load translation files required by the page @@ -1381,7 +1381,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'TASK_MODIFY') { + } elseif ($action == 'TASK_MODIFY' && $object instanceof Task) { '@phan-var-force Task $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "projects")); @@ -1399,7 +1399,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'TASK_DELETE') { + } elseif ($action == 'TASK_DELETE' && $object instanceof Task) { '@phan-var-force Task $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "projects")); @@ -1417,7 +1417,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = array(); - } elseif ($action == 'TICKET_ASSIGNED') { + } elseif ($action == 'TICKET_ASSIGNED' && $object instanceof Ticket) { '@phan-var-force Ticket $object'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "projects")); From 9349de974d8f829c897ee168e43e4fc7c31abdca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Nov 2025 13:14:19 +0100 Subject: [PATCH 03/11] Fix: missing the increase of pos_counter_print --- htdocs/blockedlog/ajax/block-add.php | 10 +++++++++- htdocs/main.inc.php | 16 +++++++++------- htdocs/takepos/receipt.php | 3 +++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/htdocs/blockedlog/ajax/block-add.php b/htdocs/blockedlog/ajax/block-add.php index f72f1885ef2..91e3ed0c86b 100644 --- a/htdocs/blockedlog/ajax/block-add.php +++ b/htdocs/blockedlog/ajax/block-add.php @@ -48,7 +48,11 @@ require '../../main.inc.php'; $id = GETPOSTINT('id'); $element = GETPOST('element', 'alpha'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); // Can be DOC_PREVIEW or DOC_DOWNLOAD + +if (! in_array($action, array('DOC_PREVIEW', 'DOC_DOWNLOAD'))) { + accessforbidden('Bad value for action. Must be DOC_PREVIEW or DOC_DOWNLOAD'); +} if ($element === 'facture') { restrictedArea($user, 'facture', $id, '', '', 'fk_soc', 'rowid', 0); @@ -74,6 +78,10 @@ if ($element === 'facture') { // Test on permission done in top of page $facture = new Facture($db); if ($facture->fetch($id) > 0) { + $facture->pos_print_counter += 1; + + $facture->update($user, 1); // We disable trigger here because we already call the trigger $action = DOC_PREVIEW or DOC_DOWNLOAD just after + $facture->call_trigger($action, $user); } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 383b0f0bec4..3973c556505 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -3678,7 +3678,9 @@ if (!function_exists("llxFooter")) { print ''."\n"; } - // JS wrapper to add log when clicking on download or preview + // JS wrapper to add an unalterable log when clicking on Download or Preview + // This is done on customer invoices only. + // This add a log and increase the pos_print_counter too (done by block-add.php). if (isModEnabled('blockedlog') && is_object($object) && !empty($object->id) && $object->id > 0) { if (in_array($object->element, array('facture')) && $object->statut > 0) { // Restrict for the moment to element 'facture' print "\n\n"; @@ -3689,9 +3691,9 @@ if (!function_exists("llxFooter")) { console.log("Call /blockedlog/ajax/block-add on a.documentpreview"); $.post('' , { - id:id; ?> - , element:'element) ?>' - , action:'DOC_PREVIEW' + id: id; ?> + , element: 'element) ?>' + , action: 'DOC_PREVIEW' , token: '' } ); @@ -3700,9 +3702,9 @@ if (!function_exists("llxFooter")) { console.log("Call /blockedlog/ajax/block-add a.documentdownload"); $.post('' , { - id:id; ?> - , element:'element) ?>' - , action:'DOC_DOWNLOAD' + id: id; ?> + , element: 'element) ?>' + , action: 'DOC_DOWNLOAD' , token: '' } ); diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index 70b7a4b291f..471ccda6e60 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -111,9 +111,12 @@ if ($facid > 0 && !GETPOST('specimen')) { } print ''; + // Record entry in blocked logs each time we print a receipt +// // This will also increase the counter of printings of the receipt // DOL_DOCUMENT_ROOT.'/blockedlog/ajax/block-add.php?id='.$object->id.'&element='.$object->element.'&action=DOC_PREVIEW&token='.newToken(); + print " '; - - print ''; - - $parameters = array(); - $reshook = $hookmanager->executeHooks('insertExtraFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - - print dol_get_fiche_end(); + $i++; } +print ''; +print ''; + +print ''; + +print ''; + +$parameters = array(); +$reshook = $hookmanager->executeHooks('insertExtraFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + +print dol_get_fiche_end(); + + // End of page llxFooter(); $db->close(); From 5ac31bb84ed81e71d3e44db0d2fd21e134ac6eb1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Nov 2025 14:39:48 +0100 Subject: [PATCH 08/11] css --- htdocs/theme/md/style.css.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index e3c1b3eb5e8..0369cb6fadb 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1980,6 +1980,7 @@ select.flat.selectlimit { .amountpaymentcomplete { color: var(--amountpaymentcomplete); font-weight: bold; + font-size: 1.7em; white-space: nowrap; } .amountpaymentcompletenoresize { @@ -1989,6 +1990,7 @@ select.flat.selectlimit { .amountremaintopay { color: var(--amountremaintopaycolor); font-weight: bold; + font-size: 1.7em; white-space: nowrap; } .amountremaintopaynoresize { @@ -1997,6 +1999,7 @@ select.flat.selectlimit { } .amountremaintopayback { font-weight: bold; + font-size: 1.7em; white-space: nowrap; } .amountremaintopaybacknoresize { @@ -2005,7 +2008,7 @@ select.flat.selectlimit { .amountpaymentneutral { color: var(--amountremaintopaybackcolor); font-weight: bold; - font-size: 1.4em; + font-size: 1.7em; white-space: nowrap; } .amountpaymentneutralnoresize { @@ -4246,7 +4249,7 @@ div.divButAction { margin-bottom: 1.4em; } div.tabsAction { - margin: 20px 0em 20px 0em; + margin: 30px 0em 30px 0em; padding: 0em 0em; text-align: right; } @@ -4557,7 +4560,7 @@ table.nointerlines tr:not(:last-child) td { /* Management of border radius */ -table.noborder:not(.cal_month, .paymenttable) { +table.noborder:not(.cal_month, .paymenttable, .margintable) { border-radius: px; } table.noborder.cal_month { From 27f4fef048c3078a654ceaea7c49842c6ed5c8ef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Nov 2025 15:04:22 +0100 Subject: [PATCH 09/11] Solve confusion between tag of project/user and thirdparty in project list --- htdocs/langs/en_US/categories.lang | 2 + htdocs/projet/list.php | 93 +++++++++++++++++++++++++----- 2 files changed, 80 insertions(+), 15 deletions(-) diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 58cd226b200..06d7c7a92a8 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -46,6 +46,8 @@ SuppliersCategoryShort=Vendors tag/category CustomersCategoryShort=Customers tag/category ProductsCategoryShort=Products tag/category MembersCategoryShort=Members tag/category +UsersCategoryShort=Users tag/category +ProjectsCategoryShort=Projects tag/category SuppliersCategoriesShort=Vendors tags/categories CustomersCategoriesShort=Customers tags/categories ProspectsCategoriesShort=Prospects tags/categories diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 795262320bb..1a7d2476aea 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -36,6 +36,13 @@ // Load Dolibarr environment require '../main.inc.php'; +/** + * @var Conf $conf + * @var DoliDB $db + * @var HookManager $hookmanager + * @var Translate $langs + * @var User $user + */ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -47,14 +54,6 @@ if (isModEnabled('category')) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; } -/** - * @var Conf $conf - * @var DoliDB $db - * @var HookManager $hookmanager - * @var Translate $langs - * @var User $user - */ - // Load translation files required by the page $langs->loadLangs(array('projects', 'companies', 'commercial')); if (isModEnabled('eventorganization') && $conf->eventorganization->enabled) { @@ -124,6 +123,15 @@ $search_price_registration = GETPOST("search_price_registration", 'alpha'); $search_price_booth = GETPOST("search_price_booth", 'alpha'); $search_login = GETPOST('search_login', 'alpha'); $search_import_key = GETPOST('search_import_key', 'alpha'); + +$searchCategoryUserOperator = 0; +if (GETPOSTISSET('formfilteraction')) { + $searchCategoryUserOperator = GETPOSTINT('search_category_user_operator'); +} elseif (getDolGlobalString('MAIN_SEARCH_CAT_USER_OR_BY_DEFAULT')) { + $searchCategoryUserOperator = getDolGlobalString('MAIN_SEARCH_CAT_USER_OR_BY_DEFAULT'); +} +$searchCategoryUserList = GETPOST('search_category_user_list', 'array:int'); + $searchCategoryCustomerOperator = 0; if (GETPOSTISSET('formfilteraction')) { $searchCategoryCustomerOperator = GETPOSTINT('search_category_customer_operator'); @@ -131,6 +139,7 @@ if (GETPOSTISSET('formfilteraction')) { $searchCategoryCustomerOperator = getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT'); } $searchCategoryCustomerList = GETPOST('search_category_customer_list', 'array:int'); + $search_omitChildren = 0; if (getDolGlobalInt('PROJECT_ENABLE_SUB_PROJECT')) { $search_omitChildren = GETPOST('search_omitChildren', 'alpha') == 'on' ? 1 : 0; @@ -187,9 +196,11 @@ $search_date_modif_endday = GETPOSTINT('search_date_modif_endday'); $search_date_modif_end = GETPOSTDATE('search_date_modif_end', 'end'); // Use tzserver $search_category_array = array(); +$search_category_user_array = array(); if (isModEnabled('category')) { $search_category_array = GETPOST("search_category_".Categorie::TYPE_PROJECT."_list", "array"); + $search_category_user_array = GETPOST("search_category_".Categorie::TYPE_USER."_list", "array"); } if (GETPOSTISARRAY('search_status') || GETPOST('search_status_multiselect')) { @@ -473,6 +484,7 @@ if (empty($reshook)) { $toselect = array(); $search_array_options = array(); $search_category_array = array(); + $search_category_user_array = array(); } @@ -806,7 +818,38 @@ if (getDolGlobalInt('PROJECT_ENABLE_SUB_PROJECT')) { } } -// Search for tag/category ($searchCategoryProjectList is an array of ID) +// Search for tag/category of User ($searchCategoryUserList is an array of ID) +$searchCategoryUserSqlList = $search_category_user_array; +$searchCategoryUserOperator = 0; +if (!empty($searchCategoryUserList)) { + $searchCategoryUserSqlList = array(); + $listofcategoryid = ''; + foreach ($searchCategoryUserList as $searchCategoryUser) { + if (intval($searchCategoryUser) == -2) { + $searchCategoryUserSqlList[] = "NOT EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user)"; + } elseif (intval($searchCategoryUser) > 0) { + if ($searchCategoryUserOperator == 0) { + $searchCategoryUserSqlList[] = " EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user AND ck.fk_categorie = ".((int) $searchCategoryUser).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryUser); + } + } + } + if ($listofcategoryid) { + $searchCategoryUserSqlList[] = " EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_User AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; + } + if ($searchCategoryUserOperator == 1) { + if (!empty($searchCategoryUserSqlList)) { + $sql .= " AND (".implode(' OR ', $searchCategoryUserSqlList).")"; + } + } else { + if (!empty($searchCategoryUserSqlList)) { + $sql .= " AND (".implode(' AND ', $searchCategoryUserSqlList).")"; + } + } +} + +// Search for tag/category or Project ($searchCategoryProjectList is an array of ID) $searchCategoryProjectList = $search_category_array; $searchCategoryProjectOperator = 0; if (!empty($searchCategoryProjectList)) { @@ -836,6 +879,9 @@ if (!empty($searchCategoryProjectList)) { } } } + +// Search for tag/category of Customer Third party ($searchCategoryCustomerList is an array of ID) +/* $searchCategoryCustomerSqlList = array(); if ($searchCategoryCustomerOperator == 1) { $existsCategoryCustomerList = array(); @@ -880,6 +926,8 @@ if ($searchCategoryCustomerOperator == 1) { $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")"; } } +*/ + // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -1086,11 +1134,21 @@ if ($search_date_modif_endday) { if ($search_date_modif_end) { $param .= '&search_date_modif_end=' . urlencode((string) $search_date_modif_end); } +if (!empty($search_category_user_array)) { + foreach ($search_category_user_array as $tmpval) { + $param .= '&search_categegory_user_list[]='.urlencode($tmpval); + } +} if (!empty($search_category_array)) { foreach ($search_category_array as $tmpval) { $param .= '&search_categegory_project_list[]='.urlencode($tmpval); } } +if (!empty($searchCategoryCustomerList)) { + foreach ($searchCategoryCustomerList as $searchCategoryCustomer) { + $param .= "&search_category_customer_list[]=".urlencode($searchCategoryCustomer); + } +} if ($search_id != '') { $param .= '&search_id='.urlencode($search_id); } @@ -1172,9 +1230,6 @@ if ($search_login) { if ($search_import_key) { $param .= '&search_import_key='.urlencode($search_import_key); } -foreach ($searchCategoryCustomerList as $searchCategoryCustomer) { - $param .= "&search_category_customer_list[]=".urlencode($searchCategoryCustomer); -} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -1281,6 +1336,14 @@ if (!$user->hasRight('user', 'user', 'lire')) { $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, null, 0, $includeonly, '', '0', 0, 0, '', 0, '', 'maxwidth300 widthcentpercentminusx'); $moreforfilter .= ''; +// Filter on user categories +if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) { + $langs->load("categories"); + $formcategory = new FormCategory($db); + $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_USER, $search_category_user_array, 'minwidth200imp minwidth200 widthcentpercentminusx', -1, 1, 1, $langs->trans("UsersCategoryShort")); +} + + $moreforfilter .= '
'; $tmptitle = $langs->trans('ProjectsWithThisContact'); $moreforfilter .= img_picto($tmptitle, 'contact', 'class="pictofixedwidth"').$form->select_contact(0, $search_project_contact ? $search_project_contact : '', 'search_project_contact', $tmptitle, '', '', 0, 'maxwidth300 widthcentpercentminusx'); @@ -1296,16 +1359,16 @@ if ($user->hasRight('user', 'user', 'lire')) { $moreforfilter .= '
'; } -// Filter on categories +// Filter on project categories if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) { $formcategory = new FormCategory($db); - $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array, 'minwidth300imp minwidth300 widthcentpercentminusx'); + $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array, 'minwidth200imp minwidth200 widthcentpercentminusx', -1, 1, 1, $langs->trans("ProjectsCategoryShort")); } // Filter on customer categories if (getDolGlobalString('MAIN_SEARCH_CATEGORY_CUSTOMER_ON_PROJECT_LIST') && isModEnabled("category") && $user->hasRight('categorie', 'lire')) { $formcategory = new FormCategory($db); - $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_CUSTOMER, $searchCategoryCustomerList, 'minwidth300', $searchCategoryCustomerList ? $searchCategoryCustomerList : 0); + $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_CUSTOMER, $searchCategoryCustomerList, 'minwidth200imp minwidth200 widthcentpercentminusx', $searchCategoryCustomerList ? $searchCategoryCustomerList : 0); } // alert on late date From 53337fb848e94250ccb478ba3d0734e597ee0f1c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Nov 2025 15:51:44 +0100 Subject: [PATCH 10/11] Fix type --- htdocs/adherents/class/adherent_type.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 3d08bf8edea..f03d1099c41 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -674,7 +674,7 @@ class AdherentType extends CommonObject * Return the array of all amounts per membership type id * * @param int $status Filter on status of type - * @return array Array of membership type + * @return array Array of membership type */ public function amountByType($status = null) { From c26e37cd9b27e25879207c69f2e1700fc1e02a65 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Nov 2025 16:59:10 +0100 Subject: [PATCH 11/11] Fix edit color --- htdocs/categories/edit.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 62414a7b59a..33d759d1bc9 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -23,7 +23,7 @@ /** * \file htdocs/categories/edit.php * \ingroup category - * \brief Page d'edition de categorie produit + * \brief Page to edit a category */ // Load Dolibarr environment @@ -54,7 +54,7 @@ $dol_openinpopup = GETPOST('dol_openinpopup', 'aZ'); $socid = GETPOSTINT('socid'); $label = (string) GETPOST('label', 'alphanohtml'); $description = (string) GETPOST('description', 'restricthtml'); -$color = preg_replace('/^#/', '', preg_replace('/[^0-9a-f#]/i', '', (string) GETPOST('color', 'alphanohtml'))); +$color = preg_replace('/[^0-9a-f]/i', '', (string) GETPOST('color', 'alphanohtml')); $position = GETPOSTINT('position'); $visible = GETPOSTINT('visible'); $parent = GETPOSTINT('parent'); @@ -91,6 +91,7 @@ $error = 0; /* * Actions */ + $parameters = array('id' => $id, 'ref' => $ref, 'cancel' => $cancel, 'backtopage' => $backtopage, 'socid' => $socid, 'label' => $label, 'description' => $description, 'color' => $color, 'position' => $position, 'visible' => $visible, 'parent' => $parent); // Note that $action and $object may be modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);