Skip to content

Firefly III: a personal finances manager

Basic for for #262

James Colea447c886c447
diff --git a/app/Http/Controllers/ImportController.php b/app/Http/Controllers/ImportController.php
new file mode 100644
index 0000000000..0319bdb87f
--- /dev/null
+++ b/app/Http/Controllers/ImportController.php
@@ -0,0 +1,41 @@
+<?php
+
+namespace FireflyIII\Http\Controllers;
+
+use FireflyIII\Http\Requests;
+use View;
+
+/**
+ * Class ImportController
+ *
+ * @package FireflyIII\Http\Controllers
+ */
+class ImportController extends Controller
+{
+ /**
+ *
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ View::share('mainTitleIcon', 'fa-archive');
+ View::share('title', trans('firefly.import_data'));
+ }
+
+ /**
+ * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ */
+ public function index()
+ {
+ $subTitle = trans('firefly.import_data_index');
+ $subTitleIcon = 'fa-home';
+ $importFileTypes = [];
+ $defaultImportType = config('firefly.default_import_format');
+
+ foreach (array_keys(config('firefly.import_formats')) as $type) {
+ $importFileTypes[$type] = trans('firefly.import_file_type_' . $type);
+ }
+
+ return view('import.index', compact('subTitle', 'subTitleIcon', 'importFileTypes', 'defaultImportType'));
+ }
+}
diff --git a/app/Http/routes.php b/app/Http/routes.php
index f51ea854a8..e5e0fe4085 100644
--- a/app/Http/routes.php
+++ b/app/Http/routes.php
@@ -220,6 +220,11 @@ Route::group(
Route::get('/chart/report/in-out-sum/{reportType}/{start_date}/{end_date}/{accountList}', ['uses' => 'Chart\ReportController@yearInOutSummarized']);
Route::get('/chart/report/net-worth/{reportType}/{start_date}/{end_date}/{accountList}', ['uses' => 'Chart\ReportController@netWorth']);
+ /**
+ * IMPORT CONTROLLER
+ */
+ Route::get('/import', ['uses' => 'ImportController@index','as' => 'import.index']);
+ Route::post('/import/upload', ['uses' => 'ImportController@upload','as' => 'import.upload']);
/**
* Help Controller
diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php
index 80315ff5d1..d937f51863 100644
--- a/app/Support/Twig/General.php
+++ b/app/Support/Twig/General.php
@@ -87,7 +87,8 @@ class General extends Twig_Extension
'activeRoutePartial', function () : string {
$args = func_get_args();
$route = $args[0]; // name of the route.
- if (!(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
+ $name = Route::getCurrentRoute()->getName() ?? '';
+ if (!(strpos($name, $route) === false)) {
return 'active';
}
diff --git a/resources/views/import/index.twig b/resources/views/import/index.twig
new file mode 100644
index 0000000000..16ea17886e
--- /dev/null
+++ b/resources/views/import/index.twig
@@ -0,0 +1,52 @@
+{% extends "./layout/default.twig" %}
+
+{% block breadcrumbs %}
+ {{ Breadcrumbs.renderIfExists }}
+{% endblock %}
+{% block content %}
+ <div class="row">
+ <div class="col-lg-12 col-md-12 col-sm-12">
+ <!-- ACCOUNTS -->
+ <div class="box box-default">
+ <div class="box-header with-border">
+ <h3 class="box-title">{{ 'import'|_ }}</h3>
+ </div>
+ <div class="box-body">
+ <p>
+ {{ 'import_intro_text'|_ }}
+ </p>
+ <p>
+ &nbsp;
+ </p>
+ <div class="row">
+ <form method="POST" action="{{ route('import.upload') }}" accept-charset="UTF-8" class="form-horizontal" id="update"
+ enctype="multipart/form-data">
+
+ <input name="_token" type="hidden" value="{{ csrf_token() }}">
+
+ <div class="col-lg-6 col-md-8 col-sm-12 col-xs-12">
+ {{ ExpandedForm.file('import_file',{helpText: 'import_file_help'|_}) }}
+
+ {{ ExpandedForm.select('import_file_type', importFileTypes, defaultImportType, {'helpText' : 'import_file_type_help'|_}) }}
+
+ <div class="form-group" id="import_file_holder">
+ <label for="ffInput_submit" class="col-sm-4 control-label">&nbsp;</label>
+
+ <div class="col-sm-8">
+ <button type="submit" class="btn pull-right btn-success">
+ {{ ('import_start')|_ }}
+ </button>
+ </div>
+ </div>
+ </div>
+ </form>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+{% endblock %}
+{% block scripts %}
+{% endblock %}
+{% block styles %}
+{% endblock %}