diff --git a/app/Http/Controllers/LocationsController.php b/app/Http/Controllers/LocationsController.php index 7dc56e9b96..3457e115f9 100755 --- a/app/Http/Controllers/LocationsController.php +++ b/app/Http/Controllers/LocationsController.php @@ -253,23 +253,41 @@ class LocationsController extends Controller $this->authorize('view', Location::class); if ($location = Location::where('id', $id)->first()) { - $parent = Location::where('id', $location->parent_id)->first(); - $manager = User::where('id', $location->manager_id)->first(); - $company = Company::where('id', $location->company_id)->first(); - $users = User::where('location_id', $id)->with('company', 'department', 'location')->get(); - $assets = Asset::where('assigned_to', $id)->where('assigned_type', Location::class)->with('model', 'model.category')->get(); return view('locations/print') - ->with('assets', $assets) - ->with('users',$users) + ->with('assigned', false) + ->with('assets', $location->assets) + ->with('assignedAssets', $location->assignedAssets) + ->with('accessories', $location->accessories) + ->with('assignedAccessories', $location->assignedAccessories) + ->with('users',$location->users) ->with('location', $location) - ->with('parent', $parent) - ->with('manager', $manager) - ->with('company', $company); + ->with('consumables', $location->consumables) + ->with('components', $location->components) + ->with('children', $location->children); } return redirect()->route('locations.index')->with('error', trans('admin/locations/message.does_not_exist')); } + public function print_all_assigned($id) : View | RedirectResponse + { + $this->authorize('view', Location::class); + if ($location = Location::where('id', $id)->first()) { + return view('locations/print') + ->with('assigned', true) + ->with('assets', $location->assets) + ->with('assignedAssets', $location->assignedAssets) + ->with('accessories', $location->accessories) + ->with('assignedAccessories', $location->assignedAccessories) + ->with('users',$location->users) + ->with('location', $location) + ->with('consumables', $location->consumables) + ->with('components', $location->components) + ->with('children', $location->children); + } + return redirect()->route('locations.index')->with('error', trans('admin/locations/message.does_not_exist')); + } + /** * Returns a view that presents a form to clone a location. @@ -333,26 +351,6 @@ class LocationsController extends Controller return redirect()->back()->with('error', trans('admin/models/message.does_not_exist')); } - public function print_all_assigned($id) : View | RedirectResponse - { - $this->authorize('view', Location::class); - if ($location = Location::where('id', $id)->first()) { - $parent = Location::where('id', $location->parent_id)->first(); - $manager = User::where('id', $location->manager_id)->first(); - $company = Company::where('id', $location->company_id)->first(); - $users = User::where('location_id', $id)->with('company', 'department', 'location')->get(); - $assets = Asset::where('location_id', $id)->with('model', 'model.category')->get(); - return view('locations/print') - ->with('assets', $assets) - ->with('users',$users) - ->with('location', $location) - ->with('parent', $parent) - ->with('manager', $manager) - ->with('company', $company); - } - return redirect()->route('locations.index')->with('error', trans('admin/locations/message.does_not_exist')); - } - /** * Returns a view that allows the user to bulk delete locations diff --git a/resources/lang/en-US/admin/locations/table.php b/resources/lang/en-US/admin/locations/table.php index 53176d8a4e..d7128b30f7 100644 --- a/resources/lang/en-US/admin/locations/table.php +++ b/resources/lang/en-US/admin/locations/table.php @@ -12,7 +12,8 @@ return [ 'create' => 'Create Location', 'update' => 'Update Location', 'print_assigned' => 'Print Assigned', - 'print_all_assigned' => 'Print All Assigned', + 'print_inventory' => 'Print Inventory', + 'print_all_assigned' => 'Print Inventory and Assigned', 'name' => 'Location Name', 'address' => 'Address', 'address2' => 'Address Line 2', diff --git a/resources/lang/en-US/admin/models/table.php b/resources/lang/en-US/admin/models/table.php index 11a512b3d3..20af866dde 100644 --- a/resources/lang/en-US/admin/models/table.php +++ b/resources/lang/en-US/admin/models/table.php @@ -11,7 +11,6 @@ return array( 'title' => 'Asset Models', 'update' => 'Update Asset Model', 'view' => 'View Asset Model', - 'update' => 'Update Asset Model', - 'clone' => 'Clone Model', - 'edit' => 'Edit Model', + 'clone' => 'Clone Model', + 'edit' => 'Edit Model', ); diff --git a/resources/lang/en-US/general.php b/resources/lang/en-US/general.php index 3516203331..a57c7c9f3a 100644 --- a/resources/lang/en-US/general.php +++ b/resources/lang/en-US/general.php @@ -614,6 +614,7 @@ return [ 'footer_credit' => 'Snipe-IT is open source software, made with love by @snipeitapp.com.', 'set_password' => 'Set a Password', 'upload_deleted' => 'Upload Deleted', + 'child_locations' => 'Child Locations', // Add form placeholders here 'placeholders' => [ diff --git a/resources/views/locations/print.blade.php b/resources/views/locations/print.blade.php index 6f383468b2..76f8b175e9 100644 --- a/resources/views/locations/print.blade.php +++ b/resources/views/locations/print.blade.php @@ -49,107 +49,359 @@ @endif @endif -

{{ trans('general.assigned_to', array('name' => $location->display_name)) }}

- @if ($parent) - {{ $parent->display_name }} +

+ @if ($assigned) + {{ trans('general.assigned_to', array('name' => $location->display_name)) }} + @else + {{ trans('admin/locations/table.print_inventory') }} : {{ $location->display_name }} @endif +

+ @if ($location->parent) + {{ trans('admin/locations/table.parent') }}: {{ $location->parent->display_name }} +@endif
-@if ($company) - {{ trans('admin/companies/table.name') }}: {{ $company->display_name }} +@if ($location->company) +{{ trans('admin/companies/table.name') }}: {{ $location->company->display_name }}
@endif -@if ($manager) - {{ trans('general.manager') }} {{ $manager->display_name }}
+@if ($location->manager) +{{ trans('admin/users/table.manager') }}: {{ $location->manager->display_name }}
@endif -{{ trans('general.date') }} {{ \App\Helpers\Helper::getFormattedDateObject(now(), 'datetime', false) }}

+{{ trans('general.date') }}: {{ \App\Helpers\Helper::getFormattedDateObject(now(), 'datetime', false) }}

@if ($users->count() > 0) - @php - $counter = 1; - @endphp - - +@php + $counter = 1; +@endphp +
+ + + + + + - + + + + + + - - - - - - - - - - - - @foreach ($users as $user) + +@foreach ($users as $user) - - - - - - - - - @php - $counter++ - @endphp - @endforeach -
{{ trans('general.users') }}
{{ trans('general.users') }}{{ trans('general.company') }}{{ trans('admin/locations/table.user_name') }}{{ trans('general.employee_number') }}{{ trans('admin/locations/table.department') }}{{ trans('admin/locations/table.location') }}
{{ trans('general.company') }}{{ trans('admin/locations/table.user_name') }}{{ trans('general.employee_number') }}{{ trans('admin/locations/table.department') }}{{ trans('admin/locations/table.location') }}
{{ $counter }}{{ (($user) && ($user->company)) ? $user->company->name : '' }}{{ ($user) ? $user->first_name .' '. $user->last_name : '' }}{{ ($user) ? $user->employee_num : '' }}{{ (($user) && ($user->department)) ? $user->department->name : '' }}{{ (($user) && ($user->location)) ? $user->location->name : '' }}
+ + {{ $counter }} + {{ (($user) && ($user->company)) ? $user->company->name : '' }} + {{ ($user) ? $user->first_name .' '. $user->last_name : '' }} + {{ ($user) ? $user->employee_num : '' }} + {{ (($user) && ($user->department)) ? $user->department->name : '' }} + {{ (($user) && ($user->location)) ? $user->location->name : '' }} + + @php + $counter++ + @endphp +@endforeach + @endif - - -@if ($assets->count() > 0) +@if ($children->count() > 0)

- + - - - - - - - - - - - - - - @php - $counter = 1; - @endphp - - @foreach ($assets as $asset) - @php - if($snipeSettings->show_archived_in_list != 1 && $asset->assetstatus?->archived == 1){ - continue; - } - @endphp - - - - - - - - - - + + + + + + + + + + @php + $counter = 1; + @endphp + + @foreach ($children as $child) + + + + + + + + + @php $counter++ @endphp - @endforeach + @endforeach +
{{ trans('general.assets') }}{{ trans('general.child_locations') }}
{{ trans('admin/locations/table.asset_tag') }}{{ trans('admin/locations/table.asset_name') }}{{ trans('admin/locations/table.asset_category') }}{{ trans('admin/locations/table.asset_manufacturer') }}{{ trans('admin/locations/table.asset_model') }}{{ trans('admin/locations/table.asset_serial') }}{{ trans('admin/locations/table.asset_location') }}{{ trans('admin/locations/table.asset_checked_out') }}{{ trans('admin/locations/table.asset_expected_checkin') }}
{{ $counter }}{{ $asset->asset_tag }}{{ $asset->name }}{{ (($asset->model) && ($asset->model->category)) ? $asset->model->category->name : '' }}{{ (($asset->model) && ($asset->model->manufacturer)) ? $asset->model->manufacturer->name : '' }}{{ ($asset->model) ? $asset->model->name : '' }}{{ $asset->serial }}{{ ($asset->location) ? $asset->location->name : '' }}{{ \App\Helpers\Helper::getFormattedDateObject( $asset->last_checkout, 'datetime', false) }}{{ \App\Helpers\Helper::getFormattedDateObject( $asset->expected_checkin, 'datetime', false) }}{{ trans('general.name') }}{{ trans('general.address') }}{{ trans('general.city') }}{{ trans('general.state') }}{{ trans('general.country') }}{{ trans('general.zip') }}
{{ $counter }}{{ $child->name }}{{ $child->address }}{{ $child->city }}{{ $child->state }}{{ $child->country }}{{ $child->zip }}
+@endif + +@if ($assets->count() > 0) +

+ + + + + + + + + + + + + + + + + + + + + @php + $counter = 1; + @endphp + + @foreach ($assets as $asset) + @php + if($snipeSettings->show_archived_in_list != 1 && $asset->assetstatus?->archived == 1){ + continue; + } + @endphp + + + + + + + + + + + + + @php + $counter++ + @endphp +@endforeach +
{{ trans('general.assets') }}
{{ trans('admin/locations/table.asset_tag') }}{{ trans('admin/locations/table.asset_name') }}{{ trans('admin/locations/table.asset_category') }}{{ trans('admin/locations/table.asset_manufacturer') }}{{ trans('admin/locations/table.asset_model') }}{{ trans('admin/locations/table.asset_serial') }}{{ trans('admin/locations/table.asset_location') }}{{ trans('admin/locations/table.asset_checked_out') }}{{ trans('admin/locations/table.asset_expected_checkin') }}
{{ $counter }}{{ $asset->asset_tag }}{{ $asset->name }}{{ (($asset->model) && ($asset->model->category)) ? $asset->model->category->name : '' }}{{ (($asset->model) && ($asset->model->manufacturer)) ? $asset->model->manufacturer->name : '' }}{{ ($asset->model) ? $asset->model->name : '' }}{{ $asset->serial }}{{ ($asset->location) ? $asset->location->name : '' }}{{ \App\Helpers\Helper::getFormattedDateObject( $asset->last_checkout, 'datetime', false) }}{{ \App\Helpers\Helper::getFormattedDateObject( $asset->expected_checkin, 'datetime', false) }}
+@endif + +@if ($assigned) + @if ($assignedAssets->count() > 0) +

+ + + + + + + + + + + + + + + + + + + + + @php + $counter = 1; + @endphp + + @foreach ($assignedAssets as $asset) + @php + if($snipeSettings->show_archived_in_list != 1 && $asset->assetstatus?->archived == 1){ + continue; + } + @endphp + + + + + + + + + + + + + @php + $counter++ + @endphp + @endforeach +
{{ trans('admin/locations/message.assigned_assets') }}
{{ trans('admin/locations/table.asset_tag') }}{{ trans('admin/locations/table.asset_name') }}{{ trans('admin/locations/table.asset_category') }}{{ trans('admin/locations/table.asset_manufacturer') }}{{ trans('admin/locations/table.asset_model') }}{{ trans('admin/locations/table.asset_serial') }}{{ trans('admin/locations/table.asset_location') }}{{ trans('admin/locations/table.asset_checked_out') }}{{ trans('admin/locations/table.asset_expected_checkin') }}
{{ $counter }}{{ $asset->asset_tag }}{{ $asset->name }}{{ (($asset->model) && ($asset->model->category)) ? $asset->model->category->name : '' }}{{ (($asset->model) && ($asset->model->manufacturer)) ? $asset->model->manufacturer->name : '' }}{{ ($asset->model) ? $asset->model->name : '' }}{{ $asset->serial }}{{ ($asset->location) ? $asset->location->name : '' }}{{ \App\Helpers\Helper::getFormattedDateObject( $asset->last_checkout, 'datetime', false) }}{{ \App\Helpers\Helper::getFormattedDateObject( $asset->expected_checkin, 'datetime', false) }}
+ @endif +@endif + +@if ($accessories->count() > 0) +

+ + + + + + + + + + + + + + + + + @php + $counter = 1; + @endphp + + @foreach ($accessories as $accessory) + + + + + + + + + @php + $counter++ + @endphp + @endforeach +
{{ trans('general.accessories') }}
{{ trans('admin/locations/table.asset_name') }}{{ trans('admin/locations/table.asset_category') }}{{ trans('admin/locations/table.asset_manufacturer') }}{{ trans('admin/models/table.modelnumber') }}{{ trans('admin/locations/table.asset_location') }}
{{ $counter }}{{ $accessory->name }}{{ ($accessory->category) ? $accessory->category->name : '' }}{{ ($accessory->manufacturer) ? $accessory->manufacturer->name : '' }}{{ $asset->model_number }}{{ ($asset->location) ? $asset->location->name : '' }}
+@endif + +@if ($assigned) + @if ($assignedAccessories->count() > 0) +

+ + + + + + + + + + + + + + + + + @php + $counter = 1; + @endphp + + @foreach ($assignedAccessories as $accessory) + + + + + + + + + @php + $counter++ + @endphp + @endforeach +
{{ trans('general.accessories_assigned') }}
{{ trans('admin/locations/table.asset_name') }}{{ trans('admin/locations/table.asset_category') }}{{ trans('admin/locations/table.asset_manufacturer') }}{{ trans('admin/models/table.modelnumber') }}{{ trans('admin/locations/table.asset_location') }}
{{ $counter }}{{ $accessory->name }}{{ ($accessory->category) ? $accessory->category->name : '' }}{{ ($accessory->manufacturer) ? $accessory->manufacturer->name : '' }}{{ $asset->model_number }}{{ ($asset->location) ? $asset->location->name : '' }}
+ @endif +@endif + +@if ($consumables->count() > 0) +

+ + + + + + + + + + + + + + + + + @php + $counter = 1; + @endphp + + @foreach ($consumables as $consumable) + + + + + + + + + @php + $counter++ + @endphp + @endforeach +
{{ trans('general.accessories') }}
{{ trans('admin/locations/table.asset_name') }}{{ trans('general.qty') }}{{ trans('admin/locations/table.asset_category') }}{{ trans('admin/locations/table.asset_manufacturer') }}{{ trans('admin/models/table.modelnumber') }}
{{ $counter }}{{ $consumable->name }}{{ $consumable->qty }}{{ ($consumable->category) ? $consumable->category->name : '' }}{{ ($consumable->manufacturer) ? $consumable->manufacturer->name : '' }}{{ $consumable->model_number }}
+@endif + +@if ($components->count() > 0) +

+ + + + + + + + + + + + + + + + + @php + $counter = 1; + @endphp + + @foreach ($components as $component) + + + + + + + + + @php + $counter++ + @endphp + @endforeach
{{ trans('general.components') }}
{{ trans('admin/locations/table.asset_name') }}{{ trans('general.qty') }}{{ trans('admin/locations/table.asset_category') }}{{ trans('admin/locations/table.asset_manufacturer') }}{{ trans('admin/models/table.modelnumber') }}
{{ $counter }}{{ $component->name }}{{ $component->qty }}{{ ($component->category) ? $component->category->name : '' }}{{ ($component->manufacturer) ? $component->manufacturer->name : '' }}{{ $component->model_number }}
@endif @@ -157,26 +409,26 @@

- - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + +
{{ trans('admin/locations/table.signed_by_asset_auditor') }}
------------------------------------------------------    
{{ trans('admin/locations/table.date') }}
------------------------------    
{{ trans('admin/locations/table.signed_by_asset_auditor') }}
------------------------------------------------------    
{{ trans('admin/locations/table.date') }}
------------------------------    
{{ trans('admin/locations/table.signed_by_finance_auditor') }}
------------------------------------------------------    
{{ trans('admin/locations/table.date') }}
------------------------------    
{{ trans('admin/locations/table.signed_by_finance_auditor') }}
------------------------------------------------------    
{{ trans('admin/locations/table.date') }}
------------------------------    
{{ trans('admin/locations/table.signed_by_location_manager') }}
------------------------------------------------------    
{{ trans('admin/locations/table.date') }}
------------------------------    
{{ trans('admin/locations/table.signed_by_location_manager') }}
------------------------------------------------------    
{{ trans('admin/locations/table.date') }}
------------------------------    
diff --git a/resources/views/locations/view.blade.php b/resources/views/locations/view.blade.php index 2f13a804d6..f912e921a4 100644 --- a/resources/views/locations/view.blade.php +++ b/resources/views/locations/view.blade.php @@ -42,7 +42,7 @@ {{ trans('general.users') }} - {!! ($location->users->count() > 0) ? ''.number_format($location->users->count()).'' : '' !!} + {!! ($location->users()->count() > 0) ? ''.number_format($location->users()->count()).'' : '' !!} @endcan @@ -83,7 +83,7 @@
  • - {!! ($location->accessories->count() > 0) ? ''.number_format($location->accessories->count()).'' : '' !!} + {!! ($location->accessories()->count() > 0) ? ''.number_format($location->accessories()->count()).'' : '' !!} {{ trans('general.accessories') }} @@ -93,7 +93,7 @@
  • - {!! ($location->assignedAccessories->count() > 0) ? ''.number_format($location->assignedAccessories->count()).'' : '' !!} + {!! ($location->assignedAccessories()->count() > 0) ? ''.number_format($location->assignedAccessories()->count()).'' : '' !!} {{ trans('general.accessories_assigned') }} @@ -106,7 +106,7 @@
  • - {!! ($location->consumables->count() > 0) ? ''.number_format($location->consumables->count()).'' : '' !!} + {!! ($location->consumables()->count() > 0) ? ''.number_format($location->consumables->count()).'' : '' !!} {{ trans('general.consumables') }} @@ -118,7 +118,7 @@
  • - {!! ($location->components->count() > 0) ? ''.number_format($location->components->count()).'' : '' !!} + {!! ($location->components->count() > 0) ? ''.number_format($location->components()->count()).'' : '' !!} {{ trans('general.components') }} @@ -126,6 +126,18 @@
  • @endcan +
  • + + + +
  • +
  • @@ -137,11 +149,15 @@ {{ trans('general.files') }} - {!! ($location->uploads->count() > 0 ) ? ''.number_format($location->uploads->count()).'' : '' !!} + {!! ($location->uploads()->count() > 0 ) ? ''.number_format($location->uploads()->count()).'' : '' !!}
  • + + + +
  • @@ -350,16 +366,53 @@ -
    - -
    -
    - -
    -
    - +
    +
    +

    + {{ trans('general.child_locations') }} +

    + +
    +
    +
    +

    + {{ trans('general.accessories_assigned') }} +

    + + +
    +
    +

    {{ trans('general.history') }}

    @@ -424,16 +477,16 @@
  • {{ $location->city }} {{ $location->state }} {{ $location->zip }}
  • @endif @if ($location->manager) -
  • {{ trans('admin/users/table.manager') }}: {!! $location->manager->present()->nameUrl() !!}
  • +
  • {{ trans('admin/users/table.manager') }}: {!! $location->manager->present()->nameUrl() !!}
  • @endif @if ($location->company) -
  • {{ trans('admin/companies/table.name') }}: {!! $location->company->present()->nameUrl() !!}
  • +
  • {{ trans('admin/companies/table.name') }}: {!! $location->company->present()->nameUrl() !!}
  • @endif @if ($location->parent) -
  • {{ trans('admin/locations/table.parent') }}: {!! $location->parent->present()->nameUrl() !!}
  • +
  • {{ trans('admin/locations/table.parent') }}: {!! $location->parent->present()->nameUrl() !!}
  • @endif @if ($location->ldap_ou) -
  • {{ trans('admin/locations/table.ldap_ou') }}: {{ $location->ldap_ou }}
  • +
  • {{ trans('admin/locations/table.ldap_ou') }}: {{ $location->ldap_ou }}
  • @endif @@ -476,7 +529,7 @@
    - {{ trans('admin/locations/table.print_assigned') }} + {{ trans('admin/locations/table.print_inventory') }}