mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-23 19:59:18 -08:00
Updates asset acceptance report to show unaccepted assets
This commit is contained in:
parent
1bdf71b584
commit
8c96e8fd4b
|
@ -7,6 +7,7 @@ use App\Models\Actionlog;
|
|||
use App\Models\Asset;
|
||||
use App\Models\AssetMaintenance;
|
||||
use App\Models\CustomField;
|
||||
use App\Models\CheckoutAcceptance;
|
||||
use App\Models\Depreciation;
|
||||
use App\Models\License;
|
||||
use App\Models\Setting;
|
||||
|
@ -805,7 +806,20 @@ class ReportsController extends Controller
|
|||
public function getAssetAcceptanceReport()
|
||||
{
|
||||
$this->authorize('reports.view');
|
||||
$assetsForReport = Asset::notYetAccepted()->with('company')->get();
|
||||
|
||||
/**
|
||||
* Get all assets with pending checkout acceptances
|
||||
*/
|
||||
|
||||
$acceptances = CheckoutAcceptance::pending()->get();
|
||||
|
||||
$assetsForReport = $acceptances
|
||||
->filter(function($acceptance) {
|
||||
return $acceptance->checkoutable_type == 'App\Models\Asset';
|
||||
})
|
||||
->map(function($acceptance) {
|
||||
return $acceptance->checkoutable;
|
||||
});
|
||||
|
||||
return view('reports/unaccepted_assets', compact('assetsForReport'));
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ class Asset extends Depreciable
|
|||
const ASSET = 'asset';
|
||||
const USER = 'user';
|
||||
|
||||
const ACCEPTANCE_PENDING = 'pending';
|
||||
use Acceptable;
|
||||
|
||||
/**
|
||||
|
@ -263,18 +262,6 @@ class Asset extends Depreciable
|
|||
$this->location_id = $target->id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the user have to confirm that they accept the asset?
|
||||
*
|
||||
* If so, set the acceptance-status to "pending".
|
||||
* This value is used in the unaccepted assets reports, for example
|
||||
*
|
||||
* @see https://github.com/snipe/snipe-it/issues/5772
|
||||
*/
|
||||
if ($this->requireAcceptance() && $target instanceof User) {
|
||||
$this->accepted = self::ACCEPTANCE_PENDING;
|
||||
}
|
||||
|
||||
if ($this->save()) {
|
||||
|
||||
|
|
Loading…
Reference in a new issue