added initial UI for uploading csv

This commit is contained in:
Finn 2019-07-04 14:16:49 +01:00
parent c456428681
commit 4b7550f569
No known key found for this signature in database
GPG key ID: 7455B4B17685B598
4 changed files with 45 additions and 9 deletions

View file

@ -246,6 +246,8 @@ sub startup {
$admin_routes->get('/import/:set_id/import')->to('admin-import#run_import'); $admin_routes->get('/import/:set_id/import')->to('admin-import#run_import');
$admin_routes->get('/import_from')->to('admin-import_from#index'); $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'); # my $user_routes = $r->under('/')->to('root#under');

View file

@ -1,4 +1,26 @@
package Pear::LocalLoop::Controller::Admin::ImportFrom; package Pear::LocalLoop::Controller::Admin::ImportFrom;
use Mojo::Base 'Mojolicious::Controller'; use Mojo::Base 'Mojolicious::Controller';
use Devel::Dwarn;
1; 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;

View file

@ -5,6 +5,8 @@ extends qw/Pear::LocalLoop::Import::LCCCsv/;
sub import { sub import {
my $self = shift; my $self = shift;
$import = Pear::LocalLoop::Import::LCCCsv->new;
} }
sub _row_to_result { sub _row_to_result {
@ -13,4 +15,4 @@ sub _row_to_result {
} }
1; 1;

View file

@ -17,15 +17,25 @@
<h3 class="float-left">Import From</h3> <h3 class="float-left">Import From</h3>
</div> </div>
<div class="col-12 mb-3"> <div class="col-12 mb-3">
<p>Various import options depending on source. Each one is custom.</p> <p>Various import options depending on source. Each one is custom. For Creditor reports from LCC.</p>
</div> </div>
<div class="col col-md-4 mb-3"> <div class="row">
<div class="card"> <div class="card col-md-6 m-3">
<div class="card-body"> <div class="card-body">
<h5 class="card-title">LCC Procurement Import</h5> <h4 class="card-title">LCC Procurement Import - Suppliers</h4>
<div class="card-text">Creditor reports from LCC</div> <form action="/admin/import_from/suppliers" method="POST" enctype="multipart/form-data">
<a href="#" class="card-link">Suppliers</a> <input type="file" name="suppliers_csv" accept="text/csv">
<a href="#" class="card-link">Transactions</a> <input type="submit" value="Upload Suppliers CSV">
</form>
</div>
</div>
<div class="card col-md-6 m-3">
<div class="card-body">
<h4 class="card-title">LCC Procurement Import - Transactions</h4>
<form action="/admin/import_from/transactions" method="POST" enctype="multipart/form-data">
<input type="file" name="transactions_csv" accept="text/csv">
<input type="submit" value="Upload Transactions CSV">
</form>
</div> </div>
</div> </div>
</div> </div>