From 41a20d8f663696c33ccd42f5085259b3fe93172c Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 12 Aug 2016 17:10:03 -0700 Subject: [PATCH] Tidied up some debugging code, better explanation --- app/Http/Controllers/AssetsController.php | 39 +++++++++++----------- config/version.php | 4 +-- resources/views/hardware/history.blade.php | 37 +++++--------------- resources/views/layouts/default.blade.php | 4 +-- 4 files changed, 32 insertions(+), 52 deletions(-) diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.php index 85321fd15e..d754692f83 100755 --- a/app/Http/Controllers/AssetsController.php +++ b/app/Http/Controllers/AssetsController.php @@ -1099,6 +1099,7 @@ class AssetsController extends Controller // A matching user was found if ($user = $user->first()) { + $item[$asset_tag][$batch_counter]['checkedout_to'] = $user->id; $status['success'][] = 'Found user '.Helper::array_smart_fetch($row, "name").$user_query; @@ -1110,7 +1111,7 @@ class AssetsController extends Controller 'asset_id' => $asset->id, 'asset_type' => 'hardware', 'user_id' => Auth::user()->id, - 'note' => 'Imported by '.Auth::user()->fullName().' from history importer', + 'note' => 'Checkout imported by '.Auth::user()->fullName().' from history importer', 'checkedout_to' => $item[$asset_tag][$batch_counter]['user_id'], 'created_at' => $item[$asset_tag][$batch_counter]['date'], 'action_type' => 'checkout' @@ -1126,6 +1127,7 @@ class AssetsController extends Controller } else { + $item[$asset_tag][$batch_counter]['checkedout_to'] = null; $status['error'][] = 'No matching user for '.Helper::array_smart_fetch($row, "name"); } @@ -1136,33 +1138,32 @@ class AssetsController extends Controller foreach ($item as $key => $asset_batch) { $batch_counter = 0; - echo '
';
-            print_r($asset_batch);
-            echo '
'; - for($x = 0; $x < count($asset_batch); $x++) { + + // Only do this if a matching user was found + if ($asset_batch[$x]['checkedout_to']!='') { $batch_counter++; - if ((count($asset_batch) != 1) && ($batch_counter < count($asset_batch))) { - $checkin_date = date('Y-m-d H:i:s',(strtotime($asset_batch[$x]['date']) - 10)); - Actionlog::firstOrCreate(array( - 'asset_id' => $asset_batch[$x]['asset_id'], - 'asset_type' => 'hardware', - 'user_id' => Auth::user()->id, - 'note' => 'Imported by '.Auth::user()->fullName().' from history importer', - 'checkedout_to' => null, - 'created_at' => $checkin_date, - 'action_type' => 'checkin' - ) - ); + if ((count($asset_batch) != 1) && ($batch_counter < count($asset_batch))) { + + $checkin_date = date('Y-m-d H:i:s',(strtotime($asset_batch[$x]['date']) + 10)); + Actionlog::firstOrCreate(array( + 'asset_id' => $asset_batch[$x]['asset_id'], + 'asset_type' => 'hardware', + 'user_id' => Auth::user()->id, + 'note' => 'Checkin imported by '.Auth::user()->fullName().' from history importer', + 'checkedout_to' => null, + 'created_at' => $checkin_date, + 'action_type' => 'checkin' + ) + ); + } } } - - } return View::make('hardware/history')->with('status',$status); diff --git a/config/version.php b/config/version.php index 4269428b40..0a2444836c 100644 --- a/config/version.php +++ b/config/version.php @@ -1,5 +1,5 @@ 'v3.2.0', - 'hash_version' => 'v3.2.0-53-gfff2bce', + 'app_version' => '3.3.0-beta', + 'hash_version' => '3.3.0-beta-19-g7a0843e', ); diff --git a/resources/views/hardware/history.blade.php b/resources/views/hardware/history.blade.php index 6230853f9a..d48d0ffa40 100644 --- a/resources/views/hardware/history.blade.php +++ b/resources/views/hardware/history.blade.php @@ -31,36 +31,23 @@ @endif

- Upload a CSV that contains asset history. The assets MUST already exist in the system, or they will be skipped. Matching assets for history import happens against the asset tag. + 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 < Settings.

-

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

+

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

-

Date should be the checkin/checkout date. Tag should be the asset tag. Name should be the user's name (firstname lastname). Action should be either checkin or checkout.

- - @if (config('app.lock_passwords')) -

Note: Email notification for users is disabled for this installation.

- @endif +

Date should be the checkout date. Tag should be the asset tag. Name should be the user's name (firstname lastname).

- -
- -
-
+ +
+ +
+ - -
-
-
-
- {{ Form::checkbox('create_users', '1', Input::old('create_users')) }} Create users if they do not exist? -
-
-
@@ -97,14 +84,6 @@
- -
-
-
-
- {{ Form::checkbox('checkin_date', '1', Input::old('checkin_date')) }} If no checkin date info is available, should we generate a checkin right before the next checkout? -
-
diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php index a91470a829..9b119d9374 100644 --- a/resources/views/layouts/default.blade.php +++ b/resources/views/layouts/default.blade.php @@ -420,7 +420,6 @@
  •  
  • - {{ trans('general.new') }} {{ trans('general.bulk_checkout') }} @@ -428,7 +427,8 @@
  • @lang('general.categories')
  • @lang('general.deleted')
  • @lang('general.asset_maintenances')
  • -
  • @lang('general.import')
  • +
  • @lang('general.import')
  • +
  • {{ trans('general.new') }}@lang('general.import-history')
  • @endcan