X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Far.pl;h=562f8aac2968758ea6909fc65ef6aedcd76799d9;hb=e070b6383cd90405970527fdb90f08fb1d96ba6d;hp=a1a7635ab8bd0afc955774a274b5edf76b7ff72f;hpb=d7d43eb2e00f0609b452e1bea65d50004f2d77e9;p=kivitendo-erp.git diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index a1a7635ab..562f8aac2 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -51,6 +51,8 @@ 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/common.pl"; @@ -310,7 +312,7 @@ sub create_links { # currencies $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); - $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all; + $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all_sorted; # build the popup menus $form->{taxincluded} = ($form->{id}) ? $form->{taxincluded} : "checked"; @@ -371,7 +373,7 @@ sub form_header { "taxcharts" => { "key" => "ALL_TAXCHARTS", "module" => "AR" },); - $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all; + $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all_sorted; $_->{link_split} = { map { $_ => 1 } split/:/, $_->{link} } for @{ $form->{ALL_CHARTS} }; @@ -393,7 +395,7 @@ sub form_header { 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)"; - $::request->layout->add_javascripts("autocomplete_chart.js", "autocomplete_customer.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"); + $::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"); my $transdate = $::form->{transdate} ? DateTime->from_kivitendo($::form->{transdate}) : DateTime->today_local; my $first_taxchart; @@ -407,8 +409,7 @@ sub form_header { }; 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 $chart_has_changed = $::form->{"previous_AR_amount_chart_id_$i"} && ($amount_chart_id != $::form->{"previous_AR_amount_chart_id_$i"}); + my $amount_chart_id = $form->{"AR_amount_chart_id_$i"} // $default_ar_amount_chart_id; foreach my $item ( GL->get_active_taxes_for_chart($amount_chart_id, $transdate) ) { my $key = $item->id . "--" . $item->rate; @@ -420,12 +421,12 @@ sub form_header { $taxchart_labels{$key} = $item->taxdescription . " " . $item->rate * 100 . ' %'; } - $taxchart_to_use = $default_taxchart // $first_taxchart if $chart_has_changed || !$taxchart_to_use; + $taxchart_to_use //= $default_taxchart // $first_taxchart; my $selected_taxchart = $taxchart_to_use->id . '--' . $taxchart_to_use->rate; $transaction->{selectAR_amount} = - $::request->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" : "")) - . $::request->presenter->hidden_tag("previous_AR_amount_chart_id_$i", $amount_chart_id); + 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", @@ -611,6 +612,10 @@ sub update { if (($form->{previous_customer_id} || $form->{customer_id}) != $form->{customer_id}) { IS->get_customer(\%myconfig, $form); + if (($form->{rowcount} == 1) && ($form->{amount_1} == 0)) { + 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; + } } $form->{invtotal} = @@ -789,7 +794,7 @@ sub post { } # /saving the history - $form->redirect($locale->text("AR transaction posted.")) unless $inline; + $form->redirect($locale->text('AR transaction posted.') . ' ' . $locale->text('ID') . ': ' . $form->{id}) unless $inline; $main::lxdebug->leave_sub(); } @@ -871,10 +876,12 @@ sub setup_ar_search_action_bar { action => [ $::locale->text('Search'), submit => [ '#form' ], + checks => [ 'kivi.validate_form' ], accesskey => 'enter', ], ); } + $::request->layout->add_javascripts('kivi.Validator.js'); } sub setup_ar_transactions_action_bar { @@ -913,7 +920,7 @@ sub search { my $locale = $main::locale; my $cgi = $::request->{cgi}; - $form->{title} = $locale->text('AR Transactions'); + $form->{title} = $locale->text('Invoices, Credit Notes & AR Transactions'); $form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]); $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all_sorted; @@ -974,7 +981,7 @@ sub ar_transactions { AR->ar_transactions(\%myconfig, \%$form); - $form->{title} = $locale->text('AR Transactions'); + $form->{title} = $locale->text('Invoices, Credit Notes & AR Transactions'); my $report = SL::ReportGenerator->new(\%myconfig, $form); @@ -993,13 +1000,13 @@ sub ar_transactions { my @hidden_variables = map { "l_${_}" } @columns; push @hidden_variables, "l_subtotal", qw(open closed customer invnumber ordnumber cusordnumber transaction_description notes project_id transdatefrom transdateto duedatefrom duedateto - employee_id salesman_id business_id parts_partnumber parts_description department_id); + employee_id salesman_id business_id parts_partnumber parts_description department_id show_marked_as_closed); push @hidden_variables, map { "cvar_$_->{name}" } @ct_searchable_custom_variables; $href = build_std_url('action=ar_transactions', grep { $form->{$_} } @hidden_variables); my %column_defs = ( - 'ids' => { raw_header_data => $::request->presenter->checkbox_tag("", id => "check_all", checkall => "[data-checkall=1]"), align => 'center' }, + 'ids' => { raw_header_data => SL::Presenter::Tag::checkbox_tag("", id => "check_all", checkall => "[data-checkall=1]"), align => 'center' }, 'transdate' => { 'text' => $locale->text('Date'), }, 'id' => { 'text' => $locale->text('ID'), }, 'type' => { 'text' => $locale->text('Type'), }, @@ -1028,7 +1035,7 @@ sub ar_transactions { 'ustid' => { 'text' => $locale->text('USt-IdNr.'), }, 'taxzone' => { 'text' => $locale->text('Steuersatz'), }, 'payment_terms' => { 'text' => $locale->text('Payment Terms'), }, - 'charts' => { 'text' => $locale->text('Buchungskonto'), }, + 'charts' => { 'text' => $locale->text('Chart'), }, 'customertype' => { 'text' => $locale->text('Customer type'), }, 'direct_debit' => { 'text' => $locale->text('direct debit'), }, 'department' => { 'text' => $locale->text('Department'), }, @@ -1177,7 +1184,7 @@ sub ar_transactions { . "&id=" . E($ar->{id}) . "&callback=${callback}"; $row->{ids} = { - raw_data => $::request->presenter->checkbox_tag("id[]", value => $ar->{id}, "data-checkall" => 1), + raw_data => SL::Presenter::Tag::checkbox_tag("id[]", value => $ar->{id}, "data-checkall" => 1), valign => 'center', align => 'center', }; @@ -1201,7 +1208,7 @@ sub ar_transactions { $::request->layout->add_javascripts('kivi.MassInvoiceCreatePrint.js'); setup_ar_transactions_action_bar(num_rows => scalar(@{ $form->{AR} })); - $report->generate_with_headers(action_bar => 1); + $report->generate_with_headers(); $main::lxdebug->leave_sub(); } @@ -1254,6 +1261,7 @@ sub setup_ar_form_header_action_bar { t8('Update'), submit => [ '#form', { action => "update" } ], id => 'update_button', + checks => [ 'kivi.validate_form' ], accesskey => 'enter', ], @@ -1261,7 +1269,7 @@ sub setup_ar_form_header_action_bar { action => [ t8('Post'), submit => [ '#form', { action => "post" } ], - checks => [ 'kivi.AR.check_fields_before_posting' ], + checks => [ 'kivi.validate_form', 'kivi.AR.check_fields_before_posting' ], disabled => $is_closed ? t8('The billing period has already been locked.') : $is_storno ? t8('A canceled invoice cannot be posted.') : ($::form->{id} && $change_never) ? t8('Changing invoices has been disabled in the configuration.') @@ -1284,7 +1292,7 @@ sub setup_ar_form_header_action_bar { combobox => [ action => [ t8('Storno'), submit => [ '#form', { action => "storno" } ], - checks => [ 'kivi.AR.check_fields_before_posting' ], + checks => [ 'kivi.validate_form', 'kivi.AR.check_fields_before_posting' ], confirm => t8('Do you really want to cancel this invoice?'), disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : $has_storno ? t8('This invoice has been canceled already.') @@ -1310,6 +1318,7 @@ sub setup_ar_form_header_action_bar { action => [ t8('Use As New'), submit => [ '#form', { action => "use_as_new" } ], + checks => [ 'kivi.validate_form' ], disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef, ], ], # end of combobox "Workflow" @@ -1340,6 +1349,7 @@ sub setup_ar_form_header_action_bar { ], # end of combobox "more" ); } + $::request->layout->add_javascripts('kivi.Validator.js'); } 1;