Lines 36-46
Link Here
|
36 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
36 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
37 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
37 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
38 |
|
38 |
|
39 |
use strict; |
39 |
use Modern::Perl; |
40 |
#use warnings; FIXME - Bug 2505 |
40 |
|
41 |
use CGI; |
41 |
use CGI; |
42 |
use C4::Context; |
42 |
use C4::Context; |
43 |
use C4::Auth; |
43 |
use C4::Auth; |
|
|
44 |
use C4::Branch; |
44 |
use C4::Output; |
45 |
use C4::Output; |
45 |
use C4::Dates; |
46 |
use C4::Dates; |
46 |
use C4::Form::MessagingPreferences; |
47 |
use C4::Form::MessagingPreferences; |
Lines 90-105
if ($op eq 'add_form') {
Link Here
|
90 |
|
91 |
|
91 |
#---- if primkey exists, it's a modify action, so read values to modify... |
92 |
#---- if primkey exists, it's a modify action, so read values to modify... |
92 |
my $data; |
93 |
my $data; |
|
|
94 |
my @selected_branches; |
93 |
if ($categorycode) { |
95 |
if ($categorycode) { |
94 |
my $dbh = C4::Context->dbh; |
96 |
my $dbh = C4::Context->dbh; |
95 |
my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?"); |
97 |
my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?"); |
96 |
$sth->execute($categorycode); |
98 |
$sth->execute($categorycode); |
97 |
$data=$sth->fetchrow_hashref; |
99 |
$data=$sth->fetchrow_hashref; |
98 |
$sth->finish; |
100 |
|
99 |
} |
101 |
$sth = $dbh->prepare("SELECT b.branchcode, b.branchname FROM categories_branches AS cb, branches AS b WHERE cb.branchcode = b.branchcode AND cb.categorycode = ?"); |
|
|
102 |
$sth->execute( $categorycode ); |
103 |
while ( my $branch = $sth->fetchrow_hashref ) { |
104 |
push @selected_branches, $branch; |
105 |
} |
106 |
$sth->finish; |
107 |
} |
100 |
|
108 |
|
101 |
$data->{'enrolmentperioddate'} = undef if ($data->{'enrolmentperioddate'} eq '0000-00-00'); |
109 |
$data->{'enrolmentperioddate'} = undef if ($data->{'enrolmentperioddate'} eq '0000-00-00'); |
102 |
|
110 |
|
|
|
111 |
my $branches = GetBranches; |
112 |
my @branches_loop; |
113 |
foreach my $branch (sort keys %$branches) { |
114 |
my $selected = ( grep {$$_{branchcode} eq $branch} @selected_branches ) ? 1 : 0; |
115 |
push @branches_loop, { |
116 |
branchcode => $$branches{$branch}{branchcode}, |
117 |
branchname => $$branches{$branch}{branchname}, |
118 |
selected => $selected, |
119 |
}; |
120 |
} |
121 |
|
103 |
$template->param(description => $data->{'description'}, |
122 |
$template->param(description => $data->{'description'}, |
104 |
enrolmentperiod => $data->{'enrolmentperiod'}, |
123 |
enrolmentperiod => $data->{'enrolmentperiod'}, |
105 |
enrolmentperioddate => C4::Dates::format_date($data->{'enrolmentperioddate'}), |
124 |
enrolmentperioddate => C4::Dates::format_date($data->{'enrolmentperioddate'}), |
Lines 113-119
if ($op eq 'add_form') {
Link Here
|
113 |
category_type => $data->{'category_type'}, |
132 |
category_type => $data->{'category_type'}, |
114 |
DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), |
133 |
DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), |
115 |
"type_".$data->{'category_type'} => 1, |
134 |
"type_".$data->{'category_type'} => 1, |
116 |
SMSSendDriver => C4::Context->preference("SMSSendDriver") |
135 |
SMSSendDriver => C4::Context->preference("SMSSendDriver"), |
|
|
136 |
branches_loop => \@branches_loop, |
117 |
); |
137 |
); |
118 |
if (C4::Context->preference('EnhancedMessagingPreferences')) { |
138 |
if (C4::Context->preference('EnhancedMessagingPreferences')) { |
119 |
C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template); |
139 |
C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template); |
Lines 132-137
if ($op eq 'add_form') {
Link Here
|
132 |
if ($is_a_modif) { |
152 |
if ($is_a_modif) { |
133 |
my $sth=$dbh->prepare("UPDATE categories SET description=?,enrolmentperiod=?, enrolmentperioddate=?,upperagelimit=?,dateofbirthrequired=?,enrolmentfee=?,reservefee=?,hidelostitems=?,overduenoticerequired=?,category_type=? WHERE categorycode=?"); |
153 |
my $sth=$dbh->prepare("UPDATE categories SET description=?,enrolmentperiod=?, enrolmentperioddate=?,upperagelimit=?,dateofbirthrequired=?,enrolmentfee=?,reservefee=?,hidelostitems=?,overduenoticerequired=?,category_type=? WHERE categorycode=?"); |
134 |
$sth->execute(map { $input->param($_) } ('description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','categorycode')); |
154 |
$sth->execute(map { $input->param($_) } ('description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','categorycode')); |
|
|
155 |
my @branches = $input->param("branches"); |
156 |
if ( @branches ) { |
157 |
$sth = $dbh->prepare("DELETE FROM categories_branches WHERE categorycode = ?"); |
158 |
$sth->execute( $input->param( "categorycode" ) ); |
159 |
$sth = $dbh->prepare( |
160 |
"INSERT INTO categories_branches |
161 |
( categorycode, branchcode ) |
162 |
VALUES ( ?, ? )" |
163 |
); |
164 |
for my $branchcode ( @branches ) { |
165 |
next if not $branchcode; |
166 |
$sth->bind_param( 1, $input->param( "categorycode" ) ); |
167 |
$sth->bind_param( 2, $branchcode ); |
168 |
$sth->execute; |
169 |
} |
170 |
} |
135 |
$sth->finish; |
171 |
$sth->finish; |
136 |
} else { |
172 |
} else { |
137 |
my $sth=$dbh->prepare("INSERT INTO categories (categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,hidelostitems,overduenoticerequired,category_type) values (?,?,?,?,?,?,?,?,?,?,?)"); |
173 |
my $sth=$dbh->prepare("INSERT INTO categories (categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,hidelostitems,overduenoticerequired,category_type) values (?,?,?,?,?,?,?,?,?,?,?)"); |