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;
|
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : $context_default;
|
||||||
$show_subgroup = GETPOST('show_subgroup', 'alpha');
|
$show_subgroup = GETPOST('show_subgroup', 'alpha');
|
||||||
|
|
||||||
$search_date_start = GETPOSTDATE('date_start', 'getpost');
|
$search_date_start = GETPOSTDATE('date_start', 'getpost', 'auto', 'search_date_start_accountancy');
|
||||||
$search_date_end = GETPOSTDATE('date_end', 'getpostend');
|
$search_date_end = GETPOSTDATE('date_end', 'getpostend', 'auto', 'search_date_end_accountancy');
|
||||||
|
|
||||||
$search_ledger_code = GETPOST('search_ledger_code', 'array');
|
$search_ledger_code = GETPOST('search_ledger_code', 'array');
|
||||||
$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
|
$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_doc_date = GETPOSTDATE('doc_date', 'getpost'); // deprecated. Can use 'search_date_start/end'
|
||||||
|
|
||||||
$search_date_start = GETPOSTDATE('search_date_start', 'getpost');
|
$search_date_start = GETPOSTDATE('search_date_start', 'getpost', 'auto', 'search_date_start_accountancy');
|
||||||
$search_date_end = GETPOSTDATE('search_date_end', 'getpostend');
|
$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_start = GETPOSTDATE('search_date_creation_start', 'getpost');
|
||||||
$search_date_creation_end = GETPOSTDATE('search_date_creation_end', 'getpostend');
|
$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_startyear = GETPOSTINT('search_date_startyear');
|
||||||
$search_date_startmonth = GETPOSTINT('search_date_startmonth');
|
$search_date_startmonth = GETPOSTINT('search_date_startmonth');
|
||||||
$search_date_startday = GETPOSTINT('search_date_startday');
|
$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_endyear = GETPOSTINT('search_date_endyear');
|
||||||
$search_date_endmonth = GETPOSTINT('search_date_endmonth');
|
$search_date_endmonth = GETPOSTINT('search_date_endmonth');
|
||||||
$search_date_endday = GETPOSTINT('search_date_endday');
|
$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_startyear = GETPOSTINT('search_date_export_startyear');
|
||||||
$search_date_export_startmonth = GETPOSTINT('search_date_export_startmonth');
|
$search_date_export_startmonth = GETPOSTINT('search_date_export_startmonth');
|
||||||
|
|||||||
@@ -1157,17 +1157,18 @@ function GETPOSTFLOAT($paramname, $rounding = '')
|
|||||||
* Helper function that combines values of a dolibarr DatePicker (such as Form::selectDate) for year, month, day (and
|
* Helper function that combines values of a dolibarr DatePicker (such as Form::selectDate) for year, month, day (and
|
||||||
* optionally hour, minute, second) fields to return a timestamp.
|
* optionally hour, minute, second) fields to return a timestamp.
|
||||||
*
|
*
|
||||||
* @param string $prefix Prefix used to build the date selector (for instance using Form::selectDate). Example: 'select_datec'
|
* @param string $prefix Prefix used to build the date selector (for instance using Form::selectDate). Example: 'select_datec'
|
||||||
* @param string $hourTime 'getpost' or 'getpostend' to include hour, minute, second values from the HTTP request,
|
* @param string $hourTime 'getpost' or 'getpostend' to include hour, minute, second values from the HTTP request,
|
||||||
* or 'XX:YY:ZZ' to set hour, minute, second respectively, for example '23:59:59'
|
* or 'XX:YY:ZZ' to set hour, minute, second respectively, for example '23:59:59'
|
||||||
* or 'end' means '23:59:59'
|
* or 'end' means '23:59:59'
|
||||||
* or '' means '00:00:00' (default)
|
* 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).
|
||||||
* @return int|string Date as a timestamp, '' or false if error
|
* @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()
|
* @see dol_mktime()
|
||||||
*/
|
*/
|
||||||
function GETPOSTDATE($prefix, $hourTime = '', $gm = 'auto')
|
function GETPOSTDATE($prefix, $hourTime = '', $gm = 'auto', $saverestore = '')
|
||||||
{
|
{
|
||||||
$m = array();
|
$m = array();
|
||||||
if ($hourTime === 'getpost' || $hourTime === 'getpostend') {
|
if ($hourTime === 'getpost' || $hourTime === 'getpostend') {
|
||||||
@@ -1183,13 +1184,30 @@ function GETPOSTDATE($prefix, $hourTime = '', $gm = 'auto')
|
|||||||
} else {
|
} else {
|
||||||
$hour = $minute = $second = 0;
|
$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
|
// normalize out of range values
|
||||||
$hour = (int) min($hour, 23);
|
$hour = (int) min($hour, 23);
|
||||||
$minute = (int) min($minute, 59);
|
$minute = (int) min($minute, 59);
|
||||||
$second = (int) min($second, 59);
|
$second = (int) min($second, 59);
|
||||||
|
|
||||||
//print "$hour, $minute, $second, GETPOSTINT($prefix . 'month'), GETPOSTINT($prefix . 'day'), GETPOSTINT($prefix . 'year'), $gm<br>";
|
if ($saverestore) {
|
||||||
return dol_mktime($hour, $minute, $second, GETPOSTINT($prefix . 'month'), GETPOSTINT($prefix . 'day'), GETPOSTINT($prefix . 'year'), $gm);
|
$_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