mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 06:04:08 -08:00
Unaccepted Assets Report Actions (send reminder, delete) added
Unaccepted Assets Export fixed
This commit is contained in:
parent
3980c80c70
commit
ed99532c30
|
@ -12,8 +12,10 @@ use App\Models\CustomField;
|
||||||
use App\Models\Depreciation;
|
use App\Models\Depreciation;
|
||||||
use App\Models\License;
|
use App\Models\License;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
|
use App\Notifications\CheckoutAssetNotification;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Notification;
|
||||||
use Illuminate\Support\Facades\Response;
|
use Illuminate\Support\Facades\Response;
|
||||||
use Illuminate\Support\Facades\View;
|
use Illuminate\Support\Facades\View;
|
||||||
use Input;
|
use Input;
|
||||||
|
@ -904,6 +906,7 @@ class ReportsController extends Controller
|
||||||
* getAssetAcceptanceReport
|
* getAssetAcceptanceReport
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||||
* @version v1.0
|
* @version v1.0
|
||||||
*/
|
*/
|
||||||
|
@ -914,19 +917,87 @@ class ReportsController extends Controller
|
||||||
/**
|
/**
|
||||||
* Get all assets with pending checkout acceptances
|
* Get all assets with pending checkout acceptances
|
||||||
*/
|
*/
|
||||||
|
<<<<<<< HEAD
|
||||||
$acceptances = CheckoutAcceptance::pending()->get();
|
$acceptances = CheckoutAcceptance::pending()->get();
|
||||||
|
=======
|
||||||
|
$acceptances = CheckoutAcceptance::pending()->with(['assignedTo', 'checkoutable.assignedTo', 'checkoutable.model'])->get();
|
||||||
|
>>>>>>> Unaccepted Assets Report Actions (send reminder, delete) added
|
||||||
|
|
||||||
$assetsForReport = $acceptances
|
$assetsForReport = $acceptances
|
||||||
->filter(function ($acceptance) {
|
->filter(function ($acceptance) {
|
||||||
return $acceptance->checkoutable_type == \App\Models\Asset::class;
|
return $acceptance->checkoutable_type == \App\Models\Asset::class;
|
||||||
})
|
})
|
||||||
|
<<<<<<< HEAD
|
||||||
->map(function ($acceptance) {
|
->map(function ($acceptance) {
|
||||||
return $acceptance->checkoutable;
|
return $acceptance->checkoutable;
|
||||||
|
=======
|
||||||
|
->map(function($acceptance) {
|
||||||
|
return ['assetItem' => $acceptance->checkoutable, 'acceptance' => $acceptance];
|
||||||
|
>>>>>>> Unaccepted Assets Report Actions (send reminder, delete) added
|
||||||
});
|
});
|
||||||
|
|
||||||
return view('reports/unaccepted_assets', compact('assetsForReport'));
|
return view('reports/unaccepted_assets', compact('assetsForReport'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sentAssetAcceptanceReminder
|
||||||
|
*
|
||||||
|
* @param integer|null $acceptanceId
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||||
|
* @version v1.0
|
||||||
|
*/
|
||||||
|
public function sentAssetAcceptanceReminder($acceptanceId = null)
|
||||||
|
{
|
||||||
|
$this->authorize('reports.view');
|
||||||
|
|
||||||
|
if (!$acceptance = CheckoutAcceptance::pending()->find($acceptanceId)) {
|
||||||
|
// Redirect to the unaccepted assets report page with error
|
||||||
|
return redirect()->route('reports/unaccepted_assets')->with('error', trans('general.bad_data'));
|
||||||
|
}
|
||||||
|
$assetItem = $acceptance->checkoutable;
|
||||||
|
|
||||||
|
$logItem = $assetItem->checkouts()->where('created_at', '=', $acceptance->created_at)->get()[0];
|
||||||
|
|
||||||
|
if(!$assetItem->assignedTo->locale){
|
||||||
|
Notification::locale(Setting::getSettings()->locale)->send(
|
||||||
|
$assetItem->assignedTo,
|
||||||
|
new CheckoutAssetNotification($assetItem, $assetItem->assignedTo, $logItem->user, $acceptance, $logItem->note)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Notification::send(
|
||||||
|
$assetItem->assignedTo,
|
||||||
|
new CheckoutAssetNotification($assetItem, $assetItem->assignedTo, $logItem->user, $acceptance, $logItem->note)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route('reports/unaccepted_assets')->with('success', trans('admin/reports/general.reminder_sent'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sentAssetAcceptanceReminder
|
||||||
|
*
|
||||||
|
* @param integer|null $acceptanceId
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||||
|
* @version v1.0
|
||||||
|
*/
|
||||||
|
public function deleteAssetAcceptance($acceptanceId = null)
|
||||||
|
{
|
||||||
|
$this->authorize('reports.view');
|
||||||
|
|
||||||
|
if (!$acceptance = CheckoutAcceptance::pending()->find($acceptanceId)) {
|
||||||
|
// Redirect to the unaccepted assets report page with error
|
||||||
|
return redirect()->route('reports/unaccepted_assets')->with('error', trans('general.bad_data'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if($acceptance->delete()) {
|
||||||
|
return redirect()->route('reports/unaccepted_assets')->with('success', trans('admin/reports/general.acceptance_deleted'));
|
||||||
|
} else {
|
||||||
|
return redirect()->route('reports/unaccepted_assets')->with('error', trans('general.deletion_failed'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* exportAssetAcceptanceReport
|
* exportAssetAcceptanceReport
|
||||||
*
|
*
|
||||||
|
@ -937,9 +1008,19 @@ class ReportsController extends Controller
|
||||||
public function exportAssetAcceptanceReport()
|
public function exportAssetAcceptanceReport()
|
||||||
{
|
{
|
||||||
$this->authorize('reports.view');
|
$this->authorize('reports.view');
|
||||||
// Grab all the improvements
|
|
||||||
$assetsForReport = Actionlog::whereIn('id', $this->getAssetsNotAcceptedYet())
|
/**
|
||||||
->get();
|
* Get all assets with pending checkout acceptances
|
||||||
|
*/
|
||||||
|
$acceptances = CheckoutAcceptance::pending()->with(['assignedTo', 'checkoutable.assignedTo', 'checkoutable.model'])->get();
|
||||||
|
|
||||||
|
$assetsForReport = $acceptances
|
||||||
|
->filter(function($acceptance) {
|
||||||
|
return $acceptance->checkoutable_type == 'App\Models\Asset';
|
||||||
|
})
|
||||||
|
->map(function($acceptance) {
|
||||||
|
return ['assetItem' => $acceptance->checkoutable, 'acceptance' => $acceptance];
|
||||||
|
});
|
||||||
|
|
||||||
$rows = [];
|
$rows = [];
|
||||||
|
|
||||||
|
@ -954,6 +1035,7 @@ class ReportsController extends Controller
|
||||||
$header = array_map('trim', $header);
|
$header = array_map('trim', $header);
|
||||||
$rows[] = implode($header, ',');
|
$rows[] = implode($header, ',');
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
foreach ($assetsForReport as $assetItem) {
|
foreach ($assetsForReport as $assetItem) {
|
||||||
$row = [];
|
$row = [];
|
||||||
$row[] = str_replace(',', '', e($assetItem->assetlog->model->category->name));
|
$row[] = str_replace(',', '', e($assetItem->assetlog->model->category->name));
|
||||||
|
@ -961,6 +1043,15 @@ class ReportsController extends Controller
|
||||||
$row[] = str_replace(',', '', e($assetItem->assetlog->present()->name()));
|
$row[] = str_replace(',', '', e($assetItem->assetlog->present()->name()));
|
||||||
$row[] = str_replace(',', '', e($assetItem->assetlog->asset_tag));
|
$row[] = str_replace(',', '', e($assetItem->assetlog->asset_tag));
|
||||||
$row[] = str_replace(',', '', e($assetItem->assetlog->assignedTo->present()->name()));
|
$row[] = str_replace(',', '', e($assetItem->assetlog->assignedTo->present()->name()));
|
||||||
|
=======
|
||||||
|
foreach ($assetsForReport as $item) {
|
||||||
|
$row = [ ];
|
||||||
|
$row[] = str_replace(',', '', e($item['assetItem']->model->category->name));
|
||||||
|
$row[] = str_replace(',', '', e($item['assetItem']->model->name));
|
||||||
|
$row[] = str_replace(',', '', e($item['assetItem']->name));
|
||||||
|
$row[] = str_replace(',', '', e($item['assetItem']->asset_tag));
|
||||||
|
$row[] = str_replace(',', '', e(($item['acceptance']->assignedTo) ? $item['acceptance']->assignedTo->present()->name() : trans('admin/reports/general.deleted_user')));
|
||||||
|
>>>>>>> Unaccepted Assets Report Actions (send reminder, delete) added
|
||||||
$rows[] = implode($row, ',');
|
$rows[] = implode($row, ',');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
return [
|
return [
|
||||||
'info' => 'Select the options you want for your asset report.',
|
'info' => 'Select the options you want for your asset report.',
|
||||||
];
|
];
|
||||||
|
=======
|
||||||
|
return array(
|
||||||
|
'info' => 'Select the options you want for your asset report.',
|
||||||
|
'deleted_user' => 'Deleted user',
|
||||||
|
'send_reminder' => 'Send reminder',
|
||||||
|
'reminder_sent' => 'Reminder sent',
|
||||||
|
'acceptance_deleted' => 'Acceptance request deleted',
|
||||||
|
'acceptance_request' => 'Acceptance request'
|
||||||
|
);
|
||||||
|
>>>>>>> Unaccepted Assets Report Actions (send reminder, delete) added
|
||||||
|
|
|
@ -73,6 +73,7 @@
|
||||||
'delete_confirm' => 'Are you sure you wish to delete :item?',
|
'delete_confirm' => 'Are you sure you wish to delete :item?',
|
||||||
'deleted' => 'Deleted',
|
'deleted' => 'Deleted',
|
||||||
'delete_seats' => 'Deleted Seats',
|
'delete_seats' => 'Deleted Seats',
|
||||||
|
'deletion_failed' => 'Deletion failed',
|
||||||
'departments' => 'Departments',
|
'departments' => 'Departments',
|
||||||
'department' => 'Department',
|
'department' => 'Department',
|
||||||
'deployed' => 'Deployed',
|
'deployed' => 'Deployed',
|
||||||
|
|
|
@ -41,19 +41,24 @@
|
||||||
<th class="col-sm-1">{{ trans('admin/hardware/form.name') }}</th>
|
<th class="col-sm-1">{{ trans('admin/hardware/form.name') }}</th>
|
||||||
<th class="col-sm-1">{{ trans('admin/hardware/table.asset_tag') }}</th>
|
<th class="col-sm-1">{{ trans('admin/hardware/table.asset_tag') }}</th>
|
||||||
<th class="col-sm-1">{{ trans('admin/hardware/table.checkoutto') }}</th>
|
<th class="col-sm-1">{{ trans('admin/hardware/table.checkoutto') }}</th>
|
||||||
|
<th class="col-md-1"><span class="line"></span>{{ trans('table.actions') }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@if ($assetsForReport)
|
@if ($assetsForReport)
|
||||||
@foreach ($assetsForReport as $assetItem)
|
@foreach ($assetsForReport as $item)
|
||||||
@if ($assetItem)
|
@if ($item['assetItem'])
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ ($assetItem->company) ? $assetItem->company->name : '' }}</td>
|
<td>{{ ($item['assetItem']->company) ? $assetItem->company->name : '' }}</td>
|
||||||
<td>{{ $assetItem->model->category->name }}</td>
|
<td>{!! $item['assetItem']->model->category->present()->nameUrl() !!}</td>
|
||||||
<td>{{ $assetItem->model->name }}</td>
|
<td>{!! $item['assetItem']->present()->modelUrl() !!}</td>
|
||||||
<td>{!! $assetItem->present()->nameUrl() !!}</td>
|
<td>{!! $item['assetItem']->present()->nameUrl() !!}</td>
|
||||||
<td>{{ $assetItem->asset_tag }}</td>
|
<td>{{ $item['assetItem']->asset_tag }}</td>
|
||||||
<td>{!! ($assetItem->assignedTo) ? $assetItem->assignedTo->present()->nameUrl() : 'Deleted user' !!}</td>
|
<td>{!! ($item['acceptance']->assignedTo) ? $item['acceptance']->assignedTo->present()->nameUrl() : trans('admin/reports/general.deleted_user') !!}</td>
|
||||||
|
<td>
|
||||||
|
@if ($item['acceptance']->assignedTo)<a href="{{ route('reports/unaccepted_assets_sent_reminder', ['acceptanceId' => $item['acceptance']->id]) }}" class="btn btn-sm bg-purple" data-tooltip="true">{{ trans('admin/reports/general.send_reminder') }}</a>@endif
|
||||||
|
<a href="{{ route('reports/unaccepted_assets_delete', ['acceptanceId' => $item['acceptance']->id]) }}" class="btn btn-sm btn-danger delete-asset" data-tooltip="true" data-toggle="modal" data-content="{{ trans('general.delete_confirm', ['item' =>trans('admin/reports/general.acceptance_request')]) }}" data-title="{{ trans('general.delete') }}" onClick="return false;"><i class="fa fa-trash"></i></a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endif
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
|
@ -322,6 +322,14 @@ Route::group(['middleware' => ['auth']], function () {
|
||||||
'reports/unaccepted_assets',
|
'reports/unaccepted_assets',
|
||||||
[ReportsController::class, 'getAssetAcceptanceReport']
|
[ReportsController::class, 'getAssetAcceptanceReport']
|
||||||
)->name('reports/unaccepted_assets');
|
)->name('reports/unaccepted_assets');
|
||||||
|
Route::get(
|
||||||
|
'reports/unaccepted_assets/{acceptanceId}/sent_reminder',
|
||||||
|
[ 'as' => 'reports/unaccepted_assets_sent_reminder', 'uses' => 'ReportsController@sentAssetAcceptanceReminder' ]
|
||||||
|
);
|
||||||
|
Route::delete(
|
||||||
|
'reports/unaccepted_assets/{acceptanceId}/delete',
|
||||||
|
[ 'as' => 'reports/unaccepted_assets_delete', 'uses' => 'ReportsController@deleteAssetAcceptance' ]
|
||||||
|
);
|
||||||
Route::get(
|
Route::get(
|
||||||
'reports/export/unaccepted_assets',
|
'reports/export/unaccepted_assets',
|
||||||
[ReportsController::class, 'exportAssetAcceptanceReport']
|
[ReportsController::class, 'exportAssetAcceptanceReport']
|
||||||
|
|
Loading…
Reference in a new issue