Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a5a42ed1

Von Sven Schöling vor mehr als 12 Jahren hinzugefügt

  • ID a5a42ed1bf23da4a35b675ce00781fea99df2acd
  • Vorgänger 67643d03
  • Nachfolger 5d74fd02

CsvReport: Status mitspeichern

Unterschiede anzeigen:

SL/Controller/CsvImport.pm
my $dbh = $::form->get_standard_dbh;
$dbh->begin_work;
my $query = 'INSERT INTO csv_import_report_rows (csv_import_report_id, col, row, value) VALUES (?, ?, ?, ?)';
my $query = 'INSERT INTO csv_import_report_rows (csv_import_report_id, col, row, value) VALUES (?, ?, ?, ?)';
my $query2 = 'INSERT INTO csv_import_report_status (csv_import_report_id, row, type, value) VALUES (?, ?, ?, ?)';
my $sth = $dbh->prepare($query);
my $sth2 = $dbh->prepare($query2);
# save headers
my @headers = (
......
$sth->execute($report->id, $_, $row + 1, $data_row->{info_data}{ $info_methods[$_] }) for 0 .. $#info_methods;
$sth->execute($report->id, $o1 + $_, $row + 1, $data_row->{object}->${ \ $methods[$_] }) for 0 .. $#methods;
$sth->execute($report->id, $o2 + $_, $row + 1, $data_row->{raw_data}{ $raw_methods[$_] }) for 0 .. $#raw_methods;
$sth2->execute($report->id, $row + 1, 'information', $_) for @{ $data_row->{information} || [] };
$sth2->execute($report->id, $row + 1, 'errors', $_) for @{ $data_row->{errors} || [] };
}
$dbh->commit;
SL/DB/CsvImportReport.pm
class => 'SL::DB::CsvImportReportRow',
column_map => { id => 'csv_import_report_id' },
},
status => {
type => 'one to many',
class => 'SL::DB::CsvImportReportStatus',
column_map => { id => 'csv_import_report_id' },
},
);
__PACKAGE__->meta->make_manager_class;
......
return $self->{folded_rows};
}
sub folded_status {
my ($self) = @_;
$self->_fold_status unless $self->{folded_status};
return $self->{folded_status};
}
sub _fold_rows {
my ($self) = @_;
$self->{folded_rows} = [];
for my $row_obj (@{ $self->rows }) {
$::lxdebug->dump(0, "adding", $row_obj->row . ' ' . $row_obj->col . ' ' . $row_obj->value);
$self->{folded_rows}->[ $row_obj->row ] ||= [];
$self->{folded_rows}->[ $row_obj->row ][ $row_obj->col ] = $row_obj->value;
$::lxdebug->dump(0, "now", $self->{folded_rows});
}
}
sub _fold_status {
my ($self) = @_;
$self->{folded_status} = [];
for my $status_obj (@{ $self->status }) {
$self->{folded_status}->[ $status_obj->row ] ||= {};
$self->{folded_status}->[ $status_obj->row ]{information} ||= [];
$self->{folded_status}->[ $status_obj->row ]{errors} ||= [];
push @{ $self->{folded_status}->[ $status_obj->row ]{ $status_obj->type } }, $status_obj->value;
}
}
SL/DB/CsvImportReportRowStatus.pm
# This file has been auto-generated only because it didn't exist.
# Feel free to modify it at will; it will not be overwritten automatically.
package SL::DB::CsvImportReportRowStatus;
use strict;
use SL::DB::MetaSetup::CsvImportReportRowStatus;
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
__PACKAGE__->meta->make_manager_class;
1;
SL/DB/CsvImportReportStatus.pm
# This file has been auto-generated only because it didn't exist.
# Feel free to modify it at will; it will not be overwritten automatically.
package SL::DB::CsvImportReportStatus;
use strict;
use SL::DB::MetaSetup::CsvImportReportStatus;
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
__PACKAGE__->meta->make_manager_class;
1;
SL/DB/Helper/Mappings.pm
csv_import_profile_settings => 'csv_import_profile_setting',
csv_import_reports => 'csv_import_report',
csv_import_report_rows => 'csv_import_report_row',
csv_import_report_row_status => 'csv_import_report_row_status',
csv_import_report_status => 'csv_import_report_status',
custom_variable_configs => 'custom_variable_config',
custom_variables => 'custom_variable',
custom_variables_validity => 'custom_variable_validity',
SL/DB/MetaSetup/CsvImportReportRowStatus.pm
# This file has been auto-generated. Do not modify it; it will be overwritten
# by rose_auto_create_model.pl automatically.
package SL::DB::CsvImportReportRowStatus;
use strict;
use base qw(SL::DB::Object);
__PACKAGE__->meta->setup(
table => 'csv_import_report_row_status',
columns => [
id => { type => 'serial', not_null => 1 },
csv_import_report_row_id => { type => 'integer', not_null => 1 },
type => { type => 'text', not_null => 1 },
value => { type => 'text' },
],
primary_key_columns => [ 'id' ],
foreign_keys => [
csv_import_report_row => {
class => 'SL::DB::CsvImportReportRow',
key_columns => { csv_import_report_row_id => 'id' },
},
],
);
1;
;
SL/DB/MetaSetup/CsvImportReportStatus.pm
# This file has been auto-generated. Do not modify it; it will be overwritten
# by rose_auto_create_model.pl automatically.
package SL::DB::CsvImportReportStatus;
use strict;
use base qw(SL::DB::Object);
__PACKAGE__->meta->setup(
table => 'csv_import_report_status',
columns => [
id => { type => 'serial', not_null => 1 },
csv_import_report_id => { type => 'integer', not_null => 1 },
row => { type => 'integer', not_null => 1 },
type => { type => 'text', not_null => 1 },
value => { type => 'text' },
],
primary_key_columns => [ 'id' ],
);
1;
;
sql/Pg-upgrade2/csv_import_report_cache.sql
value TEXT
);
CREATE TABLE csv_import_report_row_status (
CREATE TABLE csv_import_report_status (
id SERIAL PRIMARY KEY,
csv_import_report_row_id INTEGER NOT NULL REFERENCES csv_import_report_rows(id),
csv_import_report_id INTEGER NOT NULL REFERENCES csv_import_reports(id),
row INTEGER NOT NULL,
type TEXT NOT NULL,
value TEXT
);
templates/webpages/csv_import/report.html
<th>[%- LxERP.t8('Notes') %]</th>
</tr>
[%- ELSE %]
<tr class="[% IF row.errors.size %]redrow[% ELSE %]listrow[% END %][% loop.count % 2 %]">
[% csv_import_report_errors = SELF.report.folded_status.${loop.index}.errors %]
<tr class="[% IF csv_import_report_errors.size %]redrow[% ELSE %]listrow[% END %][% loop.count % 2 %]">
[%- FOREACH value = row %]
<td>[%- value | html %]</td>
[%- END %]
<td>
[%- FOREACH error = row.errors %][%- HTML.escape(error) %][% UNLESS loop.last %]<br>[%- END %][%- END %]
[%- FOREACH info = row.information %][% IF !loop.first || row.errors.size %]<br>[%- END %][%- HTML.escape(info) %][%- END %]
[%- FOREACH error = csv_import_report_errors %][%- error | html %][% UNLESS loop.last %]<br>[%- END %][%- END %]
[%- FOREACH info = SELF.report.folded_status.${loop.index}.information %][% IF !loop.first || csv_import_report_errors.size %]<br>[%- END %][%- info | html %][%- END %]
</td>
</tr>
[%- END %]

Auch abrufbar als: Unified diff