|
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_fee = $input->param('article_request_fee'); |
| 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_fee < 0) { |
| 91 |
$enrolmentperioddate = output_pref( |
81 |
push @messages, {type => 'error', code => 'article_request_negative_fee' }; |
| 92 |
{ |
82 |
$op = 'add_form'; |
| 93 |
dt => dt_from_string($enrolmentperioddate), |
83 |
} else { |
| 94 |
dateformat => 'iso', |
84 |
if ($enrolmentperioddate) { |
| 95 |
dateonly => 1, |
85 |
$enrolmentperioddate = output_pref( |
| 96 |
} |
86 |
{ |
| 97 |
); |
87 |
dt => dt_from_string($enrolmentperioddate), |
| 98 |
} |
88 |
dateformat => 'iso', |
|
|
89 |
dateonly => 1, |
| 90 |
} |
| 91 |
); |
| 92 |
} |
| 99 |
|
93 |
|
| 100 |
if ($is_a_modif) { |
94 |
if ($is_a_modif) { |
| 101 |
my $category = Koha::Patron::Categories->find( $categorycode ); |
95 |
my $category = Koha::Patron::Categories->find( $categorycode ); |
| 102 |
$category->categorycode($categorycode); |
96 |
$category->categorycode($categorycode); |
| 103 |
$category->description($description); |
97 |
$category->description($description); |
| 104 |
$category->enrolmentperiod($enrolmentperiod); |
98 |
$category->enrolmentperiod($enrolmentperiod); |
| 105 |
$category->enrolmentperioddate($enrolmentperioddate); |
99 |
$category->enrolmentperioddate($enrolmentperioddate); |
| 106 |
$category->upperagelimit($upperagelimit); |
100 |
$category->upperagelimit($upperagelimit); |
| 107 |
$category->dateofbirthrequired($dateofbirthrequired); |
101 |
$category->dateofbirthrequired($dateofbirthrequired); |
| 108 |
$category->enrolmentfee($enrolmentfee); |
102 |
$category->enrolmentfee($enrolmentfee); |
| 109 |
$category->reservefee($reservefee); |
103 |
$category->reservefee($reservefee); |
| 110 |
$category->hidelostitems($hidelostitems); |
104 |
$category->hidelostitems($hidelostitems); |
| 111 |
$category->overduenoticerequired($overduenoticerequired); |
105 |
$category->overduenoticerequired($overduenoticerequired); |
| 112 |
$category->category_type($category_type); |
106 |
$category->category_type($category_type); |
| 113 |
$category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions); |
107 |
$category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions); |
| 114 |
$category->checkprevcheckout($checkPrevCheckout); |
108 |
$category->checkprevcheckout($checkPrevCheckout); |
| 115 |
$category->default_privacy($default_privacy); |
109 |
$category->default_privacy($default_privacy); |
| 116 |
$category->reset_password($reset_password); |
110 |
$category->reset_password($reset_password); |
| 117 |
$category->change_password($change_password); |
111 |
$category->change_password($change_password); |
| 118 |
$category->exclude_from_local_holds_priority($exclude_from_local_holds_priority); |
112 |
$category->exclude_from_local_holds_priority($exclude_from_local_holds_priority); |
| 119 |
$category->min_password_length($min_password_length); |
113 |
$category->min_password_length($min_password_length); |
| 120 |
$category->require_strong_password($require_strong_password); |
114 |
$category->require_strong_password($require_strong_password); |
| 121 |
eval { |
115 |
$category->article_request_fee($article_request_fee); |
| 122 |
$category->store; |
116 |
eval { |
| 123 |
$category->replace_library_limits( \@branches ); |
117 |
$category->store; |
| 124 |
}; |
118 |
$category->replace_library_limits( \@branches ); |
| 125 |
if ( $@ ) { |
119 |
}; |
| 126 |
push @messages, {type => 'error', code => 'error_on_update' }; |
120 |
if ( $@ ) { |
| 127 |
} else { |
121 |
push @messages, {type => 'error', code => 'error_on_update' }; |
| 128 |
push @messages, { type => 'message', code => 'success_on_update' }; |
122 |
} else { |
|
|
123 |
push @messages, { type => 'message', code => 'success_on_update' }; |
| 124 |
} |
| 129 |
} |
125 |
} |
| 130 |
} |
126 |
else { |
| 131 |
else { |
127 |
my $category = Koha::Patron::Category->new({ |
| 132 |
my $category = Koha::Patron::Category->new({ |
128 |
categorycode => $categorycode, |
| 133 |
categorycode => $categorycode, |
129 |
description => $description, |
| 134 |
description => $description, |
130 |
enrolmentperiod => $enrolmentperiod, |
| 135 |
enrolmentperiod => $enrolmentperiod, |
131 |
enrolmentperioddate => $enrolmentperioddate, |
| 136 |
enrolmentperioddate => $enrolmentperioddate, |
132 |
upperagelimit => $upperagelimit, |
| 137 |
upperagelimit => $upperagelimit, |
133 |
dateofbirthrequired => $dateofbirthrequired, |
| 138 |
dateofbirthrequired => $dateofbirthrequired, |
134 |
enrolmentfee => $enrolmentfee, |
| 139 |
enrolmentfee => $enrolmentfee, |
135 |
reservefee => $reservefee, |
| 140 |
reservefee => $reservefee, |
136 |
hidelostitems => $hidelostitems, |
| 141 |
hidelostitems => $hidelostitems, |
137 |
overduenoticerequired => $overduenoticerequired, |
| 142 |
overduenoticerequired => $overduenoticerequired, |
138 |
category_type => $category_type, |
| 143 |
category_type => $category_type, |
139 |
BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions, |
| 144 |
BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions, |
140 |
checkprevcheckout => $checkPrevCheckout, |
| 145 |
checkprevcheckout => $checkPrevCheckout, |
141 |
default_privacy => $default_privacy, |
| 146 |
default_privacy => $default_privacy, |
142 |
reset_password => $reset_password, |
| 147 |
reset_password => $reset_password, |
143 |
change_password => $change_password, |
| 148 |
change_password => $change_password, |
144 |
exclude_from_local_holds_priority => $exclude_from_local_holds_priority, |
| 149 |
exclude_from_local_holds_priority => $exclude_from_local_holds_priority, |
145 |
min_password_length => $min_password_length, |
| 150 |
min_password_length => $min_password_length, |
146 |
require_strong_password => $require_strong_password, |
| 151 |
require_strong_password => $require_strong_password, |
147 |
article_request_fee => $article_request_fee, |
| 152 |
}); |
148 |
}); |
| 153 |
eval { |
149 |
eval { |
| 154 |
$category->store; |
150 |
$category->store; |
| 155 |
$category->replace_library_limits( \@branches ); |
151 |
$category->replace_library_limits( \@branches ); |
| 156 |
}; |
152 |
}; |
| 157 |
|
153 |
|
| 158 |
if ( $@ ) { |
154 |
if ( $@ ) { |
| 159 |
push @messages, { type => 'error', code => 'error_on_insert' }; |
155 |
push @messages, { type => 'error', code => 'error_on_insert' }; |
| 160 |
} else { |
156 |
} else { |
| 161 |
push @messages, { type => 'message', code => 'success_on_insert' }; |
157 |
push @messages, { type => 'message', code => 'success_on_insert' }; |
|
|
158 |
} |
| 162 |
} |
159 |
} |
| 163 |
} |
|
|
| 164 |
|
160 |
|
| 165 |
if ( C4::Context->preference('EnhancedMessagingPreferences') ) { |
161 |
if ( C4::Context->preference('EnhancedMessagingPreferences') ) { |
| 166 |
C4::Form::MessagingPreferences::handle_form_action( $input, |
162 |
C4::Form::MessagingPreferences::handle_form_action( $input, |
| 167 |
{ categorycode => scalar $input->param('categorycode') }, $template ); |
163 |
{ categorycode => scalar $input->param('categorycode') }, $template ); |
|
|
164 |
} |
| 165 |
|
| 166 |
$searchfield = q||; |
| 167 |
$op = 'list'; |
| 168 |
} |
168 |
} |
| 169 |
|
|
|
| 170 |
$searchfield = q||; |
| 171 |
$op = 'list'; |
| 172 |
} |
169 |
} |
| 173 |
elsif ( $op eq 'delete_confirm' ) { |
170 |
elsif ( $op eq 'delete_confirm' ) { |
| 174 |
|
171 |
|
|
Lines 199-204
elsif ( $op eq 'delete_confirmed' ) {
Link Here
|
| 199 |
$op = 'list'; |
196 |
$op = 'list'; |
| 200 |
} |
197 |
} |
| 201 |
|
198 |
|
|
|
199 |
if ( $op eq 'add_form' ) { |
| 200 |
|
| 201 |
$template->param( |
| 202 |
category => scalar Koha::Patron::Categories->find($categorycode), |
| 203 |
); |
| 204 |
|
| 205 |
if ( C4::Context->preference('EnhancedMessagingPreferences') ) { |
| 206 |
C4::Form::MessagingPreferences::set_form_values( |
| 207 |
{ categorycode => $categorycode }, $template ); |
| 208 |
} |
| 209 |
} |
| 210 |
|
| 202 |
if ( $op eq 'list' ) { |
211 |
if ( $op eq 'list' ) { |
| 203 |
my $categories = Koha::Patron::Categories->search( |
212 |
my $categories = Koha::Patron::Categories->search( |
| 204 |
{ |
213 |
{ |