mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-11 08:04:09 -08:00
Merge branch 'develop'
This commit is contained in:
commit
340386f282
|
@ -31,7 +31,7 @@ class AssetModelsController extends Controller
|
|||
$this->authorize('view', AssetModel::class);
|
||||
$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')
|
||||
->withCount('assets');
|
||||
|
||||
|
@ -39,6 +39,10 @@ class AssetModelsController extends Controller
|
|||
$assetmodels->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
if ($request->has('status')) {
|
||||
$assetmodels->onlyTrashed();
|
||||
}
|
||||
|
||||
|
||||
$offset = $request->input('offset', 0);
|
||||
$limit = $request->input('limit', 50);
|
||||
|
|
|
@ -15,6 +15,7 @@ use Illuminate\Support\Facades\View;
|
|||
use Input;
|
||||
use League\Csv\Reader;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Reports for
|
||||
|
@ -102,18 +103,45 @@ class ReportsController extends Controller
|
|||
* @since [v1.0]
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function exportAssetReport()
|
||||
public function exportAssetReport(Request $request)
|
||||
{
|
||||
|
||||
\Debugbar::disable();
|
||||
|
||||
$customfields = CustomField::get();
|
||||
|
||||
$response = new StreamedResponse(function () use ($customfields) {
|
||||
$response = new StreamedResponse(function () use ($customfields, $request) {
|
||||
// Open output stream
|
||||
$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=[
|
||||
trans('general.company'),
|
||||
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_cost'),
|
||||
trans('admin/hardware/form.order'),
|
||||
trans('admin/hardware/form.supplier'),
|
||||
trans('general.supplier'),
|
||||
trans('admin/hardware/table.checkoutto'),
|
||||
trans('admin/hardware/table.checkout_date'),
|
||||
trans('admin/hardware/table.location'),
|
||||
|
@ -154,7 +182,7 @@ class ReportsController extends Controller
|
|||
($asset->supplier) ? e($asset->supplier->name) : '',
|
||||
($asset->assignedTo) ? e($asset->assignedTo->present()->name()) : '',
|
||||
($asset->last_checkout!='') ? e($asset->last_checkout) : '',
|
||||
e($asset->assetLoc->present()->name()),
|
||||
($asset->assetLoc) ? e($asset->assetLoc->present()->name()) : '',
|
||||
($asset->notes) ? e($asset->notes) : '',
|
||||
];
|
||||
foreach ($customfields as $field) {
|
||||
|
@ -168,7 +196,8 @@ class ReportsController extends Controller
|
|||
fclose($handle);
|
||||
}, 200, [
|
||||
'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;
|
||||
|
|
|
@ -414,7 +414,7 @@ class SettingsController extends Controller
|
|||
$file_name = "logo.".$image->getClientOriginalExtension();
|
||||
$path = public_path('uploads');
|
||||
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->upsize();
|
||||
})->save($path.'/'.$file_name);
|
||||
|
|
|
@ -47,13 +47,15 @@ class AssetModelsTransformer
|
|||
'notes' => e($assetmodel->notes),
|
||||
'created_at' => Helper::getFormattedDateObject($assetmodel->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($assetmodel->updated_at, 'datetime'),
|
||||
'deleted_at' => Helper::getFormattedDateObject($assetmodel->deleted_at, 'datetime'),
|
||||
|
||||
];
|
||||
|
||||
$permissions_array['available_actions'] = [
|
||||
'update' => Gate::allows('update', AssetModel::class) ? true : false,
|
||||
'delete' => Gate::allows('delete', AssetModel::class) ? true : false,
|
||||
'clone' => Gate::allows('create', AssetModel::class) ? true : false,
|
||||
'update' => (Gate::allows('update', AssetModel::class) && ($assetmodel->deleted_at=='')) ? true : false,
|
||||
'delete' => (Gate::allows('delete', AssetModel::class) && ($assetmodel->deleted_at=='')) ? 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;
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
{{ trans('general.pending') }}
|
||||
@elseif (Input::get('status')=='RTD')
|
||||
{{ trans('general.ready_to_deploy') }}
|
||||
@elseif (Input::get('status')=='Deployed')
|
||||
{{ trans('general.deployed') }}
|
||||
@elseif (Input::get('status')=='Undeployable')
|
||||
{{ trans('general.undeployable') }}
|
||||
@elseif (Input::get('status')=='Deployable')
|
||||
|
@ -40,7 +42,7 @@
|
|||
@stop
|
||||
|
||||
@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>
|
||||
<a href="{{ route('hardware.create') }}" class="btn btn-primary pull-right"></i> {{ trans('general.create') }}</a>
|
||||
@stop
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<link rel="stylesheet" href="{{ url(asset('js/plugins/select2/select2.min.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))
|
||||
|
@ -42,7 +42,7 @@
|
|||
|
||||
@if (($snipeSettings) && ($snipeSettings->logo!=''))
|
||||
<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>
|
||||
@endif
|
||||
<!-- Content -->
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
@if ($snipeSettings->brand == '3')
|
||||
<a class="logo navbar-brand no-hover" href="{{ url('/') }}">
|
||||
@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
|
||||
{{ $snipeSettings->site_name }}
|
||||
</a>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
{{-- Page title --}}
|
||||
@section('header_right')
|
||||
<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
|
||||
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
|||
name="models"
|
||||
class="table table-striped snipe-table"
|
||||
id="table"
|
||||
data-url="{{ route('api.models.index') }}"
|
||||
data-url="{{ route('api.models.index', ['status'=> e(Input::get('status'))]) }}"
|
||||
data-cookie="true"
|
||||
data-click-to-select="true"
|
||||
data-cookie-id-table="modelsTable-{{ config('version.hash_version') }}">
|
||||
|
|
|
@ -309,7 +309,7 @@ Route::group(['middleware' => ['auth']], function () {
|
|||
Route::get('reports/assets', [ 'as' => 'reports/assets', 'uses' => 'ReportsController@getAssetsReport' ]);
|
||||
Route::get(
|
||||
'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(
|
||||
|
|
Loading…
Reference in a new issue