filter_is_current_active_user

 
          filter_is_current_active_user($table, $column, $session_key, $column_data_type = SRE_NUMBER)  
This data filtration function should filter any report by the current user ID so that each logged-in user sees only their records. In other words, this function should make each user sees only their records even when multiple users are accessing the exact same report.
In the following code example, any logged-in user when accessing the "orders" report, should see only the records related to them. Smart Report Engine should implements this by querying the "Orders" table with a where clause for filtering the "Employee_id" column by the value of the "user_id" session key which Smart Report Engine will expect to find in the logged-in user's PHP session. Please note that usually, on logging in, any session-based login system stores some reference identifying the user (often the user's ID) in their PHP session.
# This method is exclusive to the commercial edition and is not supported in the community edition .

# Note

This function can only be used with private reports

# Parameters

Parameter Description
$tableThe table contains the filter by column.
$columnThe filter-by column (The column by which you want to filter the report ). Typically, in this case, this column would contain the IDs of the users as a primary or a foreign key. Please note that Smart Report Engine will filter this column by the "$session_key" value to display only the records related to the logged-in user.
$session_keyA PHP session key in your project is used to identify the logged-in user, and, you want Smart Report Engine to use its value for filtering the $column to display only the records related to the logged-in user. Please note that, for this to work as expected, the value of this session key for any user (typically their user_iD) should be consistent with their value stored in the filter_by $column.
$column_data_typeThe data type of the filter_by $column. It can be SRE_NUMBER or SRE_TEXT. If omitted, SRE_NUMBER will be used.

# Returns

This method returns the calling object, so it can be chained with other methods in the ‘ReportOptions’ class

# Code Example

 
           use SRE\Engine\CustomEngine;
use SRE\Engine\ReportOptions;
require_once "sre_bootstrap.php"; 
$report = new ReportOptions(SRE_PRIVATE_REPORT);
$report->select_tables(array("orders"))
        ->security_init()
        ->security_check_session_saved_user_key("user_id")
        ->filter_is_current_active_user("orders", "employee_id", "user_id")
        ->select_all_fields();

$engine = new CustomEngine($report);
$report_path = $engine->create_report();
if ($report_path) {
    echo "Report created successfully! Your report URL: $report_path  ";
}