Merge branch 'develop'

This commit is contained in:
snipe 2017-10-03 17:55:21 -07:00
commit 340386f282
9 changed files with 56 additions and 19 deletions

View file

@ -31,7 +31,7 @@ class AssetModelsController extends Controller
$this->authorize('view', AssetModel::class); $this->authorize('view', AssetModel::class);
$allowed_columns = ['id','image','name','model_number','eol','notes','created_at','manufacturer']; $allowed_columns = ['id','image','name','model_number','eol','notes','created_at','manufacturer'];
$assetmodels = AssetModel::select(['models.id','models.image','models.name','model_number','eol','models.notes','models.created_at','category_id','manufacturer_id','depreciation_id','fieldset_id']) $assetmodels = AssetModel::select(['models.id','models.image','models.name','model_number','eol','models.notes','models.created_at','category_id','manufacturer_id','depreciation_id','fieldset_id', 'models.deleted_at'])
->with('category','depreciation', 'manufacturer','fieldset') ->with('category','depreciation', 'manufacturer','fieldset')
->withCount('assets'); ->withCount('assets');
@ -39,6 +39,10 @@ class AssetModelsController extends Controller
$assetmodels->TextSearch($request->input('search')); $assetmodels->TextSearch($request->input('search'));
} }
if ($request->has('status')) {
$assetmodels->onlyTrashed();
}
$offset = $request->input('offset', 0); $offset = $request->input('offset', 0);
$limit = $request->input('limit', 50); $limit = $request->input('limit', 50);

View file

