Added searching using year

This commit is contained in:
Ion Agorria 2014-12-28 03:39:30 +01:00
parent af15fe7dad
commit bdd7e9df23
2 changed files with 9 additions and 1 deletions

View File

@ -84,7 +84,8 @@ if (! empty($conf->projet->enabled) && $user->rights->projet->lire)
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAProject").'</td></tr>';
print '<tr '.$bc[$var].'>';
print '<td class="nowrap"><label for="sf_ref">'.$langs->trans("Ref").'</label>:</td><td><input type="text" class="flat" name="search_ref" id="sf_ref" size="18"></td>';
print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print '<td rowspan="3"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print '<tr '.$bc[$var].'><td class="nowrap"><label for="syear">'.$langs->trans("Year").'</label>:</td><td><input type="text" class="flat" name="search_year" id="search_year" size="18"></td>';
print '<tr '.$bc[$var].'><td class="nowrap"><label for="sall">'.$langs->trans("Other").'</label>:</td><td><input type="text" class="flat" name="search_all" id="search_all" size="18"></td>';
print '</tr>';
print "</table></form>\n";

View File

@ -27,6 +27,7 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$langs->load('projects');
@ -61,6 +62,7 @@ $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
$search_ref=GETPOST("search_ref");
$search_label=GETPOST("search_label");
$search_societe=GETPOST("search_societe");
$search_year=GETPOST("search_year");
$search_all=GETPOST("search_all");
// Purge criteria
@ -69,6 +71,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
$search_ref="";
$search_label="";
$search_societe="";
$search_year="";
$search_all=0;
}
@ -106,6 +109,10 @@ if ($search_societe)
{
$sql .= natural_search('s.nom', $search_societe);
}
if ($search_year) {
$sql .= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($search_year,12,false)).")";
$sql .= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($search_year,1,false)).")";
}
if ($search_all)
{
$sql .= natural_search(array('p.ref','p.title','s.nom'), $search_all);