diff --git a/js/dolisirh.js.php b/js/dolisirh.js.php
index 8f9735f..84828e1 100644
--- a/js/dolisirh.js.php
+++ b/js/dolisirh.js.php
@@ -570,6 +570,7 @@
$( document ).on( 'click', '.auto-fill-timespent', window.eoxiaJS.task.addTimeSpent );
$( document ).on( 'click', '.auto-fill-timespent-project', window.eoxiaJS.task.divideTimeSpent );
$( document ).on( 'click', '.show-only-favorite-tasks', window.eoxiaJS.task.showOnlyFavoriteTasks );
+ $( document ).on( 'click', '.show-only-tasks-with-timespent', window.eoxiaJS.task.showOnlyTasksWithTimeSpent );
};
/**
@@ -652,6 +653,34 @@
});
};
+/**
+ * Active/désactive la configuration pour n'afficher que les tâches avec du temps pointé
+ *
+ * @since 1.1.0
+ * @version 1.1.0
+ *
+ * @param {MouseEvent} event [description]
+ * @return {void}
+ */
+window.eoxiaJS.task.showOnlyTasksWithTimeSpent = function( event ) {
+ let token = $('.id-container').find('input[name="token"]').val();
+ let querySeparator = '?';
+
+ document.URL.match(/\?/) ? querySeparator = '&' : 1
+
+ $.ajax({
+ url: document.URL + querySeparator + "action=showOnlyTasksWithTimeSpent&token=" + token,
+ type: "POST",
+ processData: false,
+ contentType: false,
+ success: function ( resp ) {
+ window.location.reload()
+ },
+ error: function ( ) {
+ }
+ });
+};
+
/**
* Initialise l'objet "menu" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
*
diff --git a/langs/fr_FR/dolisirh.lang b/langs/fr_FR/dolisirh.lang
index 360149d..275e993 100644
--- a/langs/fr_FR/dolisirh.lang
+++ b/langs/fr_FR/dolisirh.lang
@@ -121,7 +121,7 @@ WarningShowOnlyFavoriteTasks = Attention quand l'option 'Afficher uniquement les
ExpectedWorkedHoursWeek = Heures de travail prévues du %s au %s
ThemeDashboardTimeSpent = Thème du Rapport de pointage de temps
TimeSpentList = Liste des temps consommés
-
+ShowOnlyTasksWithTimeSpent = Afficher uniquement les tâches avec du temps consommé
#
diff --git a/lib/dolisirh_function.lib.php b/lib/dolisirh_function.lib.php
index 3209c7c..b514a2f 100644
--- a/lib/dolisirh_function.lib.php
+++ b/lib/dolisirh_function.lib.php
@@ -157,6 +157,9 @@ function getFavoriteTasksArray($task_id = 0, $usert = null, $userp = null, $proj
if ($conf->global->DOLISIRH_SHOW_ONLY_FAVORITE_TASKS) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as elel ON (t.rowid = elel.fk_target AND elel.targettype='project_task')";
}
+ if ($conf->global->DOLISIRH_SHOW_ONLY_TASKS_WITH_TIMESPENT) {
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as ptt ON (t.rowid = ptt.fk_task)";
+ }
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_extrafields as efpt ON (t.rowid = efpt.fk_object)";
$sql .= " WHERE p.entity IN (".getEntity('project').")";
$sql .= " AND t.fk_projet = p.rowid";
@@ -164,6 +167,10 @@ function getFavoriteTasksArray($task_id = 0, $usert = null, $userp = null, $proj
$sql .= " AND elel.fk_target = t.rowid";
$sql .= " AND elel.fk_source = " . $user->id;
}
+ if ($conf->global->DOLISIRH_SHOW_ONLY_TASKS_WITH_TIMESPENT) {
+ $sql .= " AND ptt.fk_task = t.rowid";
+ }
+
} elseif ($mode == 1) {
if ($filteronprojuser > 0) {
$sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
@@ -879,7 +886,6 @@ function projectLinesPerDayOnMonth(&$inc, $firstdaytoshow, $lastdaytoshow, $fuse
if ($lines[$i]->fk_task_parent == $parent) {
$obj = &$lines[$i]; // To display extrafields
-
// If we want all or we have a role on task, we show it
if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
//dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
@@ -938,13 +944,23 @@ function projectLinesPerDayOnMonth(&$inc, $firstdaytoshow, $lastdaytoshow, $fuse
}
if ($conf->global->DOLISIRH_SHOW_ONLY_FAVORITE_TASKS) {
- $taskfavorite = isTaskFavorite($lines[$i]->id, $fuser->id);
+ $taskFavorite = isTaskFavorite($lines[$i]->id, $fuser->id);
} else {
- $taskfavorite = 1;
+ $taskFavorite = 1;
}
+ if ($conf->global->DOLISIRH_SHOW_ONLY_TASKS_WITH_TIMESPENT) {
+ $filter = ' AND ptt.fk_task = ' . $lines[$i]->id;
+ $timeSpentArray = $lines[$i]->fetchAllTimeSpent($fuser, $filter);
+ $taskHasTimeSpent = (is_array($timeSpentArray) && !empty($timeSpentArray));
+ } else {
+ $taskHasTimeSpent = 1;
+ }
+
+ $displayTask = $taskFavorite && $taskHasTimeSpent;
+
if (!$noprint) {
- print '
' . "\n";
+ print ' ' . "\n";
print '';
print $projectstatic->getNomUrl(1, '', 0, '' . $langs->transnoentitiesnoconv("YourRole") . ': ' . $projectsrole[$lines[$i]->fk_project]);
if ($thirdpartystatic->id > 0) {
@@ -956,65 +972,6 @@ function projectLinesPerDayOnMonth(&$inc, $firstdaytoshow, $lastdaytoshow, $fuse
}
}
- /*$colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2);
- print '';
-
- print '';
-
- // PROJECT fields
- if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center ');
- if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right ');
- if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER["PHP_SELF"], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right ');
- if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right ');
- if (! empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right ');
-
- $extrafieldsobjectkey='projet';
- $extrafieldsobjectprefix='efp.';
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
-
- print ' ';
- print '';
-
- // PROJECT fields
- if (! empty($arrayfields['p.fk_opp_status']['checked']))
- {
- print '';
- $code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code');
- if ($code) print $langs->trans("OppStatus".$code);
- print " \n";
- }
- if (! empty($arrayfields['p.opp_amount']['checked']))
- {
- print '';
- print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
- print " \n";
- }
- if (! empty($arrayfields['p.opp_percent']['checked']))
- {
- print '';
- print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %';
- print " \n";
- }
- if (! empty($arrayfields['p.budget_amount']['checked']))
- {
- print '';
- print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
- print " \n";
- }
- if (! empty($arrayfields['p.usage_bill_time']['checked']))
- {
- print '';
- print yn($lines[$i]->usage_bill_time);
- print " \n";
- }
-
- $extrafieldsobjectkey='projet';
- $extrafieldsobjectprefix='efp.';
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
-
- print ' ';
- print '
';
- */
if (!$noprint) {
print ' ';
print ' ';
@@ -1026,23 +983,26 @@ function projectLinesPerDayOnMonth(&$inc, $firstdaytoshow, $lastdaytoshow, $fuse
}
if ($conf->global->DOLISIRH_SHOW_ONLY_FAVORITE_TASKS) {
- $taskfavorite = isTaskFavorite($lines[$i]->id, $fuser->id);
+ $taskFavorite = isTaskFavorite($lines[$i]->id, $fuser->id);
} else {
- $taskfavorite = 1;
+ $taskFavorite = 1;
}
- if (!$noprint) {
- print 'id . '" >' . "\n";
+ if ($conf->global->DOLISIRH_SHOW_ONLY_TASKS_WITH_TIMESPENT) {
+ $filter = ' AND ptt.fk_task = ' . $lines[$i]->id;
+ $timeSpentArray = $lines[$i]->fetchAllTimeSpent($fuser, $filter);
+ $taskHasTimeSpent = (is_array($timeSpentArray) && !empty($timeSpentArray));
+ } else {
+ $taskHasTimeSpent = 1;
}
+ $displayTask = $taskFavorite && $taskHasTimeSpent;
+
if (!$noprint) {
- // User
- /*
- print '';
- print $fuser->getNomUrl(1, 'withproject', 'time');
- print ' ';
- */
+ print ' id . '" >' . "\n";
+ }
+ if (!$noprint) {
// Project
if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
print '';
@@ -1421,12 +1381,12 @@ function projectLinesPerWeekDoliSIRH(&$inc, $firstdaytoshow, $fuser, $parent, $l
}
if ($conf->global->DOLISIRH_SHOW_ONLY_FAVORITE_TASKS) {
- $taskfavorite = isTaskFavorite($lines[$i]->id, $fuser->id);
+ $displayTask = isTaskFavorite($lines[$i]->id, $fuser->id);
} else {
- $taskfavorite = 1;
+ $displayTask = 1;
}
- print ' '."\n";
+ print ' '."\n";
print '';
print $projectstatic->getNomUrl(1, '', 0, ''.$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
if ($thirdpartystatic->id > 0) {
@@ -1437,66 +1397,6 @@ function projectLinesPerWeekDoliSIRH(&$inc, $firstdaytoshow, $fuser, $parent, $l
print ''.dol_trunc($projectstatic->title, '64').' ';
}
- /*$colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2);
- print '';
-
- print '';
-
- // PROJECT fields
- if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center ');
- if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right ');
- if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER["PHP_SELF"], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right ');
- if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right ');
- if (! empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right ');
-
- $extrafieldsobjectkey='projet';
- $extrafieldsobjectprefix='efp.';
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
-
- print ' ';
- print '';
-
- // PROJECT fields
- if (! empty($arrayfields['p.fk_opp_status']['checked']))
- {
- print '';
- $code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code');
- if ($code) print $langs->trans("OppStatus".$code);
- print " \n";
- }
- if (! empty($arrayfields['p.opp_amount']['checked']))
- {
- print '';
- print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
- print " \n";
- }
- if (! empty($arrayfields['p.opp_percent']['checked']))
- {
- print '';
- print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %';
- print " \n";
- }
- if (! empty($arrayfields['p.budget_amount']['checked']))
- {
- print '';
- print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
- print " \n";
- }
- if (! empty($arrayfields['p.usage_bill_time']['checked']))
- {
- print '';
- print yn($lines[$i]->usage_bill_time);
- print " \n";
- }
-
- $extrafieldsobjectkey='projet';
- $extrafieldsobjectprefix='efp.';
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
-
- print ' ';
- print '
';
- */
-
print ' ';
print ' ';
}
@@ -1506,19 +1406,12 @@ function projectLinesPerWeekDoliSIRH(&$inc, $firstdaytoshow, $fuser, $parent, $l
}
if ($conf->global->DOLISIRH_SHOW_ONLY_FAVORITE_TASKS) {
- $taskfavorite = isTaskFavorite($lines[$i]->id, $fuser->id);
+ $displayTask = isTaskFavorite($lines[$i]->id, $fuser->id);
} else {
- $taskfavorite = 1;
+ $displayTask = 1;
}
- print 'id.'">'."\n";
-
- // User
- /*
- print '';
- print $fuser->getNomUrl(1, 'withproject', 'time');
- print ' ';
- */
+ print ' id.'">'."\n";
// Project
if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
diff --git a/view/timespent_month.php b/view/timespent_month.php
index 4ecee90..802215b 100644
--- a/view/timespent_month.php
+++ b/view/timespent_month.php
@@ -388,6 +388,14 @@
}
}
+if ($action == 'showOnlyTasksWithTimeSpent') {
+ if ($conf->global->DOLISIRH_SHOW_ONLY_TASKS_WITH_TIMESPENT == 1) {
+ dolibarr_set_const($db, 'DOLISIRH_SHOW_ONLY_TASKS_WITH_TIMESPENT', 0, 'integer', 0, '', $conf->entity);
+ } else {
+ dolibarr_set_const($db, 'DOLISIRH_SHOW_ONLY_TASKS_WITH_TIMESPENT', 1, 'integer', 0, '', $conf->entity);
+ }
+}
+
/*
* View
@@ -452,7 +460,9 @@
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
$tasksarray = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields);
-//$tasksarray = getFavoriteTasksArray($taskstatic->id, 0, 0, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later.
+//if ($conf->global->DOLISIRH_SHOW_ONLY_FAVORITE_TASKS) {
+// $tasksarray = getFavoriteTasksArray($taskstatic->id, 0, 0, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later.
+//}
if (!empty($conf->global->DOLISIRH_SHOW_ONLY_FAVORITE_TASKS)) { // Get all task without any filter, so we can show total of time spent for not visible tasks
$tasksarraywithoutfilter = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later.
}
@@ -550,6 +560,9 @@
print ' '.' '.$langs->trans('WarningShowOnlyFavoriteTasks').'
';
}
+print '
';
+print $langs->trans('ShowOnlyTasksWithTimeSpent');
+print ' global->DOLISIRH_SHOW_ONLY_TASKS_WITH_TIMESPENT ? ' checked' : '').' >';
$numendworkingday = 0;
$numstartworkingday = 0;