my $self = shift;
my %params = @_;
- Common::check_params(\%params, qw(id));
+ Common::check_params(\%params, qw(id vc));
my $myconfig = \%main::myconfig;
my $form = $main::form;
+ my $vc = $params{vc} eq 'customer' ? 'customer' : 'vendor';
+ my $arap = $params{vc} eq 'customer' ? 'ar' : 'ap';
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
my ($joins, $columns);
if ($params{details}) {
- $columns = ', ap.invoice';
- $joins = 'LEFT JOIN ap ON (se.ap_id = ap.id)';
+ $columns = ', arap.invoice';
+ $joins = "LEFT JOIN ${arap} arap ON (se.${arap}_id = arap.id)";
}
my $query =
my ($columns, $joins);
if ($params{details}) {
- $columns = qq|, ap.invnumber, ap.invoice, v.name AS vendor_name, c.accno AS chart_accno, c.description AS chart_description|;
- $joins = qq|LEFT JOIN ap ON (sei.ap_id = ap.id)
- LEFT JOIN vendor v ON (ap.vendor_id = v.id)
- LEFT JOIN chart c ON (sei.chart_id = c.id)|;
+ $columns = qq|, arap.invnumber, arap.invoice, vc.name AS vc_name, c.accno AS chart_accno, c.description AS chart_description|;
+ $joins = qq|LEFT JOIN ${arap} arap ON (sei.${arap}_id = arap.id)
+ LEFT JOIN ${vc} vc ON (arap.${vc}_id = vc.id)
+ LEFT JOIN chart c ON (sei.chart_id = c.id)|;
}
$query = qq|SELECT sei.*
FROM sepa_export_items sei
$joins
WHERE sei.sepa_export_id = ?|;
+
$export->{items} = selectall_hashref_query($form, $dbh, $query, conv_i($params{id}));
} else {
$form->{jsscript} = 1;
$form->header();
- print $form->parse_html_template('sepa/bank_transfer_search');
+ print $form->parse_html_template('sepa/bank_transfer_search', { vc => $vc });
$main::lxdebug->leave_sub();
}
$report->set_options('top_info_text' => join("\n", @options),
'raw_top_info_text' => $form->parse_html_template('sepa/bank_transfer_list_top'),
- 'raw_bottom_info_text' => $form->parse_html_template('sepa/bank_transfer_list_bottom', { 'show_buttons' => $open_available }),
+ 'raw_bottom_info_text' => $form->parse_html_template('sepa/bank_transfer_list_bottom', { 'show_buttons' => $open_available, vc => $vc }),
'std_column_visibility' => 1,
'output_format' => 'HTML',
'title' => $form->{title},
my $form = $main::form;
my $locale = $main::locale;
+ my $vc = $form->{vc} eq 'customer' ? 'customer' : 'vendor';
my @ids = ();
if (!$form->{mode} || ($form->{mode} eq 'single')) {
my $export;
foreach my $id (@ids) {
- my $curr_export = SL::SEPA->retrieve_export('id' => $id, 'details' => 1);
+ my $curr_export = SL::SEPA->retrieve_export('id' => $id, 'details' => 1, 'vc' => $vc);
foreach my $item (@{ $curr_export->{items} }) {
map { $item->{"export_${_}"} = $curr_export->{$_} } grep { !ref $curr_export->{$_} } keys %{ $curr_export };
[%- USE T8 %]
[% USE HTML %]
[% USE LxERP %]
+[% IF vc == 'vendor' %]
+ [% SET is_vendor = 1 %]
+ [% SET arap = 'ap' %]
+ [% SET iris = 'ir' %]
+[% ELSE %]
+ [% SET is_vendor = 0 %]
+ [% SET arap = 'ar' %]
+ [% SET iris = 'is' %]
+[%- END %]
<body>
<p><div class="listtop">[% title %]: [% HTML.escape(export.ids.join(', ')) %]</div></p>
<th class="listheading" align="center"><input type="checkbox" id="select_all"></th>
[%- END %]
<th class="listheading">[% 'Invoice' | $T8 %]</th>
- <th class="listheading">[% 'Vendor' | $T8 %]</th>
- <th class="listheading" colspan="2">[% 'Source bank account' | $T8 %]</th>
- <th class="listheading" colspan="2">[% 'Target bank account' | $T8 %]</th>
+ <th class="listheading">[%- IF is_vendor %][% 'Vendor' | $T8 %][%- ELSE %][%- LxERP.t8('Customer') %][%- END %]</th>
+ [%- IF is_vendor %]
+ <th class="listheading" colspan="2">[% 'Source bank account' | $T8 %]</th>
+ <th class="listheading" colspan="2">[% 'Target bank account' | $T8 %]</th>
+ [%- ELSE %]
+ <th class="listheading" colspan="2">[% 'Target bank account' | $T8 %]</th>
+ <th class="listheading" colspan="2">[% 'Source bank account' | $T8 %]</th>
+ [%- END %]
<th class="listheading" align="right">[% 'Amount' | $T8 %]</th>
<th class="listheading">[% 'Reference' | $T8 %]</th>
<th class="listheading" align="right">[% 'Requested execution date' | $T8 %]</th>
</td>
[%- END %]
<td>
- <a href="[% IF item.invoice %]ir[% ELSE %]ap[% END %].pl?action=edit&type=invoice&id=[% HTML.url(item.ap_id) %]">[% HTML.escape(item.invnumber) %]</a>
+ <a href="[% IF item.invoice %][% iris %][% ELSE %][% arap %][% END %].pl?action=edit&type=invoice&id=[% IF is_vendor %][% HTML.url(item.ap_id) %][% ELSE %][% HTML.url(item.ar_id) %][% END %]">[% HTML.escape(item.invnumber) %]</a>
</td>
- <td>[% HTML.escape(item.vendor_name) %]</td>
+ <td>[% HTML.escape(item.vc_name) %]</td>
<td>[% HTML.escape(item.our_iban) %]</td>
<td>[% HTML.escape(item.our_bic) %]</td>
- <td>[% HTML.escape(item.vendor_iban) %]</td>
- <td>[% HTML.escape(item.vendor_bic) %]</td>
+ <td>[% HTML.escape(item.vc_iban) %]</td>
+ <td>[% HTML.escape(item.vc_bic) %]</td>
<td align="right">[% HTML.escape(LxERP.format_amount(item.amount, 2)) %]</td>
<td>[% HTML.escape(item.reference) %]</td>
<td align="right">[% HTML.escape(item.requested_execution_date) %]</td>
[%- END %]
[%- END %]
[%- END %]
+
+ <input type="hidden" name="vc" value="[% HTML.escape(vc) %]">
</form>
</body>
[%- IF show_buttons %]
<input type="hidden" name="action" value="dispatcher">
<input type="hidden" name="mode" value="multi">
+ <input type="hidden" name="vc" value="[%- HTML.escape(vc) %]">
<p>
<input type="submit" class="submit" name="action_bank_transfer_download_sepa_xml" value="[% 'SEPA XML download' | $T8 %]">