From 4b7550f56967121d2312a1e18b7a3b1d667b1eac Mon Sep 17 00:00:00 2001 From: Finn Date: Thu, 4 Jul 2019 14:16:49 +0100 Subject: [PATCH] added initial UI for uploading csv --- lib/Pear/LocalLoop.pm | 2 ++ .../LocalLoop/Controller/Admin/ImportFrom.pm | 24 ++++++++++++++++++- lib/Pear/LocalLoop/Import/LCCCsv/Suppliers.pm | 4 +++- templates/admin/import_from/index.html.ep | 24 +++++++++++++------ 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/lib/Pear/LocalLoop.pm b/lib/Pear/LocalLoop.pm index fe1d6f4..3dad2b6 100644 --- a/lib/Pear/LocalLoop.pm +++ b/lib/Pear/LocalLoop.pm @@ -246,6 +246,8 @@ sub startup { $admin_routes->get('/import/:set_id/import')->to('admin-import#run_import'); $admin_routes->get('/import_from')->to('admin-import_from#index'); + $admin_routes->post('/import_from/suppliers')->to('admin-import_from#post_suppliers'); + $admin_routes->post('/import_from/transactions')->to('admin-import_from#post_transactions'); # my $user_routes = $r->under('/')->to('root#under'); diff --git a/lib/Pear/LocalLoop/Controller/Admin/ImportFrom.pm b/lib/Pear/LocalLoop/Controller/Admin/ImportFrom.pm index 66b1129..83a2d78 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/ImportFrom.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/ImportFrom.pm @@ -1,4 +1,26 @@ package Pear::LocalLoop::Controller::Admin::ImportFrom; use Mojo::Base 'Mojolicious::Controller'; +use Devel::Dwarn; -1; \ No newline at end of file +sub index { + my $c = shift; + + $c->app->max_request_size(1048576); +} + +sub post_suppliers { + my $c = shift; + + Dwarn "yahoo!"; + return $c->redirect_to( '/admin/import_from' ); +} + +sub post_transactions { + my $c = shift; + + Dwarn "yahoo!"; + $c->flash( success => "CSV imported!" ); + return $c->redirect_to( '/admin/import_from' ); +} + +1; diff --git a/lib/Pear/LocalLoop/Import/LCCCsv/Suppliers.pm b/lib/Pear/LocalLoop/Import/LCCCsv/Suppliers.pm index a9d2635..721c24a 100644 --- a/lib/Pear/LocalLoop/Import/LCCCsv/Suppliers.pm +++ b/lib/Pear/LocalLoop/Import/LCCCsv/Suppliers.pm @@ -5,6 +5,8 @@ extends qw/Pear::LocalLoop::Import::LCCCsv/; sub import { my $self = shift; + + $import = Pear::LocalLoop::Import::LCCCsv->new; } sub _row_to_result { @@ -13,4 +15,4 @@ sub _row_to_result { } -1; \ No newline at end of file +1; diff --git a/templates/admin/import_from/index.html.ep b/templates/admin/import_from/index.html.ep index e9b45f1..c9e0f51 100644 --- a/templates/admin/import_from/index.html.ep +++ b/templates/admin/import_from/index.html.ep @@ -17,15 +17,25 @@

Import From

-

Various import options depending on source. Each one is custom.

+

Various import options depending on source. Each one is custom. For Creditor reports from LCC.

-
-
+
+
-
LCC Procurement Import
-
Creditor reports from LCC
- Suppliers - Transactions +

LCC Procurement Import - Suppliers

+
+ + +
+
+
+
+
+

LCC Procurement Import - Transactions

+
+ + +