Skip to content
Merged

1.0 #47

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# CHANGELOG MODULE TIMESHEETWEEK FOR [DOLIBARR ERP CRM](https://www.dolibarr.org)

## 1.0.4
- Assure le chargement de la librairie admin Dolibarr avant l'appel à `dolibarr_set_const` dans le compteur FH. / Ensures the Dolibarr admin library loads before calling `dolibarr_set_const` in the FH counter.

## 1.0.3
- Corrige l'initialisation du compteur FH en chargeant les librairies Dolibarr adéquates. / Fixes FH counter initialisation by loading the appropriate Dolibarr libraries.
- Sécurise les droits hiérarchiques pour lire, créer, modifier, supprimer et valider les feuilles des seuls collaborateurs gérés. / Secures hierarchy rights to read, create, update, delete and validate only managed employees' timesheets.
- Restreint la liste hebdomadaire aux salariés autorisés et ajoute des filtres compatibles Multicompany. / Restricts the weekly list to authorised employees and adds Multicompany-compatible filters.
- Limite le filtre salarié aux collaborateurs visibles par l'utilisateur et respecte le périmètre Multicompany. / Limits the employee filter to collaborators visible to the user and honours the Multicompany scope.
Expand Down
4 changes: 2 additions & 2 deletions core/modules/modTimesheetWeek.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public function __construct($db)
$this->editor_squarred_logo = ''; // Must be image filename into the module/img directory followed with @modulename. Example: 'myimage.png@timesheetweek'

// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated', 'experimental_deprecated' or a version string like 'x.y.z'
$this->version = '1.0.3'; // EN: Bump module version to ship hierarchy permission fixes.
// FR: Incrémente la version du module pour livrer les correctifs de permissions hiérarchiques.
$this->version = '1.0.4'; // EN: Release FH counter fix ensuring Dolibarr admin library loads.
// FR: Publie la correction du compteur FH en garantissant le chargement de la librairie admin Dolibarr.
// Url to the file with your last numberversion of this module
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';

Expand Down
15 changes: 10 additions & 5 deletions core/modules/timesheetweek/mod_timesheetweek_fhweekly.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?php
/* Copyright (C) 2025
/*
* Copyright (C) 2025
* Pierre Ardoin <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU GPL v3 or later.
*/

require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';

/**
* Numbering module for TimesheetWeek
Expand Down Expand Up @@ -57,11 +61,11 @@ public function getNextValue($object)
$year = (int) $object->year;
$week = (int) $object->week;

// fallback si non renseigné
// EN: Fallback to current year and week when missing. FR: Repli sur l'année et la semaine courantes si absentes.
if (empty($year) || empty($week)) {
$ts = dol_now();
$year = (int) dol_print_date($ts, '%Y');
$week = (int) dol_print_date($ts, '%W'); // ISO week number
$ts = dol_now();
$year = (int) dol_print_date($ts, '%Y');
$week = (int) dol_print_date($ts, '%W'); // ISO week number
}

$key = 'TIMESHEETWEEK_FHWEEKLY_COUNTER_'.$entity.'_'.$year;
Expand All @@ -71,6 +75,7 @@ public function getNextValue($object)
$current = (int) getDolGlobalInt($key, 0);
$next = $current + 1;

// EN: Persist the counter in Dolibarr constants per entity. FR: Persiste le compteur dans les constantes Dolibarr par entité.
$res = dolibarr_set_const($db, $key, $next, 'integer', 0, '', $entity);
if ($res <= 0) {
$db->rollback();
Expand Down