Lines 46-63
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Link Here
|
46 |
} |
46 |
} |
47 |
); |
47 |
); |
48 |
|
48 |
|
49 |
if ( $op eq 'add_form' ) { |
49 |
if ( $op eq 'add_validate' ) { |
50 |
|
|
|
51 |
$template->param( |
52 |
category => scalar Koha::Patron::Categories->find($categorycode), |
53 |
); |
54 |
|
55 |
if ( C4::Context->preference('EnhancedMessagingPreferences') ) { |
56 |
C4::Form::MessagingPreferences::set_form_values( |
57 |
{ categorycode => $categorycode }, $template ); |
58 |
} |
59 |
} |
60 |
elsif ( $op eq 'add_validate' ) { |
61 |
|
50 |
|
62 |
my $categorycode = $input->param('categorycode'); |
51 |
my $categorycode = $input->param('categorycode'); |
63 |
my $description = $input->param('description'); |
52 |
my $description = $input->param('description'); |
Lines 78-83
elsif ( $op eq 'add_validate' ) {
Link Here
|
78 |
my $exclude_from_local_holds_priority = $input->param('exclude_from_local_holds_priority'); |
67 |
my $exclude_from_local_holds_priority = $input->param('exclude_from_local_holds_priority'); |
79 |
my $min_password_length = $input->param('min_password_length'); |
68 |
my $min_password_length = $input->param('min_password_length'); |
80 |
my $require_strong_password = $input->param('require_strong_password'); |
69 |
my $require_strong_password = $input->param('require_strong_password'); |
|
|
70 |
my $article_request_limit = $input->param('article_request_limit'); |
81 |
my @branches = grep { $_ ne q{} } $input->multi_param('branches'); |
71 |
my @branches = grep { $_ ne q{} } $input->multi_param('branches'); |
82 |
|
72 |
|
83 |
$reset_password = undef if $reset_password eq -1; |
73 |
$reset_password = undef if $reset_password eq -1; |
Lines 87-174
elsif ( $op eq 'add_validate' ) {
Link Here
|
87 |
|
77 |
|
88 |
my $is_a_modif = $input->param("is_a_modif"); |
78 |
my $is_a_modif = $input->param("is_a_modif"); |
89 |
|
79 |
|
90 |
if ($enrolmentperioddate) { |
80 |
if ($article_request_limit ne '' && $article_request_limit !~ /\d+/) { |
91 |
$enrolmentperioddate = output_pref( |
81 |
push @messages, {type => 'error', code => 'article_request_numeric_limit' }; |
92 |
{ |
82 |
$op = 'add_form'; |
93 |
dt => dt_from_string($enrolmentperioddate), |
83 |
} elsif ($article_request_limit ne '' && $article_request_limit < 0) { |
94 |
dateformat => 'iso', |
84 |
push @messages, {type => 'error', code => 'article_request_negative_limit' }; |
95 |
dateonly => 1, |
85 |
$op = 'add_form'; |
96 |
} |
86 |
} else { |
97 |
); |
87 |
if ($enrolmentperioddate) { |
98 |
} |
88 |
$enrolmentperioddate = output_pref( |
|
|
89 |
{ |
90 |
dt => dt_from_string($enrolmentperioddate), |
91 |
dateformat => 'iso', |
92 |
dateonly => 1, |
93 |
} |
94 |
); |
95 |
} |
99 |
|
96 |
|
100 |
if ($is_a_modif) { |
97 |
if ($is_a_modif) { |
101 |
my $category = Koha::Patron::Categories->find( $categorycode ); |
98 |
my $category = Koha::Patron::Categories->find( $categorycode ); |
102 |
$category->categorycode($categorycode); |
99 |
$category->categorycode($categorycode); |
103 |
$category->description($description); |
100 |
$category->description($description); |
104 |
$category->enrolmentperiod($enrolmentperiod); |
101 |
$category->enrolmentperiod($enrolmentperiod); |
105 |
$category->enrolmentperioddate($enrolmentperioddate); |
102 |
$category->enrolmentperioddate($enrolmentperioddate); |
106 |
$category->upperagelimit($upperagelimit); |
103 |
$category->upperagelimit($upperagelimit); |
107 |
$category->dateofbirthrequired($dateofbirthrequired); |
104 |
$category->dateofbirthrequired($dateofbirthrequired); |
108 |
$category->enrolmentfee($enrolmentfee); |
105 |
$category->enrolmentfee($enrolmentfee); |
109 |
$category->reservefee($reservefee); |
106 |
$category->reservefee($reservefee); |
110 |
$category->hidelostitems($hidelostitems); |
107 |
$category->hidelostitems($hidelostitems); |
111 |
$category->overduenoticerequired($overduenoticerequired); |
108 |
$category->overduenoticerequired($overduenoticerequired); |
112 |
$category->category_type($category_type); |
109 |
$category->category_type($category_type); |
113 |
$category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions); |
110 |
$category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions); |
114 |
$category->checkprevcheckout($checkPrevCheckout); |
111 |
$category->checkprevcheckout($checkPrevCheckout); |
115 |
$category->default_privacy($default_privacy); |
112 |
$category->default_privacy($default_privacy); |
116 |
$category->reset_password($reset_password); |
113 |
$category->reset_password($reset_password); |
117 |
$category->change_password($change_password); |
114 |
$category->change_password($change_password); |
118 |
$category->exclude_from_local_holds_priority($exclude_from_local_holds_priority); |
115 |
$category->exclude_from_local_holds_priority($exclude_from_local_holds_priority); |
119 |
$category->min_password_length($min_password_length); |
116 |
$category->min_password_length($min_password_length); |
120 |
$category->require_strong_password($require_strong_password); |
117 |
$category->require_strong_password($require_strong_password); |
121 |
eval { |
118 |
$category->article_request_limit($article_request_limit); |
122 |
$category->store; |
119 |
eval { |
123 |
$category->replace_library_limits( \@branches ); |
120 |
$category->store; |
124 |
}; |
121 |
$category->replace_library_limits( \@branches ); |
125 |
if ( $@ ) { |
122 |
}; |
126 |
push @messages, {type => 'error', code => 'error_on_update' }; |
123 |
if ( $@ ) { |
127 |
} else { |
124 |
push @messages, {type => 'error', code => 'error_on_update' }; |
128 |
push @messages, { type => 'message', code => 'success_on_update' }; |
125 |
} else { |
|
|
126 |
push @messages, { type => 'message', code => 'success_on_update' }; |
127 |
} |
129 |
} |
128 |
} |
130 |
} |
129 |
else { |
131 |
else { |
130 |
my $category = Koha::Patron::Category->new({ |
132 |
my $category = Koha::Patron::Category->new({ |
131 |
categorycode => $categorycode, |
133 |
categorycode => $categorycode, |
132 |
description => $description, |
134 |
description => $description, |
133 |
enrolmentperiod => $enrolmentperiod, |
135 |
enrolmentperiod => $enrolmentperiod, |
134 |
enrolmentperioddate => $enrolmentperioddate, |
136 |
enrolmentperioddate => $enrolmentperioddate, |
135 |
upperagelimit => $upperagelimit, |
137 |
upperagelimit => $upperagelimit, |
136 |
dateofbirthrequired => $dateofbirthrequired, |
138 |
dateofbirthrequired => $dateofbirthrequired, |
137 |
enrolmentfee => $enrolmentfee, |
139 |
enrolmentfee => $enrolmentfee, |
138 |
reservefee => $reservefee, |
140 |
reservefee => $reservefee, |
139 |
hidelostitems => $hidelostitems, |
141 |
hidelostitems => $hidelostitems, |
140 |
overduenoticerequired => $overduenoticerequired, |
142 |
overduenoticerequired => $overduenoticerequired, |
141 |
category_type => $category_type, |
143 |
category_type => $category_type, |
142 |
BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions, |
144 |
BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions, |
143 |
checkprevcheckout => $checkPrevCheckout, |
145 |
checkprevcheckout => $checkPrevCheckout, |
144 |
default_privacy => $default_privacy, |
146 |
default_privacy => $default_privacy, |
145 |
reset_password => $reset_password, |
147 |
reset_password => $reset_password, |
146 |
change_password => $change_password, |
148 |
change_password => $change_password, |
147 |
exclude_from_local_holds_priority => $exclude_from_local_holds_priority, |
149 |
exclude_from_local_holds_priority => $exclude_from_local_holds_priority, |
148 |
min_password_length => $min_password_length, |
150 |
min_password_length => $min_password_length, |
149 |
require_strong_password => $require_strong_password, |
151 |
require_strong_password => $require_strong_password, |
150 |
article_request_limit => $article_request_limit |
152 |
}); |
151 |
}); |
153 |
eval { |
152 |
eval { |
154 |
$category->store; |
153 |
$category->store; |
155 |
$category->replace_library_limits( \@branches ); |
154 |
$category->replace_library_limits( \@branches ); |
156 |
}; |
155 |
}; |
157 |
|
156 |
|
158 |
if ( $@ ) { |
157 |
if ( $@ ) { |
159 |
push @messages, { type => 'error', code => 'error_on_insert' }; |
158 |
push @messages, { type => 'error', code => 'error_on_insert' }; |
160 |
} else { |
159 |
} else { |
161 |
push @messages, { type => 'message', code => 'success_on_insert' }; |
160 |
push @messages, { type => 'message', code => 'success_on_insert' }; |
|
|
161 |
} |
162 |
} |
162 |
} |
163 |
} |
|
|
164 |
|
163 |
|
165 |
if ( C4::Context->preference('EnhancedMessagingPreferences') ) { |
164 |
if ( C4::Context->preference('EnhancedMessagingPreferences') ) { |
166 |
C4::Form::MessagingPreferences::handle_form_action( $input, |
165 |
C4::Form::MessagingPreferences::handle_form_action( $input, |
167 |
{ categorycode => scalar $input->param('categorycode') }, $template ); |
166 |
{ categorycode => scalar $input->param('categorycode') }, $template ); |
168 |
} |
167 |
} |
169 |
|
168 |
|
170 |
$searchfield = q||; |
169 |
$searchfield = q||; |
171 |
$op = 'list'; |
170 |
$op = 'list'; |
|
|
171 |
} |
172 |
} |
172 |
} |
173 |
elsif ( $op eq 'delete_confirm' ) { |
173 |
elsif ( $op eq 'delete_confirm' ) { |
174 |
|
174 |
|
Lines 199-204
elsif ( $op eq 'delete_confirmed' ) {
Link Here
|
199 |
$op = 'list'; |
199 |
$op = 'list'; |
200 |
} |
200 |
} |
201 |
|
201 |
|
|
|
202 |
if ( $op eq 'add_form' ) { |
203 |
|
204 |
$template->param( |
205 |
category => scalar Koha::Patron::Categories->find($categorycode), |
206 |
); |
207 |
|
208 |
if ( C4::Context->preference('EnhancedMessagingPreferences') ) { |
209 |
C4::Form::MessagingPreferences::set_form_values( |
210 |
{ categorycode => $categorycode }, $template ); |
211 |
} |
212 |
} |
213 |
|
202 |
if ( $op eq 'list' ) { |
214 |
if ( $op eq 'list' ) { |
203 |
my $categories = Koha::Patron::Categories->search( |
215 |
my $categories = Koha::Patron::Categories->search( |
204 |
{ |
216 |
{ |