Ignore:
Timestamp:
Sep 22, 2021, 10:34:30 PM (3 years ago)
Author:
chronos
Message:
  • Added: Made IS dashboard numbers as links with filters.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/IS/IS.php

    r912 r914  
    549549  }
    550550
     551  function GetParam(string $Name, string $Default): string
     552  {
     553    $Result = $Default;
     554    if (array_key_exists($Name, $_POST) and ($_POST[$Name] != ''))
     555    {
     556      $Result = $_POST[$Name];
     557    }
     558    if (array_key_exists($Name, $_GET) and ($_GET[$Name] != ''))
     559    {
     560      $Result = $_GET[$Name];
     561    }
     562    return $Result;
     563  }
     564
    551565  function ShowTable(string $Table, string $Filter = '', string $Title = '', string $RowActions = '', string $ExcludeColumn = ''): string
    552566  {
     
    604618        $FilterName = $this->System->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterName',
    605619          array('Name' => $ItemIndex, 'Type' => $FormItem['Type']));
    606         if (array_key_exists('Filter'.$ItemIndex, $_POST) and ($_POST['Filter'.$ItemIndex] != ''))
     620
     621        $SqlOperator = array(
     622          'like' => 'LIKE',
     623          'notlike' => 'NOT LIKE',
     624          'equal' => '=',
     625          'notequal' => '!=',
     626          'less' => '<',
     627          'lessorequal' => '<=',
     628          'greater' => '>',
     629          'greaterorequal' => '>=',
     630          'isnull' => 'IS NULL',
     631          'isnotnull' => 'IS NOT NULL',
     632        );
     633        $Operator = $this->GetParam('FilterOp'.$ItemIndex, 'like');
     634        if (array_key_exists($Operator, $SqlOperator))
     635        {
     636          $OperatorSql = $SqlOperator[$Operator];
     637        } else $OperatorSql = $SqlOperator['like'];
     638
     639        $FilterValue = $this->GetParam('Filter'.$ItemIndex, '');
     640        if ($FilterValue != '')
    607641        {
    608642          if ($UserFilter != '') $UserFilter .= ' AND ';
    609           $UserFilter .= '('.$FilterName.' LIKE "%'.$_POST['Filter'.$ItemIndex].'%")';
     643          $UserFilter .= '('.$FilterName.' '.$OperatorSql;
     644          if (($Operator == 'like') or ($Operator == 'notlike')) $UserFilter .= ' "%'.$FilterValue.'%")';
     645            else if (($Operator == 'isnull') or ($Operator == 'isnotnull')) $UserFilter .= ')';
     646            else $UserFilter .= ' "'.$FilterValue.'")';
    610647        }
    611648      }
    612649    }
     650    echo($UserFilter);
    613651    if ($UserFilter != '')
    614652    {
Note: See TracChangeset for help on using the changeset viewer.