From 9ae5c03f28ce1f715a66bb9f0452f7932c199efa Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 2 Dec 2024 09:47:43 +0100 Subject: [PATCH 01/69] FIX #32186 --- htdocs/fourn/facture/list.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index e6597b29ce3..086995608dd 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -307,7 +307,6 @@ if (empty($reshook)) { $search_categ_sup = 0; $filter = ''; $option = ''; - $socid = ""; } // Mass actions From d4236332661beb85ae94f8647ebfe2e55f6f5c83 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 2 Dec 2024 10:36:54 +0100 Subject: [PATCH 02/69] FIX phan errors --- htdocs/fourn/commande/list.php | 1 + htdocs/fourn/facture/card.php | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 5a80dc98f81..d806ef812d3 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -511,6 +511,7 @@ if (empty($reshook)) { } $tva_tx = $lines[$i]->tva_tx; + // @phan-suppress-next-line PhanTypeMismatchArgumentInternal if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) { $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 609270a284a..fe3507a8344 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1339,6 +1339,7 @@ if (empty($reshook)) { } $tva_tx = $lines[$i]->tva_tx; + // @phan-suppress-next-line PhanTypeMismatchArgumentInternal if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) { $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; } From 6aa70da43f232f50170074ba4cf2bce6d0ecd680 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 2 Dec 2024 11:24:03 +0100 Subject: [PATCH 03/69] FIX wrong "fournisseur" var value checking --- htdocs/societe/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 53842b8b2d8..28b3b7250a5 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1388,7 +1388,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio if (getDolGlobalString('THIRDPARTY_SUPPLIER_BY_DEFAULT')) { $default = 1; } - print $form->selectyesno("fournisseur", (GETPOSTINT('fournisseur') != '' ? GETPOSTINT('fournisseur') : (GETPOST("type") == '' ? $default : $object->fournisseur)), 1, 0, (GETPOST("type") == '' ? 1 : 0), 1); + print $form->selectyesno("fournisseur", (GETPOSTINT('fournisseur') > 0 ? GETPOSTINT('fournisseur') : (GETPOST("type") == '' ? $default : $object->fournisseur)), 1, 0, (GETPOST("type") == '' ? 1 : 0), 1); print ''; From 2beb6e1e3495fd43d4c26037cb8a38936cfaed70 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 2 Dec 2024 11:38:17 +0100 Subject: [PATCH 04/69] FIX uniformize code --- htdocs/supplier_proposal/list.php | 40 ++++++++++++++++++------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 6622a28fec3..d8bc7165389 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -65,8 +65,8 @@ $mode = GETPOST('mode', 'alpha'); $search_user = GETPOST('search_user', 'intcomma'); $search_sale = GETPOST('search_sale', 'intcomma'); $search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); -$search_societe = GETPOST('search_societe', 'alpha'); -$search_societe_alias = GETPOST('search_societe_alias', 'alpha'); +$search_company = GETPOST('search_company', 'alpha'); +$search_company_alias = GETPOST('search_company_alias', 'alpha'); $search_login = GETPOST('search_login', 'alpha'); $search_town = GETPOST('search_town', 'alpha'); $search_zip = GETPOST('search_zip', 'alpha'); @@ -236,8 +236,8 @@ if (empty($reshook)) { $search_user = ''; $search_sale = ''; $search_ref = ''; - $search_societe = ''; - $search_societe_alias = ''; + $search_company = ''; + $search_company_alias = ''; $search_montant_ht = ''; $search_montant_vat = ''; $search_montant_ttc = ''; @@ -294,6 +294,14 @@ $formcompany = new FormCompany($db); $now = dol_now(); +if ($socid > 0) { + $soc = new Societe($db); + $soc->fetch($socid); + if (empty($search_company)) { + $search_company = $soc->name; + } +} + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields @@ -362,14 +370,14 @@ if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) { if ($search_ref) { $sql .= natural_search('sp.ref', $search_ref); } -if (empty($arrayfields['s.name_alias']['checked']) && $search_societe) { - $sql .= natural_search(array("s.nom", "s.name_alias"), $search_societe); +if (empty($arrayfields['s.name_alias']['checked']) && $search_company) { + $sql .= natural_search(array("s.nom", "s.name_alias"), $search_company); } else { - if ($search_societe) { - $sql .= natural_search('s.nom', $search_societe); + if ($search_company) { + $sql .= natural_search('s.nom', $search_company); } - if ($search_societe_alias) { - $sql .= natural_search('s.name_alias', $search_societe_alias); + if ($search_company_alias) { + $sql .= natural_search('s.name_alias', $search_company_alias); } } if ($search_login) { @@ -571,11 +579,11 @@ if ($resql) { if ($search_ref) { $param .= '&search_ref='.urlencode($search_ref); } - if ($search_societe) { - $param .= '&search_societe='.urlencode($search_societe); + if ($search_company) { + $param .= '&search_company='.urlencode($search_company); } - if ($search_societe_alias) { - $param .= '&search_societe_alias='.urlencode($search_societe_alias); + if ($search_company_alias) { + $param .= '&search_company_alias='.urlencode($search_company_alias); } if ($search_user > 0) { $param .= '&search_user='.urlencode((string) ($search_user)); @@ -742,12 +750,12 @@ if ($resql) { } if (!empty($arrayfields['s.nom']['checked'])) { print ''; - print ''; + print ''; print ''; } if (!empty($arrayfields['s.name_alias']['checked'])) { print ''; - print ''; + print ''; print ''; } if (!empty($arrayfields['s.town']['checked'])) { From 3e3f9c755db2f8207f8f3da20424e120a5289267 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 2 Dec 2024 12:10:39 +0100 Subject: [PATCH 05/69] FIX Check "$search_sale" only if it's an internal user --- htdocs/comm/propal/list.php | 3 ++- htdocs/compta/facture/list.php | 3 ++- htdocs/fourn/commande/list.php | 3 ++- htdocs/fourn/facture/list.php | 3 ++- htdocs/supplier_proposal/list.php | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 9ad46ac19d6..9977b93927c 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -286,7 +286,8 @@ foreach ($object->fields as $key => $val) { } }*/ -if (!$user->hasRight('societe', 'client', 'voir')) { +// Check only if it's an internal user +if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; } diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 29225c9e178..c48e14971de 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -304,7 +304,8 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); '@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan -if (!$user->hasRight('societe', 'client', 'voir')) { +// Check only if it's an internal user +if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; } diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index d806ef812d3..c47a099ae47 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -217,7 +217,8 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); $error = 0; -if (!$user->hasRight('societe', 'client', 'voir')) { +// Check only if it's an internal user +if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; } diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 086995608dd..c7e10e2317c 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -226,7 +226,8 @@ if ((!$user->hasRight("fournisseur", "facture", "lire") && !getDolGlobalString(' accessforbidden(); } -if (!$user->hasRight('societe', 'client', 'voir')) { +// Check only if it' an internal user +if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; } diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index d8bc7165389..3e8b03d3d22 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -198,7 +198,8 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); '@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan -if (!$user->hasRight('societe', 'client', 'voir')) { +// Check only if it's an internal user +if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; } From a3193a08bce1df62f5f4af092ff001eb3a089ea1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 6 Jan 2025 13:56:32 +0100 Subject: [PATCH 06/69] FIX merge problem --- htdocs/fourn/commande/list.php | 4 ---- htdocs/fourn/facture/card.php | 4 ---- 2 files changed, 8 deletions(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index e399ce50745..7616d21227f 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -512,12 +512,8 @@ if (empty($reshook)) { } $tva_tx = $lines[$i]->tva_tx; -<<<<<<< HEAD // @phan-suppress-next-line PhanTypeMismatchArgumentInternal - if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) { -======= if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', (string) $tva_tx)) { ->>>>>>> branch '20.0' of git@github.com:Dolibarr/dolibarr.git $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index b2de69e162e..a7d7df70c25 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1339,12 +1339,8 @@ if (empty($reshook)) { } $tva_tx = $lines[$i]->tva_tx; -<<<<<<< HEAD // @phan-suppress-next-line PhanTypeMismatchArgumentInternal - if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) { -======= if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', (string) $tva_tx)) { ->>>>>>> branch '20.0' of git@github.com:Dolibarr/dolibarr.git $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; } From 34409e8a4dd465556208488dec2be2b8ca8ebe15 Mon Sep 17 00:00:00 2001 From: vmaury Date: Sat, 11 Jan 2025 07:33:08 +0100 Subject: [PATCH 07/69] Fix 31370 Pb with external account --- htdocs/comm/propal/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 59bea619be2..4a5a5e69795 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -286,7 +286,7 @@ foreach ($object->fields as $key => $val) { } }*/ -if (!$user->hasRight('societe', 'client', 'voir')) { +if ($socid == 0 && !$user->hasRight('societe', 'client', 'voir')) { // add VMA $search_sale = $user->id; } From 40e22cc40eeb811fad95c1949e8eb85b5e505e92 Mon Sep 17 00:00:00 2001 From: vmaury Date: Sat, 11 Jan 2025 12:31:35 +0100 Subject: [PATCH 08/69] Fix 31370 Pb with external account --- htdocs/comm/propal/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 4a5a5e69795..96f5da1ce5f 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -286,7 +286,7 @@ foreach ($object->fields as $key => $val) { } }*/ -if ($socid == 0 && !$user->hasRight('societe', 'client', 'voir')) { // add VMA +if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; } From 09185331720be2a4f381cb99e4762170355a5626 Mon Sep 17 00:00:00 2001 From: uvaldenaire-opendsi Date: Mon, 13 Jan 2025 11:54:58 +0100 Subject: [PATCH 09/69] NEW add option to not prefill qty line at shipment creation --- htdocs/admin/expedition.php | 8 ++++++++ htdocs/expedition/card.php | 25 ++++++++++++++++++++----- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/fr_FR/admin.lang | 1 + 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 3fcfa7c7b36..5ad30fc921f 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -490,6 +490,14 @@ print ''; print ajax_constantonoff('EXPEDITION_ALLOW_ONLINESIGN', array(), null, 0, 0, 0, 2, 0, 1, '', '', 'inline-block', 0, $langs->trans("WarningOnlineSignature")); print ''; +// Pre fill shipment qty option +print ''; +print ''.$langs->trans("DontPrefillShipmentQty"); +print ''; +print ''; +print ajax_constantonoff('SHIPMENT_DONT_PREFILL_QTY', array(), null, 0, 0, 0, 2, 0, 1, '', '', 'inline-block', 0, ''); +print ''; + print ''; print $form->buttonsSaveCancel("Modify", ''); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 8c365e7bee5..1b74583596c 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1360,7 +1360,11 @@ if ($action == 'create') { $deliverableQty = GETPOSTINT('qtyl'.$indiceAsked); } print ''; - print ''; + $qtylValue = $deliverableQty; + if (getDolGlobalBool('SHIPMENT_DONT_PREFILL_QTY', false)) { + $qtylValue = ''; + } + print ''; } else { if (getDolGlobalString('SHIPMENT_GETS_ALL_ORDER_PRODUCTS')) { print ''; @@ -1491,7 +1495,11 @@ if ($action == 'create') { print ''; print ''; - print ''; + $qtylValue = $deliverableQty; + if (getDolGlobalBool('SHIPMENT_DONT_PREFILL_QTY', false)) { + $qtylValue = ''; + } + print ''; print ''; print ''; @@ -1604,8 +1612,11 @@ if ($action == 'create') { if (GETPOSTISSET($inputName)) { $deliverableQty = GETPOSTINT($inputName); } - - print ''; + $qtylValue = $deliverableQty; + if (getDolGlobalBool('SHIPMENT_DONT_PREFILL_QTY', false)) { + $qtylValue = ''; + } + print ''; print ''; } else { if (getDolGlobalString('SHIPMENT_GETS_ALL_ORDER_PRODUCTS')) { @@ -1729,7 +1740,11 @@ if ($action == 'create') { $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]; print ''; - print ''; + $qtylValue = $deliverableQty; + if (getDolGlobalBool('SHIPMENT_DONT_PREFILL_QTY', false)) { + $qtylValue = ''; + } + print ''; print ''; print ''; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 436c7d2ddd2..bca02410227 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1805,6 +1805,7 @@ SendingsNumberingModules=Sendings numbering modules SendingsAbility=Support shipping sheets for customer deliveries NoNeedForDeliveryReceipts=In most cases, shipping sheets are used both as sheets for customer deliveries (list of products to send) and sheets that are received and signed by customer. Hence the product deliveries receipt is a duplicated feature and is rarely activated. FreeLegalTextOnShippings=Free text on shipments +DontPrefillShipmentQty = Don't prefill lines quantities at shipment creation ##### Deliveries ##### DeliveryOrderNumberingModules=Products deliveries receipt numbering module DeliveryOrderModel=Products deliveries receipt model diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index b5d380188cb..6cfe8774cc5 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1800,6 +1800,7 @@ SendingsNumberingModules=Modèles de numérotation des expéditions SendingsAbility=Prise en charge des bons d'expédition pour les livraisons clients NoNeedForDeliveryReceipts=Dans le plupart des cas, la fiche expédition est utilisée en tant que bon d'expédition (liste des produits expédiés) et bon de livraison (signée par le client). Le bon de réception est un doublon de fonctionnalité et est rarement utilisé. FreeLegalTextOnShippings=Mention complémentaire sur les expéditions +DontPrefillShipmentQty = Ne pas pré-remplir les quantités des lignes à la création d'une expédition ##### Deliveries ##### DeliveryOrderNumberingModules=Modèle de numérotation des bons de réception client DeliveryOrderModel=Modèle de bon de réception client From cf0c04c6ee870b36ff82f3e2ed4f00d225286a92 Mon Sep 17 00:00:00 2001 From: vmaury Date: Mon, 13 Jan 2025 11:58:16 +0100 Subject: [PATCH 10/69] Fix 31370 Pb with external account --- htdocs/comm/index.php | 46 +++++++++---------- htdocs/comm/propal/class/propal.class.php | 6 +-- .../comm/propal/class/propalestats.class.php | 12 ++--- htdocs/commande/class/commande.class.php | 10 ++-- htdocs/commande/class/commandestats.class.php | 12 ++--- htdocs/commande/index.php | 16 +++---- htdocs/commande/list.php | 5 +- htdocs/compta/facture/class/facture.class.php | 6 +-- .../facture/class/facturestats.class.php | 14 +++--- htdocs/compta/facture/list.php | 8 ++-- htdocs/compta/index.php | 6 +-- htdocs/contrat/class/contrat.class.php | 6 +-- htdocs/contrat/list.php | 4 +- htdocs/core/boxes/box_actions.php | 4 +- htdocs/core/boxes/box_actions_future.php | 4 +- htdocs/core/boxes/box_activity.php | 12 ++--- htdocs/core/boxes/box_clients.php | 4 +- htdocs/core/boxes/box_commandes.php | 4 +- htdocs/core/boxes/box_contacts.php | 4 +- htdocs/core/boxes/box_contracts.php | 4 +- ...box_customers_outstanding_bill_reached.php | 4 +- htdocs/core/boxes/box_factures.php | 4 +- htdocs/core/boxes/box_factures_fourn.php | 4 +- htdocs/core/boxes/box_factures_fourn_imp.php | 4 +- htdocs/core/boxes/box_factures_imp.php | 4 +- htdocs/core/boxes/box_ficheinter.php | 4 +- htdocs/core/boxes/box_fournisseurs.php | 4 +- .../boxes/box_graph_propales_permonth.php | 2 +- htdocs/core/boxes/box_propales.php | 4 +- htdocs/core/boxes/box_prospect.php | 4 +- htdocs/core/boxes/box_services_contracts.php | 2 +- htdocs/core/boxes/box_services_expired.php | 4 +- htdocs/core/boxes/box_shipments.php | 4 +- htdocs/core/boxes/box_supplier_orders.php | 4 +- ...box_supplier_orders_awaiting_reception.php | 4 +- htdocs/core/lib/invoice.lib.php | 36 ++++++++------- htdocs/core/lib/order.lib.php | 6 +-- htdocs/core/lib/propal.lib.php | 8 ++-- .../fichinter/class/fichinterstats.class.php | 10 ++-- htdocs/fichinter/list.php | 2 +- .../class/fournisseur.commande.class.php | 4 +- .../fourn/class/fournisseur.facture.class.php | 4 +- .../class/supplier_proposal.class.php | 8 ++-- htdocs/ticket/class/ticket.class.php | 6 +-- 44 files changed, 165 insertions(+), 162 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 01c96b952f2..c45c7cb0fe6 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -140,13 +140,13 @@ if (isModEnabled("propal") && $user->hasRight("propal", "lire")) { $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")"; $sql .= " AND p.fk_soc = s.rowid"; $sql .= " AND p.fk_statut = ".Propal::STATUS_DRAFT; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($socid) { @@ -239,13 +239,13 @@ if (isModEnabled('supplier_proposal') && $user->hasRight("supplier_proposal", "l $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE p.entity IN (".getEntity($supplierproposalstatic->element).")"; $sql .= " AND p.fk_statut = ".SupplierProposal::STATUS_DRAFT; $sql .= " AND p.fk_soc = s.rowid"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($socid) { @@ -336,13 +336,13 @@ if (isModEnabled('order') && $user->hasRight('commande', 'lire')) { $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")"; $sql .= " AND c.fk_statut = ".Commande::STATUS_DRAFT; $sql .= " AND c.fk_soc = s.rowid"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($socid) { @@ -436,13 +436,13 @@ if ((isModEnabled("fournisseur") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMO $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE cf.entity IN (".getEntity($supplierorderstatic->element).")"; $sql .= " AND cf.fk_statut = ".CommandeFournisseur::STATUS_DRAFT; $sql .= " AND cf.fk_soc = s.rowid"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($socid) { @@ -534,7 +534,7 @@ if (isModEnabled('intervention')) { $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE f.entity IN (".getEntity('intervention').")"; @@ -543,7 +543,7 @@ if (isModEnabled('intervention')) { if ($socid) { $sql .= " AND f.fk_soc = ".((int) $socid); } - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } @@ -617,12 +617,12 @@ if (isModEnabled("societe") && $user->hasRight('societe', 'lire')) { $sql .= ", s.canvas"; $sql .= ", s.datec, s.tms"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")"; $sql .= " AND s.client IN (".Societe::CUSTOMER.", ".Societe::PROSPECT.", ".Societe::CUSTOMER_AND_PROSPECT.")"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } // Add where from hooks @@ -725,7 +725,7 @@ if (isModEnabled('propal')) { $sql .= " AND c.fk_soc = s.rowid"; // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; } // Search on sale representative @@ -820,7 +820,7 @@ if (isModEnabled('order')) { $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.fk_soc = s.rowid"; @@ -829,7 +829,7 @@ if (isModEnabled('order')) { if ($socid) { $sql .= " AND c.fk_soc = ".((int) $socid); } - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= " ORDER BY c.tms DESC"; @@ -908,12 +908,12 @@ if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $use $sql .= ", s.canvas"; $sql .= ", s.datec as dc, s.tms as dm"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")"; $sql .= " AND s.fournisseur = ".Societe::SUPPLIER; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } // Add where from hooks @@ -1023,13 +1023,13 @@ if (isModEnabled('contract') && $user->hasRight("contrat", "lire") && 0) { // TO $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."contrat as c"; $sql .= ", ".MAIN_DB_PREFIX."product as p"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.entity IN (".getEntity($staticcontrat->element).")"; $sql .= " AND c.fk_soc = s.rowid"; $sql .= " AND c.fk_product = p.rowid"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($socid) { @@ -1098,13 +1098,13 @@ if (isModEnabled("propal") && $user->hasRight("propal", "lire")) { $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")"; $sql .= " AND p.fk_soc = s.rowid"; $sql .= " AND p.fk_statut = ".Propal::STATUS_VALIDATED; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($socid) { @@ -1217,13 +1217,13 @@ if (isModEnabled('order') && $user->hasRight('commande', 'lire')) { $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")"; $sql .= " AND c.fk_soc = s.rowid"; $sql .= " AND c.fk_statut IN (".Commande::STATUS_VALIDATED.", ".Commande::STATUS_SHIPMENTONPROCESS.")"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($socid) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a27eca21f18..44fd80ca8b7 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2861,7 +2861,7 @@ class Propal extends CommonObject // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; } // Search on sale representative @@ -3384,7 +3384,7 @@ class Propal extends CommonObject } // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; } // Search on sale representative @@ -3561,7 +3561,7 @@ class Propal extends CommonObject // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; } // Search on sale representative diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index 5321886f0fb..ace66cd25bd 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -122,7 +122,7 @@ class PropaleStats extends Stats $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, COUNT(*) as nb"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; @@ -147,7 +147,7 @@ class PropaleStats extends Stats $sql = "SELECT date_format(".$this->field_date.",'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; @@ -171,7 +171,7 @@ class PropaleStats extends Stats $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, SUM(p.".$this->field.")"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; @@ -196,7 +196,7 @@ class PropaleStats extends Stats $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, AVG(p.".$this->field.")"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; @@ -219,7 +219,7 @@ class PropaleStats extends Stats $sql = "SELECT date_format(".$this->field_date.",'%Y') as year, COUNT(*) as nb, SUM(".$this->field.") as total, AVG(".$this->field.") as avg"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; @@ -247,7 +247,7 @@ class PropaleStats extends Stats $sql .= " FROM ".$this->from; $sql .= " INNER JOIN ".$this->from_line." ON p.rowid = tl.fk_propal"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."product as product ON tl.fk_product = product.rowid"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 2ac0d52671a..70a7656fa0b 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2715,16 +2715,16 @@ class Commande extends CommonOrder $sql = "SELECT s.rowid, s.nom as name, s.client,"; $sql .= " c.rowid as cid, c.ref"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", sc.fk_soc, sc.fk_user"; } $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.entity IN (".getEntity('commande').")"; $sql .= " AND c.fk_soc = s.rowid"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($socid) { @@ -3551,7 +3551,7 @@ class Commande extends CommonOrder $sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.date_livraison as delivery_date, c.fk_statut, c.total_ht"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc"; $sql .= " WHERE sc.fk_user = ".((int) $user->id); $clause = " AND"; @@ -4059,7 +4059,7 @@ class Commande extends CommonOrder $sql = "SELECT count(co.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as co"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON co.fk_soc = s.rowid"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql .= " WHERE sc.fk_user = ".((int) $user->id); $clause = "AND"; diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index f9f49ef7ada..332bddd1698 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -123,7 +123,7 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_commande,'%m') as dm, COUNT(*) as nb"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; @@ -148,7 +148,7 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_commande,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; @@ -172,7 +172,7 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_commande,'%m') as dm, SUM(c.".$this->field.")"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; @@ -197,7 +197,7 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_commande,'%m') as dm, AVG(c.".$this->field.")"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; @@ -220,7 +220,7 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_commande,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; @@ -246,7 +246,7 @@ class CommandeStats extends Stats $sql .= " FROM ".$this->from; $sql .= " INNER JOIN ".$this->from_line." ON c.rowid = tl.fk_commande"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."product as product ON tl.fk_product = product.rowid"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index 61be815d34d..ff9d1a3a6e2 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -98,7 +98,7 @@ if (isModEnabled('order')) { $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.fk_soc = s.rowid"; @@ -107,7 +107,7 @@ if (isModEnabled('order')) { if ($socid) { $sql .= " AND c.fk_soc = ".((int) $socid); } - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } @@ -164,7 +164,7 @@ $sql .= ", s.code_client"; $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; -if (!$user->hasRight('societe', 'client', 'voir')) { +if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.fk_soc = s.rowid"; @@ -173,7 +173,7 @@ $sql .= " AND c.entity IN (".getEntity('commande').")"; if ($socid) { $sql .= " AND c.fk_soc = ".((int) $socid); } -if (!$user->hasRight('societe', 'client', 'voir')) { +if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= " ORDER BY c.tms DESC"; @@ -250,7 +250,7 @@ if (isModEnabled('order')) { $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.fk_soc = s.rowid"; @@ -259,7 +259,7 @@ if (isModEnabled('order')) { if ($socid) { $sql .= " AND c.fk_soc = ".((int) $socid); } - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= " ORDER BY c.rowid DESC"; @@ -339,7 +339,7 @@ if (isModEnabled('order')) { $sql .= ", s.canvas"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.fk_soc = s.rowid"; @@ -348,7 +348,7 @@ if (isModEnabled('order')) { if ($socid) { $sql .= " AND c.fk_soc = ".((int) $socid); } - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= " ORDER BY c.rowid DESC"; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 3db787bbcc2..b60cb2e58fe 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -906,9 +906,8 @@ $sql .= ' AND c.entity IN ('.getEntity('commande').')'; if ($socid > 0) { $sql .= ' AND s.rowid = '.((int) $socid); } - // Restriction on sale representative -if (!$permissiontoreadallthirdparty) { +if (empty($user->socid) && !$permissiontoreadallthirdparty) { $sql .= " AND (EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user = ".((int) $user->id).")"; if (getDolGlobalInt('MAIN_SEE_SUBORDINATES') && $userschilds) { $sql .= " OR EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user IN (".$db->sanitize(implode(',', $userschilds))."))"; @@ -1619,7 +1618,7 @@ if (!empty($arrayfields['p.title']['checked'])) { // Thirpdarty if (!empty($arrayfields['s.nom']['checked'])) { print ''; - print ''; + print 'socid) ? " disabled" : "").'>'; print ''; } // Alias diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 375a9eb087a..76ca915f9a8 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4753,7 +4753,7 @@ class Facture extends CommonInvoice } // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; } // Search on sale representative @@ -4946,7 +4946,7 @@ class Facture extends CommonInvoice $sql = "SELECT f.rowid, f.date_lim_reglement as datefin, f.fk_statut as status, f.total_ht"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc"; $sql .= " WHERE sc.fk_user = ".((int) $user->id); $clause = " AND"; @@ -5194,7 +5194,7 @@ class Facture extends CommonInvoice $sql = "SELECT count(f.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql .= " WHERE sc.fk_user = ".((int) $user->id); $clause = "AND"; diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index 6476235c9b2..0a02a2294c6 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -136,7 +136,7 @@ class FactureStats extends Stats $sql = "SELECT date_format(f.datef,'%m') as dm, COUNT(*) as nb"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= $this->join; @@ -162,7 +162,7 @@ class FactureStats extends Stats $sql = "SELECT date_format(f.datef,'%Y') as dm, COUNT(*), SUM(c.".$this->field.")"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= $this->join; @@ -187,7 +187,7 @@ class FactureStats extends Stats $sql = "SELECT date_format(datef,'%m') as dm, SUM(f.".$this->field.")"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= $this->join; @@ -213,7 +213,7 @@ class FactureStats extends Stats $sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= $this->join; @@ -236,7 +236,7 @@ class FactureStats extends Stats $sql = "SELECT date_format(datef,'%Y') as year, COUNT(*) as nb, SUM(f.".$this->field.") as total, AVG(f.".$this->field.") as avg"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= $this->join; @@ -260,7 +260,7 @@ class FactureStats extends Stats $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= $this->join; @@ -288,7 +288,7 @@ class FactureStats extends Stats $startYear = $endYear - $numberYears; $sql = "SELECT date_format(datef,'%Y') as dm, SUM(f.".$this->field.")"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= $this->join; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 29225c9e178..fde549cc967 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -304,15 +304,15 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); '@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan -if (!$user->hasRight('societe', 'client', 'voir')) { - $search_sale = $user->id; -} - // Security check $fieldid = (!empty($ref) ? 'ref' : 'rowid'); if (!empty($user->socid)) { $socid = $user->socid; } +if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { + $search_sale = $user->id; +} + $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid); diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 9968411c62e..a238b4f6a2b 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -153,7 +153,7 @@ if (isModEnabled('invoice') && $user->hasRight('facture', 'lire')) { $sql .= " AND f.fk_soc = ".((int) $socid); } // Filter on sale representative - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc AND sc.fk_user = ".((int) $user->id).")"; } // Add where from hooks @@ -304,7 +304,7 @@ if ((isModEnabled('fournisseur') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMO $sql .= " AND ff.fk_soc = ".((int) $socid); } // Filter on sale representative - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = ff.fk_soc AND sc.fk_user = ".((int) $user->id).")"; } // Add where from hooks @@ -624,7 +624,7 @@ if (isModEnabled('invoice') && isModEnabled('order') && $user->hasRight("command $sql .= " AND c.fk_statut = ".((int) Commande::STATUS_CLOSED); $sql .= " AND c.facture = 0"; // Filter on sale representative - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user = ".((int) $user->id).")"; } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 633034c27f4..8bf66f9fe2e 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2279,7 +2279,7 @@ class Contrat extends CommonObject $this->from = " FROM ".MAIN_DB_PREFIX."contrat as c"; $this->from .= ", ".MAIN_DB_PREFIX."contratdet as cd"; $this->from .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $this->from .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } @@ -2310,7 +2310,7 @@ class Contrat extends CommonObject if ($user->socid) { $sql .= " AND c.fk_soc = ".((int) $user->socid); } - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } @@ -2376,7 +2376,7 @@ class Contrat extends CommonObject $sql = "SELECT count(c.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql .= " WHERE sc.fk_user = ".((int) $user->id); $clause = "AND"; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index bc5af219667..09d8e040b26 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -200,7 +200,7 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); '@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan -if (!$user->hasRight('societe', 'client', 'voir')) { +if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; } @@ -875,7 +875,7 @@ if (!empty($arrayfields['c.ref_supplier']['checked'])) { } if (!empty($arrayfields['s.nom']['checked'])) { print ''; - print ''; + print 'socid > 0 ? " disabled" : "").'>'; print ''; } if (!empty($arrayfields['s.email']['checked'])) { diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index 633914ce74b..1cd2a57f3dc 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -83,14 +83,14 @@ class box_actions extends ModeleBoxes $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.logo, s.email, s.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm AS ta, ".MAIN_DB_PREFIX."actioncomm AS a"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; $sql .= " WHERE a.fk_action = ta.id"; $sql .= " AND a.entity IN (".getEntity('actioncomm').")"; $sql .= " AND a.percent >= 0 AND a.percent < 100"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).")"; } if ($user->socid) { diff --git a/htdocs/core/boxes/box_actions_future.php b/htdocs/core/boxes/box_actions_future.php index 6a202bd9f2b..e9d8841fcc9 100644 --- a/htdocs/core/boxes/box_actions_future.php +++ b/htdocs/core/boxes/box_actions_future.php @@ -85,14 +85,14 @@ class box_actions_future extends ModeleBoxes $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.logo, s.email, s.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm AS ta, ".MAIN_DB_PREFIX."actioncomm AS a"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; $sql .= " WHERE a.fk_action = ta.id"; $sql .= " AND a.entity IN (".getEntity('actioncomm').")"; //$sql .= " AND a.percent >= 0 AND a.percent < 100"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).")"; } if ($user->socid) { diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 88571ed872b..3c8d2ce6a83 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -104,13 +104,13 @@ class box_activity extends ModeleBoxes $sql = "SELECT p.fk_statut, SUM(p.total_ttc) as Mnttot, COUNT(*) as nb"; $sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= ")"; $sql .= " WHERE p.entity IN (".getEntity('propal').")"; $sql .= " AND p.fk_soc = s.rowid"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { @@ -193,13 +193,13 @@ class box_activity extends ModeleBoxes $sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb"; $sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= ")"; $sql .= " WHERE c.entity IN (".getEntity('commande').")"; $sql .= " AND c.fk_soc = s.rowid"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { @@ -278,12 +278,12 @@ class box_activity extends ModeleBoxes $data = array(); $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; $sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= ")"; $sql .= " WHERE f.entity IN (".getEntity('invoice').')'; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index 7201ec1da11..a8d706fdb63 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -85,12 +85,12 @@ class box_clients extends ModeleBoxes $sql .= ", s.logo, s.email, s.entity"; $sql .= ", s.datec, s.tms, s.status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE s.client IN (1, 3)"; $sql .= " AND s.entity IN (".getEntity('societe').")"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } // Add where from hooks diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index d7a87dacbfa..bbb226fcf03 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -92,7 +92,7 @@ class box_commandes extends ModeleBoxes $sql .= ", c.total_tva"; $sql .= ", c.total_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.fk_soc = s.rowid"; @@ -100,7 +100,7 @@ class box_commandes extends ModeleBoxes if (getDolGlobalString('ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY')) { $sql .= " AND c.fk_statut = 1"; } - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index b9be887b2ed..0d5f91eb35f 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -98,11 +98,11 @@ class box_contacts extends ModeleBoxes if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); } - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE sp.entity IN (".getEntity('contact').")"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= " AND ((sp.fk_user_creat = ".((int) $user->id)." AND sp.priv = 1) OR sp.priv = 0)"; // check if this is a private contact diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index 2f32b170066..2653acb63a1 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -77,12 +77,12 @@ class box_contracts extends ModeleBoxes $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.tms as date_modification, c.fin_validite, c.date_cloture,"; $sql .= " c.ref_customer, c.ref_supplier"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " AND c.entity = ".$conf->entity; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { diff --git a/htdocs/core/boxes/box_customers_outstanding_bill_reached.php b/htdocs/core/boxes/box_customers_outstanding_bill_reached.php index 3aaf3082ae3..57237f6a318 100644 --- a/htdocs/core/boxes/box_customers_outstanding_bill_reached.php +++ b/htdocs/core/boxes/box_customers_outstanding_bill_reached.php @@ -84,12 +84,12 @@ class box_customers_outstanding_bill_reached extends ModeleBoxes $sql .= ", s.outstanding_limit"; $sql .= ", s.datec, s.tms, s.status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE s.client IN (1, 3)"; $sql .= " AND s.entity IN (".getEntity('societe').")"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 3e8de6c90e8..8a4f99ffb1c 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -93,12 +93,12 @@ class box_factures extends ModeleBoxes $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity IN (".getEntity('invoice').")"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index cfaeddc5b0f..4e874faa4eb 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -91,12 +91,12 @@ class box_factures_fourn extends ModeleBoxes $sql .= ', f.date_lim_reglement as datelimite, f.tms, f.type'; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity = ".$conf->entity; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index c75418ae958..24cecd0024a 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -93,14 +93,14 @@ class box_factures_fourn_imp extends ModeleBoxes $sql2 = " FROM ".MAIN_DB_PREFIX."societe as s"; $sql2 .= ",".MAIN_DB_PREFIX."facture_fourn as f"; $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf ON f.rowid = pf.fk_facturefourn"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql2 .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql2 .= " WHERE f.fk_soc = s.rowid"; $sql2 .= " AND f.entity IN (".getEntity('supplier_invoice').")"; $sql2 .= " AND f.paye = 0"; $sql2 .= " AND fk_statut = 1"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql2 .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index 6cfb7650547..8f52032b742 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -102,7 +102,7 @@ class box_factures_imp extends ModeleBoxes if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { $sql2 .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); } - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql2 .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql2 .= ", ".MAIN_DB_PREFIX."facture as f"; @@ -111,7 +111,7 @@ class box_factures_imp extends ModeleBoxes $sql2 .= " AND f.entity IN (".getEntity('invoice').")"; $sql2 .= " AND f.paye = 0"; $sql2 .= " AND fk_statut = 1"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql2 .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index 636c2b6eb2a..7da9d06d350 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -80,13 +80,13 @@ class box_ficheinter extends ModeleBoxes $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.logo, s.email, s.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= ", ".MAIN_DB_PREFIX."fichinter as f"; $sql .= " WHERE f.fk_soc = s.rowid "; $sql .= " AND f.entity = ".$conf->entity; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index ee5ae31472f..b54c5d7074a 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -78,12 +78,12 @@ class box_fournisseurs extends ModeleBoxes $sql .= ", s.logo, s.email, s.entity"; $sql .= ", s.datec, s.tms, s.status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE s.fournisseur = 1"; $sql .= " AND s.entity IN (".getEntity('societe').")"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } // Add where from hooks diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index e153e4bbe92..0597d7ec8de 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -93,7 +93,7 @@ class box_graph_propales_permonth extends ModeleBoxes if ($user->socid) { $socid = $user->socid; } - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user } diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 9922fc1e881..3b2b4370237 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -81,12 +81,12 @@ class box_propales extends ModeleBoxes $sql .= ", s.logo, s.email, s.entity"; $sql .= ", p.rowid, p.ref, p.fk_statut as status, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.total_tva, p.total_ttc, p.tms"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE p.fk_soc = s.rowid"; $sql .= " AND p.entity IN (".getEntity('propal').")"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index aa4725935ab..159c9bca946 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -86,12 +86,12 @@ class box_prospect extends ModeleBoxes $sql .= ", s.fk_stcomm"; $sql .= ", s.datec, s.tms, s.status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE s.client IN (2, 3)"; $sql .= " AND s.entity IN (".getEntity('societe').")"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } // Add where from hooks diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 6a9dd91c55a..21259696bfb 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -86,7 +86,7 @@ class box_services_contracts extends ModeleBoxes $sql .= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= ")"; diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index e2dea31cd4a..0e6b66add1b 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -74,7 +74,7 @@ class box_services_expired extends ModeleBoxes $sql .= " s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services"; $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$this->db->idate($now)."'"; @@ -83,7 +83,7 @@ class box_services_expired extends ModeleBoxes if ($user->socid) { $sql .= ' AND c.fk_soc = '.((int) $user->socid); } - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid"; diff --git a/htdocs/core/boxes/box_shipments.php b/htdocs/core/boxes/box_shipments.php index 512dbc6a944..42fa9b4821c 100644 --- a/htdocs/core/boxes/box_shipments.php +++ b/htdocs/core/boxes/box_shipments.php @@ -92,7 +92,7 @@ class box_shipments extends ModeleBoxes $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; } $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; @@ -102,7 +102,7 @@ class box_shipments extends ModeleBoxes if ($user->socid > 0) { $sql.= " AND s.rowid = ".((int) $user->socid); } - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND sc.fk_user = ".((int) $user->id); } else { $sql .= " ORDER BY e.tms DESC, e.date_delivery DESC, e.ref DESC"; diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index 88e87cff07b..3287e20c852 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -84,12 +84,12 @@ class box_supplier_orders extends ModeleBoxes $sql .= ", c.fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { diff --git a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php index acddab7dc23..86f30d122e1 100644 --- a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php +++ b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php @@ -81,14 +81,14 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes $sql .= ", c.fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; $sql .= " AND c.date_livraison IS NOT NULL"; $sql .= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.")"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index b1af5dbd95e..dee5549fee8 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -492,6 +492,7 @@ function getCustomerInvoiceDraftTable($maxCount = 500, $socid = 0) $result = ''; if (isModEnabled('invoice') && $user->hasRight('facture', 'lire')) { + if ($user->socid > 0) $socid = $user->socid; $maxofloop = (!getDolGlobalString('MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD); $tmpinvoice = new Facture($db); @@ -502,16 +503,16 @@ function getCustomerInvoiceDraftTable($maxCount = 500, $socid = 0) $sql .= ", s.rowid as socid, s.email"; $sql .= ", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; $sql .= ", cc.rowid as country_id, cc.code as country_code"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", sc.fk_soc, sc.fk_user "; } $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = ".Facture::STATUS_DRAFT; $sql .= " AND f.entity IN (".getEntity('invoice').")"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } @@ -526,7 +527,7 @@ function getCustomerInvoiceDraftTable($maxCount = 500, $socid = 0) $sql .= " GROUP BY f.rowid, f.ref, f.datef, f.total_ht, f.total_tva, f.total_ttc, f.ref_client, f.type, f.fk_statut, f.paye,"; $sql .= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur,"; $sql .= " cc.rowid, cc.code"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", sc.fk_soc, sc.fk_user"; } @@ -642,6 +643,7 @@ function getDraftSupplierTable($maxCount = 500, $socid = 0) $result = ''; if ((isModEnabled('fournisseur') || isModEnabled('supplier_invoice')) && $user->hasRight('facture', 'lire')) { + if ($user->socid > 0) $socid = $user->socid; $maxofloop = (!getDolGlobalString('MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD); $facturesupplierstatic = new FactureFournisseur($db); @@ -653,12 +655,12 @@ function getDraftSupplierTable($maxCount = 500, $socid = 0) $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; $sql .= ", cc.rowid as country_id, cc.code as country_code"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = ".FactureFournisseur::STATUS_DRAFT; $sql .= " AND f.entity IN (".getEntity('invoice').')'; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($socid) { @@ -773,12 +775,12 @@ function getDraftSupplierTable($maxCount = 500, $socid = 0) function getCustomerInvoiceLatestEditTable($maxCount = 5, $socid = 0) { global $conf, $db, $langs, $user; - + if ($user->socid > 0) $socid = $user->socid; $sql = "SELECT f.rowid, f.entity, f.ref, f.fk_statut as status, f.paye, f.type, f.total_ht, f.total_tva, f.total_ttc, f.datec,"; $sql .= " s.nom as socname, s.rowid as socid, s.canvas, s.client"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE f.fk_soc = s.rowid"; @@ -786,7 +788,7 @@ function getCustomerInvoiceLatestEditTable($maxCount = 5, $socid = 0) if ($socid) { $sql .= " AND f.fk_soc = ".((int) $socid); } - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= " ORDER BY f.tms DESC"; @@ -881,12 +883,12 @@ function getCustomerInvoiceLatestEditTable($maxCount = 5, $socid = 0) function getPurchaseInvoiceLatestEditTable($maxCount = 5, $socid = 0) { global $conf, $db, $langs, $user; - + if ($user->socid > 0) $socid = $user->socid; $sql = "SELECT f.rowid, f.entity, f.ref, f.fk_statut as status, f.paye, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier, f.datec,"; $sql .= " s.nom as socname, s.rowid as socid, s.canvas, s.client"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE f.fk_soc = s.rowid"; @@ -894,7 +896,7 @@ function getPurchaseInvoiceLatestEditTable($maxCount = 5, $socid = 0) if ($socid) { $sql .= " AND f.fk_soc = ".((int) $socid); } - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= " ORDER BY f.tms DESC"; @@ -999,6 +1001,7 @@ function getCustomerInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0) $result = ''; if (isModEnabled('invoice') && $user->hasRight('facture', 'lire')) { + if ($user->socid > 0) $socid = $user->socid; $tmpinvoice = new Facture($db); $sql = "SELECT f.rowid, f.ref, f.fk_statut as status, f.datef, f.type, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.tms"; @@ -1011,12 +1014,12 @@ function getCustomerInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0) $sql .= ", sum(pf.amount) as am"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays,".MAIN_DB_PREFIX."facture as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = ".Facture::STATUS_VALIDATED; $sql .= " AND f.entity IN (".getEntity('invoice').')'; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($socid) { @@ -1187,6 +1190,7 @@ function getPurchaseInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0) $result = ''; if (isModEnabled("supplier_invoice") && ($user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'read'))) { + if ($user->socid > 0) $socid = $user->socid; $facstatic = new FactureFournisseur($db); $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut as status, ff.type, ff.libelle as label, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye"; @@ -1198,14 +1202,14 @@ function getPurchaseInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0) $sql .= ", sum(pf.amount) as am"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE s.rowid = ff.fk_soc"; $sql .= " AND ff.entity = ".$conf->entity; $sql .= " AND ff.paye = 0"; $sql .= " AND ff.fk_statut = ".FactureFournisseur::STATUS_VALIDATED; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($socid) { diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 2f2d71a978b..72bf04842b8 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -239,11 +239,11 @@ function getCustomerOrderPieChart($socid = 0) /* * Statistics */ - + if ($user->socid > 0) $socid = $user->socid; $sql = "SELECT count(c.rowid) as nb, c.fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."commande as c"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.fk_soc = s.rowid"; @@ -251,7 +251,7 @@ function getCustomerOrderPieChart($socid = 0) if ($user->socid) { $sql .= ' AND c.fk_soc = '.((int) $user->socid); } - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= " GROUP BY c.fk_statut"; diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index 46cf91ce684..f9247d84d1f 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -217,15 +217,15 @@ function getCustomerProposalPieChart($socid = 0) if (!isModEnabled('propal') || !$user->hasRight('propal', 'lire')) { return ''; } - + $listofstatus = array(Propal::STATUS_DRAFT, Propal::STATUS_VALIDATED, Propal::STATUS_SIGNED, Propal::STATUS_NOTSIGNED, Propal::STATUS_BILLED); $propalstatic = new Propal($db); - + if ($user->socid > 0) $socid = $user->socid; $sql = "SELECT count(p.rowid) as nb, p.fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."propal as p"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if ($user->socid == 0 && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")"; @@ -233,7 +233,7 @@ function getCustomerProposalPieChart($socid = 0) if ($user->socid) { $sql .= ' AND p.fk_soc = '.((int) $user->socid); } - if (!$user->hasRight('societe', 'client', 'voir')) { + if ($user->socid == 0 && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= " AND p.fk_statut IN (".$db->sanitize(implode(" ,", $listofstatus)).")"; diff --git a/htdocs/fichinter/class/fichinterstats.class.php b/htdocs/fichinter/class/fichinterstats.class.php index 15d19eaba73..fea03d405fa 100644 --- a/htdocs/fichinter/class/fichinterstats.class.php +++ b/htdocs/fichinter/class/fichinterstats.class.php @@ -98,7 +98,7 @@ class FichinterStats extends Stats $sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; @@ -122,7 +122,7 @@ class FichinterStats extends Stats $sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, 0"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE ".$this->where; @@ -145,7 +145,7 @@ class FichinterStats extends Stats $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; @@ -169,7 +169,7 @@ class FichinterStats extends Stats $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; @@ -191,7 +191,7 @@ class FichinterStats extends Stats $sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, 0 as total, 0 as avg"; $sql .= " FROM ".$this->from; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE ".$this->where; diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 08b4b55373a..450396fbe2b 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -296,7 +296,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -if (!$user->hasRight('societe', 'client', 'voir')) { +if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= ", ".MAIN_DB_PREFIX."societe as s"; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 5eea5501d69..cb94ccd7366 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3207,7 +3207,7 @@ class CommandeFournisseur extends CommonOrder $sql = "SELECT count(co.rowid) as nb"; $sql .= " FROM ".$this->db->prefix()."commande_fournisseur as co"; $sql .= " LEFT JOIN ".$this->db->prefix()."societe as s ON co.fk_soc = s.rowid"; - if (!$user->hasRight("societe", "client", "voir") && !$user->socid) { + if (empty($user->socid) && !$user->hasRight("societe", "client", "voir") && !$user->socid) { $sql .= " LEFT JOIN ".$this->db->prefix()."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql .= " WHERE sc.fk_user = ".((int) $user->id); $clause = "AND"; @@ -3243,7 +3243,7 @@ class CommandeFournisseur extends CommonOrder $sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.fk_statut, c.date_livraison as delivery_date, c.total_ht"; $sql .= " FROM ".$this->db->prefix()."commande_fournisseur as c"; - if (!$user->hasRight("societe", "client", "voir") && !$user->socid) { + if (empty($user->socid) && !$user->hasRight("societe", "client", "voir") && !$user->socid) { $sql .= " JOIN ".$this->db->prefix()."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= " WHERE c.entity = ".$conf->entity; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 79b345dab2c..0ca5cf7f339 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2703,7 +2703,7 @@ class FactureFournisseur extends CommonInvoice $sql = 'SELECT ff.rowid, ff.date_lim_reglement as datefin, ff.fk_statut as status, ff.total_ht, ff.total_ttc'; $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as ff'; - if (!$user->hasRight("societe", "client", "voir") && !$user->socid) { + if (empty($user->socid) && !$user->hasRight("societe", "client", "voir")) { $sql .= " JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ff.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= ' WHERE ff.paye = 0'; @@ -3123,7 +3123,7 @@ class FactureFournisseur extends CommonInvoice $sql = "SELECT count(f.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; - if (!$user->hasRight("societe", "client", "voir") && !$user->socid) { + if (empty($user->socid) && !$user->hasRight("societe", "client", "voir")) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql .= " WHERE sc.fk_user = ".((int) $user->id); $clause = "AND"; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 959533d131d..6437570bf0f 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1943,7 +1943,7 @@ class SupplierProposal extends CommonObject $ga = array(); $search_sale = 0; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; } @@ -2212,7 +2212,7 @@ class SupplierProposal extends CommonObject public function load_board($user, $mode) { // phpcs:enable - global $conf, $user, $langs; + global $conf, $langs; $now = dol_now(); @@ -2220,7 +2220,7 @@ class SupplierProposal extends CommonObject $sql = "SELECT p.rowid, p.ref, p.datec as datec, p.date_cloture as datefin"; $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc"; $sql .= " WHERE sc.fk_user = ".((int) $user->id); $clause = " AND"; @@ -2377,7 +2377,7 @@ class SupplierProposal extends CommonObject $sql = "SELECT count(p.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql .= " WHERE sc.fk_user = ".((int) $user->id); $clause = "AND"; diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 4791136e400..839b4e89efa 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -891,7 +891,7 @@ class Ticket extends CommonObject $socid = $user->socid ? $user->socid : 0; // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; } // Search on sale representative @@ -3156,7 +3156,7 @@ class Ticket extends CommonObject $sql = "SELECT p.rowid, p.ref, p.datec as datec"; $sql .= " FROM ".MAIN_DB_PREFIX."ticket as p"; - if (isModEnabled('societe') && !$user->hasRight('societe', 'client', 'voir') && !$user->socid) { + if (empty($user->socid) && isModEnabled('societe') && !$user->hasRight('societe', 'client', 'voir') && !$user->socid) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc"; $sql .= " WHERE sc.fk_user = ".((int) $user->id); $clause = " AND"; @@ -3220,7 +3220,7 @@ class Ticket extends CommonObject $sql = "SELECT count(p.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."ticket as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; - if (!$user->hasRight('societe', 'client', 'voir')) { + if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql .= " WHERE sc.fk_user = ".((int) $user->id); $clause = "AND"; From df88c74d119c0da18880b7f73c6e411f4c630927 Mon Sep 17 00:00:00 2001 From: vmaury Date: Mon, 13 Jan 2025 12:04:16 +0100 Subject: [PATCH 11/69] Fix 31370 Pb with external account --- htdocs/core/lib/invoice.lib.php | 2 +- htdocs/core/lib/propal.lib.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index dee5549fee8..7eecd6b0131 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -1190,7 +1190,7 @@ function getPurchaseInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0) $result = ''; if (isModEnabled("supplier_invoice") && ($user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'read'))) { - if ($user->socid > 0) $socid = $user->socid; + if ($user->socid > 0) $socid = $user->socid; $facstatic = new FactureFournisseur($db); $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut as status, ff.type, ff.libelle as label, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye"; diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index f9247d84d1f..6ec7c824cee 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -217,7 +217,7 @@ function getCustomerProposalPieChart($socid = 0) if (!isModEnabled('propal') || !$user->hasRight('propal', 'lire')) { return ''; } - + $listofstatus = array(Propal::STATUS_DRAFT, Propal::STATUS_VALIDATED, Propal::STATUS_SIGNED, Propal::STATUS_NOTSIGNED, Propal::STATUS_BILLED); $propalstatic = new Propal($db); From 979a10fcb183d37005e67deafa2d87174c578552 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 20 Jan 2025 15:26:06 +0100 Subject: [PATCH 12/69] Update list.php --- htdocs/compta/facture/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 7b7b2565569..aecb059d464 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -304,7 +304,7 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); '@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan -// Check only if it's an internal user, external users are already filterd by $socid +// Check only if it's an internal user, external users are already filtered by $socid if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; } From be06fc32affc41b37a2b580ccdabf3fdda282586 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 20 Jan 2025 15:55:19 +0100 Subject: [PATCH 13/69] Qual: Fix ci for new api_memberstypes.class # Qual: Fix ci for new api_memberstypes.class This fixes the notifications for the new api_memberstypes.class --- htdocs/adherents/class/api_members.class.php | 16 +++++++------ .../class/api_memberstypes.class.php | 23 +++++++++++++------ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 19882d2fc11..55f5b61af8c 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -1,9 +1,9 @@ - * Copyright (C) 2017 Regis Houssin - * Copyright (C) 2020 Thibault FOUCART - * Copyright (C) 2020 Frédéric France - * Copyright (C) 2024 MDW +/* Copyright (C) 2016 Xebax Christy + * Copyright (C) 2017 Regis Houssin + * Copyright (C) 2020 Thibault FOUCART + * Copyright (C) 2020-2024 Frédéric France + * Copyright (C) 2024-2025 MDW * * 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 @@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; class Members extends DolibarrApi { /** - * @var array $FIELDS Mandatory fields, checked when create and update object + * @var string[] Mandatory fields, checked when create and update object */ public static $FIELDS = array( 'morphy', @@ -283,7 +283,9 @@ class Members extends DolibarrApi /** * Create member object * - * @param array $request_data Request data + * @param array $request_data Request data + * @phan-param ?array $request_data + * @phpstan-param ?array $request_data * @return int ID of member * * @throws RestException 403 Access denied diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 32e9e105fa2..c96967f79ff 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2025 MDW * * 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 @@ -28,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; class MembersTypes extends DolibarrApi { /** - * @var array $FIELDS Mandatory fields, checked when create and update object + * @var string[] Mandatory fields, checked when create and update object */ public static $FIELDS = array( 'label', @@ -84,6 +85,8 @@ class MembersTypes extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.libelle:like:'SO-%') and (t.subscription:=:'1')" * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names * @return array Array of member type objects + * @phan-return AdherentType[] + * @phpstan-return AdherentType[] * * @throws RestException */ @@ -143,7 +146,9 @@ class MembersTypes extends DolibarrApi /** * Create member type object * - * @param array $request_data Request data + * @param array $request_data Request data + * @phan-param ?array $request_data + * @phpstan-param ?array $request_data * @return int ID of member type */ public function post($request_data = null) @@ -175,7 +180,9 @@ class MembersTypes extends DolibarrApi * * @param int $id ID of member type to update * @param array $request_data Datas - * @return int + * @phan-param ?array $request_data + * @phpstan-param ?array $request_data + * @return Object */ public function put($id, $request_data = null) { @@ -227,6 +234,8 @@ class MembersTypes extends DolibarrApi * * @param int $id member type ID * @return array + * @phan-return array + * @phpstan-return array */ public function delete($id) { @@ -261,8 +270,8 @@ class MembersTypes extends DolibarrApi /** * Validate fields before creating an object * - * @param array|null $data Data to validate - * @return array + * @param ?array $data Data to validate + * @return array * * @throws RestException */ @@ -282,8 +291,8 @@ class MembersTypes extends DolibarrApi /** * Clean sensible object datas * - * @param Object $object Object to clean - * @return Object Object with cleaned properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { From dc976ce2ec02e172c8074a666f1bc08850d4b478 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 20 Jan 2025 22:54:37 +0100 Subject: [PATCH 14/69] FIX remove socid when cloning a project without third parties --- htdocs/projet/class/project.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index d4ecaff58a0..cf7cc5558a4 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1729,9 +1729,7 @@ class Project extends CommonObject // Load source object $clone_project->fetch($fromid); $clone_project->fetch_optionals(); - if ($newthirdpartyid > 0) { - $clone_project->socid = $newthirdpartyid; - } + $clone_project->socid = ($newthirdpartyid > 0 ? $newthirdpartyid : 0); $clone_project->fetch_thirdparty(); $orign_dt_start = $clone_project->date_start; From 7a8e0d9b5ccd24e1571559a0e19dd9457f4147d3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 21 Jan 2025 18:51:18 +0100 Subject: [PATCH 15/69] FIX #32736 + avoid php warning --- htdocs/compta/sociales/card.php | 1 + htdocs/compta/sociales/list.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 67ede36a989..e6027db3b1c 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -207,6 +207,7 @@ if (empty($reshook)) { $object->mode_reglement_id = GETPOSTINT('mode_reglement_id'); $object->fk_account = GETPOSTINT('fk_account'); $object->fk_project = GETPOSTINT('fk_project'); + $object->paye = ChargeSociales::STATUS_UNPAID; $id = $object->create($user); if ($id <= 0) { diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 550c532ddb5..92f4772fcab 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -72,7 +72,7 @@ $search_date_limit_endyear = GETPOSTINT('search_date_limit_endyear'); $search_date_limit_start = dol_mktime(0, 0, 0, $search_date_limit_startmonth, $search_date_limit_startday, $search_date_limit_startyear); $search_date_limit_end = dol_mktime(23, 59, 59, $search_date_limit_endmonth, $search_date_limit_endday, $search_date_limit_endyear); $search_project_ref = GETPOST('search_project_ref', 'alpha'); -$search_users = GETPOST('search_users', 'intcomma'); +$search_users = GETPOST('search_users', 'array:int'); $search_type = GETPOST('search_type', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); From f709a073fc17765a0f0618065cb2e1747d715c9d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Jan 2025 22:42:50 +0100 Subject: [PATCH 16/69] Fix price format with multicurrency --- htdocs/core/class/html.form.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a3787797c25..05d6f60ba06 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3978,16 +3978,16 @@ class Form $optstart .= ' data-product-id="' . dol_escape_htmltag($objp->rowid) . '"'; $optstart .= ' data-price-id="' . dol_escape_htmltag($objp->idprodfournprice) . '"'; $optstart .= ' data-qty="' . dol_escape_htmltag($objp->quantity) . '"'; - $optstart .= ' data-up="' . dol_escape_htmltag(price2num($objp->unitprice)) . '"'; - $optstart .= ' data-up-locale="' . dol_escape_htmltag(price($objp->unitprice)) . '"'; + $optstart .= ' data-up="' . dol_escape_htmltag(price2num($objp->unitprice)) . '"'; // the price with numeric international format + $optstart .= ' data-up-locale="' . dol_escape_htmltag(price($objp->unitprice)) . '"'; // the price formated in user languge $optstart .= ' data-discount="' . dol_escape_htmltag($outdiscount) . '"'; - $optstart .= ' data-tvatx="' . dol_escape_htmltag(price2num($objp->tva_tx)) . '"'; - $optstart .= ' data-tvatx-formated="' . dol_escape_htmltag(price($objp->tva_tx, 0, $langs, 1, -1, 2)) . '"'; + $optstart .= ' data-tvatx="' . dol_escape_htmltag(price2num($objp->tva_tx)) . '"'; // the rate with numeric international format + $optstart .= ' data-tvatx-formated="' . dol_escape_htmltag(price($objp->tva_tx, 0, $langs, 1, -1, 2)) . '"'; // the rate formated in user language $optstart .= ' data-default-vat-code="' . dol_escape_htmltag($objp->default_vat_code) . '"'; $optstart .= ' data-supplier-ref="' . dol_escape_htmltag($objp->ref_fourn) . '"'; if (isModEnabled('multicurrency')) { $optstart .= ' data-multicurrency-code="' . dol_escape_htmltag($objp->multicurrency_code) . '"'; - $optstart .= ' data-multicurrency-up="' . dol_escape_htmltag($objp->multicurrency_unitprice) . '"'; + $optstart .= ' data-multicurrency-up="' . dol_escape_htmltag(price2num($objp->multicurrency_unitprice)) . '"'; // the price with numeric international format } } $optstart .= ' data-description="' . dol_escape_htmltag($objp->description, 0, 1) . '"'; From 391aca510c48fd59f790b0caa7f2022663950d83 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Jan 2025 23:18:04 +0100 Subject: [PATCH 17/69] FIX autofill price with multicurrency on supplier doc --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a550f366b93..8c465f0e050 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3996,7 +3996,7 @@ class Form $optstart .= ' data-supplier-ref="' . dol_escape_htmltag($objp->ref_fourn) . '"'; if (isModEnabled('multicurrency')) { $optstart .= ' data-multicurrency-code="' . dol_escape_htmltag($objp->multicurrency_code) . '"'; - $optstart .= ' data-multicurrency-up="' . dol_escape_htmltag(price2num($objp->multicurrency_unitprice)) . '"'; // the price with numeric international format + $optstart .= ' data-multicurrency-unitprice="' . dol_escape_htmltag(price2num($objp->multicurrency_unitprice)) . '"'; // the price with numeric international format } } $optstart .= ' data-description="' . dol_escape_htmltag($objp->description, 0, 1) . '"'; From 0ed1317607fbdf661551bc3fca130c4de5922ea7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 22 Jan 2025 05:40:50 +0100 Subject: [PATCH 18/69] FIX avoid warning with the new Dolistore website --- htdocs/admin/modules.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 6f96506cc31..b4bc00f68ca 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -1185,7 +1185,9 @@ if ($mode == 'marketplace') { print '
'; - if (!getDolGlobalString('MAIN_DISABLE_DOLISTORE_SEARCH') && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1) { + $conf->global->MAIN_DISABLE_DOLISTORE_SEARCH = 1; // avoid warning with the new Dolistore website + + if (!getDolGlobalString('MAIN_DISABLE_DOLISTORE_SEARCH') && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { // $options is array with filter criteria //var_dump($options); $dolistore->getRemoteCategories(); From 99caa9aa37b67098be5be7d262240006942ddf0b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 22 Jan 2025 05:48:25 +0100 Subject: [PATCH 19/69] FIX Brian is in the kitchen --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8c465f0e050..29824c01b50 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3988,7 +3988,7 @@ class Form $optstart .= ' data-price-id="' . dol_escape_htmltag($objp->idprodfournprice) . '"'; $optstart .= ' data-qty="' . dol_escape_htmltag($objp->quantity) . '"'; $optstart .= ' data-up="' . dol_escape_htmltag(price2num($objp->unitprice)) . '"'; // the price with numeric international format - $optstart .= ' data-up-locale="' . dol_escape_htmltag(price($objp->unitprice)) . '"'; // the price formated in user languge + $optstart .= ' data-up-locale="' . dol_escape_htmltag(price($objp->unitprice)) . '"'; // the price formatted in user language $optstart .= ' data-discount="' . dol_escape_htmltag($outdiscount) . '"'; $optstart .= ' data-tvatx="' . dol_escape_htmltag(price2num($objp->tva_tx)) . '"'; // the rate with numeric international format $optstart .= ' data-tvatx-formated="' . dol_escape_htmltag(price($objp->tva_tx, 0, $langs, 1, -1, 2)) . '"'; // the rate formated in user language From 8c5dce626733611ee954812cbb08a0f15a13eaaf Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 22 Jan 2025 05:57:05 +0100 Subject: [PATCH 20/69] FIX Where is Brian ? --- htdocs/core/class/html.form.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 29824c01b50..0140a6589cc 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3991,7 +3991,7 @@ class Form $optstart .= ' data-up-locale="' . dol_escape_htmltag(price($objp->unitprice)) . '"'; // the price formatted in user language $optstart .= ' data-discount="' . dol_escape_htmltag($outdiscount) . '"'; $optstart .= ' data-tvatx="' . dol_escape_htmltag(price2num($objp->tva_tx)) . '"'; // the rate with numeric international format - $optstart .= ' data-tvatx-formated="' . dol_escape_htmltag(price($objp->tva_tx, 0, $langs, 1, -1, 2)) . '"'; // the rate formated in user language + $optstart .= ' data-tvatx-formated="' . dol_escape_htmltag(price($objp->tva_tx, 0, $langs, 1, -1, 2)) . '"'; // the rate formatted in user language $optstart .= ' data-default-vat-code="' . dol_escape_htmltag($objp->default_vat_code) . '"'; $optstart .= ' data-supplier-ref="' . dol_escape_htmltag($objp->ref_fourn) . '"'; if (isModEnabled('multicurrency')) { @@ -7082,17 +7082,17 @@ class Form if ($d) { // Show date with popup if ($usecalendar != 'combo') { - $formated_date = ''; + $formatted_date = ''; //print "e".$set_time." t ".$conf->format_date_short; if (strval($set_time) != '' && $set_time != -1) { - //$formated_date=dol_print_date($set_time,$conf->format_date_short); - $formated_date = dol_print_date($set_time, $langs->trans("FormatDateShortInput"), $gm); // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript + //$formatted_date=dol_print_date($set_time,$conf->format_date_short); + $formatted_date = dol_print_date($set_time, $langs->trans("FormatDateShortInput"), $gm); // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript } // Calendrier popup version eldy if ($usecalendar == "eldy") { // Input area to enter date manually - $retstring .= 'trans("FormatDateShortJavaInput") . '\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript $retstring .= ' autocomplete="off">'; @@ -7148,7 +7148,7 @@ class Form // Input area to enter date manually $retstring .= '
'; - $retstring .= 'trans("FormatDateShortJavaInput")) . '\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript From 5c6ddba47ae500afec95d9ebabd3fe788ae7eb6c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 22 Jan 2025 06:22:14 +0100 Subject: [PATCH 21/69] FIX #32743 --- htdocs/product/stock/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 346d0f89595..97a42add100 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -199,6 +199,7 @@ $form = new Form($db); $warehouse = new Entrepot($db); $now = dol_now(); +$totalarray = array(); $title = $langs->trans("Warehouses"); $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; @@ -615,7 +616,6 @@ if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { } print ''."\n"; -$totalarray = array(); $totalarray['nbfield'] = 0; // Fields title label From 2c4bfe38604af5d47dc0f699f2dbb75d658af469 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 22 Jan 2025 05:57:05 +0100 Subject: [PATCH 22/69] FIX Where is Brian ? --- htdocs/core/class/html.form.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8c465f0e050..e7a9fda4156 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3991,7 +3991,7 @@ class Form $optstart .= ' data-up-locale="' . dol_escape_htmltag(price($objp->unitprice)) . '"'; // the price formated in user languge $optstart .= ' data-discount="' . dol_escape_htmltag($outdiscount) . '"'; $optstart .= ' data-tvatx="' . dol_escape_htmltag(price2num($objp->tva_tx)) . '"'; // the rate with numeric international format - $optstart .= ' data-tvatx-formated="' . dol_escape_htmltag(price($objp->tva_tx, 0, $langs, 1, -1, 2)) . '"'; // the rate formated in user language + $optstart .= ' data-tvatx-formated="' . dol_escape_htmltag(price($objp->tva_tx, 0, $langs, 1, -1, 2)) . '"'; // the rate formatted in user language $optstart .= ' data-default-vat-code="' . dol_escape_htmltag($objp->default_vat_code) . '"'; $optstart .= ' data-supplier-ref="' . dol_escape_htmltag($objp->ref_fourn) . '"'; if (isModEnabled('multicurrency')) { @@ -7082,17 +7082,17 @@ class Form if ($d) { // Show date with popup if ($usecalendar != 'combo') { - $formated_date = ''; + $formatted_date = ''; //print "e".$set_time." t ".$conf->format_date_short; if (strval($set_time) != '' && $set_time != -1) { - //$formated_date=dol_print_date($set_time,$conf->format_date_short); - $formated_date = dol_print_date($set_time, $langs->trans("FormatDateShortInput"), $gm); // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript + //$formatted_date=dol_print_date($set_time,$conf->format_date_short); + $formatted_date = dol_print_date($set_time, $langs->trans("FormatDateShortInput"), $gm); // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript } // Calendrier popup version eldy if ($usecalendar == "eldy") { // Input area to enter date manually - $retstring .= 'trans("FormatDateShortJavaInput") . '\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript $retstring .= ' autocomplete="off">'; @@ -7148,7 +7148,7 @@ class Form // Input area to enter date manually $retstring .= '
'; - $retstring .= 'trans("FormatDateShortJavaInput")) . '\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript From 8ae1208ff659256d59d8d42b9e8ee63172be2513 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 22 Jan 2025 05:48:25 +0100 Subject: [PATCH 23/69] FIX Brian is in the kitchen --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e7a9fda4156..0140a6589cc 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3988,7 +3988,7 @@ class Form $optstart .= ' data-price-id="' . dol_escape_htmltag($objp->idprodfournprice) . '"'; $optstart .= ' data-qty="' . dol_escape_htmltag($objp->quantity) . '"'; $optstart .= ' data-up="' . dol_escape_htmltag(price2num($objp->unitprice)) . '"'; // the price with numeric international format - $optstart .= ' data-up-locale="' . dol_escape_htmltag(price($objp->unitprice)) . '"'; // the price formated in user languge + $optstart .= ' data-up-locale="' . dol_escape_htmltag(price($objp->unitprice)) . '"'; // the price formatted in user language $optstart .= ' data-discount="' . dol_escape_htmltag($outdiscount) . '"'; $optstart .= ' data-tvatx="' . dol_escape_htmltag(price2num($objp->tva_tx)) . '"'; // the rate with numeric international format $optstart .= ' data-tvatx-formated="' . dol_escape_htmltag(price($objp->tva_tx, 0, $langs, 1, -1, 2)) . '"'; // the rate formatted in user language From 8069cd304d508a388adf853045f1e231efaa4394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NASSIET?= <109105553+comaiteseb@users.noreply.github.com> Date: Wed, 22 Jan 2025 14:31:05 +0100 Subject: [PATCH 24/69] Update facture.class.php ajout de class_element_line --- htdocs/compta/facture/class/facture.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0723255b101..3bad1dfee22 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -75,6 +75,11 @@ class Facture extends CommonInvoice */ public $table_element_line = 'facturedet'; + /** + * @var string Name of class line + */ + public $class_element_line = 'FactureLigne'; + /** * @var string Fieldname with ID of parent key if this field has a parent */ From 4f80adc2bf6e8fe5fc79ec493c8b880300a7283b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NASSIET?= <109105553+comaiteseb@users.noreply.github.com> Date: Wed, 22 Jan 2025 14:56:53 +0100 Subject: [PATCH 25/69] Update facture.class.php --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3bad1dfee22..0da59edf3d9 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -79,7 +79,7 @@ class Facture extends CommonInvoice * @var string Name of class line */ public $class_element_line = 'FactureLigne'; - + /** * @var string Fieldname with ID of parent key if this field has a parent */ From d42f958398ddc913e47a326c18c84b30275fc3b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 23 Jan 2025 09:34:32 +0100 Subject: [PATCH 26/69] fix pre-commit --- htdocs/stripe/admin/stripe.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index eb08aac811d..b993a699cb8 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -386,7 +386,7 @@ $form->select_comptes(getDolGlobalString('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS'), 'S print ''; -// Param to record automatically payouts (received from IPN payout.payed and payout.created) +// Param to record automatically payouts (received from IPN payout.paid and payout.created) print ''; print $langs->trans("StripeAutoRecordPayout").''; if ($conf->use_javascript_ajax) { From bcf62738f0965787986206dcf020c63197a8fba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 23 Jan 2025 09:42:32 +0100 Subject: [PATCH 27/69] Update main.lang --- htdocs/langs/en_US/main.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index a76687104cb..d1cb8efc86c 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1253,6 +1253,7 @@ CommercialAffected=Sales representative assigned CommercialsDisaffected=Sales representatives unlinked CommercialDisaffected=Sales representative unlinked Message=Message +Emailing=Emailing Progression=Progress YourMessage=Your message YourMessageHasBeenReceived=Your message has been received. We will answer or contact you as soon as possible. From 1ef30c3006081ab67f6ebc63df38a49f795d188f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 23 Jan 2025 21:59:04 +0100 Subject: [PATCH 28/69] fix --- htdocs/adherents/class/api_memberstypes.class.php | 3 ++- htdocs/loan/note.php | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 32e9e105fa2..ce8f2457f66 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2025 Frédéric France * * 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 @@ -28,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; class MembersTypes extends DolibarrApi { /** - * @var array $FIELDS Mandatory fields, checked when create and update object + * @var string[] $FIELDS Mandatory fields, checked when create and update object */ public static $FIELDS = array( 'label', diff --git a/htdocs/loan/note.php b/htdocs/loan/note.php index 9bc1da5c0a9..3fa7c606d83 100644 --- a/htdocs/loan/note.php +++ b/htdocs/loan/note.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Florian Henry - * Copyright (C) 2015-2024 Frédéric France + * Copyright (C) 2015-2025 Frédéric France * Copyright (C) 2016-2025 Alexandre Spangaro * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2024 MDW @@ -84,9 +84,6 @@ if (empty($reshook)) { $morehtmlright = ''; $form = new Form($db); -if (isModEnabled('project')) { - $formproject = new FormProjets($db); -} $title = $langs->trans("Loan").' - '.$langs->trans("Notes"); $help_url = 'EN:Module_Loan|FR:Module_Emprunt'; @@ -109,6 +106,7 @@ if ($id > 0) { $morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); // Project if (isModEnabled('project')) { + $formproject = new FormProjets($db); $langs->loadLangs(array("projects")); $morehtmlref .= '
'.$langs->trans('Project').' : '; if ($user->hasRight('loan', 'write')) { From 5c616a2812b551845a5731b0fdbd84f7bcc6e9df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 23 Jan 2025 22:01:57 +0100 Subject: [PATCH 29/69] fix --- htdocs/adherents/class/api_memberstypes.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index ce8f2457f66..fc230bbaf41 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; class MembersTypes extends DolibarrApi { /** - * @var string[] $FIELDS Mandatory fields, checked when create and update object + * @var string[] Mandatory fields, checked when create and update object */ public static $FIELDS = array( 'label', From 622a655a3c65b4ede7fd30875e5b0cd1ad526ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 23 Jan 2025 22:15:11 +0100 Subject: [PATCH 30/69] fix --- .../adherents/class/api_memberstypes.class.php | 16 ++++++++++++---- htdocs/core/class/conf.class.php | 6 +++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index fc230bbaf41..9d0c1ebfd7e 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -85,6 +85,8 @@ class MembersTypes extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.libelle:like:'SO-%') and (t.subscription:=:'1')" * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names * @return array Array of member type objects + * @phan-return AdherentType[] + * @phpstan-return AdherentType[] * * @throws RestException */ @@ -144,7 +146,9 @@ class MembersTypes extends DolibarrApi /** * Create member type object * - * @param array $request_data Request data + * @param array $request_data Request data + * @phan-param ?array $request_data + * @phpstan-param ?array $request_data * @return int ID of member type */ public function post($request_data = null) @@ -176,7 +180,9 @@ class MembersTypes extends DolibarrApi * * @param int $id ID of member type to update * @param array $request_data Datas - * @return int + * @phan-param ?array $request_data + * @phpstan-param ?array $request_data + * @return Object */ public function put($id, $request_data = null) { @@ -228,6 +234,8 @@ class MembersTypes extends DolibarrApi * * @param int $id member type ID * @return array + * @phan-return array + * @phpstan-return array */ public function delete($id) { @@ -262,8 +270,8 @@ class MembersTypes extends DolibarrApi /** * Validate fields before creating an object * - * @param array|null $data Data to validate - * @return array + * @param ?array $data Data to validate + * @return array * * @throws RestException */ diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index f6f452062c1..fe27db7061e 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004-2020 Laurent Destailleur * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2006 Jean Heimburger - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024-2025 Frédéric France * * 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 @@ -1197,10 +1197,10 @@ class Conf extends stdClass // For modules that want to disable top or left menu if (!empty($this->global->MAIN_HIDE_TOP_MENU)) { - $this->dol_hide_topmenu = getDolGlobalString('MAIN_HIDE_TOP_MENU'); + $this->dol_hide_topmenu = getDolGlobalInt('MAIN_HIDE_TOP_MENU'); } if (!empty($this->global->MAIN_HIDE_LEFT_MENU)) { - $this->dol_hide_leftmenu = getDolGlobalString('MAIN_HIDE_LEFT_MENU'); + $this->dol_hide_leftmenu = getDolGlobalInt('MAIN_HIDE_LEFT_MENU'); } if (empty($this->global->MAIN_SIZE_SHORTLIST_LIMIT)) { From 9ea11cabf7ea7296a674c2ddcf54aee1b82ada13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 23 Jan 2025 22:26:02 +0100 Subject: [PATCH 31/69] fix --- .../triggers/interface_50_modTicket_TicketEmail.class.php | 5 +++-- htdocs/public/payment/paymentok.php | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index 40cd8f49827..d077ff607c1 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -4,6 +4,7 @@ * 2016 Christophe Battarel * Copyright (C) 2023 Benjamin Falière * Copyright (C) 2024 MDW + * Copyright (C) 2025 Frédéric France * * 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 @@ -178,6 +179,7 @@ class InterfaceTicketEmail extends DolibarrTriggers if (!getDolGlobalString('TICKET_DISABLE_ALL_MAILS')) { // Send email to assigned user $sendto = $userstat->email; + $old_MAIN_MAIL_AUTOCOPY_TO = ''; if (!getDolGlobalString('TICKET_DISABLE_MAIL_AUTOCOPY_TO')) { $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; @@ -192,8 +194,7 @@ class InterfaceTicketEmail extends DolibarrTriggers } } } else { - $this->error = $userstat->error; - $this->errors = $userstat->errors; + $this->setErrorsFromObject($userstat); } } diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 1c0d5a61aea..aa46e7ccf0b 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -169,7 +169,6 @@ $ErrorCode = $ErrorShortMsg = $ErrorLongMsg = $ErrorSeverityCode = ''; $object = new stdClass(); // For triggers -/** @var CommonObject $object */ $error = 0; From 6fdb20902df842f49a2b7c52c141f74406b06973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 23 Jan 2025 22:31:21 +0100 Subject: [PATCH 32/69] fix --- build/phpstan/phpstan-baseline.neon | 50 ++++------------------------- 1 file changed, 7 insertions(+), 43 deletions(-) diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index c850e576f25..260f9b768c0 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -5457,7 +5457,7 @@ parameters: - message: '#^Variable \$i might not be defined\.$#' identifier: variable.undefined - count: 4 + count: 3 path: ../../htdocs/compta/facture/card.php - @@ -6582,12 +6582,6 @@ parameters: count: 1 path: ../../htdocs/compta/sociales/card.php - - - message: '#^Variable \$resteapayer might not be defined\.$#' - identifier: variable.undefined - count: 3 - path: ../../htdocs/compta/sociales/card.php - - message: '#^Negated boolean expression is always true\.$#' identifier: booleanNot.alwaysTrue @@ -9096,12 +9090,6 @@ parameters: count: 1 path: ../../htdocs/core/class/commonobject.class.php - - - message: '#^Parameter \#17 \$pa_ht of method Commande\:\:updateline\(\) expects int, float given\.$#' - identifier: argument.type - count: 1 - path: ../../htdocs/core/class/commonobject.class.php - - message: '#^Parameter \#2 \$line of method CommonObject\:\:printObjectLine\(\) expects CommonObjectLine, CommonObject\|stdClass given\.$#' identifier: argument.type @@ -20244,12 +20232,6 @@ parameters: count: 2 path: ../../htdocs/fourn/commande/dispatch.php - - - message: '#^Variable \$reception might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../htdocs/fourn/commande/dispatch.php - - message: '#^If condition is always false\.$#' identifier: if.alwaysFalse @@ -22854,12 +22836,6 @@ parameters: count: 2 path: ../../htdocs/loan/class/loanschedule.class.php - - - message: '#^Negated boolean expression is always true\.$#' - identifier: booleanNot.alwaysTrue - count: 1 - path: ../../htdocs/loan/class/paymentloan.class.php - - message: '#^Property PaymentLoan\:\:\$amount_capital \(float\|int\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -28734,12 +28710,6 @@ parameters: count: 16 path: ../../htdocs/public/webportal/webportal.main.inc.php - - - message: '#^Variable \$logged_partnership might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../htdocs/public/webportal/webportal.main.inc.php - - message: '#^Negated boolean expression is always false\.$#' identifier: booleanNot.alwaysFalse @@ -30315,7 +30285,7 @@ parameters: - message: '#^Ternary operator condition is always true\.$#' identifier: ternary.alwaysTrue - count: 4 + count: 3 path: ../../htdocs/societe/card.php - @@ -32581,14 +32551,14 @@ parameters: path: ../../htdocs/variants/class/ProductAttributeValue.class.php - - message: '#^Loose comparison using \!\= between ''ErrorProductAlready…'' and ''ErrorProductAlready…'' will always evaluate to false\.$#' - identifier: notEqual.alwaysFalse + message: '#^Call to function is_array\(\) with array\ will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType count: 1 path: ../../htdocs/variants/class/ProductCombination.class.php - - message: '#^Negated boolean expression is always false\.$#' - identifier: booleanNot.alwaysFalse + message: '#^Loose comparison using \!\= between ''ErrorProductAlready…'' and ''ErrorProductAlready…'' will always evaluate to false\.$#' + identifier: notEqual.alwaysFalse count: 1 path: ../../htdocs/variants/class/ProductCombination.class.php @@ -33289,7 +33259,7 @@ parameters: path: ../../htdocs/website/index.php - - message: '#^Comparison operation "\>\=" between 1 and 0 is always true\.$#' + message: '#^Comparison operation "\>\=" between 0\|1 and 0 is always true\.$#' identifier: greaterOrEqual.alwaysTrue count: 1 path: ../../htdocs/website/samples/wrapper.php @@ -33297,12 +33267,6 @@ parameters: - message: '#^If condition is always false\.$#' identifier: if.alwaysFalse - count: 3 - path: ../../htdocs/website/samples/wrapper.php - - - - message: '#^If condition is always true\.$#' - identifier: if.alwaysTrue count: 1 path: ../../htdocs/website/samples/wrapper.php From f649f59cb9258bc7695938d761eeb60839499506 Mon Sep 17 00:00:00 2001 From: PsyCrow <93346975+PsyCrow-code@users.noreply.github.com> Date: Thu, 23 Jan 2025 18:17:38 -0600 Subject: [PATCH 33/69] FIX #32765 JS Error: Uncaught TypeError FIX #32765 JS Error: Uncaught TypeError --- htdocs/core/lib/functions.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ed2f8085a32..3a6cff28efc 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -11036,7 +11036,7 @@ function printCommonFooter($zone = 'private') } // Management of focus and mandatory for fields - if ($action == 'create' || $action == 'edit' || (empty($action) && (preg_match('/new\.php/', $_SERVER["PHP_SELF"]))) || ((empty($action) || $action == 'addline') && (preg_match('/card\.php/', $_SERVER["PHP_SELF"])))) { + if ($action == 'create' || $action == 'add' || $action == 'edit' || (empty($action) && (preg_match('/new\.php/', $_SERVER["PHP_SELF"]))) || ((empty($action) || $action == 'addline') && (preg_match('/card\.php/', $_SERVER["PHP_SELF"])))) { print '/* JS CODE TO ENABLE to manage focus and mandatory form fields */'."\n"; $relativepathstring = $_SERVER["PHP_SELF"]; // Clean $relativepathstring @@ -11107,7 +11107,7 @@ function printCommonFooter($zone = 'private') // Solution 1: Add handler on submit to check if mandatory fields are empty print 'var form = $(\'#'.dol_escape_js($paramkey).'\').closest("form");'."\n"; print "form.on('submit', function(event) { - var submitter = event.originalEvent.submitter; + var submitter = $(this).find(':submit:focus').get(0); if (submitter) { var buttonName = $(submitter).attr('name'); if (buttonName == 'cancel') { @@ -11134,10 +11134,10 @@ function printCommonFooter($zone = 'private') if (tmpvalue === null || tmpvalue === undefined || tmpvalue === '') { tmpvalueisempty = true; } - if (tmpvalue === '0' && tmptypefield == 'select') { + if (tmpvalue === '0' && (tmptypefield == 'select' || tmptypefield == 'input')) { tmpvalueisempty = true; } - if (tmpvalueisempty) { + if (tmpvalueisempty && (buttonName == 'save')) { console.log('field has type '+tmptypefield+' and is empty, we cancel the submit'); event.preventDefault(); // Stop submission of form to allow custom code to decide. event.stopPropagation(); // Stop other handlers. From 53ec7e48d129383735f0d6bcf9e00b48a3135615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 24 Jan 2025 09:59:02 +0100 Subject: [PATCH 34/69] fix comments --- htdocs/install/mysql/migration/19.0.0-20.0.0.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql index ec3053a6a40..cf2697e3567 100644 --- a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql +++ b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql @@ -349,7 +349,7 @@ ALTER TABLE llx_societe_commerciaux ADD COLUMN fk_c_type_contact_code varchar(32 -- VPGSQL8.2 DROP INDEX uk_societe_commerciaux; ALTER TABLE llx_societe_commerciaux ADD UNIQUE INDEX uk_societe_commerciaux_c_type_contact (fk_soc, fk_user, fk_c_type_contact_code); ALTER TABLE llx_c_type_contact ADD INDEX idx_c_type_contact_code (code); ---Removed, not unique. ALTER TABLE llx_societe_commerciaux ADD CONSTRAINT fk_societe_commerciaux_fk_c_type_contact_code FOREIGN KEY (fk_c_type_contact_code) REFERENCES llx_c_type_contact(code); +-- Removed, not unique. ALTER TABLE llx_societe_commerciaux ADD CONSTRAINT fk_societe_commerciaux_fk_c_type_contact_code FOREIGN KEY (fk_c_type_contact_code) REFERENCES llx_c_type_contact(code); ALTER TABLE llx_societe_commerciaux DROP FOREIGN KEY fk_societe_commerciaux_fk_c_type_contact_code; ALTER TABLE llx_societe_commerciaux ADD CONSTRAINT fk_societe_commerciaux_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid); ALTER TABLE llx_societe_commerciaux ADD CONSTRAINT fk_societe_commerciaux_fk_user FOREIGN KEY (fk_user) REFERENCES llx_user(rowid); @@ -363,7 +363,7 @@ ALTER TABLE llx_ecm_files DROP column keyword; ALTER TABLE llx_c_type_container ADD COLUMN typecontainer varchar(10) DEFAULT 'page'; UPDATE llx_c_type_container SET typecontainer = 'container' WHERE code IN ('banner', 'other', 'menu'); ---UPDATE llx_c_type_container SET typecontainer = 'page' WHERE code IN ('page', 'blogpost'); +-- UPDATE llx_c_type_container SET typecontainer = 'page' WHERE code IN ('page', 'blogpost'); UPDATE llx_c_type_container SET position = 10 WHERE code IN ('page'); UPDATE llx_c_type_container SET position = 20 WHERE code IN ('blogpost'); @@ -413,7 +413,7 @@ ALTER TABLE llx_hrm_evaluation ADD COLUMN entity INTEGER DEFAULT 1 NOT NULL; -- Error SQL DB_ERROR_1170 BLOB/TEXT column 'url' used in key specification without a key length, so we remove completely the unique key ALTER TABLE llx_menu DROP INDEX idx_menu_uk_menu; ALTER TABLE llx_menu MODIFY COLUMN url TEXT NOT NULL; ---ALTER TABLE llx_menu ADD UNIQUE INDEX idx_menu_uk_menu (menu_handler, fk_menu, position, entity, url); +-- ALTER TABLE llx_menu ADD UNIQUE INDEX idx_menu_uk_menu (menu_handler, fk_menu, position, entity, url); UPDATE llx_c_units SET short_label = 'mn' WHERE short_label = 'i' AND code = 'MI'; From 81b0ff4ebf7c510fc9d81d24790c035da4a11a1f Mon Sep 17 00:00:00 2001 From: Dolibot Date: Fri, 24 Jan 2025 12:06:49 +0000 Subject: [PATCH 35/69] PHPStan > Update baseline --- dev/build/phpstan/phpstan-baseline.neon | 234 ------------------------ 1 file changed, 234 deletions(-) diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index ff60a067420..51aaca26db7 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -10734,36 +10734,12 @@ parameters: count: 1 path: ../../../htdocs/core/customreports.php - - - message: '#^Variable \$gval might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/customreports.php - - message: '#^Variable \$page might not be defined\.$#' identifier: variable.undefined count: 1 path: ../../../htdocs/core/customreports.php - - - message: '#^Variable \$search_graph might not be defined\.$#' - identifier: variable.undefined - count: 3 - path: ../../../htdocs/core/customreports.php - - - - message: '#^Variable \$search_groupby might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../htdocs/core/customreports.php - - - - message: '#^Variable \$search_xaxis might not be defined\.$#' - identifier: variable.undefined - count: 5 - path: ../../../htdocs/core/customreports.php - - message: '#^Variable \$search_yaxis might not be defined\.$#' identifier: variable.undefined @@ -10782,12 +10758,6 @@ parameters: count: 1 path: ../../../htdocs/core/customreports.php - - - message: '#^Variable \$tabfamily might not be defined\.$#' - identifier: variable.undefined - count: 3 - path: ../../../htdocs/core/customreports.php - - message: '#^Constructor of class DoliDBMysqli has an unused parameter \$type\.$#' identifier: constructor.unusedParameter @@ -10866,12 +10836,6 @@ parameters: count: 1 path: ../../../htdocs/core/db/sqlite3.class.php - - - message: '#^Method DoliDBSqlite3\:\:getListOfCollation\(\) should return array\\|null but returns array\{array\{charset\: ''UTF\-8'', description\: ''UTF\-8''\}\}\.$#' - identifier: return.type - count: 1 - path: ../../../htdocs/core/db/sqlite3.class.php - - message: '#^Cannot access property \$db on mixed\.$#' identifier: property.nonObject @@ -11424,12 +11388,6 @@ parameters: count: 3 path: ../../../htdocs/core/lib/images.lib.php - - - message: '#^Variable \$extImg might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/lib/images.lib.php - - message: '#^Loose comparison using \=\= between ''suppliers'' and ''fourn'' will always evaluate to false\.$#' identifier: equal.alwaysFalse @@ -12150,12 +12108,6 @@ parameters: count: 1 path: ../../../htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php - - - message: '#^Variable \$carac_client_name might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php - - message: '#^Call to function is_object\(\) with object will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -12198,12 +12150,6 @@ parameters: count: 2 path: ../../../htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php - - - message: '#^Variable \$result might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/modules/barcode/doc/phpbarcode.modules.php - - message: '#^Property modTcpdfbarcode\:\:\$is2d has no type specified\.$#' identifier: missingType.property @@ -12216,18 +12162,6 @@ parameters: count: 1 path: ../../../htdocs/core/modules/barcode/mod_barcode_product_standard.php - - - message: '#^Property mod_barcode_product_standard\:\:\$numbitcounter has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../../htdocs/core/modules/barcode/mod_barcode_product_standard.php - - - - message: '#^Property mod_barcode_product_standard\:\:\$searchcode has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../../htdocs/core/modules/barcode/mod_barcode_product_standard.php - - message: '#^Parameter \#2 \$type of method mod_barcode_thirdparty_standard\:\:literalBarcodeType\(\) expects int, string given\.$#' identifier: argument.type @@ -12336,12 +12270,6 @@ parameters: count: 1 path: ../../../htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php - - - message: '#^Left side of && is always true\.$#' - identifier: booleanAnd.leftAlwaysTrue - count: 1 - path: ../../../htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php - - message: '#^Property Commande\:\:\$availability \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -12450,18 +12378,6 @@ parameters: count: 1 path: ../../../htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php - - - message: '#^Variable \$carac_client_name might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php - - - - message: '#^Variable \$realpath might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php - - message: '#^Parameter \#1 \$object of method CommonDocGenerator\:\:get_substitutionarray_each_var_object\(\) expects array\, Contrat given\.$#' identifier: argument.type @@ -12498,12 +12414,6 @@ parameters: count: 1 path: ../../../htdocs/core/modules/delivery/doc/pdf_storm.modules.php - - - message: '#^Left side of && is always true\.$#' - identifier: booleanAnd.leftAlwaysTrue - count: 1 - path: ../../../htdocs/core/modules/delivery/doc/pdf_storm.modules.php - - message: '#^Parameter \#3 \$posy of method pdf_storm\:\:_tableau_info\(\) expects int, float given\.$#' identifier: argument.type @@ -12558,12 +12468,6 @@ parameters: count: 1 path: ../../../htdocs/core/modules/delivery/doc/pdf_storm.modules.php - - - message: '#^Variable \$realpath might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/modules/delivery/doc/pdf_storm.modules.php - - message: '#^Call to function is_object\(\) with object will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -12582,24 +12486,6 @@ parameters: count: 2 path: ../../../htdocs/core/modules/delivery/doc/pdf_typhon.modules.php - - - message: '#^Property pdf_typhon\:\:\$posxcomm has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../../htdocs/core/modules/delivery/doc/pdf_typhon.modules.php - - - - message: '#^Property pdf_typhon\:\:\$posxremainingqty has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../../htdocs/core/modules/delivery/doc/pdf_typhon.modules.php - - - - message: '#^Property pdf_typhon\:\:\$posxweightvol has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../../htdocs/core/modules/delivery/doc/pdf_typhon.modules.php - - message: '#^Call to function is_object\(\) with object will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -12720,24 +12606,6 @@ parameters: count: 1 path: ../../../htdocs/core/modules/expedition/doc/pdf_merou.modules.php - - - message: '#^Property pdf_merou\:\:\$destinataire has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../../htdocs/core/modules/expedition/doc/pdf_merou.modules.php - - - - message: '#^Property pdf_merou\:\:\$expediteur has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../../htdocs/core/modules/expedition/doc/pdf_merou.modules.php - - - - message: '#^Property pdf_merou\:\:\$livreur has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../../htdocs/core/modules/expedition/doc/pdf_merou.modules.php - - message: '#^Parameter \#4 \$posy of method pdf_rouget\:\:_tableau_tot\(\) expects int, float given\.$#' identifier: argument.type @@ -12768,36 +12636,6 @@ parameters: count: 6 path: ../../../htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php - - - message: '#^Property pdf_standard_expensereport\:\:\$postotalttc has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../../htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php - - - - message: '#^Property pdf_standard_expensereport\:\:\$posxcomment has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../../htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php - - - - message: '#^Property pdf_standard_expensereport\:\:\$posxpiece has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../../htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php - - - - message: '#^Property pdf_standard_expensereport\:\:\$posxprojet has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../../htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php - - - - message: '#^Property pdf_standard_expensereport\:\:\$posxtype has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../../htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php - - message: '#^Ternary operator condition is always false\.$#' identifier: ternary.alwaysFalse @@ -12900,12 +12738,6 @@ parameters: count: 13 path: ../../../htdocs/core/modules/facture/doc/pdf_octopus.modules.php - - - message: '#^Left side of && is always true\.$#' - identifier: booleanAnd.leftAlwaysTrue - count: 1 - path: ../../../htdocs/core/modules/facture/doc/pdf_octopus.modules.php - - message: '#^Parameter \#1 \$a of method pdf_octopus\:\:sumSituation\(\) expects array\\|float\|int\>, array\ given\.$#' identifier: argument.type @@ -13068,12 +12900,6 @@ parameters: count: 3 path: ../../../htdocs/core/modules/facture/doc/pdf_octopus.modules.php - - - message: '#^Variable \$realpath might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/modules/facture/doc/pdf_octopus.modules.php - - message: '#^Call to function is_object\(\) with object will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -13086,12 +12912,6 @@ parameters: count: 1 path: ../../../htdocs/core/modules/facture/doc/pdf_sponge.modules.php - - - message: '#^Left side of && is always true\.$#' - identifier: booleanAnd.leftAlwaysTrue - count: 1 - path: ../../../htdocs/core/modules/facture/doc/pdf_sponge.modules.php - - message: '#^Property CommonInvoice\:\:\$type \(int\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -13212,12 +13032,6 @@ parameters: count: 1 path: ../../../htdocs/core/modules/facture/doc/pdf_sponge.modules.php - - - message: '#^Variable \$realpath might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/modules/facture/doc/pdf_sponge.modules.php - - message: '#^Property mod_facture_mars\:\:\$prefixcreditnote has no type specified\.$#' identifier: missingType.property @@ -13296,12 +13110,6 @@ parameters: count: 1 path: ../../../htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php - - - message: '#^Variable \$max might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/modules/fichinter/mod_pacific.php - - message: '#^Property CommonObject\:\:\$entity \(int\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -14094,36 +13902,6 @@ parameters: count: 2 path: ../../../htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php - - - message: '#^Property pdf_standard_movementstock\:\:\$posxdatemouv has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../../htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php - - - - message: '#^Property pdf_standard_movementstock\:\:\$posxidref has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../../htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php - - - - message: '#^Property pdf_standard_movementstock\:\:\$wref has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../../htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php - - - - message: '#^Variable \$lastmovementdate might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php - - - - message: '#^Variable \$result might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php - - message: '#^Parameter \#1 \$object of method CommonDocGenerator\:\:get_substitutionarray_each_var_object\(\) expects array\, Mo given\.$#' identifier: argument.type @@ -14526,12 +14304,6 @@ parameters: count: 1 path: ../../../htdocs/core/modules/propale/doc/pdf_azur.modules.php - - - message: '#^Variable \$filetomerge_dir might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../htdocs/core/modules/propale/doc/pdf_azur.modules.php - - message: '#^Call to function is_object\(\) with object will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -14646,12 +14418,6 @@ parameters: count: 1 path: ../../../htdocs/core/modules/propale/doc/pdf_cyan.modules.php - - - message: '#^Variable \$filetomerge_dir might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../htdocs/core/modules/propale/doc/pdf_cyan.modules.php - - message: '#^Call to function is_object\(\) with object will always evaluate to true\.$#' identifier: function.alreadyNarrowedType From 4e9faa16be7b29708f5f0c282c3776637a9fccf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 24 Jan 2025 14:14:10 +0100 Subject: [PATCH 36/69] Update societeaccount.class.php --- htdocs/societe/class/societeaccount.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index 47207ec2fda..80fb22b0838 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -162,6 +162,12 @@ class SocieteAccount extends CommonObject * @var string */ public $site; + + /** + * @var int + */ + public $fk_website; + /** * @var ?string */ From a6f978c67f9d19f66a7c8b4a4e015b57bd107c0a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 24 Jan 2025 14:26:07 +0100 Subject: [PATCH 37/69] FIX broken feature, compatibility with "Default search filters" --- htdocs/ticket/list.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 8e800a841db..ea06f4fc308 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -387,13 +387,15 @@ foreach ($search as $key => $val) { $tmpkey = 't.' . $key; if ($key == 'fk_statut' && !empty($search['fk_statut'])) { $newarrayofstatus = array(); - foreach ($search['fk_statut'] as $key2 => $val2) { - if (in_array($val2, array('openall', 'closeall'))) { - continue; + if (is_array($search['fk_statut'])) { + foreach ($search['fk_statut'] as $key2 => $val2) { + if (in_array($val2, array('openall', 'closeall'))) { + continue; + } + $newarrayofstatus[] = $val2; } - $newarrayofstatus[] = $val2; } - if ($search['fk_statut'] == 'openall' || in_array('openall', $search['fk_statut'])) { + if ($search['fk_statut'] == 'openall' || (is_array($search['fk_statut']) && in_array('openall', $search['fk_statut']))) { $newarrayofstatus[] = Ticket::STATUS_NOT_READ; $newarrayofstatus[] = Ticket::STATUS_READ; $newarrayofstatus[] = Ticket::STATUS_ASSIGNED; @@ -401,7 +403,7 @@ foreach ($search as $key => $val) { $newarrayofstatus[] = Ticket::STATUS_NEED_MORE_INFO; $newarrayofstatus[] = Ticket::STATUS_WAITING; } - if ($search['fk_statut'] == 'closeall' || in_array('closeall', $search['fk_statut'])) { + if ($search['fk_statut'] == 'closeall' || (is_array($search['fk_statut']) && in_array('closeall', $search['fk_statut']))) { $newarrayofstatus[] = Ticket::STATUS_CLOSED; $newarrayofstatus[] = Ticket::STATUS_CANCELED; } @@ -901,7 +903,11 @@ foreach ($object->fields as $key => $val) { //var_dump(array_values($search[$key])); $selectedarray = null; if (!empty($search[$key])) { - $selectedarray = array_values($search[$key]); + if (is_array($search[$key])) { + $selectedarray = array_values($search[$key]); + } else { + $selectedarray = array($search[$key]); // Compatibility with "Default search filters" + } } print Form::multiselectarray('search_fk_statut', $arrayofstatus, $selectedarray, 0, 0, 'search_status width150 onrightofpage', 1, 0, '', '', ''); print ''; From 0932c2e492169019a1dd5cd1c6c5c30f1c7e1f3a Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Fri, 24 Jan 2025 17:28:10 +0100 Subject: [PATCH 38/69] Debug v21 --- htdocs/comm/action/class/actioncomm.class.php | 2 +- htdocs/comm/action/index.php | 259 ++--- htdocs/comm/action/peruser.php | 930 +++++++++++++++--- htdocs/contact/card.php | 5 +- htdocs/holiday/list.php | 5 +- htdocs/langs/fr_FR/holiday.lang | 2 +- 6 files changed, 939 insertions(+), 264 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 6eb05106686..d198de99b1a 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1883,7 +1883,7 @@ class ActionComm extends CommonObject $color = 'style="color: #'.$this->type_color.' !important;"'; } if ($this->type_picto) { - $imgpicto = img_picto($titlealt.'rr', $this->type_picto, '', 0, 0, 0, '', ($morecss ? ' '.$morecss : '')); + $imgpicto = img_picto($titlealt, $this->type_picto, '', 0, 0, 0, '', ($morecss ? ' '.$morecss : '')); } else { if ($this->type_code == 'AC_RDV') { $imgpicto = img_picto($titlealt, 'meeting', $color, 0, 0, 0, '', ($morecss ? ' '.$morecss : '')); diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 93ae98884a3..02737de7db2 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -33,14 +33,13 @@ // Load Dolibarr environment require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; -if (isModEnabled('project')) { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -} +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; /** * @var Conf $conf @@ -50,14 +49,7 @@ if (isModEnabled('project')) { * @var User $user */ -if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) { - $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; -} - -if (!getDolGlobalString('AGENDA_EXT_NB')) { - $conf->global->AGENDA_EXT_NB = 5; -} -$MAXAGENDA = getDolGlobalString('AGENDA_EXT_NB'); +$MAXAGENDA = getDolGlobalString('AGENDA_EXT_NB', 5); $DELAYFORCACHE = 300; // 300 seconds $disabledefaultvalues = GETPOSTINT('disabledefaultvalues'); @@ -122,10 +114,10 @@ $year = GETPOSTINT("year") ? GETPOSTINT("year") : date("Y"); $month = GETPOSTINT("month") ? GETPOSTINT("month") : date("m"); $week = GETPOSTINT("week") ? GETPOSTINT("week") : date("W"); $day = GETPOSTINT("day") ? GETPOSTINT("day") : date("d"); -$pid = GETPOSTINT("search_projectid", 3) ? GETPOSTINT("search_projectid", 3) : GETPOSTINT("projectid", 3); +$pid = GETPOSTISSET("search_projectid") ? GETPOSTINT("search_projectid", 3) : GETPOSTINT("projectid", 3); $status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo', 'na' or -1 $type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'aZ09') : GETPOST("type", 'aZ09'); -$maxprint = GETPOSTISSET("maxprint") ? GETPOSTINT("maxprint") : getDolGlobalInt('AGENDA_MAX_EVENTS_DAY_VIEW'); +$maxprint = GETPOSTISSET("maxprint") ? GETPOSTINT("maxprint") : getDolGlobalInt('AGENDA_MAX_EVENTS_DAY_VIEW', 3); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $dateselect = dol_mktime(0, 0, 0, GETPOSTINT('dateselectmonth'), GETPOSTINT('dateselectday'), GETPOSTINT('dateselectyear')); @@ -149,7 +141,7 @@ if (is_scalar($actioncode) && $actioncode == '-1') { } if ($status == '' && !GETPOSTISSET('search_status')) { - $status = ((!getDolGlobalString('AGENDA_DEFAULT_FILTER_STATUS') || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); + $status = ((!getDolGlobalString('AGENDA_DEFAULT_FILTER_STATUS') || $disabledefaultvalues) ? '' : getDolGlobalString('AGENDA_DEFAULT_FILTER_STATUS')); } $defaultview = getDolGlobalString('AGENDA_DEFAULT_VIEW', 'show_month'); // default for app @@ -253,14 +245,14 @@ if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } -$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung'; -llxHeader('', $langs->trans("Agenda"), $help_url); - $form = new Form($db); $companystatic = new Societe($db); $contactstatic = new Contact($db); $userstatic = new User($db); +$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung'; +llxHeader('', $langs->trans("Agenda"), $help_url); + $now = dol_now(); $nowarray = dol_getdate($now); $nowyear = $nowarray['year']; @@ -407,9 +399,13 @@ if ($mode == 'show_day') { //print dol_print_date($firstdaytoshow,'dayhour').' '.dol_print_date($lastdaytoshow,'dayhour'); /*$title = $langs->trans("DoneAndToDoActions"); - if ($status == 'done') $title = $langs->trans("DoneActions"); - if ($status == 'todo') $title = $langs->trans("ToDoActions"); - */ +if ($status == 'done') { + $title = $langs->trans("DoneActions"); +} +if ($status == 'todo') { + $title = $langs->trans("ToDoActions"); +} +*/ $param = ''; if ($actioncode || GETPOSTISSET('search_actioncode')) { @@ -428,10 +424,10 @@ if ($status || GETPOSTISSET('status') || GETPOSTISSET('search_status')) { $param .= "&search_status=".urlencode($status); } if ($filter) { - $param .= "&search_filter=".urlencode($filter); + $param .= "&search_filter=".urlencode((string) $filter); } if ($filtert) { - $param .= "&search_filtert=".urlencode($filtert); + $param .= "&search_filtert=".urlencode((string) $filtert); } if ($usergroup > 0) { $param .= "&search_usergroup=".urlencode((string) ($usergroup)); @@ -771,10 +767,14 @@ if ($resourceid > 0) { } // We must filter on assignment table if ($filtert > 0 || $usergroup > 0) { - $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; -} -if ($usergroup > 0) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar"; + $sql .= " ON ar.fk_actioncomm = a.id AND ar.element_type='user'"; + if ($filtert > 0) { + $sql .= " AND ar.fk_element = ".((int) $filtert); + } + if ($usergroup > 0) { + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element AND ugu.fk_usergroup = ".((int) $usergroup); + } } $sql .= ' WHERE a.fk_action = ca.id'; $sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // bookcal is a "virtual view" of agenda @@ -830,10 +830,6 @@ if ($search_sale && $search_sale != '-1') { if ($socid) { $sql .= " AND a.fk_soc = ".((int) $socid); } -// We must filter on assignment table -if ($filtert > 0 || $usergroup > 0) { - $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; -} //var_dump($day.' '.$month.' '.$year); if ($mode == 'show_day') { $sql .= " AND ("; @@ -866,7 +862,7 @@ if ($status == '0') { // To do (not started) $sql .= " AND a.percent = 0"; } -if ($status == 'na') { +if ($status === 'na') { // Not applicable $sql .= " AND a.percent = -1"; } @@ -902,7 +898,7 @@ if ($search_categ_cus != -1) { } // Sort on date -$sql .= ' ORDER BY datep'; +$sql .= $db->order("datep"); //print $sql; dol_syslog("comm/action/index.php", LOG_DEBUG); @@ -1170,8 +1166,8 @@ if ($user->hasRight("holiday", "read")) { $event->type = 'holiday'; $event->type_picto = 'holiday'; - $event->datep = $db->jdate($obj->date_start) + (empty($halfday) || $halfday == 1 ? 0 : 12 * 60 * 60 - 1); - $event->datef = $db->jdate($obj->date_end) + (empty($halfday) || $halfday == -1 ? 24 : 12) * 60 * 60 - 1; + $event->datep = $db->jdate($obj->date_start) + (empty($obj->halfday) || $obj->halfday == 1 ? 0 : 12 * 60 * 60 - 1); + $event->datef = $db->jdate($obj->date_end) + (empty($obj->halfday) || $obj->halfday == -1 ? 24 : 12) * 60 * 60 - 1; $event->date_start_in_calendar = $event->datep; $event->date_end_in_calendar = $event->datef; @@ -1183,24 +1179,50 @@ if ($user->hasRight("holiday", "read")) { $event->percentage = 0; } - if ($obj->halfday == 1) { - $event->label = $obj->lastname.' ('.$langs->trans("Morning").')'; - } elseif ($obj->halfday == -1) { - $event->label = $obj->lastname.' ('.$langs->trans("Afternoon").')'; - } else { - $event->label = $obj->lastname; - } + $event->label = $langs->trans("Holiday"); $daycursor = $event->date_start_in_calendar; $annee = (int) dol_print_date($daycursor, '%Y', 'tzuserrel'); $mois = (int) dol_print_date($daycursor, '%m', 'tzuserrel'); $jour = (int) dol_print_date($daycursor, '%d', 'tzuserrel'); + $daycursorend = $event->date_end_in_calendar; + $anneeend = (int) dol_print_date($daycursorend, '%Y', 'tzuserrel'); + $moisend = (int) dol_print_date($daycursorend, '%m', 'tzuserrel'); + $jourend = (int) dol_print_date($daycursorend, '%d', 'tzuserrel'); + + // daykey must be date that represent day box in calendar so must be a user time $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); + $daykeygmt = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); + $ifornbofdays = 0; do { - $eventarray[$daykey][] = $event; + $ifornbofdays++; + + $firstdayofholiday = ($ifornbofdays == 1); + $lastdayofholiday = ($daykeygmt == dol_get_first_hour($event->date_end_in_calendar, 'gmt')); + + /* + var_dump(dol_print_date($daykeygmt, 'dayhour', 'gmt')); + var_dump(dol_print_date(dol_get_first_hour($event->date_end_in_calendar, 'gmt'), 'dayhour', 'gmt')); + var_dump($lastdayofholiday); + var_dump($obj->halfday); + */ + + if ((in_array($obj->halfday, array(1, 2)) == 1 && $lastdayofholiday) || (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday)) { + // We create a copy of event because we want tochange the label + $newevent = dol_clone($event, 1); + if (in_array($obj->halfday, array(1, 2)) && $lastdayofholiday) { + $newevent->label .= ' ('.$langs->trans("Morning").')'; + } elseif (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday) { + $newevent->label .= ' ('.$langs->trans("Afternoon").')'; + } + $eventarray[$daykey][] = $newevent; // We need to use ->gtTypePicto, getXXXon object, so clone must be PHP clone. + } else { + $eventarray[$daykey][] = $event; // We can use the event unchanged + } $daykey += 60 * 60 * 24; + $daykeygmt += 60 * 60 * 24; } while ($daykey <= $event->date_end_in_calendar); $i++; @@ -1951,6 +1973,10 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa if (!empty($cacheusers[$event->userownerid]->color)) { $color = $cacheusers[$event->userownerid]->color; } + + /* May be we need this: if (getDolGlobalString('AGENDA_USE_COLOR_PER_EVENT_TYPE')) { + $color = $event->type_color; + }*/ } elseif ($event->type_code == 'ICALEVENT') { // Event come from external ical file $numical++; if (!empty($event->icalname)) { @@ -2092,7 +2118,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa //var_dump($event->userassigned); //var_dump($event->transparency); print ''; + + // First the tr of the event (only one tr for event is used, but several td) print ''; print ''; + // Status - Percent $withstatus = 0; - if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') { + if ($event->type_code != 'HOLIDAY' && $event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') { $withstatus = 1; if ($event->percentage >= 0) { $withstatus = 2; diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index bab2ff5916c..915094db599 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -49,14 +49,12 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; * @var User $user */ -if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) { - $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; -} - -$action = GETPOST('action', 'aZ09'); +$MAXAGENDA = getDolGlobalString('AGENDA_EXT_NB', 5); +$DELAYFORCACHE = 300; // 300 seconds $disabledefaultvalues = GETPOSTINT('disabledefaultvalues'); +$check_holiday = GETPOSTINT('check_holiday'); $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); $filtert = GETPOSTINT("search_filtert", 3) ? GETPOSTINT("search_filtert", 3) : GETPOSTINT("filtert", 3); $usergroup = GETPOSTINT("search_usergroup", 3) ? GETPOSTINT("search_usergroup", 3) : GETPOSTINT("usergroup", 3); @@ -64,10 +62,9 @@ $usergroup = GETPOSTINT("search_usergroup", 3) ? GETPOSTINT("search_usergroup", //$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; $showbirthday = 0; -// If not choice done on calendar owner, we filter on user. -/*if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) -{ - $filtert = $user->id; +// If no choice done on calendar owner (like on left menu link "Agenda"), we filter on current user by default. +/*if (empty($filtert) && !getDolGlobalString('AGENDA_ALL_CALENDARS')) { + $filtert = (string) $user->id; }*/ $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -85,6 +82,7 @@ if (!$sortfield) { $sortfield = "a.datec"; } +// Security check $socid = GETPOSTINT("search_socid") ? GETPOSTINT("search_socid") : GETPOSTINT("socid"); if ($user->socid) { $socid = $user->socid; @@ -101,19 +99,21 @@ if (!$user->hasRight('agenda', 'allactions', 'read')) { $canedit = 0; } if (!$user->hasRight('agenda', 'allactions', 'read') || $filter == 'mine') { // If no permission to see all, we show only affected to me - $filtert = $user->id; + $filtert = (string) $user->id; } +$action = GETPOST('action', 'aZ09'); + $mode = 'show_peruser'; $resourceid = GETPOSTINT("search_resourceid") ? GETPOSTINT("search_resourceid") : GETPOSTINT("resourceid"); -$year = GETPOSTINT("year") ? GETPOSTINT("year") : idate("Y"); -$month = GETPOSTINT("month") ? GETPOSTINT("month") : idate("m"); -$week = GETPOSTINT("week") ? GETPOSTINT("week") : idate("W"); -$day = GETPOSTINT("day") ? GETPOSTINT("day") : idate("d"); +$year = GETPOSTINT("year") ? GETPOSTINT("year") : date("Y"); +$month = GETPOSTINT("month") ? GETPOSTINT("month") : date("m"); +$week = GETPOSTINT("week") ? GETPOSTINT("week") : date("W"); +$day = GETPOSTINT("day") ? GETPOSTINT("day") : date("d"); $pid = GETPOSTISSET("search_projectid") ? GETPOSTINT("search_projectid", 3) : GETPOSTINT("projectid", 3); $status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo', 'na' or -1 -$type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); -$maxprint = ((GETPOSTINT("maxprint") != '') ? GETPOSTINT("maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); +$type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'aZ09') : GETPOST("type", 'aZ09'); +$maxprint = GETPOSTISSET("maxprint") ? GETPOSTINT("maxprint") : getDolGlobalInt('AGENDA_MAX_EVENTS_DAY_VIEW', 3); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $search_categ_cus = GETPOSTINT("search_categ_cus", 3) ? GETPOSTINT("search_categ_cus", 3) : 0; // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) @@ -133,7 +133,7 @@ if ($dateselect > 0) { $year = GETPOSTINT('dateselectyear'); } -$tmp = !getDolGlobalString('MAIN_DEFAULT_WORKING_HOURS') ? '9-18' : $conf->global->MAIN_DEFAULT_WORKING_HOURS; +$tmp = getDolGlobalString('MAIN_DEFAULT_WORKING_HOURS', '9-18'); $tmp = str_replace(' ', '', $tmp); // FIX 7533 $tmparray = explode('-', $tmp); $begin_h = GETPOSTISSET('begin_h') ? GETPOSTINT('begin_h') : ($tmparray[0] != '' ? $tmparray[0] : 9); @@ -148,7 +148,7 @@ if ($end_h <= $begin_h) { $end_h = $begin_h + 1; } -$tmp = !getDolGlobalString('MAIN_DEFAULT_WORKING_DAYS') ? '1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS; +$tmp = getDolGlobalString('MAIN_DEFAULT_WORKING_DAYS', '1-5'); $tmp = str_replace(' ', '', $tmp); // FIX 7533 $tmparray = explode('-', $tmp); $begin_d = GETPOSTISSET('begin_d') ? GETPOSTINT('begin_d') : ($tmparray[0] != '' ? $tmparray[0] : 1); @@ -164,7 +164,7 @@ if ($end_d < $begin_d) { } if ($status == '' && !GETPOSTISSET('search_status')) { - $status = ((!getDolGlobalString('AGENDA_DEFAULT_FILTER_STATUS') || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); + $status = ((!getDolGlobalString('AGENDA_DEFAULT_FILTER_STATUS') || $disabledefaultvalues) ? '' : getDolGlobalString('AGENDA_DEFAULT_FILTER_STATUS')); } if (empty($mode) && !GETPOSTISSET('mode')) { @@ -177,12 +177,12 @@ if (GETPOST('viewcal', 'alpha') && $mode != 'show_day' && $mode != 'show_week' & } // View by month if (GETPOST('viewweek', 'alpha') || $mode == 'show_week') { $mode = 'show_week'; - $week = ($week ? $week : idate("W")); - $day = ($day ? $day : idate("d")); + $week = ($week ? $week : date("W")); + $day = ($day ? $day : date("d")); } // View by week if (GETPOST('viewday', 'alpha') || $mode == 'show_day') { $mode = 'show_day'; - $day = ($day ? $day : idate("d")); + $day = ($day ? $day : date("d")); } // View by day $object = new ActionComm($db); @@ -193,7 +193,7 @@ $langs->loadLangs(array('users', 'agenda', 'other', 'commercial')); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('agenda')); -$result = restrictedArea($user, 'agenda', 0, '', 'myactions'); +$result = restrictedArea($user, 'agenda', 0, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); if ($user->socid && $socid) { $result = restrictedArea($user, 'societe', $socid); } @@ -248,9 +248,65 @@ $nowmonth = $nowarray['mon']; $nowday = $nowarray['mday']; -// Define list of all external calendars (global setup) $listofextcals = array(); +// Define list of all external calendars (global setup) +if (!getDolGlobalString('AGENDA_DISABLE_EXT')) { + $i = 0; + while ($i < $MAXAGENDA) { + $i++; + $source = 'AGENDA_EXT_SRC'.$i; + $name = 'AGENDA_EXT_NAME'.$i; + $offsettz = 'AGENDA_EXT_OFFSETTZ'.$i; + $color = 'AGENDA_EXT_COLOR'.$i; + $default = 'AGENDA_EXT_ACTIVEBYDEFAULT'.$i; + $buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i; + if (getDolGlobalString($source) && getDolGlobalString($name)) { + // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' + $listofextcals[] = array( + 'type' => 'globalsetup', + 'src' => getDolGlobalString($source), + 'name' => dol_string_nohtmltag(getDolGlobalString($name)), + 'offsettz' => (int) getDolGlobalInt($offsettz, 0), + 'color' => dol_string_nohtmltag(getDolGlobalString($color)), + // @phan-suppress-next-line PhanPluginSuspiciousParamPosition + 'default' => dol_string_nohtmltag(getDolGlobalString($default)), + 'buggedfile' => dol_string_nohtmltag(getDolGlobalString('buggedfile', '')) + ); + } + } +} + +// Define list of external calendars (user setup) +if (!getDolUserString('AGENDA_DISABLE_EXT')) { + $i = 0; + while ($i < $MAXAGENDA) { + $i++; + $source = 'AGENDA_EXT_SRC_'.$user->id.'_'.$i; + $name = 'AGENDA_EXT_NAME_'.$user->id.'_'.$i; + $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i; + $color = 'AGENDA_EXT_COLOR_'.$user->id.'_'.$i; + $enabled = 'AGENDA_EXT_ENABLED_'.$user->id.'_'.$i; + $default = 'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.'_'.$i; + $buggedfile = 'AGENDA_EXT_BUGGEDFILE_'.$user->id.'_'.$i; + + if (getDolUserString($source) && getDolUserString($name)) { + // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' + $listofextcals[] = array( + 'type' => 'usersetup', + 'src' => getDolUserString($source), + 'name' => dol_string_nohtmltag(getDolUserString($name)), + 'offsettz' => (int) (empty($user->conf->$offsettz) ? 0 : $user->conf->$offsettz), + 'color' => dol_string_nohtmltag(getDolUserString($color)), + // @phan-suppress-next-line PhanPluginSuspiciousParamPosition + 'default' => dol_string_nohtmltag(getDolUserString($default)), + 'buggedfile' => dol_string_nohtmltag(isset($user->conf->buggedfile) ? $user->conf->buggedfile : '') + ); + } + } +} + + $prev = dol_get_first_day_week($day, $month, $year); $first_day = $prev['first_day']; $first_month = $prev['first_month']; @@ -264,7 +320,7 @@ $next_year = $next['year']; $next_month = $next['month']; $next_day = $next['day']; -$max_day_in_month = idate("t", dol_mktime(0, 0, 0, $month, 1, $year)); +$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); $tmpday = $first_day; //print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day; @@ -296,7 +352,7 @@ if ($status || GETPOSTISSET('status') || GETPOSTISSET('search_status')) { $param .= "&search_status=".urlencode($status); } if ($filter) { - $param .= "&search_filter=".urlencode($filter); + $param .= "&search_filter=".urlencode((string) $filter); } if ($filtert) { $param .= "&search_filtert=".urlencode((string) $filtert); @@ -377,66 +433,31 @@ $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $first_mo $nav .= " \n"; $nav .= "   trans("Next"))."\">\n"; if (empty($conf->dol_optimize_smallscreen)) { - $nav .= "   '.$langs->trans("Today").' '; + $nav .= '   '.$langs->trans("Today").' '; } $nav .= ''; $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); -$nav .= ' '; +//$nav .= ' '; +$nav .= ''; // Must be after the nav definition -$param .= '&year='.urlencode((string) ($year)).'&month='.urlencode((string) ($month)).($day ? '&day='.urlencode((string) ($day)) : ''); +$paramnodate = $param; +$param .= '&year='.$year.'&month='.$month.($day ? '&day='.$day : ''); //print 'x'.$param; -$paramnoaction = preg_replace('/action=[a-z_]+/', '', $param); +$paramnoaction = preg_replace('/mode=[a-z_]+/', '', preg_replace('/action=[a-z_]+/', '', $param)); +$paramnoactionodate = preg_replace('/mode=[a-z_]+/', '', preg_replace('/action=[a-z_]+/', '', $paramnodate)); $head = calendars_prepare_head($paramnoaction); print ''."\n"; - -$showextcals = $listofextcals; -// Legend -if ($conf->use_javascript_ajax) { - $s = ''; - $s .= ''."\n"; - if (!empty($conf->use_javascript_ajax)) { - $s .= '
'.$langs->trans("LocalAgenda").'  
'; - if (is_array($showextcals) && count($showextcals) > 0) { - foreach ($showextcals as $val) { - $htmlname = md5($val['name']); - $s .= ''."\n"; - $s .= '
'.$val ['name'].'  
'; - } - } - - //$s.='
'.$langs->trans("AgendaShowBirthdayEvents").'  
'; - - // Calendars from hooks - $parameters = array(); - $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); - if (empty($reshook)) { - $s .= $hookmanager->resPrint; - } elseif ($reshook > 1) { - $s = $hookmanager->resPrint; - } - } +if ($optioncss != '') { + print ''; } +print ''; +print ''; + $mode = 'show_peruser'; $massactionbutton = ''; @@ -515,43 +536,135 @@ if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda' $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', $urltocreateaction); } -$num = 0; - -print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.''.$newcardbutton, '', $limit, 1, 0, 1, $viewmode); +// Define the legend/list of calendard to show +$s = ''; $link = ''; -//print load_fiche_titre('', $link.'     '.$nav.' '.$newcardbutton, ''); -$s .= "\n".''."\n"; +$showextcals = $listofextcals; +$bookcalcalendars = array(); -// Local calendar -$newtitle = '
'; -$newtitle .= ' '.$langs->trans("LocalAgenda").'   '; -$newtitle .= '
'; -//$newtitle=$langs->trans($title); - -$s = $newtitle; - -// Calendars from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); -if (empty($reshook)) { - $s .= $hookmanager->resPrint; -} elseif ($reshook > 1) { - $s = $hookmanager->resPrint; +// Load Bookcal Calendars +if (isModEnabled("bookcal")) { + $sql = "SELECT ba.rowid, bc.label, bc.ref, bc.rowid as id_cal"; + $sql .= " FROM ".MAIN_DB_PREFIX."bookcal_availabilities as ba"; + $sql .= " JOIN ".MAIN_DB_PREFIX."bookcal_calendar as bc"; + $sql .= " ON bc.rowid = ba.fk_bookcal_calendar"; + $sql .= " WHERE bc.status = 1"; + $sql .= " AND ba.status = 1"; + $sql .= " AND bc.entity IN (".getEntity('agenda').")"; // bookcal is a "virtual view" of agenda + if (!empty($filtert) && $filtert != '-1') { + $sql .= " AND bc.visibility IN (".$db->sanitize($filtert, 0, 0, 0, 0).")"; + } + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $objp = $db->fetch_object($resql); + $label = !empty($objp->label) ? $objp->label : $objp->ref; + $bookcalcalendars["calendars"][] = array("id" => $objp->id_cal, "label" => $label); + $bookcalcalendars["availabilitieslink"][$objp->rowid] = $objp->id_cal; + $i++; + } + } else { + dol_print_error($db); + } } -$s .= "\n".''."\n"; +if (!empty($conf->use_javascript_ajax)) { // If javascript on + $s .= "\n".''."\n"; -print $s; + $s .= ''."\n"; -print '
'; -print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, '', (string) $filtert, '', $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid, $search_categ_cus); -print '
'; + // Local calendar + $s .= '
'; + + // Holiday calendar + if ($user->hasRight("holiday", "read")) { + $s .= ' +
+   +
'; + } + + // External calendars + if (is_array($showextcals) && count($showextcals) > 0) { + foreach ($showextcals as $val) { + $htmlname = md5($val['name']); // not used for security purpose, only to get a string with no special char + + $s .= ''."\n"; + $s .= '
'.$val ['name'].'  
'; + } + } + + // Birthdays + //$s.='
'.$langs->trans("AgendaShowBirthdayEvents").'  
'; + + // Bookcal Calendar + /* + if (isModEnabled("bookcal")) { + if (!empty($bookcalcalendars["calendars"])) { + foreach ($bookcalcalendars["calendars"] as $key => $value) { + $label = $value['label']; + $s .= '
'; + $s .= ''; + $s .= '  
'; + } + } + } + */ + + // Calendars from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); + if (empty($reshook)) { + $s .= $hookmanager->resPrint; + } elseif ($reshook > 1) { + $s = $hookmanager->resPrint; + } + + $s .= "\n".''."\n"; +} else { // If javascript off + $newparam = $param; // newparam is for birthday links + $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam); + if (!preg_match('/showbirthday=/i', $newparam)) { + $newparam .= '&showbirthday=1'; + } + $link = ''; + if (empty($showbirthday)) { + $link .= $langs->trans("AgendaShowBirthdayEvents"); + } else { + $link .= $langs->trans("AgendaHideBirthdayEvents"); + } + $link .= ''; +} -// Get event in an array +// Load events from database into $eventarray $eventarray = array(); @@ -566,8 +679,14 @@ $sql .= " a.datep2,"; $sql .= " a.percent,"; $sql .= " a.fk_user_author,a.fk_user_action,"; $sql .= " a.transparency, a.priority, a.fulldayevent, a.location,"; -$sql .= " a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,"; -$sql .= " ca.code, ca.libelle as type_label, ca.color, ca.type as type_type, ca.picto as type_picto"; +$sql .= " a.fk_soc, a.fk_contact, a.fk_project, a.fk_bookcal_calendar,"; +$sql .= " a.fk_element, a.elementtype,"; +$sql .= " ca.code as type_code, ca.libelle as type_label, ca.color as type_color, ca.type as type_type, ca.picto as type_picto"; + +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm as ca, ".MAIN_DB_PREFIX."actioncomm as a"; // We must filter on resource table if ($resourceid > 0) { @@ -586,7 +705,7 @@ if ($filtert > 0 || $usergroup > 0) { } $sql .= " WHERE a.fk_action = ca.id"; -$sql .= " AND a.entity IN (".getEntity('agenda').")"; +$sql .= " AND a.entity IN (".getEntity('agenda').")"; // bookcal is a "virtual view" of agenda // Condition on actioncode if (!empty($actioncode)) { if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE')) { @@ -624,7 +743,7 @@ if ($pid) { } // If the internal user must only see his customers, force searching by him $search_sale = 0; -if (!$user->hasRight('societe', 'client', 'voir')) { +if (isModEnabled("societe") && !$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; } // Search on sale representative @@ -668,6 +787,7 @@ if ($type) { $sql .= " AND ca.id = ".((int) $type); } if ($status == '0') { + // To do (not started) $sql .= " AND a.percent = 0"; } if ($status === 'na') { @@ -684,6 +804,18 @@ if ($status == 'done' || $status == '100') { if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } +// We must filter on assignment table +if ($filtert > 0 || $usergroup > 0) { + $sql .= " AND ("; + if ($filtert > 0) { + $sql .= "ar.fk_element = ".((int) $filtert); + } + if ($usergroup > 0) { + $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".((int) $usergroup); + } + $sql .= ")"; +} + // Search in categories, -1 is all and -2 is no categories if ($search_categ_cus != -1) { if ($search_categ_cus == -2) { @@ -701,13 +833,14 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); + $MAXONSAMEPAGE = 10000; // Useless to have more. Protection to avoid memory overload when high number of event (for example after a mass import) $i = 0; - while ($i < $num) { + while ($i < $num && $i < $MAXONSAMEPAGE) { $obj = $db->fetch_object($resql); //print $obj->fk_user_action.' '.$obj->id."
"; // Discard auto action if option is on - if (getDolGlobalString('AGENDA_ALWAYS_HIDE_AUTO') && $obj->code == 'AC_OTH_AUTO') { + if (getDolGlobalString('AGENDA_ALWAYS_HIDE_AUTO') && $obj->type_code == 'AC_OTH_AUTO') { $i++; continue; } @@ -718,49 +851,70 @@ if ($resql) { // Create a new object action $event = new ActionComm($db); + $event->id = $obj->id; - $event->datep = $datep; // datep and datef are GMT date - $event->datef = $datep2; - $event->type_code = $obj->code; - $event->type_color = $obj->color; + $event->ref = $event->id; + + $event->fulldayevent = $obj->fulldayevent; + + // event->datep and event->datef must be GMT date. + if ($event->fulldayevent) { + $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); + $event->datep = $db->jdate($obj->datep, $tzforfullday ? 'tzuser' : 'tzserver'); // If saved in $tzforfullday = gmt, we must invert date to be in user tz + $event->datef = $db->jdate($obj->datep2, $tzforfullday ? 'tzuser' : 'tzserver'); + } else { + // Example: $obj->datep = '1970-01-01 01:00:00', jdate will return 0 if TZ of PHP server is Europe/Berlin (+1) + $event->datep = $db->jdate($obj->datep, 'tzserver'); + $event->datef = $db->jdate($obj->datep2, 'tzserver'); + } + //$event->datep_formated_gmt = dol_print_date($event->datep, 'dayhour', 'gmt'); + //var_dump($obj->id.' '.$obj->datep.' '.dol_print_date($obj->datep, 'dayhour', 'gmt')); + //var_dump($obj->id.' '.$event->datep.' '.dol_print_date($event->datep, 'dayhour', 'gmt')); + + $event->type_code = $obj->type_code; + $event->type_label = $obj->type_label; + $event->type_color = $obj->type_color; + $event->type = $obj->type_type; + $event->type_picto = $obj->type_picto; + $event->label = $obj->label; $event->percentage = $obj->percent; $event->authorid = $obj->fk_user_author; // user id of creator $event->userownerid = $obj->fk_user_action; // user id of owner + $event->fetch_userassigned(); // This load $event->userassigned + $event->priority = $obj->priority; - $event->fulldayevent = $obj->fulldayevent; $event->location = $obj->location; $event->transparency = $obj->transparency; + $event->fk_element = $obj->fk_element; + $event->elementid = $obj->fk_element; + $event->elementtype = $obj->elementtype; $event->fk_project = $obj->fk_project; $event->socid = $obj->fk_soc; $event->contact_id = $obj->fk_contact; - - $event->fk_element = $obj->fk_element; - $event->elementid = $obj->fk_element; - $event->elementtype = $obj->elementtype; + $event->fk_bookcal_calendar = $obj->fk_bookcal_calendar; + if (!empty($event->fk_bookcal_calendar)) { + $event->type = "bookcal_calendar"; + } // Defined date_start_in_calendar and date_end_in_calendar property // They are date start and end of action but modified to not be outside calendar view. - $event->date_start_in_calendar = $datep; - if ($datep2 != '' && $datep2 >= $datep) { - $event->date_end_in_calendar = $datep2; + $event->date_start_in_calendar = $event->datep; + if ($event->datef != '' && $event->datef >= $event->datep) { + $event->date_end_in_calendar = $event->datef; } else { - $event->date_end_in_calendar = $datep; + $event->date_end_in_calendar = $event->datep; } //print '
'.$i.' - eventid='.$event->id.' '.dol_print_date($event->date_start_in_calendar, 'dayhour').' '.dol_print_date($firstdaytoshow, 'dayhour').' - '.dol_print_date($event->date_end_in_calendar, 'dayhour').' '.dol_print_date($lastdaytoshow, 'dayhour').'
'."\n"; // Check values - if ($event->date_end_in_calendar < $firstdaytoshow || - $event->date_start_in_calendar >= $lastdaytoshow) { + if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) { // This record is out of visible range unset($event); } else { - //print $i.' - eventid='.$event->id.' '.dol_print_date($event->date_start_in_calendar, 'dayhour').' - '.dol_print_date($event->date_end_in_calendar, 'dayhour').'
'."\n"; - $event->fetch_userassigned(); // This load $event->userassigned - if ($event->date_start_in_calendar < $firstdaytoshow) { $event->date_start_in_calendar = $firstdaytoshow; } @@ -773,33 +927,527 @@ if ($resql) { $annee = (int) dol_print_date($daycursor, '%Y', 'tzuserrel'); $mois = (int) dol_print_date($daycursor, '%m', 'tzuserrel'); $jour = (int) dol_print_date($daycursor, '%d', 'tzuserrel'); - //print $daycursor.' '.dol_print_date($daycursor, 'dayhour', 'gmt').' '.$event->id.' -> '.$annee.'-'.$mois.'-'.$jour.'
'; + + $daycursorend = $event->date_end_in_calendar; + $anneeend = (int) dol_print_date($daycursorend, '%Y', 'tzuserrel'); + $moisend = (int) dol_print_date($daycursorend, '%m', 'tzuserrel'); + $jourend = (int) dol_print_date($daycursorend, '%d', 'tzuserrel'); // Loop on each day covered by action to prepare an index to show on calendar $loop = true; $j = 0; - $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); // $mois, $jour, $annee has been set for user tz + $daykeyend = dol_mktime(0, 0, 0, $moisend, $jourend, $anneeend, 'gmt'); // $moisend, $jourend, $anneeend has been set for user tz + /* + print 'GMT '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'gmt').'
'; + print 'TZSERVER '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzserver').'
'; + print 'TZUSERREL '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzuserrel').'
'; + print 'GMT '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'gmt').'
'; + print 'TZSERVER '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzserver').'
'; + print 'TZUSER '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel').'
'; + */ do { - //print 'Add event into eventarray for daykey='.$daykey.'='.dol_print_date($daykey, 'dayhour', 'gmt').' '.$event->id.' '.$event->datep.' '.$event->datef.'
'; + //if ($event->id==408) + //print 'daykey='.$daykey.' daykeyend='.$daykeyend.' '.dol_print_date($daykey, 'dayhour', 'gmt').' - '.dol_print_date($event->datep, 'dayhour', 'gmt').' '.dol_print_date($event->datef, 'dayhour', 'gmt').'
'; + //print 'daykey='.$daykey.' daykeyend='.$daykeyend.' '.dol_print_date($daykey, 'dayhour', 'tzuserrel').' - '.dol_print_date($event->datep, 'dayhour', 'tzuserrel').' '.dol_print_date($event->datef, 'dayhour', 'tzuserrel').'
'; $eventarray[$daykey][] = $event; $j++; $daykey += 60 * 60 * 24; - if ($daykey > $event->date_end_in_calendar) { + //if ($daykey > $event->date_end_in_calendar) { + if ($daykey > $daykeyend) { $loop = false; } } while ($loop); - + //var_dump($eventarray); //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
'; } + + $parameters['obj'] = $obj; + $reshook = $hookmanager->executeHooks('hookEventElements', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks + $event = $hookmanager->resPrint; + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + $i++; } $db->free($resql); } else { dol_print_error($db); } +//var_dump($eventarray); + + +// BIRTHDATES CALENDAR +// Complete $eventarray with birthdates +if ($showbirthday) { + // Add events in array + $sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp'; + $sql .= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.((int) $user->id).'))'; + $sql .= " AND sp.entity IN (".getEntity('contact').")"; + if ($mode == 'show_day') { + $sql .= ' AND MONTH(birthday) = '.((int) $month); + $sql .= ' AND DAY(birthday) = '.((int) $day); + } else { + $sql .= ' AND MONTH(birthday) = '.((int) $month); + } + $sql .= ' ORDER BY birthday'; + + dol_syslog("comm/action/index.php", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $obj = $db->fetch_object($resql); + + $event = new ActionComm($db); + + $event->id = $obj->rowid; // We put contact id in action id for birthdays events + $event->ref = $event->id; + + $datebirth = dol_stringtotime($obj->birthday, 1); + //print 'ee'.$obj->birthday.'-'.$datebirth; + $datearray = dol_getdate($datebirth, true); + $event->datep = dol_mktime(0, 0, 0, $datearray['mon'], $datearray['mday'], $year, true); // For full day events, date are also GMT but they won't but converted during output + $event->datef = $event->datep; + + $event->type_code = 'BIRTHDAY'; + $event->type_label = ''; + $event->type_color = ''; + $event->type = 'birthdate'; + $event->type_picto = 'birthdate'; + + $event->label = $langs->trans("Birthday").' '.dolGetFirstLastname($obj->firstname, $obj->lastname); + $event->percentage = 100; + $event->fulldayevent = 1; + + $event->contact_id = $obj->rowid; + + $event->date_start_in_calendar = $db->jdate($event->datep); + $event->date_end_in_calendar = $db->jdate($event->datef); + + // Add an entry in eventarray for each day + $daycursor = $event->datep; + $annee = (int) dol_print_date($daycursor, '%Y', 'tzuserrel'); + $mois = (int) dol_print_date($daycursor, '%m', 'tzuserrel'); + $jour = (int) dol_print_date($daycursor, '%d', 'tzuserrel'); + + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); + + $eventarray[$daykey][] = $event; + + /*$loop = true; + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); + do { + $eventarray[$daykey][] = $event; + $daykey += 60 * 60 * 24; + if ($daykey > $event->date_end_in_calendar) $loop = false; + } while ($loop); + */ + $i++; + } + } else { + dol_print_error($db); + } +} + +if ($user->hasRight("holiday", "read")) { + // LEAVE-HOLIDAY CALENDAR + $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.statut, x.rowid, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.statut as status"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE u.rowid = x.fk_user"; + $sql .= " AND u.statut = '1'"; // Show only active users (0 = inactive user, 1 = active user) + $sql .= " AND (x.statut = '2' OR x.statut = '3')"; // Show only public leaves (2 = leave wait for approval, 3 = leave approved) + + if ($mode == 'show_day') { + // Request only leaves for the current selected day + $sql .= " AND '".$db->escape($year)."-".$db->escape($month)."-".$db->escape($day)."' BETWEEN x.date_debut AND x.date_fin"; // date_debut and date_fin are date without time + } elseif ($mode == 'show_week') { + // Restrict on current month (we get more, but we will filter later) + $sql .= " AND date_debut < '".$db->idate(dol_get_last_day($year, $month))."'"; + $sql .= " AND date_fin >= '".$db->idate(dol_get_first_day($year, $month))."'"; + } elseif ($mode == 'show_month') { + // Restrict on current month + $sql .= " AND date_debut <= '".$db->idate(dol_get_last_day($year, $month))."'"; + $sql .= " AND date_fin >= '".$db->idate(dol_get_first_day($year, $month))."'"; + } + + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + + while ($i < $num) { + $obj = $db->fetch_object($resql); + + $event = new ActionComm($db); + + // Need the id of the leave object for link to it + $event->id = $obj->rowid; + $event->ref = $event->id; + + $event->type_code = 'HOLIDAY'; + $event->type_label = ''; + $event->type_color = ''; + $event->type = 'holiday'; + $event->type_picto = 'holiday'; + + $event->datep = $db->jdate($obj->date_start) + (empty($obj->halfday) || $obj->halfday == 1 ? 0 : 12 * 60 * 60 - 1); + $event->datef = $db->jdate($obj->date_end) + (empty($obj->halfday) || $obj->halfday == -1 ? 24 : 12) * 60 * 60 - 1; + $event->date_start_in_calendar = $event->datep; + $event->date_end_in_calendar = $event->datef; + + if ($obj->status == 3) { + // Show no symbol for leave with state "leave approved" + $event->percentage = -1; + } elseif ($obj->status == 2) { + // Show TO-DO symbol for leave with state "leave wait for approval" + $event->percentage = 0; + } + + if ($obj->halfday == 1) { + $event->label = $obj->lastname.' ('.$langs->trans("Morning").')'; + } elseif ($obj->halfday == -1) { + $event->label = $obj->lastname.' ('.$langs->trans("Afternoon").')'; + } else { + $event->label = $obj->lastname; + } + + $daycursor = $event->date_start_in_calendar; + $annee = (int) dol_print_date($daycursor, '%Y', 'tzuserrel'); + $mois = (int) dol_print_date($daycursor, '%m', 'tzuserrel'); + $jour = (int) dol_print_date($daycursor, '%d', 'tzuserrel'); + + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); + do { + $eventarray[$daykey][] = $event; + + $daykey += 60 * 60 * 24; + } while ($daykey <= $event->date_end_in_calendar); + + $i++; + } + } +} + +// EXTERNAL CALENDAR +// Complete $eventarray with external import Ical +if (count($listofextcals)) { + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/ical.class.php'; + + foreach ($listofextcals as $key => $extcal) { + $url = $extcal['src']; // Example: https://www.google.com/calendar/ical/eldy10%40gmail.com/private-cde92aa7d7e0ef6110010a821a2aaeb/basic.ics + $namecal = $extcal['name']; + $offsettz = $extcal['offsettz']; + $colorcal = $extcal['color']; + $buggedfile = $extcal['buggedfile']; + + $pathforcachefile = dol_sanitizePathName($conf->user->dir_temp).'/'.dol_sanitizeFileName('extcal_'.$namecal.'_user'.$user->id).'.cache'; + //var_dump($pathforcachefile);exit; + + $ical = new ICal(); + $ical->parse($url, $pathforcachefile, $DELAYFORCACHE); + if ($ical->error) { + // Save error message for extcal + $listofextcals[$key]['error'] = $ical->error; + $s .= '
'.dol_escape_htmltag($listofextcals[$key]['name']).': '.$url.'
Error message: '.dol_escape_htmltag($ical->error).'
'; + } + + // After this $ical->cal['VEVENT'] contains array of events, $ical->cal['DAYLIGHT'] contains daylight info, $ical->cal['STANDARD'] contains non daylight info, ... + //var_dump($ical->cal); exit; + $icalevents = array(); + if (is_array($ical->get_event_list())) { + $icalevents = array_merge($icalevents, $ical->get_event_list()); // Add $ical->cal['VEVENT'] + } + if (is_array($ical->get_freebusy_list())) { + $icalevents = array_merge($icalevents, $ical->get_freebusy_list()); // Add $ical->cal['VFREEBUSY'] + } + + if (count($icalevents) > 0) { + // Duplicate all repeatable events into new entries + $moreicalevents = array(); + foreach ($icalevents as $icalevent) { + if (isset($icalevent['RRULE']) && is_array($icalevent['RRULE'])) { //repeatable event + //if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; + //if ($event->date_end_in_calendar > $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow-1); + if ($icalevent['DTSTART;VALUE=DATE']) { //fullday event + $datecurstart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); + $datecurend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day + } elseif (is_array($icalevent['DTSTART']) && !empty($icalevent['DTSTART']['unixtime'])) { + $datecurstart = $icalevent['DTSTART']['unixtime']; + $datecurend = $icalevent['DTEND']['unixtime']; + if (!empty($ical->cal['DAYLIGHT']['DTSTART']) && $datecurstart) { + //var_dump($ical->cal); + $tmpcurstart = $datecurstart; + $tmpcurend = $datecurend; + $tmpdaylightstart = dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['DAYLIGHT']['DTSTART']; + $tmpdaylightend = dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['STANDARD']['DTSTART']; + //var_dump($tmpcurstart);var_dump($tmpcurend); var_dump($ical->cal['DAYLIGHT']['DTSTART']);var_dump($ical->cal['STANDARD']['DTSTART']); + // Edit datecurstart and datecurend + if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) { + $datecurstart -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; + } else { + $datecurstart -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; + } + if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) { + $datecurend -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; + } else { + $datecurend -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; + } + } + // datecurstart and datecurend are now GMT date + //var_dump($datecurstart); var_dump($datecurend); exit; + } else { + // Not a recognized record + dol_syslog("Found a not recognized repeatable record with unknown date start", LOG_ERR); + continue; + } + //print 'xx'.$datecurstart;exit; + + $interval = (empty($icalevent['RRULE']['INTERVAL']) ? 1 : $icalevent['RRULE']['INTERVAL']); + $until = empty($icalevent['RRULE']['UNTIL']) ? 0 : dol_stringtotime($icalevent['RRULE']['UNTIL'], 1); + $maxrepeat = empty($icalevent['RRULE']['COUNT']) ? 0 : $icalevent['RRULE']['COUNT']; + if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) { + continue; // We discard repeatable event that end before start date to show + } + if ($datecurstart >= $lastdaytoshow) { + continue; // We discard repeatable event that start after end date to show + } + + $numofevent = 0; + while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) { + if ($datecurend >= $firstdaytoshow) { // We add event + $newevent = $icalevent; + unset($newevent['RRULE']); + if ($icalevent['DTSTART;VALUE=DATE']) { + $newevent['DTSTART;VALUE=DATE'] = dol_print_date($datecurstart, '%Y%m%d'); + $newevent['DTEND;VALUE=DATE'] = dol_print_date($datecurend + 1, '%Y%m%d'); + } else { + $newevent['DTSTART'] = $datecurstart; + $newevent['DTEND'] = $datecurend; + } + $moreicalevents[] = $newevent; + } + // Jump on next occurrence + $numofevent++; + $savdatecurstart = $datecurstart; + if ($icalevent['RRULE']['FREQ'] == 'DAILY') { + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'd'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'd'); + } + if ($icalevent['RRULE']['FREQ'] == 'WEEKLY') { + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'w'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'w'); + } elseif ($icalevent['RRULE']['FREQ'] == 'MONTHLY') { + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'm'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'm'); + } elseif ($icalevent['RRULE']['FREQ'] == 'YEARLY') { + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'y'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'y'); + } + // Test to avoid infinite loop ($datecurstart must increase) + if ($savdatecurstart >= $datecurstart) { + dol_syslog("Found a rule freq ".$icalevent['RRULE']['FREQ']." not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR); + $datecurstart += 3600 * 24 * 7; + $datecurend += 3600 * 24 * 7; + } + } + } + } + $icalevents = array_merge($icalevents, $moreicalevents); + + // Loop on each entry into cal file to know if entry is qualified and add an ActionComm into $eventarray + foreach ($icalevents as $icalevent) { + //var_dump($icalevent); + + //print $icalevent['SUMMARY'].'->'; + //var_dump($icalevent);exit; + if (!empty($icalevent['RRULE'])) { + continue; // We found a repeatable event. It was already split into unitary events, so we discard general rule. + } + + // Create a new object action + $event = new ActionComm($db); + $addevent = false; + if (isset($icalevent['DTSTART;VALUE=DATE'])) { // fullday event + // For full day events, date are also GMT but they won't but converted using tz during output + $datestart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); + if (empty($icalevent['DTEND;VALUE=DATE'])) { + $dateend = $datestart + 86400 - 1; + } else { + $dateend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day + } + //print 'x'.$datestart.'-'.$dateend;exit; + //print dol_print_date($dateend,'dayhour','gmt'); + $event->fulldayevent = 1; + $addevent = true; + } elseif (!is_array($icalevent['DTSTART'])) { // not fullday event (DTSTART is not array. It is a value like '19700101T000000Z' for 00:00 in greenwitch) + $datestart = $icalevent['DTSTART']; + $dateend = empty($icalevent['DTEND']) ? $datestart : $icalevent['DTEND']; + + $datestart += +($offsettz * 3600); + $dateend += +($offsettz * 3600); + + $addevent = true; + //var_dump($offsettz); + //var_dump(dol_print_date($datestart, 'dayhour', 'gmt')); + } elseif (isset($icalevent['DTSTART']['unixtime'])) { // File contains a local timezone + a TZ (for example when using bluemind) + $datestart = $icalevent['DTSTART']['unixtime']; + $dateend = $icalevent['DTEND']['unixtime']; + + $datestart += +($offsettz * 3600); + $dateend += +($offsettz * 3600); + + // $buggedfile is set to uselocalandtznodaylight if conf->global->AGENDA_EXT_BUGGEDFILEx = 'uselocalandtznodaylight' + if ($buggedfile === 'uselocalandtznodaylight') { // unixtime is a local date that does not take daylight into account, TZID is +1 for example for 'Europe/Paris' in summer instead of 2 + // TODO + } + // $buggedfile is set to uselocalandtzdaylight if conf->global->AGENDA_EXT_BUGGEDFILEx = 'uselocalandtzdaylight' (for example with bluemind) + if ($buggedfile === 'uselocalandtzdaylight') { // unixtime is a local date that does take daylight into account, TZID is +2 for example for 'Europe/Paris' in summer + $localtzs = new DateTimeZone(preg_replace('/"/', '', $icalevent['DTSTART']['TZID'])); + $localtze = new DateTimeZone(preg_replace('/"/', '', $icalevent['DTEND']['TZID'])); + $localdts = new DateTime(dol_print_date($datestart, 'dayrfc', 'gmt'), $localtzs); + $localdte = new DateTime(dol_print_date($dateend, 'dayrfc', 'gmt'), $localtze); + $tmps = -1 * $localtzs->getOffset($localdts); + $tmpe = -1 * $localtze->getOffset($localdte); + $datestart += $tmps; + $dateend += $tmpe; + //var_dump($datestart); + } + $addevent = true; + } + + if ($addevent) { + $event->id = $icalevent['UID']; + $event->ref = $event->id; + $userId = $userstatic->findUserIdByEmail($namecal); + if (!empty($userId) && $userId > 0) { + $event->userassigned[$userId] = $userId; + $event->percentage = -1; + } + + $event->type_code = "ICALEVENT"; + $event->type_label = $namecal; + $event->type_color = $colorcal; + $event->type = 'icalevent'; + $event->type_picto = 'rss'; + + $event->icalname = $namecal; + $event->icalcolor = $colorcal; + $usertime = 0; // We don't modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output. + $event->datep = $datestart + $usertime; + $event->datef = $dateend + $usertime; + + if (isset($icalevent['SUMMARY']) && $icalevent['SUMMARY']) { + $event->label = dol_string_nohtmltag($icalevent['SUMMARY']); + } elseif (isset($icalevent['DESCRIPTION']) && $icalevent['DESCRIPTION']) { + $event->label = dol_nl2br(dol_string_nohtmltag($icalevent['DESCRIPTION']), 1); + } else { + $event->label = $langs->trans("ExtSiteNoLabel"); + } + + // Priority (see https://www.kanzaki.com/docs/ical/priority.html) + // LOW = 0 to 4 + // MEDIUM = 5 + // HIGH = 6 to 9 + if (!empty($icalevent['PRIORITY'])) { + $event->priority = $icalevent['PRIORITY']; + } + + // Transparency (see https://www.kanzaki.com/docs/ical/transp.html) + if (!empty($icalevent['TRANSP'])) { + if ($icalevent['TRANSP'] == "TRANSPARENT") { + $event->transparency = 0; // 0 = available / free + } + if ($icalevent['TRANSP'] == "OPAQUE") { + $event->transparency = 1; // 1 = busy + } + + // TODO: MS outlook states + // X-MICROSOFT-CDO-BUSYSTATUS:FREE + TRANSP:TRANSPARENT => Available / Free + // X-MICROSOFT-CDO-BUSYSTATUS:FREE + TRANSP:OPAQUE => Work another place + // X-MICROSOFT-CDO-BUSYSTATUS:TENTATIVE + TRANSP:OPAQUE => With reservations + // X-MICROSOFT-CDO-BUSYSTATUS:BUSY + TRANSP:OPAQUE => Busy + // X-MICROSOFT-CDO-BUSYSTATUS:OOF + TRANSP:OPAQUE => Away from the office / off-site + } + + if (!empty($icalevent['LOCATION'])) { + $event->location = $icalevent['LOCATION']; + } + + $event->date_start_in_calendar = $event->datep; + + if ($event->datef != '' && $event->datef >= $event->datep) { + $event->date_end_in_calendar = $event->datef; + } else { + $event->date_end_in_calendar = $event->datep; + } + + // Add event into $eventarray if date range are ok. + if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) { + //print 'x'.$datestart.'-'.$dateend;exit; + //print 'x'.$datestart.'-'.$dateend;exit; + //print 'x'.$datestart.'-'.$dateend;exit; + // This record is out of visible range + } else { + if ($event->date_start_in_calendar < $firstdaytoshow) { + $event->date_start_in_calendar = $firstdaytoshow; + } + if ($event->date_end_in_calendar >= $lastdaytoshow) { + $event->date_end_in_calendar = ($lastdaytoshow - 1); + } + + // Add an entry in actionarray for each day + $daycursor = $event->date_start_in_calendar; + $annee = (int) dol_print_date($daycursor, '%Y', 'tzuserrel'); + $mois = (int) dol_print_date($daycursor, '%m', 'tzuserrel'); + $jour = (int) dol_print_date($daycursor, '%d', 'tzuserrel'); + + // Loop on each day covered by action to prepare an index to show on calendar + $loop = true; + $j = 0; + // daykey must be date that represent day box in calendar so must be a user time + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); + $daykeygmt = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); + do { + //if ($event->fulldayevent) print dol_print_date($daykeygmt,'dayhour','gmt').'-'.dol_print_date($daykey,'dayhour','gmt').'-'.dol_print_date($event->date_end_in_calendar,'dayhour','gmt').' '; + $eventarray[$daykey][] = $event; + $daykey += 60 * 60 * 24; + $daykeygmt += 60 * 60 * 24; // Add one day + if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) { + $loop = false; + } + } while ($loop); + } + } + } + } + } +} + +// Complete $eventarray with events coming from external module +$parameters = array(); +$object = null; +$reshook = $hookmanager->executeHooks('getCalendarEvents', $parameters, $object, $action); +if (!empty($hookmanager->resArray['eventarray'])) { + foreach ($hookmanager->resArray['eventarray'] as $keyDate => $events) { + if (!isset($eventarray[$keyDate])) { + $eventarray[$keyDate] = array(); + } + $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events); + } +} + +// Sort events +foreach ($eventarray as $keyDate => &$dateeventarray) { + usort($dateeventarray, 'sort_events_by_date'); +} + $maxnbofchar = 18; $cachethirdparties = array(); @@ -812,9 +1460,24 @@ if (is_readable($color_file)) { include $color_file; } if (!is_array($theme_datacolor)) { - $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); + $theme_datacolor = array(array(137, 86, 161), array(60, 147, 183), array(250, 190, 80), array(80, 166, 90), array(190, 190, 100), array(91, 115, 247), array(140, 140, 220), array(190, 120, 120), array(115, 125, 150), array(100, 170, 20), array(150, 135, 125), array(85, 135, 150), array(150, 135, 80), array(150, 80, 150)); } +$massactionbutton = ''; + +$num = 0; + +print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.''.$newcardbutton, '', $limit, 1, 0, 1, $viewmode); + +$link = ''; + +// Show div with list of calendars +print $s; + +print '
'; +print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, '', (string) $filtert, '', $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid, $search_categ_cus); +print '
'; + $newparam = $param; // newparam is for birthday links $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done @@ -1091,6 +1754,7 @@ if (getDolGlobalString('AGENDA_USE_EVENT_TYPE') && getDolGlobalString('AGENDA_US } print "\n".''; + print "\n"; // Add js code to manage click on a box @@ -1187,13 +1851,13 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & // We are in a particular day for $username, now we scan all events foreach ($eventarray as $daykey => $notused) { - $annee = dol_print_date($daykey, '%Y', 'tzuserrel'); - $mois = dol_print_date($daykey, '%m', 'tzuserrel'); - $jour = dol_print_date($daykey, '%d', 'tzuserrel'); + $annee = (int) dol_print_date($daykey, '%Y', 'tzuserrel'); + $mois = (int) dol_print_date($daykey, '%m', 'tzuserrel'); + $jour = (int) dol_print_date($daykey, '%d', 'tzuserrel'); //var_dump("daykey=$daykey day=$day jour=$jour, month=$month mois=$mois, year=$year annee=$annee"); - if ($day == $jour && (int) $month == (int) $mois && $year == $annee) { // Is it the day we are looking for when calling function ? + if ($day == $jour && (int) $month == $mois && $year == $annee) { // Is it the day we are looking for when calling function ? //var_dump("day=$day jour=$jour month=$month mois=$mois year=$year annee=$annee"); // Scan all event for this date diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index a3db32f86cb..606ca72fecf 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -924,16 +924,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
'; print ''; $daterange = ''; - if ($event->type_code == 'BIRTHDAY') { - // It's birthday calendar - $picb = ''; - //$pice = ''; - //$typea = ($objp->typea == 'birth') ? $picb : $pice; - //var_dump($event); - print $picb.' '.$langs->trans("Birthday").'
'; - //print img_picto($langs->trans("Birthday"), 'birthday-cake').' '; - - $tmpid = $event->id; - - if (empty($cachecontacts[$tmpid])) { - $newcontact = new Contact($db); - $newcontact->fetch($tmpid); - $cachecontacts[$tmpid] = $newcontact; - } - print $cachecontacts[$tmpid]->getNomUrl(1, '', 0, '', -1, 0, 'valignmiddle inline-block'); - - //$event->picto = 'birthday-cake'; - //print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'birthday', 'contact'); - /*$listofcontacttoshow = ''; - $listofcontacttoshow .= '
'.$cacheusers[$tmpid]->getNomUrl(-1, '', 0, 0, 0, 0, '', 'paddingright valignmiddle'); - print $listofcontacttoshow; - */ - } elseif ($event->type_code == 'HOLIDAY') { - // It's holiday calendar - $tmpholiday->fetch($event->id); - - print $tmpholiday->getNomUrl(1, -1, 0, 'valignmiddle inline-block'); - - $tmpid = $tmpholiday->fk_user; - if (empty($cacheusers[$tmpid])) { - $newuser = new User($db); - $newuser->fetch($tmpid); - $cacheusers[$tmpid] = $newuser; - } - - $listofusertoshow = ''; - $listofusertoshow .= '
'.$cacheusers[$tmpid]->getNomUrl(-1, '', 0, 0, 0, 0, '', 'paddingright valignmiddle inline-block'); - print $listofusertoshow; - } - $parameters = array(); $reshook = $hookmanager->executeHooks('eventOptions', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -2174,41 +2160,49 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa } */ - // Date - if (empty($event->fulldayevent)) { - // Show hours (start ... end) - $tmpyearstart = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel'); - $tmpmonthstart = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel'); - $tmpdaystart = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel'); - $tmpyearend = dol_print_date($event->date_end_in_calendar, '%Y', 'tzuserrel'); - $tmpmonthend = dol_print_date($event->date_end_in_calendar, '%m', 'tzuserrel'); - $tmpdayend = dol_print_date($event->date_end_in_calendar, '%d', 'tzuserrel'); + if ($event->type_code == 'BIRTHDAY') { + // It's birthday calendar + $picb = img_picto('', 'birthday-cake', 'class="pictofixedwidth"'); + print $picb.$langs->trans("Birthday").'
'; + } - // Hour start - if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) { - $daterange .= dol_print_date($event->date_start_in_calendar, 'hour', 'tzuserrel'); - if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { - if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) { - $daterange .= '-'; + // Date + if ($event->type_code != 'HOLIDAY' && $event->type_code != 'BIRTHDAY') { + if (empty($event->fulldayevent)) { + // Show hours (start ... end) + $tmpyearstart = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel'); + $tmpmonthstart = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel'); + $tmpdaystart = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel'); + $tmpyearend = dol_print_date($event->date_end_in_calendar, '%Y', 'tzuserrel'); + $tmpmonthend = dol_print_date($event->date_end_in_calendar, '%m', 'tzuserrel'); + $tmpdayend = dol_print_date($event->date_end_in_calendar, '%d', 'tzuserrel'); + + // Hour start + if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) { + $daterange .= dol_print_date($event->date_start_in_calendar, 'hour', 'tzuserrel'); + if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { + if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) { + $daterange .= '-'; + } + //else + //print '...'; } - //else - //print '...'; } - } - if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { - if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) { - $daterange .= '...'; + if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { + if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) { + $daterange .= '...'; + } } - } - // Hour end - if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { - if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) { - $daterange .= dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel'); + // Hour end + if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { + if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) { + $daterange .= dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel'); + } + } + } else { + if ($showinfo) { + print $langs->trans("EventOnFullDay")."
\n"; } - } - } else { - if ($showinfo) { - print $langs->trans("EventOnFullDay")."
\n"; } } @@ -2216,7 +2210,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $titletoshow = $daterange; $titletoshow .= ($titletoshow ? ' ' : '').dol_escape_htmltag($event->label); - if ($event->type_code != 'ICALEVENT') { + if ($event->type_code != 'ICALEVENT' && $event->type_code != 'BIRTHDAY') { $savlabel = $event->label; $event->label = $titletoshow; // Note: List of users are inside $event->userassigned. Link may be clickable depending on permissions of user. @@ -2242,8 +2236,10 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $listofusertoshow .= $cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'valignmiddle inline-block'); } - print $titletoshow; - print $listofusertoshow.'  '; + if ($event->type_code != 'BIRTHDAY') { + print $titletoshow; + print $listofusertoshow.'  '; + } if ($event->type_code == 'ICALEVENT') { print '
('.dol_trunc($event->icalname, $maxnbofchar).')'; @@ -2263,7 +2259,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $thirdparty = $cachethirdparties[$thirdparty_id]; } if (!empty($thirdparty->id)) { - $linerelatedto .= $thirdparty->getNomUrl(1, '', 0, 0, -1, 0, '', 'valignmiddle inline-block'); + $linerelatedto .= $thirdparty->getNomUrl(1, '', 0, 0, -1, 0, '', 'valignmiddle inline'); // using inline-block make the content completely replace with ... when too large } } if (!empty($contact_id) && $contact_id > 0) { @@ -2278,7 +2274,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $linerelatedto .= ' '; } if (!empty($contact->id)) { - $linerelatedto .= $contact->getNomUrl(1, '', 0, '', -1, 0, 'valignmiddle inline-block'); + $linerelatedto .= $contact->getNomUrl(1, '', 0, '', -1, 0, 'valignmiddle inline'); // using inline-block make the content completely replace with ... when too large } } if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && getDolGlobalString('AGENDA_SHOW_LINKED_OBJECT')) { @@ -2296,6 +2292,24 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa } } + if ($event->type_code == 'HOLIDAY') { + // It's holiday calendar + $tmpholiday->fetch($event->id); + + //print $tmpholiday->getNomUrl(1, -1, 0, 'valignmiddle inline-block'); + + $tmpid = $tmpholiday->fk_user; + if (empty($cacheusers[$tmpid])) { + $newuser = new User($db); + $newuser->fetch($tmpid); + $cacheusers[$tmpid] = $newuser; + } + + $listofusertoshow = ''; + $listofusertoshow .= "\n".'
'.$cacheusers[$tmpid]->getNomUrl(-1, '', 0, 0, 0, 0, '', 'paddingright valignmiddle inline-block')."\n"; + print $listofusertoshow; + } + // Show location if ($showinfo) { if ($event->location) { @@ -2305,9 +2319,10 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa } print '
'; // Date To Birth - print ''; - print '
'; + print '
'; $form = new Form($db); if ($object->birthday) { print $form->selectDate($object->birthday, 'birthday', 0, 0, 0, "perso", 1, 0); } else { print $form->selectDate('', 'birthday', 0, 0, 1, "perso", 1, 0); } - print ': '; + print '   '; if (!empty($object->birthday_alert)) { print ''; } else { diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index cfe0f519db9..de0d14ebd49 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -246,7 +246,7 @@ $holidaystatic = new Holiday($db); // Update sold $result = $object->updateBalance(); -$title = $langs->trans('CPTitreMenu'); +$title = $langs->trans('Holidays'); $help_url = 'EN:Module_Holiday'; llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist mod-holiday page-list'); @@ -542,9 +542,6 @@ if ($id > 0) { // For user tab print ''; } else { - $title = $langs->trans("ListeCP"); - - $newcardbutton = ''; $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); diff --git a/htdocs/langs/fr_FR/holiday.lang b/htdocs/langs/fr_FR/holiday.lang index 859f6d0d00a..7c9c40ea112 100644 --- a/htdocs/langs/fr_FR/holiday.lang +++ b/htdocs/langs/fr_FR/holiday.lang @@ -1,7 +1,7 @@ # Dolibarr language file - Source file is en_US - holiday HRM=GRH Holidays=Congés -Holiday=Demande de congés +Holiday=Congés CPTitreMenu=Demande de congés MenuReportMonth=État mensuel MenuAddCP=Créer demande de congés From e9e7b854104880c84207d13ca370a1d560a8d72d Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Fri, 24 Jan 2025 20:22:23 +0100 Subject: [PATCH 39/69] Debug v21 - pb holiday view into agenda --- htdocs/comm/action/index.php | 23 +-- htdocs/comm/action/pertype.php | 2 - htdocs/comm/action/peruser.php | 326 ++++++++++++++++++------------- htdocs/theme/eldy/global.inc.php | 7 +- htdocs/theme/md/style.css.php | 8 + htdocs/user/perms.php | 3 +- 6 files changed, 219 insertions(+), 150 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 02737de7db2..e13c531d640 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -620,8 +620,8 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on $s .= '