X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=bin%2Fmozilla%2Far.pl;h=562f8aac2968758ea6909fc65ef6aedcd76799d9;hb=2ac999504a5039c972da30c0f6177b34f6e2177b;hp=45193ed877097e6c9d5161bc67a53925ab76ebc8;hpb=0ba3b647155cba9b668cbcc7579fd135b3a1a9be;p=kivitendo-erp.git diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index 45193ed87..562f8aac2 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -24,7 +24,8 @@ # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1335, USA. #====================================================================== # # Accounts Receivables @@ -33,16 +34,28 @@ use POSIX qw(strftime); use List::Util qw(sum first max); +use List::UtilsBy qw(sort_by); use SL::AR; +use SL::Controller::Base; use SL::FU; +use SL::GL; use SL::IS; -use SL::PE; +use SL::DB::Business; +use SL::DB::Chart; +use SL::DB::Currency; +use SL::DB::Default; +use SL::DB::Employee; +use SL::DB::Invoice; +use SL::DB::RecordTemplate; +use SL::DB::Tax; +use SL::Helper::Flash qw(flash); +use SL::Locale::String qw(t8); +use SL::Presenter::Tag; +use SL::Presenter::Chart; use SL::ReportGenerator; -require "bin/mozilla/arap.pl"; require "bin/mozilla/common.pl"; -require "bin/mozilla/drafts.pl"; require "bin/mozilla/reportgenerator.pl"; use strict; @@ -76,16 +89,138 @@ use strict; # $locale->text('Nov') # $locale->text('Dec') +sub load_record_template { + $::auth->assert('ar_transactions'); + + # Load existing template and verify that its one for this module. + my $template = SL::DB::RecordTemplate + ->new(id => $::form->{id}) + ->load( + with_object => [ qw(customer payment currency record_items record_items.chart) ], + ); + + die "invalid template type" unless $template->template_type eq 'ar_transaction'; + + $template->substitute_variables; + + # Clean the current $::form before rebuilding it from the template. + my $form_defaults = delete $::form->{form_defaults}; + delete @{ $::form }{ grep { !m{^(?:script|login)$}i } keys %{ $::form } }; + + # Fill $::form from the template. + my $today = DateTime->today_local; + $::form->{title} = "Add"; + $::form->{currency} = $template->currency->name; + $::form->{direct_debit} = $template->direct_debit; + $::form->{globalproject_id} = $template->project_id; + $::form->{AR_chart_id} = $template->ar_ap_chart_id; + $::form->{transdate} = $today->to_kivitendo; + $::form->{duedate} = $today->to_kivitendo; + $::form->{rowcount} = @{ $template->items }; + $::form->{paidaccounts} = 1; + $::form->{$_} = $template->$_ for qw(department_id ordnumber taxincluded employee_id notes); + + if ($template->customer) { + $::form->{customer_id} = $template->customer_id; + $::form->{customer} = $template->customer->name; + $::form->{duedate} = $template->customer->payment->calc_date(reference_date => $today)->to_kivitendo if $template->customer->payment; + } + + my $row = 0; + foreach my $item (@{ $template->items }) { + $row++; + + my $active_taxkey = $item->chart->get_active_taxkey; + my $taxes = SL::DB::Manager::Tax->get_all( + where => [ chart_categories => { like => '%' . $item->chart->category . '%' }], + sort_by => 'taxkey, rate', + ); + + my $tax = first { $item->tax_id == $_->id } @{ $taxes }; + $tax //= first { $active_taxkey->tax_id == $_->id } @{ $taxes }; + $tax //= $taxes->[0]; + + if (!$tax) { + $row--; + next; + } + + $::form->{"AR_amount_chart_id_${row}"} = $item->chart_id; + $::form->{"previous_AR_amount_chart_id_${row}"} = $item->chart_id; + $::form->{"amount_${row}"} = $::form->format_amount(\%::myconfig, $item->amount1, 2); + $::form->{"taxchart_${row}"} = $item->tax_id . '--' . $tax->rate; + $::form->{"project_id_${row}"} = $item->project_id; + } + + $::form->{$_} = $form_defaults->{$_} for keys %{ $form_defaults // {} }; + + flash('info', $::locale->text("The record template '#1' has been loaded.", $template->template_name)); + + update( + keep_rows_without_amount => 1, + dont_add_new_row => 1, + ); +} + +sub save_record_template { + $::auth->assert('ar_transactions'); + + my $template = $::form->{record_template_id} ? SL::DB::RecordTemplate->new(id => $::form->{record_template_id})->load : SL::DB::RecordTemplate->new; + my $js = SL::ClientJS->new(controller => SL::Controller::Base->new); + my $new_name = $template->template_name_to_use($::form->{record_template_new_template_name}); + + $js->dialog->close('#record_template_dialog'); + + my @items = grep { + $_->{chart_id} && (($_->{tax_id} // '') ne '') + } map { + +{ chart_id => $::form->{"AR_amount_chart_id_${_}"}, + amount1 => $::form->parse_amount(\%::myconfig, $::form->{"amount_${_}"}), + tax_id => (split m{--}, $::form->{"taxchart_${_}"})[0], + project_id => $::form->{"project_id_${_}"} || undef, + } + } (1..($::form->{rowcount} || 1)); + + $template->assign_attributes( + template_type => 'ar_transaction', + template_name => $new_name, + + currency_id => SL::DB::Manager::Currency->find_by(name => $::form->{currency})->id, + ar_ap_chart_id => $::form->{AR_chart_id} || undef, + customer_id => $::form->{customer_id} || undef, + department_id => $::form->{department_id} || undef, + project_id => $::form->{globalproject_id} || undef, + employee_id => $::form->{employee_id} || undef, + taxincluded => $::form->{taxincluded} ? 1 : 0, + direct_debit => $::form->{direct_debit} ? 1 : 0, + ordnumber => $::form->{ordnumber}, + notes => $::form->{notes}, + + items => \@items, + ); + + eval { + $template->save; + 1; + } or do { + return $js + ->flash('error', $::locale->text("Saving the record template '#1' failed.", $new_name)) + ->render; + }; + + return $js + ->flash('info', $::locale->text("The record template '#1' has been saved.", $new_name)) + ->render; +} + sub add { $main::lxdebug->enter_sub(); - $main::auth->assert('general_ledger'); + $main::auth->assert('ar_transactions'); my $form = $main::form; my %myconfig = %main::myconfig; - return $main::lxdebug->leave_sub() if (load_draft_maybe()); - # saving the history if(!exists $form->{addition} && ($form->{id} ne "")) { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; @@ -95,12 +230,18 @@ sub add { # /saving the history $form->{title} = "Add"; - $form->{callback} = "ar.pl?action=add&DONT_LOAD_DRAFT=1" unless $form->{callback}; + $form->{callback} = "ar.pl?action=add" unless $form->{callback}; AR->get_transdate(\%myconfig, $form); $form->{initial_transdate} = $form->{transdate}; - &create_links; + create_links(dont_save => 1); $form->{transdate} = $form->{initial_transdate}; + + if ($form->{customer_id}) { + my $last_used_ar_chart = SL::DB::Customer->load_cached($form->{customer_id})->last_used_ar_chart; + $form->{"AR_amount_chart_id_1"} = $last_used_ar_chart->id if $last_used_ar_chart; + } + &display_form; $main::lxdebug->leave_sub(); } @@ -108,7 +249,7 @@ sub add { sub edit { $main::lxdebug->enter_sub(); - $main::auth->assert('general_ledger'); + $main::auth->assert('ar_transactions'); my $form = $main::form; @@ -118,7 +259,7 @@ sub edit { $form->{javascript} .= qq||; $form->{title} = "Edit"; - &create_links; + create_links(); &display_form; $main::lxdebug->leave_sub(); @@ -127,7 +268,7 @@ sub edit { sub display_form { $main::lxdebug->enter_sub(); - $main::auth->assert('general_ledger'); + $main::auth->assert('ar_transactions'); my $form = $main::form; @@ -137,63 +278,41 @@ sub display_form { $main::lxdebug->leave_sub(); } +sub _retrieve_invoice_object { + return undef if !$::form->{id}; + return $::form->{invoice_obj} if $::form->{invoice_obj} && $::form->{invoice_obj}->id == $::form->{id}; + return SL::DB::Invoice->new(id => $::form->{id})->load; +} + sub create_links { $main::lxdebug->enter_sub(); - $main::auth->assert('general_ledger'); + $main::auth->assert('ar_transactions'); + my %params = @_; my $form = $main::form; my %myconfig = %main::myconfig; - my ($duedate, $taxincluded); - $form->create_links("AR", \%myconfig, "customer"); - $duedate = $form->{duedate}; + $form->{invoice_obj} = _retrieve_invoice_object(); + + my %saved; + if (!$params{dont_save}) { + %saved = map { ($_ => $form->{$_}) } qw(direct_debit id taxincluded); + $saved{duedate} = $form->{duedate} if $form->{duedate}; + $saved{currency} = $form->{currency} if $form->{currency}; + } - $taxincluded = $form->{taxincluded}; - my $id = $form->{id}; IS->get_customer(\%myconfig, \%$form); - $form->{taxincluded} = $taxincluded; - $form->{id} = $id; - $form->{duedate} = $duedate if $duedate; - $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}"; + $form->{$_} = $saved{$_} for keys %saved; $form->{rowcount} = 1; - - # notes - $form->{notes} = $form->{intnotes} unless $form->{notes}; + $form->{AR_chart_id} = $form->{acc_trans} && $form->{acc_trans}->{AR} ? $form->{acc_trans}->{AR}->[0]->{chart_id} : $form->{AR_links}->{AR}->[0]->{chart_id}; # currencies $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); - map { $form->{selectcurrency} .= "$_\n" } $form->get_all_currencies(\%myconfig); - - # customers - if (@{ $form->{all_customer} || [] }) { - $form->{customer} = "$form->{customer}--$form->{customer_id}"; - map { $form->{selectcustomer} .= "$_->{name}--$_->{id}\n" } - (@{ $form->{all_customer} }); - } - - # departments - if (@{ $form->{all_departments} || [] }) { - $form->{selectdepartment} = "\n"; - $form->{department} = "$form->{department}--$form->{department_id}"; - - map { - $form->{selectdepartment} .= - "$_->{description}--$_->{id}\n" - } (@{ $form->{all_departments} || [] }); - } - - $form->{employee} = "$form->{employee}--$form->{employee_id}"; - - # sales staff - if (@{ $form->{all_employees} || [] }) { - $form->{selectemployee} = ""; - map { $form->{selectemployee} .= "$_->{name}--$_->{id}\n" } - (@{ $form->{all_employees} || [] }); - } + $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all_sorted; # build the popup menus $form->{taxincluded} = ($form->{id}) ? $form->{taxincluded} : "checked"; @@ -210,60 +329,38 @@ sub create_links { sub form_header { $main::lxdebug->enter_sub(); - $main::auth->assert('general_ledger'); + $main::auth->assert('ar_transactions'); my $form = $main::form; my %myconfig = %main::myconfig; my $locale = $main::locale; my $cgi = $::request->{cgi}; + $form->{invoice_obj} = _retrieve_invoice_object(); + my ($title, $readonly, $exchangerate, $rows); - my ($notes, $department, $customer, $employee, $amount, $project); - my ($onload); - my ($ARselected); + my ($notes, $amount, $project); + $form->{initial_focus} = !($form->{amount_1} * 1) ? 'customer_id' : 'row_' . $form->{rowcount}; $title = $form->{title}; # $locale->text('Add Accounts Receivables Transaction') # $locale->text('Edit Accounts Receivables Transaction') $form->{title} = $locale->text("$title Accounts Receivables Transaction"); - $form->{javascript} = qq||; - # show history button js - $form->{javascript} .= qq||; - #/show history button js $readonly = ($form->{id}) ? "readonly" : ""; - $form->{radier} = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0; + $form->{radier} = ($::instance_conf->get_ar_changeable == 2) + ? ($form->current_date(\%myconfig) eq $form->{gldate}) + : ($::instance_conf->get_ar_changeable == 1); $readonly = ($form->{radier}) ? "" : $readonly; - # set option selected - foreach my $item (qw(customer currency department employee)) { - $form->{"select$item"} =~ s/ selected//; - $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; - } - $form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{transdate}, 'buy'); $form->{exchangerate} = $form->{forex} if $form->{forex}; + # format exchangerate + $form->{exchangerate} = $form->{exchangerate} ? $form->format_amount(\%myconfig, $form->{exchangerate}) : ''; + $rows = max 2, $form->numtextrows($form->{notes}, 50); my @old_project_ids = grep { $_ } map { $form->{"project_id_$_"} } 1..$form->{rowcount}; @@ -276,104 +373,60 @@ sub form_header { "taxcharts" => { "key" => "ALL_TAXCHARTS", "module" => "AR" },); + $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all_sorted; + $_->{link_split} = { map { $_ => 1 } split/:/, $_->{link} } for @{ $form->{ALL_CHARTS} }; my %project_labels = map { $_->{id} => $_->{projectnumber} } @{ $form->{"ALL_PROJECTS"} }; - my (@AR_amount_values); - my (@AR_values); - my (@AR_paid_values); - my %chart_labels; - my %charts; - my $taxchart_init; + my (@AR_paid_values, %AR_paid_labels); + my $default_ar_amount_chart_id; foreach my $item (@{ $form->{ALL_CHARTS} }) { if ($item->{link_split}{AR_amount}) { - $taxchart_init = $item->{tax_id} if ($taxchart_init eq ""); - my $key = "$item->{accno}--$item->{tax_id}"; - push(@AR_amount_values, $key); - } elsif ($item->{link_split}{AR}) { - push(@AR_values, $item->{accno}); + $default_ar_amount_chart_id //= $item->{id}; + } elsif ($item->{link_split}{AR_paid}) { push(@AR_paid_values, $item->{accno}); + $AR_paid_labels{$item->{accno}} = "$item->{accno}--$item->{description}"; } - - # weirdness for AR_amount - $chart_labels{$item->{accno}} = "$item->{accno}--$item->{description}"; - $chart_labels{"$item->{accno}--$item->{tax_id}"} = "$item->{accno}--$item->{description}"; - - $charts{$item->{accno}} = $item; - } - - my %taxchart_labels = (); - my @taxchart_values = (); - my %taxcharts = (); - foreach my $item (@{ $form->{ALL_TAXCHARTS} }) { - my $key = "$item->{id}--$item->{rate}"; - $taxchart_init = $key if ($taxchart_init eq $item->{id}); - push(@taxchart_values, $key); - $taxchart_labels{$key} = "$item->{taxdescription} " . ($item->{rate} * 100) . ' %'; - $taxcharts{$item->{id}} = $item; } - $form->{fokus} = "arledger.customer"; - - my $follow_up_vc = $form->{customer}; - $follow_up_vc =~ s/--.*?//; + my $follow_up_vc = $form->{customer_id} ? SL::DB::Customer->load_cached($form->{customer_id})->name : ''; my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)"; - $form->{javascript} .= - qq|| . - qq||; - - $onload = qq|focus()|; - $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|; + $::request->layout->add_javascripts("autocomplete_chart.js", "show_vc_details.js", "show_history.js", "follow_up.js", "kivi.Draft.js", "kivi.GL.js", "kivi.File.js", "kivi.RecordTemplate.js", "kivi.AR.js", "kivi.CustomerVendor.js", "kivi.Validator.js"); -# $amount = $locale->text('Amount'); -# $project = $locale->text('Project'); + my $transdate = $::form->{transdate} ? DateTime->from_kivitendo($::form->{transdate}) : DateTime->today_local; + my $first_taxchart; my @transactions; for my $i (1 .. $form->{rowcount}) { my $transaction = { amount => $form->{"amount_$i"}, tax => $form->{"tax_$i"}, - project_id => $form->{"project_id_$i"}, + project_id => ($i==$form->{rowcount}) ? $form->{globalproject_id} : $form->{"project_id_$i"}, }; - my $selected_accno_full; - my ($accno_row) = split(/--/, $form->{"AR_amount_$i"}); - my $item = $charts{$accno_row}; - $selected_accno_full = "$item->{accno}--$item->{tax_id}"; + my (%taxchart_labels, @taxchart_values, $default_taxchart, $taxchart_to_use); + my $amount_chart_id = $form->{"AR_amount_chart_id_$i"} // $default_ar_amount_chart_id; - my $selected_taxchart = $form->{"taxchart_$i"}; - my ($selected_accno, $selected_tax_id) = split(/--/, $selected_accno_full); - my ($previous_accno, $previous_tax_id) = split(/--/, $form->{"previous_AR_amount_$i"}); + foreach my $item ( GL->get_active_taxes_for_chart($amount_chart_id, $transdate) ) { + my $key = $item->id . "--" . $item->rate; + $first_taxchart //= $item; + $default_taxchart = $item if $item->{is_default}; + $taxchart_to_use = $item if $key eq $form->{"taxchart_$i"}; - if ($previous_accno && - ($previous_accno eq $selected_accno) && - ($previous_tax_id ne $selected_tax_id)) { - my $item = $taxcharts{$selected_tax_id}; - $selected_taxchart = "$item->{id}--$item->{rate}"; + push(@taxchart_values, $key); + $taxchart_labels{$key} = $item->taxdescription . " " . $item->rate * 100 . ' %'; } - if (!$form->{"taxchart_$i"}) { - if ($form->{"AR_amount_$i"} =~ m/.--./) { - $selected_taxchart = join '--', map { ($_->{id}, $_->{rate}) } first { $_->{id} == $item->{tax_id} } @{ $form->{ALL_TAXCHARTS} }; - } else { - $selected_taxchart = $taxchart_init; - } - } + $taxchart_to_use //= $default_taxchart // $first_taxchart; + my $selected_taxchart = $taxchart_to_use->id . '--' . $taxchart_to_use->rate; $transaction->{selectAR_amount} = - NTI($cgi->popup_menu('-name' => "AR_amount_$i", - '-id' => "AR_amount_$i", - '-style' => 'width:400px', - '-onChange' => "setTaxkey(this, $i)", - '-values' => \@AR_amount_values, - '-labels' => \%chart_labels, - '-default' => $selected_accno_full)) - . $cgi->hidden('-name' => "previous_AR_amount_$i", - '-default' => $selected_accno_full); + SL::Presenter::Chart::picker("AR_amount_chart_id_$i", $amount_chart_id, style => "width: 400px", type => "AR_amount", class => ($form->{initial_focus} eq "row_$i" ? "initial_focus" : "")) + . SL::Presenter::Tag::hidden_tag("previous_AR_amount_chart_id_$i", $amount_chart_id); $transaction->{taxchart} = NTI($cgi->popup_menu('-name' => "taxchart_$i", @@ -388,13 +441,6 @@ sub form_header { $form->{invtotal_unformatted} = $form->{invtotal}; - $ARselected = - NTI($cgi->popup_menu('-name' => "ARselected", '-id' => "ARselected", - '-style' => 'width:400px', - '-values' => \@AR_values, '-labels' => \%chart_labels, - '-default' => $form->{ARselected})); - - $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"}); my $now = $form->current_date(\%myconfig); @@ -415,25 +461,51 @@ sub form_header { gldate => $form->{"gldate_$i"}, }; + # default account for current assets (i.e. 1801 - SKR04) if no account is selected + $form->{accno_arap} = IS->get_standard_accno_current_assets(\%myconfig, \%$form); + $payment->{selectAR_paid} = NTI($cgi->popup_menu('-name' => "AR_paid_$i", '-id' => "AR_paid_$i", '-values' => \@AR_paid_values, - '-labels' => \%chart_labels, - '-default' => $payment->{AR_paid})); + '-labels' => \%AR_paid_labels, + '-default' => $payment->{AR_paid} || $form->{accno_arap})); $payment->{changeable} = - $::lx_office_conf{features}->{payments_changeable} == 0 ? !$payment->{acc_trans_id} # never - : $::lx_office_conf{features}->{payments_changeable} == 2 ? $payment->{gldate} eq '' || $payment->{gldate} eq $now + SL::DB::Default->get->payments_changeable == 0 ? !$payment->{acc_trans_id} # never + : SL::DB::Default->get->payments_changeable == 2 ? $payment->{gldate} eq '' || $payment->{gldate} eq $now : 1; + #deaktivieren von gebuchten Zahlungen ausserhalb der Bücherkontrolle, vorher prüfen ob heute eingegeben + if ($form->date_closed($payment->{"gldate_$i"})) { + $payment->{changeable} = 0; + } + push @payments, $payment; } + my @empty = grep { $_->{paid} eq '' } @payments; + @payments = ( + (sort_by { DateTime->from_kivitendo($_->{datepaid}) } grep { $_->{paid} ne '' } @payments), + @empty, + ); + $form->{totalpaid} = sum map { $_->{paid} } @payments; + my $employees = SL::DB::Manager::Employee->get_all_sorted( + where => [ + or => [ + (id => $::form->{employee_id}) x !!$::form->{employee_id}, + deleted => undef, + deleted => 0, + ], + ], + ); + + setup_ar_form_header_action_bar(); + $form->header; print $::form->parse_html_template('ar/form_header', { paid_missing => $::form->{invtotal} - $::form->{totalpaid}, @@ -442,10 +514,12 @@ sub form_header { transactions => \@transactions, project_labels => \%project_labels, rows => $rows, - ARselected => $ARselected, - onload => $onload, + AR_chart_id => $form->{AR_chart_id}, title_str => $title, follow_up_trans_info => $follow_up_trans_info, + today => DateTime->today, + currencies => scalar(SL::DB::Manager::Currency->get_all_sorted), + employees => $employees, }); $main::lxdebug->leave_sub(); @@ -454,124 +528,44 @@ sub form_header { sub form_footer { $main::lxdebug->enter_sub(); - $main::auth->assert('general_ledger'); + $main::auth->assert('ar_transactions'); my $form = $main::form; my %myconfig = %main::myconfig; my $locale = $main::locale; my $cgi = $::request->{cgi}; - my ($transdate, $closedto); - - my $follow_ups_block; - if ($form->{id}) { - my $follow_ups = FU->follow_ups('trans_id' => $form->{id}); - - if (@{ $follow_ups} ) { - my $num_due = sum map { $_->{due} * 1 } @{ $follow_ups }; - $follow_ups_block = qq|| . $locale->text("There are #1 unfinished follow-ups of which #2 are due.", scalar @{ $follow_ups }, $num_due) . qq||; - } - } - - print qq| - -$follow_ups_block - - - - -| -. $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}]) -. $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]) -. qq| - - -|; - - if (!$form->{id} && $form->{draft_id}) { - print(NTI($cgi->checkbox('-name' => 'remove_draft', '-id' => 'remove_draft', - '-value' => 1, '-checked' => $form->{remove_draft}, - '-label' => '')) . - qq| | . - $locale->text("Remove draft when posting") . - qq||); - } - - $transdate = $form->datetonum($form->{transdate}, \%myconfig); - $closedto = $form->datetonum($form->{closedto}, \%myconfig); - - print qq|\n|; - - # ToDO: - insert a global check for stornos, so that a storno is only possible a limited time after saving it - print qq| | - if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ar') && !IS->is_storno(\%myconfig, $form, 'ar') && (($form->{totalpaid} == 0) || ($form->{totalpaid} eq ""))); - - if ($form->{id}) { - if ($form->{radier}) { - print qq| - - |; - } - if ($transdate > $closedto) { - print qq| - |; - } - print qq| - - |; - - } else { - if ($transdate > $closedto) { - print qq| | . - NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'), '-class' => 'submit')); + if ( $form->{id} ) { + my $follow_ups = FU->follow_ups('trans_id' => $form->{id}, 'not_done' => 1); + if ( @{ $follow_ups} ) { + $form->{follow_up_length} = scalar(@{$follow_ups}); + $form->{follow_up_due_length} = sum(map({ $_->{due} * 1 } @{ $follow_ups })); } } - if ($form->{menubar}) { - require "bin/mozilla/menu.pl"; - &menubar; - } - # button for saving history - if($form->{id} ne "") { - print qq| {id}); name=history id=history value=| . $locale->text('history') . qq|> |; - } - # /button for saving history - # mark_as_paid button - if($form->{id} ne "") { - print qq||; - } - # /mark_as_paid button - - print " - - -
| . $locale->text("There are #1 unfinished follow-ups of which #2 are due.", scalar @{ $follow_ups }, $num_due) . qq|