*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -71,12 +72,22 @@ if ($mine) {
$search_task_user = $user->id; $mine = 0;
}
-$search_sday = GETPOST('search_sday', 'int');
-$search_smonth = GETPOST('search_smonth', 'int');
-$search_syear = GETPOST('search_syear', 'int');
-$search_eday = GETPOST('search_eday', 'int');
-$search_emonth = GETPOST('search_emonth', 'int');
-$search_eyear = GETPOST('search_eyear', 'int');
+$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_datelimit_startday = GETPOST('search_datelimit_startday', 'int');
+$search_datelimit_startmonth = GETPOST('search_datelimit_startmonth', 'int');
+$search_datelimit_startyear = GETPOST('search_datelimit_startyear', 'int');
+$search_datelimit_endday = GETPOST('search_datelimit_endday', 'int');
+$search_datelimit_endmonth = GETPOST('search_datelimit_endmonth', 'int');
+$search_datelimit_endyear = GETPOST('search_datelimit_endyear', 'int');
+$search_datelimit_start = dol_mktime(0, 0, 0, $search_datelimit_startmonth, $search_datelimit_startday, $search_datelimit_startyear);
+$search_datelimit_end = dol_mktime(23, 59, 59, $search_datelimit_endmonth, $search_datelimit_endday, $search_datelimit_endyear);
// Initialize context for list
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'tasklist';
@@ -191,12 +202,22 @@ if (empty($reshook)) {
$search_task_progress = "";
$search_task_user = -1;
$search_project_user = -1;
- $search_sday = '';
- $search_smonth = '';
- $search_syear = '';
- $search_eday = '';
- $search_emonth = '';
- $search_eyear = '';
+ $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_datelimit_startday = '';
+ $search_datelimit_startmonth = '';
+ $search_datelimit_startyear = '';
+ $search_datelimit_endday = '';
+ $search_datelimit_endmonth = '';
+ $search_datelimit_endyear = '';
+ $search_datelimit_start = '';
+ $search_datelimit_end = '';
$toselect = '';
$search_array_options = array();
}
@@ -372,8 +393,18 @@ if ($search_task_progress) {
if ($search_societe) {
$sql .= natural_search('s.nom', $search_societe);
}
-$sql .= dolSqlDateFilter('t.dateo', $search_sday, $search_smonth, $search_syear);
-$sql .= dolSqlDateFilter('t.datee', $search_eday, $search_emonth, $search_eyear);
+if ($search_date_start) {
+ $sql .= " AND t.dateo >= '".$db->idate($search_date_start)."'";
+}
+if ($search_date_end) {
+ $sql .= " AND t.dateo <= '".$db->idate($search_date_end)."'";
+}
+if ($search_datelimit_start) {
+ $sql .= " AND t.datee >= '".$db->idate($search_datelimit_start)."'";
+}
+if ($search_datelimit_end) {
+ $sql .= " AND t.datee <= '".$db->idate($search_datelimit_end)."'";
+}
if ($search_all) {
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
}
@@ -454,23 +485,41 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
-if ($search_sday) {
- $param .= '&search_sday='.urlencode($search_sday);
+if ($search_date_startday) {
+ $param .= '&search_date_startday='.urlencode($search_date_startday);
}
-if ($search_smonth) {
- $param .= '&search_smonth='.urlencode($search_smonth);
+if ($search_date_startmonth) {
+ $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
}
-if ($search_syear) {
- $param .= '&search_syear='.urlencode($search_syear);
+if ($search_date_startyear) {
+ $param .= '&search_date_startyear='.urlencode($search_date_startyear);
}
-if ($search_eday) {
- $param .= '&search_eday='.urlencode($search_eday);
+if ($search_date_endday) {
+ $param .= '&search_date_endday='.urlencode($search_date_endday);
}
-if ($search_emonth) {
- $param .= '&search_emonth='.urlencode($search_emonth);
+if ($search_date_endmonth) {
+ $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
}
-if ($search_eyear) {
- $param .= '&search_eyear='.urlencode($search_eyear);
+if ($search_date_endyear) {
+ $param .= '&search_date_endyear='.urlencode($search_date_endyear);
+}
+if ($search_datelimit_startday) {
+ $param .= '&search_datelimit_startday='.urlencode($search_datelimit_startday);
+}
+if ($search_datelimit_startmonth) {
+ $param .= '&search_datelimit_startmonth='.urlencode($search_datelimit_startmonth);
+}
+if ($search_datelimit_startyear) {
+ $param .= '&search_datelimit_startyear='.urlencode($search_datelimit_startyear);
+}
+if ($search_datelimit_endday) {
+ $param .= '&search_datelimit_endday='.urlencode($search_datelimit_endday);
+}
+if ($search_datelimit_endmonth) {
+ $param .= '&search_datelimit_endmonth='.urlencode($search_datelimit_endmonth);
+}
+if ($search_datelimit_endyear) {
+ $param .= '&search_datelimit_endyear='.urlencode($search_datelimit_endyear);
}
if ($socid) {
$param .= '&socid='.urlencode($socid);
@@ -646,22 +695,26 @@ if (!empty($arrayfields['t.description']['checked'])) {
}
// Start date
if (!empty($arrayfields['t.dateo']['checked'])) {
- print '';
- if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
- print ' ';
- }
- print ' ';
- print $formother->selectyear($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5, 0, 0, '', 'valignmiddle width75', 1);
+ print ' ';
+ print '';
+ print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
+ print '
';
+ print '';
+ print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
+ print '
';
print ' ';
}
// End date
if (!empty($arrayfields['t.datee']['checked'])) {
- print '';
- if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
- print ' ';
- }
- print ' ';
- print $formother->selectyear($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5, 0, 0, '', 'valignmiddle width75', 1);
+ print ' ';
+ print '';
+ print $form->selectDate($search_datelimit_start ? $search_datelimit_start : -1, 'search_datelimit_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
+ print '
';
+ print '';
+ print $form->selectDate($search_datelimit_end ? $search_datelimit_end : -1, 'search_datelimit_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
+ // TODO Add option late
+ //print ' '.$langs->trans("Alert");
+ print '
';
print ' ';
}
if (!empty($arrayfields['p.ref']['checked'])) {
diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php
index 917a0a8b64b..33a32cea0a8 100644
--- a/htdocs/reception/list.php
+++ b/htdocs/reception/list.php
@@ -491,6 +491,12 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.rowid = ee.fk_target";
if (!$user->rights->societe->client->voir && !$socid) { // Internal user with no permission to see all
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
+
+// Add joins from hooks
+$parameters = array();
+$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters); // Note that $action and $object may have been modified by hook
+$sql .= $hookmanager->resPrint;
+
$sql .= " WHERE e.entity IN (".getEntity('reception').")";
if (!$user->rights->societe->client->voir && !$socid) { // Internal user with no permission to see all
$sql .= " AND e.fk_soc = sc.fk_soc";