diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 3da8dd903d..8db3bea158 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -125,6 +125,10 @@ class AssetsController extends Controller $assets->ByManufacturer($request->input('manufacturer_id')); } + if ($request->has('depreciation_id')) { + $assets->ByDepreciationId($request->input('depreciation_id')); + } + $request->has('order_number') ? $assets = $assets->where('assets.order_number', '=', e($request->get('order_number'))) : ''; $offset = request('offset', 0); @@ -133,28 +137,61 @@ class AssetsController extends Controller // This is used by the sidenav, mostly + + // We switched from using query scopes here because of a Laravel bug + // related to fulltext searches on complex queries. + // I am sad. :( switch ($request->input('status')) { case 'Deleted': $assets->withTrashed()->Deleted(); break; case 'Pending': - $assets->Pending(); + $assets->join('status_labels',function ($join) { + $join->on('status_labels.id', "=", "assets.status_id") + ->where('status_labels.deployable','=',0) + ->where('status_labels.pending','=',1) + ->where('status_labels.archived', '=', 0); + }); break; case 'RTD': - $assets->RTD(); + $assets->join('status_labels',function ($join) { + $join->on('status_labels.id', "=", "assets.status_id") + ->where('status_labels.deployable','=',1) + ->where('status_labels.pending','=',0) + ->where('status_labels.archived', '=', 0); + }); break; case 'Undeployable': $assets->Undeployable(); break; case 'Archived': - $assets->Archived(); + $assets->join('status_labels',function ($join) { + $join->on('status_labels.id', "=", "assets.status_id") + ->where('status_labels.deployable','=',0) + ->where('status_labels.pending','=',0) + ->where('status_labels.archived', '=', 1); + }); break; case 'Requestable': - $assets->RequestableAssets(); + $assets->where('assets.requestable', '=', 1) + ->join('status_labels',function ($join) { + $join->on('status_labels.id', "=", "assets.status_id") + ->where('status_labels.deployable','=',1) + ->where('status_labels.pending','=',0) + ->where('status_labels.archived', '=', 0); + }); + break; case 'Deployed': - $assets->Deployed(); + // more sad, horrible workarounds for laravel bugs when doing full text searches + $assets->where('assets.assigned_to', '>', '0'); break; + default: + // terrible workaround for complex-query Laravel bug in fulltext + $assets->join('status_labels',function ($join) { + $join->on('status_labels.id', "=", "assets.status_id") + ->where('status_labels.archived', '=', 0); + }); } @@ -481,6 +518,9 @@ class AssetsController extends Controller $data['item_tag'] = $asset->asset_tag; $data['item_serial'] = $asset->serial; $data['note'] = $logaction->note; + $data['manufacturer_name'] = $asset->model->manufacturer->name; + $data['model_name'] = $asset->model->name; + $data['model_number'] = $asset->model->model_number; if ((($asset->checkin_email()=='1')) && (isset($user)) && (!config('app.lock_passwords'))) { Mail::send('emails.checkin-asset', $data, function ($m) use ($user) { diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.php index d341522e87..2c00ee541f 100755 --- a/app/Http/Controllers/AssetsController.php +++ b/app/Http/Controllers/AssetsController.php @@ -558,6 +558,9 @@ class AssetsController extends Controller $data['item_tag'] = $asset->asset_tag; $data['item_serial'] = $asset->serial; $data['note'] = $logaction->note; + $data['manufacturer_name'] = $asset->model->manufacturer->name; + $data['model_name'] = $asset->model->name; + $data['model_number'] = $asset->model->model_number; if ((($asset->checkin_email()=='1')) && (isset($user)) && (!empty($user->email)) && (!config('app.lock_passwords'))) { Mail::send('emails.checkin-asset', $data, function ($m) use ($user) { diff --git a/app/Http/Controllers/DepreciationsController.php b/app/Http/Controllers/DepreciationsController.php index e4af313148..8eb14ccc89 100755 --- a/app/Http/Controllers/DepreciationsController.php +++ b/app/Http/Controllers/DepreciationsController.php @@ -155,5 +155,24 @@ class DepreciationsController extends Controller return redirect()->route('depreciations.index')->with('success', trans('admin/depreciations/message.delete.success')); } + /** + * Returns a view that displays a form to display depreciation listing + * + * @author [A. Gianotto] [route('depreciations.index')->with('error', trans('admin/depreciations/message.does_not_exist')); + } + + return view('depreciations/view', compact('depreciation')); + } + } diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 730ac7f8c3..d8df3f788a 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -1106,4 +1106,20 @@ class Asset extends Depreciable } + /** + * Query builder scope to search on location ID + * + * @param \Illuminate\Database\Query\Builder $query Query builder instance + * @param text $search Search term + * + * @return \Illuminate\Database\Query\Builder Modified query builder + */ + public function scopeByDepreciationId($query, $search) + { + return $query->join('models', 'assets.model_id', '=', 'models.id') + ->join('depreciations', 'models.depreciation_id', '=', 'depreciations.id')->where('models.depreciation_id', '=', $search); + + } + + } diff --git a/app/Notifications/CheckoutNotification.php b/app/Notifications/CheckoutNotification.php index b31b87f294..a0f44baf10 100644 --- a/app/Notifications/CheckoutNotification.php +++ b/app/Notifications/CheckoutNotification.php @@ -99,6 +99,9 @@ class CheckoutNotification extends Notification 'item_serial' => $item->serial, 'require_acceptance' => method_exists($item, 'requireAcceptance') ? $item->requireAcceptance() : '', 'log_id' => $this->params['log_id'], + 'manufacturer_name' => $item->model->manufacturer->name, + 'model_name' => $item->model->name, + 'model_number' => $item->model->model_number, ]; if ((method_exists($item, 'requireAcceptance') && ($item->requireAcceptance() == '1')) diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index 55f238140d..761ec9c14c 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -14,6 +14,7 @@ 'all' => 'All', 'archived' => 'Archived', 'asset_models' => 'Asset Models', + 'asset_model' => 'Model', 'asset' => 'Asset', 'asset_report' => 'Asset Report', 'asset_tag' => 'Asset Tag', diff --git a/resources/views/depreciations/view.blade.php b/resources/views/depreciations/view.blade.php new file mode 100644 index 0000000000..89baef33f4 --- /dev/null +++ b/resources/views/depreciations/view.blade.php @@ -0,0 +1,54 @@ +@extends('layouts/default') + +{{-- Page title --}} +@section('title') + + {{ trans('general.depreciation') }} + : {{ $depreciation->name }} + + @parent +@stop + +@section('header_right') + {{ trans('admin/depreciations/table.update') }} +@stop + +{{-- Page content --}} +@section('content') + +
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+ +@stop + +@section('moar_scripts') + @include ('partials.bootstrap-table', [ + 'exportFile' => 'assets-export', + 'search' => true, + 'columns' => \App\Presenters\AssetPresenter::dataTableLayout() + ]) + +@stop diff --git a/resources/views/emails/accept-accessory.blade.php b/resources/views/emails/accept-accessory.blade.php index f5d0bc1dc2..61f7cc2466 100644 --- a/resources/views/emails/accept-accessory.blade.php +++ b/resources/views/emails/accept-accessory.blade.php @@ -57,5 +57,5 @@

