Revision 0c09beb4
Von Moritz Bunkus vor etwa 9 Jahren hinzugefügt
SL/Controller/RecordLinks.pm | ||
---|---|---|
use SL::DB::Order;
|
||
use SL::DB::DeliveryOrder;
|
||
use SL::DB::Invoice;
|
||
use SL::DB::Letter;
|
||
use SL::DB::PurchaseInvoice;
|
||
use SL::DB::RecordLink;
|
||
use SL::DB::RequirementSpec;
|
||
... | ... | |
__PACKAGE__->run_before('check_link_params', only => [ qw( ajax_add_list ajax_add_do) ]);
|
||
|
||
my %link_type_defaults = (
|
||
filter => 'type_filter',
|
||
project => 'globalproject',
|
||
description => 'transaction_description',
|
||
date => 'transdate',
|
||
filter => 'type_filter',
|
||
project => 'globalproject',
|
||
description => 'transaction_description',
|
||
description_title => t8('Transaction description'),
|
||
date => 'transdate',
|
||
);
|
||
|
||
my @link_type_specifics = (
|
||
{ title => t8('Requirement spec'), type => 'requirement_spec', model => 'RequirementSpec', number => 'id', project => 'project', description => 'title', date => undef, filter => 'working_copy_filter', },
|
||
{ 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('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', },
|
||
... | ... | |
{ title => t8('Purchase Order'), type => 'purchase_order', model => 'Order', number => 'ordnumber', },
|
||
{ title => t8('Purchase delivery order'), type => 'purchase_delivery_order', model => 'DeliveryOrder', number => 'donumber', },
|
||
{ title => t8('Purchase Invoice'), type => 'purchase_invoice', model => 'PurchaseInvoice', number => 'invnumber', },
|
||
{ title => t8('Letter'), type => 'letter', model => 'Letter', number => 'letternumber', description => 'subject', description_title => t8('Subject'), date => 'date', project => undef },
|
||
);
|
||
|
||
my @link_types = map { +{ %link_type_defaults, %{ $_ } } } @link_type_specifics;
|
||
... | ... | |
my ($self) = @_;
|
||
|
||
my $manager = 'SL::DB::Manager::' . $self->link_type_desc->{model};
|
||
my $vc = $self->link_type =~ m/sales_|^invoice|requirement_spec$/ ? 'customer' : 'vendor';
|
||
my $vc = $self->link_type =~ m/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};
|
||
my $filter = $self->link_type_desc->{filter};
|
||
|
||
my @where = $filter ? $manager->$filter($self->link_type) : ();
|
||
my @where = $filter && $manager->can($filter) ? $manager->$filter($self->link_type) : ();
|
||
push @where, ("${vc}.${vc}number" => { ilike => '%' . $::form->{vc_number} . '%' }) if $::form->{vc_number};
|
||
push @where, ("${vc}.name" => { ilike => '%' . $::form->{vc_name} . '%' }) if $::form->{vc_name};
|
||
push @where, ($description => { ilike => '%' . $::form->{transaction_description} . '%' }) if $::form->{transaction_description};
|
||
push @where, ("${project}_id" => $::form->{globalproject_id}) if $::form->{globalproject_id};
|
||
push @where, ($project_id => $::form->{globalproject_id}) if $::form->{globalproject_id} && $manager->can($project_id);
|
||
|
||
my $objects = $manager->get_all_sorted(where => \@where, with_objects => [ $vc, $project ]);
|
||
my @with_objects = ($vc);
|
||
push @with_objects, $project if $manager->can($project_id);
|
||
|
||
my $objects = $manager->get_all_sorted(where => \@where, with_objects => \@with_objects);
|
||
my $output = $self->render(
|
||
'record_links/add_list',
|
||
{ output => 0 },
|
||
... | ... | |
vc => $vc,
|
||
number_column => $self->link_type_desc->{number},
|
||
description_column => $description,
|
||
description_title => $self->link_type_desc->{description_title},
|
||
project_column => $project,
|
||
date_column => $self->link_type_desc->{date},
|
||
);
|
SL/DB/Helper/LinkedRecords.pm | ||
---|---|---|
'SL::DB::Invoice' => sub { $_[0]->invnumber },
|
||
'SL::DB::PurchaseInvoice' => sub { $_[0]->invnumber },
|
||
'SL::DB::RequirementSpec' => sub { $_[0]->id },
|
||
'SL::DB::Letter' => sub { $_[0]->letternumber },
|
||
UNKNOWN => '9999999999999999',
|
||
);
|
||
my $number_xtor = sub {
|
||
... | ... | |
purchase_order => 130,
|
||
purchase_delivery_order => 140,
|
||
'SL::DB::PurchaseInvoice' => 150,
|
||
'SL::DB::PurchaseInvoice' => 150,
|
||
'SL::DB::Letter' => 200,
|
||
UNKNOWN => 999,
|
||
);
|
||
my $score_xtor = sub {
|
SL/DB/Letter.pm | ||
---|---|---|
use strict;
|
||
|
||
use SL::DB::Helper::AttrHTML;
|
||
use SL::DB::Helper::LinkedRecords;
|
||
use SL::DB::MetaSetup::Letter;
|
||
use SL::DB::Manager::Letter;
|
||
|
SL/Presenter.pm | ||
---|---|---|
use SL::Presenter::EscapedText;
|
||
use SL::Presenter::Invoice;
|
||
use SL::Presenter::GL;
|
||
use SL::Presenter::Letter;
|
||
use SL::Presenter::Order;
|
||
use SL::Presenter::Part;
|
||
use SL::Presenter::Project;
|
SL/Presenter/Letter.pm | ||
---|---|---|
package SL::Presenter::Letter;
|
||
|
||
use strict;
|
||
|
||
use parent qw(Exporter);
|
||
|
||
use Exporter qw(import);
|
||
our @EXPORT = qw(letter);
|
||
|
||
use Carp;
|
||
|
||
sub letter {
|
||
my ($self, $letter, %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=Letter/edit&letter.id=' . $self->escape($letter->id) . '">',
|
||
$self->escape($letter->letternumber),
|
||
$params{no_link} ? '' : '</a>',
|
||
);
|
||
|
||
return $self->escaped_text($text);
|
||
}
|
||
|
||
1;
|
||
|
||
__END__
|
||
|
||
=pod
|
||
|
||
=encoding utf8
|
||
|
||
=head1 NAME
|
||
|
||
SL::Presenter::Letter - Presenter module for letter objects
|
||
|
||
=head1 SYNOPSIS
|
||
|
||
my $letter = SL::DB::Manager::Letter->get_first(where => [ … ]);
|
||
my $html = SL::Presenter->get->letter($letter, display => 'inline');
|
||
|
||
=head1 FUNCTIONS
|
||
|
||
=over 4
|
||
|
||
=item C<letter $object, %params>
|
||
|
||
Returns a rendered version (actually an instance of
|
||
L<SL::Presenter::EscapedText>) of the letter object C<$object>
|
||
.
|
||
|
||
C<%params> can include:
|
||
|
||
=over 2
|
||
|
||
=item * display
|
||
|
||
Either C<inline> (the default) or C<table-cell>. At the moment both
|
||
representations are identical and produce the invoice number linked
|
||
to the corresponding 'edit' action.
|
||
|
||
=item * no_link
|
||
|
||
If falsish (the default) then the invoice number will be linked to the
|
||
"edit invoice" dialog from the general ledger menu.
|
||
|
||
=back
|
||
|
||
=back
|
||
|
||
=head1 BUGS
|
||
|
||
Nothing here yet.
|
||
|
||
=head1 AUTHOR
|
||
|
||
Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
|
||
|
||
=cut
|
SL/Presenter/Record.pm | ||
---|---|---|
$output .= _sepa_collection_list( $self, $groups{sepa_collections}, %params) if $groups{sepa_collections};
|
||
$output .= _sepa_transfer_list( $self, $groups{sepa_transfers}, %params) if $groups{sepa_transfers};
|
||
|
||
$output .= _letter_list( $self, $groups{letters}, %params) if $groups{letters};
|
||
|
||
$output = $self->render('presenter/record/grouped_record_list', %params, output => $output);
|
||
|
||
return $output;
|
||
... | ... | |
sepa_transfers => sub { (ref($_[0]) eq 'SL::DB::SepaExportItem') && $_[0]->ap_id },
|
||
gl_transactions => sub { (ref($_[0]) eq 'SL::DB::GLTransaction') },
|
||
bank_transactions => sub { (ref($_[0]) eq 'SL::DB::BankTransaction') && $_[0]->id },
|
||
letters => sub { (ref($_[0]) eq 'SL::DB::Letter') && $_[0]->id },
|
||
);
|
||
|
||
my %groups;
|
||
... | ... | |
_sepa_export_list($self, $list, %params, type => 'sepa_collection');
|
||
}
|
||
|
||
sub _letter_list {
|
||
my ($self, $list, %params) = @_;
|
||
|
||
return $self->record_list(
|
||
$list,
|
||
title => $::locale->text('Letters'),
|
||
type => 'letter',
|
||
columns => [
|
||
[ $::locale->text('Date'), 'date' ],
|
||
[ $::locale->text('Letternumber'), sub { $self->letter($_[0], display => 'table-cell') } ],
|
||
[ $::locale->text('Customer'), 'customer' ],
|
||
[ $::locale->text('Reference'), 'reference' ],
|
||
[ $::locale->text('Subject'), 'subject' ],
|
||
],
|
||
%params,
|
||
);
|
||
}
|
||
|
||
1;
|
||
|
||
__END__
|
js/locale/de.js | ||
---|---|---|
"Save and keep open":"Speichern und geöffnet lassen",
|
||
"Section/Function block actions":"Abschnitts-/Funktionsblockaktionen",
|
||
"Select template to paste":"Einzufügende Vorlage auswählen",
|
||
"Subject":"Betreff",
|
||
"Text block actions":"Textblockaktionen",
|
||
"Text block picture actions":"Aktionen für Textblockbilder",
|
||
"The IBAN is missing.":"Die IBAN fehlt.",
|
templates/webpages/letter/edit.html | ||
---|---|---|
|
||
[%- PROCESS 'common/flash.html' %]
|
||
|
||
<div id="oe_tabs" class="tabwidget">
|
||
<ul>
|
||
<li><a href="#ui-tabs-letter">[% LxERP.t8("Letter") %]</a></li>
|
||
[%- IF letter.id %]
|
||
<li><a href="controller.pl?action=RecordLinks/ajax_list&object_model=Letter&object_id=[% HTML.url(letter.id) %]">[% LxERP.t8("Linked Records") %]</a></li>
|
||
[%- END %]
|
||
</ul>
|
||
|
||
<div id="ui-tabs-letter">
|
||
|
||
<table width=100%>
|
||
<tr>
|
||
<td width=50%>
|
||
... | ... | |
</tr>
|
||
</table>
|
||
|
||
</div>
|
||
<div id="ui-tabs-1">
|
||
[%- LxERP.t8("Loading...") %]
|
||
</div>
|
||
</div>
|
||
|
||
<input type="hidden" name="action" value="Letter/dispatch">
|
||
<input class="submit" type="submit" name="action_update" id="update_button" value="[% 'Update' | $T8 %]">
|
||
|
templates/webpages/record_links/add_filter.html | ||
---|---|---|
<td>[% L.input_tag('vc_name', is_sales ? SELF.object.customer.name : SELF.object.vendor.name, style=style) %]</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<tr id="record_links_add_filter_project_row">
|
||
<td>[%- LxERP.t8("Project") %]:</td>
|
||
<td>[% L.select_tag('globalproject_id', PROJECTS, default=SELF.object.globalproject_id, with_empty=1, style=style) %]</td>
|
||
</tr>
|
||
... | ... | |
<!--
|
||
$(function() {
|
||
$('#record_links_add input[name=vc_name]').focus();
|
||
$('#record_links_add_filter_link_type').change(function() {
|
||
var title = $('#record_links_add_filter_link_type').val() == 'requirement_spec' ? kivi.t8('Title') : kivi.t8('Transaction description');
|
||
$('#record_links_add_filter_title').html(title);
|
||
});
|
||
$('#record_links_add_filter_link_type').change(record_links_change_form_to_match_type);
|
||
record_links_change_form_to_match_type();
|
||
});
|
||
|
||
function record_links_reset_form() {
|
||
... | ... | |
}
|
||
});
|
||
}
|
||
|
||
function record_links_change_form_to_match_type() {
|
||
var type = $('#record_links_add_filter_link_type').val();
|
||
var title = type == 'requirement_spec' ? kivi.t8('Title')
|
||
: type == 'letter' ? kivi.t8('Subject')
|
||
: kivi.t8('Transaction description');
|
||
|
||
if (type == 'letter') {
|
||
$('#record_links_add_filter_project_row').hide();
|
||
|
||
} else {
|
||
$('#record_links_add_filter_project_row').show();
|
||
}
|
||
|
||
$('#record_links_add_filter_title').html(title);
|
||
}
|
||
-->
|
||
</script>
|
templates/webpages/record_links/add_list.html | ||
---|---|---|
[% IF date_column %]
|
||
<th>[%- LxERP.t8("Date") %]</th>
|
||
[% END %]
|
||
<th>[% IF SELF.link_type == 'requirement_spec' %][%- LxERP.t8("Title") %][% ELSE %][%- LxERP.t8("Transaction description") %][% END %]</th>
|
||
<th>[%- LxERP.t8("Project") %]</th>
|
||
<th>[% HTML.escape(description_title) %]</th>
|
||
[% IF project_column %]
|
||
<th>[%- LxERP.t8("Project") %]</th>
|
||
[% END %]
|
||
</tr>
|
||
|
||
[%- FOREACH object = OBJECTS %]
|
||
... | ... | |
<td>[%- HTML.escape(object.$date_column.to_kivitendo) %]</td>
|
||
[% END %]
|
||
<td>[%- HTML.escape(object.$description_column) %]</td>
|
||
<td>[%- P.project(object.$project_column, no_link=1) %]</td>
|
||
[% IF project_column %]
|
||
<td>[%- P.project(object.$project_column, no_link=1) %]</td>
|
||
[% END %]
|
||
</tr>
|
||
[%- END %]
|
||
</table>
|
Auch abrufbar als: Unified diff
Briefe mit anderen Dokumenten verknüpfen können