Lines 17-39
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
# standard or CPAN modules used |
|
|
21 |
use CGI qw ( -utf8 ); |
20 |
use CGI qw ( -utf8 ); |
22 |
use CGI::Cookie; |
|
|
23 |
use MARC::File::USMARC; |
24 |
use Try::Tiny; |
21 |
use Try::Tiny; |
25 |
|
22 |
|
26 |
# Koha modules used |
|
|
27 |
use C4::Context; |
23 |
use C4::Context; |
28 |
use C4::Koha; |
|
|
29 |
use C4::Auth; |
24 |
use C4::Auth; |
30 |
use C4::AuthoritiesMarc; |
|
|
31 |
use C4::Output; |
25 |
use C4::Output; |
32 |
use C4::Biblio; |
|
|
33 |
use C4::ImportBatch; |
26 |
use C4::ImportBatch; |
34 |
use C4::Matcher; |
|
|
35 |
use C4::BackgroundJob; |
36 |
use C4::Labels::Batch; |
37 |
use Koha::MarcOverlayRules; |
27 |
use Koha::MarcOverlayRules; |
38 |
use Koha::Patron::Categories; |
28 |
use Koha::Patron::Categories; |
39 |
|
29 |
|
Lines 71-84
my ($template, $loggedinuser, $cookie) = get_template_and_user(
Link Here
|
71 |
} |
61 |
} |
72 |
); |
62 |
); |
73 |
|
63 |
|
74 |
my %cookies = parse CGI::Cookie($cookie); |
64 |
# TODO: order? |
75 |
our $sessionID = $cookies{'CGISESSID'}->value; |
65 |
my $rules = Koha::MarcOverlayRules->search->unblessed; |
76 |
|
|
|
77 |
my $get_rules = sub { |
78 |
# TODO: order? |
79 |
return [map { { $_->get_columns() } } Koha::MarcOverlayRules->_resultset->all]; |
80 |
}; |
81 |
my $rules; |
82 |
|
66 |
|
83 |
if ($op eq 'remove' || $op eq 'doremove') { |
67 |
if ($op eq 'remove' || $op eq 'doremove') { |
84 |
my @remove_ids = $input->multi_param('batchremove'); |
68 |
my @remove_ids = $input->multi_param('batchremove'); |
Lines 86-92
if ($op eq 'remove' || $op eq 'doremove') {
Link Here
|
86 |
if ($op eq 'remove') { |
70 |
if ($op eq 'remove') { |
87 |
$template->{VARS}->{removeConfirm} = 1; |
71 |
$template->{VARS}->{removeConfirm} = 1; |
88 |
my %remove_ids = map { $_ => undef } @remove_ids; |
72 |
my %remove_ids = map { $_ => undef } @remove_ids; |
89 |
$rules = $get_rules->(); |
|
|
90 |
for my $rule (@{$rules}) { |
73 |
for my $rule (@{$rules}) { |
91 |
$rule->{'removemarked'} = 1 if exists $remove_ids{$rule->{id}}; |
74 |
$rule->{'removemarked'} = 1 if exists $remove_ids{$rule->{id}}; |
92 |
} |
75 |
} |
Lines 95-107
if ($op eq 'remove' || $op eq 'doremove') {
Link Here
|
95 |
my @remove_ids = $input->multi_param('batchremove'); |
78 |
my @remove_ids = $input->multi_param('batchremove'); |
96 |
push @remove_ids, scalar $input->param('id') if $input->param('id'); |
79 |
push @remove_ids, scalar $input->param('id') if $input->param('id'); |
97 |
Koha::MarcOverlayRules->search({ id => { in => \@remove_ids } })->delete(); |
80 |
Koha::MarcOverlayRules->search({ id => { in => \@remove_ids } })->delete(); |
98 |
$rules = $get_rules->(); |
|
|
99 |
} |
81 |
} |
100 |
} |
82 |
} |
101 |
elsif ($op eq 'edit') { |
83 |
elsif ($op eq 'edit') { |
102 |
$template->{VARS}->{edit} = 1; |
84 |
$template->param( edit => 1 ); |
103 |
my $id = $input->param('id'); |
85 |
my $id = $input->param('id'); |
104 |
$rules = $get_rules->(); |
|
|
105 |
for my $rule(@{$rules}) { |
86 |
for my $rule(@{$rules}) { |
106 |
if ($rule->{id} == $id) { |
87 |
if ($rule->{id} == $id) { |
107 |
$rule->{'edit'} = 1; |
88 |
$rule->{'edit'} = 1; |
Lines 142-155
elsif ($op eq 'doedit' || $op eq 'add') {
Link Here
|
142 |
$rule->set($rule_data); |
123 |
$rule->set($rule_data); |
143 |
$rule->store(); |
124 |
$rule->store(); |
144 |
} |
125 |
} |
145 |
$rules = $get_rules->(); |
|
|
146 |
} |
126 |
} |
147 |
} |
127 |
} |
148 |
else { |
|
|
149 |
$rules = $get_rules->(); |
150 |
} |
151 |
|
128 |
|
152 |
my $categorycodes = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']}); |
129 |
my $categorycodes = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']}); |
153 |
$template->param( rules => $rules, categorycodes => $categorycodes, messages => $errors ); |
130 |
$template->param( |
|
|
131 |
rules => $rules, |
132 |
categorycodes => $categorycodes, |
133 |
messages => $errors |
134 |
); |
154 |
|
135 |
|
155 |
output_html_with_http_headers $input, $cookie, $template->output; |
136 |
output_html_with_http_headers $input, $cookie, $template->output; |
156 |
- |
|
|