Lines 53-70
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Link Here
|
53 |
my $borrowernumber = $input->param('borrowernumber'); |
53 |
my $borrowernumber = $input->param('borrowernumber'); |
54 |
my $catcode = $input->param('catcode'); |
54 |
my $catcode = $input->param('catcode'); |
55 |
my $cattype = $input->param('cattype'); |
55 |
my $cattype = $input->param('cattype'); |
56 |
my $catcode_multi = $input->param('catcode_multi'); |
|
|
57 |
my $op = $input->param('op'); |
56 |
my $op = $input->param('op'); |
58 |
|
57 |
|
59 |
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in"; |
58 |
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in"; |
60 |
|
59 |
|
|
|
60 |
my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']}); |
61 |
if ( $op eq 'multi' ) { |
61 |
if ( $op eq 'multi' ) { |
62 |
# FIXME - what are the possible upgrade paths? C -> A , C -> S ... |
62 |
# FIXME - what are the possible upgrade paths? C -> A , C -> S ... |
63 |
# currently just allowing C -> A |
63 |
# currently just allowing C -> A |
64 |
my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']}); |
|
|
65 |
$template->param( |
64 |
$template->param( |
66 |
MULTI => 1, |
65 |
MULTI => 1, |
67 |
CATCODE_MULTI => 1, |
|
|
68 |
borrowernumber => $borrowernumber, |
66 |
borrowernumber => $borrowernumber, |
69 |
patron_categories => $patron_categories, |
67 |
patron_categories => $patron_categories, |
70 |
); |
68 |
); |
Lines 75-85
elsif ( $op eq 'update' ) {
Link Here
|
75 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
73 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
76 |
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); |
74 |
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); |
77 |
|
75 |
|
|
|
76 |
my $adult_category; |
77 |
if ( $patron_categories->count == 1 ) { |
78 |
$adult_category = $patron_categories->next; |
79 |
} else { |
80 |
$adult_category = $patron_categories->search({'me.categorycode' => $catcode })->next; |
81 |
} |
82 |
|
83 |
# Just in case someone is trying something bad |
84 |
# But we should not hit that with a normal use of the interface |
85 |
die "You are doing something wrong updating this child" unless $adult_category; |
86 |
|
78 |
$patron->guarantorid(undef); |
87 |
$patron->guarantorid(undef); |
79 |
$patron->categorycode($catcode); |
88 |
$patron->categorycode($adult_category->categorycode); |
80 |
$patron->store; |
89 |
$patron->store; |
81 |
|
90 |
|
82 |
if ( $catcode_multi ) { |
91 |
# FIXME We should not need that |
|
|
92 |
# We could redirect with a friendly message |
93 |
if ( $patron_categories->count > 1 ) { |
83 |
$template->param( |
94 |
$template->param( |
84 |
SUCCESS => 1, |
95 |
SUCCESS => 1, |
85 |
borrowernumber => $borrowernumber, |
96 |
borrowernumber => $borrowernumber, |
86 |
- |
|
|