#use Data::Dumper;
#use SL::ClientJS;
+use SL::mebil::Mapping;
+
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) ],
$::form->{title} = $::locale->text('Mebil Map');
- my $sql = "SELECT fromacc,typ,toacc from mebil_mapping order by ordering";
- $self->{data} = SL::DBUtils::selectall_hashref_query($::form, $::form->get_standard_dbh, $sql);
+ my $mapping = new SL::mebil::Mapping($::form, $::form->get_standard_dbh);
+ $self->{data} = $mapping->get_mapping();
$self->prepare_report;
$self->list_data;
__PACKAGE__->make_manager_methods;
1;
+
+# The call above creates the methods shown below. (The actual
+# method bodies vary slightly, but this is the gist of it...)
+#
+# sub get_products
+# {
+# shift->get_objects(@_, object_class => 'Product');
+# }
+#
+# sub get_products_iterator
+# {
+# shift->get_objects_iterator(@_, object_class => 'Product');
+# }
+#
+# sub get_products_count
+# {
+# shift->get_objects_count(@_, object_class => 'Product');
+# }
+#
+# sub update_products
+# {
+# shift->update_objects(@_, object_class => 'Product');
+# }
+#
+# sub delete_products
+# {
+# shift->delete_objects(@_, object_class => 'Product');
+# }
__PACKAGE__->meta->initialize;
-sub getMappings {
- my $dbh = shift;
-
- return SL::DB::Manager::MebilMapping::get_mebilmappings();
-}
-
1;
--- /dev/null
+package SL::mebil::Mapping;
+
+use strict;
+
+# Manager methods for mebil
+
+sub new {
+ # parameter: 1) ...
+ my $name = shift;
+ my $my_data = {
+ error_channel => shift,
+ dbh => shift};
+ bless $my_data;
+ return $my_data;
+}
+sub get_mapping {
+ my $self = shift;
+ my $sql = "SELECT fromacc,typ,toacc from mebil_mapping order by ordering";
+ return SL::DBUtils::selectall_hashref_query($self->{error_channel}, $self->{dbh}, $sql);
+}
+
+1;
+|FrontPage.MappingSuite.ShowMapping||18:30:23 Di., Dez. 13, 2022|
+|FrontPage.MappingSuite||12:36:18 Di., Dez. 13, 2022|
|FrontPage.AlAktualisierung||19:45:06 Do, Feb 18, 2021|
|FrontPage.AdNeuInstallation||19:39:22 Do, Feb 18, 2021|
|FrontPage.AbDeinstallieren||19:21:22 Do, Feb 18, 2021|
--- /dev/null
+use strict;
+
+package ErrorChannel;
+
+sub new {
+ my $self = {};
+ bless $self, shift;
+ return $self;
+}
+
+sub dberror {
+ my $self = shift;
+ print shift; print "\n";
+}
+
+1;
\ No newline at end of file
#!/usr/bin/perl
use strict;
-#use SL::Controller::Mebil;
-use SL::DB;
-use SL::Form;
+use lib "/opt/kivitendo-erp";
use SL::LXDebug;
-use SL::DB::Manager::MebilMapping;
+use SL::mebil::Mapping;
+use Test::perl::ErrorChannel;
$::lxdebug = new LXDebug;
-#$::form = new Form;
-
-#my $dbh = $::form->get_standard_dbh;
SL::DB->register_db(
domain => 'KIVITENDO',
type => 'KIVITENDO',);
my $dbh = $db->dbh;
-#$dbh->do("SELECT * FROM mebil_mapping");
-
-#$db->begin_work or die $db->error;
-#my $m = new SL::Controller::Mebil;
-#$m->action_calcmap;
-my $mappings = SL::DB::Manager::MebilMapping->get_objects(dbh => $dbh);
-
-foreach my $map (@$mappings) {
- print ("$map\n");
+my $errch = new ErrorChannel;
+my $mapper = new SL::mebil::Mapping($errch, $dbh);
+
+my $command = $ARGV[0];
+if ($command eq "GetMapping") {
+ my $mapping = $mapper->get_mapping();
+ foreach (@$mapping) {
+ print $_->{fromacc}."\n";
+ }
+ die ("Kein Mapping vorhanden.") unless (scalar(@$mapping) > 0);
+} elsif ($command eq "CalcMapping") {
+ die ("NIY.");
+} else {
+ die "Invalid command: $command";
}