mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 07:34:06 -08:00
e86adccf19
* Save progress * Create a new action_log table to replace asset_log. Use Polymorphism to generalize class and targets. Port everything I can find to use it. Add a migration to port the asset_logs table to action_logs. * Allow accepted_id to be nullable. * Comment out the thread_id migration, because it b0rks on a new database with the move. I'm unsure if the thread_id does anything...It doesn't seem to be used * Clean up all old methods from Actionlog model. Port everything to use new cleaner interface. * Port the actionlog factory to fix travis. * Adjust code to work on php5. Also fix lurking adminlog call. * Remove weird code * Port the pave command. Also fix dangling adminlog
92 lines
2.9 KiB
PHP
Executable file
92 lines
2.9 KiB
PHP
Executable file
<?php
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Controllers\AdminController;
|
|
use App\Models\Actionlog;
|
|
use View;
|
|
use Auth;
|
|
use Redirect;
|
|
use App\Models\Asset;
|
|
use App\Models\Company;
|
|
|
|
/**
|
|
* This controller handles all actions related to the Admin Dashboard
|
|
* for the Snipe-IT Asset Management application.
|
|
*
|
|
* @version v1.0
|
|
*/
|
|
class DashboardController extends Controller
|
|
{
|
|
/**
|
|
* Check authorization and display admin dashboard, otherwise display
|
|
* the user's checked-out assets.
|
|
*
|
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
|
* @since [v1.0]
|
|
* @return View
|
|
*/
|
|
public function getIndex()
|
|
{
|
|
// Show the page
|
|
if (Auth::user()->hasAccess('admin')) {
|
|
|
|
$recent_activity = Actionlog::latest()
|
|
->with('item')
|
|
->take(20)
|
|
->get();
|
|
|
|
|
|
$asset_stats['total'] = Asset::Hardware()->count();
|
|
|
|
$asset_stats['rtd']['total'] = Asset::Hardware()->RTD()->count();
|
|
|
|
if ($asset_stats['rtd']['total'] > 0) {
|
|
$asset_stats['rtd']['percent'] = round(($asset_stats['rtd']['total']/$asset_stats['total']) * 100);
|
|
} else {
|
|
$asset_stats['rtd']['percent'] = 0;
|
|
}
|
|
|
|
|
|
$asset_stats['pending']['total'] = Asset::Hardware()->Pending()->count();
|
|
|
|
if ($asset_stats['pending']['total'] > 0) {
|
|
$asset_stats['pending']['percent'] = round(($asset_stats['pending']['total']/$asset_stats['total']) * 100);
|
|
} else {
|
|
$asset_stats['pending']['percent'] = 0;
|
|
}
|
|
|
|
|
|
$asset_stats['deployed']['total'] = Asset::Hardware()->Deployed()->count();
|
|
|
|
if ($asset_stats['deployed']['total'] > 0) {
|
|
$asset_stats['deployed']['percent'] = round(($asset_stats['deployed']['total']/$asset_stats['total']) * 100);
|
|
} else {
|
|
$asset_stats['deployed']['percent'] = 0;
|
|
}
|
|
|
|
|
|
$asset_stats['undeployable']['total'] = Asset::Hardware()->Undeployable()->count();
|
|
|
|
if ($asset_stats['undeployable']['total'] > 0) {
|
|
$asset_stats['undeployable']['percent'] = round(($asset_stats['undeployable']['total']/$asset_stats['total']) * 100);
|
|
} else {
|
|
$asset_stats['undeployable']['percent'] = 0;
|
|
}
|
|
|
|
$asset_stats['archived']['total'] = Asset::Hardware()->Archived()->count();
|
|
|
|
if ($asset_stats['archived']['total'] > 0) {
|
|
$asset_stats['archived']['percent'] = round(($asset_stats['archived']['total']/$asset_stats['total']) * 100);
|
|
} else {
|
|
$asset_stats['archived']['percent'] = 0;
|
|
}
|
|
|
|
|
|
return View::make('dashboard')->with('asset_stats', $asset_stats)->with('recent_activity', $recent_activity);
|
|
} else {
|
|
// Redirect to the profile page
|
|
return redirect()->route('view-assets');
|
|
}
|
|
}
|
|
}
|