Merge branch '30-auto-validate-estimate' into 'develop'
Resolve "Auto Validate Estimate" See merge request ldc-web/projets/support-web!30
This commit is contained in:
commit
d6d3bba81c
5 changed files with 41 additions and 4 deletions
|
|
@ -91,7 +91,6 @@ class EstimationController extends Controller
|
|||
$ticket->id,
|
||||
$estimation->status->label
|
||||
);
|
||||
event(new TicketStatusChanged($ticket, $ticket->status, $user));
|
||||
event(new NotifySubscriptions($ticket, $message));
|
||||
event(new NotifyAdmin($ticket, $message));
|
||||
return response()->redirectToRoute('ticket.show', $ticket)
|
||||
|
|
@ -99,4 +98,19 @@ class EstimationController extends Controller
|
|||
}
|
||||
return \back();
|
||||
}
|
||||
|
||||
public function estimateCancelSubmit(Ticket $ticket)
|
||||
{
|
||||
$this->authorize('cancelEstimate', $ticket);
|
||||
|
||||
/** @var \App\Models\Credit\Estimation */
|
||||
$estimation = $ticket->estimation;
|
||||
$ticket->status = TicketStatus::estimateTodo();
|
||||
|
||||
if ($estimation->deleteOrFail() and $ticket->saveOrFail()) {
|
||||
return response()->redirectToRoute('ticket.show', $ticket)
|
||||
->with('info', trans('L\'estimation a été supprimée.'));
|
||||
}
|
||||
return \back();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class AnswerEstimateRequest extends FormRequest
|
|||
}
|
||||
/** @var \App\Models\User */
|
||||
$user = auth()->user();
|
||||
return !$user->isAdmin() and $user->can('validateEstimate', $this->ticket);
|
||||
return $user->can('validateEstimate', $this->ticket);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -67,11 +67,18 @@ class TicketPolicy extends RootPolicy
|
|||
TicketStaticRules::make('ticketIsNotArchived', $model)
|
||||
]),
|
||||
'validateEstimate' => StaticRules::and([
|
||||
URR::make('userIsClient', $user),
|
||||
StaticRules::or([
|
||||
URR::make('userIsClient', $user),
|
||||
URR::make('userIsDev', $user),
|
||||
]),
|
||||
TicketStaticRules::make('ticketsBrandHasAnAccount', $model),
|
||||
TicketStaticRules::make('ticketDoesHaveEstimation', $model),
|
||||
TicketStaticRules::make('ticketIsNotInternal', $model),
|
||||
TicketStaticRules::make('ticketIsNotArchived', $model)
|
||||
]),
|
||||
'cancelEstimate' => StaticRules::and([
|
||||
URR::make('userIsDev', $user),
|
||||
TicketStaticRules::make('ticketDoesHaveEstimation', $model),
|
||||
])
|
||||
]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -29,13 +29,26 @@
|
|||
<form class="mx-1" action="{{ route('ticket.estimation.estimatePendingSubmit', $ticket) }}" method="POST">
|
||||
@csrf
|
||||
<input type="hidden" name="status" value="accept">
|
||||
<button type="submit" class="btn btn-primary">{{ __('J\'accepte') }}</button>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
@if (auth()->user()->role->equals(App\Enums\Role::developper()))
|
||||
{{ __('Débiter') }}
|
||||
@else
|
||||
{{ __('J\'accepte') }}
|
||||
@endif
|
||||
</button>
|
||||
</form>
|
||||
@if (auth()->user()->role->equals(App\Enums\Role::developper()))
|
||||
<form class="mx-1" action="{{ route('ticket.estimation.estimateCancelSubmit', $ticket) }}" method="POST">
|
||||
@csrf
|
||||
<button type="submit" class="btn btn-warning">{{ __('Annuler') }}</button>
|
||||
</form>
|
||||
@else
|
||||
<form class="mx-1" action="{{ route('ticket.estimation.estimatePendingSubmit', $ticket) }}" method="POST">
|
||||
@csrf
|
||||
<input type="hidden" name="status" value="refuse">
|
||||
<button type="submit" class="btn btn-warning">{{ __('Je refuse') }}</button>
|
||||
</form>
|
||||
@endif
|
||||
</div>
|
||||
@endcan
|
||||
@endcan
|
||||
|
|
|
|||
|
|
@ -163,6 +163,9 @@ Route::middleware('auth:web')->group(function () {
|
|||
Route::post('/{ticket}/estimate/answer', [EstimationController::class, 'estimatePendingSubmit'])
|
||||
->middleware('can:validateEstimate,ticket')
|
||||
->name('estimatePendingSubmit');
|
||||
Route::post('/{ticket}/estimate/cancel', [EstimationController::class, 'estimateCancelSubmit'])
|
||||
->middleware('can:cancelEstimate,ticket')
|
||||
->name('estimateCancelSubmit');
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue