Add Asset Management app
Assets from purchase invoice lines, straight-line depreciation/amortization with salvage value, disposals, and [Asset Mgmt] sources in Batch GL Entries. Green third workspace with an app access guard.
This commit is contained in:
@@ -2,21 +2,51 @@
|
||||
// app/assets/utils/app_registry.php
|
||||
//
|
||||
// The apps a user can be given access to (user.app_access and
|
||||
// company_map_user.app_access), with the label, icon and badge colour the
|
||||
// Users Access page shows for each.
|
||||
// company_map_user.app_access), with the label, icon, badge colour and home
|
||||
// page of each. Used by the app switcher, the login redirect and the Users
|
||||
// Access page.
|
||||
//
|
||||
// config.php may define its own $app_registry; this file only fills it in when
|
||||
// it is missing or empty — which is every Docker-generated config.php written
|
||||
// before the setting was documented. Without it the Add User dialog breaks
|
||||
// config.php may define its own $app_registry. Configs written before Asset
|
||||
// Management existed (every Docker-generated config.php among them) list fewer
|
||||
// apps and have no 'home', so missing apps and keys are filled in from the
|
||||
// defaults below. Without a registry the Add User dialog breaks
|
||||
// (Object.entries(null) in setting/users.php) and inviting a user fails
|
||||
// (array_keys(null) in setting/api/engine/manage_users.php).
|
||||
//
|
||||
// Keys must stay within the user.app_access enum: 'wms' and 'accounting'
|
||||
// Keys must stay within the user.app_access enum: 'wms', 'accounting', 'asset'
|
||||
// ('all' is implied and never listed here).
|
||||
|
||||
$_default_app_registry = [
|
||||
'wms' => ['label' => 'WMS', 'icon' => 'ti-box', 'color' => 'bg-label-primary', 'home' => 'dashboard/index.php'],
|
||||
'accounting' => ['label' => 'Accounting', 'icon' => 'ti-calculator', 'color' => 'bg-label-info', 'home' => 'ac_dashboard/index.php'],
|
||||
'asset' => ['label' => 'Asset Management', 'icon' => 'ti-building-warehouse', 'color' => 'bg-label-success', 'home' => 'asset_dashboard/index.php'],
|
||||
];
|
||||
|
||||
if (!isset($app_registry) || !is_array($app_registry) || !$app_registry) {
|
||||
$app_registry = [
|
||||
'wms' => ['label' => 'WMS', 'icon' => 'ti-box', 'color' => 'bg-label-primary'],
|
||||
'accounting' => ['label' => 'Accounting', 'icon' => 'ti-calculator', 'color' => 'bg-label-success'],
|
||||
];
|
||||
$app_registry = $_default_app_registry;
|
||||
} else {
|
||||
foreach ($_default_app_registry as $_registry_key => $_registry_defaults) {
|
||||
$app_registry[$_registry_key] = array_merge($_registry_defaults, $app_registry[$_registry_key] ?? []);
|
||||
}
|
||||
}
|
||||
unset($_default_app_registry, $_registry_key, $_registry_defaults);
|
||||
|
||||
if (!function_exists('app_can_access')) {
|
||||
/** 'all' opens every app. */
|
||||
function app_can_access(string $access, string $app): bool
|
||||
{
|
||||
return $access === 'all' || $access === $app;
|
||||
}
|
||||
|
||||
/** The app a user lands in: their single app, or WMS for 'all'. */
|
||||
function app_default_for_access(array $registry, string $access): string
|
||||
{
|
||||
return ($access !== 'all' && isset($registry[$access])) ? $access : 'wms';
|
||||
}
|
||||
|
||||
/** An app's home page, relative to $server_url. */
|
||||
function app_home_path(array $registry, string $app): string
|
||||
{
|
||||
return $registry[$app]['home'] ?? 'dashboard/index.php';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user