From c7d1ccda0f59bc8662e8836cab1f3ab453acd3cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 14 Dec 2011 16:10:17 +0100 Subject: [PATCH] DB/OrderItem: relationship zu order, sort_spec und paginating --- SL/DB/OrderItem.pm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/SL/DB/OrderItem.pm b/SL/DB/OrderItem.pm index 9e045f74d..6efee0049 100644 --- a/SL/DB/OrderItem.pm +++ b/SL/DB/OrderItem.pm @@ -27,6 +27,11 @@ __PACKAGE__->meta->add_relationship( class => 'SL::DB::Unit', column_map => { unit => 'name' }, }, + order => { + type => 'one to one', + class => 'SL::DB::Order', + column_map => { trans_id => 'id' }, + }, ); # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. @@ -39,4 +44,26 @@ sub is_price_update_available { return $self->origprice > $self->part->sellprice; } +package SL::DB::Manager::OrderItem; + +use SL::DB::Helper::Paginated; +use SL::DB::Helper::Sorted; + +sub _sort_spec { + return ( columns => { delivery_date => [ 'deliverydate', ], + description => [ 'lower(orderitems.description)', ], + partnumber => [ 'part.partnumber', ], + qty => [ 'qty' ], + ordnumber => [ 'order.ordnumber' ], + customer => [ 'lower(customer.name)', ], + position => [ 'trans_id', 'runningnumber' ], + transdate => [ 'transdate', 'lower(order.reqdate::text)' ], + }, + default => [ 'position', 1 ], + nulls => { } + ); +} + +sub default_objects_per_page { 40 } + 1; -- 2.20.1