From affd886bff7af48273af3dad20ea0680398489a3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 23 Oct 2020 15:27:08 +0200 Subject: [PATCH] AP: Project picker in form --- bin/mozilla/ap.pl | 22 +++------------------- templates/webpages/ap/form_header.html | 6 +++--- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index 0417cd060..03542d703 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -413,20 +413,7 @@ sub form_header { $form->{creditremaining_plus} = ($form->{creditremaining} =~ /-/) ? "0" : "1"; - my @old_project_ids = (); - map( - { - if ($form->{"project_id_$_"}) { - push(@old_project_ids, $form->{"project_id_$_"}); - } - } - (1..$form->{"rowcount"}) - ); - - $form->get_lists("projects" => { "key" => "ALL_PROJECTS", - "all" => 0, - "old_id" => \@old_project_ids }, - "charts" => { "key" => "ALL_CHARTS", + $form->get_lists("charts" => { "key" => "ALL_CHARTS", "transdate" => $form->{transdate} }, ); @@ -437,10 +424,7 @@ sub form_header { $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all_sorted; - my %project_labels = (); - foreach my $item (@{ $form->{"ALL_PROJECTS"} }) { - $project_labels{$item->{id}} = $item->{projectnumber}; - } + my %project_labels = map { $_->id => $_->projectnumber } @{ SL::DB::Manager::Project->get_all }; my %charts; my $default_ap_amount_chart_id; @@ -459,7 +443,7 @@ sub form_header { my $follow_up_vc = $form->{vendor_id} ? SL::DB::Vendor->load_cached($form->{vendor_id})->name : ''; my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)"; - $::request->layout->add_javascripts("autocomplete_chart.js", "show_vc_details.js", "show_history.js", "follow_up.js", "kivi.Draft.js", "kivi.GL.js", "kivi.RecordTemplate.js", "kivi.File.js", "kivi.AP.js", "kivi.CustomerVendor.js", "kivi.Validator.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.RecordTemplate.js", "kivi.File.js", "kivi.AP.js", "kivi.CustomerVendor.js", "kivi.Validator.js", "autocomplete_project.js"); # $form->{totalpaid} is used by the action bar setup to determine # whether or not canceling is allowed. Therefore it must be # calculated prior to the action bar setup. diff --git a/templates/webpages/ap/form_header.html b/templates/webpages/ap/form_header.html index e569004bc..872e78dc1 100644 --- a/templates/webpages/ap/form_header.html +++ b/templates/webpages/ap/form_header.html @@ -170,7 +170,7 @@ [% 'Project Number' | $T8 %] - [% L.select_tag('globalproject_id', ALL_PROJECTS, with_empty = 1, default = globalproject_id, value_key = 'id', title_key = 'projectnumber', onChange = "document.getElementById('update_button').click();") %] + [% P.project.picker('globalproject_id', globalproject_id, onchange="document.getElementById('update_button').click();") %] @@ -212,7 +212,7 @@ [% temp = "project_id_"_ i %] - [% L.select_tag(temp, ALL_PROJECTS, with_empty = 1, default = loop.last ? globalproject_id : $temp, value_key = 'id', title_key = 'projectnumber') %] + [% P.project.picker(temp, loop.last ? globalproject_id : $temp) %] [% END %] @@ -351,7 +351,7 @@ [% temp = "paid_project_id_"_ i %] [% IF( changeable ) %] - [% L.select_tag(temp, ALL_PROJECTS, with_empty = 1, default = $temp, value_key = 'id', title_key = 'projectnumber') %] + [% P.project.picker(temp, $temp) %] [% ELSE %] [% temp = "label"_ temp %] -- 2.20.1