Lines 172-188
if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ) {
Link Here
|
172 |
} |
172 |
} |
173 |
|
173 |
|
174 |
$borrower_data = $patron->unblessed; |
174 |
$borrower_data = $patron->unblessed; |
175 |
$borrower_data->{category_type} = $patron->category->category_type; |
|
|
176 |
} |
175 |
} |
177 |
|
176 |
|
178 |
my $categorycode = $input->param('categorycode') || $borrower_data->{'categorycode'}; |
177 |
my $categorycode = $input->param('categorycode') || $borrower_data->{'categorycode'}; |
179 |
my $category_type = $input->param('category_type') || ''; |
|
|
180 |
|
181 |
my $category = Koha::Patron::Categories->find($categorycode); |
178 |
my $category = Koha::Patron::Categories->find($categorycode); |
182 |
$category_type ||= $category && $category->category_type; |
|
|
183 |
|
184 |
$category_type="A" unless $category_type; # FIXME we should display a error message instead of a 500 error ! |
185 |
|
186 |
$template->param( patron_category => $category ); |
179 |
$template->param( patron_category => $category ); |
187 |
|
180 |
|
188 |
# if a add or modify is requested => check validity of data. |
181 |
# if a add or modify is requested => check validity of data. |
Lines 212-218
if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' )
Link Here
|
212 |
} |
205 |
} |
213 |
|
206 |
|
214 |
# check permission to modify login info. |
207 |
# check permission to modify login info. |
215 |
if (ref($borrower_data) && ($borrower_data->{'category_type'} eq 'S') && ! (C4::Auth::haspermission($userenv->{'id'},{'staffaccess'=>1})) ) { |
208 |
if (ref($borrower_data) && ($category->category_type eq 'S') && ! (C4::Auth::haspermission($userenv->{'id'},{'staffaccess'=>1})) ) { |
216 |
$NoUpdateLogin = 1; |
209 |
$NoUpdateLogin = 1; |
217 |
} |
210 |
} |
218 |
} |
211 |
} |
Lines 222-228
if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' )
Link Here
|
222 |
my @keys_to_delete = ( |
215 |
my @keys_to_delete = ( |
223 |
qr/^(borrowernumber|date_renewed|debarred|debarredcomment|flags|privacy|updated_on|lastseen|login_attempts|overdrive_auth_token|anonymized)$/, # Bug 28935 |
216 |
qr/^(borrowernumber|date_renewed|debarred|debarredcomment|flags|privacy|updated_on|lastseen|login_attempts|overdrive_auth_token|anonymized)$/, # Bug 28935 |
224 |
qr/^BorrowerMandatoryField$/, |
217 |
qr/^BorrowerMandatoryField$/, |
225 |
qr/^category_type$/, |
|
|
226 |
qr/^check_member$/, |
218 |
qr/^check_member$/, |
227 |
qr/^destination$/, |
219 |
qr/^destination$/, |
228 |
qr/^nodouble$/, |
220 |
qr/^nodouble$/, |
Lines 297-310
$newdata{'lang'} = $input->param('lang') if defined($input->param('lang'))
Link Here
|
297 |
if ( ( defined $newdata{'userid'} && $newdata{'userid'} eq '' ) || $check_BorrowerUnwantedField =~ /userid/ && !defined $data{'userid'} ) { |
289 |
if ( ( defined $newdata{'userid'} && $newdata{'userid'} eq '' ) || $check_BorrowerUnwantedField =~ /userid/ && !defined $data{'userid'} ) { |
298 |
my $fake_patron = Koha::Patron->new; |
290 |
my $fake_patron = Koha::Patron->new; |
299 |
$fake_patron->userid($patron->userid) if $patron; # editing |
291 |
$fake_patron->userid($patron->userid) if $patron; # editing |
300 |
if ( ( defined $newdata{'firstname'} || $category_type eq 'I' ) && ( defined $newdata{'surname'} ) ) { |
292 |
if ( ( defined $newdata{'firstname'} || $category->category_type eq 'I' ) && ( defined $newdata{'surname'} ) ) { |
301 |
# Full page edit, firstname and surname input zones are present |
293 |
# Full page edit, firstname and surname input zones are present |
302 |
$fake_patron->firstname($newdata{firstname}); |
294 |
$fake_patron->firstname($newdata{firstname}); |
303 |
$fake_patron->surname($newdata{surname}); |
295 |
$fake_patron->surname($newdata{surname}); |
304 |
$fake_patron->generate_userid; |
296 |
$fake_patron->generate_userid; |
305 |
$newdata{'userid'} = $fake_patron->userid; |
297 |
$newdata{'userid'} = $fake_patron->userid; |
306 |
} |
298 |
} |
307 |
elsif ( ( defined $data{'firstname'} || $category_type eq 'I' ) && ( defined $data{'surname'} ) ) { |
299 |
elsif ( ( defined $data{'firstname'} || $category->category_type eq 'I' ) && ( defined $data{'surname'} ) ) { |
308 |
# Partial page edit (access through "Details"/"Library details" tab), firstname and surname input zones are not used |
300 |
# Partial page edit (access through "Details"/"Library details" tab), firstname and surname input zones are not used |
309 |
# Still, if the userid field is erased, we can create a new userid with available firstname and surname |
301 |
# Still, if the userid field is erased, we can create a new userid with available firstname and surname |
310 |
# FIXME clean thiscode newdata vs data is very confusing |
302 |
# FIXME clean thiscode newdata vs data is very confusing |
Lines 738-744
if (C4::Context->userenv && C4::Context->userenv->{'branch'}) {
Link Here
|
738 |
$userbranch = C4::Context->userenv->{'branch'}; |
730 |
$userbranch = C4::Context->userenv->{'branch'}; |
739 |
} |
731 |
} |
740 |
|
732 |
|
741 |
if (defined ($data{'branchcode'}) and ( $op eq 'modify' || $op eq 'duplicate' || ( $op eq 'add' && $category_type eq 'C' ) )) { |
733 |
if (defined ($data{'branchcode'}) and ( $op eq 'modify' || $op eq 'duplicate' || ( $op eq 'add' && $category->category_type eq 'C' ) )) { |
742 |
$userbranch = $data{'branchcode'}; |
734 |
$userbranch = $data{'branchcode'}; |
743 |
} |
735 |
} |
744 |
$template->param( userbranch => $userbranch ); |
736 |
$template->param( userbranch => $userbranch ); |
Lines 809-816
$template->param( step => $step ) if $step; # associate with step to know wh
Link Here
|
809 |
|
801 |
|
810 |
$template->param( |
802 |
$template->param( |
811 |
BorrowerMandatoryField => C4::Context->preference("BorrowerMandatoryField"),#field to test with javascript |
803 |
BorrowerMandatoryField => C4::Context->preference("BorrowerMandatoryField"),#field to test with javascript |
812 |
category_type => $category_type,#to know the category type of the borrower |
|
|
813 |
"$category_type" => 1,# associate with step to know where u are |
814 |
destination => $destination,#to know where u come from and where u must go in redirect |
804 |
destination => $destination,#to know where u come from and where u must go in redirect |
815 |
check_member => $check_member,#to know if the borrower already exist(=>1) or not (=>0) |
805 |
check_member => $check_member,#to know if the borrower already exist(=>1) or not (=>0) |
816 |
"op$op" => 1); |
806 |
"op$op" => 1); |
Lines 822-828
$template->param(
Link Here
|
822 |
relshiploop => \@relshipdata, |
812 |
relshiploop => \@relshipdata, |
823 |
btitle=> $default_borrowertitle, |
813 |
btitle=> $default_borrowertitle, |
824 |
flagloop => \@flagdata, |
814 |
flagloop => \@flagdata, |
825 |
category_type =>$category_type, |
|
|
826 |
modify => $modify, |
815 |
modify => $modify, |
827 |
nok => $nok,#flag to know if an error |
816 |
nok => $nok,#flag to know if an error |
828 |
NoUpdateLogin => $NoUpdateLogin, |
817 |
NoUpdateLogin => $NoUpdateLogin, |
829 |
- |
|
|