Added in importing Supplier CSV
This commit is contained in:
parent
c9fce1c887
commit
c814085630
17 changed files with 4696 additions and 23 deletions
|
@ -1,25 +1,55 @@
|
|||
package Pear::LocalLoop::Controller::Admin::ImportFrom;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
use Moo;
|
||||
use Devel::Dwarn;
|
||||
|
||||
use Pear::LocalLoop::Import::LCCCsv::Suppliers;
|
||||
|
||||
sub index {
|
||||
my $c = shift;
|
||||
|
||||
$c->app->max_request_size(1048576);
|
||||
$c->app->max_request_size(104857600);
|
||||
}
|
||||
|
||||
sub post_suppliers {
|
||||
my $c = shift;
|
||||
|
||||
Dwarn "yahoo!";
|
||||
unless ($c->param('suppliers_csv')) {
|
||||
$c->flash( error => "No CSV file given" );
|
||||
return $c->redirect_to( '/admin/import_from' );
|
||||
}
|
||||
|
||||
# Check file size
|
||||
if ($c->req->is_limit_exceeded) {
|
||||
$c->flash( error => "CSV file size is too large" );
|
||||
return $c->redirect_to( '/admin/import_from' );
|
||||
}
|
||||
my $csv_import = Pear::LocalLoop::Import::LCCCsv::Suppliers->new(
|
||||
csv_string => $c->param('suppliers_csv')->slurp,
|
||||
schema => $c->app->schema
|
||||
)->import_csv;
|
||||
|
||||
$c->flash( success => "CSV imported" );
|
||||
return $c->redirect_to( '/admin/import_from' );
|
||||
}
|
||||
|
||||
sub post_transactions {
|
||||
my $c = shift;
|
||||
|
||||
Dwarn "yahoo!";
|
||||
$c->flash( success => "CSV imported!" );
|
||||
unless ($c->param('transactions_csv')) {
|
||||
$c->flash( error => "No CSV file given" );
|
||||
return $c->redirect_to( '/admin/import_from' );
|
||||
}
|
||||
|
||||
# Check file size
|
||||
if ($c->req->is_limit_exceeded) {
|
||||
$c->flash( error => "CSV file size is too large" );
|
||||
return $c->redirect_to( '/admin/import_from' );
|
||||
}
|
||||
|
||||
my $csv_import = Pear::LocalLoop::Import::LCCCsv::Suppliers->import( $c->param('transactions_csv') );
|
||||
|
||||
$c->flash( success => "CSV imported" );
|
||||
return $c->redirect_to( '/admin/import_from' );
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue