|
Lines 21-26
use JSON qw( encode_json decode_json );
Link Here
|
| 21 |
use Koha::BackgroundJobs; |
21 |
use Koha::BackgroundJobs; |
| 22 |
use Koha::DateUtils qw( dt_from_string ); |
22 |
use Koha::DateUtils qw( dt_from_string ); |
| 23 |
use Koha::Holds; |
23 |
use Koha::Holds; |
|
|
24 |
use Koha::Patrons; |
| 25 |
use Koha::Holds; |
| 24 |
|
26 |
|
| 25 |
use base 'Koha::BackgroundJob'; |
27 |
use base 'Koha::BackgroundJob'; |
| 26 |
|
28 |
|
|
Lines 89-104
sub process {
Link Here
|
| 89 |
type => 'error', |
91 |
type => 'error', |
| 90 |
code => 'hold_not_cancelled', |
92 |
code => 'hold_not_cancelled', |
| 91 |
patron_id => defined $patron ? $patron->borrowernumber : '', |
93 |
patron_id => defined $patron ? $patron->borrowernumber : '', |
| 92 |
patron_name => defined $patron |
|
|
| 93 |
? ( $patron->firstname ? $patron->firstname . ', ' : '' ) |
| 94 |
. $patron->surname |
| 95 |
: '', |
| 96 |
biblio_id => defined $biblio ? $biblio->biblionumber : '', |
94 |
biblio_id => defined $biblio ? $biblio->biblionumber : '', |
| 97 |
biblio_title => defined $biblio ? $biblio->title : '', |
|
|
| 98 |
hold_id => $hold_id, |
95 |
hold_id => $hold_id, |
| 99 |
error => defined $hold |
96 |
error => defined $hold |
| 100 |
? ( $@ ? $@ : 0 ) |
97 |
? ( $@ ? $@ : 0 ) |
| 101 |
: 'No hold with id ' . $hold_id . ' found', |
98 |
: 'hold_not_found', |
| 102 |
}; |
99 |
}; |
| 103 |
} |
100 |
} |
| 104 |
else { |
101 |
else { |
|
Lines 107-117
sub process {
Link Here
|
| 107 |
type => 'success', |
104 |
type => 'success', |
| 108 |
code => 'hold_cancelled', |
105 |
code => 'hold_cancelled', |
| 109 |
patron_id => $patron->borrowernumber, |
106 |
patron_id => $patron->borrowernumber, |
| 110 |
patron_name => |
|
|
| 111 |
( $patron->firstname ? $patron->firstname . ', ' : '' ) |
| 112 |
. $patron->surname, |
| 113 |
biblio_id => $biblio->biblionumber, |
107 |
biblio_id => $biblio->biblionumber, |
| 114 |
biblio_title => $biblio->title, |
|
|
| 115 |
hold_id => $hold_id, |
108 |
hold_id => $hold_id, |
| 116 |
}; |
109 |
}; |
| 117 |
$report->{total_success}++; |
110 |
$report->{total_success}++; |
|
Lines 151-154
sub enqueue {
Link Here
|
| 151 |
); |
144 |
); |
| 152 |
} |
145 |
} |
| 153 |
|
146 |
|
|
|
147 |
=head3 additional_report |
| 148 |
|
| 149 |
Pass the biblio's title and patron's name |
| 150 |
|
| 151 |
=cut |
| 152 |
|
| 153 |
sub additional_report { |
| 154 |
my ( $self, $args ) = @_; |
| 155 |
|
| 156 |
my $job = Koha::BackgroundJobs->find( $args->{job_id} ); |
| 157 |
my $messages = $job->messages; |
| 158 |
for my $m ( @$messages ) { |
| 159 |
$m->{patron} = Koha::Patrons->find($m->{patron_id}); |
| 160 |
$m->{biblio} = Koha::Biblios->find($m->{biblio_id}); |
| 161 |
} |
| 162 |
return { report_messages => $messages }; |
| 163 |
} |
| 164 |
|
| 154 |
1; |
165 |
1; |