X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FHelper%2FLinkedRecords.pm;h=3c26b01b0b55a4003a98dee3ee7f1dcdef6bca2a;hb=37ff0a6b1b9bab9d12a6e92373764d0ff6b4de03;hp=3fb594848164cf17c2c55bb63966a327bbd56a03;hpb=460cd14ecfb30a599884bb7dffbcdcdca9e7c432;p=kivitendo-erp.git diff --git a/SL/DB/Helper/LinkedRecords.pm b/SL/DB/Helper/LinkedRecords.pm index 3fb594848..3c26b01b0 100644 --- a/SL/DB/Helper/LinkedRecords.pm +++ b/SL/DB/Helper/LinkedRecords.pm @@ -64,10 +64,15 @@ sub _linked_records_implementation { my @get_objects_query = ref($params{query}) eq 'ARRAY' ? @{ $params{query} } : (); my $get_objects = sub { - my $manager_class = SL::DB::Helper::Mappings::get_manager_package_for_table($_[0]->$sub_wanted_table); - my $object_class = SL::DB::Helper::Mappings::get_package_for_table($_[0]->$sub_wanted_table); + my ($link) = @_; + my $manager_class = SL::DB::Helper::Mappings::get_manager_package_for_table($link->$sub_wanted_table); + my $object_class = SL::DB::Helper::Mappings::get_package_for_table($link->$sub_wanted_table); eval "require " . $object_class . "; 1;"; - return @{ $manager_class->get_all(query => [ id => $_[0]->$sub_wanted_id, @get_objects_query ]) }; + return map { + $_->{_record_link_direction} = $wanted; + $_->{_record_link} = $link; + $_ + } @{ $manager_class->get_all(query => [ id => $link->$sub_wanted_id, @get_objects_query ]) }; }; # If no 'via' is given then use a simple(r) method for querying the wanted objects. @@ -144,6 +149,7 @@ sub sort_linked_records { 'SL::DB::DeliveryOrder' => sub { $_[0]->donumber }, 'SL::DB::Invoice' => sub { $_[0]->invnumber }, 'SL::DB::PurchaseInvoice' => sub { $_[0]->invnumber }, + 'SL::DB::RequirementSpec' => sub { $_[0]->id }, UNKNOWN => '9999999999999999', ); my $number_xtor = sub { @@ -160,6 +166,7 @@ sub sort_linked_records { my %scores; %scores = ( 'SL::DB::SalesProcess' => 10, + 'SL::DB::RequirementSpec' => 15, 'SL::DB::Order' => sub { $scores{ $_[0]->type } }, sales_quotation => 20, sales_order => 30, @@ -295,7 +302,22 @@ the current employee. =back -Returns an array reference. +Returns an array reference. Each element returned is a Rose::DB +instance. Additionally several elements in the element returned are +set to special values: + +=over 2 + +=item C<_record_link_direction> + +Either C or C indicating the direction. C means that +this object is the source in the link. + +=item C<_record_link> + +The actual database link object (an instance of L). + +=back =item C