NEW : search on time spent duration range

This commit is contained in:
Gauthier PC portable 024 2023-01-02 16:21:14 +01:00
parent 70e1e8cbb9
commit 3ed5edc003

View File

@ -88,6 +88,10 @@ $search_company = GETPOST('$search_company', 'alpha');
$search_company_alias = GETPOST('$search_company_alias', 'alpha');
$search_project_ref = GETPOST('$search_project_ref', 'alpha');
$search_project_label = GETPOST('$search_project_label', 'alpha');
$search_timespent_starthour = GETPOSTINT("search_timespent_duration_starthour");
$search_timespent_startmin = GETPOSTINT("search_timespent_duration_startmin");
$search_timespent_endhour = GETPOSTINT("search_timespent_duration_endhour");
$search_timespent_endmin = GETPOSTINT("search_timespent_duration_endmin");
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
@ -196,6 +200,10 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_product_ref = '';
$toselect = array();
$search_array_options = array();
$search_timespent_starthour = '';
$search_timespent_startmin = '';
$search_timespent_endhour = '';
$search_timespent_endmin = '';
$action = '';
}
@ -1337,6 +1345,18 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if ($search_date_endyear) {
$param .= '&search_date_endyear='.urlencode($search_date_endyear);
}
if ($search_timespent_starthour) {
$param .= '&search_timespent_duration_starthour='.urlencode($search_timespent_starthour);
}
if ($search_timespent_startmin) {
$param .= '&search_timespent_duration_startmin='.urlencode($search_timespent_startmin);
}
if ($search_timespent_endhour) {
$param .= '&search_timespent_duration_endhour='.urlencode($search_timespent_endhour);
}
if ($search_timespent_endmin) {
$param .= '&search_timespent_duration_endmin='.urlencode($search_timespent_endmin);
}
/*
// Add $param from extra fields
@ -1609,6 +1629,18 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$sql .= " AND t.task_date <= '".$db->idate($search_date_end)."'";
}
if($search_timespent_starthour || $search_timespent_startmin) {
$timespent_duration_start = $search_timespent_starthour * 60 * 60; // We store duration in seconds
$timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60; // We store duration in seconds
$sql .= " AND t.task_duration >= ".$timespent_duration_start;
}
if($search_timespent_endhour || $search_timespent_endmin) {
$timespent_duration_end = $search_timespent_endhour * 60 * 60; // We store duration in seconds
$timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60; // We store duration in seconds
$sql .= " AND t.task_duration <= ".$timespent_duration_end;
}
$sql .= dolSqlDateFilter('t.task_datehour', $search_day, $search_month, $search_year);
// Add where from hooks
@ -1877,7 +1909,26 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
// Duration
if (!empty($arrayfields['t.task_duration']['checked'])) {
print '<td class="liste_titre right"></td>';
// Duration - Time spent
print '<td class="liste_titre right">';
$durationtouse_start = 0;
if ($search_timespent_starthour || $search_timespent_startmin) {
$durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60);
}
print '<div class="nowraponall">'.$langs->trans('from').'&nbsp;';
$form->select_duration('search_timespent_duration_start', $durationtouse_start, 0, 'text');
print '</div>';
$durationtouse_end = 0;
if ($search_timespent_endhour || $search_timespent_endmin) {
$durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60);
}
print '<div class="nowraponall">'.$langs->trans('at').'&nbsp;';
$form->select_duration('search_timespent_duration_end', $durationtouse_end, 0, 'text');
print '</div>';
print '</td>';
}
// Product
if (!empty($arrayfields['t.fk_product']['checked'])) {