diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index dbb0affdbdf..9e31c3637dd 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -117,10 +117,10 @@ else if (GETPOST('downloadcsv','alpha')) $sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data"; $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog"; $sql.= " WHERE entity = ".$conf->entity; - if (GETPOST('yeartoexport','int') > 0) + if (GETPOST('monthtoexport','int') > 0 || GETPOST('yeartoexport','int') > 0) { - $dates = dol_get_first_day(GETPOST('yeartoexport','int'), 1); - $datee = dol_get_last_day(GETPOST('yeartoexport','int'), 12); + $dates = dol_get_first_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):1); + $datee = dol_get_last_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):12); $sql.= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'"; } $sql.= " ORDER BY rowid ASC"; // Required so we get the first one @@ -131,9 +131,16 @@ else if (GETPOST('downloadcsv','alpha')) { // Make the first fetch to get first line $obj = $db->fetch_object($res); - - $previoushash = $block_static->getPreviousHash(0, $obj->rowid); - $firstid = $obj->rowid; + if ($obj) + { + $previoushash = $block_static->getPreviousHash(0, $obj->rowid); + $firstid = $obj->rowid; + } + else + { // If not data found for filter, we do not need previoushash neither firstid + $previoushash = 'nodata'; + $firstid = ''; + } } else { @@ -144,14 +151,14 @@ else if (GETPOST('downloadcsv','alpha')) if (! $error) { - // Now restart request with all data + // Now restart request with all data = no limit(1) in sql request $sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data"; $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog"; $sql.= " WHERE entity = ".$conf->entity; - if (GETPOST('yeartoexport','int') > 0) + if (GETPOST('monthtoexport','int') > 0 || GETPOST('yeartoexport','int') > 0) { - $dates = dol_get_first_day(GETPOST('yeartoexport','int'), 1); - $datee = dol_get_last_day(GETPOST('yeartoexport','int'), 12); + $dates = dol_get_first_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):1); + $datee = dol_get_last_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):12); $sql.= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'"; } $sql.= " ORDER BY rowid ASC"; // Required so later we can use the parameter $previoushash of checkSignature() @@ -161,7 +168,7 @@ else if (GETPOST('downloadcsv','alpha')) { header('Content-Type: application/octet-stream'); header("Content-Transfer-Encoding: Binary"); - header("Content-disposition: attachment; filename=\"unalterable-log-archive-" .$dolibarr_main_db_name."-".(GETPOST('yeartoexport','int')>0?GETPOST('yeartoexport','int').'-':'').$previoushash. ".csv\""); + header("Content-disposition: attachment; filename=\"unalterable-log-archive-" .$dolibarr_main_db_name."-".(GETPOST('yeartoexport','int')>0 ? GETPOST('yeartoexport','int').(GETPOST('monthtoexport','int')>0?sprintf("%02d",GETPOST('monthtoexport','int')):'').'-':'').$previoushash. ".csv\""); print $langs->transnoentities('Id') .';'.$langs->transnoentities('Date') @@ -321,7 +328,20 @@ print '