$query =
qq|SELECT
- a.id, a.ordnumber, a.transdate, a.invnumber, a.amount,
+ a.id, a.ordnumber, a.transdate, a.invnumber, a.amount, a.language_id,
ct.name AS customername, a.customer_id, a.duedate,
a.amount - a.paid AS open_amount,
my $sortorder = join ', ', map { "$_ $sortdir" } @{ $sort_columns{$sortkey} };
my $query =
- qq|SELECT a.id, a.ordnumber, a.invoice, a.transdate, a.invnumber, a.amount,
+ qq|SELECT a.id, a.ordnumber, a.invoice, a.transdate, a.invnumber, a.amount, a.language_id,
ct.name AS customername, ct.id AS customer_id, a.duedate, da.fee,
da.interest, dn.dunning_description, da.transdate AS dunning_date,
da.duedate AS dunning_duedate, da.dunning_id, da.dunning_config_id,
map { $_->{SELECTED} = $_->{id} == $row->{next_dunning_config_id} } @{ $row->{DUNNING_CONFIG } };
}
map { $row->{$_} = $form->format_amount(\%myconfig, $row->{$_} * 1, -2) } qw(amount open_amount fee interest);
+
+ if ($row->{'language_id'}) {
+ $row->{language} = SL::DB::Manager::Language->find_by('id' => $row->{'language_id'})->{'description'};
+ }
}
$form->get_lists('printers' => 'printers',
'no_opendocument' => 1,);
$form->header();
+ $form->{onload} = "document.getElementsByName('language_id')[0].disabled =
+ !document.getElementsByName('force_lang')[0].checked;";
print $form->parse_html_template("dunning/show_invoices");
$main::lxdebug->leave_sub();
my @rows = ();
undef($form->{DUNNING_PDFS});
+ my $saved_language_id = $form->{language_id};
+
if ($form->{groupinvoices}) {
my %dunnings_for;
push @{ $level }, { "row" => $i,
"invoice_id" => $form->{"inv_id_$i"},
"customer_id" => $form->{"customer_id_$i"},
+ "language_id" => $form->{"language_id_$i"},
"next_dunning_config_id" => $form->{"next_dunning_config_id_$i"},
"email" => $form->{"email_$i"}, };
}
foreach my $levels (values %dunnings_for) {
foreach my $level (values %{ $levels }) {
next unless scalar @{ $level };
-
+ if (!$form->{force_lang}) {
+ $form->{language_id} = @{$level}[0]->{language_id};
+ }
DN->save_dunning(\%myconfig, $form, $level);
}
}
my $level = [ { "row" => $i,
"invoice_id" => $form->{"inv_id_$i"},
"customer_id" => $form->{"customer_id_$i"},
+ "language_id" => $form->{"language_id_$i"},
"next_dunning_config_id" => $form->{"next_dunning_config_id_$i"},
"email" => $form->{"email_$i"}, } ];
+ if (!$form->{force_lang}) {
+ $form->{language_id} = @{$level}[0]->{language_id};
+ }
DN->save_dunning(\%myconfig, $form, $level);
}
}
+ $form->{language_id} = $saved_language_id;
+
if($form->{DUNNING_PDFS}) {
DN->melt_pdfs(\%myconfig, $form, $form->{copies});
}
'checkbox' => { 'text' => '', 'visible' => 'HTML' },
'dunning_description' => { 'text' => $locale->text('Dunning Level') },
'customername' => { 'text' => $locale->text('Customername') },
+ 'language' => { 'text' => $locale->text('Language') },
'invnumber' => { 'text' => $locale->text('Invnumber') },
'transdate' => { 'text' => $locale->text('Invdate') },
'duedate' => { 'text' => $locale->text('Invoice Duedate') },
);
$report->set_columns(%column_defs);
- $report->set_column_order(qw(checkbox dunning_description customername invnumber transdate
+ $report->set_column_order(qw(checkbox dunning_description customername language invnumber transdate
duedate amount dunning_date dunning_duedate fee interest salesman));
$report->set_sort_indicator($form->{sort}, $form->{sortdir});
my $edit_url = sub { build_std_url('script=' . ($_[0]->{invoice} ? 'is' : 'ar') . '.pl', 'action=edit', 'callback') . '&id=' . $::form->escape($_[0]->{id}) };
- my $print_url = build_std_url('action=print_dunning', 'format=pdf', 'media=screen') . '&dunning_id=';
+ my $print_url = sub { build_std_url('action=print_dunning', 'format=pdf', 'media=screen', 'dunning_id='.$_[0]->{dunning_id}, 'language_id=' . $_[0]->{language_id}) };
my $sort_url = build_std_url('action=show_dunning', grep { $form->{$_} } @filter_field_list);
foreach my $name (qw(dunning_description customername invnumber transdate duedate dunning_date dunning_duedate salesman)) {
$first_row_for_dunning = 1;
}
+ if ($ref->{'language_id'}) {
+ $ref->{language} = SL::DB::Manager::Language->find_by('id' => $ref->{'language_id'})->{'description'};
+ }
+
my $row = { };
foreach my $column (keys %{ $ref }) {
$row->{$column} = {
'align' => $alignment{$column},
'link' => ( $column eq 'invnumber' ? $edit_url->($ref)
- : $column eq 'dunning_description' ? $print_url . E($ref->{dunning_id})
+ : $column eq 'dunning_description' ? $print_url->($ref)
: ''),
};
}
'align' => 'center',
};
+ if ($first_row_for_dunning) {
+ $row->{language} = {'raw_data' => $cgi->hidden('-name' => "language_id_$i", '-value' => $ref->{language_id})
+ . " $ref->{language}" };
+ } else {
+ $row->{language} = { };
+ }
+
push @{ $current_dunning_rows }, $row;
$previous_dunning_id = $ref->{dunning_id};
$report->set_options_from_form();
+ $form->{onload} = "document.getElementsByName('language_id')[0].disabled =
+ !document.getElementsByName('force_lang')[0].checked;";
$report->generate_with_headers();
$main::lxdebug->leave_sub();
$form->{rowcount} = 1;
$form->{selected_1} = 1;
$form->{dunning_id_1} = $form->{dunning_id};
+ $form->{language_id_1} = $form->{language_id};
print_multiple();
$form->{title} = $locale->text('Print dunnings');
my @dunning_ids = map { $form->{"dunning_id_$_"} } grep { $form->{"selected_$_"} } (1..$form->{rowcount});
+ my @language_ids = map { $form->{"language_id_$_"} } grep { $form->{"selected_$_"} } (1..$form->{rowcount});
if (!scalar @dunning_ids) {
$form->error($locale->text('No dunnings have been selected for printing.'));
$form->{DUNNING_PDFS} = [];
+ my $saved_language_id = $form->{language_id};
+ my $i = 0;
foreach my $dunning_id (@dunning_ids) {
+ if (!$form->{force_lang}) {
+ $form->{language_id} = $language_ids[$i];
+ }
DN->print_invoice_for_fees(\%myconfig, $form, $dunning_id);
DN->print_dunning(\%myconfig, $form, $dunning_id);
+ $i++;
}
+ $form->{language_id} = $saved_language_id;
if (scalar @{ $form->{DUNNING_PDFS} }) {
$form->{dunning_id} = strftime("%Y%m%d", localtime time);
[% L.javascript_tag('jquery.checkall') %]
[% SET all_active = 1 %][% FOREACH row = DUNNINGS %][% IF !row.active %][% SET all_active = 0 %][% LAST %][% END %][% END %]
[% SET all_email = 1 %][% FOREACH row = DUNNINGS %][% IF !row.email %][% SET all_email = 0 %][% LAST %][% END %][% END %]
-<body>
+<body [% IF onload %] onload="[% onload %]"[% END %]>
+
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/dunning.js"></script>
</th>
<th class="listheading">[% 'Customername' | $T8 %]</th>
+ <th class="listheading">[% 'Language' | $T8 %]</th>
<th class="listheading">[% 'Invno.' | $T8 %]</th>
<th class="listheading">[% 'Invdate' | $T8 %]</th>
<th class="listheading">[% 'Inv. Duedate' | $T8 %]</th>
<td><input type="checkbox" name="active_[% loop.count %]" value="1" [% IF row.active %]checked[% END %]></td>
<td><input type="checkbox" name="email_[% loop.count %]" value="1" [% IF row.email %]checked[% END %]></td>
<td><input type="hidden" name="customername_[% loop.count %]" size="6" value="[% HTML.escape(row.customername) %]">[% HTML.escape(row.customername) %]</td>
+ <td><input type="hidden" name="language_id_[% loop.count %]" size="6" value="[% HTML.escape(row.language_id) %]">[% HTML.escape(row.language) %]</td>
<td>
<input type="hidden" name="invnumber_[% loop.count %]" size="6" value="[% HTML.escape(row.invnumber) %]">
<a href="is.pl?action=edit&type=invoice&id=[% row.id | url %]">[% HTML.escape(row.invnumber) %]</a>
<hr size=3 noshade>
+ <input type="checkbox" name="force_lang" size="6" value="1" onclick="document.getElementsByName('language_id')[0].disabled = !document.getElementsByName('force_lang')[0].checked;">
+ [% 'Override invoice language' | T8 %]
[% PRINT_OPTIONS %]
<br>