Bug 21222: (bug 20226 follow-up) Fix patron creation
Since bug 20226 you cannot longer creation a patron, memberentry.pl will
explode with
Template process failed: undef error - DBIC result _type isn't of the
_type Category at /home/vagrant/kohaclone/koha-tmpl/intranet-tmpl/prog/en/includes/str/members-menu.inc
line 22.
The problem is that "patron" is actually defined and the test in
str/members-menu.inc does not work as expected.
It comes from
commit 7b1d08df0f
Bug 19936: Replace Generate_Userid - Update the occurrences
where I needed $patron to be defined in order to use Koha::Patron->generate_userid
on an blessed object.
But this was actually wrong, as it could have side-effects.
Test plan:
Create a new patron
Edit it
Retest bug 19936 and make sure the userid is generated correctly in the
different situations
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
51933c7753
commit
644de1c4e7
|
|
@ -4,7 +4,17 @@
|
|||
[% USE Branches %]
|
||||
[% SET footerjs = 1 %]
|
||||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
<title>Koha › Patrons › [% IF ( opadd ) %]Add[% ELSIF ( opduplicate ) %]Duplicate[% ELSE %] Modify[% END %] patron [% IF (firstname) %][% firstname %] [% END %][% IF (surname) %][% surname %] [% END %]([%IF categoryname %][% categoryname %][% ELSE %][% IF ( I ) %]Organization[% END %][% IF ( A ) %]Adult[% END %][% IF ( C ) %]Child[% END %][% IF ( P ) %]Professional[% END %][% IF ( S ) %]Staff[% END %][% END %])</title>
|
||||
<title>Koha › Patrons ›
|
||||
[% UNLESS blocking_error %]
|
||||
[% IF ( opadd ) %]Add
|
||||
[% ELSIF ( opduplicate ) %]Duplicate
|
||||
[% ELSE %] Modify
|
||||
[% END %] patron
|
||||
[% IF (firstname) %][% firstname %] [% END %]
|
||||
[% IF (surname) %][% surname %] [% END %]
|
||||
([%IF categoryname %][% categoryname %][% ELSE %][% IF ( I ) %]Organization[% END %][% IF ( A ) %]Adult[% END %][% IF ( C ) %]Child[% END %][% IF ( P ) %]Professional[% END %][% IF ( S ) %]Staff[% END %][% END %])
|
||||
[% END %]
|
||||
</title>
|
||||
[% INCLUDE 'doc-head-close.inc' %]
|
||||
</head>
|
||||
|
||||
|
|
@ -12,15 +22,19 @@
|
|||
[% INCLUDE 'header.inc' %]
|
||||
[% INCLUDE 'patron-search.inc' %]
|
||||
|
||||
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> ›
|
||||
[% IF (firstname || surname ) %] <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% IF (firstname) %][% firstname | html %] [% END %][% IF (surname) %][% surname | html %] [% END %]</a> ›[% END %]
|
||||
<div id="breadcrumbs">
|
||||
<a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
|
||||
[% UNLESS blocking_error %]
|
||||
›[% IF (firstname || surname ) %] <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% IF (firstname) %][% firstname | html %] [% END %][% IF (surname) %][% surname | html %] [% END %]</a> ›[% END %]
|
||||
<strong>[% IF ( opadd ) %]Add[% ELSIF ( opduplicate ) %]Duplicate[% ELSE %] Modify[% END %] patron ([%IF ( categoryname ) %][% categoryname %][% ELSE %][% IF ( I ) %]Organization[% END %][% IF ( A ) %]Adult[% END %][% IF ( C ) %]Child[% END %][% IF ( P ) %]Professional[% END %][% IF ( S ) %]Staff[% END %][% END %])</strong>
|
||||
[% END %]
|
||||
</div>
|
||||
[% IF ( opadd ) %]<div id="doc" class="yui-t7">[% ELSE %]<div id="doc3" class="yui-t2">[% END %]
|
||||
|
||||
<div id="bd">
|
||||
<div id="yui-main">
|
||||
<div class="yui-b">
|
||||
[% INCLUDE 'blocking_errors.inc' %]
|
||||
[% IF error_alert %]
|
||||
[% IF ( error_alert == "no_email" ) %]
|
||||
<div class="error">This member has no email</div>
|
||||
|
|
|
|||
|
|
@ -160,9 +160,8 @@ if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ) {
|
|||
|
||||
$borrower_data = $patron->unblessed;
|
||||
$borrower_data->{category_type} = $patron->category->category_type;
|
||||
} else {
|
||||
$patron = Koha::Patron->new;
|
||||
}
|
||||
|
||||
my $categorycode = $input->param('categorycode') || $borrower_data->{'categorycode'};
|
||||
my $category_type = $input->param('category_type') || '';
|
||||
unless ($category_type or !($categorycode)){
|
||||
|
|
@ -285,21 +284,23 @@ $newdata{'lang'} = $input->param('lang') if defined($input->param('lang'))
|
|||
# builds default userid
|
||||
# userid input text may be empty or missing because of syspref BorrowerUnwantedField
|
||||
if ( ( defined $newdata{'userid'} && $newdata{'userid'} eq '' ) || $check_BorrowerUnwantedField =~ /userid/ && !defined $data{'userid'} ) {
|
||||
my $fake_patron = Koha::Patron->new;
|
||||
$fake_patron->userid($patron->userid) if $patron; # editing
|
||||
if ( ( defined $newdata{'firstname'} || $category_type eq 'I' ) && ( defined $newdata{'surname'} ) ) {
|
||||
# Full page edit, firstname and surname input zones are present
|
||||
$patron->firstname($newdata{firstname});
|
||||
$patron->surname($newdata{surname});
|
||||
$patron->generate_userid;
|
||||
$newdata{'userid'} = $patron->userid;
|
||||
$fake_patron->firstname($newdata{firstname});
|
||||
$fake_patron->surname($newdata{surname});
|
||||
$fake_patron->generate_userid;
|
||||
$newdata{'userid'} = $fake_patron->userid;
|
||||
}
|
||||
elsif ( ( defined $data{'firstname'} || $category_type eq 'I' ) && ( defined $data{'surname'} ) ) {
|
||||
# Partial page edit (access through "Details"/"Library details" tab), firstname and surname input zones are not used
|
||||
# Still, if the userid field is erased, we can create a new userid with available firstname and surname
|
||||
# FIXME clean thiscode newdata vs data is very confusing
|
||||
$patron->firstname($data{firstname});
|
||||
$patron->surname($data{surname});
|
||||
$patron->generate_userid;
|
||||
$newdata{'userid'} = $patron->userid;
|
||||
$fake_patron->firstname($data{firstname});
|
||||
$fake_patron->surname($data{surname});
|
||||
$fake_patron->generate_userid;
|
||||
$newdata{'userid'} = $fake_patron->userid;
|
||||
}
|
||||
else {
|
||||
$newdata{'userid'} = $data{'userid'};
|
||||
|
|
|
|||
Loading…
Reference in New Issue