Updates asset acceptance report to show unaccepted assets

This commit is contained in:
Till Deeke 2018-07-28 13:21:11 +02:00
parent 1bdf71b584
commit 8c96e8fd4b
2 changed files with 15 additions and 14 deletions

View file

@ -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'));
}

View file

@ -34,7 +34,6 @@ class Asset extends Depreciable
const ASSET = 'asset';
const USER = 'user';
const ACCEPTANCE_PENDING = 'pending';
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()) {
event(new AssetCheckedOut($this, $target, Auth::user(), $note));