Bugzilla – Attachment 140065 Details for
Bug 31459
Make order receive page faster on systems with many budgets
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31459: Use the same dropdown as when adding orders to a basket
Bug-31459-Use-the-same-dropdown-as-when-adding-ord.patch (text/plain), 7.93 KB, created by
Nick Clemens (kidclamp)
on 2022-09-02 06:09:10 UTC
(
hide
)
Description:
Bug 31459: Use the same dropdown as when adding orders to a basket
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-09-02 06:09:10 UTC
Size:
7.93 KB
patch
obsolete
>From d6f8a92a234d9a83ead3074df15a64dbc0c75d5a Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 25 Aug 2022 11:26:33 +0000 >Subject: [PATCH] Bug 31459: Use the same dropdown as when adding orders to a > basket > >Current order receive code loops over each budget period and gets the hierarchy, this >is slow when systems have many budgets. Additionally, the list includes inactive items >by default > >We can switch to a single call, and add consistency by adopting the same dropdown as used >when placing an order > >To test: >1 - Add some budgets with funds - ensure you have at least one inactive budget and fund >2 - Place an order, observe the fund selection menu >3 - Close basket, receive order, observe the fund menu >4 - Apply patch >5 - Cancel receipt >6 - Receive again >7 - Observe fund menu, confirm it matches the order placing menu >8 - Confirm inactive are not displayed by default, but are when button is checked >--- > acqui/orderreceive.pl | 46 +++++--------- > .../prog/en/modules/acqui/orderreceive.tt | 62 +++++++++++++++---- > 2 files changed, 64 insertions(+), 44 deletions(-) > >diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl >index c690dca55f..43b9c109f7 100755 >--- a/acqui/orderreceive.pl >+++ b/acqui/orderreceive.pl >@@ -170,39 +170,21 @@ if ( $suggestion ) { > } > > my $patron = Koha::Patrons->find( $loggedinuser )->unblessed; >-my @budget_loop; >-my $periods = GetBudgetPeriods( ); >-foreach my $period (@$periods) { >- if ($period->{'budget_period_id'} == $budget->{'budget_period_id'}) { >- $template->{'VARS'}->{'budget_period_description'} = $period->{'budget_period_description'}; >- } >- next if $period->{'budget_period_locked'} || !$period->{'budget_period_description'}; >- my $budget_hierarchy = GetBudgetHierarchy( $period->{'budget_period_id'}, undef, undef, 1 ); >- my @funds; >- foreach my $r ( @{$budget_hierarchy} ) { >- next unless ( CanUserUseBudget( $patron, $r, $userflags ) ); >- if ( !defined $r->{budget_amount} || $r->{budget_amount} == 0 ) { >- next; >- } >- push @funds, >- { >- b_id => $r->{budget_id}, >- b_txt => $r->{budget_name}, >- b_sel => ( $r->{budget_id} == $order->budget_id ) ? 1 : 0, >- }; >- } >- >- @funds = sort { uc( $a->{b_txt} ) cmp uc( $b->{b_txt} ) } @funds; >- >- push @budget_loop, >- { >- 'id' => $period->{'budget_period_id'}, >- 'description' => $period->{'budget_period_description'}, >- 'funds' => \@funds >- }; >+my $budget_loop = []; >+my $budgets = GetBudgetHierarchy( undef, undef, undef, 1 ); >+foreach my $r (@{$budgets}) { >+ next unless (CanUserUseBudget($patron, $r, $userflags)); >+ push @{$budget_loop}, { >+ b_id => $r->{budget_id}, >+ b_txt => $r->{budget_name}, >+ b_sort1_authcat => $r->{'sort1_authcat'}, >+ b_sort2_authcat => $r->{'sort2_authcat'}, >+ b_active => $r->{budget_period_active}, >+ b_sel => ( $r->{budget_id} == $order->budget_id ) ? 1 : 0, >+ b_level => $r->{budget_level}, >+ }; > } >- >-$template->{'VARS'}->{'budget_loop'} = \@budget_loop; >+$template->{'VARS'}->{'budget_loop'} = $budget_loop; > > my $op = $input->param('op'); > if ($op and $op eq 'edit'){ >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >index 80a1d9da65..fc22221e48 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >@@ -280,20 +280,43 @@ > <input type="text" size="10" id="datereceived" name="datereceived" value="[% datereceived | html %]" class="flatpickr" /> > <div class="hint">[% INCLUDE 'date-format.inc' %]</div> > </li> >- <li><label for="bookfund">Fund: </label><select id="bookfund" name="bookfund"> >- <option value="">Keep current ([% budget_period_description | html %] - [% order.fund.budget_name | html %])</option> >- [% FOREACH period IN budget_loop %] >- <optgroup label="[% period.description | html %]"> >- [% FOREACH fund IN period.funds %] >- [% IF ( fund.b_sel ) %] >- <option value="[% fund.b_id | html %]" selected="selected">[% fund.b_txt | html %]</option> >- [% ELSE %] >- <option value="[% fund.b_id | html %]">[% fund.b_txt | html %]</option> >- [% END %] >+ <li> >+ <label class="required" for="bookfund">Fund: </label> >+ [% active_count = 0 %] >+ [% IF !ordernumber %] >+ [% FOREACH budget_loo IN budget_loop %] >+ [% active_count= active_count + budget_loo.b_active %] >+ [% END %] >+ [% END %] >+ <select class="select2" id="bookfund" name="bookfund"> >+ [% FOREACH budget_loo IN budget_loop %] >+ [% level_indent_cnt = 0 %] >+ [% level_indent = "" %] >+ [% WHILE level_indent_cnt < budget_loo.b_level %] >+ [% level_indent = level_indent _ " -- " %] >+ [% level_indent_cnt = level_indent_cnt +1 %] >+ [% END %] >+ >+ [% IF ( budget_loo.b_sel ) %] >+ [% active_count = 0 #select no other fund %] >+ <option value="[% budget_loo.b_id | html %]" selected="selected" data-sort1-authcat="[% budget_loo.b_sort1_authcat | html %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat | html %]" >+ > >+ [% ELSIF active_count==1 && budget_loo.b_active %] >+ <option value="[% budget_loo.b_id | html %]" selected="selected" data-sort1-authcat="[% budget_loo.b_sort1_authcat | html %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat | html %]" >+ > >+ [% ELSE %] >+ [% bdgclass=budget_loo.b_active? "": "b_inactive" | html %] >+ <option value="[% budget_loo.b_id | html %]" class="[% bdgclass | html %]" data-sort1-authcat="[% budget_loo.b_sort1_authcat | html %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat | html %]" >+ > > [% END %] >- </optgroup> >+ [% level_indent | html %][% budget_loo.b_txt | html %][% IF !budget_loo.b_active %] (inactive)[% END %] >+ </option> > [% END %] >- </select></li> >+ </select> >+ <span class="required">Required</span> >+ <label for="showallbudgets" style="float:none;"> Show inactive:</label> >+ <input type="checkbox" id="showallbudgets" /> >+ </li> > <li><label> </label><span>(Current: [% budget_period_description | html %] - [% bookfund | html %])</span></li> > <li> > <label for="creator">Ordered by: </label> >@@ -427,6 +450,7 @@ > [% INCLUDE 'calendar.inc' %] > [% Asset.js("js/additem.js") | $raw %] > [% Asset.js("js/cataloging.js") | $raw %] >+ [% INCLUDE 'select2.inc' %] > <script> > function Check(form) { > [% IF (AcqCreateItem == 'receiving') %] >@@ -521,6 +545,20 @@ > [% END %] > > $(document).ready(function() { >+ >+ //keep a copy of all budgets before removing the inactives >+ disabledBudgetsCopy = $('#bookfund').html(); >+ $('#bookfund .b_inactive').remove(); >+ >+ $('#showallbudgets').click(function() { >+ if ($(this).is(":checked")) { >+ $('#bookfund').html(disabledBudgetsCopy); //Puts back all the funds >+ } >+ else { >+ $('#bookfund .b_inactive').remove(); >+ } >+ }); >+ > [% IF (AcqCreateItem == 'receiving') %] > cloneItemBlock(0, '[% Koha.Preference('UniqueItemFields') | html %]'); > [% ELSIF (AcqCreateItem == 'ordering') && not order.subscriptionid %] >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31459
:
139767
|
140065
|
140168
|
141733
|
141734
|
141960
|
142019
|
142020
|
142021
|
142022