commit bef5a02c495b4d912ffb95e95f8a8b39bee68214
Author: Werner Hahn <wh@futureworldsearch.net>
Date:   Thu Jan 7 11:42:58 2016 +0100

    Shopmodul: RecordsLinks auch für/bei ShopOrders anzeigen
    
    Conflicts:
            SL/Controller/RecordLinks.pm
    
    record links fehlende Datei

diff --git a/SL/Controller/RecordLinks.pm b/SL/Controller/RecordLinks.pm
index b71467752..cb37917de 100644
--- a/SL/Controller/RecordLinks.pm
+++ b/SL/Controller/RecordLinks.pm
@@ -15,6 +15,7 @@ use SL::DB::PurchaseInvoice;
 use SL::DB::RecordLink;
 use SL::DB::RequirementSpec;
 use SL::DBUtils qw(like);
+use SL::DB::ShopOrder;
 use SL::JSON;
 use SL::Locale::String;
 
@@ -36,7 +37,8 @@ my %link_type_defaults = (
 );
 
 my @link_type_specifics = (
-  { title => t8('Requirement spec'),        type => 'requirement_spec',        model => 'RequirementSpec', number => 'id',           description => 'title',   description_title => t8('Title'),   date => undef, project => 'project', filter => 'working_copy_filter', },
+  { title => t8('Requirement spec'),        type => 'requirement_spec',        model => 'RequirementSpec', number => 'id', project => 'project', description => 'title', date => undef, filter => 'working_copy_filter', },
+  { title => t8('Shop Order'),              type => 'shop_order',              model => 'ShopOrder',       number => 'shop_ordernumber', },
   { title => t8('Sales quotation'),         type => 'sales_quotation',         model => 'Order',           number => 'quonumber', },
   { title => t8('Sales Order'),             type => 'sales_order',             model => 'Order',           number => 'ordnumber', },
   { title => t8('Sales delivery order'),    type => 'sales_delivery_order',    model => 'DeliveryOrder',   number => 'donumber',  },
@@ -60,6 +62,8 @@ sub action_ajax_list {
   eval {
     my $linked_records = $self->object->linked_records(direction => 'both', recursive => 1, save_path => 1);
     push @{ $linked_records }, $self->object->sepa_export_items if $self->object->can('sepa_export_items');
+    $main::lxdebug->dump(0, 'WH: RECORDS:', \$linked_records);
+
     my $output         = SL::Presenter->get->grouped_record_list(
       $linked_records,
       with_columns      => [ qw(record_link_direction) ],
@@ -119,7 +123,7 @@ sub action_ajax_add_list {
   my ($self) = @_;
 
   my $manager     = 'SL::DB::Manager::' . $self->link_type_desc->{model};
-  my $vc          = $self->link_type =~ m/sales_|^invoice|requirement_spec|letter/ ? 'customer' : 'vendor';
+  my $vc          = $self->link_type =~ m/shop|sales_|^invoice|requirement_spec|letter/ ? 'customer' : 'vendor';
   my $project     = $self->link_type_desc->{project};
   my $project_id  = "${project}_id";
   my $description = $self->link_type_desc->{description};
diff --git a/SL/Presenter.pm b/SL/Presenter.pm
index 590800294..cd4f4e17e 100644
--- a/SL/Presenter.pm
+++ b/SL/Presenter.pm
@@ -22,6 +22,7 @@ use SL::Presenter::RequirementSpec;
 use SL::Presenter::RequirementSpecItem;
 use SL::Presenter::RequirementSpecTextBlock;
 use SL::Presenter::SepaExport;
+use SL::Presenter::ShopOrder;
 use SL::Presenter::Text;
 use SL::Presenter::Tag;
 use SL::Presenter::BankAccount;
diff --git a/SL/Presenter/Record.pm b/SL/Presenter/Record.pm
index 708e72653..4740ca838 100644
--- a/SL/Presenter/Record.pm
+++ b/SL/Presenter/Record.pm
@@ -43,6 +43,7 @@ sub grouped_record_list {
   my $output = '';
 
   $output .= _requirement_spec_list(       $self, $groups{requirement_specs},        %params) if $groups{requirement_specs};
+  $output .= _shop_order_list(             $self, $groups{shop_orders},               %params) if $groups{shop_orders};
   $output .= _sales_quotation_list(        $self, $groups{sales_quotations},         %params) if $groups{sales_quotations};
   $output .= _sales_order_list(            $self, $groups{sales_orders},             %params) if $groups{sales_orders};
   $output .= _sales_delivery_order_list(   $self, $groups{sales_delivery_orders},    %params) if $groups{sales_delivery_orders};
@@ -167,9 +168,10 @@ sub record_list {
 
 sub _group_records {
   my ($list) = @_;
-
+$main::lxdebug->dump(0, 'WH: GROUP_RECORDS: ',\@_);
   my %matchers = (
     requirement_specs        => sub { (ref($_[0]) eq 'SL::DB::RequirementSpec')                                         },
+    shop_orders              => sub { (ref($_[0]) eq 'SL::DB::ShopOrder')                                               },
     sales_quotations         => sub { (ref($_[0]) eq 'SL::DB::Order')           &&  $_[0]->is_type('sales_quotation')   },
     sales_orders             => sub { (ref($_[0]) eq 'SL::DB::Order')           &&  $_[0]->is_type('sales_order')       },
     sales_delivery_orders    => sub { (ref($_[0]) eq 'SL::DB::DeliveryOrder')   &&  $_[0]->is_sales                     },
@@ -231,6 +233,27 @@ sub _requirement_spec_list {
   );
 }
 
+sub _shop_order_list {
+  my ($self, $list, %params) = @_;
+$main::lxdebug->dump(0, 'WH: ORDER_LIST: ',\@_);
+  return $self->record_list(
+    $list,
+    title   => $::locale->text('Shop Orders'),
+    type    => 'shop_order',
+    columns => [
+      [ $::locale->text('Shop Order Date'),         'order_date'                                                              ],
+      [ $::locale->text('Shop Order Number'),        sub { $self->shop_order($_[0], display => 'table-cell') }                 ],
+      [ $::locale->text('Transfer Date'),           'transfer_date'                                                            ],
+      #     [ $::locale->text('Customer'),                'customer'                                                                 ],
+      [ $::locale->text('Net amount'),              'netamount'                                                                ],
+      #[ $::locale->text('Transaction description'), 'transaction_description'                                                  ],
+      #[ $::locale->text('Project'),                 'globalproject', ],
+      #[ $::locale->text('Closed'),                  'closed'                                                                   ],
+    ],
+    %params,
+  );
+}
+
 sub _sales_quotation_list {
   my ($self, $list, %params) = @_;
 
diff --git a/SL/Presenter/ShopOrder.pm b/SL/Presenter/ShopOrder.pm
new file mode 100644
index 000000000..abfe864b2
--- /dev/null
+++ b/SL/Presenter/ShopOrder.pm
@@ -0,0 +1,26 @@
+package SL::Presenter::ShopOrder;
+
+use strict;
+
+use parent qw(Exporter);
+
+use Exporter qw(import);
+our @EXPORT = qw(shop_order);
+
+use Carp;
+
+sub shop_order {
+  my ($self, $shop_order, $type, %params) = @_;
+
+  $params{display} ||= 'inline';
+
+  croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/;
+
+  my $text = join '', (
+    $params{no_link} ? '' : '<a href="controller.pl?action=ShopOrder/show&amp;id='.$self->escape($shop_order->id).'">',
+    $self->escape($shop_order->id),
+    $params{no_link} ? '' : '</a>',
+  );
+  return $self->escaped_text($text);
+}
+1;
diff --git a/templates/webpages/shop_order/show.html b/templates/webpages/shop_order/show.html
index 432120773..d7b1dcdac 100644
--- a/templates/webpages/shop_order/show.html
+++ b/templates/webpages/shop_order/show.html
@@ -111,7 +111,7 @@
         </table>
       </td>
       <td style="padding-left: 20px; vertical-align: top;">
-        [% UNLESS IMPORT.tranferred %]
+        [% UNLESS IMPORT.transferred %]
         [% IF PROPOSALS %]
         <div style="height: 120px; overflow:auto;">
           <table>
@@ -138,6 +138,11 @@
        [% ELSE %]
         <div>
           Wurde schon übernommen
+          <div id="recordlinks"></div>
+          <script type="text/javascript">
+            var url = 'controller.pl?action=RecordLinks/ajax_list&object_model=ShopOrder&object_id=[% IMPORT.id %]';
+            $('#recordlinks').load(url);
+          </script>
         </div>
         [% END %]
       </td>
@@ -177,4 +182,4 @@
     $.post("controller.pl", { action: 'ShopOrder/list'});
   }
 </script>
-[% L.dump(IMPORT) %] 
+[% L.dump(IMPORT) %]
