Skip to content

Commit

Permalink
Filter on blockedlog
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Dec 14, 2017
1 parent 427f149 commit 4a9b610
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 23 deletions.
49 changes: 33 additions & 16 deletions htdocs/blockedlog/admin/blockedlog_list.php
Expand Up @@ -38,10 +38,16 @@
$backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print')

$search=array();

$showonlyerrors = GETPOST('showonlyerrors','int');

$search_start = -1;
if(GETPOST('search_startyear')!='') $search_start = dol_mktime(0, 0, 0, GETPOST('search_startmonth'), GETPOST('search_startday'), GETPOST('search_startyear'));
$search_end = -1;
if(GETPOST('search_endyear')!='') $search_end= dol_mktime(23, 59, 59, GETPOST('search_endmonth'), GETPOST('search_endday'), GETPOST('search_endyear'));
$search_ref = GETPOST('search_ref', 'alpha');
$search_amount = GETPOST('search_amount', 'alpha');


// Load variable for pagination
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
Expand All @@ -55,11 +61,6 @@
if (empty($sortfield)) $sortfield='rowid';
if (empty($sortorder)) $sortorder='DESC';

$search_start = -1;
if(GETPOST('search_startyear')!='') $search_start = dol_mktime(0, 0, 0, GETPOST('search_startmonth'), GETPOST('search_startday'), GETPOST('search_startyear'));

$search_end = -1;
if(GETPOST('search_endyear')!='') $search_end= dol_mktime(23, 59, 59, GETPOST('search_endmonth'), GETPOST('search_endday'), GETPOST('search_endyear'));



Expand All @@ -75,6 +76,8 @@
{
$search_start = -1;
$search_end = -1;
$search_ref = '';
$search_amount = '';
$toselect='';
$search_array_options=array();
}
Expand Down Expand Up @@ -153,10 +156,15 @@

$form=new Form($db);

$blocks = $block_static->getLog('all', 0, GETPOST('all','alpha') ? 0 : 50, $sortfield, $sortorder, $search_start, $search_end);

llxHeader('',$langs->trans("BlockedLogSetup"));

$blocks = $block_static->getLog('all', 0, GETPOST('all','alpha') ? 0 : 50, $sortfield, $sortorder, $search_start, $search_end, $search_ref, $search_amount);
if (! is_array($blocks))
{
dol_print_error($block_static->db);
exit;
}

$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'),$linkback);

Expand All @@ -173,10 +181,6 @@
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($search_start > 0) $param.='&search_startyear='.urlencode(GETPOST('search_startyear','int')).'&search_startmonth='.urlencode(GETPOST('search_startmonth','int')).'&search_startday='.urlencode(GETPOST('search_startday','int'));
if ($search_end > 0) $param.='&search_endyear='.urlencode(GETPOST('search_endyear','int')).'&search_endmonth='.urlencode(GETPOST('search_endmonth','int')).'&search_endday='.urlencode(GETPOST('search_endday','int'));
foreach($search as $key => $val)
{
$param.= '&search_'.$key.'='.urlencode($search[$key]);
}
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
// Add $param from extra fields
//include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
Expand All @@ -196,14 +200,27 @@

print '<table class="noborder" width="100%">';
print '<tr class="liste_titre_filter">';

print '<td class="liste_titre">&nbsp;</td>';

print '<td class="liste_titre">';
print $form->select_date($search_start,'search_start');
print $form->select_date($search_end,'search_end');
print '</td>';

print '<td class="liste_titre" colspan="7">&nbsp;</td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';

// Ref
print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';

print '<td class="liste_titre"></td>';

// Amount
print '<td class="liste_titre right"><input type="text" class="maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';

print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';

