forked from Wavyzz/dolibarr
Close #29312 Can keep date filters between screens
This commit is contained in:
@@ -60,8 +60,8 @@ if ($type == 'sub') {
|
||||
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : $context_default;
|
||||
$show_subgroup = GETPOST('show_subgroup', 'alpha');
|
||||
|
||||
$search_date_start = GETPOSTDATE('date_start', 'getpost');
|
||||
$search_date_end = GETPOSTDATE('date_end', 'getpostend');
|
||||
$search_date_start = GETPOSTDATE('date_start', 'getpost', 'auto', 'search_date_start_accountancy');
|
||||
$search_date_end = GETPOSTDATE('date_end', 'getpostend', 'auto', 'search_date_end_accountancy');
|
||||
|
||||
$search_ledger_code = GETPOST('search_ledger_code', 'array');
|
||||
$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
|
||||
|
||||
@@ -68,8 +68,8 @@ $search_doc_ref = GETPOST("search_doc_ref", 'alpha');
|
||||
|
||||
$search_doc_date = GETPOSTDATE('doc_date', 'getpost'); // deprecated. Can use 'search_date_start/end'
|
||||
|
||||
$search_date_start = GETPOSTDATE('search_date_start', 'getpost');
|
||||
$search_date_end = GETPOSTDATE('search_date_end', 'getpostend');
|
||||
$search_date_start = GETPOSTDATE('search_date_start', 'getpost', 'auto', 'search_date_start_accountancy');
|
||||
$search_date_end = GETPOSTDATE('search_date_end', 'getpostend', 'auto', 'search_date_end_accountancy');
|
||||
|
||||
$search_date_creation_start = GETPOSTDATE('search_date_creation_start', 'getpost');
|
||||
$search_date_creation_end = GETPOSTDATE('search_date_creation_end', 'getpostend');
|
||||
|
||||
@@ -69,12 +69,12 @@ $search_doc_date = GETPOSTDATE('doc_date', 'getpost'); // deprecated. Can use 's
|
||||
$search_date_startyear = GETPOSTINT('search_date_startyear');
|
||||
$search_date_startmonth = GETPOSTINT('search_date_startmonth');
|
||||
$search_date_startday = GETPOSTINT('search_date_startday');
|
||||
$search_date_start = GETPOSTDATE('search_date_start', 'getpost');
|
||||
$search_date_start = GETPOSTDATE('search_date_start', 'getpost', 'auto', 'search_date_start_accountancy');
|
||||
|
||||
$search_date_endyear = GETPOSTINT('search_date_endyear');
|
||||
$search_date_endmonth = GETPOSTINT('search_date_endmonth');
|
||||
$search_date_endday = GETPOSTINT('search_date_endday');
|
||||
$search_date_end = GETPOSTDATE('search_date_end', 'getpostend');
|
||||
$search_date_end = GETPOSTDATE('search_date_end', 'getpostend', 'auto', 'search_date_end_accountancy');
|
||||
|
||||
$search_date_export_startyear = GETPOSTINT('search_date_export_startyear');
|
||||
$search_date_export_startmonth = GETPOSTINT('search_date_export_startmonth');
|
||||
|
||||
@@ -1162,12 +1162,13 @@ function GETPOSTFLOAT($paramname, $rounding = '')
|
||||
* or 'XX:YY:ZZ' to set hour, minute, second respectively, for example '23:59:59'
|
||||
* or 'end' means '23:59:59'
|
||||
* or '' means '00:00:00' (default)
|
||||
* @param int|string $gm Passed to dol_mktime. If most cases, when used with 'getpost' or 'getpostend', it should be 'tzuserrel'.
|
||||
* @param int|string $gm Passed to dol_mktime. In most cases, when used with 'getpost' or 'getpostend', it should be 'tzuserrel'. Use 'auto' if you need dates related to 'tzserver' (like in accountancy).
|
||||
* @param string $saverestore Use a string context to save retrieved date so it will be used on next retrieve using same context if not defined.
|
||||
* @return int|string Date as a timestamp, '' or false if error
|
||||
*
|
||||
* @see dol_mktime()
|
||||
*/
|
||||
function GETPOSTDATE($prefix, $hourTime = '', $gm = 'auto')
|
||||
function GETPOSTDATE($prefix, $hourTime = '', $gm = 'auto', $saverestore = '')
|
||||
{
|
||||
$m = array();
|
||||
if ($hourTime === 'getpost' || $hourTime === 'getpostend') {
|
||||
@@ -1183,13 +1184,30 @@ function GETPOSTDATE($prefix, $hourTime = '', $gm = 'auto')
|
||||
} else {
|
||||
$hour = $minute = $second = 0;
|
||||
}
|
||||
|
||||
if ($saverestore && !GETPOSTISSET($prefix.'day') && !GETPOSTISSET($prefix.'month') && !GETPOSTISSET($prefix.'year')) {
|
||||
$day = $_SESSION['DOLDATE_'.$saverestore.'_day'];
|
||||
$month = $_SESSION['DOLDATE_'.$saverestore.'_month'];
|
||||
$year = $_SESSION['DOLDATE_'.$saverestore.'_year'];
|
||||
} else {
|
||||
$month = GETPOSTINT($prefix . 'month');
|
||||
$day = GETPOSTINT($prefix . 'day');
|
||||
$year = GETPOSTINT($prefix . 'year');
|
||||
}
|
||||
|
||||
// normalize out of range values
|
||||
$hour = (int) min($hour, 23);
|
||||
$minute = (int) min($minute, 59);
|
||||
$second = (int) min($second, 59);
|
||||
|
||||
//print "$hour, $minute, $second, GETPOSTINT($prefix . 'month'), GETPOSTINT($prefix . 'day'), GETPOSTINT($prefix . 'year'), $gm<br>";
|
||||
return dol_mktime($hour, $minute, $second, GETPOSTINT($prefix . 'month'), GETPOSTINT($prefix . 'day'), GETPOSTINT($prefix . 'year'), $gm);
|
||||
if ($saverestore) {
|
||||
$_SESSION['DOLDATE_'.$saverestore.'_day'] = $day;
|
||||
$_SESSION['DOLDATE_'.$saverestore.'_month'] = $month;
|
||||
$_SESSION['DOLDATE_'.$saverestore.'_year'] = $year;
|
||||
}
|
||||
|
||||
//print "$hour, $minute, $second, $month, $day, $year, $gm<br>";
|
||||
return dol_mktime($hour, $minute, $second, $month, $day, $year, $gm);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user