Bugzilla – Attachment 135527 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.57 KB, created by
Jonathan Druart
on 2022-06-01 08:11:02 UTC
(
hide
)
Description:
Bug 30874: Simplify categories loop construction
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-06-01 08:11:02 UTC
Size:
8.57 KB
patch
obsolete
>From 0aa04f6d2cb85c31c5ec97e5c0793a30e0592e40 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, 40 insertions(+), 47 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 78bee54ae19..a6d6689d7e3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -914,26 +914,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="[% categoryloo.categorycode | html %]" data-pwd-length="[% categoryloo.effective_min_password_length | html %]" data-pwd-strong="[% categoryloo.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 b8219370680..dbe0a170a90 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -668,37 +668,23 @@ 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->{canbeguarantee} = 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 ) { >- 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' => >- ( defined($categorycode) && $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 $categories_limits = { category_type => [qw(C A S P I X) ] }; >+$categories_limits->{canbeguarantee} = 1 if ($guarantor_id); >+my $patron_categories = Koha::Patron::Categories->search_with_library_limits( >+ { >+ category_type => [qw(C A S P I X)], >+ ( $guarantor_id ? ( canbeguarantee => 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, > ); > >@@ -760,6 +746,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