// Action column
print '<td class="liste_titre" align="middle">';
Expand All @@ -223,7 +240,7 @@
print getTitleFieldOfList($langs->trans('Amount'), 0, $_SERVER["PHP_SELF"],'','',$param,'align="right"',$sortfield,$sortorder,'')."\n";
print getTitleFieldOfList($langs->trans('DataOfArchivedEvent'), 0, $_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder,'')."\n";
print getTitleFieldOfList($langs->trans('Fingerprint'), 0, $_SERVER["PHP_SELF"],'','',$param,'',$sortfield,$sortorder,'')."\n";
print getTitleFieldOfList('<span id="blockchainstatus"></span>', 0, $_SERVER["PHP_SELF"],'','',$param,'',$sortfield,$sortorder,'')."\n";
print getTitleFieldOfList('<span id="blockchainstatus"></span>', 0, $_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder,'')."\n";
print '</tr>';

$loweridinerror=0;
Expand Down Expand Up @@ -261,7 +278,7 @@
print $form->textwithpicto(dol_trunc($block->signature, '12'), $block->signature);
print '</td>';

print '<td>';
print '<td class="center">';
if (! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error
{
if ($checkresult[$block->id]) print img_picto($langs->trans('OkCheckFingerprintValidityButChainIsKo'), 'statut1');
Expand Down
10 changes: 7 additions & 3 deletions htdocs/blockedlog/class/blockedlog.class.php
Expand Up @@ -582,9 +582,11 @@ private function getPreviousHash($withlock=0, $beforeid=0)
* @param string $sortorder sort order
* @param int $search_start start time limit
* @param int $search_end end time limit
* @param string $search_ref search ref
* @param string $search_amount search amount
* @return array array of object log
*/
public function getLog($element, $fk_object, $limit = 0, $sortfield = '', $sortorder = '', $search_start = -1, $search_end = -1)
public function getLog($element, $fk_object, $limit = 0, $sortfield = '', $sortorder = '', $search_start = -1, $search_end = -1, $search_ref='', $search_amount='')
{
global $conf, $cachedlogs;

Expand Down Expand Up @@ -612,8 +614,10 @@ public function getLog($element, $fk_object, $limit = 0, $sortfield = '', $sorto
WHERE element='".$element."' AND fk_object=".(int) $fk_object;
}

if($search_start > 0) $sql.=" AND date_creation >= '".$this->db->idate($search_start)."'";
if($search_end > 0) $sql.=" AND date_creation <= '".$this->db->idate($search_end)."'";
if ($search_start > 0) $sql.=" AND date_creation >= '".$this->db->idate($search_start)."'";
if ($search_end > 0) $sql.=" AND date_creation <= '".$this->db->idate($search_end)."'";
if ($search_ref != '') $sql.=natural_search("ref_object", $search_ref);
if ($search_amount != '') $sql.=natural_search("amounts", $search_amount, 1);

$sql.=$this->db->order($sortfield, $sortorder);

Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/modules/modBlockedLog.class.php
Expand Up @@ -48,7 +48,7 @@ function __construct($db)
$this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "Enable a log on some business events into a non reversible log. This module may be mandatory for some countries.";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'experimental';
$this->version = 'dolibarr';
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
Expand Down Expand Up @@ -134,7 +134,7 @@ function remove($options = '') {
$object->id = 1;
$object->element = 'module';
$object->ref = 'module';
$object->date = time();
$object->date = dol_now();

$b=new BlockedLog($this->db);
$b->setObjectData($object, 'MODULE_RESET', -1);
Expand Down
4 changes: 2 additions & 2 deletions htdocs/theme/eldy/style.css.php
Expand Up @@ -2731,10 +2731,10 @@
}

table.dataTable td {
padding: 5px 2px 5px 3px !important;
padding: 5px 8px 5px 8px !important;
}
tr.pair td, tr.impair td, form.impair div.tagtd, form.pair div.tagtd, div.impair div.tagtd, div.pair div.tagtd, div.liste_titre div.tagtd {
padding: 7px 2px 7px 3px;
padding: 7px 8px 7px 8px;
border-bottom: 1px solid #ddd;
}
form.pair, form.impair {
Expand Down

0 comments on commit 4a9b610

Please sign in to comment.