Files
opensourcepos/app/Helpers/report_helper.php
objecttothis 1328b4d9b8 - Removed TODOs that had been completed
- Added TODO where we need to convert to querybuilder
- Converted to switch statement.
- Removed unnecessary local variable
- Replaced Qualifiers with imports
- Replaced isset() call with null coalescing operator
- Replaced strpos function calls in if statements with str_contains calls
- Removed unnecessary leading \ in use statement
- Replaced deprecated functions
- Updated PHPdocs to match function signature
- Added missing type declarations
- Made class variables private.
- Explicitly declared dynamic properties
- use https:// links instead of http://
- Fixed type error from sending null when editing transactions
- Fixed Search Suggestion function name in Employees, Persons, Suppliers controller
- Fixed function name on Receivings Controller

Signed-off-by: objecttothis <objecttothis@gmail.com>
2024-06-15 17:19:15 +02:00

57 lines
1.0 KiB
PHP

<?php
/**
* @param string $report_name
* @param string $report_prefix
* @param string $lang_key
* @return array
*/
function get_report_link(string $report_name, string $report_prefix = '', string $lang_key = ''): array
{
$path = 'reports/';
if ($report_prefix !== '')
{
$path .= $report_prefix . '_';
}
/**
* Sanitize the report name in case it has come from the permissions table.
*/
$report_name = str_replace('reports_', '', $report_name);
$path .= $report_name;
if ($lang_key === '')
{
$lang_key = 'Reports.' . $report_name;
}
return [
'path' => site_url($path),
'label' => lang($lang_key),
];
}
/**
* @param string $permission_id
* @param string[] $restrict_views
*
* @return bool
*/
function can_show_report(string $permission_id, array $restrict_views = []): bool
{
if(!str_contains($permission_id, 'reports_'))
{
return false;
}
foreach ($restrict_views as $restrict_view)
{
if (str_contains($permission_id, $restrict_view))
{
return false;
}
}
return true;
}