From 8b4a9aa3824cff758b01e71f39fda43c0113f12d Mon Sep 17 00:00:00 2001
From: snipe
Date: Tue, 13 Aug 2019 18:15:42 -0700
Subject: [PATCH] Fixes to history importer
---
app/Http/Controllers/AssetsController.php | 8 ++++++--
resources/views/hardware/history.blade.php | 3 +--
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.php
index d237420328..20f3a22854 100755
--- a/app/Http/Controllers/AssetsController.php
+++ b/app/Http/Controllers/AssetsController.php
@@ -597,7 +597,9 @@ class AssetsController extends Controller
}
$batch_counter = count($item[$asset_tag]);
- $item[$asset_tag][$batch_counter]['checkout_date'] = Carbon::parse(Helper::array_smart_fetch($row, "date"))->format('Y-m-d H:i:s');
+ $item[$asset_tag][$batch_counter]['checkout_date'] = Carbon::parse(Helper::array_smart_fetch($row, "checkout date"))->format('Y-m-d H:i:s');
+ $item[$asset_tag][$batch_counter]['checkin_date'] = Carbon::parse(Helper::array_smart_fetch($row, "checkin date"))->format('Y-m-d H:i:s');
+ \Log::debug($item[$asset_tag][$batch_counter]['checkin_date']);
$item[$asset_tag][$batch_counter]['asset_tag'] = Helper::array_smart_fetch($row, "asset tag");
$item[$asset_tag][$batch_counter]['name'] = Helper::array_smart_fetch($row, "name");
@@ -680,9 +682,11 @@ class AssetsController extends Controller
// Only do this if a matching user was found
if ((array_key_exists('checkedout_to', $asset_batch[$x])) && ($asset_batch[$x]['checkedout_to']!='')) {
if (($total_in_batch > 1) && ($x < $total_in_batch) && (array_key_exists($next, $asset_batch))) {
- $checkin_date = Carbon::parse($asset_batch[$next]['checkout_date'])->subDay(1)->format('Y-m-d H:i:s');
+ $checkin_date = Carbon::parse($asset_batch[$next]['checkin_date'])->format('Y-m-d H:i:s');
$asset_batch[$x]['real_checkin'] = $checkin_date;
+ \Log::debug($asset_batch[$next]['checkin_date']);
+ \Log::debug($checkin_date);
Actionlog::firstOrCreate(array(
'item_id' => $asset_batch[$x]['asset_id'],
'item_type' => Asset::class,
diff --git a/resources/views/hardware/history.blade.php b/resources/views/hardware/history.blade.php
index 92f38a269c..5204823566 100644
--- a/resources/views/hardware/history.blade.php
+++ b/resources/views/hardware/history.blade.php
@@ -64,9 +64,8 @@
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: Date, Tag, Name. Any additional fields will be ignored.
+ Fields included in the CSV must match the headers: Asset Tag, Checkout Date, Checkin Date, Name. Any additional fields will be ignored.
- Date should be the checkout date. Tag should be the asset tag. Name should be the user's name (firstname lastname).
History should be ordered by date in ascending order.