diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.php index bf19d97bd0..bc06f59e90 100755 --- a/app/Http/Controllers/AssetsController.php +++ b/app/Http/Controllers/AssetsController.php @@ -687,6 +687,34 @@ class AssetsController extends Controller return View::make('hardware/import'); } + + /** + * Map the fields for import + * + * @author [A. Gianotto] [] + * @since [v4.0] + * @return View + */ + public function getImportMap() + { + + $this->authorize('create', Asset::class); + + // This is currently hardcoded for testing - should use a post variable or something to dynamically select the correct file. + $file = storage_path().'/private_uploads/imports/2017-06-08-072329-sample-assets.csv'; + $reader = Reader::createFromPath($file); + $header_rows = $reader->fetchOne(0); + + // Grab the first row to display via ajax as the user picks fields + $first_row = $reader->fetchOne(1); + + // Grab all of the custom fields to we can map those too. + $custom_fields = CustomField::all(); + + return View::make('importer/fieldmapper')->with('header_rows', $header_rows)->with('first_row',$first_row)->with('custom_fields',$custom_fields); + } + + /** * Process the uploaded file * diff --git a/resources/macros/macros.php b/resources/macros/macros.php index 3981183435..3936a31165 100644 --- a/resources/macros/macros.php +++ b/resources/macros/macros.php @@ -518,3 +518,22 @@ Form::macro('customfield_elements', function ($name = "customfield_elements", $s return $select; }); + + + + +Form::macro('header_list', function ($headers = null, $name = "header_list", $selected = null, $class = null) { + + + $select = ''; + + return $select; + +}); diff --git a/resources/views/importer/fieldmapper.blade.php b/resources/views/importer/fieldmapper.blade.php new file mode 100644 index 0000000000..72f614ccdb --- /dev/null +++ b/resources/views/importer/fieldmapper.blade.php @@ -0,0 +1,233 @@ +@extends('layouts.default') + +{{-- Page title --}} +@section('title') + Map Import Fields + @parent +@stop + +@section('header_right') + + {{ trans('general.back') }} +@stop + + + +{{-- Page content --}} + +@section('content') + +
+
+
+
+

+ +

+ @if (isset($helpText)) +
+ +
+ @endif +
+ +
+
+ + + {{ csrf_field() }} + +
+                            @php
+                            print_r($first_row);
+                            @endphp
+                        
+ +
+

Standard Fields

+
+
+ +
+ +
+ {!! Form::header_list($header_rows, 'user_name_header', Input::old('header_row'), 'select2') !!} +
+
+ +
+ +
+ {!! Form::header_list($header_rows, 'username_header', Input::old('header_row'), 'select2') !!} +
+
+ + +
+ +
+ {!! Form::header_list($header_rows, 'email_header', Input::old('header_row'), 'select2') !!} +
+
+ + +
+ +
+ {!! Form::header_list($header_rows, 'item_name_header', Input::old('header_row'), 'select2') !!} +
+
+ + +
+ +
+ {!! Form::header_list($header_rows, 'asset_tag_header', Input::old('header_row'), 'select2') !!} +
+
+ +
+ +
+ {!! Form::header_list($header_rows, 'serial_number_header', Input::old('header_row'), 'select2') !!} +
+
+ +
+ +
+ {!! Form::header_list($header_rows, 'model_name_header', Input::old('header_row'), 'select2') !!} +
+
+ + +
+ +
+ {!! Form::header_list($header_rows, 'model_number_header', Input::old('header_row'), 'select2') !!} +
+
+ + +
+ +
+ {!! Form::header_list($header_rows, 'category_header', Input::old('header_row'), 'select2') !!} +
+
+ +
+ +
+ {!! Form::header_list($header_rows, 'manufacturer_header', Input::old('header_row'), 'select2') !!} +
+
+ + +
+ +
+ {!! Form::header_list($header_rows, 'company_header', Input::old('header_row'), 'select2') !!} +
+
+ +
+ +
+ {!! Form::header_list($header_rows, 'location_header', Input::old('header_row'), 'select2') !!} +
+
+ +
+ +
+ {!! Form::header_list($header_rows, 'purchase_date_header', Input::old('header_row'), 'select2') !!} +
+
+ +
+ +
+ {!! Form::header_list($header_rows, 'purchase_cost_header', Input::old('header_row'), 'select2') !!} +
+
+ +
+ +
+ {!! Form::header_list($header_rows, 'status_header', Input::old('header_row'), 'select2') !!} +
+
+ +
+ +
+ {!! Form::header_list($header_rows, 'notes_header', Input::old('header_row'), 'select2') !!} +
+
+ +
+ +
+ {!! Form::header_list($header_rows, 'image_header', Input::old('header_row'), 'select2') !!} +
+
+ + @if ($custom_fields->count() > 0) +
+

Custom Fields

+
+
+ @foreach ($custom_fields as $custom_field) +
+ +
+ {!! Form::header_list($header_rows, 'image_header', Input::old('header_row'), 'select2') !!} +
+
+ @endforeach + @endif + + + + + +
+
+
+
+ + @if ((isset($helpText)) && (isset($helpTitle))) +
+ × +

+ {{ $helpTitle}} +

+

{{ $helpText }}

+
+ @endif +
+ +@stop + diff --git a/resources/views/settings/edit.blade.php b/resources/views/settings/edit.blade.php index 6f43a8a738..db2468be4e 100755 --- a/resources/views/settings/edit.blade.php +++ b/resources/views/settings/edit.blade.php @@ -1,4 +1,4 @@ -@extends('layouts/default') +two@extends('layouts/default') {{-- Page title --}} @section('title') diff --git a/routes/web/hardware.php b/routes/web/hardware.php index 3b976e928b..e26b739038 100644 --- a/routes/web/hardware.php +++ b/routes/web/hardware.php @@ -87,6 +87,11 @@ Route::group( 'uses' => 'AssetsController@getDeleteImportFile' ]); + Route::get('import/map',[ + 'as' => 'import.map', + 'uses' => 'AssetsController@getImportMap' + ]); + Route::get('import',[ 'as' => 'assets/import', 'uses' => 'AssetsController@getImportUpload'