Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 60e1aa55

Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt

  • ID 60e1aa5531badb7f7ff81b6ebfc577060b8f3cfe
  • Vorgänger ad65bf1b
  • Nachfolger d0172f91

Verknüpfte Belege: Spalte "Verknüpfungsrichtung" anzeigen

Unterschiede anzeigen:

SL/Controller/RecordLinks.pm
23 23
    my $model          = 'SL::DB::' . $::form->{object_model};
24 24
    my $object         = $model->new(id => $::form->{object_id})->load || die $::locale->text("Record not found");
25 25
    my $linked_records = $object->linked_records(direction => 'both');
26
    my $output         = SL::Presenter->get->grouped_record_list($linked_records);
26
    my $output         = SL::Presenter->get->grouped_record_list($linked_records, with_columns => [ qw(record_link_direction) ]);
27 27
    $self->render(\$output, { layout => 0, process => 0 });
28 28

  
29 29
    1;
SL/DB/Helper/LinkedRecords.pm
64 64

  
65 65
  my @get_objects_query = ref($params{query}) eq 'ARRAY' ? @{ $params{query} } : ();
66 66
  my $get_objects       = sub {
67
    my $manager_class = SL::DB::Helper::Mappings::get_manager_package_for_table($_[0]->$sub_wanted_table);
68
    my $object_class  = SL::DB::Helper::Mappings::get_package_for_table($_[0]->$sub_wanted_table);
67
    my ($link)        = @_;
68
    my $manager_class = SL::DB::Helper::Mappings::get_manager_package_for_table($link->$sub_wanted_table);
69
    my $object_class  = SL::DB::Helper::Mappings::get_package_for_table($link->$sub_wanted_table);
69 70
    eval "require " . $object_class . "; 1;";
70
    return @{ $manager_class->get_all(query => [ id => $_[0]->$sub_wanted_id, @get_objects_query ]) };
71
    return map {
72
      $_->{_record_link_direction} = $wanted;
73
      $_->{_record_link}           = $link;
74
      $_
75
    } @{ $manager_class->get_all(query => [ id => $link->$sub_wanted_id, @get_objects_query ]) };
71 76
  };
72 77

  
73 78
  # If no 'via' is given then use a simple(r) method for querying the wanted objects.
......
295 300

  
296 301
=back
297 302

  
298
Returns an array reference.
303
Returns an array reference. Each element returned is a Rose::DB
304
instance. Additionally several elements in the element returned are
305
set to special values:
306

  
307
=over 2
308

  
309
=item C<_record_link_direction>
310

  
311
Either C<from> or C<to> indicating the direction. C<from> means that
312
this object is the source in the link.
313

  
314
=item C<_record_link>
315

  
316
The actual database link object (an instance of L<SL::DB::RecordLink>).
317

  
318
=back
299 319

  
300 320
=item C<link_to_record $record, %params>
301 321

  
SL/Presenter/Record.pm
10 10
use Carp;
11 11
use List::Util qw(first);
12 12

  
13
sub _arrayify {
14
  my ($array) = @_;
15
  return []     if !defined $array;
16
  return $array if ref $array;
17
  return [ $array ];
18
}
19

  
13 20
sub grouped_record_list {
14 21
  my ($self, $list, %params) = @_;
15 22

  
23
  %params    = map { exists $params{$_} ? ($_ => $params{$_}) : () } qw(selectable with_columns);
24

  
16 25
  my %groups = _group_records($list);
17 26
  my $output = '';
18 27

  
19
  $output .= _sales_quotation_list(        $self, $groups{sales_quotations})         if $groups{sales_quotations};
20
  $output .= _sales_order_list(            $self, $groups{sales_orders})             if $groups{sales_orders};
21
  $output .= _sales_delivery_order_list(   $self, $groups{sales_delivery_orders})    if $groups{sales_delivery_orders};
22
  $output .= _sales_invoice_list(          $self, $groups{sales_invoices})           if $groups{sales_invoices};
23
  $output .= _ar_transaction_list(         $self, $groups{ar_transactions})          if $groups{ar_transactions};
28
  $output .= _sales_quotation_list(        $self, $groups{sales_quotations},         %params) if $groups{sales_quotations};
29
  $output .= _sales_order_list(            $self, $groups{sales_orders},             %params) if $groups{sales_orders};
30
  $output .= _sales_delivery_order_list(   $self, $groups{sales_delivery_orders},    %params) if $groups{sales_delivery_orders};
31
  $output .= _sales_invoice_list(          $self, $groups{sales_invoices},           %params) if $groups{sales_invoices};
32
  $output .= _ar_transaction_list(         $self, $groups{ar_transactions},          %params) if $groups{ar_transactions};
24 33

  
25
  $output .= _request_quotation_list(      $self, $groups{purchase_quotations})      if $groups{purchase_quotations};
26
  $output .= _purchase_order_list(         $self, $groups{purchase_orders})          if $groups{purchase_orders};
27
  $output .= _purchase_delivery_order_list($self, $groups{purchase_delivery_orders}) if $groups{purchase_delivery_orders};
28
  $output .= _purchase_invoice_list(       $self, $groups{purchase_invoices})        if $groups{purchase_invoices};
29
  $output .= _ar_transaction_list(         $self, $groups{ar_transactions})          if $groups{ar_transactions};
34
  $output .= _request_quotation_list(      $self, $groups{purchase_quotations},      %params) if $groups{purchase_quotations};
35
  $output .= _purchase_order_list(         $self, $groups{purchase_orders},          %params) if $groups{purchase_orders};
36
  $output .= _purchase_delivery_order_list($self, $groups{purchase_delivery_orders}, %params) if $groups{purchase_delivery_orders};
37
  $output .= _purchase_invoice_list(       $self, $groups{purchase_invoices},        %params) if $groups{purchase_invoices};
38
  $output .= _ar_transaction_list(         $self, $groups{ar_transactions},          %params) if $groups{ar_transactions};
30 39

  
31 40
  return $output || $self->empty_record_list;
32 41
}
......
54 63
    croak "Wrong type for 'columns' argument: not an array reference";
