Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 3bd01861

Von Kivitendo Admin vor fast 10 Jahren hinzugefügt

  • ID 3bd0186152b02a358563ff441172c23f1fc8fadc
  • Vorgänger 26c66e2c
  • Nachfolger 420354a7

Allgemeine Presenter-Methode für records (ar/ap/gl)

Damit kann man einen HTML-Link für ein einzelnes Record Objekt
erstellen, ohne zu wissen ob es ar, ap oder gl ist.

SL::Presenter->get->record($record, display => 'inline');

Unterschiede anzeigen:

SL/Presenter/Record.pm
5 5
use parent qw(Exporter);
6 6

  
7 7
use Exporter qw(import);
8
our @EXPORT = qw(grouped_record_list empty_record_list record_list);
8
our @EXPORT = qw(grouped_record_list empty_record_list record_list record);
9 9

  
10 10
use SL::Util;
11 11

  
......
19 19
  return [ $array ];
20 20
}
21 21

  
22
sub record {
23
  my ($self, $record, %params) = @_;
24

  
25
  my %grouped = _group_records( [ $record ] ); # pass $record as arrayref
26
  my $type    = (keys %grouped)[0];
27

  
28
  return $self->sales_invoice(   $record, %params) if $type eq 'sales_invoices';
29
  return $self->purchase_invoice($record, %params) if $type eq 'purchase_invoices';
30
  return $self->ar_transaction(  $record, %params) if $type eq 'ar_transactions';
31
  return $self->ap_transaction(  $record, %params) if $type eq 'ap_transactions';
32
  return $self->gl_transaction(  $record, %params) if $type eq 'gl_transactions';
33

  
34
  return '';
35
}
36

  
22 37
sub grouped_record_list {
23 38
  my ($self, $list, %params) = @_;
24 39

  
......
161 176
    ap_transactions          => sub { (ref($_[0]) eq 'SL::DB::PurchaseInvoice') && !$_[0]->invoice                      },
162 177
    sepa_collections         => sub { (ref($_[0]) eq 'SL::DB::SepaExportItem')  &&  $_[0]->ar_id                        },
163 178
    sepa_transfers           => sub { (ref($_[0]) eq 'SL::DB::SepaExportItem')  &&  $_[0]->ap_id                        },
179
    gl_transactions          => sub { (ref($_[0]) eq 'SL::DB::GLTransaction')                                           },
164 180
  );
165 181

  
166 182
  my %groups;
......
478 494

  
479 495
=over 4
480 496

  
497
=item C<record>
498

  
499
Returns a rendered version (actually an instance of
500
L<SL::Presenter::EscapedText>) of a single ar, ap or gl object.
501

  
502
Example:
503
  # fetch the record from a random acc_trans object and print its link (could be ar, ap or gl)
504
  my $record = SL::DB::Manager::AccTransaction->get_first()->record;
505
  my $html   = SL::Presenter->get->record($record, display => 'inline');
506

  
507
=item C<grouped_record_list $list, %params>
508

  
481 509
=item C<empty_record_list>
482 510

  
483 511
Returns a rendered version (actually an instance of

Auch abrufbar als: Unified diff