Revision d0172f91
Von Moritz Bunkus vor fast 12 Jahren hinzugefügt
SL/Controller/RecordLinks.pm | ||
---|---|---|
use SL::DB::PurchaseInvoice;
|
||
use SL::Locale::String;
|
||
|
||
__PACKAGE__->run_before('check_object_params', only => [ qw(ajax_list ajax_delete) ]);
|
||
|
||
#
|
||
# actions
|
||
#
|
||
... | ... | |
my ($self) = @_;
|
||
|
||
eval {
|
||
die $::locale->text("Invalid parameters") if (!$::form->{object_id} || ($::form->{object_model} !~ m/^(?:Order|DeliveryOrder|Invoice|PurchaseInvoice)$/));
|
||
|
||
my $model = 'SL::DB::' . $::form->{object_model};
|
||
my $object = $model->new(id => $::form->{object_id})->load || die $::locale->text("Record not found");
|
||
my $linked_records = $object->linked_records(direction => 'both');
|
||
my $output = SL::Presenter->get->grouped_record_list($linked_records, with_columns => [ qw(record_link_direction) ]);
|
||
my $output = SL::Presenter->get->grouped_record_list(
|
||
$linked_records,
|
||
with_columns => [ qw(record_link_direction) ],
|
||
edit_record_links => 1,
|
||
object_model => $::form->{object_model},
|
||
object_id => $::form->{object_id},
|
||
);
|
||
$self->render(\$output, { layout => 0, process => 0 });
|
||
|
||
1;
|
||
... | ... | |
};
|
||
}
|
||
|
||
sub action_ajax_delete {
|
||
my ($self) = @_;
|
||
|
||
my $prefix = $::form->{form_prefix} || 'record_links';
|
||
foreach my $str (@{ $::form->{"${prefix}_delete"} || [] }) {
|
||
my ($from_table, $from_id, $to_table, $to_id) = split m/__/, $str, 4;
|
||
$from_id *= 1;
|
||
$to_id *= 1;
|
||
|
||
next if !$from_table || !$from_id || !$to_table || !$to_id;
|
||
|
||
# $::lxdebug->message(0, "INSERT INTO record_links (from_table, from_id, to_table, to_id) VALUES ('${from_table}', ${from_id}, '${to_table}', ${to_id});");
|
||
|
||
SL::DB::Manager::RecordLink->delete_all(where => [
|
||
from_table => $from_table,
|
||
from_id => $from_id,
|
||
to_table => $to_table,
|
||
to_id => $to_id,
|
||
]);
|
||
}
|
||
|
||
$self->action_ajax_list;
|
||
}
|
||
|
||
#
|
||
# filters
|
||
#
|
||
|
||
sub check_object_params {
|
||
my ($self) = @_;
|
||
|
||
return $::form->{object_id} && ($::form->{object_model} =~ m/^(?:Order|DeliveryOrder|Invoice|PurchaseInvoice)$/);
|
||
}
|
||
|
||
1;
|
SL/Presenter/Record.pm | ||
---|---|---|
sub grouped_record_list {
|
||
my ($self, $list, %params) = @_;
|
||
|
||
%params = map { exists $params{$_} ? ($_ => $params{$_}) : () } qw(selectable with_columns);
|
||
%params = map { exists $params{$_} ? ($_ => $params{$_}) : () } qw(edit_record_links form_prefix with_columns object_id object_model);
|
||
$params{form_prefix} ||= 'record_links';
|
||
|
||
my %groups = _group_records($list);
|
||
my $output = '';
|
||
... | ... | |
$output .= _purchase_invoice_list( $self, $groups{purchase_invoices}, %params) if $groups{purchase_invoices};
|
||
$output .= _ar_transaction_list( $self, $groups{ar_transactions}, %params) if $groups{ar_transactions};
|
||
|
||
$output = $self->render('presenter/record/grouped_record_list', %params, output => $output, nownow => DateTime->now) if $output;
|
||
|
||
return $output || $self->empty_record_list;
|
||
}
|
||
|
||
... | ... | |
push @row, \%cell;
|
||
}
|
||
|
||
push @data, \@row;
|
||
push @data, { columns => \@row, record_link => $obj->{_record_link} };
|
||
}
|
||
|
||
my @header =
|
||
map +{ value => $columns[$_]->{title},
|
||
alignment => $data[0]->[$_]->{alignment},
|
||
alignment => $data[0]->{columns}->[$_]->{alignment},
|
||
}, (0..scalar(@columns) - 1);
|
||
|
||
$params{form_prefix} ||= 'record_links';
|
||
|
||
return $self->render(
|
||
'presenter/record/record_list',
|
||
%params,
|
||
... | ... | |
|
||
Objects of unknown types are skipped.
|
||
|
||
Parameters are passed to C<record_list> include C<with_objects> and
|
||
C<edit_record_links>.
|
||
|
||
=item C<record_list $list, %params>
|
||
|
||
Returns a rendered version (actually an instance of
|
||
... | ... | |
expected. The corresponding hash keys are C<title>, C<data> and
|
||
C<link>.
|
||
|
||
=item C<with_columns>
|
||
|
||
Can be set by the caller to indicate additional columns to
|
||
list. Currently supported:
|
||
|
||
=over 2
|
||
|
||
=item C<record_link_destination>
|
||
|
||
The record link destination. Requires that the records to list have
|
||
been retrieved via the L<SL::DB::Helper::LinkedRecords> helper.
|
||
|
||
=back
|
||
|
||
=item C<edit_record_links>
|
||
|
||
If trueish additional controls will be rendered that allow the user to
|
||
remove and add record links. Requires that the records to list have
|
||
been retrieved via the L<SL::DB::Helper::LinkedRecords> helper.
|
||
|
||
=back
|
||
|
||
=back
|
locale/de/all | ||
---|---|---|
'Delete delivery order' => 'Lieferschein löschen',
|
||
'Delete drafts' => 'Entwürfe löschen',
|
||
'Delete group' => 'Gruppe löschen',
|
||
'Delete links' => 'Verknüpfungen löschen',
|
||
'Delete profile' => 'Profil löschen',
|
||
'Delete transaction' => 'Buchung löschen',
|
||
'Deleted' => 'Gelöscht',
|
||
... | ... | |
'Do you really want to delete AP transaction #1?' => 'Wollen Sie wirklich die Kreditorenbuchung #1 löschen?',
|
||
'Do you really want to delete AR transaction #1?' => 'Wollen Sie wirklich die Debitorenbuchung #1 löschen?',
|
||
'Do you really want to delete GL transaction #1?' => 'Wollen Sie wirklich die Dialogbuchung #1 löschen?',
|
||
'Do you really want to delete the selected links?' => 'Wollen Sie wirklich die ausgewählten Verknüpfungen löschen?',
|
||
'Do you really want to delete this group?' => 'Gruppe wirklich löschen?',
|
||
'Do you really want to delete this object?' => 'Wollen Sie dieses Objekt wirklich löschen?',
|
||
'Do you really want to delete this warehouse?' => 'Wollen Sie dieses Lager wirklich löschen?',
|
||
... | ... | |
'Inv. Duedate' => 'Rg. Fälligkeit',
|
||
'Invalid' => 'Ungültig',
|
||
'Invalid follow-up ID.' => 'Ungültige Wiedervorlage-ID.',
|
||
'Invalid parameters' => 'Ungültige Parameter',
|
||
'Invalid quantity.' => 'Die Mengenangabe ist ungültig.',
|
||
'Invalid request type \'#1\'' => 'Ungültiger Request-Typ \'#1\'',
|
||
'Invdate' => 'Rechnungsdatum',
|
templates/webpages/presenter/record/grouped_record_list.html | ||
---|---|---|
[%- USE LxERP -%][%- USE L -%][%- USE HTML -%][%- USE JavaScript -%]
|
||
|
||
<div id="[% form_prefix %]_list">
|
||
<p>[% nownow %]</p>
|
||
|
||
[% output %]
|
||
|
||
[%- IF edit_record_links %]
|
||
<div>
|
||
[% L.button_tag(form_prefix _ '_delete()', LxERP.t8('Delete links')) %]
|
||
</div>
|
||
|
||
<script type="text/javascript">
|
||
<!--
|
||
function [% form_prefix %]_delete() {
|
||
var checkboxes = $('.record_links_delete').filter(function () { return $(this).attr('checked'); });
|
||
|
||
if ((checkboxes.size() == 0) || !confirm('[% LxERP.t8('Do you really want to delete the selected links?') %]'))
|
||
return false;
|
||
|
||
var data = {
|
||
action: 'RecordLinks/ajax_delete',
|
||
object_model: '[% JavaScript.escape(object_model) %]',
|
||
object_id: '[% JavaScript.escape(object_id) %]'
|
||
};
|
||
|
||
$.ajax({
|
||
url: "controller.pl?" + checkboxes.serialize(),
|
||
data: data,
|
||
success: function(new_data) { $('#[% form_prefix %]_list').replaceWith(new_data); }
|
||
});
|
||
|
||
return false;
|
||
}
|
||
|
||
-->
|
||
</script>
|
||
[%- END %]
|
||
</div>
|
templates/webpages/presenter/record/record_list.html | ||
---|---|---|
<table style="width: 100%">
|
||
<thead>
|
||
<tr>
|
||
[%- IF edit_record_links %]<th class="listheading"></th>[%- END %]
|
||
[%- FOREACH column = TABLE_HEADER %]
|
||
<th class="listheading"[% IF column.alignment %] align="[% column.alignment %]"[% END %]>[%- P.escape(column.value) %]</th>
|
||
[%- END %]
|
||
... | ... | |
<tbody>
|
||
[%- FOREACH row = TABLE_ROWS %]
|
||
<tr class="listrow[% loop.count % 2 %]">
|
||
[%- FOREACH column = row %]
|
||
[%- IF edit_record_links %]
|
||
<td>[%- L.checkbox_tag(form_prefix _ '_delete[]', 'value'=row.record_link.from_table _ '__' _ row.record_link.from_id _ '__' _ row.record_link.to_table _ '__' _ row.record_link.to_id, 'class'='record_links_delete') %]</td>
|
||
[%- END %]
|
||
[%- FOREACH column = row.columns %]
|
||
<td[% IF column.alignment %] align="[% column.alignment %]"[% END %]>
|
||
[%- IF column.link %]<a href="[% column.link %]">[%- END %]
|
||
[%- P.escape(column.value) %]
|
Auch abrufbar als: Unified diff
Verknüpfte Belege: Implementation "Verknüpfungen löschen"