filter_is_current_active_user
filter_is_current_active_user
filter_is_current_active_user($table, $column, $session_key, $column_data_type = SRE_NUMBER)
Parameter | Description |
---|---|
$table | The table contains the filter by column. |
$column | The 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_key | A 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_type | The data type of the filter_by $column. It can be SRE_NUMBER or SRE_TEXT. If omitted, SRE_NUMBER will be used. |
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 ";
}