View | Details | Raw Unified | Return to bug 23678
Collapse All | Expand All

(-)a/Koha/BackgroundJob/BatchCancelHold.pm (-10 / +21 lines)
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;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/batch_hold_cancel.inc (-1 / +47 lines)
Line 0 Link Here
0
- 
1
[% BLOCK report %]
2
    [% SET report = job.report %]
3
    [% IF report %]
4
        [% IF report.total_holds == report.total_success %]
5
            <div class="dialog message">
6
                All holds have successfully been cancelled!
7
            </div>
8
        [% ELSE %]
9
            <div class="dialog message">
10
                [% report.total_success | html %] / [% report.total_holds | html %] holds have successfully been modified. Some errors occurred.
11
                [% IF job.status == 'cancelled' %]The job has been cancelled before it finished.[% END %]
12
            </div>
13
        [% END %]
14
    [% END %]
15
16
[% END %]
17
18
[% BLOCK detail %]
19
    [% FOR m IN report_messages %]
20
        <div class="dialog message">
21
            [% IF m.type == 'success' %]
22
                <i class="fa fa-check success"></i>
23
            [% ELSIF m.type == 'warning' %]
24
                <i class="fa fa-warning warn"></i>
25
            [% ELSIF m.type == 'error' %]
26
                <i class="fa fa-exclamation error"></i>
27
            [% END %]
28
            [% SWITCH m.code %]
29
            [% CASE 'hold_not_cancelled' %]
30
                [% IF m.biblio && m.patron %]
31
                    Hold on <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% m.biblio.biblionumber | uri %]">[% m.biblio.title | html %]</a> for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% m.patron.borrowernumber | uri %]">[% INCLUDE 'patron-title.inc' patron=m.patron %]</a> has not been cancelled.
32
                [% END %]
33
                An error occurred on cancelling.
34
                [% SWITCH m.error %]
35
                [% CASE 'hold_not_found' %]
36
                    No hold with id [% m.hold_id %] found.
37
                [% CASE %]Unknown error '[% m.error %]'.
38
                [% END %]
39
            [% CASE 'hold_cancelled' %]
40
                Hold on <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% m.biblio_id | uri %]">[% m.biblio.title | html %]</a> for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% m.patron_id | uri %]">[% INCLUDE 'patron-title.inc' patron=m.patron %]</a> has successfully been cancelled.
41
            [% END %]
42
        </div>
43
    [% END %]
44
[% END %]
45
46
[% BLOCK js %]
47
[% END %]

Return to bug 23678