Merge pull request #22963 from atm-steve/new_list_for_task_time

NEW Filter on task time
This commit is contained in:
Laurent Destailleur 2022-11-29 00:26:31 +01:00 committed by GitHub
commit 2a8ad9ed50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,6 +68,14 @@ $search_month = GETPOST('search_month', 'int');
$search_year = GETPOST('search_year', 'int');
$search_datehour = '';
$search_datewithhour = '';
$search_date_startday = GETPOST('search_date_startday', 'int');
$search_date_startmonth = GETPOST('search_date_startmonth', 'int');
$search_date_startyear = GETPOST('search_date_startyear', 'int');
$search_date_endday = GETPOST('search_date_endday', 'int');
$search_date_endmonth = GETPOST('search_date_endmonth', 'int');
$search_date_endyear = GETPOST('search_date_endyear', 'int');
$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
$search_note = GETPOST('search_note', 'alpha');
$search_duration = GETPOST('search_duration', 'int');
$search_value = GETPOST('search_value', 'int');
@ -77,6 +85,9 @@ $search_user = GETPOST('search_user', 'int');
$search_valuebilled = GETPOST('search_valuebilled', 'int');
$search_product_ref = GETPOST('search_product_ref', 'alpha');
$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');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
@ -166,8 +177,19 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_value = '';
$search_date_creation = '';
$search_date_update = '';
$search_date_startday = '';
$search_date_startmonth = '';
$search_date_startyear = '';
$search_date_endday = '';
$search_date_endmonth = '';
$search_date_endyear = '';
$search_date_start = '';
$search_date_end = '';
$search_task_ref = '';
$search_company = '';
$search_company_alias = '';
$search_project_ref = '';
$search_project_label = '';
$search_task_label = '';
$search_user = 0;
$search_valuebilled = '';
@ -1220,11 +1242,16 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$arrayfields = array();
$arrayfields['t.task_date'] = array('label'=>$langs->trans("Date"), 'checked'=>1);
$arrayfields['p.fk_soc'] = array('label'=>$langs->trans("ThirdParty"), 'type'=>'integer:Societe:/societe/class/societe.class.php:1','checked'=>1);
$arrayfields['s.name_alias'] = array('label'=>$langs->trans("AliasNameShort"), 'type'=>'integer:Societe:/societe/class/societe.class.php:1');
if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task
if(! empty($allprojectforuser)) {
$arrayfields['p.project_ref'] = ['label' => $langs->trans('RefProject'), 'checked' => 1];
$arrayfields['p.project_label'] = ['label' => $langs->trans('ProjectLabel'), 'checked' => 1];
}
$arrayfields['t.task_ref'] = array('label'=>$langs->trans("RefTask"), 'checked'=>1);
$arrayfields['t.task_label'] = array('label'=>$langs->trans("LabelTask"), 'checked'=>1);
}
$arrayfields['author'] = array('label'=>$langs->trans("By"), 'checked'=>1);
}
$arrayfields['author'] = array('label'=>$langs->trans("By"), 'checked'=>1);
$arrayfields['t.note'] = array('label'=>$langs->trans("Note"), 'checked'=>1);
if ($conf->service->enabled && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
$arrayfields['t.fk_product'] = array('label' => $langs->trans("Product"), 'checked' => 1);
@ -1259,6 +1286,15 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if ($search_company != '') {
$param .= '&$search_company='.urlencode($search_company);
}
if ($search_company_alias != '') {
$param .= '&$search_company_alias='.urlencode($search_company_alias);
}
if ($search_project_ref != '') {
$param .= '&$search_project_ref='.urlencode($search_project_ref);
}
if ($search_project_label != '') {
$param .= '&$search_project_label='.urlencode($search_project_label);
}
if ($search_task_label != '') {
$param .= '&search_task_label='.urlencode($search_task_label);
}
@ -1271,6 +1307,25 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
if ($search_date_startday) {
$param .= '&search_date_startday='.urlencode($search_date_startday);
}
if ($search_date_startmonth) {
$param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
}
if ($search_date_startyear) {
$param .= '&search_date_startyear='.urlencode($search_date_startyear);
}
if ($search_date_endday) {
$param .= '&search_date_endday='.urlencode($search_date_endday);
}
if ($search_date_endmonth) {
$param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
}
if ($search_date_endyear) {
$param .= '&search_date_endyear='.urlencode($search_date_endyear);
}
/*
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -1460,7 +1515,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$sql .= " pt.ref, pt.label, pt.fk_projet,";
$sql .= " u.lastname, u.firstname, u.login, u.photo, u.statut as user_status,";
$sql .= " il.fk_facture as invoice_id, inv.fk_statut,";
$sql .= " p.fk_soc,";
$sql .= " p.fk_soc,s.name_alias,";
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
@ -1503,6 +1558,15 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if ($search_company) {
$sql .= natural_search('s.nom', $search_company);
}
if ($search_company_alias) {
$sql .= natural_search('s.name_alias', $search_company_alias);
}
if ($search_project_ref) {
$sql .= natural_search('p.ref', $search_project_ref);
}
if ($search_project_label) {
$sql .= natural_search('p.title', $search_project_label);
}
if ($search_task_label) {
$sql .= natural_search('pt.label', $search_task_label);
}
@ -1519,6 +1583,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$sql .= ' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
}
if ($search_date_start) {
$sql .= " AND t.task_date >= '".$db->idate($search_date_start)."'";
}
if ($search_date_end) {
$sql .= " AND t.task_date <= '".$db->idate($search_date_end)."'";
}
$sql .= dolSqlDateFilter('t.task_datehour', $search_day, $search_month, $search_year);
// Add where from hooks
@ -1740,22 +1811,33 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
// Fields title search
print '<tr class="liste_titre_filter">';
// Date
if (!empty($arrayfields['t.task_date']['checked'])) {
print '<td class="liste_titre">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">';
}
print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">';
print $formother->selectyear($search_year, 'search_year', 1, 20, 5);
print '</td>';
}
if (!empty($arrayfields['t.task_date']['checked'])) {
print '<td class="liste_titre left">';
print '<div class="nowrap">';
print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
print '</div>';
print '<div class="nowrap">';
print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
print '</div>';
print '</td>';
}
// Thirdparty
if (!empty($arrayfields['p.fk_soc']['checked'])) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="'.dol_escape_htmltag($search_company).'"></td>';
}
// Thirdparty alias
if (!empty($arrayfields['s.name_alias']['checked'])) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company_alias" value="'.dol_escape_htmltag($search_company_alias).'"></td>';
}
if (!empty($allprojectforuser)) {
print '<td class="liste_titre"></td>';
if (!empty($arrayfields['p.project_ref']['checked'])) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
}
if (!empty($arrayfields['p.project_label']['checked'])) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_project_label" value="'.dol_escape_htmltag($search_project_label).'"></td>';
}
}
// Task
if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task
@ -1810,11 +1892,20 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if (!empty($arrayfields['t.task_date']['checked'])) {
print_liste_field_titre($arrayfields['t.task_date']['label'], $_SERVER['PHP_SELF'], 't.task_date,t.task_datehour,t.rowid', '', $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['p.fk_soc']['checked'])) {
print_liste_field_titre($arrayfields['p.fk_soc']['label'], $_SERVER['PHP_SELF'], 't.task_date,t.task_datehour,t.rowid', '', $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['s.name_alias']['checked'])) {
print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER['PHP_SELF'], 's.name_alias', '', $param, '', $sortfield, $sortorder);
}
if (!empty($allprojectforuser)) {
print_liste_field_titre("Project", $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['p.project_ref']['checked'])) {
print_liste_field_titre("Project", $_SERVER['PHP_SELF'], 'p.ref', '', $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['p.project_label']['checked'])) {
print_liste_field_titre("ProjectLabel", $_SERVER['PHP_SELF'], 'p.title', '', $param, '', $sortfield, $sortorder);
}
}
if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task
if (!empty($arrayfields['t.task_ref']['checked'])) {
@ -1901,7 +1992,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
} else {
$tmpsociete = $conf->cache['thridparty'][$task_time->fk_soc];
}
print $tmpsociete->getNomUrl(1);
print $tmpsociete->getNomUrl(1, '', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
}
print '</td>';
if (!$i) {
@ -1909,23 +2000,61 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
}
// Project ref
if (!empty($allprojectforuser)) {
print '<td class="nowraponall">';
if (empty($conf->cache['project'][$task_time->fk_projet])) {
$tmpproject = new Project($db);
$tmpproject->fetch($task_time->fk_projet);
$conf->cache['project'][$task_time->fk_projet] = $tmpproject;
} else {
$tmpproject = $conf->cache['project'][$task_time->fk_projet];
// Thirdparty alias
if (!empty($arrayfields['s.name_alias']['checked'])) {
print '<td class="nowrap">';
if ($task_time->fk_soc > 0) {
if (empty($conf->cache['thridparty'][$task_time->fk_soc])) {
$tmpsociete = new Societe($db);
$tmpsociete->fetch($task_time->fk_soc);
$conf->cache['thridparty'][$task_time->fk_soc] = $tmpsociete;
} else {
$tmpsociete = $conf->cache['thridparty'][$task_time->fk_soc];
}
print $tmpsociete->name_alias;
}
print $tmpproject->getNomUrl(1);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Project ref & label
if (!empty($allprojectforuser)) {
if (!empty($arrayfields['p.project_ref']['checked'])) {
print '<td class="nowraponall">';
if(empty($conf->cache['project'][$task_time->fk_projet])) {
$tmpproject = new Project($db);
$tmpproject->fetch($task_time->fk_projet);
$conf->cache['project'][$task_time->fk_projet] = $tmpproject;
}
else {
$tmpproject = $conf->cache['project'][$task_time->fk_projet];
}
print $tmpproject->getNomUrl(1);
print '</td>';
if(! $i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['p.project_label']['checked'])) {
print '<td class="nowraponall">';
if(empty($conf->cache['project'][$task_time->fk_projet])) {
$tmpproject = new Project($db);
$tmpproject->fetch($task_time->fk_projet);
$conf->cache['project'][$task_time->fk_projet] = $tmpproject;
}
else {
$tmpproject = $conf->cache['project'][$task_time->fk_projet];
}
print $tmpproject->title;
print '</td>';
if(! $i) {
$totalarray['nbfield']++;
}
}
}
// Task ref
if (!empty($arrayfields['t.task_ref']['checked'])) {
if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task