mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -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\Asset;
|
||||||
use App\Models\AssetMaintenance;
|
use App\Models\AssetMaintenance;
|
||||||
use App\Models\CustomField;
|
use App\Models\CustomField;
|
||||||
|
use App\Models\CheckoutAcceptance;
|
||||||
use App\Models\Depreciation;
|
use App\Models\Depreciation;
|
||||||
use App\Models\License;
|
use App\Models\License;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
|
@ -805,7 +806,20 @@ class ReportsController extends Controller
|
||||||
public function getAssetAcceptanceReport()
|
public function getAssetAcceptanceReport()
|
||||||
{
|
{
|
||||||
$this->authorize('reports.view');
|
$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'));
|
return view('reports/unaccepted_assets', compact('assetsForReport'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ class Asset extends Depreciable
|
||||||
const ASSET = 'asset';
|
const ASSET = 'asset';
|
||||||
const USER = 'user';
|
const USER = 'user';
|
||||||
|
|
||||||
const ACCEPTANCE_PENDING = 'pending';
|
|
||||||
use Acceptable;
|
use Acceptable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -264,18 +263,6 @@ class Asset extends Depreciable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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()) {
|
if ($this->save()) {
|
||||||
|
|
||||||
event(new AssetCheckedOut($this, $target, Auth::user(), $note));
|
event(new AssetCheckedOut($this, $target, Auth::user(), $note));
|
||||||
|
|
Loading…
Reference in a new issue