Revision 3bd01861
Von Kivitendo Admin vor etwa 10 Jahren hinzugefügt
SL/Presenter/Record.pm | ||
---|---|---|
use parent qw(Exporter);
|
||
|
||
use Exporter qw(import);
|
||
our @EXPORT = qw(grouped_record_list empty_record_list record_list);
|
||
our @EXPORT = qw(grouped_record_list empty_record_list record_list record);
|
||
|
||
use SL::Util;
|
||
|
||
... | ... | |
return [ $array ];
|
||
}
|
||
|
||
sub record {
|
||
my ($self, $record, %params) = @_;
|
||
|
||
my %grouped = _group_records( [ $record ] ); # pass $record as arrayref
|
||
my $type = (keys %grouped)[0];
|
||
|
||
return $self->sales_invoice( $record, %params) if $type eq 'sales_invoices';
|
||
return $self->purchase_invoice($record, %params) if $type eq 'purchase_invoices';
|
||
return $self->ar_transaction( $record, %params) if $type eq 'ar_transactions';
|
||
return $self->ap_transaction( $record, %params) if $type eq 'ap_transactions';
|
||
return $self->gl_transaction( $record, %params) if $type eq 'gl_transactions';
|
||
|
||
return '';
|
||
}
|
||
|
||
sub grouped_record_list {
|
||
my ($self, $list, %params) = @_;
|
||
|
||
... | ... | |
ap_transactions => sub { (ref($_[0]) eq 'SL::DB::PurchaseInvoice') && !$_[0]->invoice },
|
||
sepa_collections => sub { (ref($_[0]) eq 'SL::DB::SepaExportItem') && $_[0]->ar_id },
|
||
sepa_transfers => sub { (ref($_[0]) eq 'SL::DB::SepaExportItem') && $_[0]->ap_id },
|
||
gl_transactions => sub { (ref($_[0]) eq 'SL::DB::GLTransaction') },
|
||
);
|
||
|
||
my %groups;
|
||
... | ... | |
|
||
=over 4
|
||
|
||
=item C<record>
|
||
|
||
Returns a rendered version (actually an instance of
|
||
L<SL::Presenter::EscapedText>) of a single ar, ap or gl object.
|
||
|
||
Example:
|
||
# fetch the record from a random acc_trans object and print its link (could be ar, ap or gl)
|
||
my $record = SL::DB::Manager::AccTransaction->get_first()->record;
|
||
my $html = SL::Presenter->get->record($record, display => 'inline');
|
||
|
||
=item C<grouped_record_list $list, %params>
|
||
|
||
=item C<empty_record_list>
|
||
|
||
Returns a rendered version (actually an instance of
|
Auch abrufbar als: Unified diff
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');