Lines 18-24
Link Here
|
18 |
# if $op=delete_confirm |
18 |
# if $op=delete_confirm |
19 |
# - we delete the record having primkey=$primkey |
19 |
# - we delete the record having primkey=$primkey |
20 |
|
20 |
|
21 |
|
|
|
22 |
# Copyright 2000-2002 Katipo Communications |
21 |
# Copyright 2000-2002 Katipo Communications |
23 |
# |
22 |
# |
24 |
# This file is part of Koha. |
23 |
# This file is part of Koha. |
Lines 47-132
use C4::Dates;
Link Here
|
47 |
use C4::Form::MessagingPreferences; |
46 |
use C4::Form::MessagingPreferences; |
48 |
use Koha::Database; |
47 |
use Koha::Database; |
49 |
|
48 |
|
50 |
sub StringSearch { |
49 |
sub StringSearch { |
51 |
my ($searchstring,$type)=@_; |
50 |
my ( $searchstring, $type ) = @_; |
52 |
my $dbh = C4::Context->dbh; |
51 |
my $dbh = C4::Context->dbh; |
53 |
$searchstring //= ''; |
52 |
$searchstring //= ''; |
54 |
$searchstring=~ s/\'/\\\'/g; |
53 |
$searchstring =~ s/\'/\\\'/g; |
55 |
my @data=split(' ',$searchstring); |
54 |
my @data = split( ' ', $searchstring ); |
56 |
push @data,q{} if $#data==-1; |
55 |
push @data, q{} if $#data == -1; |
57 |
my $count=@data; |
56 |
my $count = @data; |
58 |
my $sth=$dbh->prepare("Select * from categories where (description like ?) order by category_type,description,categorycode"); |
57 |
my $sth = $dbh->prepare("Select * from categories where (description like ?) order by category_type,description,categorycode"); |
59 |
$sth->execute("$data[0]%"); |
58 |
$sth->execute("$data[0]%"); |
60 |
my @results; |
59 |
my @results; |
61 |
while (my $data=$sth->fetchrow_hashref){ |
|
|
62 |
push(@results,$data); |
63 |
} |
64 |
# $sth->execute; |
65 |
$sth->finish; |
66 |
return (scalar(@results),\@results); |
67 |
} |
68 |
|
60 |
|
69 |
my $input = new CGI; |
61 |
while ( my $data = $sth->fetchrow_hashref ) { |
70 |
my $searchfield=$input->param('description'); |
62 |
push( @results, $data ); |
71 |
my $script_name="/cgi-bin/koha/admin/categorie.pl"; |
63 |
} |
72 |
my $categorycode=$input->param('categorycode'); |
|
|
73 |
my $op = $input->param('op') // ''; |
74 |
my $block_expired = $input->param("block_expired"); |
75 |
|
64 |
|
76 |
my ($template, $loggedinuser, $cookie) |
65 |
# $sth->execute; |
77 |
= get_template_and_user({template_name => "admin/categorie.tmpl", |
66 |
$sth->finish; |
78 |
query => $input, |
67 |
return ( scalar(@results), \@results ); |
79 |
type => "intranet", |
68 |
} |
80 |
authnotrequired => 0, |
|
|
81 |
flagsrequired => {parameters => 'parameters_remaining_permissions'}, |
82 |
debug => 1, |
83 |
}); |
84 |
|
69 |
|
|
|
70 |
my $input = new CGI; |
71 |
my $searchfield = $input->param('description'); |
72 |
my $script_name = "/cgi-bin/koha/admin/categorie.pl"; |
73 |
my $categorycode = $input->param('categorycode'); |
74 |
my $op = $input->param('op') // ''; |
75 |
my $block_expired = $input->param("block_expired"); |
85 |
|
76 |
|
86 |
$template->param(script_name => $script_name, |
77 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
87 |
categorycode => $categorycode, |
78 |
{ |
88 |
searchfield => $searchfield); |
79 |
template_name => "admin/categorie.tmpl", |
|
|
80 |
query => $input, |
81 |
type => "intranet", |
82 |
authnotrequired => 0, |
83 |
flagsrequired => { parameters => 'parameters_remaining_permissions' }, |
84 |
debug => 1, |
85 |
} |
86 |
); |
89 |
|
87 |
|
|
|
88 |
$template->param( |
89 |
script_name => $script_name, |
90 |
categorycode => $categorycode, |
91 |
searchfield => $searchfield |
92 |
); |
90 |
|
93 |
|
91 |
################## ADD_FORM ################################## |
94 |
################## ADD_FORM ################################## |
92 |
# called by default. Used to create form to add or modify a record |
95 |
# called by default. Used to create form to add or modify a record |
93 |
if ($op eq 'add_form') { |
96 |
if ( $op eq 'add_form' ) { |
94 |
$template->param(add_form => 1); |
97 |
$template->param( add_form => 1 ); |
95 |
|
98 |
|
96 |
#---- if primkey exists, it's a modify action, so read values to modify... |
99 |
#---- if primkey exists, it's a modify action, so read values to modify... |
97 |
my $data; |
100 |
my $data; |
98 |
my @selected_branches; |
101 |
my @selected_branches; |
99 |
if ($categorycode) { |
102 |
if ($categorycode) { |
100 |
my $dbh = C4::Context->dbh; |
103 |
my $dbh = C4::Context->dbh; |
101 |
my $sth=$dbh->prepare("SELECT * FROM categories WHERE categorycode=?"); |
104 |
my $sth = |
102 |
$sth->execute($categorycode); |
105 |
$dbh->prepare("SELECT * FROM categories WHERE categorycode=?"); |
103 |
$data=$sth->fetchrow_hashref; |
106 |
$sth->execute($categorycode); |
104 |
|
107 |
$data = $sth->fetchrow_hashref; |
105 |
$sth = $dbh->prepare("SELECT b.branchcode, b.branchname FROM categories_branches AS cb, branches AS b WHERE cb.branchcode = b.branchcode AND cb.categorycode = ?"); |
108 |
|
106 |
$sth->execute( $categorycode ); |
109 |
$sth = $dbh->prepare( |
|
|
110 |
"SELECT b.branchcode, b.branchname |
111 |
FROM categories_branches AS cb, branches AS b |
112 |
WHERE cb.branchcode = b.branchcode AND cb.categorycode = ? |
113 |
"); |
114 |
$sth->execute($categorycode); |
107 |
while ( my $branch = $sth->fetchrow_hashref ) { |
115 |
while ( my $branch = $sth->fetchrow_hashref ) { |
108 |
push @selected_branches, $branch; |
116 |
push @selected_branches, $branch; |
109 |
} |
117 |
} |
110 |
$sth->finish; |
118 |
$sth->finish; |
111 |
} |
119 |
} |
112 |
|
120 |
|
113 |
if ($data->{'enrolmentperioddate'} && $data->{'enrolmentperioddate'} eq '0000-00-00') { |
121 |
if ( $data->{'enrolmentperioddate'} |
|
|
122 |
&& $data->{'enrolmentperioddate'} eq '0000-00-00' ) |
123 |
{ |
114 |
$data->{'enrolmentperioddate'} = undef; |
124 |
$data->{'enrolmentperioddate'} = undef; |
115 |
} |
125 |
} |
|
|
126 |
|
116 |
$data->{'category_type'} //= ''; |
127 |
$data->{'category_type'} //= ''; |
117 |
|
128 |
|
118 |
my $branches = GetBranches; |
129 |
my $branches = GetBranches(); |
119 |
my @branches_loop; |
130 |
my @branches_loop; |
120 |
foreach my $branch (sort keys %$branches) { |
131 |
foreach my $branch ( sort keys %$branches ) { |
121 |
my $selected = ( grep {$$_{branchcode} eq $branch} @selected_branches ) ? 1 : 0; |
132 |
my $selected = |
122 |
push @branches_loop, { |
133 |
( grep { $$_{branchcode} eq $branch } @selected_branches ) ? 1 : 0; |
|
|
134 |
push @branches_loop, |
135 |
{ |
123 |
branchcode => $$branches{$branch}{branchcode}, |
136 |
branchcode => $$branches{$branch}{branchcode}, |
124 |
branchname => $$branches{$branch}{branchname}, |
137 |
branchname => $$branches{$branch}{branchname}, |
125 |
selected => $selected, |
138 |
selected => $selected, |
126 |
}; |
139 |
}; |
127 |
} |
140 |
} |
128 |
|
141 |
|
129 |
$template->param( |
142 |
$template->param( |
|
|
143 |
branches_loop => \@branches_loop, |
130 |
description => $data->{'description'}, |
144 |
description => $data->{'description'}, |
131 |
enrolmentperiod => $data->{'enrolmentperiod'}, |
145 |
enrolmentperiod => $data->{'enrolmentperiod'}, |
132 |
enrolmentperioddate => $data->{'enrolmentperioddate'}, |
146 |
enrolmentperioddate => $data->{'enrolmentperioddate'}, |
Lines 138-169
if ($op eq 'add_form') {
Link Here
|
138 |
reservefee => sprintf( "%.2f", $data->{'reservefee'} || 0 ), |
152 |
reservefee => sprintf( "%.2f", $data->{'reservefee'} || 0 ), |
139 |
hidelostitems => $data->{'hidelostitems'}, |
153 |
hidelostitems => $data->{'hidelostitems'}, |
140 |
category_type => $data->{'category_type'}, |
154 |
category_type => $data->{'category_type'}, |
|
|
155 |
default_privacy => $data->{'default_privacy'}, |
141 |
SMSSendDriver => C4::Context->preference("SMSSendDriver"), |
156 |
SMSSendDriver => C4::Context->preference("SMSSendDriver"), |
142 |
TalkingTechItivaPhone => |
|
|
143 |
C4::Context->preference("TalkingTechItivaPhoneNotification"), |
144 |
"type_" . $data->{'category_type'} => 1, |
157 |
"type_" . $data->{'category_type'} => 1, |
145 |
branches_loop => \@branches_loop, |
|
|
146 |
BlockExpiredPatronOpacActions => |
158 |
BlockExpiredPatronOpacActions => |
147 |
$data->{'BlockExpiredPatronOpacActions'}, |
159 |
$data->{'BlockExpiredPatronOpacActions'}, |
148 |
default_privacy => $data->{'default_privacy'}, |
160 |
TalkingTechItivaPhone => |
|
|
161 |
C4::Context->preference("TalkingTechItivaPhoneNotification"), |
149 |
); |
162 |
); |
150 |
|
163 |
|
151 |
if (C4::Context->preference('EnhancedMessagingPreferences')) { |
164 |
if ( C4::Context->preference('EnhancedMessagingPreferences') ) { |
152 |
C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template); |
165 |
C4::Form::MessagingPreferences::set_form_values( |
|
|
166 |
{ categorycode => $categorycode }, $template ); |
153 |
} |
167 |
} |
154 |
# END $OP eq ADD_FORM |
168 |
|
|
|
169 |
# END $OP eq ADD_FORM |
155 |
################## ADD_VALIDATE ################################## |
170 |
################## ADD_VALIDATE ################################## |
156 |
# called by add_form, used to insert/modify data in DB |
171 |
# called by add_form, used to insert/modify data in DB |
157 |
} elsif ($op eq 'add_validate') { |
172 |
} |
158 |
$template->param(add_validate => 1); |
173 |
elsif ( $op eq 'add_validate' ) { |
159 |
my $is_a_modif = $input->param("is_a_modif"); |
174 |
$template->param( add_validate => 1 ); |
160 |
my $dbh = C4::Context->dbh; |
175 |
|
161 |
if($input->param('enrolmentperioddate')){ |
176 |
my $is_a_modif = $input->param("is_a_modif"); |
162 |
$input->param('enrolmentperioddate' => C4::Dates::format_date_in_iso($input->param('enrolmentperioddate')) ); |
177 |
|
163 |
} |
178 |
my $dbh = C4::Context->dbh; |
164 |
|
179 |
|
165 |
if ($is_a_modif) { |
180 |
if ( $input->param('enrolmentperioddate') ) { |
166 |
my $sth=$dbh->prepare(" |
181 |
$input->param( |
|
|
182 |
'enrolmentperioddate' => C4::Dates::format_date_in_iso( |
183 |
$input->param('enrolmentperioddate') |
184 |
) |
185 |
); |
186 |
} |
187 |
|
188 |
if ($is_a_modif) { |
189 |
my $sth = $dbh->prepare( " |
167 |
UPDATE categories |
190 |
UPDATE categories |
168 |
SET description=?, |
191 |
SET description=?, |
169 |
enrolmentperiod=?, |
192 |
enrolmentperiod=?, |
Lines 178-220
if ($op eq 'add_form') {
Link Here
|
178 |
BlockExpiredPatronOpacActions=?, |
201 |
BlockExpiredPatronOpacActions=?, |
179 |
default_privacy=? |
202 |
default_privacy=? |
180 |
WHERE categorycode=?" |
203 |
WHERE categorycode=?" |
|
|
204 |
); |
205 |
$sth->execute( |
206 |
map { $input->param($_) } ( |
207 |
'description', 'enrolmentperiod', |
208 |
'enrolmentperioddate', 'upperagelimit', |
209 |
'dateofbirthrequired', 'enrolmentfee', |
210 |
'reservefee', 'hidelostitems', |
211 |
'overduenoticerequired', 'category_type', |
212 |
'block_expired', 'default_privacy', |
213 |
'categorycode' |
214 |
) |
215 |
); |
216 |
my @branches = $input->param("branches"); |
217 |
if (@branches) { |
218 |
$sth = $dbh->prepare( |
219 |
"DELETE FROM categories_branches WHERE categorycode = ?" |
181 |
); |
220 |
); |
182 |
$sth->execute( |
221 |
$sth->execute( $input->param("categorycode") ); |
183 |
map { $input->param($_) } ( |
222 |
$sth = $dbh->prepare( |
184 |
'description', |
223 |
"INSERT INTO categories_branches ( categorycode, branchcode ) VALUES ( ?, ? )" |
185 |
'enrolmentperiod', |
|
|
186 |
'enrolmentperioddate', |
187 |
'upperagelimit', |
188 |
'dateofbirthrequired', |
189 |
'enrolmentfee', |
190 |
'reservefee', |
191 |
'hidelostitems', |
192 |
'overduenoticerequired', |
193 |
'category_type', |
194 |
'block_expired', |
195 |
'default_privacy', |
196 |
'categorycode' |
197 |
) |
198 |
); |
224 |
); |
199 |
my @branches = $input->param("branches"); |
225 |
for my $branchcode (@branches) { |
200 |
if ( @branches ) { |
226 |
next if not $branchcode; |
201 |
$sth = $dbh->prepare("DELETE FROM categories_branches WHERE categorycode = ?"); |
227 |
$sth->bind_param( 1, $input->param("categorycode") ); |
202 |
$sth->execute( $input->param( "categorycode" ) ); |
228 |
$sth->bind_param( 2, $branchcode ); |
203 |
$sth = $dbh->prepare( |
229 |
$sth->execute; |
204 |
"INSERT INTO categories_branches |
|
|
205 |
( categorycode, branchcode ) |
206 |
VALUES ( ?, ? )" |
207 |
); |
208 |
for my $branchcode ( @branches ) { |
209 |
next if not $branchcode; |
210 |
$sth->bind_param( 1, $input->param( "categorycode" ) ); |
211 |
$sth->bind_param( 2, $branchcode ); |
212 |
$sth->execute; |
213 |
} |
214 |
} |
230 |
} |
215 |
$sth->finish; |
231 |
} |
216 |
} else { |
232 |
$sth->finish; |
217 |
my $sth=$dbh->prepare(" |
233 |
} |
|
|
234 |
else { |
235 |
my $sth = $dbh->prepare( " |
218 |
INSERT INTO categories ( |
236 |
INSERT INTO categories ( |
219 |
categorycode, |
237 |
categorycode, |
220 |
description, |
238 |
description, |
Lines 230-360
if ($op eq 'add_form') {
Link Here
|
230 |
BlockExpiredPatronOpacActions, |
248 |
BlockExpiredPatronOpacActions, |
231 |
default_privacy |
249 |
default_privacy |
232 |
) |
250 |
) |
233 |
VALUES (?,?,?,?,?,?,?,?,?,?,?,?)"); |
251 |
VALUES (?,?,?,?,?,?,?,?,?,?,?,?)" ); |
234 |
$sth->execute( |
252 |
$sth->execute( |
235 |
map { $input->param($_) } ( |
253 |
map { $input->param($_) } ( |
236 |
'categorycode', |
254 |
'categorycode', 'description', |
237 |
'description', |
255 |
'enrolmentperiod', 'enrolmentperioddate', |
238 |
'enrolmentperiod', |
256 |
'upperagelimit', 'dateofbirthrequired', |
239 |
'enrolmentperioddate', |
257 |
'enrolmentfee', 'reservefee', |
240 |
'upperagelimit', |
258 |
'hidelostitems', 'overduenoticerequired', |
241 |
'dateofbirthrequired', |
259 |
'category_type', 'block_expired', |
242 |
'enrolmentfee', |
|
|
243 |
'reservefee', |
244 |
'hidelostitems', |
245 |
'overduenoticerequired', |
246 |
'category_type', |
247 |
'block_expired', |
248 |
'default_privacy', |
260 |
'default_privacy', |
249 |
) |
261 |
) |
250 |
); |
262 |
); |
251 |
$sth->finish; |
263 |
$sth->finish; |
252 |
} |
264 |
} |
253 |
|
265 |
|
254 |
if (C4::Context->preference('EnhancedMessagingPreferences')) { |
266 |
if ( C4::Context->preference('EnhancedMessagingPreferences') ) { |
255 |
C4::Form::MessagingPreferences::handle_form_action($input, |
267 |
C4::Form::MessagingPreferences::handle_form_action( $input, |
256 |
{ categorycode => $input->param('categorycode') }, $template); |
268 |
{ categorycode => $input->param('categorycode') }, $template ); |
257 |
} |
269 |
} |
258 |
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=categorie.pl\"></html>"; |
|
|
259 |
exit; |
260 |
|
270 |
|
261 |
# END $OP eq ADD_VALIDATE |
271 |
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=categorie.pl\"></html>"; |
|
|
272 |
exit; |
273 |
|
274 |
# END $OP eq ADD_VALIDATE |
262 |
################## DELETE_CONFIRM ################################## |
275 |
################## DELETE_CONFIRM ################################## |
263 |
# called by default form, used to confirm deletion of data in DB |
276 |
# called by default form, used to confirm deletion of data in DB |
264 |
} elsif ($op eq 'delete_confirm') { |
277 |
} |
|
|
278 |
elsif ( $op eq 'delete_confirm' ) { |
265 |
my $schema = Koha::Database->new()->schema(); |
279 |
my $schema = Koha::Database->new()->schema(); |
266 |
$template->param(delete_confirm => 1); |
280 |
$template->param( delete_confirm => 1 ); |
|
|
281 |
|
282 |
my $count = |
283 |
$schema->resultset('Borrower') |
284 |
->search( { categorycode => $categorycode } )->count(); |
267 |
|
285 |
|
268 |
my $count = $schema->resultset('Borrower')->search( { categorycode => $categorycode } )->count(); |
|
|
269 |
my $category = $schema->resultset('Category')->find($categorycode); |
286 |
my $category = $schema->resultset('Category')->find($categorycode); |
270 |
$category->enrolmentperioddate( C4::Dates::format_date( $category->enrolmentperioddate() ) ); |
287 |
|
|
|
288 |
$category->enrolmentperioddate( |
289 |
C4::Dates::format_date( $category->enrolmentperioddate() ) ); |
290 |
|
271 |
$template->param( category => $category, patrons_in_category => $count ); |
291 |
$template->param( category => $category, patrons_in_category => $count ); |
272 |
# END $OP eq DELETE_CONFIRM |
292 |
|
|
|
293 |
# END $OP eq DELETE_CONFIRM |
273 |
################## DELETE_CONFIRMED ################################## |
294 |
################## DELETE_CONFIRMED ################################## |
274 |
# called by delete_confirm, used to effectively confirm deletion of data in DB |
295 |
# called by delete_confirm, used to effectively confirm deletion of data in DB |
275 |
} elsif ($op eq 'delete_confirmed') { |
296 |
} |
276 |
$template->param(delete_confirmed => 1); |
297 |
elsif ( $op eq 'delete_confirmed' ) { |
277 |
my $dbh = C4::Context->dbh; |
298 |
$template->param( delete_confirmed => 1 ); |
278 |
my $categorycode=uc($input->param('categorycode')); |
299 |
my $dbh = C4::Context->dbh; |
279 |
my $sth=$dbh->prepare("delete from categories where categorycode=?"); |
300 |
|
280 |
$sth->execute($categorycode); |
301 |
my $categorycode = uc( $input->param('categorycode') ); |
281 |
$sth->finish; |
302 |
|
282 |
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=categorie.pl\"></html>"; |
303 |
my $sth = $dbh->prepare("delete from categories where categorycode=?"); |
283 |
exit; |
304 |
|
284 |
|
305 |
$sth->execute($categorycode); |
285 |
# END $OP eq DELETE_CONFIRMED |
306 |
$sth->finish; |
286 |
} else { # DEFAULT |
307 |
|
287 |
$template->param(else => 1); |
308 |
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=categorie.pl\"></html>"; |
288 |
my @loop; |
309 |
exit; |
289 |
my ($count,$results)=StringSearch($searchfield,'web'); |
310 |
|
|
|
311 |
# END $OP eq DELETE_CONFIRMED |
312 |
} |
313 |
else { # DEFAULT |
314 |
$template->param( else => 1 ); |
315 |
my @loop; |
316 |
my ( $count, $results ) = StringSearch( $searchfield, 'web' ); |
317 |
|
290 |
my $dbh = C4::Context->dbh; |
318 |
my $dbh = C4::Context->dbh; |
291 |
my $sth = $dbh->prepare("SELECT b.branchcode, b.branchname FROM categories_branches AS cb, branches AS b WHERE cb.branchcode = b.branchcode AND cb.categorycode = ?"); |
319 |
my $sth = $dbh->prepare(" |
292 |
for (my $i=0; $i < $count; $i++){ |
320 |
SELECT b.branchcode, b.branchname |
|
|
321 |
FROM categories_branches AS cb, branches AS b |
322 |
WHERE cb.branchcode = b.branchcode AND cb.categorycode = ? |
323 |
"); |
324 |
|
325 |
for ( my $i = 0 ; $i < $count ; $i++ ) { |
293 |
$sth->execute( $results->[$i]{'categorycode'} ); |
326 |
$sth->execute( $results->[$i]{'categorycode'} ); |
|
|
327 |
|
294 |
my @selected_branches; |
328 |
my @selected_branches; |
295 |
while ( my $branch = $sth->fetchrow_hashref ) { |
329 |
while ( my $branch = $sth->fetchrow_hashref ) { |
296 |
push @selected_branches, $branch; |
330 |
push @selected_branches, $branch; |
297 |
} |
331 |
} |
|
|
332 |
|
298 |
my $enrolmentperioddate = $results->[$i]{'enrolmentperioddate'}; |
333 |
my $enrolmentperioddate = $results->[$i]{'enrolmentperioddate'}; |
299 |
if ($enrolmentperioddate && $enrolmentperioddate eq '0000-00-00') { |
334 |
if ( $enrolmentperioddate && $enrolmentperioddate eq '0000-00-00' ) { |
300 |
$enrolmentperioddate = undef; |
335 |
$enrolmentperioddate = undef; |
301 |
} |
336 |
} |
302 |
$results->[$i]{'category_type'} //= ''; |
337 |
|
303 |
my %row = ( |
338 |
$results->[$i]{'category_type'} //= ''; |
304 |
categorycode => $results->[$i]{'categorycode'}, |
339 |
|
305 |
description => $results->[$i]{'description'}, |
340 |
my %row = ( |
306 |
enrolmentperiod => $results->[$i]{'enrolmentperiod'}, |
341 |
branches => \@selected_branches, |
307 |
enrolmentperioddate => $enrolmentperioddate, |
342 |
categorycode => $results->[$i]{'categorycode'}, |
308 |
upperagelimit => $results->[$i]{'upperagelimit'}, |
343 |
description => $results->[$i]{'description'}, |
309 |
dateofbirthrequired => $results->[$i]{'dateofbirthrequired'}, |
344 |
enrolmentperiod => $results->[$i]{'enrolmentperiod'}, |
310 |
enrolmentfee => sprintf("%.2f",$results->[$i]{'enrolmentfee'} || 0), |
345 |
enrolmentperioddate => $enrolmentperioddate, |
311 |
overduenoticerequired => $results->[$i]{'overduenoticerequired'}, |
346 |
upperagelimit => $results->[$i]{'upperagelimit'}, |
312 |
issuelimit => $results->[$i]{'issuelimit'}, |
347 |
dateofbirthrequired => $results->[$i]{'dateofbirthrequired'}, |
313 |
reservefee => sprintf("%.2f",$results->[$i]{'reservefee'} || 0), |
348 |
overduenoticerequired => $results->[$i]{'overduenoticerequired'}, |
314 |
hidelostitems => $results->[$i]{'hidelostitems'}, |
349 |
issuelimit => $results->[$i]{'issuelimit'}, |
315 |
category_type => $results->[$i]{'category_type'}, |
350 |
hidelostitems => $results->[$i]{'hidelostitems'}, |
|
|
351 |
category_type => $results->[$i]{'category_type'}, |
316 |
default_privacy => $results->[$i]{'default_privacy'}, |
352 |
default_privacy => $results->[$i]{'default_privacy'}, |
317 |
"type_".$results->[$i]{'category_type'} => 1, |
353 |
reservefee => sprintf( "%.2f", $results->[$i]{'reservefee'} || 0 ), |
318 |
branches => \@selected_branches, |
354 |
enrolmentfee => |
|
|
355 |
sprintf( "%.2f", $results->[$i]{'enrolmentfee'} || 0 ), |
356 |
"type_" . $results->[$i]{'category_type'} => 1, |
319 |
); |
357 |
); |
320 |
if (C4::Context->preference('EnhancedMessagingPreferences')) { |
358 |
|
321 |
my $brief_prefs = _get_brief_messaging_prefs($results->[$i]{'categorycode'}); |
359 |
if ( C4::Context->preference('EnhancedMessagingPreferences') ) { |
|
|
360 |
my $brief_prefs = |
361 |
_get_brief_messaging_prefs( $results->[$i]{'categorycode'} ); |
322 |
$row{messaging_prefs} = $brief_prefs if @$brief_prefs; |
362 |
$row{messaging_prefs} = $brief_prefs if @$brief_prefs; |
323 |
} |
363 |
} |
324 |
push @loop, \%row; |
364 |
push @loop, \%row; |
325 |
} |
365 |
} |
326 |
$template->param(loop => \@loop); |
366 |
|
327 |
# check that I (institution) and C (child) exists. otherwise => warning to the user |
367 |
$template->param( loop => \@loop ); |
328 |
$sth=$dbh->prepare("select category_type from categories where category_type='C'"); |
368 |
|
329 |
$sth->execute; |
369 |
# check that I (institution) and C (child) exists. otherwise => warning to the user |
330 |
my ($categoryChild) = $sth->fetchrow; |
370 |
$sth = $dbh->prepare("select category_type from categories where category_type='C'"); |
331 |
$template->param(categoryChild => $categoryChild); |
371 |
$sth->execute; |
332 |
$sth=$dbh->prepare("select category_type from categories where category_type='I'"); |
372 |
my ($categoryChild) = $sth->fetchrow; |
333 |
$sth->execute; |
373 |
$template->param( categoryChild => $categoryChild ); |
334 |
my ($categoryInstitution) = $sth->fetchrow; |
374 |
|
335 |
$template->param(categoryInstitution => $categoryInstitution); |
375 |
$sth = $dbh->prepare("select category_type from categories where category_type='I'"); |
336 |
$sth->finish; |
376 |
$sth->execute; |
337 |
|
377 |
my ($categoryInstitution) = $sth->fetchrow; |
338 |
|
378 |
$template->param( categoryInstitution => $categoryInstitution ); |
339 |
} #---- END $OP eq DEFAULT |
379 |
$sth->finish; |
|
|
380 |
|
381 |
} #---- END $OP eq DEFAULT |
340 |
output_html_with_http_headers $input, $cookie, $template->output; |
382 |
output_html_with_http_headers $input, $cookie, $template->output; |
341 |
|
383 |
|
342 |
exit 0; |
384 |
exit 0; |
343 |
|
385 |
|
344 |
sub _get_brief_messaging_prefs { |
386 |
sub _get_brief_messaging_prefs { |
345 |
my $categorycode = shift; |
387 |
my $categorycode = shift; |
346 |
my $messaging_options = C4::Members::Messaging::GetMessagingOptions(); |
388 |
my $messaging_options = C4::Members::Messaging::GetMessagingOptions(); |
347 |
my $results = []; |
389 |
my $results = []; |
348 |
PREF: foreach my $option ( @$messaging_options ) { |
390 |
PREF: foreach my $option (@$messaging_options) { |
349 |
my $pref = C4::Members::Messaging::GetMessagingPreferences( { categorycode => $categorycode, |
391 |
my $pref = C4::Members::Messaging::GetMessagingPreferences( |
350 |
message_name => $option->{'message_name'} } ); |
392 |
{ |
351 |
next unless $pref->{'transports'}; |
393 |
categorycode => $categorycode, |
|
|
394 |
message_name => $option->{'message_name'} |
395 |
} |
396 |
); |
397 |
next unless $pref->{'transports'}; |
352 |
my $brief_pref = { |
398 |
my $brief_pref = { |
353 |
message_attribute_id => $option->{'message_attribute_id'}, |
399 |
message_attribute_id => $option->{'message_attribute_id'}, |
354 |
message_name => $option->{'message_name'}, |
400 |
message_name => $option->{'message_name'}, |
355 |
$option->{'message_name'} => 1 |
401 |
$option->{'message_name'} => 1 |
356 |
}; |
402 |
}; |
357 |
foreach my $transport ( keys %{$pref->{'transports'}} ) { |
403 |
foreach my $transport ( keys %{ $pref->{'transports'} } ) { |
358 |
push @{ $brief_pref->{'transports'} }, { transport => $transport }; |
404 |
push @{ $brief_pref->{'transports'} }, { transport => $transport }; |
359 |
} |
405 |
} |
360 |
push @$results, $brief_pref; |
406 |
push @$results, $brief_pref; |