Bug 30874: Remove category_type

In which case do we pass category_type to this script? Am I missing
something?

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2022-06-01 10:28:20 +02:00 committed by Tomas Cohen Arazi
parent a2330a84e0
commit bc0d561cf0
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
2 changed files with 11 additions and 23 deletions

View File

@ -242,7 +242,6 @@ legend:hover {
[% END %]
<!-- field always hidden in different form (1,2,3) -->
<input type="hidden" name="BorrowerMandatoryField" value="[% BorrowerMandatoryField | html %]" />
<input type="hidden" name="category_type" value="[% category_type | html %]" />
<input type="hidden" name="updtype" value="[% updtype | html %]" />
<input type="hidden" name="destination" value="[% destination | html %]" />
<input type="hidden" name="check_member" value="[% check_member | html %]" />
@ -269,9 +268,9 @@ legend:hover {
[% IF ( step_1 ) %]
[% UNLESS notitle && nosurname && nofirstname && nomiddle_name && nodateofbirth && noinitials && noothernames &&nosex %]
<fieldset class="rows" id="memberentry_identity">
<legend id="identity_lgd">[% IF ( I ) %]<span>Organization</span> [% ELSE %]<span>Patron</span> [% END %]<span>identity</span></legend>
<legend id="identity_lgd">[% IF ( patron_category.category_type == 'I' ) %]<span>Organization</span> [% ELSE %]<span>Patron</span> [% END %]<span>identity</span></legend>
<ol>
[% UNLESS ( I ) %]
[% UNLESS ( patron_category.category_type == 'I' ) %]
[% UNLESS notitle %]
[% IF Koha.Preference('BorrowersTitles') %]
<li>
@ -301,7 +300,7 @@ legend:hover {
[% UNLESS nosurname %]
<li>
[% IF ( I ) %]
[% IF ( patron_category.category_type == 'I' ) %]
<label for="surname" class="required">
Name:
</label>
@ -325,7 +324,7 @@ legend:hover {
</li>
[% END # /UNLESS nosurname %]
[% UNLESS ( I ) %]
[% UNLESS ( patron_category.category_type == 'I' ) %]
[% UNLESS nofirstname %]
<li>
[% IF ( mandatoryfirstname ) %]
@ -404,11 +403,11 @@ legend:hover {
[% IF ( mandatoryothernames ) %]
<span class="required">Required</span>
[% END %]
[% IF ( I ) %]<input type="hidden" name="sex" value="N" />[% END %]
[% IF ( patron_category.category_type == 'I' ) %]<input type="hidden" name="sex" value="N" />[% END %]
</li>
[% END #/UNLESS noothernames %]
[% UNLESS ( I ) %]
[% UNLESS ( patron_category.category_type == 'I' ) %]
[% UNLESS nosex %]
<li class="radio">
[% UNLESS ( opduplicate ) %]
@ -455,7 +454,7 @@ legend:hover {
[% FOREACH r IN relationships %]
<fieldset>
<ol>
[% IF category_type == 'I' %]
[% IF patron_category.category_type == 'I' %]
<li class="guarantor-details" data-borrowernumber="[% r.guarantor_id | $raw %]">
<span class="label">Organization:</span>
[% INCLUDE 'patron-title.inc' patron=r.guarantor hide_patron_infos_if_needed=1 %]

View File

@ -172,17 +172,10 @@ if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ) {
}
$borrower_data = $patron->unblessed;
$borrower_data->{category_type} = $patron->category->category_type;
}
my $categorycode = $input->param('categorycode') || $borrower_data->{'categorycode'};
my $category_type = $input->param('category_type') || '';
my $category = Koha::Patron::Categories->find($categorycode);
$category_type ||= $category && $category->category_type;
$category_type="A" unless $category_type; # FIXME we should display a error message instead of a 500 error !
$template->param( patron_category => $category );
# if a add or modify is requested => check validity of data.
@ -212,7 +205,7 @@ if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' )
}
# check permission to modify login info.
if (ref($borrower_data) && ($borrower_data->{'category_type'} eq 'S') && ! (C4::Auth::haspermission($userenv->{'id'},{'staffaccess'=>1})) ) {
if (ref($borrower_data) && ($category->category_type eq 'S') && ! (C4::Auth::haspermission($userenv->{'id'},{'staffaccess'=>1})) ) {
$NoUpdateLogin = 1;
}
}
@ -222,7 +215,6 @@ if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' )
my @keys_to_delete = (
qr/^(borrowernumber|date_renewed|debarred|debarredcomment|flags|privacy|updated_on|lastseen|login_attempts|overdrive_auth_token|anonymized)$/, # Bug 28935
qr/^BorrowerMandatoryField$/,
qr/^category_type$/,
qr/^check_member$/,
qr/^destination$/,
qr/^nodouble$/,
@ -297,14 +289,14 @@ $newdata{'lang'} = $input->param('lang') if defined($input->param('lang'))
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'} ) ) {
if ( ( defined $newdata{'firstname'} || $category->category_type eq 'I' ) && ( defined $newdata{'surname'} ) ) {
# Full page edit, firstname and surname input zones are present
$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'} ) ) {
elsif ( ( defined $data{'firstname'} || $category->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
@ -738,7 +730,7 @@ if (C4::Context->userenv && C4::Context->userenv->{'branch'}) {
$userbranch = C4::Context->userenv->{'branch'};
}
if (defined ($data{'branchcode'}) and ( $op eq 'modify' || $op eq 'duplicate' || ( $op eq 'add' && $category_type eq 'C' ) )) {
if (defined ($data{'branchcode'}) and ( $op eq 'modify' || $op eq 'duplicate' || ( $op eq 'add' && $category->category_type eq 'C' ) )) {
$userbranch = $data{'branchcode'};
}
$template->param( userbranch => $userbranch );
@ -809,8 +801,6 @@ $template->param( step => $step ) if $step; # associate with step to know wh
$template->param(
BorrowerMandatoryField => C4::Context->preference("BorrowerMandatoryField"),#field to test with javascript
category_type => $category_type,#to know the category type of the borrower
"$category_type" => 1,# associate with step to know where u are
destination => $destination,#to know where u come from and where u must go in redirect
check_member => $check_member,#to know if the borrower already exist(=>1) or not (=>0)
"op$op" => 1);
@ -822,7 +812,6 @@ $template->param(
relshiploop => \@relshipdata,
btitle=> $default_borrowertitle,
flagloop => \@flagdata,
category_type =>$category_type,
modify => $modify,
nok => $nok,#flag to know if an error
NoUpdateLogin => $NoUpdateLogin,