55 64
  }
56 65

  
66
  my %with_columns = map { ($_ => 1) } @{ _arrayify($params{with_columns}) };
67
  if ($with_columns{record_link_direction}) {
68
    push @columns, {
69
      title => $::locale->text('Link direction'),
70
      data  => sub { $_[0]->{_record_link_direction} eq 'from' ? $::locale->text('Row was source for current record') : $::locale->text('Row was created from current record') },
71
    };
72
  }
73

  
57 74
  my %column_meta   = map { $_->name => $_ } @{ $list->[0]->meta->columns       };
58 75
  my %relationships = map { $_->name => $_ } @{ $list->[0]->meta->relationships };
59 76

  
......
141 158
}
142 159

  
143 160
sub _sales_quotation_list {
144
  my ($self, $list) = @_;
161
  my ($self, $list, %params) = @_;
145 162

  
146 163
  return $self->record_list(
147 164
    $list,
......
155 172
      [ $::locale->text('Project'),                 'globalproject', ],
156 173
      [ $::locale->text('Closed'),                  'closed'                                                                   ],
157 174
    ],
175
    %params,
158 176
  );
159 177
}
160 178

  
161 179
sub _request_quotation_list {
162
  my ($self, $list) = @_;
180
  my ($self, $list, %params) = @_;
163 181

  
164 182
  return $self->record_list(
165 183
    $list,
......
173 191
      [ $::locale->text('Project'),                 'globalproject', ],
174 192
      [ $::locale->text('Closed'),                  'closed'                                                                   ],
175 193
    ],
194
    %params,
176 195
  );
177 196
}
178 197

  
179 198
sub _sales_order_list {
180
  my ($self, $list) = @_;
199
  my ($self, $list, %params) = @_;
181 200

  
182 201
  return $self->record_list(
183 202
    $list,
......
192 211
      [ $::locale->text('Project'),                 'globalproject', ],
193 212
      [ $::locale->text('Closed'),                  'closed'                                                                   ],
194 213
    ],
214
    %params,
195 215
  );
196 216
}
197 217

  
198 218
sub _purchase_order_list {
199
  my ($self, $list) = @_;
219
  my ($self, $list, %params) = @_;
200 220

  
201 221
  return $self->record_list(
202 222
    $list,
......
211 231
      [ $::locale->text('Project'),                 'globalproject', ],
212 232
      [ $::locale->text('Closed'),                  'closed'                                                                   ],
213 233
    ],
234
    %params,
214 235
  );