{{ trans('mail.i_have_read') }}

@endif -

{{ $snipeSettings->site_name }}

+

{{ $snipeSettings->site_name }}

@stop diff --git a/resources/views/emails/accept-asset.blade.php b/resources/views/emails/accept-asset.blade.php index e87f6987b0..df078104eb 100755 --- a/resources/views/emails/accept-asset.blade.php +++ b/resources/views/emails/accept-asset.blade.php @@ -25,6 +25,36 @@ @endif + @if (isset($manufacturer_name)) + + + {{ trans('general.manufacturer') }} + + + {{ $manufacturer_name }} + + + @endif + @if (isset($model_name)) + + + {{ trans('general.model_no') }}: + + + {{ $model_name }} + + + @endif + @if (isset($model_number)) + + + {{ trans('general.asset_model') }}: + + + {{ $model_number }} + + + @endif @if (isset($item_serial)) @@ -87,5 +117,5 @@

{{ trans('mail.i_have_read') }}

@endif -

{{ $snipeSettings->site_name }}

+

{{ $snipeSettings->site_name }}

@stop diff --git a/resources/views/emails/asset-canceled.blade.php b/resources/views/emails/asset-canceled.blade.php index 16b3a05cf5..08736b8d69 100644 --- a/resources/views/emails/asset-canceled.blade.php +++ b/resources/views/emails/asset-canceled.blade.php @@ -9,4 +9,5 @@ {{ trans('mail.canceled') }} {{ $requested_date }}

+

{{ $snipeSettings->site_name }}

@stop diff --git a/resources/views/emails/asset-requested.blade.php b/resources/views/emails/asset-requested.blade.php index 14c2572a4f..901b2606bf 100644 --- a/resources/views/emails/asset-requested.blade.php +++ b/resources/views/emails/asset-requested.blade.php @@ -11,4 +11,5 @@ {{ trans('mail.quantity') }} {{ $item_quantity}} @endif +

