mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Merge pull request #13219 from inietov/features/cancel_request_asset
Cancel requested assets without checkin/out [ch-17606]
This commit is contained in:
commit
a3096e1b47
|
@ -82,7 +82,7 @@ class ViewAssetsController extends Controller
|
|||
return view('account/requestable-assets', compact('assets', 'models'));
|
||||
}
|
||||
|
||||
public function getRequestItem(Request $request, $itemType, $itemId = null)
|
||||
public function getRequestItem(Request $request, $itemType, $itemId = null, $cancel_by_admin = false, $requestingUser = null)
|
||||
{
|
||||
$item = null;
|
||||
$fullItemType = 'App\\Models\\'.studly_case($itemType);
|
||||
|
@ -119,16 +119,16 @@ class ViewAssetsController extends Controller
|
|||
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
if ($item_request = $item->isRequestedBy($user)) {
|
||||
$item->cancelRequest();
|
||||
$data['item_quantity'] = $item_request->qty;
|
||||
if (($item_request = $item->isRequestedBy($user)) || $cancel_by_admin) {
|
||||
$item->cancelRequest($requestingUser);
|
||||
$data['item_quantity'] = ($item_request) ? $item_request->qty : 1;
|
||||
$logaction->logaction('request_canceled');
|
||||
|
||||
if (($settings->alert_email != '') && ($settings->alerts_enabled == '1') && (! config('app.lock_passwords'))) {
|
||||
$settings->notify(new RequestAssetCancelation($data));
|
||||
}
|
||||
|
||||
return redirect()->route('requestable-assets')->with('success')->with('success', trans('admin/hardware/message.requests.canceled'));
|
||||
return redirect()->back()->with('success')->with('success', trans('admin/hardware/message.requests.canceled'));
|
||||
} else {
|
||||
$item->request();
|
||||
if (($settings->alert_email != '') && ($settings->alerts_enabled == '1') && (! config('app.lock_passwords'))) {
|
||||
|
|
|
@ -38,8 +38,12 @@ trait Requestable
|
|||
$this->requests()->where('user_id', Auth::id())->delete();
|
||||
}
|
||||
|
||||
public function cancelRequest()
|
||||
public function cancelRequest($user_id = null)
|
||||
{
|
||||
$this->requests()->where('user_id', Auth::id())->update(['canceled_at' => \Carbon\Carbon::now()]);
|
||||
if (!$user_id){
|
||||
$user_id = Auth::id();
|
||||
}
|
||||
|
||||
$this->requests()->where('user_id', $user_id)->update(['canceled_at' => \Carbon\Carbon::now()]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -436,6 +436,7 @@ return [
|
|||
'errors_importing' => 'Some Errors occurred while importing: ',
|
||||
'warning' => 'WARNING: :warning',
|
||||
'success_redirecting' => '"Success... Redirecting.',
|
||||
'cancel_request' => 'Cancel this item request',
|
||||
'setup_successful_migrations' => 'Your database tables have been created',
|
||||
'setup_migration_output' => 'Migration output:',
|
||||
'setup_migration_create_user' => 'Next: Create User',
|
||||
|
|
|
@ -17,11 +17,6 @@
|
|||
<div class="col-md-12">
|
||||
<div class="box">
|
||||
<div class="box-body">
|
||||
{{ Form::open([
|
||||
'method' => 'POST',
|
||||
'route' => ['hardware/bulkedit'],
|
||||
'class' => 'form-inline',
|
||||
'id' => 'bulkForm']) }}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
|
@ -51,7 +46,7 @@
|
|||
<th class="col-md-2" data-sortable="true">{{ trans('admin/hardware/form.expected_checkin') }}</th>
|
||||
<th class="col-md-3" data-sortable="true">{{ trans('admin/hardware/table.requesting_user') }}</th>
|
||||
<th class="col-md-2">{{ trans('admin/hardware/table.requested_date') }}</th>
|
||||
<th class="col-md-1">{{ trans('general.checkin').'/'.trans('general.checkout') }}</th>
|
||||
<th class="col-md-1">{{ trans('button.actions') }}</th> <th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -103,6 +98,14 @@
|
|||
@endif
|
||||
</td>
|
||||
<td>{{ App\Helpers\Helper::getFormattedDateObject($request->created_at, 'datetime', false) }}</td>
|
||||
<td>
|
||||
{{ Form::open([
|
||||
'method' => 'POST',
|
||||
'route' => ['account/request-item', $request->itemType(), $request->requestable->id, true, $request->requestingUser()->id],
|
||||
]) }}
|
||||
<button class="btn btn-warning btn-sm" data-tooltip="true" title="{{ trans('general.cancel_request') }}">{{ trans('button.cancel') }}</button>
|
||||
{{ Form::close() }}
|
||||
</td>
|
||||
<td>
|
||||
@if ($request->itemType() == "asset")
|
||||
@if ($request->requestable->assigned_to=='')
|
||||
|
|
|
@ -281,7 +281,7 @@ Route::group(['prefix' => 'account', 'middleware' => ['auth']], function () {
|
|||
)->name('account/request-asset');
|
||||
|
||||
Route::post(
|
||||
'request/{itemType}/{itemId}',
|
||||
'request/{itemType}/{itemId}/{cancel_by_admin?}/{requestingUser?}',
|
||||
[ViewAssetsController::class, 'getRequestItem']
|
||||
)->name('account/request-item');
|
||||
|
||||
|
|
Loading…
Reference in a new issue