215 236
}
216 237

  
217 238
sub _sales_delivery_order_list {
218
  my ($self, $list) = @_;
239
  my ($self, $list, %params) = @_;
219 240

  
220 241
  return $self->record_list(
221 242
    $list,
......
230 251
      [ $::locale->text('Delivered'),               'delivered'                                                                ],
231 252
      [ $::locale->text('Closed'),                  'closed'                                                                   ],
232 253
    ],
254
    %params,
233 255
  );
234 256
}
235 257

  
236 258
sub _purchase_delivery_order_list {
237
  my ($self, $list) = @_;
259
  my ($self, $list, %params) = @_;
238 260

  
239 261
  return $self->record_list(
240 262
    $list,
......
249 271
      [ $::locale->text('Delivered'),               'delivered'                                                                ],
250 272
      [ $::locale->text('Closed'),                  'closed'                                                                   ],
251 273
    ],
274
    %params,
252 275
  );
253 276
}
254 277

  
255 278
sub _sales_invoice_list {
256
  my ($self, $list) = @_;
279
  my ($self, $list, %params) = @_;
257 280

  
258 281
  return $self->record_list(
259 282
    $list,
......
268 291
      [ $::locale->text('Paid'),                    'paid'                    ],
269 292
      [ $::locale->text('Transaction description'), 'transaction_description' ],
270 293
    ],
294
    %params,
271 295
  );
272 296
}
273 297

  
274 298
sub _purchase_invoice_list {
275
  my ($self, $list) = @_;
299
  my ($self, $list, %params) = @_;
276 300

  
277 301
  return $self->record_list(
278 302
    $list,
......
287 311
      [ $::locale->text('Paid'),                         'paid'                    ],
288 312
      [ $::locale->text('Transaction description'),      'transaction_description' ],
289 313
    ],
314
    %params,
290 315
  );
291 316
}
292 317

  
293 318
sub _ar_transaction_list {
294
  my ($self, $list) = @_;
319
  my ($self, $list, %params) = @_;
295 320

  
296 321
  return $self->record_list(
297 322
    $list,
......
304 329
      [ $::locale->text('Paid'),                    'paid'                    ],
305 330
      [ $::locale->text('Transaction description'), 'transaction_description' ],
306 331
    ],
332
    %params,
307 333
  );
308 334
}
309 335

  
310 336
sub _ap_transaction_list {
311
  my ($self, $list) = @_;
337
  my ($self, $list, %params) = @_;
312 338

  
313 339
  return $self->record_list(
314 340
    $list,
......
321 347
      [ $::locale->text('Paid'),                    'paid'                           ],
322 348
      [ $::locale->text('Transaction description'), 'transaction_description'        ],
323 349
    ],
350
    %params,
324 351
  );
325 352
}
326 353

  
locale/de/all
1125 1125
  'Line Total'                  => 'Zeilensumme',
1126 1126
  'Line and column'             => 'Zeile und Spalte',
1127 1127
  'Line endings'                => 'Zeilenumbr&uuml;che',
1128
  'Link direction'              => 'Verknüpfungsrichtung',
1128 1129
  'Linked Records'              => 'Verknüpfte Belege',
1129 1130
  'List Accounts'               => 'Konten anzeigen',
1130 1131
  'List Languages'              => 'Sprachen anzeigen',
......
1615 1616
  'Right'                       => 'Rechts',
1616 1617
  'Row #1: amount has to be different from zero.' => 'Zeile #1: Der Wert darf nicht 0 sein.',
1617 1618
  'Row number'                  => 'Zeilennummer',
1619
  'Row was created from current record' => 'Zeile wurde aus aktuellem Beleg erstellt',
1620
  'Row was source for current record' => 'Zeile war Quelle für aktuellen Beleg',
1618 1621
  'Run at'                      => 'Ausgeführt um',
1619 1622
  'SAVED'                       => 'Gespeichert',
1620 1623
  'SAVED FOR DUNNING'           => 'Gespeichert',

Auch abrufbar als: Unified diff