{{ $snipeSettings->site_name }}

@stop diff --git a/resources/views/emails/checkin-asset.blade.php b/resources/views/emails/checkin-asset.blade.php index bf759e2bd7..6358daffd8 100644 --- a/resources/views/emails/checkin-asset.blade.php +++ b/resources/views/emails/checkin-asset.blade.php @@ -25,6 +25,36 @@ @endif + @if (isset($manufacturer_name)) + + + {{ trans('general.manufacturer') }} + + + {{ $manufacturer_name }} + + + @endif + @if (isset($model_name)) + + + {{ trans('general.model_no') }}: + + + {{ $model_name }} + + + @endif + @if (isset($model_number)) + + + {{ trans('general.asset_model') }}: + + + {{ $model_number }} + + + @endif {{ trans('mail.checkin_date') }} @@ -45,5 +75,5 @@ @endif -

{{ $snipeSettings->site_name }}

+

{{ $snipeSettings->site_name }}

@stop diff --git a/resources/views/emails/expiring-assets-report.blade.php b/resources/views/emails/expiring-assets-report.blade.php index cd331bd29b..d4006b76a1 100644 --- a/resources/views/emails/expiring-assets-report.blade.php +++ b/resources/views/emails/expiring-assets-report.blade.php @@ -17,5 +17,5 @@ {!! $email_content !!} - +

{{ $snipeSettings->site_name }}

@stop diff --git a/resources/views/emails/expiring-licenses-report.blade.php b/resources/views/emails/expiring-licenses-report.blade.php index 7b8becd826..b032d7c356 100755 --- a/resources/views/emails/expiring-licenses-report.blade.php +++ b/resources/views/emails/expiring-licenses-report.blade.php @@ -14,5 +14,5 @@ {!! $email_content !!} - +

{{ $snipeSettings->site_name }}

@stop diff --git a/resources/views/emails/forgot-password.blade.php b/resources/views/emails/forgot-password.blade.php index 633d26df79..5ab341881a 100755 --- a/resources/views/emails/forgot-password.blade.php +++ b/resources/views/emails/forgot-password.blade.php @@ -9,5 +9,5 @@

{{ trans('mail.best_regards') }}

-

{{ $snipeSettings->site_name }}

+

{{ $snipeSettings->site_name }}

@stop diff --git a/resources/views/emails/low-inventory.blade.php b/resources/views/emails/low-inventory.blade.php index 5b188cc320..e7f2191fee 100644 --- a/resources/views/emails/low-inventory.blade.php +++ b/resources/views/emails/low-inventory.blade.php @@ -27,5 +27,6 @@ +

{{ $snipeSettings->site_name }}

@stop diff --git a/resources/views/emails/register-activate.blade.php b/resources/views/emails/register-activate.blade.php index 92091902ba..cc0b5d8fc7 100755 --- a/resources/views/emails/register-activate.blade.php +++ b/resources/views/emails/register-activate.blade.php @@ -9,5 +9,5 @@

{{ trans('mail.best_regards') }}

-

{{ $snipeSettings->site_name }}

+

{{ $snipeSettings->site_name }}

@stop diff --git a/resources/views/emails/send-login.blade.php b/resources/views/emails/send-login.blade.php index e2f8b8451e..4f728dec19 100644 --- a/resources/views/emails/send-login.blade.php +++ b/resources/views/emails/send-login.blade.php @@ -12,5 +12,5 @@

{{ trans('mail.best_regards') }}

-

{{ $snipeSettings->site_name }}

+

{{ $snipeSettings->site_name }}

@stop diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index ef2e4c9612..e640d277a0 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -250,27 +250,25 @@ $('.snipe-table').bootstrapTable({ if ((row.available_actions.checkout == true) && (row.user_can_checkout == true) && (!row.assigned_to)) { // case for licenses if (row.next_seat) { - return '{{ trans('general.checkout') }}'; + return '{{ trans('general.checkout') }}'; } else { - return '{{ trans('general.checkout') }}'; + return '{{ trans('general.checkout') }}'; } // The user is allowed to check items out, but the item is not deployable } else if (((row.user_can_checkout == false)) && (row.available_actions.checkout == true) && (!row.assigned_to)) { - return '
{{ trans('general.checkout') }}
'; + return '
{{ trans('general.checkout') }}
'; // The user is allowed to check items in } else if (row.available_actions.checkin == true) { if (row.assigned_to) { - return '{{ trans('general.checkin') }}'; + return '{{ trans('general.checkin') }}'; } else if (row.assigned_pivot_id) { - return '{{ trans('general.checkin') }}'; + return '{{ trans('general.checkin') }}'; } - } else { - - } + } }