diff --git a/app/Abstracts/View/Components/DocumentShow.php b/app/Abstracts/View/Components/DocumentShow.php index a0c2b0996..ce4d123e9 100644 --- a/app/Abstracts/View/Components/DocumentShow.php +++ b/app/Abstracts/View/Components/DocumentShow.php @@ -104,6 +104,9 @@ abstract class DocumentShow extends Base /** @var string */ public $permissionDelete; + /** @var string */ + public $permissionTransactionDelete; + /** @var string */ public $permissionButtonCustomize; @@ -366,7 +369,7 @@ abstract class DocumentShow extends Base string $routeButtonAddNew = '', string $routeButtonEdit = '', string $routeButtonDuplicate = '', string $routeButtonPrint = '', string $routeButtonPdf = '', string $routeButtonCancelled = '', string $routeButtonDelete = '', string $routeButtonCustomize = '', string $routeButtonSent = '', string $routeButtonReceived = '', string $routeButtonEmail = '', string $routeButtonPaid = '', bool $checkButtonReconciled = true, bool $checkButtonCancelled = true, - string $permissionCreate = '', string $permissionUpdate = '', string $permissionDelete = '', string $permissionButtonCustomize = '', + string $permissionCreate = '', string $permissionUpdate = '', string $permissionDelete = '', string $permissionTransactionDelete = '', string $permissionButtonCustomize = '', bool $hideButtonGroupDivider1 = false, bool $hideButtonGroupDivider2 = false, bool $hideButtonGroupDivider3 = false, bool $hideButtonMoreActions = false, bool $hideButtonAddNew = false, bool $hideButtonEdit = false, bool $hideButtonDuplicate = false, bool $hideButtonPrint = false, bool $hideButtonPdf = false, bool $hideButtonCancel = false, bool $hideButtonCustomize = false, bool $hideButtonDelete = false, bool $hideHeader = false,bool $hideRecurringMessage = false, bool $hideStatusMessage = false, bool $hideTimeline = false, bool $hideFooter = false, bool $hideFooterHistories = false, bool $hideFooterTransactions = false, @@ -418,6 +421,7 @@ abstract class DocumentShow extends Base $this->permissionCreate = $this->getPermissionCreate($type, $permissionCreate); $this->permissionUpdate = $this->getPermissionUpdate($type, $permissionUpdate); $this->permissionDelete = $this->getPermissionDelete($type, $permissionDelete); + $this->permissionTransactionDelete = $this->getPermissionTransactionDelete($type, $permissionTransactionDelete); $this->permissionButtonCustomize = $this->getPermissionButtonCustomize($type, $permissionButtonCustomize); $this->hideButtonGroupDivider1 = $hideButtonGroupDivider1; @@ -958,6 +962,17 @@ abstract class DocumentShow extends Base return $permissionDelete; } + protected function getPermissionTransactionDelete($type, $permissionTransactionDelete) + { + if (!empty($permissionTransactionDelete)) { + return $permissionTransactionDelete; + } + + $permissionTransactionDelete = 'delete-banking-transactions'; + + return $permissionTransactionDelete; + } + protected function getPermissionButtonCustomize($type, $permissionButtonCustomize) { if (!empty($permissionButtonCustomize)) { diff --git a/resources/views/components/documents/show/transactions.blade.php b/resources/views/components/documents/show/transactions.blade.php index 136e3e3aa..e4ea0d909 100644 --- a/resources/views/components/documents/show/transactions.blade.php +++ b/resources/views/components/documents/show/transactions.blade.php @@ -9,71 +9,87 @@
- {{ trans('general.date') }} - | -- {{ trans('general.amount') }} - | -- {{ trans_choice('general.accounts', 1) }} - | -- {{ trans('general.actions') }} - | - @stack('row_footer_transactions_head_td_end') -
---|---|---|---|
+ {{ trans('general.date') }} + | + ++ {{ trans('general.amount') }} + | + ++ {{ trans_choice('general.accounts', 1) }} + | + + @can($permissionTransactionDelete) ++ {{ trans('general.actions') }} + | + @endcan + @stack('row_footer_transactions_head_td_end') +
- @date($transaction->paid_at) - | -- @money($transaction->amount, $transaction->currency_code, true) - | -- {{ $transaction->account->name }} - | -- @if ($transaction->reconciled) - - @else - @php $message = trans('general.delete_confirm', [ - 'name' => '' . Date::parse($transaction->paid_at)->format($date_format) . ' - ' . money($transaction->amount, $transaction->currency_code, true) . ' - ' . $transaction->account->name . '', - 'type' => strtolower(trans_choice('general.transactions', 1)) - ]); - @endphp + @if ($transactions->count()) + @foreach($transactions as $transaction) + |
+ @date($transaction->paid_at) + | - {!! Form::button(trans('general.delete'), array( - 'type' => 'button', - 'class' => 'btn btn-danger btn-sm', - 'title' => trans('general.delete'), - '@click' => 'confirmDelete("' . route('transactions.destroy', $transaction->id) . '", "' . trans_choice('general.transactions', 2) . '", "' . $message. '", "' . trans('general.cancel') . '", "' . trans('general.delete') . '")' - )) !!} - @endif ++ @money($transaction->amount, $transaction->currency_code, true) + | + ++ {{ $transaction->account->name }} + | + + @can($permissionTransactionDelete) ++ @if ($transaction->reconciled) + + @else + @php $message = trans('general.delete_confirm', [ + 'name' => '' . Date::parse($transaction->paid_at)->format($date_format) . ' - ' . money($transaction->amount, $transaction->currency_code, true) . ' - ' . $transaction->account->name . '', + 'type' => strtolower(trans_choice('general.transactions', 1)) + ]); + @endphp + + {!! Form::button(trans('general.delete'), array( + 'type' => 'button', + 'class' => 'btn btn-danger btn-sm', + 'title' => trans('general.delete'), + '@click' => 'confirmDelete("' . route('transactions.destroy', $transaction->id) . '", "' . trans_choice('general.transactions', 2) . '", "' . $message. '", "' . trans('general.cancel') . '", "' . trans('general.delete') . '")' + )) !!} + @endif + | + @endcan + @stack('row_footer_transactions_body_td_end') +
+
+ {{ trans('general.no_records') }}
+
|
- @stack('row_footer_transactions_body_td_end')
|||
-
- {{ trans('general.no_records') }}
-
- |
-