@ -15,6 +15,7 @@ use Illuminate\Support\Facades\View;
use Input; use Input;
use League\Csv\Reader; use League\Csv\Reader;
use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpFoundation\StreamedResponse;
use Illuminate\Http\Request;
/** /**
* This controller handles all actions related to Reports for * This controller handles all actions related to Reports for
@ -102,18 +103,45 @@ class ReportsController extends Controller
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function exportAssetReport() public function exportAssetReport(Request $request)
{ {
\Debugbar::disable(); \Debugbar::disable();
$customfields = CustomField::get(); $customfields = CustomField::get();
$response = new StreamedResponse(function () use ($customfields) { $response = new StreamedResponse(function () use ($customfields, $request) {
// Open output stream // Open output stream
$handle = fopen('php://output', 'w'); $handle = fopen('php://output', 'w');
Asset::with('assignedTo', 'assetLoc','defaultLoc','assignedTo','model','supplier','assetstatus','model.manufacturer')->orderBy('created_at', 'DESC')->chunk(500, function($assets) use($handle, $customfields) { $assets = Asset::with('assignedTo', 'assetLoc','defaultLoc','assignedTo','model','supplier','assetstatus','model.manufacturer');
// This is used by the sidenav, mostly
switch ($request->input('status')) {
case 'Deleted':
$assets->withTrashed()->Deleted();
break;
case 'Pending':
$assets->Pending();
break;
case 'RTD':
$assets->RTD();
break;
case 'Undeployable':
$assets->Undeployable();
break;
case 'Archived':
$assets->Archived();
break;
case 'Requestable':
$assets->RequestableAssets();
break;
case 'Deployed':
$assets->Deployed();
break;
}
$assets->orderBy('created_at', 'DESC')->chunk(500, function($assets) use($handle, $customfields) {
$headers=[ $headers=[
trans('general.company'), trans('general.company'),
trans('admin/hardware/table.asset_tag'), trans('admin/hardware/table.asset_tag'),
@ -126,7 +154,7 @@ class ReportsController extends Controller
trans('admin/hardware/table.purchase_date'), trans('admin/hardware/table.purchase_date'),
trans('admin/hardware/table.purchase_cost'), trans('admin/hardware/table.purchase_cost'),
trans('admin/hardware/form.order'), trans('admin/hardware/form.order'),
trans('admin/hardware/form.supplier'), trans('general.supplier'),
trans('admin/hardware/table.checkoutto'), trans('admin/hardware/table.checkoutto'),
trans('admin/hardware/table.checkout_date'), trans('admin/hardware/table.checkout_date'),
trans('admin/hardware/table.location'), trans('admin/hardware/table.location'),
@ -154,7 +182,7 @@ class ReportsController extends Controller
($asset->supplier) ? e($asset->supplier->name) : '', ($asset->supplier) ? e($asset->supplier->name) : '',
($asset->assignedTo) ? e($asset->assignedTo->present()->name()) : '', ($asset->assignedTo) ? e($asset->assignedTo->present()->name()) : '',
($asset->last_checkout!='') ? e($asset->last_checkout) : '', ($asset->last_checkout!='') ? e($asset->last_checkout) : '',
e($asset->assetLoc->present()->name()), ($asset->assetLoc) ? e($asset->assetLoc->present()->name()) : '',
($asset->notes) ? e($asset->notes) : '', ($asset->notes) ? e($asset->notes) : '',
]; ];
foreach ($customfields as $field) { foreach ($customfields as $field) {
@ -168,7 +196,8 @@ class ReportsController extends Controller
fclose($handle); fclose($handle);
}, 200, [ }, 200, [
'Content-Type' => 'text/csv', 'Content-Type' => 'text/csv',
'Content-Disposition' => 'attachment; filename="assets-'.date('Y-m-d-his').'.csv"', 'Content-Disposition'
=> 'attachment; filename="'.(($request->has('status')) ? trim($request->input('status')) : 'all').'-assets-'.date('Y-m-d-his').'.csv"',
]); ]);
return $response; return $response;

View file

@ -414,7 +414,7 @@ class SettingsController extends Controller
$file_name = "logo.".$image->getClientOriginalExtension(); $file_name = "logo.".$image->getClientOriginalExtension();
$path = public_path('uploads'); $path = public_path('uploads');
if ($image->getClientOriginalExtension()!='svg') { if ($image->getClientOriginalExtension()!='svg') {
Image::make($image->getRealPath())->resize(null, 40, function ($constraint) { Image::make($image->getRealPath())->resize(null, 150, function ($constraint) {
$constraint->aspectRatio(); $constraint->aspectRatio();
$constraint->upsize(); $constraint->upsize();
})->save($path.'/'.$file_name); })->save($path.'/'.$file_name);

View file

@ -47,13 +47,15 @@ class AssetModelsTransformer
'notes' => e($assetmodel->notes), 'notes' => e($assetmodel->notes),
'created_at' => Helper::getFormattedDateObject($assetmodel->created_at, 'datetime'), 'created_at' => Helper::getFormattedDateObject($assetmodel->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($assetmodel->updated_at, 'datetime'), 'updated_at' => Helper::getFormattedDateObject($assetmodel->updated_at, 'datetime'),
'deleted_at' => Helper::getFormattedDateObject($assetmodel->deleted_at, 'datetime'),
]; ];
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'update' => Gate::allows('update', AssetModel::class) ? true : false, 'update' => (Gate::allows('update', AssetModel::class) && ($assetmodel->deleted_at=='')) ? true : false,
'delete' => Gate::allows('delete', AssetModel::class) ? true : false, 'delete' => (Gate::allows('delete', AssetModel::class) && ($assetmodel->deleted_at=='')) ? true : false,
'clone' => Gate::allows('create', AssetModel::class) ? true : false, 'clone' => (Gate::allows('create', AssetModel::class) && ($assetmodel->deleted_at=='')) ,
'restore' => (Gate::allows('create', AssetModel::class) && ($assetmodel->deleted_at!='')) ? true : false,
]; ];
$array += $permissions_array; $array += $permissions_array;

View file

@ -13,6 +13,8 @@
{{ trans('general.pending') }} {{ trans('general.pending') }}
@elseif (Input::get('status')=='RTD') @elseif (Input::get('status')=='RTD')
{{ trans('general.ready_to_deploy') }} {{ trans('general.ready_to_deploy') }}
@elseif (Input::get('status')=='Deployed')
{{ trans('general.deployed') }}
@elseif (Input::get('status')=='Undeployable') @elseif (Input::get('status')=='Undeployable')
{{ trans('general.undeployable') }} {{ trans('general.undeployable') }}
@elseif (Input::get('status')=='Deployable') @elseif (Input::get('status')=='Deployable')
@ -40,7 +42,7 @@
@stop @stop
@section('header_right') @section('header_right')
<a href="{{ route('reports/export/assets') }}" style="margin-right: 5px;" class="btn btn-default"><i class="fa fa-download icon-white"></i> <a href="{{ route('reports.export.assets', ['status'=> e(Input::get('status'))]) }}" style="margin-right: 5px;" class="btn btn-default"><i class="fa fa-download icon-white"></i>
{{ trans('admin/hardware/table.dl_csv') }}</a> {{ trans('admin/hardware/table.dl_csv') }}</a>
<a href="{{ route('hardware.create') }}" class="btn btn-primary pull-right"></i> {{ trans('general.create') }}</a> <a href="{{ route('hardware.create') }}" class="btn btn-primary pull-right"></i> {{ trans('general.create') }}</a>
@stop @stop

View file

@ -13,7 +13,7 @@
<link rel="stylesheet" href="{{ url(asset('js/plugins/select2/select2.min.css')) }}"> <link rel="stylesheet" href="{{ url(asset('js/plugins/select2/select2.min.css')) }}">
<link rel="stylesheet" href="{{ url(mix('css/dist/all.css')) }}"> <link rel="stylesheet" href="{{ url(mix('css/dist/all.css')) }}">
<link rel="shortcut icon" type="image/ico" href="{{ asset('favicon.ico') }}"> <link rel="shortcut icon" type="image/ico" href="{{ url(asset('favicon.ico')) }}">
@if (($snipeSettings) && ($snipeSettings->header_color)) @if (($snipeSettings) && ($snipeSettings->header_color))
@ -42,7 +42,7 @@
@if (($snipeSettings) && ($snipeSettings->logo!='')) @if (($snipeSettings) && ($snipeSettings->logo!=''))
<center> <center>
<img class="logo" style="padding-top: 20px; padding-bottom: 10px;" src="{{ url('/') }}/uploads/{{ $snipeSettings->logo }}"> <img style="padding-top: 20px; padding-bottom: 10px; max-width: 150px" src="{{ url('/') }}/uploads/{{ $snipeSettings->logo }}">
</center> </center>
@endif @endif
<!-- Content --> <!-- Content -->

View file

@ -108,7 +108,7 @@
@if ($snipeSettings->brand == '3') @if ($snipeSettings->brand == '3')
<a class="logo navbar-brand no-hover" href="{{ url('/') }}"> <a class="logo navbar-brand no-hover" href="{{ url('/') }}">
@if ($snipeSettings->logo!='') @if ($snipeSettings->logo!='')
<img class="navbar-brand-img" src="{{ url('/') }}/uploads/{{ $snipeSettings->logo }}"> <img class="navbar-brand-img" style="max-height: 50px;" src="{{ url('/') }}/uploads/{{ $snipeSettings->logo }}">
@endif @endif
{{ $snipeSettings->site_name }} {{ $snipeSettings->site_name }}
</a> </a>

View file

@ -9,7 +9,7 @@
{{-- Page title --}} {{-- Page title --}}
@section('header_right') @section('header_right')
<a href="{{ route('models.create') }}" class="btn btn-primary pull-right"></i> {{ trans('general.create') }}</a> <a href="{{ route('models.create') }}" class="btn btn-primary pull-right"></i> {{ trans('general.create') }}</a>
<a href="{{ url('hardware/models?status=Deleted') }}" class="btn btn-default pull-right" style="margin-right:5px;"><i class="fa fa-trash"></i> {{ trans('admin/models/general.view_deleted') }}</a> <a href="{{ route('models.index', ['status' => 'Deleted']) }}" class="btn btn-default pull-right" style="margin-right:5px;"><i class="fa fa-trash"></i> {{ trans('admin/models/general.view_deleted') }}</a>
@stop @stop
@ -41,7 +41,7 @@
name="models" name="models"
class="table table-striped snipe-table" class="table table-striped snipe-table"
id="table" id="table"
data-url="{{ route('api.models.index') }}" data-url="{{ route('api.models.index', ['status'=> e(Input::get('status'))]) }}"
data-cookie="true" data-cookie="true"
data-click-to-select="true" data-click-to-select="true"
data-cookie-id-table="modelsTable-{{ config('version.hash_version') }}"> data-cookie-id-table="modelsTable-{{ config('version.hash_version') }}">

View file

@ -309,7 +309,7 @@ Route::group(['middleware' => ['auth']], function () {
Route::get('reports/assets', [ 'as' => 'reports/assets', 'uses' => 'ReportsController@getAssetsReport' ]); Route::get('reports/assets', [ 'as' => 'reports/assets', 'uses' => 'ReportsController@getAssetsReport' ]);
Route::get( Route::get(
'reports/export/assets', 'reports/export/assets',
[ 'as' => 'reports/export/assets', 'uses' => 'ReportsController@exportAssetReport' ] [ 'as' => 'reports.export.assets', 'uses' => 'ReportsController@exportAssetReport' ]
); );
Route::get('reports/accessories', [ 'as' => 'reports/accessories', 'uses' => 'ReportsController@getAccessoryReport' ]); Route::get('reports/accessories', [ 'as' => 'reports/accessories', 'uses' => 'ReportsController@getAccessoryReport' ]);
Route::get( Route::get(