Bugzilla – Attachment 138446 Details for
Bug 30874
Simplify patron category handling in memberentry
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30874: Simplify categories loop construction
Bug-30874-Simplify-categories-loop-construction.patch (text/plain), 8.54 KB, created by
Jonathan Druart
on 2022-08-01 07:47:34 UTC
(
hide
)
Description:
Bug 30874: Simplify categories loop construction
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-08-01 07:47:34 UTC
Size:
8.54 KB
patch
obsolete
>From 75a5caf6348a10d637667f7e5f0d02e2e3b916a4 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 1 Jun 2022 10:00:37 +0200 >Subject: [PATCH] Bug 30874: Simplify categories loop construction > >--- > .../prog/en/modules/members/memberentrygen.tt | 42 +++++++++-------- > members/memberentry.pl | 45 ++++++------------- > 2 files changed, 38 insertions(+), 49 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >index bdf59c87d3a..fa3b4b88ddb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -929,26 +929,32 @@ legend:hover { > <li> > <label for="categorycode_entry" class="required">Category: </label> > <select id="categorycode_entry" name="categorycode"> >- [% FOREACH typeloo IN typeloop %] >- [% FOREACH categoryloo IN typeloo.categoryloop %] >- [% IF ( loop.first ) %] >- [% IF ( typeloo.typename_C ) %]<optgroup label="Child">[% END %] >- [% IF ( typeloo.typename_A ) %]<optgroup label="Adult">[% END %] >- [% IF ( typeloo.typename_S ) %]<optgroup label="Staff">[% END %] >- [% IF ( typeloo.typename_I ) %]<optgroup label="Organization">[% END %] >- [% IF ( typeloo.typename_P ) %]<optgroup label="Professional">[% END %] >- [% IF ( typeloo.typename_X ) %]<optgroup label="Statistical">[% END %] >- [% END %] >- [% IF ( categoryloo.categorycodeselected ) %] >- <option value="[% categoryloo.categorycode | html %]" selected="selected" data-pwd-length="[% categoryloo.effective_min_password_length | html %]" data-pwd-strong="[% categoryloo.effective_require_strong_password | html %]" data-typename="[% typeloo.typename | html %]">[% categoryloo.categoryname | html %]</option> >+ [% FOREACH category_type IN patron_categories.keys %] >+ [% SWITCH category_type %] >+ [% CASE 'C' %] >+ <optgroup label="Child"> >+ [% CASE 'A' %] >+ <optgroup label="Adult"> >+ [% CASE 'S' %] >+ <optgroup label="Staff"> >+ [% CASE 'I' %] >+ <optgroup label="Organization"> >+ [% CASE 'P' %] >+ <optgroup label="Professional"> >+ [% CASE 'X' %] >+ <optgroup label="Statistical"> >+ [% CASE %] >+ <optgroup label="Unknown"> >+ [% END %] >+ [% FOREACH category IN patron_categories.$category_type %] >+ [% IF category.categorycode == patron_category.categorycode %] >+ <option value="[% category.categorycode | html %]" selected="selected" data-pwd-length="[% category.effective_min_password_length | html %]" data-pwd-strong="[% category.effective_require_strong_password | html %]" data-typename="[% category_type | html %]">[% category.description | html %]</option> > [% ELSE %] >- <option value="[% categoryloo.categorycode | html %]" data-pwd-length="[% categoryloo.effective_min_password_length | html %]" data-pwd-strong="[% categoryloo.effective_require_strong_password | html %]" data-typename="[% typeloo.typename | html %]">[% categoryloo.categoryname | html %]</option> >- [% END %] >- [% IF ( loop.last ) %] >- </optgroup> >+ <option value="[% category.categorycode | html %]" data-pwd-length="[% category.effective_min_password_length | html %]" data-pwd-strong="[% category.effective_require_strong_password | html %]" data-typename="[% category_type | html %]">[% category.description | html %]</option> > [% END %] >- [% END # /FOREACH categoryloo %] >- [% END # /FOREACH typeloo %] >+ [% END %] >+ </optgroup> >+ [% END %] > </select> > <span class="required">Required</span> > </li> >diff --git a/members/memberentry.pl b/members/memberentry.pl >index f2b51b7a348..7703edfa086 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -667,39 +667,21 @@ if(!defined($data{'sex'})){ > > ##Now all the data to modify a member. > >-my @typeloop; >-my $no_categories = 1; >-my $no_add; >-foreach my $category_type (qw(C A S P I X)) { >- my $categories_limits = { category_type => $category_type }; >- $categories_limits->{can_be_guarantee} = 1 if ($guarantor_id); >- my $patron_categories = Koha::Patron::Categories->search_with_library_limits( $categories_limits, {order_by => ['categorycode']} ); >- $no_categories = 0 if $patron_categories->count > 0; >- >- my @categoryloop; >- while ( my $patron_category = $patron_categories->next ) { >- $categorycode = $patron_category->categorycode unless defined($categorycode); #If none passed in, select the first >- push @categoryloop, >- { 'categorycode' => $patron_category->categorycode, >- 'categoryname' => $patron_category->description, >- 'effective_min_password_length' => $patron_category->effective_min_password_length, >- 'effective_require_strong_password' => $patron_category->effective_require_strong_password, >- 'categorycodeselected' => >- ( $patron_category->categorycode eq $categorycode ), >- }; >- } >- my %typehash; >- $typehash{'typename'} = $category_type; >- my $typedescription = "typename_" . $typehash{'typename'}; >- $typehash{'categoryloop'} = \@categoryloop; >- push @typeloop, >- { 'typename' => $category_type, >- $typedescription => 1, >- 'categoryloop' => \@categoryloop >- }; >+my $patron_categories = Koha::Patron::Categories->search_with_library_limits( >+ { >+ category_type => [qw(C A S P I X)], >+ ( $guarantor_id ? ( can_be_guarantee => 1 ) : () ) >+ }, >+ { order_by => ['categorycode'] } >+); >+my $no_categories = ! $patron_categories->count; >+my $categories = {}; >+foreach my $patron_category ($patron_categories->as_list ) { >+ push @{ $categories->{ $patron_category->category_type } }, $patron_category; > } >+ > $template->param( >- typeloop => \@typeloop, >+ patron_categories => $categories, > no_categories => $no_categories, > ); > >@@ -761,6 +743,7 @@ if (defined ($data{'branchcode'}) and ( $op eq 'modify' || $op eq 'duplicate' || > } > $template->param( userbranch => $userbranch ); > >+my $no_add; > if ( Koha::Libraries->search->count < 1 ){ > $no_add = 1; > $template->param(no_branches => 1); >-- >2.25.1
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 30874
:
135524
|
135525
|
135526
|
135527
|
135528
|
135529
|
138443
|
138444
|
138445
|
138446
|
138447
|
138545
|
138546
|
138547
|
138548
|
138549
|
138637
|
138638
|
138639
|
138640
|
138641