From a184b4e67cc1267803c51d609ede3071f91c14a1 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 23 Feb 2024 11:40:10 +0000 Subject: [PATCH] Nicer UI for history importer Signed-off-by: snipe --- .../Controllers/Assets/AssetsController.php | 8 +- .../lang/en-US/admin/hardware/general.php | 19 +- resources/views/hardware/history.blade.php | 315 +++++++++--------- 3 files changed, 172 insertions(+), 170 deletions(-) diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index 838b3a44cb2b..0683a54e3a6b 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -737,11 +737,11 @@ public function postImportHistory(Request $request) if ($isCheckinHeaderExplicit) { - //if checkin date header exists, assume that empty or future date is still checked out - //if checkin is before todays date, assume it's checked in and do not assign user ID, if checkin date is in the future or blank, this is the expected checkin date, items is checked out + // if checkin date header exists, assume that empty or future date is still checked out + // if checkin is before today's date, assume it's checked in and do not assign user ID, if checkin date is in the future or blank, this is the expected checkin date, items are checked out - if ((strtotime($checkin_date) > strtotime(Carbon::now())) || (empty($checkin_date)) - ) { + if ((strtotime($checkin_date) > strtotime(Carbon::now())) || (empty($checkin_date))) + { //only do this if item is checked out $asset->assigned_to = $user->id; $asset->assigned_type = User::class; diff --git a/resources/lang/en-US/admin/hardware/general.php b/resources/lang/en-US/admin/hardware/general.php index dd7d74e4337f..f7f8ad4d0680 100644 --- a/resources/lang/en-US/admin/hardware/general.php +++ b/resources/lang/en-US/admin/hardware/general.php @@ -27,20 +27,13 @@ 'undeployable_tooltip' => 'This asset has a status label that is undeployable and cannot be checked out at this time.', 'view' => 'View Asset', 'csv_error' => 'You have an error in your CSV file:', - 'import_text' => ' -

- Upload a CSV that contains asset history. The assets and users MUST already exist in the system, or they will be skipped. Matching assets for history import happens against the asset tag. We will try to find a matching user based on the user\'s name you provide, and the criteria you select below. If you do not select any criteria below, it will simply try to match on the username format you configured in the Admin > General Settings. -

- -

Fields included in the CSV must match the headers: Asset Tag, Name, Checkout Date, Checkin Date. Any additional fields will be ignored.

- -

Checkin Date: blank or future checkin dates will checkout items to associated user. Excluding the Checkin Date column will create a checkin date with todays date.

+ 'import_text' => '

Upload a CSV that contains asset history. The assets and users MUST already exist in the system, or they will be skipped. Matching assets for history import happens against the asset tag. We will try to find a matching user based on the user\'s name you provide, and the criteria you select below. If you do not select any criteria below, it will simply try to match on the username format you configured in the Admin > General Settings.

Fields included in the CSV must match the headers: Asset Tag, Name, Checkout Date, Checkin Date. Any additional fields will be ignored.

Checkin Date: blank or future checkin dates will checkout items to associated user. Excluding the Checkin Date column will create a checkin date with todays date.

', - 'csv_import_match_f-l' => 'Try to match users by firstname.lastname (jane.smith) format', - 'csv_import_match_initial_last' => 'Try to match users by first initial last name (jsmith) format', - 'csv_import_match_first' => 'Try to match users by first name (jane) format', - 'csv_import_match_email' => 'Try to match users by email as username', - 'csv_import_match_username' => 'Try to match users by username', + 'csv_import_match_f-l' => 'Try to match users by firstname.lastname (jane.smith) format', + 'csv_import_match_initial_last' => 'Try to match users by first initial last name (jsmith) format', + 'csv_import_match_first' => 'Try to match users by first name (jane) format', + 'csv_import_match_email' => 'Try to match users by email as username', + 'csv_import_match_username' => 'Try to match users by username', 'error_messages' => 'Error messages:', 'success_messages' => 'Success messages:', 'alert_details' => 'Please see below for details.', diff --git a/resources/views/hardware/history.blade.php b/resources/views/hardware/history.blade.php index 349dc8da382e..a6c0df20f3eb 100644 --- a/resources/views/hardware/history.blade.php +++ b/resources/views/hardware/history.blade.php @@ -44,179 +44,188 @@ @endif -
-
-
-
-
-
- - - - @if (Session::get('message')) -

- {{ trans('admin/hardware/general.csv_error') }}
- {{ Session::get('message') }} -

- @endif - - {!! trans('admin/hardware/general.import_text') !!} - -
- -
- - @if (config('app.lock_passwords')===true) -

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

- @endif -
+
+
+
+
+ + + + +
+ @if (Session::get('message')) +

+ {{ trans('admin/hardware/general.csv_error') }}
+ {{ Session::get('message') }} +

+ @endif +
+
+ {!! trans('admin/hardware/general.import_text') !!}
+
+
+
+ + + @if (config('app.lock_passwords')===true) +

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

+ @endif +
+
+
- -
-
-
-
- {{ Form::checkbox('match_firstnamelastname', '1', Request::old('match_firstnamelastname')) }} {{ trans('admin/hardware/general.csv_import_match_f-l') }} -
-
- - -
-
-
-
- {{ Form::checkbox('match_flastname', '1', Request::old('match_flastname')) }} {{ trans('admin/hardware/general.csv_import_match_initial_last') }} -
-
+
+ +
+
+ +
+
- -
-
-
-
- {{ Form::checkbox('match_firstname', '1', Request::old('match_firstname')) }} {{ trans('admin/hardware/general.csv_import_match_first') }} -
-
+ +
+
+ +
+
- -
-
-
-
- {{ Form::checkbox('match_email', '1', Request::old('match_email')) }} {{ trans('admin/hardware/general.csv_import_match_email') }} -
-
+ +
+
+ +
+
- -
-
-
-
- {{ Form::checkbox('match_username', '1', Request::old('match_username')) }} {{ trans('admin/hardware/general.csv_import_match_username') }} -
-
+ +
+
+ +
+
-
+ +
+
+ +
+
+ + + @else + + @endif +
- - +
- +@if (isset($status)) -
- @if (isset($status)) +@if (count($status['error']) > 0) +
+
+
+
+

{{ count($status['error']) }} {{ trans('admin/hardware/general.error_messages') }}

+
+
+
+ + @for ($x = 0; $x < count($status['error']); $x++) + @foreach($status['error'][$x] as $object_type => $message) + + + + + @endforeach + @endfor +
{{ ucwords($object_type) }} {{ key($message) }}:{{ $message[key($message)]['msg'] }}
+
+
+
+
+
+@endif - @if (count($status['error']) > 0) -
-
-
-
-

{{ count($status['error']) }} {{ trans('admin/hardware/general.error_messages') }}

-
-
-
- - @for ($x = 0; $x < count($status['error']); $x++) - @foreach($status['error'][$x] as $object_type => $message) - - - - - @endforeach - @endfor -
{{ ucwords($object_type) }} {{ key($message) }}:{{ $message[key($message)]['msg'] }}
-
-
-
-
+@if (count($status['success']) > 0) +
+
+
+
+

{{ count($status['success']) }} {{ trans('admin/hardware/general.success_messages') }}

+
+
+
+ + @for ($x = 0; $x < count($status['success']); $x++) + @foreach($status['success'][$x] as $object_type => $message) + + + + + @endforeach + @endfor +
{{ ucwords($object_type) }} {{ key($message) }}:{{ $message[key($message)]['msg'] }}
+
+
+
+
+@endif +@endif - @endif +
+
+
- @if (count($status['success']) > 0) -
-
-
-
-

{{ count($status['success']) }} {{ trans('admin/hardware/general.success_messages') }}

-
-
-
- - @for ($x = 0; $x < count($status['success']); $x++) - @foreach($status['success'][$x] as $object_type => $message) - - - - - @endforeach - @endfor -
{{ ucwords($object_type) }} {{ key($message) }}:{{ $message[key($message)]['msg'] }}
-
-
-
-
-
- @endif - @endif - -
- @stop