-
- $form->{title} |
-
-
-
-
-
- |
-
-
-
- |
-
-
-$jsscript
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-|;
+ $TMPL_VAR{is_type_credit_note} = $form->{type} eq "credit_note";
+ $TMPL_VAR{is_format_html} = $form->{format} eq 'html';
+ $TMPL_VAR{dateformat} = $myconfig{dateformat};
+ $TMPL_VAR{numberformat} = $myconfig{numberformat};
- foreach $item (split / /, $form->{taxaccounts}) {
- print qq|
-
-
-
-|;
- }
- $lxdebug->leave_sub();
-}
-
-sub form_footer {
- $lxdebug->enter_sub();
+ # hiddens
+ $TMPL_VAR{HIDDENS} = [qw(
+ id action type media format queued printed emailed title vc discount
+ title creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id
+ max_dunning_level dunning_amount
+ shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax
+ shiptoemail shiptodepartment_1 shiptodepartment_2 shiptocp_gender message email subject cc bcc taxaccounts cursor_fokus
+ convert_from_do_ids convert_from_oe_ids
+ ), @custom_hiddens,
+ map { $_.'_rate', $_.'_description', $_.'_taxnumber' } split / /, $form->{taxaccounts}];
- $form->{invtotal} = $form->{invsubtotal};
+ $form->{jsscript} = 1;
+ $form->header();
- if (($rows = $form->numtextrows($form->{notes}, 26, 8)) < 2) {
- $rows = 2;
- }
- if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
- $introws = 2;
- }
- $rows = ($rows > $introws) ? $rows : $introws;
- $notes =
- qq||;
- $intnotes =
- qq||;
-
- $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
-
- $taxincluded = "";
- if ($form->{taxaccounts}) {
- $taxincluded = qq|
- {taxincluded}> |
- . $locale->text('Tax Included') . qq|
|;
- }
+ print $form->parse_html_template("is/form_header", \%TMPL_VAR);
- if (!$form->{taxincluded}) {
+ $main::lxdebug->leave_sub();
+}
- foreach $item (split / /, $form->{taxaccounts}) {
- if ($form->{"${item}_base"}) {
- $form->{"${item}_total"} =
- $form->round_amount(
- $form->{"${item}_base"} * $form->{"${item}_rate"},
- 2);
- $form->{invtotal} += $form->{"${item}_total"};
- $form->{"${item}_total"} =
- $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
-
- $tax .= qq|
-
- $form->{"${item}_description"} |
- $form->{"${item}_total"} |
-
-|;
- }
- }
+sub form_footer {
+ $main::lxdebug->enter_sub();
- $form->{invsubtotal} =
- $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
+ my $locale = $main::locale;
- $subtotal = qq|
-
- | . $locale->text('Subtotal') . qq| |
- $form->{invsubtotal} |
-
-|;
+ $main::auth->assert('invoice_edit');
- }
+ $form->{invtotal} = $form->{invsubtotal};
+ $form->{oldinvtotal} = $form->{invtotal};
- if ($form->{taxincluded}) {
- foreach $item (split / /, $form->{taxaccounts}) {
- if ($form->{"${item}_base"}) {
- $form->{"${item}_total"} =
- $form->round_amount(
- ($form->{"${item}_base"} * $form->{"${item}_rate"} /
- (1 + $form->{"${item}_rate"})
- ),
- 2);
- $form->{"${item}_netto"} =
- $form->round_amount(
- ($form->{"${item}_base"} - $form->{"${item}_total"}),
- 2);
- $form->{"${item}_total"} =
- $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
- $form->{"${item}_netto"} =
- $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
-
- $tax .= qq|
-
- Enthaltene $form->{"${item}_description"} |
- $form->{"${item}_total"} |
-
-
- Nettobetrag |
- $form->{"${item}_netto"} |
-
-|;
- }
- }
+ # note rows
+ $form->{rows} = max 2,
+ $form->numtextrows($form->{notes}, 26, 8),
+ $form->numtextrows($form->{intnotes}, 35, 8);
- }
- $form->{oldinvtotal} = $form->{invtotal};
- $form->{invtotal} =
- $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
+ # tax, total and subtotal calculations
+ my ($tax, $subtotal);
+ $form->{taxaccounts_array} = [ split / /, $form->{taxaccounts} ];
- print qq|
-
-
-
-
-
-
-
- | . $locale->text('Notes') . qq| |
- | . $locale->text('Internal Notes') . qq| |
-
-
- $notes |
- $intnotes |
-
-
- |
-
- $taxincluded
-
- $subtotal
- $tax
-
- | . $locale->text('Total') . qq| |
- $form->{invtotal} |
-
-
- |
-
-
- |
-
-|;
- if ($webdav) {
- $webdav_list = qq|
-
-
|
-
-
- Dokumente im Webdav-Repository |
-
-
- Dateiname |
- Webdavlink |
-|;
- foreach $file (keys %{ $form->{WEBDAV} }) {
- $webdav_list .= qq|
-
- $file |
- $form->{WEBDAV}{$file} |
-
-|;
+ foreach my $item (@{ $form->{taxaccounts_array} }) {
+ if ($form->{"${item}_base"}) {
+ if ($form->{taxincluded}) {
+ $form->{"${item}_total"} = $form->round_amount( ($form->{"${item}_base"} * $form->{"${item}_rate"}
+ / (1 + $form->{"${item}_rate"})), 2);
+ $form->{"${item}_netto"} = $form->round_amount( ($form->{"${item}_base"} - $form->{"${item}_total"}), 2);
+ } else {
+ $form->{"${item}_total"} = $form->round_amount( $form->{"${item}_base"} * $form->{"${item}_rate"}, 2);
+ $form->{invtotal} += $form->{"${item}_total"};
+ }
}
- $webdav_list .= qq|
-
-
-|;
-
- print $webdav_list;
}
- print qq|
-
-
-
- |
-
-
-
|
-
-
-
-|;
-
- &print_options;
-
- print qq|
- |
-
-
-|;
+ print $form->parse_html_template('is/form_footer', {
+ is_type_credit_note => ($form->{type} eq "credit_note"),
+ totalpaid => $totalpaid,
+ paid_missing => $form->{invtotal} - $totalpaid,
+ print_options => print_options(inline => 1),
+ show_storno => $form->{id} && !$form->{storno} && !IS->has_storno(\%myconfig, $form, "ar") && !$totalpaid,
+ show_delete => ($form->current_date(\%myconfig) eq $form->{gldate}),
+ });
+##print $form->parse_html_template('is/_payments'); # parser
+##print $form->parse_html_template('webdav/_list'); # parser
- $invdate = $form->datetonum($form->{invdate}, \%myconfig);
- $closedto = $form->datetonum($form->{closedto}, \%myconfig);
-
- if ($form->{id}) {
- print qq|
-