close #2061 Enhancement: Added permission check invoice/bill transaction delete buton
This commit is contained in:
parent
40bd54fe1c
commit
6a0de2c672
@ -104,6 +104,9 @@ abstract class DocumentShow extends Base
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
public $permissionDelete;
|
public $permissionDelete;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
public $permissionTransactionDelete;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
public $permissionButtonCustomize;
|
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 $routeButtonAddNew = '', string $routeButtonEdit = '', string $routeButtonDuplicate = '', string $routeButtonPrint = '', string $routeButtonPdf = '', string $routeButtonCancelled = '', string $routeButtonDelete = '', string $routeButtonCustomize = '', string $routeButtonSent = '',
|
||||||
string $routeButtonReceived = '', string $routeButtonEmail = '', string $routeButtonPaid = '',
|
string $routeButtonReceived = '', string $routeButtonEmail = '', string $routeButtonPaid = '',
|
||||||
bool $checkButtonReconciled = true, bool $checkButtonCancelled = true,
|
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 $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 $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,
|
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->permissionCreate = $this->getPermissionCreate($type, $permissionCreate);
|
||||||
$this->permissionUpdate = $this->getPermissionUpdate($type, $permissionUpdate);
|
$this->permissionUpdate = $this->getPermissionUpdate($type, $permissionUpdate);
|
||||||
$this->permissionDelete = $this->getPermissionDelete($type, $permissionDelete);
|
$this->permissionDelete = $this->getPermissionDelete($type, $permissionDelete);
|
||||||
|
$this->permissionTransactionDelete = $this->getPermissionTransactionDelete($type, $permissionTransactionDelete);
|
||||||
$this->permissionButtonCustomize = $this->getPermissionButtonCustomize($type, $permissionButtonCustomize);
|
$this->permissionButtonCustomize = $this->getPermissionButtonCustomize($type, $permissionButtonCustomize);
|
||||||
|
|
||||||
$this->hideButtonGroupDivider1 = $hideButtonGroupDivider1;
|
$this->hideButtonGroupDivider1 = $hideButtonGroupDivider1;
|
||||||
@ -958,6 +962,17 @@ abstract class DocumentShow extends Base
|
|||||||
return $permissionDelete;
|
return $permissionDelete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getPermissionTransactionDelete($type, $permissionTransactionDelete)
|
||||||
|
{
|
||||||
|
if (!empty($permissionTransactionDelete)) {
|
||||||
|
return $permissionTransactionDelete;
|
||||||
|
}
|
||||||
|
|
||||||
|
$permissionTransactionDelete = 'delete-banking-transactions';
|
||||||
|
|
||||||
|
return $permissionTransactionDelete;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getPermissionButtonCustomize($type, $permissionButtonCustomize)
|
protected function getPermissionButtonCustomize($type, $permissionButtonCustomize)
|
||||||
{
|
{
|
||||||
if (!empty($permissionButtonCustomize)) {
|
if (!empty($permissionButtonCustomize)) {
|
||||||
|
@ -9,71 +9,87 @@
|
|||||||
<table class="table table-flush table-hover">
|
<table class="table table-flush table-hover">
|
||||||
<thead class="thead-light">
|
<thead class="thead-light">
|
||||||
@stack('row_footer_transactions_head_tr_start')
|
@stack('row_footer_transactions_head_tr_start')
|
||||||
<tr class="row table-head-line">
|
<tr class="row table-head-line">
|
||||||
@stack('row_footer_transactions_head_td_start')
|
@stack('row_footer_transactions_head_td_start')
|
||||||
<th class="col-xs-4 col-sm-3">
|
@php $class = 'col-sm-3'; @endphp
|
||||||
{{ trans('general.date') }}
|
@cannot($permissionTransactionDelete)
|
||||||
</th>
|
@php $class = 'col-sm-4'; @endphp
|
||||||
<th class="col-xs-4 col-sm-3">
|
@endcan
|
||||||
{{ trans('general.amount') }}
|
|
||||||
</th>
|
<th class="col-xs-4 {{ $class }}">
|
||||||
<th class="col-sm-3 d-none d-sm-block">
|
{{ trans('general.date') }}
|
||||||
{{ trans_choice('general.accounts', 1) }}
|
</th>
|
||||||
</th>
|
|
||||||
<th class="col-xs-4 col-sm-3">
|
<th class="col-xs-4 {{ $class }}">
|
||||||
{{ trans('general.actions') }}
|
{{ trans('general.amount') }}
|
||||||
</th>
|
</th>
|
||||||
@stack('row_footer_transactions_head_td_end')
|
|
||||||
</tr>
|
<th class="{{ $class }} d-none d-sm-block">
|
||||||
|
{{ trans_choice('general.accounts', 1) }}
|
||||||
|
</th>
|
||||||
|
|
||||||
|
@can($permissionTransactionDelete)
|
||||||
|
<th class="col-xs-4 col-sm-3">
|
||||||
|
{{ trans('general.actions') }}
|
||||||
|
</th>
|
||||||
|
@endcan
|
||||||
|
@stack('row_footer_transactions_head_td_end')
|
||||||
|
</tr>
|
||||||
@stack('row_footer_transactions_head_tr_end')
|
@stack('row_footer_transactions_head_tr_end')
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
@stack('row_footer_transactions_body_tr_start')
|
@stack('row_footer_transactions_body_tr_start')
|
||||||
@if ($transactions->count())
|
@if ($transactions->count())
|
||||||
@foreach($transactions as $transaction)
|
@foreach($transactions as $transaction)
|
||||||
<tr class="row align-items-center border-top-1 tr-py">
|
<tr class="row align-items-center border-top-1 tr-py">
|
||||||
@stack('row_footer_transactions_body_td_start')
|
@stack('row_footer_transactions_body_td_start')
|
||||||
<td class="col-xs-4 col-sm-3">
|
<td class="col-xs-4 {{ $class }}">
|
||||||
@date($transaction->paid_at)
|
@date($transaction->paid_at)
|
||||||
</td>
|
</td>
|
||||||
<td class="col-xs-4 col-sm-3">
|
|
||||||
@money($transaction->amount, $transaction->currency_code, true)
|
|
||||||
</td>
|
|
||||||
<td class="col-sm-3 d-none d-sm-block">
|
|
||||||
{{ $transaction->account->name }}
|
|
||||||
</td>
|
|
||||||
<td class="col-xs-4 col-sm-3 py-0">
|
|
||||||
@if ($transaction->reconciled)
|
|
||||||
<button type="button" class="btn btn-default btn-sm">
|
|
||||||
{{ trans('reconciliations.reconciled') }}
|
|
||||||
</button>
|
|
||||||
@else
|
|
||||||
@php $message = trans('general.delete_confirm', [
|
|
||||||
'name' => '<strong>' . Date::parse($transaction->paid_at)->format($date_format) . ' - ' . money($transaction->amount, $transaction->currency_code, true) . ' - ' . $transaction->account->name . '</strong>',
|
|
||||||
'type' => strtolower(trans_choice('general.transactions', 1))
|
|
||||||
]);
|
|
||||||
@endphp
|
|
||||||
|
|
||||||
{!! Form::button(trans('general.delete'), array(
|
<td class="col-xs-4 {{ $class }}">
|
||||||
'type' => 'button',
|
@money($transaction->amount, $transaction->currency_code, true)
|
||||||
'class' => 'btn btn-danger btn-sm',
|
</td>
|
||||||
'title' => trans('general.delete'),
|
|
||||||
'@click' => 'confirmDelete("' . route('transactions.destroy', $transaction->id) . '", "' . trans_choice('general.transactions', 2) . '", "' . $message. '", "' . trans('general.cancel') . '", "' . trans('general.delete') . '")'
|
<td class="{{ $class }} d-none d-sm-block">
|
||||||
)) !!}
|
{{ $transaction->account->name }}
|
||||||
@endif
|
</td>
|
||||||
|
|
||||||
|
@can($permissionTransactionDelete)
|
||||||
|
<td class="col-xs-4 col-sm-3 py-0">
|
||||||
|
@if ($transaction->reconciled)
|
||||||
|
<button type="button" class="btn btn-default btn-sm">
|
||||||
|
{{ trans('reconciliations.reconciled') }}
|
||||||
|
</button>
|
||||||
|
@else
|
||||||
|
@php $message = trans('general.delete_confirm', [
|
||||||
|
'name' => '<strong>' . Date::parse($transaction->paid_at)->format($date_format) . ' - ' . money($transaction->amount, $transaction->currency_code, true) . ' - ' . $transaction->account->name . '</strong>',
|
||||||
|
'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
|
||||||
|
</td>
|
||||||
|
@endcan
|
||||||
|
@stack('row_footer_transactions_body_td_end')
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
@else
|
||||||
|
<tr>
|
||||||
|
<td colspan="4">
|
||||||
|
<div class="text-muted nr-py" id="datatable-basic_info" role="status" aria-live="polite">
|
||||||
|
{{ trans('general.no_records') }}
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@stack('row_footer_transactions_body_td_end')
|
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endif
|
||||||
@else
|
|
||||||
<tr>
|
|
||||||
<td colspan="4">
|
|
||||||
<div class="text-muted nr-py" id="datatable-basic_info" role="status" aria-live="polite">
|
|
||||||
{{ trans('general.no_records') }}
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
@endif
|
|
||||||
@stack('row_footer_transactions_body_tr_end')
|
@stack('row_footer_transactions_body_tr_end')
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user