|
Lines 60-81
my $enqueue_job = sub {
Link Here
|
| 60 |
|
60 |
|
| 61 |
try { |
61 |
try { |
| 62 |
my $params = { |
62 |
my $params = { |
| 63 |
record_ids => $record_ids, |
63 |
record_ids => $record_ids, |
| 64 |
}; |
64 |
}; |
| 65 |
|
65 |
|
| 66 |
my $job_id = |
66 |
my $job_id = |
| 67 |
$recordtype eq 'biblio' |
67 |
$recordtype eq 'biblio' |
| 68 |
? Koha::BackgroundJob::BatchDeleteBiblio->new->enqueue($params) |
68 |
? Koha::BackgroundJob::BatchDeleteBiblio->new->enqueue($params) |
| 69 |
: Koha::BackgroundJob::BatchDeleteAuthority->new->enqueue($params); |
69 |
: Koha::BackgroundJob::BatchDeleteAuthority->new->enqueue($params); |
| 70 |
|
70 |
|
| 71 |
$template->param( |
71 |
$template->param( |
| 72 |
op => 'enqueued', |
72 |
op => 'enqueued', |
| 73 |
job_id => $job_id, |
73 |
job_id => $job_id, |
| 74 |
); |
74 |
); |
| 75 |
} catch { |
75 |
} catch { |
| 76 |
push @messages, { |
76 |
push @messages, { |
| 77 |
type => 'error', |
77 |
type => 'error', |
| 78 |
code => 'cannot_enqueue_job', |
78 |
code => 'cannot_enqueue_job', |
| 79 |
error => $_, |
79 |
error => $_, |
| 80 |
}; |
80 |
}; |
| 81 |
$template->param( view => 'errors' ); |
81 |
$template->param( view => 'errors' ); |
|
Lines 83-88
my $enqueue_job = sub {
Link Here
|
| 83 |
}; |
83 |
}; |
| 84 |
|
84 |
|
| 85 |
if ( $op eq 'form' ) { |
85 |
if ( $op eq 'form' ) { |
|
|
86 |
|
| 86 |
# Display the form |
87 |
# Display the form |
| 87 |
$template->param( |
88 |
$template->param( |
| 88 |
op => 'form', |
89 |
op => 'form', |
|
Lines 94-99
if ( $op eq 'form' ) {
Link Here
|
| 94 |
) |
95 |
) |
| 95 |
); |
96 |
); |
| 96 |
} elsif ( $op eq 'cud-list' || $op eq 'delete_all' ) { |
97 |
} elsif ( $op eq 'cud-list' || $op eq 'delete_all' ) { |
|
|
98 |
|
| 97 |
# List all records to process |
99 |
# List all records to process |
| 98 |
my @record_ids; |
100 |
my @record_ids; |
| 99 |
if ( my $bib_list = $input->param('bib_list') ) { |
101 |
if ( my $bib_list = $input->param('bib_list') ) { |
|
Lines 102-107
if ( $op eq 'form' ) {
Link Here
|
| 102 |
@record_ids = split /\//, $bib_list; |
104 |
@record_ids = split /\//, $bib_list; |
| 103 |
$recordtype = 'biblio'; |
105 |
$recordtype = 'biblio'; |
| 104 |
} elsif ( my $uploadfile = $input->param('uploadfile') ) { |
106 |
} elsif ( my $uploadfile = $input->param('uploadfile') ) { |
|
|
107 |
|
| 105 |
# A file of id is given |
108 |
# A file of id is given |
| 106 |
binmode $uploadfile, ':encoding(UTF-8)'; |
109 |
binmode $uploadfile, ':encoding(UTF-8)'; |
| 107 |
while ( my $content = <$uploadfile> ) { |
110 |
while ( my $content = <$uploadfile> ) { |
|
Lines 117-146
if ( $op eq 'form' ) {
Link Here
|
| 117 |
push @record_ids, $biblionumber; |
120 |
push @record_ids, $biblionumber; |
| 118 |
} |
121 |
} |
| 119 |
} else { |
122 |
} else { |
|
|
123 |
|
| 120 |
# The user enters manually the list of id |
124 |
# The user enters manually the list of id |
| 121 |
push @record_ids, split( /\s\n/, scalar $input->param('recordnumber_list') ); |
125 |
push @record_ids, split( /\s\n/, scalar $input->param('recordnumber_list') ); |
| 122 |
} |
126 |
} |
| 123 |
if ( $op eq 'delete_all' ) { |
127 |
if ( $op eq 'delete_all' ) { |
| 124 |
$enqueue_job->(\@record_ids, $recordtype); |
128 |
$enqueue_job->( \@record_ids, $recordtype ); |
| 125 |
} |
129 |
} else { |
| 126 |
else { |
|
|
| 127 |
for my $record_id ( uniq @record_ids ) { |
130 |
for my $record_id ( uniq @record_ids ) { |
| 128 |
if ( $recordtype eq 'biblio' ) { |
131 |
if ( $recordtype eq 'biblio' ) { |
|
|
132 |
|
| 129 |
# Retrieve biblio information |
133 |
# Retrieve biblio information |
| 130 |
my $biblio_object = Koha::Biblios->find( $record_id ); |
134 |
my $biblio_object = Koha::Biblios->find($record_id); |
| 131 |
unless ( $biblio_object ) { |
135 |
unless ($biblio_object) { |
| 132 |
push @messages, { |
136 |
push @messages, { |
| 133 |
type => 'warning', |
137 |
type => 'warning', |
| 134 |
code => 'biblio_not_exists', |
138 |
code => 'biblio_not_exists', |
| 135 |
biblionumber => $record_id, |
139 |
biblionumber => $record_id, |
| 136 |
}; |
140 |
}; |
| 137 |
next; |
141 |
next; |
| 138 |
} |
142 |
} |
| 139 |
my $biblio = $biblio_object->unblessed; |
143 |
my $biblio = $biblio_object->unblessed; |
| 140 |
my $record = $biblio_object->metadata->record; |
144 |
my $record = $biblio_object->metadata->record; |
| 141 |
$biblio->{itemnumbers} = [Koha::Items->search({ biblionumber => $record_id })->get_column('itemnumber')]; |
145 |
$biblio->{itemnumbers} = |
| 142 |
$biblio->{holds_count} = $biblio_object->holds->count; |
146 |
[ Koha::Items->search( { biblionumber => $record_id } )->get_column('itemnumber') ]; |
| 143 |
$biblio->{issues_count} = C4::Biblio::CountItemsIssued( $record_id ); |
147 |
$biblio->{holds_count} = $biblio_object->holds->count; |
|
|
148 |
$biblio->{issues_count} = C4::Biblio::CountItemsIssued($record_id); |
| 144 |
$biblio->{subscriptions_count} = $biblio_object->subscriptions->count; |
149 |
$biblio->{subscriptions_count} = $biblio_object->subscriptions->count; |
| 145 |
|
150 |
|
| 146 |
# Respect skip_open_orders |
151 |
# Respect skip_open_orders |
|
Lines 151-184
if ( $op eq 'form' ) {
Link Here
|
| 151 |
|
156 |
|
| 152 |
push @records, $biblio; |
157 |
push @records, $biblio; |
| 153 |
} else { |
158 |
} else { |
|
|
159 |
|
| 154 |
# Retrieve authority information |
160 |
# Retrieve authority information |
| 155 |
my $authority = C4::AuthoritiesMarc::GetAuthority( $record_id ); |
161 |
my $authority = C4::AuthoritiesMarc::GetAuthority($record_id); |
| 156 |
unless ( $authority ) { |
162 |
unless ($authority) { |
| 157 |
push @messages, { |
163 |
push @messages, { |
| 158 |
type => 'warning', |
164 |
type => 'warning', |
| 159 |
code => 'authority_not_exists', |
165 |
code => 'authority_not_exists', |
| 160 |
authid => $record_id, |
166 |
authid => $record_id, |
| 161 |
}; |
167 |
}; |
| 162 |
next; |
168 |
next; |
| 163 |
} |
169 |
} |
| 164 |
|
170 |
|
| 165 |
$authority = { |
171 |
$authority = { |
| 166 |
authid => $record_id, |
172 |
authid => $record_id, |
| 167 |
summary => C4::AuthoritiesMarc::BuildSummary( $authority, $record_id ), |
173 |
summary => C4::AuthoritiesMarc::BuildSummary( $authority, $record_id ), |
| 168 |
count_usage => Koha::Authorities->get_usage_count({ authid => $record_id }), |
174 |
count_usage => Koha::Authorities->get_usage_count( { authid => $record_id } ), |
| 169 |
}; |
175 |
}; |
| 170 |
push @records, $authority; |
176 |
push @records, $authority; |
| 171 |
} |
177 |
} |
| 172 |
$template->param( |
178 |
$template->param( |
| 173 |
records => \@records, |
179 |
records => \@records, |
| 174 |
op => 'list', |
180 |
op => 'list', |
| 175 |
); |
181 |
); |
| 176 |
} |
182 |
} |
| 177 |
} |
183 |
} |
| 178 |
} elsif ( $op eq 'cud-delete' ) { |
184 |
} elsif ( $op eq 'cud-delete' ) { |
|
|
185 |
|
| 179 |
# We want to delete selected records! |
186 |
# We want to delete selected records! |
| 180 |
my @record_ids = $input->multi_param('record_id'); |
187 |
my @record_ids = $input->multi_param('record_id'); |
| 181 |
$enqueue_job->(\@record_ids, $recordtype); |
188 |
$enqueue_job->( \@record_ids, $recordtype ); |
| 182 |
} |
189 |
} |
| 183 |
|
190 |
|
| 184 |
$template->param( |
191 |
$template->param( |