2
0
forked from Wavyzz/dolibarr

Merge pull request #1878 from Cubexed/develop

This commit adds a way to filter projects by checking if selected year is in creation/ending range.
This commit is contained in:
Laurent Destailleur
2014-09-18 17:47:12 +02:00

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,17 @@ 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 (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter,12,false)).")";
$sql.= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter,1,false)).")";
}
}
$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 +736,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>';
}
}