feat: add granular template permissions for role-based template access
- add new permissions: template.opd_print, template.pathology_print, template.diagnosis_print, template.document_print, template.ipd_document - Template controller now accepts new permission keys (with backward-compatible fallbacks) - IPD Document Master now has independent permission key (template.ipd_document) - Template index tile visibility updated to use new granular keys - OPD print template builder now honors template.opd_print permission - preserve existing behavior via legacy permission fallbacks to avoid role breakage
This commit is contained in:
parent
3294e39b02
commit
874d5ffba6
|
|
@ -124,6 +124,11 @@ class AuthGroups extends ShieldAuthGroups
|
|||
'template.mri' => 'Can access MRI templates',
|
||||
'template.echo' => 'Can access ECHO templates',
|
||||
'template.discharge' => 'Can access IPD discharge templates',
|
||||
'template.opd_print' => 'Can access OPD print templates',
|
||||
'template.pathology_print' => 'Can access pathology print templates',
|
||||
'template.diagnosis_print' => 'Can access diagnosis print templates',
|
||||
'template.document_print' => 'Can access document print templates',
|
||||
'template.ipd_document' => 'Can access IPD document master templates',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class Opd extends BaseController
|
|||
return false;
|
||||
}
|
||||
|
||||
if (method_exists($user, 'can') && $user->can('billing.opd.edit')) {
|
||||
if (method_exists($user, 'can') && ($user->can('template.opd_print') || $user->can('billing.opd.edit'))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,11 @@ class Template extends BaseController
|
|||
'template.mri',
|
||||
'template.echo',
|
||||
'template.discharge',
|
||||
'template.opd_print',
|
||||
'template.pathology_print',
|
||||
'template.diagnosis_print',
|
||||
'template.document_print',
|
||||
'template.ipd_document',
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
|
|
@ -715,7 +720,11 @@ HTML;
|
|||
|
||||
public function diagnosis_print_settings(int $modality = 3)
|
||||
{
|
||||
if ($resp = $this->requireAnyPermission(['template.pathology', 'template.ultrasound', 'template.xray', 'template.ct', 'template.mri', 'template.echo'])) {
|
||||
if ($resp = $this->requireAnyPermission([
|
||||
'template.diagnosis_print',
|
||||
'template.pathology_print',
|
||||
'template.pathology', 'template.ultrasound', 'template.xray', 'template.ct', 'template.mri', 'template.echo',
|
||||
])) {
|
||||
return $resp;
|
||||
}
|
||||
|
||||
|
|
@ -978,7 +987,10 @@ HTML;
|
|||
|
||||
public function document_print_settings()
|
||||
{
|
||||
if ($resp = $this->requireAnyPermission(['doctor_work.template_workspace.access', 'doctor_work.access', 'template.pathology'])) {
|
||||
if ($resp = $this->requireAnyPermission([
|
||||
'template.document_print',
|
||||
'doctor_work.template_workspace.access', 'doctor_work.access', 'template.pathology',
|
||||
])) {
|
||||
return $resp;
|
||||
}
|
||||
|
||||
|
|
@ -1608,7 +1620,7 @@ HTML,
|
|||
|
||||
public function ipd_document_templates()
|
||||
{
|
||||
if ($resp = $this->requireAnyPermission(['template.discharge'])) {
|
||||
if ($resp = $this->requireAnyPermission(['template.ipd_document', 'template.discharge'])) {
|
||||
return $resp;
|
||||
}
|
||||
|
||||
|
|
@ -1674,7 +1686,7 @@ HTML,
|
|||
|
||||
public function ipd_document_template_delete(int $id)
|
||||
{
|
||||
if ($resp = $this->requireAnyPermission(['template.discharge'])) {
|
||||
if ($resp = $this->requireAnyPermission(['template.ipd_document', 'template.discharge'])) {
|
||||
return $resp;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,17 +7,27 @@ $canCt = $user && method_exists($user, 'can') ? $user->can('template.ct') : fals
|
|||
$canMri = $user && method_exists($user, 'can') ? $user->can('template.mri') : false;
|
||||
$canEcho = $user && method_exists($user, 'can') ? $user->can('template.echo') : false;
|
||||
$canDischarge = $user && method_exists($user, 'can') ? $user->can('template.discharge') : false;
|
||||
$canOpdPrintTemplate = $user && method_exists($user, 'can') ? $user->can('billing.opd.edit') : false;
|
||||
$canDiagnosisPrintTemplate = $canPathology || $canUltrasound || $canXray || $canCt || $canMri || $canEcho;
|
||||
$canDoctorDocumentPrintTemplate = $user && method_exists($user, 'can')
|
||||
? ($user->can('doctor_work.template_workspace.access') || $user->can('doctor_work.access') || $user->can('template.pathology'))
|
||||
$canOpdPrintTemplate = $user && method_exists($user, 'can')
|
||||
? ($user->can('template.opd_print') || $user->can('billing.opd.edit'))
|
||||
: false;
|
||||
$canPathologyPrintTemplate = $user && method_exists($user, 'can')
|
||||
? ($user->can('template.pathology_print') || $user->can('template.pathology'))
|
||||
: false;
|
||||
$canDiagnosisPrintTemplate = $user && method_exists($user, 'can')
|
||||
? ($user->can('template.diagnosis_print') || $canPathology || $canUltrasound || $canXray || $canCt || $canMri || $canEcho)
|
||||
: ($canPathology || $canUltrasound || $canXray || $canCt || $canMri || $canEcho);
|
||||
$canDoctorDocumentPrintTemplate = $user && method_exists($user, 'can')
|
||||
? ($user->can('template.document_print') || $user->can('doctor_work.template_workspace.access') || $user->can('doctor_work.access') || $user->can('template.pathology'))
|
||||
: false;
|
||||
$canIpdDocumentMaster = $user && method_exists($user, 'can')
|
||||
? ($user->can('template.ipd_document') || $user->can('template.discharge'))
|
||||
: $canDischarge;
|
||||
|
||||
if (! $canOpdPrintTemplate && $user && method_exists($user, 'inGroup')) {
|
||||
$canOpdPrintTemplate = $user->inGroup('OPDEdit', 'admin', 'superadmin', 'developer');
|
||||
}
|
||||
|
||||
$hasTemplateAccess = $canPathology || $canUltrasound || $canXray || $canCt || $canMri || $canEcho || $canDischarge || $canDoctorDocumentPrintTemplate;
|
||||
$hasTemplateAccess = $canPathology || $canUltrasound || $canXray || $canCt || $canMri || $canEcho || $canDischarge || $canOpdPrintTemplate || $canPathologyPrintTemplate || $canDiagnosisPrintTemplate || $canDoctorDocumentPrintTemplate || $canIpdDocumentMaster;
|
||||
?>
|
||||
<section class="content">
|
||||
<div class="pagetitle">
|
||||
|
|
@ -206,6 +216,9 @@ $hasTemplateAccess = $canPathology || $canUltrasound || $canXray || $canCt || $c
|
|||
<span>IPD Discharge Template</span>
|
||||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($canIpdDocumentMaster) { ?>
|
||||
<div class="col-6 col-md-2 col-lg-2">
|
||||
<a class="admin-tile" href="javascript:load_form_div('<?= base_url('setting/template/ipd_document_templates') ?>','maindiv','IPD Document Master');">
|
||||
<span class="tile-icon"><i class="bi bi-file-earmark-richtext"></i></span>
|
||||
|
|
@ -215,7 +228,7 @@ $hasTemplateAccess = $canPathology || $canUltrasound || $canXray || $canCt || $c
|
|||
<?php } ?>
|
||||
|
||||
<?php if ($canDiagnosisPrintTemplate) { ?>
|
||||
<?php if ($canPathology) { ?>
|
||||
<?php if ($canPathologyPrintTemplate) { ?>
|
||||
<div class="col-6 col-md-2 col-lg-2">
|
||||
<a class="admin-tile" href="javascript:load_form_div('<?= base_url('setting/template/diagnosis_print_settings/5') ?>','maindiv','Pathology Print Template');">
|
||||
<span class="tile-icon"><i class="bi bi-printer"></i></span>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user