1 package SL::Controller::Mebil;
 
   5 use parent qw(SL::Controller::Base);
 
   7 use SL::Controller::Helper::ReportGenerator;
 
  13 use Rose::Object::MakeMethods::Generic (
 
  14   scalar                  => [ qw(report number_columns year current_year objects subtotals_per_quarter salesman_id) ],
 
  15   'scalar --get_set_init' => [ qw(employees types data) ],
 
  19         $::lxdebug->enter_sub;
 
  20         $::lxdebug->message(5, 'controller=mebil/action=map');
 
  23         $::form->header(no_layout => 1);
 
  25         print "<h1>Mebil running</h1>";
 
  27         my $sql = "SELECT  chart_id,xbrl_tag from mebil_mapping";
 
  28         my $result = SL::DBUtils::do_query($::form, $::form->get_standard_dbh, $sql);
 
  29         $::lxdebug->message(5, "result= $result");
 
  30         print "$result<br>\n";
 
  32         my @r = SL::DBUtils::selectall_hashref_query($::form, $::form->get_standard_dbh, $sql);
 
  33         print ref($r[1])||"SCALAR";
 
  36         while (my($k,$v) = each(%$fst)) {
 
  37                 print $k, " : ", $v, "</br>\n";
 
  43         print "<p>Mebil ready</p>";
 
  44         $::lxdebug->leave_sub;
 
  48         $::lxdebug->enter_sub;
 
  51         my $sql = "SELECT  chart_id,xbrl_tag from mebil_mapping";
 
  52         $self->{data} = SL::DBUtils::selectall_hashref_query($::form, $::form->get_standard_dbh, $sql);
 
  55 #       $self->calculate_one_time_data;
 
  56 #       $self->calculate_periodic_invoices;
 
  57         $self->prepare_report;
 
  60         $::form->header(no_layout => 1);
 
  62         print "<h1>Mebil-Mapping</h1>";
 
  63         print "<p>Folgende Zuordnungen sind in der DB hinterlegt:";
 
  66         print "<table><tr><th>Konto</th><th>Ziel</th></tr>\n";
 
  67         foreach my $mapping (@{ $self->{data} }) {
 
  68                 print "<tr><td>",$mapping->{chart_id},"</td><td>",$mapping->{xbrl_tag},"</td></tr>\n";
 
  72         $::lxdebug->leave_sub;
 
  77   $self->report(SL::ReportGenerator->new(\%::myconfig, $::form));
 
  79   my @columns = (qw(chart_id xbrl_tag));
 
  81   #$self->number_columns([ grep { !m/^(?:month|year|quarter)$/ } @columns ]);
 
  84     chart_id                  => { text => 'Kontonummer'                  },
 
  85     xbrl_tag                   => { text => 'XBRL'                   },
 
  88   $column_defs{$_}->{align} = 'right' for @columns;
 
  90   $self->report->set_options(
 
  91     std_column_visibility => 1,
 
  92     controller_class      => 'Mebil',
 
  93     output_format         => 'HTML',
 
  94  #   raw_top_info_text     => $self->render('financial_overview/report_top', { output => 0 }, YEARS_TO_LIST => [ reverse(($self->current_year - 10)..($self->current_year + 5)) ]),
 
  95  #   title                 => t8('Financial overview for #1', $self->year),
 
  96  #   allow_pdf_export      => 1,
 
  97  #   allow_csv_export      => 1,
 
  99   $self->report->set_columns(%column_defs);
 
 100   $self->report->set_column_order(@columns);
 
 101 #  $self->report->set_export_options(qw(list year subtotals_per_quarter salesman_id));
 
 102   $self->report->set_options_from_form;
 
 107 #  my @visible_columns  = $self->report->get_visible_columns;
 
 108 #  my @type_columns     = @{ $self->types };
 
 109 #  my @non_type_columns = grep { my $c = $_; none { $c eq $_ } @type_columns } @visible_columns;
 
 111         foreach my $mapping (@{ $self->{data} }) {
 
 113                         chart_id => { data => $mapping->{chart_id}},
 
 114                         xbrl_tag => { data => $mapping->{xbrl_tag}},
 
 116                 $self->report->add_data(\%data);
 
 119         return $self->report->generate_with_headers;
 
 127             sales_quotations       => SL::DB::Manager::Order->get_all(          where => [ and => [ @f_date, @f_salesman, SL::DB::Manager::Order->type_filter('sales_quotation')   ]]),
 
 128             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) ]),
 
 129             sales_orders_per_inv   => [],
 
 130             requests_for_quotation => SL::DB::Manager::Order->get_all(          where => [ and => [ @f_date, @f_salesman, SL::DB::Manager::Order->type_filter('request_quotation') ]]),
 
 131             purchase_orders        => SL::DB::Manager::Order->get_all(          where => [ and => [ @f_date, @f_salesman, SL::DB::Manager::Order->type_filter('purchase_order')    ]]),
 
 132             sales_invoices         => SL::DB::Manager::Invoice->get_all(        where => [ and => [ @f_date, @f_salesman, ]]),
 
 133             purchase_invoices      => SL::DB::Manager::PurchaseInvoice->get_all(where => [ and =>  \@f_date ]),
 
 134             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) ]),
 
 137   $self->objects->{sales_orders} = [ grep { !$_->periodic_invoices_config || !$_->periodic_invoices_config->active } @{ $self->objects->{sales_orders} } ];