From 2dbb6e258beca78e337a49c37e6bbca142b00598 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Aug 2018 22:29:02 +0200 Subject: [PATCH] FIX Can filter on month in export of blockedlog FIX Fingerprint correct in popup --- htdocs/blockedlog/admin/blockedlog_list.php | 46 +++++++++++++++------ htdocs/core/class/html.form.class.php | 2 + htdocs/langs/en_US/blockedlog.lang | 2 +- 3 files changed, 36 insertions(+), 14 deletions(-) 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 '
'; print $langs->trans("RestrictYearToExport").': '; -print ''; +$smonth=GETPOST('monthtoexport','int'); +// Month +$retstring=''; +$retstring.='"; +print $retstring; +print ''; print ''; print ''; if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) print ' | '.$langs->trans('DownloadBlockChain').''; @@ -485,7 +505,7 @@ if (is_array($blocks)) // Fingerprint print ''; - print $form->textwithpicto(dol_trunc($block->signature, '12'), $block->signature, 1, 'help', '', 0, 2, 'fingerprint'); + print $form->textwithpicto(dol_trunc($block->signature, '12'), $block->signature, 1, 'help', '', 0, 2, 'fingerprint'.$block->id); print ''; // Status diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 015ff23737b..83f613155aa 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4943,6 +4943,7 @@ class Form } // Zone de saisie manuelle de la date + $retstring.='
'; $retstring.='trans("FormatDateShortJavaInput").'\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript @@ -4966,6 +4967,7 @@ class Form $retstring.=''; } + $retstring.='
'; $retstring.=''."\n"; $retstring.=''."\n"; $retstring.=''."\n"; diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 9f6a49a5146..055345d0667 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -50,4 +50,4 @@ BlockedLogActivatedBecauseRequiredByYourCountryLegislation=Unalterable Logs modu BlockedLogDisableNotAllowedForCountry=List of countries where usage of this module is mandatory (just to prevent to disable the module by error, if your country is in this list, disable of module is not possible without editing this list first. Note also that enabling/disabling this module will keep a track into the unalterable log). OnlyNonValid=Non valid TooManyRecordToScanRestrictFilters=Too many record to scan/analyze. Please restrict list with more restrictive filters. -RestrictYearToExport=Restrict year to export \ No newline at end of file +RestrictYearToExport=Restrict month / year to export \ No newline at end of file