Revision 0c09beb4
Von Moritz Bunkus vor fast 9 Jahren hinzugefügt
SL/Controller/RecordLinks.pm | ||
---|---|---|
10 | 10 |
use SL::DB::Order; |
11 | 11 |
use SL::DB::DeliveryOrder; |
12 | 12 |
use SL::DB::Invoice; |
13 |
use SL::DB::Letter; |
|
13 | 14 |
use SL::DB::PurchaseInvoice; |
14 | 15 |
use SL::DB::RecordLink; |
15 | 16 |
use SL::DB::RequirementSpec; |
... | ... | |
25 | 26 |
__PACKAGE__->run_before('check_link_params', only => [ qw( ajax_add_list ajax_add_do) ]); |
26 | 27 |
|
27 | 28 |
my %link_type_defaults = ( |
28 |
filter => 'type_filter', |
|
29 |
project => 'globalproject', |
|
30 |
description => 'transaction_description', |
|
31 |
date => 'transdate', |
|
29 |
filter => 'type_filter', |
|
30 |
project => 'globalproject', |
|
31 |
description => 'transaction_description', |
|
32 |
description_title => t8('Transaction description'), |
|
33 |
date => 'transdate', |
|
32 | 34 |
); |
33 | 35 |
|
34 | 36 |
my @link_type_specifics = ( |
35 |
{ title => t8('Requirement spec'), type => 'requirement_spec', model => 'RequirementSpec', number => 'id', project => 'project', description => 'title', date => undef, filter => 'working_copy_filter', },
|
|
37 |
{ 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', },
|
|
36 | 38 |
{ title => t8('Sales quotation'), type => 'sales_quotation', model => 'Order', number => 'quonumber', }, |
37 | 39 |
{ title => t8('Sales Order'), type => 'sales_order', model => 'Order', number => 'ordnumber', }, |
38 | 40 |
{ title => t8('Sales delivery order'), type => 'sales_delivery_order', model => 'DeliveryOrder', number => 'donumber', }, |
... | ... | |
41 | 43 |
{ title => t8('Purchase Order'), type => 'purchase_order', model => 'Order', number => 'ordnumber', }, |
42 | 44 |
{ title => t8('Purchase delivery order'), type => 'purchase_delivery_order', model => 'DeliveryOrder', number => 'donumber', }, |
43 | 45 |
{ title => t8('Purchase Invoice'), type => 'purchase_invoice', model => 'PurchaseInvoice', number => 'invnumber', }, |
46 |
{ title => t8('Letter'), type => 'letter', model => 'Letter', number => 'letternumber', description => 'subject', description_title => t8('Subject'), date => 'date', project => undef }, |
|
44 | 47 |
); |
45 | 48 |
|
46 | 49 |
my @link_types = map { +{ %link_type_defaults, %{ $_ } } } @link_type_specifics; |
... | ... | |
114 | 117 |
my ($self) = @_; |
115 | 118 |
|
116 | 119 |
my $manager = 'SL::DB::Manager::' . $self->link_type_desc->{model}; |
117 |
my $vc = $self->link_type =~ m/sales_|^invoice|requirement_spec$/ ? 'customer' : 'vendor';
|
|
120 |
my $vc = $self->link_type =~ m/sales_|^invoice|requirement_spec|letter/ ? 'customer' : 'vendor';
|
|
118 | 121 |
my $project = $self->link_type_desc->{project}; |
122 |
my $project_id = "${project}_id"; |
|
119 | 123 |
my $description = $self->link_type_desc->{description}; |
120 | 124 |
my $filter = $self->link_type_desc->{filter}; |
121 | 125 |
|
122 |
my @where = $filter ? $manager->$filter($self->link_type) : (); |
|
126 |
my @where = $filter && $manager->can($filter) ? $manager->$filter($self->link_type) : ();
|
|
123 | 127 |
push @where, ("${vc}.${vc}number" => { ilike => '%' . $::form->{vc_number} . '%' }) if $::form->{vc_number}; |
124 | 128 |
push @where, ("${vc}.name" => { ilike => '%' . $::form->{vc_name} . '%' }) if $::form->{vc_name}; |
125 | 129 |
push @where, ($description => { ilike => '%' . $::form->{transaction_description} . '%' }) if $::form->{transaction_description}; |
126 |
push @where, ("${project}_id" => $::form->{globalproject_id}) if $::form->{globalproject_id};
|
|
130 |
push @where, ($project_id => $::form->{globalproject_id}) if $::form->{globalproject_id} && $manager->can($project_id);
|
|
127 | 131 |
|
128 |
my $objects = $manager->get_all_sorted(where => \@where, with_objects => [ $vc, $project ]); |
|
132 |
my @with_objects = ($vc); |
|
133 |
push @with_objects, $project if $manager->can($project_id); |
|
134 |
|
|
135 |
my $objects = $manager->get_all_sorted(where => \@where, with_objects => \@with_objects); |
|
129 | 136 |
my $output = $self->render( |
130 | 137 |
'record_links/add_list', |
131 | 138 |
{ output => 0 }, |
... | ... | |
133 | 140 |
vc => $vc, |
134 | 141 |
number_column => $self->link_type_desc->{number}, |
135 | 142 |
description_column => $description, |
143 |
description_title => $self->link_type_desc->{description_title}, |
|
136 | 144 |
project_column => $project, |
137 | 145 |
date_column => $self->link_type_desc->{date}, |
138 | 146 |
); |
SL/DB/Helper/LinkedRecords.pm | ||
---|---|---|
207 | 207 |
'SL::DB::Invoice' => sub { $_[0]->invnumber }, |
208 | 208 |
'SL::DB::PurchaseInvoice' => sub { $_[0]->invnumber }, |
209 | 209 |
'SL::DB::RequirementSpec' => sub { $_[0]->id }, |
210 |
'SL::DB::Letter' => sub { $_[0]->letternumber }, |
|
210 | 211 |
UNKNOWN => '9999999999999999', |
211 | 212 |
); |
212 | 213 |
my $number_xtor = sub { |
... | ... | |
234 | 235 |
purchase_order => 130, |
235 | 236 |
purchase_delivery_order => 140, |
236 | 237 |
'SL::DB::PurchaseInvoice' => 150, |
238 |
'SL::DB::PurchaseInvoice' => 150, |
|
239 |
'SL::DB::Letter' => 200, |
|
237 | 240 |
UNKNOWN => 999, |
238 | 241 |
); |
239 | 242 |
my $score_xtor = sub { |
SL/DB/Letter.pm | ||
---|---|---|
3 | 3 |
use strict; |
4 | 4 |
|
5 | 5 |
use SL::DB::Helper::AttrHTML; |
6 |
use SL::DB::Helper::LinkedRecords; |
|
6 | 7 |
use SL::DB::MetaSetup::Letter; |
7 | 8 |
use SL::DB::Manager::Letter; |
8 | 9 |
|
SL/Presenter.pm | ||
---|---|---|
13 | 13 |
use SL::Presenter::EscapedText; |
14 | 14 |
use SL::Presenter::Invoice; |
15 | 15 |
use SL::Presenter::GL; |
16 |
use SL::Presenter::Letter; |
|
16 | 17 |
use SL::Presenter::Order; |
17 | 18 |
use SL::Presenter::Part; |
18 | 19 |
use SL::Presenter::Project; |
SL/Presenter/Letter.pm | ||
---|---|---|
1 |
package SL::Presenter::Letter; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use parent qw(Exporter); |
|
6 |
|
|
7 |
use Exporter qw(import); |
|
8 |
our @EXPORT = qw(letter); |
|
9 |
|
|
10 |
use Carp; |
|
11 |
|
|
12 |
sub letter { |
|
13 |
my ($self, $letter, %params) = @_; |
|
14 |
|
|
15 |
$params{display} ||= 'inline'; |
|
16 |
|
|
17 |
croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/; |
|
18 |
|
|
19 |
my $text = join '', ( |
|
20 |
$params{no_link} ? '' : '<a href="controller.pl?action=Letter/edit&letter.id=' . $self->escape($letter->id) . '">', |
|
21 |
$self->escape($letter->letternumber), |
|
22 |
$params{no_link} ? '' : '</a>', |
|
23 |
); |
|
24 |
|
|
25 |
return $self->escaped_text($text); |
|
26 |
} |
|
27 |
|
|
28 |
1; |
|
29 |
|
|
30 |
__END__ |
|
31 |
|
|
32 |
=pod |
|
33 |
|
|
34 |
=encoding utf8 |
|
35 |
|
|
36 |
=head1 NAME |
|
37 |
|
|
38 |
SL::Presenter::Letter - Presenter module for letter objects |
|
39 |
|
|
40 |
=head1 SYNOPSIS |
|
41 |
|
|
42 |
my $letter = SL::DB::Manager::Letter->get_first(where => [ … ]); |
|
43 |
my $html = SL::Presenter->get->letter($letter, display => 'inline'); |
|
44 |
|
|
45 |
=head1 FUNCTIONS |
|
46 |
|
|
47 |
=over 4 |
|
48 |
|
|
49 |
=item C<letter $object, %params> |
|
50 |
|
|
51 |
Returns a rendered version (actually an instance of |
|
52 |
L<SL::Presenter::EscapedText>) of the letter object C<$object> |
|
53 |
. |
|
54 |
|
|
55 |
C<%params> can include: |
|
56 |
|
|
57 |
=over 2 |
|
58 |
|
|
59 |
=item * display |
|
60 |
|
|
61 |
Either C<inline> (the default) or C<table-cell>. At the moment both |
|
62 |
representations are identical and produce the invoice number linked |
|
63 |
to the corresponding 'edit' action. |
|
64 |
|
|
65 |
=item * no_link |
|
66 |
|
|
67 |
If falsish (the default) then the invoice number will be linked to the |
|
68 |
"edit invoice" dialog from the general ledger menu. |
|
69 |
|
|
70 |
=back |
|
71 |
|
|
72 |
=back |
|
73 |
|
|
74 |
=head1 BUGS |
|
75 |
|
|
76 |
Nothing here yet. |
|
77 |
|
|
78 |
=head1 AUTHOR |
|
79 |
|
|
80 |
Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt> |
|
81 |
|
|
82 |
=cut |
SL/Presenter/Record.pm | ||
---|---|---|
60 | 60 |
$output .= _sepa_collection_list( $self, $groups{sepa_collections}, %params) if $groups{sepa_collections}; |
61 | 61 |
$output .= _sepa_transfer_list( $self, $groups{sepa_transfers}, %params) if $groups{sepa_transfers}; |
62 | 62 |
|
63 |
$output .= _letter_list( $self, $groups{letters}, %params) if $groups{letters}; |
|
64 |
|
|
63 | 65 |
$output = $self->render('presenter/record/grouped_record_list', %params, output => $output); |
64 | 66 |
|
65 | 67 |
return $output; |
... | ... | |
180 | 182 |
sepa_transfers => sub { (ref($_[0]) eq 'SL::DB::SepaExportItem') && $_[0]->ap_id }, |
181 | 183 |
gl_transactions => sub { (ref($_[0]) eq 'SL::DB::GLTransaction') }, |
182 | 184 |
bank_transactions => sub { (ref($_[0]) eq 'SL::DB::BankTransaction') && $_[0]->id }, |
185 |
letters => sub { (ref($_[0]) eq 'SL::DB::Letter') && $_[0]->id }, |
|
183 | 186 |
); |
184 | 187 |
|
185 | 188 |
my %groups; |
... | ... | |
490 | 493 |
_sepa_export_list($self, $list, %params, type => 'sepa_collection'); |
491 | 494 |
} |
492 | 495 |
|
496 |
sub _letter_list { |
|
497 |
my ($self, $list, %params) = @_; |
|
498 |
|
|
499 |
return $self->record_list( |
|
500 |
$list, |
|
501 |
title => $::locale->text('Letters'), |
|
502 |
type => 'letter', |
|
503 |
columns => [ |
|
504 |
[ $::locale->text('Date'), 'date' ], |
|
505 |
[ $::locale->text('Letternumber'), sub { $self->letter($_[0], display => 'table-cell') } ], |
|
506 |
[ $::locale->text('Customer'), 'customer' ], |
|
507 |
[ $::locale->text('Reference'), 'reference' ], |
|
508 |
[ $::locale->text('Subject'), 'subject' ], |
|
509 |
], |
|
510 |
%params, |
|
511 |
); |
|
512 |
} |
|
513 |
|
|
493 | 514 |
1; |
494 | 515 |
|
495 | 516 |
__END__ |
js/locale/de.js | ||
---|---|---|
65 | 65 |
"Save and keep open":"Speichern und geöffnet lassen", |
66 | 66 |
"Section/Function block actions":"Abschnitts-/Funktionsblockaktionen", |
67 | 67 |
"Select template to paste":"Einzufügende Vorlage auswählen", |
68 |
"Subject":"Betreff", |
|
68 | 69 |
"Text block actions":"Textblockaktionen", |
69 | 70 |
"Text block picture actions":"Aktionen für Textblockbilder", |
70 | 71 |
"The IBAN is missing.":"Die IBAN fehlt.", |
templates/webpages/letter/edit.html | ||
---|---|---|
12 | 12 |
|
13 | 13 |
[%- PROCESS 'common/flash.html' %] |
14 | 14 |
|
15 |
<div id="oe_tabs" class="tabwidget"> |
|
16 |
<ul> |
|
17 |
<li><a href="#ui-tabs-letter">[% LxERP.t8("Letter") %]</a></li> |
|
18 |
[%- IF letter.id %] |
|
19 |
<li><a href="controller.pl?action=RecordLinks/ajax_list&object_model=Letter&object_id=[% HTML.url(letter.id) %]">[% LxERP.t8("Linked Records") %]</a></li> |
|
20 |
[%- END %] |
|
21 |
</ul> |
|
22 |
|
|
23 |
<div id="ui-tabs-letter"> |
|
24 |
|
|
15 | 25 |
<table width=100%> |
16 | 26 |
<tr> |
17 | 27 |
<td width=50%> |
... | ... | |
125 | 135 |
</tr> |
126 | 136 |
</table> |
127 | 137 |
|
138 |
</div> |
|
139 |
<div id="ui-tabs-1"> |
|
140 |
[%- LxERP.t8("Loading...") %] |
|
141 |
</div> |
|
142 |
</div> |
|
143 |
|
|
128 | 144 |
<input type="hidden" name="action" value="Letter/dispatch"> |
129 | 145 |
<input class="submit" type="submit" name="action_update" id="update_button" value="[% 'Update' | $T8 %]"> |
130 | 146 |
|
templates/webpages/record_links/add_filter.html | ||
---|---|---|
31 | 31 |
<td>[% L.input_tag('vc_name', is_sales ? SELF.object.customer.name : SELF.object.vendor.name, style=style) %]</td> |
32 | 32 |
</tr> |
33 | 33 |
|
34 |
<tr> |
|
34 |
<tr id="record_links_add_filter_project_row">
|
|
35 | 35 |
<td>[%- LxERP.t8("Project") %]:</td> |
36 | 36 |
<td>[% L.select_tag('globalproject_id', PROJECTS, default=SELF.object.globalproject_id, with_empty=1, style=style) %]</td> |
37 | 37 |
</tr> |
... | ... | |
59 | 59 |
<!-- |
60 | 60 |
$(function() { |
61 | 61 |
$('#record_links_add input[name=vc_name]').focus(); |
62 |
$('#record_links_add_filter_link_type').change(function() { |
|
63 |
var title = $('#record_links_add_filter_link_type').val() == 'requirement_spec' ? kivi.t8('Title') : kivi.t8('Transaction description'); |
|
64 |
$('#record_links_add_filter_title').html(title); |
|
65 |
}); |
|
62 |
$('#record_links_add_filter_link_type').change(record_links_change_form_to_match_type); |
|
63 |
record_links_change_form_to_match_type(); |
|
66 | 64 |
}); |
67 | 65 |
|
68 | 66 |
function record_links_reset_form() { |
... | ... | |
91 | 89 |
} |
92 | 90 |
}); |
93 | 91 |
} |
92 |
|
|
93 |
function record_links_change_form_to_match_type() { |
|
94 |
var type = $('#record_links_add_filter_link_type').val(); |
|
95 |
var title = type == 'requirement_spec' ? kivi.t8('Title') |
|
96 |
: type == 'letter' ? kivi.t8('Subject') |
|
97 |
: kivi.t8('Transaction description'); |
|
98 |
|
|
99 |
if (type == 'letter') { |
|
100 |
$('#record_links_add_filter_project_row').hide(); |
|
101 |
|
|
102 |
} else { |
|
103 |
$('#record_links_add_filter_project_row').show(); |
|
104 |
} |
|
105 |
|
|
106 |
$('#record_links_add_filter_title').html(title); |
|
107 |
} |
|
94 | 108 |
--> |
95 | 109 |
</script> |
templates/webpages/record_links/add_list.html | ||
---|---|---|
10 | 10 |
[% IF date_column %] |
11 | 11 |
<th>[%- LxERP.t8("Date") %]</th> |
12 | 12 |
[% END %] |
13 |
<th>[% IF SELF.link_type == 'requirement_spec' %][%- LxERP.t8("Title") %][% ELSE %][%- LxERP.t8("Transaction description") %][% END %]</th> |
|
14 |
<th>[%- LxERP.t8("Project") %]</th> |
|
13 |
<th>[% HTML.escape(description_title) %]</th> |
|
14 |
[% IF project_column %] |
|
15 |
<th>[%- LxERP.t8("Project") %]</th> |
|
16 |
[% END %] |
|
15 | 17 |
</tr> |
16 | 18 |
|
17 | 19 |
[%- FOREACH object = OBJECTS %] |
... | ... | |
23 | 25 |
<td>[%- HTML.escape(object.$date_column.to_kivitendo) %]</td> |
24 | 26 |
[% END %] |
25 | 27 |
<td>[%- HTML.escape(object.$description_column) %]</td> |
26 |
<td>[%- P.project(object.$project_column, no_link=1) %]</td> |
|
28 |
[% IF project_column %] |
|
29 |
<td>[%- P.project(object.$project_column, no_link=1) %]</td> |
|
30 |
[% END %] |
|
27 | 31 |
</tr> |
28 | 32 |
[%- END %] |
29 | 33 |
</table> |
Auch abrufbar als: Unified diff
Briefe mit anderen Dokumenten verknüpfen können