diff --git a/app/Abstracts/View/Components/Document.php b/app/Abstracts/View/Components/Document.php index ac4aaa739..f0528be48 100644 --- a/app/Abstracts/View/Components/Document.php +++ b/app/Abstracts/View/Components/Document.php @@ -62,10 +62,10 @@ abstract class Document extends Component return $route; } - $prefix = config("type.' . $type . '.route.prefix"); + $prefix = config("type.' . $type . '.route.prefix"); } - public function getPermissionFromConfig($type, $config_key, $action) + public function getPermissionFromConfig($type, $config_key) { $permission = ''; @@ -78,7 +78,7 @@ abstract class Document extends Component $group = config('type.' . $type . '.group'); $prefix = config("type.' . $type . '.permission.prefix"); - $permission = $action . '-'; + $permission = $config_key . '-'; // if use module set module alias if (!empty($alias)) { diff --git a/app/Abstracts/View/Components/DocumentIndex.php b/app/Abstracts/View/Components/DocumentIndex.php index 38b4be305..01cef1431 100644 --- a/app/Abstracts/View/Components/DocumentIndex.php +++ b/app/Abstracts/View/Components/DocumentIndex.php @@ -794,18 +794,7 @@ abstract class DocumentIndex extends Base return $permissionCreate; } - switch ($type) { - case 'sale': - case 'income': - case 'invoice': - $permissionCreate = 'create-sales-invoices'; - break; - case 'bill': - case 'expense': - case 'purchase': - $permissionCreate = 'create-purchases-bills'; - break; - } + $permissionCreate = $this->getPermissionFromConfig($type, 'create'); return $permissionCreate; } @@ -816,18 +805,7 @@ abstract class DocumentIndex extends Base return $permissionUpdate; } - switch ($type) { - case 'sale': - case 'income': - case 'invoice': - $permissionUpdate = 'update-sales-invoices'; - break; - case 'bill': - case 'expense': - case 'purchase': - $permissionUpdate = 'update-purchases-bills'; - break; - } + $permissionUpdate = $this->getPermissionFromConfig($type, 'update'); return $permissionUpdate; } @@ -838,18 +816,7 @@ abstract class DocumentIndex extends Base return $permissionDelete; } - switch ($type) { - case 'sale': - case 'income': - case 'invoice': - $permissionDelete = 'delete-sales-invoices'; - break; - case 'bill': - case 'expense': - case 'purchase': - $permissionDelete = 'delete-purchases-bills'; - break; - } + $permissionDelete = $this->getPermissionFromConfig($type, 'delete'); return $permissionDelete; } diff --git a/app/Abstracts/View/Components/DocumentShow.php b/app/Abstracts/View/Components/DocumentShow.php index 4c0e582ef..3181c9552 100644 --- a/app/Abstracts/View/Components/DocumentShow.php +++ b/app/Abstracts/View/Components/DocumentShow.php @@ -470,8 +470,6 @@ abstract class DocumentShow extends Base $this->textTimelineGetPaidMarkPaid = $this->getTextTimelineGetPaidMarkPaid($type, $textTimelineGetPaidMarkPaid); $this->textTimelineGetPaidAddPayment = $this->getTextTimelineGetPaidAddPayment($type, $textTimelineGetPaidAddPayment); - $this->permissionUpdate = $this->getPermissionUpdate($type, $permissionUpdate); - $this->routeButtonSent = $this->getRouteButtonSent($type, $routeButtonSent); $this->routeButtonReceived = $this->getRouteButtonReceived($type, $routeButtonReceived); $this->routeButtonEmail = $this->getRouteButtonEmail($type, $routeButtonEmail); @@ -918,18 +916,7 @@ abstract class DocumentShow extends Base return $permissionCreate; } - switch ($type) { - case 'sale': - case 'income': - case 'invoice': - $permissionCreate = 'create-sales-invoices'; - break; - case 'bill': - case 'expense': - case 'purchase': - $permissionCreate = 'create-purchases-bills'; - break; - } + $permissionCreate = $this->getPermissionFromConfig($type, 'create'); return $permissionCreate; } @@ -940,18 +927,7 @@ abstract class DocumentShow extends Base return $permissionUpdate; } - switch ($type) { - case 'sale': - case 'income': - case 'invoice': - $permissionUpdate = 'update-sales-invoices'; - break; - case 'bill': - case 'expense': - case 'purchase': - $permissionUpdate = 'update-purchases-bills'; - break; - } + $permissionUpdate = $this->getPermissionFromConfig($type, 'update'); return $permissionUpdate; } @@ -962,18 +938,7 @@ abstract class DocumentShow extends Base return $permissionDelete; } - switch ($type) { - case 'sale': - case 'income': - case 'invoice': - $permissionDelete = 'delete-sales-invoices'; - break; - case 'bill': - case 'expense': - case 'purchase': - $permissionDelete = 'delete-purchases-bills'; - break; - } + $permissionDelete = $this->getPermissionFromConfig($type, 'delete'); return $permissionDelete; } @@ -984,20 +949,9 @@ abstract class DocumentShow extends Base return $permissionButtonCustomize; } - switch ($type) { - case 'sale': - case 'income': - case 'invoice': - $permissionButtonCustomize = 'update-sales-invoices'; - break; - case 'bill': - case 'expense': - case 'purchase': - $permissionButtonCustomize = 'update-purchases-bills'; - break; - } + $permissionUpdate = $this->getPermissionFromConfig($type, 'update'); - return $permissionButtonCustomize; + return $permissionUpdate; } protected function getTextHeaderContact($type, $textHeaderContact)