Skip to content

Commit

Permalink
Evarisk#507 [Timespent] add: checkbox for show closed projects
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Sep 4, 2023
1 parent d0f47da commit 61f6bd8
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
2 changes: 1 addition & 1 deletion js/dolisirh.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions js/modules/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ window.dolisirh.task.event = function() {
$(document).on('click', '.show-only-favorite-tasks', window.dolisirh.task.showOnlyFavoriteTasks);
$(document).on('click', '.show-only-tasks-with-timespent', window.dolisirh.task.showOnlyTasksWithTimeSpent);
$(document).on('click', '.select-logic-operators-mode', window.dolisirh.task.selectLogicOperatorsMode);
$(document).on('click', '.show-closed-projects', window.dolisirh.task.showClosedProjects);
$(document).on('click', '.timespent-create', window.dolisirh.task.createTimeSpent);
$(document).on('click', '.toggleTaskFavorite', window.dolisirh.task.toggleTaskFavorite);
$(document).on('submit', '#addtimeform', window.dolisirh.task.searchForm );
Expand Down Expand Up @@ -235,6 +236,41 @@ window.dolisirh.task.selectLogicOperatorsMode = function() {
});
};

/**
* Enables/disables the configuration to display closed projects
*
* @memberof DoliSIRH_Task
*
* @since 1.4.0
* @version 1.4.0
*
* @return {void}
*/
window.dolisirh.task.showClosedProjects = function() {
let token = window.saturne.toolbox.getToken();
let querySeparator = window.saturne.toolbox.getQuerySeparator(document.URL);

let showClosedProjects;
if ($(this).is(':checked')) {
showClosedProjects = 1;
} else {
showClosedProjects = 0;
}

$.ajax({
url: document.URL + querySeparator + "action=show_closed_projects&token=" + token,
type: "POST",
processData: false,
data: JSON.stringify({
showClosedProjects: showClosedProjects
}),
contentType: false,
success: function() {
window.location.reload();
},
error: function() {}
});
};

/**
* Action create timespent.
Expand Down
1 change: 1 addition & 0 deletions langs/fr_FR/dolisirh.lang
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ ExpectedWorkingHoursWeek = Heures de travail prévues (%s - %s)
TimeSpentList = Liste des temps consommés
ShowOnlyTasksWithTimeSpent = Afficher uniquement les tâches avec du temps consommé sur cette période
SelectLogicOperatorsMode = Sélection de l'opérateur logique 'ET/OU' par défaut : ET
ShowClosedProjects = Afficher les projets clôturés
ExpectedWorkingHours = Heures de travail prévues
ConsumedWorkingHours = Heures de travail consommées
TimeSpentReportByFiscalYear = Rapport du temps consommé sur l'exercice fiscal
Expand Down
15 changes: 14 additions & 1 deletion view/timespent_range.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,16 @@
dol_set_user_param($db, $conf, $user, $tabParam);
}

if ($action == 'show_closed_projects') {
$data = json_decode(file_get_contents('php://input'), true);

$showClosedProjects = $data['showClosedProjects'];

$tabParam['DOLISIRH_SHOW_CLOSED_PROJECTS'] = $showClosedProjects;

dol_set_user_param($db, $conf, $user, $tabParam);
}

if ($action == 'add_timespent' && $permissiontoAdd) {
$data = json_decode(file_get_contents('php://input'), true);

Expand Down Expand Up @@ -365,7 +375,7 @@
$project->fetch_thirdparty();
}

$onlyOpenedProject = -1; // or -1.
$onlyOpenedProject = $user->conf->DOLISIRH_SHOW_CLOSED_PROJECTS ? '-1' : '1';
$moreWhereFilter = '';

if ($searchProjectRef) {
Expand Down Expand Up @@ -562,6 +572,9 @@
print ' <i class="fas fa-cogs"></i>';
print '<input type="checkbox" class="select-logic-operators-mode"'. ($user->conf->DOLISIRH_SELECT_LOGIC_OPERATORS_MODE ? ' checked' : '') . '>';
print $form->textwithpicto('', $langs->trans('SelectLogicOperatorsMode'));
print ' <i class="fas fa-project-diagram"></i>';
print '<input type="checkbox" class="show-closed-projects"'. ($user->conf->DOLISIRH_SHOW_CLOSED_PROJECTS ? ' checked' : '') . '>';
print $form->textwithpicto('', $langs->trans('ShowClosedProjects'));
print '</th>';
// TASK fields.
if (!empty($arrayFields['timeconsumed']['checked'])) {
Expand Down

0 comments on commit 61f6bd8

Please sign in to comment.