#
# This file is part of Koha.
#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
#
-use strict;
-#use warnings; FIXME - Bug 2505
-use CGI;
+use Modern::Perl;
+use CGI qw ( -utf8 );
use C4::Auth;
use C4::Context;
use C4::Output;
my $op = $input->param('op') || '';
my $source_code = $input->param('class_source');
my $rule_code = $input->param('sort_rule');
-
+my $sort_routine = $input->param('sort_routine');
my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "admin/classsources.tmpl",
+ = get_template_and_user({template_name => "admin/classsources.tt",
query => $input,
type => "intranet",
authnotrequired => 0,
$template->param(script_name => $script_name);
$template->param($op => 1) if $op;
-
+my $description = $input->param('description');
+my $used = $input->param('used');
my $display_lists = 0;
if ($op eq "add_source") {
add_class_source_form($template);
} elsif ($op eq "add_source_confirmed") {
add_class_source($template,
$source_code,
- $input->param('description'),
- $input->param('used') eq "used" ? 1 : 0,
+ $description,
+ $used eq "used" ? 1 : 0,
$rule_code);
$display_lists = 1;
} elsif ($op eq "delete_source") {
- delete_class_source_form($template);
+ delete_class_source_form($template, $source_code);
} elsif ($op eq "delete_source_confirmed") {
delete_class_source($template, $source_code);
$display_lists = 1;
} elsif ($op eq "edit_source_confirmed") {
edit_class_source($template,
$source_code,
- $input->param('description'),
- $input->param('used') eq "used" ? 1 : 0,
+ $description,
+ $used eq "used" ? 1 : 0,
$rule_code);
$display_lists = 1;
} elsif ($op eq "add_sort_rule") {
} elsif ($op eq "add_sort_rule_confirmed") {
add_class_sort_rule($template,
$rule_code,
- $input->param('description'),
- $input->param('sort_routine'));
+ $description,
+ $sort_routine);
$display_lists = 1;
} elsif ($op eq "delete_sort_rule") {
delete_sort_rule_form($template, $rule_code);
} elsif ($op eq "edit_sort_rule_confirmed") {
edit_class_sort_rule($template,
$rule_code,
- $input->param('description'),
- $input->param('sort_routine'));
+ $description,
+ $sort_routine);
$display_lists = 1;
} else {
$display_lists = 1;
sub add_class_source {
my ($template, $source_code, $description, $used, $sort_rule) = @_;
- AddClassSource($source_code, $description, $used, $sort_rule);
- $template->param(added_source => $source_code);
+ my $success = AddClassSource($source_code, $description, $used, $sort_rule);
+ if ($success > 0) {
+ $template->param(added_source => $source_code);
+ } else {
+ $template->param(failed_add_source => $source_code);
+ }
}
sub edit_class_source_form {
sub delete_class_source_form {
- my ($template) = @_;
+ my ($template, $source_code) = @_;
$template->param(
delete_class_source_form => 1,
confirm_op => "delete_source_confirmed",
sub add_class_sort_rule {
my ($template, $rule_code, $description, $sort_routine) = @_;
- AddClassSortRule($rule_code, $description, $sort_routine);
- $template->param(added_rule => $rule_code);
+ my $success = AddClassSortRule($rule_code, $description, $sort_routine);
+ if ($success > 0) {
+ $template->param(added_rule => $rule_code);
+ } else {
+ $template->param(failed_add_rule => $rule_code);
+ }
}
sub delete_sort_rule_form {