Lines 6-40
Link Here
|
6 |
# ALGO : |
6 |
# ALGO : |
7 |
# this script use an $op to know what to do. |
7 |
# this script use an $op to know what to do. |
8 |
# if $op is empty or none of the above values, |
8 |
# if $op is empty or none of the above values, |
9 |
# - the default screen is build (with all records, or filtered datas). |
9 |
# - the default screen is built |
10 |
# - the user can clic on add, modify or delete record. |
10 |
# (with all records, or filtered datas). |
|
|
11 |
# - the user can click on add, modify or delete record. |
11 |
# if $op=add_form |
12 |
# if $op=add_form |
12 |
# - if primkey exists, this is a modification,so we read the $primkey record |
13 |
# - if primkey exists, this is a modification, so we read |
13 |
# - builds the add/modify form |
14 |
# the $primkey record |
|
|
15 |
# - builds the add/modify form |
14 |
# if $op=add_validate |
16 |
# if $op=add_validate |
15 |
# - the user has just send datas, so we create/modify the record |
17 |
# - the user has just send datas, so we create or modify |
|
|
18 |
# the record |
16 |
# if $op=delete_form |
19 |
# if $op=delete_form |
17 |
# - we show the record having primkey=$primkey and ask for deletion validation form |
20 |
# - we show the record having primkey=$primkey and ask for |
|
|
21 |
# deletion validation form |
18 |
# if $op=delete_confirm |
22 |
# if $op=delete_confirm |
19 |
# - we delete the record having primkey=$primkey |
23 |
# - we delete the record having primkey=$primkey |
20 |
|
24 |
|
21 |
|
|
|
22 |
# Copyright 2000-2002 Katipo Communications |
23 |
# |
24 |
# This file is part of Koha. |
25 |
# This file is part of Koha. |
25 |
# |
26 |
# |
26 |
# Koha is free software; you can redistribute it and/or modify it under the |
27 |
# Copyright 2000-2002 Katipo Communications |
27 |
# terms of the GNU General Public License as published by the Free Software |
28 |
# Copyright (C) 2014 Mark Tompsett |
28 |
# Foundation; either version 2 of the License, or (at your option) any later |
29 |
# |
29 |
# version. |
30 |
# Koha is free software; you can redistribute it and/or modify it |
|
|
31 |
# under the terms of the GNU General Public License as published by |
32 |
# the Free Software Foundation; either version 3 of the License, or |
33 |
# (at your option) any later version. |
30 |
# |
34 |
# |
31 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
35 |
# Koha is distributed in the hope that it will be useful, but |
32 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
36 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
33 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
37 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
38 |
# GNU General Public License for more details. |
34 |
# |
39 |
# |
35 |
# You should have received a copy of the GNU General Public License along |
40 |
# You should have received a copy of the GNU General Public License |
36 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
41 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
37 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
|
38 |
|
42 |
|
39 |
use Modern::Perl; |
43 |
use Modern::Perl; |
40 |
|
44 |
|
Lines 46-307
use C4::Output;
Link Here
|
46 |
use C4::Dates; |
50 |
use C4::Dates; |
47 |
use C4::Form::MessagingPreferences; |
51 |
use C4::Form::MessagingPreferences; |
48 |
|
52 |
|
49 |
sub StringSearch { |
53 |
sub StringSearch { |
50 |
my ($searchstring,$type)=@_; |
54 |
my ( $searchstring, $type ) = @_; |
51 |
my $dbh = C4::Context->dbh; |
55 |
my $dbh = C4::Context->dbh; |
52 |
$searchstring //= ''; |
56 |
$searchstring //= ''; |
53 |
$searchstring=~ s/\'/\\\'/g; |
57 |
$searchstring =~ s/\'/\\\'/g; |
54 |
my @data=split(' ',$searchstring); |
58 |
my @data = split( ' ', $searchstring ); |
55 |
push @data,q{} if $#data==-1; |
59 |
push @data, q{} if $#data == -1; |
56 |
my $count=@data; |
60 |
my $count = @data; |
57 |
my $sth=$dbh->prepare("Select * from categories where (description like ?) order by category_type,description,categorycode"); |
61 |
my $sth = $dbh->prepare("Select * from categories where (description like ?) order by category_type,description,categorycode"); |
58 |
$sth->execute("$data[0]%"); |
62 |
$sth->execute("$data[0]%"); |
59 |
my @results; |
63 |
my @results; |
60 |
while (my $data=$sth->fetchrow_hashref){ |
64 |
while ( my $data = $sth->fetchrow_hashref ) { |
61 |
push(@results,$data); |
65 |
push( @results, $data ); |
62 |
} |
66 |
} |
63 |
# $sth->execute; |
67 |
# $sth->execute; |
64 |
$sth->finish; |
68 |
$sth->finish; |
65 |
return (scalar(@results),\@results); |
69 |
return ( scalar(@results), \@results ); |
66 |
} |
70 |
} |
67 |
|
71 |
|
68 |
my $input = new CGI; |
72 |
my $input = new CGI; |
69 |
my $searchfield=$input->param('description'); |
73 |
my $searchfield = $input->param('description'); |
70 |
my $script_name="/cgi-bin/koha/admin/categorie.pl"; |
74 |
my $script_name = "/cgi-bin/koha/admin/categorie.pl"; |
71 |
my $categorycode=$input->param('categorycode'); |
75 |
my $categorycode = $input->param('categorycode'); |
72 |
my $op = $input->param('op') // ''; |
76 |
my $op = $input->param('op') // ''; |
73 |
|
|
|
74 |
my ($template, $loggedinuser, $cookie) |
75 |
= get_template_and_user({template_name => "admin/categorie.tmpl", |
76 |
query => $input, |
77 |
type => "intranet", |
78 |
authnotrequired => 0, |
79 |
flagsrequired => {parameters => 'parameters_remaining_permissions'}, |
80 |
debug => 1, |
81 |
}); |
82 |
|
77 |
|
|
|
78 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
79 |
{ |
80 |
template_name => "admin/categorie.tmpl", |
81 |
query => $input, |
82 |
type => "intranet", |
83 |
authnotrequired => 0, |
84 |
flagsrequired => { parameters => 'parameters_remaining_permissions' }, |
85 |
debug => 1, |
86 |
} |
87 |
); |
83 |
|
88 |
|
84 |
$template->param(script_name => $script_name, |
89 |
$template->param( |
85 |
categorycode => $categorycode, |
90 |
script_name => $script_name, |
86 |
searchfield => $searchfield); |
91 |
categorycode => $categorycode, |
87 |
|
92 |
searchfield => $searchfield |
|
|
93 |
); |
88 |
|
94 |
|
89 |
################## ADD_FORM ################################## |
95 |
################## ADD_FORM ################################## |
90 |
# called by default. Used to create form to add or modify a record |
96 |
# called by default. Used to create form to add or modify a record |
91 |
if ($op eq 'add_form') { |
97 |
if ( $op eq 'add_form' ) { |
92 |
$template->param(add_form => 1); |
98 |
$template->param( add_form => 1 ); |
93 |
|
99 |
|
94 |
#---- if primkey exists, it's a modify action, so read values to modify... |
100 |
#---- if primkey exists, it's a modify action, so read values to modify... |
95 |
my $data; |
101 |
my $data; |
96 |
my @selected_branches; |
102 |
my @selected_branches; |
97 |
if ($categorycode) { |
103 |
if ($categorycode) { |
98 |
my $dbh = C4::Context->dbh; |
104 |
my $dbh = C4::Context->dbh; |
99 |
my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?"); |
105 |
my $sth = $dbh->prepare( |
100 |
$sth->execute($categorycode); |
106 |
"select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?" |
101 |
$data=$sth->fetchrow_hashref; |
107 |
); |
|
|
108 |
$sth->execute($categorycode); |
109 |
$data = $sth->fetchrow_hashref; |
102 |
|
110 |
|
103 |
$sth = $dbh->prepare("SELECT b.branchcode, b.branchname FROM categories_branches AS cb, branches AS b WHERE cb.branchcode = b.branchcode AND cb.categorycode = ?"); |
111 |
$sth = $dbh->prepare( |
104 |
$sth->execute( $categorycode ); |
112 |
"SELECT b.branchcode, b.branchname FROM categories_branches AS cb, branches AS b WHERE cb.branchcode = b.branchcode AND cb.categorycode = ?" |
|
|
113 |
); |
114 |
$sth->execute($categorycode); |
105 |
while ( my $branch = $sth->fetchrow_hashref ) { |
115 |
while ( my $branch = $sth->fetchrow_hashref ) { |
106 |
push @selected_branches, $branch; |
116 |
push @selected_branches, $branch; |
107 |
} |
117 |
} |
108 |
$sth->finish; |
118 |
$sth->finish; |
109 |
} |
119 |
} |
110 |
|
120 |
|
111 |
$data->{'enrolmentperioddate'} = undef if ($data->{'enrolmentperioddate'} && $data->{'enrolmentperioddate'} eq '0000-00-00'); |
121 |
if ( $data->{'enrolmentperioddate'} && |
|
|
122 |
$data->{'enrolmentperioddate'} eq '0000-00-00' ) { |
123 |
$data->{'enrolmentperioddate'} = undef; |
124 |
} |
112 |
$data->{'category_type'} //= ''; |
125 |
$data->{'category_type'} //= ''; |
113 |
|
126 |
|
114 |
my $branches = GetBranches; |
127 |
my $branches = GetBranches; |
115 |
my @branches_loop; |
128 |
my @branches_loop; |
116 |
foreach my $branch (sort keys %$branches) { |
129 |
foreach my $branch ( sort keys %$branches ) { |
117 |
my $selected = ( grep {$$_{branchcode} eq $branch} @selected_branches ) ? 1 : 0; |
130 |
my $selected = |
118 |
push @branches_loop, { |
131 |
( grep { $$_{branchcode} eq $branch } @selected_branches ) ? 1 : 0; |
|
|
132 |
push @branches_loop, |
133 |
{ |
119 |
branchcode => $$branches{$branch}{branchcode}, |
134 |
branchcode => $$branches{$branch}{branchcode}, |
120 |
branchname => $$branches{$branch}{branchname}, |
135 |
branchname => $$branches{$branch}{branchname}, |
121 |
selected => $selected, |
136 |
selected => $selected, |
122 |
}; |
137 |
}; |
123 |
} |
138 |
} |
124 |
|
139 |
|
125 |
$template->param(description => $data->{'description'}, |
140 |
$template->param( |
126 |
enrolmentperiod => $data->{'enrolmentperiod'}, |
141 |
description => $data->{'description'}, |
127 |
enrolmentperioddate => $data->{'enrolmentperioddate'}, |
142 |
enrolmentperiod => $data->{'enrolmentperiod'}, |
128 |
upperagelimit => $data->{'upperagelimit'}, |
143 |
enrolmentperioddate => $data->{'enrolmentperioddate'}, |
129 |
dateofbirthrequired => $data->{'dateofbirthrequired'}, |
144 |
upperagelimit => $data->{'upperagelimit'}, |
130 |
enrolmentfee => sprintf("%.2f",$data->{'enrolmentfee'} || 0), |
145 |
dateofbirthrequired => $data->{'dateofbirthrequired'}, |
131 |
overduenoticerequired => $data->{'overduenoticerequired'}, |
146 |
enrolmentfee => sprintf( "%.2f", $data->{'enrolmentfee'} || 0 ), |
132 |
issuelimit => $data->{'issuelimit'}, |
147 |
overduenoticerequired => $data->{'overduenoticerequired'}, |
133 |
reservefee => sprintf("%.2f",$data->{'reservefee'} || 0), |
148 |
issuelimit => $data->{'issuelimit'}, |
134 |
hidelostitems => $data->{'hidelostitems'}, |
149 |
reservefee => sprintf( "%.2f", $data->{'reservefee'} || 0 ), |
135 |
category_type => $data->{'category_type'}, |
150 |
hidelostitems => $data->{'hidelostitems'}, |
136 |
SMSSendDriver => C4::Context->preference("SMSSendDriver"), |
151 |
category_type => $data->{'category_type'}, |
137 |
TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"), |
152 |
SMSSendDriver => C4::Context->preference("SMSSendDriver"), |
138 |
"type_".$data->{'category_type'} => 1, |
153 |
TalkingTechItivaPhone => |
139 |
branches_loop => \@branches_loop, |
154 |
C4::Context->preference("TalkingTechItivaPhoneNotification"), |
140 |
); |
155 |
"type_" . $data->{'category_type'} => 1, |
141 |
if (C4::Context->preference('EnhancedMessagingPreferences')) { |
156 |
branches_loop => \@branches_loop, |
142 |
C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template); |
157 |
); |
|
|
158 |
if ( C4::Context->preference('EnhancedMessagingPreferences') ) { |
159 |
C4::Form::MessagingPreferences::set_form_values( |
160 |
{ categorycode => $categorycode }, $template ); |
143 |
} |
161 |
} |
144 |
# END $OP eq ADD_FORM |
162 |
|
|
|
163 |
# END $OP eq ADD_FORM |
145 |
################## ADD_VALIDATE ################################## |
164 |
################## ADD_VALIDATE ################################## |
146 |
# called by add_form, used to insert/modify data in DB |
165 |
# called by add_form, used to insert/modify data in DB |
147 |
} elsif ($op eq 'add_validate') { |
166 |
} |
148 |
$template->param(add_validate => 1); |
167 |
elsif ( $op eq 'add_validate' ) { |
149 |
my $is_a_modif = $input->param("is_a_modif"); |
168 |
$template->param( add_validate => 1 ); |
150 |
my $dbh = C4::Context->dbh; |
169 |
my $is_a_modif = $input->param("is_a_modif"); |
151 |
if($input->param('enrolmentperioddate')){ |
170 |
my $dbh = C4::Context->dbh; |
152 |
$input->param('enrolmentperioddate' => C4::Dates::format_date_in_iso($input->param('enrolmentperioddate')) ); |
171 |
if ( $input->param('enrolmentperioddate') ) { |
153 |
} |
172 |
$input->param( |
154 |
|
173 |
'enrolmentperioddate' => C4::Dates::format_date_in_iso( |
155 |
if ($is_a_modif) { |
174 |
$input->param('enrolmentperioddate') |
156 |
my $sth=$dbh->prepare("UPDATE categories SET description=?,enrolmentperiod=?, enrolmentperioddate=?,upperagelimit=?,dateofbirthrequired=?,enrolmentfee=?,reservefee=?,hidelostitems=?,overduenoticerequired=?,category_type=? WHERE categorycode=?"); |
175 |
) |
157 |
$sth->execute(map { $input->param($_) } ('description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','categorycode')); |
176 |
); |
158 |
my @branches = $input->param("branches"); |
177 |
} |
159 |
if ( @branches ) { |
178 |
|
160 |
$sth = $dbh->prepare("DELETE FROM categories_branches WHERE categorycode = ?"); |
179 |
if ($is_a_modif) { |
161 |
$sth->execute( $input->param( "categorycode" ) ); |
180 |
my $sth = $dbh->prepare( |
162 |
$sth = $dbh->prepare( |
181 |
"UPDATE categories SET description=?,enrolmentperiod=?, enrolmentperioddate=?,upperagelimit=?,dateofbirthrequired=?,enrolmentfee=?,reservefee=?,hidelostitems=?,overduenoticerequired=?,category_type=? WHERE categorycode=?" |
163 |
"INSERT INTO categories_branches |
182 |
); |
|
|
183 |
$sth->execute( |
184 |
map { $input->param($_) } ( |
185 |
'description', 'enrolmentperiod', |
186 |
'enrolmentperioddate', 'upperagelimit', |
187 |
'dateofbirthrequired', 'enrolmentfee', |
188 |
'reservefee', 'hidelostitems', |
189 |
'overduenoticerequired', 'category_type', |
190 |
'categorycode' |
191 |
) |
192 |
); |
193 |
my @branches = $input->param("branches"); |
194 |
if (@branches) { |
195 |
$sth = $dbh->prepare( |
196 |
"DELETE FROM categories_branches WHERE categorycode = ?"); |
197 |
$sth->execute( $input->param("categorycode") ); |
198 |
$sth = $dbh->prepare( |
199 |
"INSERT INTO categories_branches |
164 |
( categorycode, branchcode ) |
200 |
( categorycode, branchcode ) |
165 |
VALUES ( ?, ? )" |
201 |
VALUES ( ?, ? )" |
166 |
); |
202 |
); |
167 |
for my $branchcode ( @branches ) { |
203 |
for my $branchcode (@branches) { |
168 |
next if not $branchcode; |
204 |
next if not $branchcode; |
169 |
$sth->bind_param( 1, $input->param( "categorycode" ) ); |
205 |
$sth->bind_param( 1, $input->param("categorycode") ); |
170 |
$sth->bind_param( 2, $branchcode ); |
206 |
$sth->bind_param( 2, $branchcode ); |
171 |
$sth->execute; |
207 |
$sth->execute; |
172 |
} |
|
|
173 |
} |
208 |
} |
174 |
$sth->finish; |
|
|
175 |
} else { |
176 |
my $sth=$dbh->prepare("INSERT INTO categories (categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,hidelostitems,overduenoticerequired,category_type) values (?,?,?,?,?,?,?,?,?,?,?)"); |
177 |
$sth->execute(map { $input->param($_) } ('categorycode','description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type')); |
178 |
$sth->finish; |
179 |
} |
209 |
} |
180 |
if (C4::Context->preference('EnhancedMessagingPreferences')) { |
210 |
$sth->finish; |
181 |
C4::Form::MessagingPreferences::handle_form_action($input, |
211 |
} |
182 |
{ categorycode => $input->param('categorycode') }, $template); |
212 |
else { |
|
|
213 |
my $sth = $dbh->prepare( |
214 |
"INSERT INTO categories (categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,hidelostitems,overduenoticerequired,category_type) values (?,?,?,?,?,?,?,?,?,?,?)" |
215 |
); |
216 |
$sth->execute( |
217 |
map { $input->param($_) } ( |
218 |
'categorycode', 'description', |
219 |
'enrolmentperiod', 'enrolmentperioddate', |
220 |
'upperagelimit', 'dateofbirthrequired', |
221 |
'enrolmentfee', 'reservefee', |
222 |
'hidelostitems', 'overduenoticerequired', |
223 |
'category_type' |
224 |
) |
225 |
); |
226 |
$sth->finish; |
227 |
} |
228 |
if ( C4::Context->preference('EnhancedMessagingPreferences') ) { |
229 |
C4::Form::MessagingPreferences::handle_form_action( $input, |
230 |
{ categorycode => $input->param('categorycode') }, $template ); |
183 |
} |
231 |
} |
184 |
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=categorie.pl\"></html>"; |
232 |
print |
185 |
exit; |
233 |
"Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=categorie.pl\"></html>"; |
|
|
234 |
exit; |
186 |
|
235 |
|
187 |
# END $OP eq ADD_VALIDATE |
236 |
# END $OP eq ADD_VALIDATE |
188 |
################## DELETE_CONFIRM ################################## |
237 |
################## DELETE_CONFIRM ################################## |
189 |
# called by default form, used to confirm deletion of data in DB |
238 |
# called by default form, used to confirm deletion of data in DB |
190 |
} elsif ($op eq 'delete_confirm') { |
239 |
} |
191 |
$template->param(delete_confirm => 1); |
240 |
elsif ( $op eq 'delete_confirm' ) { |
|
|
241 |
$template->param( delete_confirm => 1 ); |
192 |
|
242 |
|
193 |
my $dbh = C4::Context->dbh; |
243 |
my $dbh = C4::Context->dbh; |
194 |
my $sth=$dbh->prepare("select count(*) as total from borrowers where categorycode=?"); |
244 |
my $sth = $dbh->prepare( |
195 |
$sth->execute($categorycode); |
245 |
"select count(*) as total from borrowers where categorycode=?"); |
196 |
my $total = $sth->fetchrow_hashref; |
246 |
$sth->execute($categorycode); |
197 |
$sth->finish; |
247 |
my $total = $sth->fetchrow_hashref; |
198 |
$template->param(total => $total->{'total'}); |
248 |
$sth->finish; |
199 |
|
249 |
$template->param( total => $total->{'total'} ); |
200 |
my $sth2=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?"); |
|
|
201 |
$sth2->execute($categorycode); |
202 |
my $data=$sth2->fetchrow_hashref; |
203 |
$sth2->finish; |
204 |
if ($total->{'total'} >0) { |
205 |
$template->param(totalgtzero => 1); |
206 |
} |
207 |
|
250 |
|
208 |
$data->{'enrolmentperioddate'} = undef if ($data->{'enrolmentperioddate'} && $data->{'enrolmentperioddate'} eq '0000-00-00'); |
251 |
my $sth2 = $dbh->prepare( |
209 |
$template->param( description => $data->{'description'}, |
252 |
"select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?" |
210 |
enrolmentperiod => $data->{'enrolmentperiod'}, |
253 |
); |
211 |
enrolmentperioddate => $data->{'enrolmentperioddate'}, |
254 |
$sth2->execute($categorycode); |
212 |
upperagelimit => $data->{'upperagelimit'}, |
255 |
my $data = $sth2->fetchrow_hashref; |
213 |
dateofbirthrequired => $data->{'dateofbirthrequired'}, |
256 |
$sth2->finish; |
214 |
enrolmentfee => sprintf("%.2f",$data->{'enrolmentfee'}), |
257 |
if ( $total->{'total'} > 0 ) { |
215 |
overduenoticerequired => $data->{'overduenoticerequired'}, |
258 |
$template->param( totalgtzero => 1 ); |
216 |
issuelimit => $data->{'issuelimit'}, |
259 |
} |
217 |
reservefee => sprintf("%.2f",$data->{'reservefee'}), |
260 |
|
218 |
hidelostitems => $data->{'hidelostitems'}, |
261 |
if ( $data->{'enrolmentperioddate'} && |
219 |
category_type => $data->{'category_type'}, |
262 |
$data->{'enrolmentperioddate'} eq '0000-00-00' ) { |
220 |
); |
263 |
$data->{'enrolmentperioddate'} = undef; |
221 |
# END $OP eq DELETE_CONFIRM |
264 |
} |
|
|
265 |
$template->param( |
266 |
description => $data->{'description'}, |
267 |
enrolmentperiod => $data->{'enrolmentperiod'}, |
268 |
enrolmentperioddate => $data->{'enrolmentperioddate'}, |
269 |
upperagelimit => $data->{'upperagelimit'}, |
270 |
dateofbirthrequired => $data->{'dateofbirthrequired'}, |
271 |
enrolmentfee => sprintf( "%.2f", $data->{'enrolmentfee'} ), |
272 |
overduenoticerequired => $data->{'overduenoticerequired'}, |
273 |
issuelimit => $data->{'issuelimit'}, |
274 |
reservefee => sprintf( "%.2f", $data->{'reservefee'} ), |
275 |
hidelostitems => $data->{'hidelostitems'}, |
276 |
category_type => $data->{'category_type'}, |
277 |
); |
278 |
|
279 |
# END $OP eq DELETE_CONFIRM |
222 |
################## DELETE_CONFIRMED ################################## |
280 |
################## DELETE_CONFIRMED ################################## |
223 |
# called by delete_confirm, used to effectively confirm deletion of data in DB |
281 |
# called by delete_confirm, used to effectively confirm deletion |
224 |
} elsif ($op eq 'delete_confirmed') { |
282 |
# of data in DB |
225 |
$template->param(delete_confirmed => 1); |
283 |
} |
226 |
my $dbh = C4::Context->dbh; |
284 |
elsif ( $op eq 'delete_confirmed' ) { |
227 |
my $categorycode=uc($input->param('categorycode')); |
285 |
$template->param( delete_confirmed => 1 ); |
228 |
my $sth=$dbh->prepare("delete from categories where categorycode=?"); |
286 |
my $dbh = C4::Context->dbh; |
229 |
$sth->execute($categorycode); |
287 |
my $categorycode = uc( $input->param('categorycode') ); |
230 |
$sth->finish; |
288 |
my $sth = $dbh->prepare("delete from categories where categorycode=?"); |
231 |
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=categorie.pl\"></html>"; |
289 |
$sth->execute($categorycode); |
232 |
exit; |
290 |
$sth->finish; |
|
|
291 |
print |
292 |
"Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=categorie.pl\"></html>"; |
293 |
exit; |
233 |
|
294 |
|
234 |
# END $OP eq DELETE_CONFIRMED |
295 |
# END $OP eq DELETE_CONFIRMED |
235 |
} else { # DEFAULT |
296 |
} |
236 |
$template->param(else => 1); |
297 |
else { # DEFAULT |
237 |
my @loop; |
298 |
$template->param( else => 1 ); |
238 |
my ($count,$results)=StringSearch($searchfield,'web'); |
299 |
my @loop; |
|
|
300 |
my ( $count, $results ) = StringSearch( $searchfield, 'web' ); |
239 |
my $dbh = C4::Context->dbh; |
301 |
my $dbh = C4::Context->dbh; |
240 |
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 = ?"); |
302 |
my $sth = $dbh->prepare( |
241 |
for (my $i=0; $i < $count; $i++){ |
303 |
"SELECT b.branchcode, b.branchname FROM categories_branches AS cb, branches AS b WHERE cb.branchcode = b.branchcode AND cb.categorycode = ?" |
|
|
304 |
); |
305 |
for ( my $i = 0 ; $i < $count ; $i++ ) { |
242 |
$sth->execute( $results->[$i]{'categorycode'} ); |
306 |
$sth->execute( $results->[$i]{'categorycode'} ); |
243 |
my @selected_branches; |
307 |
my @selected_branches; |
244 |
while ( my $branch = $sth->fetchrow_hashref ) { |
308 |
while ( my $branch = $sth->fetchrow_hashref ) { |
245 |
push @selected_branches, $branch; |
309 |
push @selected_branches, $branch; |
246 |
} |
310 |
} |
247 |
my $enrolmentperioddate = $results->[$i]{'enrolmentperioddate'}; |
311 |
my $enrolmentperioddate = $results->[$i]{'enrolmentperioddate'}; |
248 |
if (defined($enrolmentperioddate) && $enrolmentperioddate eq '0000-00-00') { |
312 |
if ( $enrolmentperioddate && |
|
|
313 |
$enrolmentperioddate eq '0000-00-00' ) { |
249 |
$enrolmentperioddate = undef; |
314 |
$enrolmentperioddate = undef; |
250 |
} |
315 |
} |
251 |
my %row = ( |
316 |
$results->[$i]{'category_type'} //= ''; |
252 |
categorycode => $results->[$i]{'categorycode'}, |
317 |
my %row = ( |
253 |
description => $results->[$i]{'description'}, |
318 |
categorycode => $results->[$i]{'categorycode'}, |
254 |
enrolmentperiod => $results->[$i]{'enrolmentperiod'}, |
319 |
description => $results->[$i]{'description'}, |
255 |
enrolmentperioddate => $enrolmentperioddate, |
320 |
enrolmentperiod => $results->[$i]{'enrolmentperiod'}, |
256 |
upperagelimit => $results->[$i]{'upperagelimit'}, |
321 |
enrolmentperioddate => $enrolmentperioddate, |
257 |
dateofbirthrequired => $results->[$i]{'dateofbirthrequired'}, |
322 |
upperagelimit => $results->[$i]{'upperagelimit'}, |
258 |
enrolmentfee => sprintf("%.2f",$results->[$i]{'enrolmentfee'}), |
323 |
dateofbirthrequired => $results->[$i]{'dateofbirthrequired'}, |
259 |
overduenoticerequired => $results->[$i]{'overduenoticerequired'}, |
324 |
enrolmentfee => sprintf( "%.2f", $results->[$i]{'enrolmentfee'} || 0), |
260 |
issuelimit => $results->[$i]{'issuelimit'}, |
325 |
overduenoticerequired => $results->[$i]{'overduenoticerequired'}, |
261 |
reservefee => sprintf("%.2f",$results->[$i]{'reservefee'}), |
326 |
issuelimit => $results->[$i]{'issuelimit'}, |
262 |
hidelostitems => $results->[$i]{'hidelostitems'}, |
327 |
reservefee => sprintf( "%.2f", $results->[$i]{'reservefee'} || 0), |
263 |
category_type => $results->[$i]{'category_type'}, |
328 |
hidelostitems => $results->[$i]{'hidelostitems'}, |
264 |
"type_".$results->[$i]{'category_type'} => 1, |
329 |
category_type => $results->[$i]{'category_type'}, |
265 |
branches => \@selected_branches, |
330 |
"type_" . $results->[$i]{'category_type'} => 1, |
|
|
331 |
branches => \@selected_branches, |
266 |
); |
332 |
); |
267 |
if (C4::Context->preference('EnhancedMessagingPreferences')) { |
333 |
if ( C4::Context->preference('EnhancedMessagingPreferences') ) { |
268 |
my $brief_prefs = _get_brief_messaging_prefs($results->[$i]{'categorycode'}); |
334 |
my $brief_prefs = |
|
|
335 |
_get_brief_messaging_prefs( $results->[$i]{'categorycode'} ); |
269 |
$row{messaging_prefs} = $brief_prefs if @$brief_prefs; |
336 |
$row{messaging_prefs} = $brief_prefs if @$brief_prefs; |
270 |
} |
337 |
} |
271 |
push @loop, \%row; |
338 |
push @loop, \%row; |
272 |
} |
339 |
} |
273 |
$template->param(loop => \@loop); |
340 |
$template->param( loop => \@loop ); |
274 |
# check that I (institution) and C (child) exists. otherwise => warning to the user |
|
|
275 |
$sth=$dbh->prepare("select category_type from categories where category_type='C'"); |
276 |
$sth->execute; |
277 |
my ($categoryChild) = $sth->fetchrow; |
278 |
$template->param(categoryChild => $categoryChild); |
279 |
$sth=$dbh->prepare("select category_type from categories where category_type='I'"); |
280 |
$sth->execute; |
281 |
my ($categoryInstitution) = $sth->fetchrow; |
282 |
$template->param(categoryInstitution => $categoryInstitution); |
283 |
$sth->finish; |
284 |
|
341 |
|
|
|
342 |
# check that I (institution) and C (child) exists. otherwise => warning to the user |
343 |
$sth = $dbh->prepare( |
344 |
"select category_type from categories where category_type='C'"); |
345 |
$sth->execute; |
346 |
my ($categoryChild) = $sth->fetchrow; |
347 |
$template->param( categoryChild => $categoryChild ); |
348 |
$sth = $dbh->prepare( |
349 |
"select category_type from categories where category_type='I'"); |
350 |
$sth->execute; |
351 |
my ($categoryInstitution) = $sth->fetchrow; |
352 |
$template->param( categoryInstitution => $categoryInstitution ); |
353 |
$sth->finish; |
285 |
|
354 |
|
286 |
} #---- END $OP eq DEFAULT |
355 |
} #---- END $OP eq DEFAULT |
287 |
output_html_with_http_headers $input, $cookie, $template->output; |
356 |
output_html_with_http_headers $input, $cookie, $template->output; |
288 |
|
357 |
|
289 |
exit 0; |
358 |
exit 0; |
290 |
|
359 |
|
291 |
sub _get_brief_messaging_prefs { |
360 |
sub _get_brief_messaging_prefs { |
292 |
my $categorycode = shift; |
361 |
my $categorycode = shift; |
293 |
my $messaging_options = C4::Members::Messaging::GetMessagingOptions(); |
362 |
my $messaging_options = C4::Members::Messaging::GetMessagingOptions(); |
294 |
my $results = []; |
363 |
my $results = []; |
295 |
PREF: foreach my $option ( @$messaging_options ) { |
364 |
PREF: foreach my $option (@$messaging_options) { |
296 |
my $pref = C4::Members::Messaging::GetMessagingPreferences( { categorycode => $categorycode, |
365 |
my $pref = C4::Members::Messaging::GetMessagingPreferences( |
297 |
message_name => $option->{'message_name'} } ); |
366 |
{ |
298 |
next unless $pref->{'transports'}; |
367 |
categorycode => $categorycode, |
|
|
368 |
message_name => $option->{'message_name'} |
369 |
} |
370 |
); |
371 |
next unless $pref->{'transports'}; |
299 |
my $brief_pref = { |
372 |
my $brief_pref = { |
300 |
message_attribute_id => $option->{'message_attribute_id'}, |
373 |
message_attribute_id => $option->{'message_attribute_id'}, |
301 |
message_name => $option->{'message_name'}, |
374 |
message_name => $option->{'message_name'}, |
302 |
$option->{'message_name'} => 1 |
375 |
$option->{'message_name'} => 1 |
303 |
}; |
376 |
}; |
304 |
foreach my $transport ( keys %{$pref->{'transports'}} ) { |
377 |
foreach my $transport ( keys %{ $pref->{'transports'} } ) { |
305 |
push @{ $brief_pref->{'transports'} }, { transport => $transport }; |
378 |
push @{ $brief_pref->{'transports'} }, { transport => $transport }; |
306 |
} |
379 |
} |
307 |
push @$results, $brief_pref; |
380 |
push @$results, $brief_pref; |
308 |
- |
|
|