This commit adds a way to filter projects by checking if

selected year is in creation/ending range.

The year input is shown after the list, outside the table.

It's hidden by default and must be
enabled with PROJECT_LIMIT_YEAR_RANGE
This commit is contained in:
Cubexed 2014-09-12 05:30:17 +02:00
parent 653d9d4167
commit c23fab267c

View File

@ -642,6 +642,7 @@ function print_projecttasks_array($db, $socid, $projectsListId, $mytasks=0, $sta
$sortfield='';
$sortorder='';
$project_year_filter=0;
$title=$langs->trans("Project");
if ($statut == 0) $title=$langs->trans("ProjectDraft");
@ -681,6 +682,16 @@ function print_projecttasks_array($db, $socid, $projectsListId, $mytasks=0, $sta
{
$sql.= " AND p.fk_statut = ".$statut;
}
if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
$project_year_filter = GETPOST("project_year_filter");
//Check if empty or invalid year. Wildcard ignores the sql check
if ($project_year_filter != "*") {
if (empty($project_year_filter) || !ctype_digit($project_year_filter)) { //
$project_year_filter = date("Y");
}
$sql.= " AND (YEAR(p.datec) <= ".$project_year_filter." AND YEAR(p.datee) >= ".$project_year_filter.")";
}
}
$sql.= " GROUP BY p.rowid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut";
$sql.= " ORDER BY p.title, p.ref";
@ -724,6 +735,19 @@ function print_projecttasks_array($db, $socid, $projectsListId, $mytasks=0, $sta
{
dol_print_error($db);
}
print "</table>";
if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
//Add the year filter input
print '<table width="100%">';
print '<tr>';
print '<td>'.$langs->trans("Year").'</td>';
print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">';
print '<td style="text-align:right"><input type="text" size="4" class="flat" name="project_year_filter" value="'.$project_year_filter.'"/>';
print '</form>';
print "</tr>\n";
print '</table>';
}
}