Lieferadressen-Drop-Downs in mehreren Masken sortiert anzeigen
authorMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 31 Jan 2014 14:48:41 +0000 (15:48 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 31 Jan 2014 14:48:41 +0000 (15:48 +0100)
SL/DB/Manager/Shipto.pm [new file with mode: 0644]
SL/DB/Shipto.pm
bin/mozilla/do.pl
bin/mozilla/is.pl
bin/mozilla/oe.pl

diff --git a/SL/DB/Manager/Shipto.pm b/SL/DB/Manager/Shipto.pm
new file mode 100644 (file)
index 0000000..50947a3
--- /dev/null
@@ -0,0 +1,24 @@
+package SL::DB::Manager::Shipto;
+
+use strict;
+
+use SL::DB::Helper::Manager;
+use base qw(SL::DB::Helper::Manager);
+
+use SL::DB::Helper::Sorted;
+
+sub object_class { 'SL::DB::Shipto' }
+
+__PACKAGE__->make_manager_methods;
+
+sub _sort_spec {
+  return (
+    default        => [ 'full_address', 1 ],
+    columns        => {
+      SIMPLE       => 'ALL',
+      full_address => '( lower(shipto.shiptoname) || lower(shipto.shiptostreet) || lower(shipto.shiptocity) )',
+      map { ( $_ => "lower(shipto.shipto$_)" ) } qw(city contact country department_1 department_2 email fax name phone street zipcode)
+    });
+}
+
+1;
index 1b174c0..b8868ab 100644 (file)
@@ -3,6 +3,7 @@ package SL::DB::Shipto;
 use strict;
 
 use SL::DB::MetaSetup::Shipto;
+use SL::DB::Manager::Shipto;
 use Rose::DB::Object::Helpers qw(clone_and_reset clone);
 
 our @SHIPTO_VARIABLES = qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact
@@ -10,8 +11,6 @@ our @SHIPTO_VARIABLES = qw(shiptoname shiptostreet shiptozipcode shiptocity ship
 
 __PACKAGE__->meta->initialize;
 
-__PACKAGE__->meta->make_manager_class;
-
 sub displayable_id {
   my $self = shift;
   my $text = join('; ', grep { $_ } (map({ $self->$_ } qw(shiptoname shiptostreet)),
index a804dee..e946e4e 100644 (file)
@@ -273,7 +273,7 @@ sub form_header {
 
   $::form->{ALL_EMPLOYEES}         = SL::DB::Manager::Employee->get_all_sorted(query => [ or => [ id => $::form->{employee_id},  deleted => 0 ] ]);
   $::form->{ALL_SALESMEN}          = SL::DB::Manager::Employee->get_all_sorted(query => [ or => [ id => $::form->{salesman_id},  deleted => 0 ] ]);
-  $::form->{ALL_SHIPTO}            = SL::DB::Manager::Shipto->get_all(query => [
+  $::form->{ALL_SHIPTO}            = SL::DB::Manager::Shipto->get_all_sorted(query => [
     or => [ trans_id  => $::form->{"$::form->{vc}_id"} * 1, and => [ shipto_id => $::form->{shipto_id} * 1, trans_id => undef ] ]
   ]);
   $::form->{ALL_CONTACTS}          = SL::DB::Manager::Contact->get_all_sorted(query => [
index b13de83..a83897a 100644 (file)
@@ -319,7 +319,7 @@ sub form_header {
 
   $TMPL_VAR{ALL_EMPLOYEES}         = SL::DB::Manager::Employee->get_all_sorted(query => [ or => [ id => $::form->{employee_id},  deleted => 0 ] ]);
   $TMPL_VAR{ALL_SALESMEN}          = SL::DB::Manager::Employee->get_all_sorted(query => [ or => [ id => $::form->{salesman_id},  deleted => 0 ] ]);
-  $TMPL_VAR{ALL_SHIPTO}            = SL::DB::Manager::Shipto->get_all(query => [
+  $TMPL_VAR{ALL_SHIPTO}            = SL::DB::Manager::Shipto->get_all_sorted(query => [
     or => [ trans_id  => $::form->{"$::form->{vc}_id"} * 1, and => [ shipto_id => $::form->{shipto_id} * 1, trans_id => undef ] ]
   ]);
   $TMPL_VAR{ALL_CONTACTS}          = SL::DB::Manager::Contact->get_all_sorted(query => [
index 71748b3..aba9c3e 100644 (file)
@@ -345,7 +345,7 @@ sub form_header {
   my $employee_list_query_gen      = sub { $::form->{$_[0]} ? [ or => [ id => $::form->{$_[0]}, deleted => 0 ] ] : [ deleted => 0 ] };
   $TMPL_VAR{ALL_EMPLOYEES}         = SL::DB::Manager::Employee->get_all_sorted(query => $employee_list_query_gen->('employee_id'));
   $TMPL_VAR{ALL_SALESMEN}          = SL::DB::Manager::Employee->get_all_sorted(query => $employee_list_query_gen->('salesman_id'));
-  $TMPL_VAR{ALL_SHIPTO}            = SL::DB::Manager::Shipto->get_all(query => [
+  $TMPL_VAR{ALL_SHIPTO}            = SL::DB::Manager::Shipto->get_all_sorted(query => [
     or => [ trans_id  => $::form->{"$::form->{vc}_id"} * 1, and => [ shipto_id => $::form->{shipto_id} * 1, trans_id => undef ] ]
   ]);
   $TMPL_VAR{ALL_CONTACTS}          = SL::DB::Manager::Contact->get_all_sorted(query => [