use parent qw(SL::Controller::Base);
+use SL::Controller::Helper::ReportGenerator;
use SL::DBUtils;
#use Data::Dumper;
#use SL::ClientJS;
+use Rose::Object::MakeMethods::Generic (
+ scalar => [ qw(report number_columns year current_year objects subtotals_per_quarter salesman_id) ],
+ 'scalar --get_set_init' => [ qw(employees types data) ],
+);
+
sub action_map {
$::lxdebug->enter_sub;
$::lxdebug->message(5, 'controller=mebil/action=map');
print "<h1>Mebil running</h1>";
- my $sql = "SELECT * from mebil_mapping";
+ my $sql = "SELECT chart_id,xbrl_tag from mebil_mapping";
my $result = SL::DBUtils::do_query($::form, $::form->get_standard_dbh, $sql);
$::lxdebug->message(5, "result= $result");
- print "$result\n";
+ print "$result<br>\n";
+
+ my @r = SL::DBUtils::selectall_hashref_query($::form, $::form->get_standard_dbh, $sql);
+ print ref($r[1])||"SCALAR";
+ print "<br>";
+ my $fst = $r[1];
+ while (my($k,$v) = each(%$fst)) {
+ print $k, " : ", $v, "</br>\n";
+ }
+ print "<br>";
+ print scalar @r;
+ print "<br>";
+ print @r;
print "<p>Mebil ready</p>";
$::lxdebug->leave_sub;
}
+sub action_showmap {
+ $::lxdebug->enter_sub;
+ my ($self) = @_;
+
+ my $sql = "SELECT chart_id,xbrl_tag from mebil_mapping";
+ $self->{data} = SL::DBUtils::selectall_hashref_query($::form, $::form->get_standard_dbh, $sql);
+
+# $self->get_objects;
+# $self->calculate_one_time_data;
+# $self->calculate_periodic_invoices;
+ $self->prepare_report;
+ $self->list_data;
+=cut
+ $::form->header(no_layout => 1);
+
+ print "<h1>Mebil-Mapping</h1>";
+ print "<p>Folgende Zuordnungen sind in der DB hinterlegt:";
+
+
+ print "<table><tr><th>Konto</th><th>Ziel</th></tr>\n";
+ foreach my $mapping (@{ $self->{data} }) {
+ print "<tr><td>",$mapping->{chart_id},"</td><td>",$mapping->{xbrl_tag},"</td></tr>\n";
+ }
+ print "</table>\n";
+=cut
+ $::lxdebug->leave_sub;
+}
+sub prepare_report {
+ my ($self) = @_;
+
+ $self->report(SL::ReportGenerator->new(\%::myconfig, $::form));
+
+ my @columns = (qw(chart_id xbrl_tag));
+
+ #$self->number_columns([ grep { !m/^(?:month|year|quarter)$/ } @columns ]);
+
+ my %column_defs = (
+ chart_id => { text => 'Kontonummer' },
+ xbrl_tag => { text => 'XBRL' },
+ );
+
+ $column_defs{$_}->{align} = 'right' for @columns;
+
+ $self->report->set_options(
+ std_column_visibility => 1,
+ controller_class => 'Mebil',
+ output_format => 'HTML',
+ # raw_top_info_text => $self->render('financial_overview/report_top', { output => 0 }, YEARS_TO_LIST => [ reverse(($self->current_year - 10)..($self->current_year + 5)) ]),
+ # title => t8('Financial overview for #1', $self->year),
+ # allow_pdf_export => 1,
+ # allow_csv_export => 1,
+ );
+ $self->report->set_columns(%column_defs);
+ $self->report->set_column_order(@columns);
+# $self->report->set_export_options(qw(list year subtotals_per_quarter salesman_id));
+ $self->report->set_options_from_form;
+}
+sub list_data {
+ my ($self) = @_;
+
+# my @visible_columns = $self->report->get_visible_columns;
+# my @type_columns = @{ $self->types };
+# my @non_type_columns = grep { my $c = $_; none { $c eq $_ } @type_columns } @visible_columns;
+
+ foreach my $mapping (@{ $self->{data} }) {
+ my %data = (
+ chart_id => { data => $mapping->{chart_id}},
+ xbrl_tag => { data => $mapping->{xbrl_tag}},
+ );
+ $self->report->add_data(\%data);
+ }
+
+ return $self->report->generate_with_headers;
+}
+
+
+=cut
+sub get_objects {
+ my ($self) = @_;
+ $self->objects({
+ sales_quotations => SL::DB::Manager::Order->get_all( where => [ and => [ @f_date, @f_salesman, SL::DB::Manager::Order->type_filter('sales_quotation') ]]),
+ sales_orders => SL::DB::Manager::Order->get_all( where => [ and => [ @f_date, @f_salesman, SL::DB::Manager::Order->type_filter('sales_order') ]], with_objects => [ qw(periodic_invoices_config) ]),
+ sales_orders_per_inv => [],
+ requests_for_quotation => SL::DB::Manager::Order->get_all( where => [ and => [ @f_date, @f_salesman, SL::DB::Manager::Order->type_filter('request_quotation') ]]),
+ purchase_orders => SL::DB::Manager::Order->get_all( where => [ and => [ @f_date, @f_salesman, SL::DB::Manager::Order->type_filter('purchase_order') ]]),
+ sales_invoices => SL::DB::Manager::Invoice->get_all( where => [ and => [ @f_date, @f_salesman, ]]),
+ purchase_invoices => SL::DB::Manager::PurchaseInvoice->get_all(where => [ and => \@f_date ]),
+ periodic_invoices_cfg => SL::DB::Manager::PeriodicInvoicesConfig->get_all(where => [ active => 1, $self->salesman_id ? ('order.salesman_id' => $self->salesman_id) : () ], with_objects => [ qw(order) ]),
+ });
+
+ $self->objects->{sales_orders} = [ grep { !$_->periodic_invoices_config || !$_->periodic_invoices_config->active } @{ $self->objects->{sales_orders} } ];
+}
+=cut
+
1;