Fixed: KPI access is now under employee permission in back-office

Co-authored-by: Name <sumit201@webkul.in>
This commit is contained in:
shazar rahman
2026-06-12 17:50:59 +05:30
parent a27e55c049
commit 653fdf3f7f
203 changed files with 9719 additions and 1593 deletions

View File

@@ -81,7 +81,7 @@ class ProfileCore extends ObjectModel
public function add($autodate = true, $null_values = false)
{
if (parent::add($autodate, true)) {
$result = Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'access (SELECT '.(int)$this->id.', id_tab, 0, 0, 0, 0 FROM '._DB_PREFIX_.'tab)');
$result = Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'access (SELECT '.(int)$this->id.', id_tab, 0, 0, 0, 0, 0 FROM '._DB_PREFIX_.'tab)');
$result &= Db::getInstance()->execute('
INSERT INTO '._DB_PREFIX_.'module_access
(`id_profile`, `id_module`, `configure`, `view`, `uninstall`)
@@ -138,14 +138,23 @@ class ProfileCore extends ObjectModel
'add' => 1,
'edit' => 1,
'delete' => 1,
'kpi' => 1,
);
}
} else {
$result = Db::getInstance()->executeS('
SELECT *
FROM `'._DB_PREFIX_.'access` a
LEFT JOIN `'._DB_PREFIX_.'tab` t ON t.id_tab = a.id_tab
WHERE `id_profile` = '.(int)$id_profile);
if ($result = Db::getInstance()->executeS('
SELECT * FROM `'._DB_PREFIX_.'access` a
LEFT JOIN `'._DB_PREFIX_.'tab` t ON t.id_tab = a.id_tab
WHERE `id_profile` = '.(int)$id_profile)
) {
foreach ($result as $key => $profileAccess) {
$result[$key]['view'] = (int) $profileAccess['view'];
$result[$key]['delete'] = (int) $profileAccess['delete'];
$result[$key]['add'] = (int) $profileAccess['add'];
$result[$key]['edit'] = (int) $profileAccess['edit'];
$result[$key]['kpi'] = (int) $profileAccess['kpi'];
}
}
foreach ($result as $row) {
self::$_cache_accesses[$id_profile][$type][$row[$type]] = $row;