Lines 25-40
use C4::Context;
Link Here
|
25 |
use C4::Output; |
25 |
use C4::Output; |
26 |
use CGI qw ( -utf8 ); |
26 |
use CGI qw ( -utf8 ); |
27 |
use C4::Auth; |
27 |
use C4::Auth; |
28 |
use Koha::Biblios; |
|
|
29 |
use C4::Debug; |
28 |
use C4::Debug; |
|
|
29 |
use C4::Items qw( ModItem ModItemTransfer ); |
30 |
use C4::Reserves qw( ModReserveCancelAll ); |
31 |
use Koha::Biblios; |
30 |
use Koha::DateUtils; |
32 |
use Koha::DateUtils; |
|
|
33 |
use Koha::Holds; |
31 |
use DateTime::Duration; |
34 |
use DateTime::Duration; |
32 |
|
35 |
|
33 |
my $input = new CGI; |
36 |
my $input = new CGI; |
34 |
my $startdate = $input->param('from'); |
37 |
my $startdate = $input->param('from'); |
35 |
my $enddate = $input->param('to'); |
38 |
my $enddate = $input->param('to'); |
36 |
|
|
|
37 |
my $theme = $input->param('theme'); # only used if allowthemeoverride is set |
39 |
my $theme = $input->param('theme'); # only used if allowthemeoverride is set |
|
|
40 |
my $op = $input->param('op') || ''; |
41 |
my $borrowernumber = $input->param('borrowernumber'); |
42 |
my $reserve_id = $input->param('reserve_id'); |
38 |
|
43 |
|
39 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
44 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
40 |
{ |
45 |
{ |
Lines 47-52
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Link Here
|
47 |
} |
52 |
} |
48 |
); |
53 |
); |
49 |
|
54 |
|
|
|
55 |
my @messages; |
56 |
if ( $op eq 'cancel_reserve' and $reserve_id ) { |
57 |
my $hold = Koha::Holds->find( $reserve_id ); |
58 |
if ( $hold ) { |
59 |
$hold->cancel; |
60 |
push @messages, { type => 'message', code => 'hold_cancelled' }; |
61 |
} |
62 |
} elsif ( $op =~ m|^mark_as_lost| ) { |
63 |
my $hold = Koha::Holds->find( $reserve_id ); |
64 |
die "wrong reserve_id" unless $hold; # This is a bit rude, but we are not supposed to get a wrong reserve_id |
65 |
my $item = $hold->item; |
66 |
if ( $item and C4::Context->preference('CanMarkHoldsToPullAsLost') =~ m|^allow| ) { |
67 |
my $patron = $hold->borrower; |
68 |
C4::Circulation::LostItem( $item->itemnumber ); |
69 |
if ( $op eq 'mark_as_lost_and_notify' and C4::Context->preference('CanMarkHoldsToPullAsLost') eq 'allow_and_notify' ) { |
70 |
my $library = $hold->branch; |
71 |
my $letter = C4::Letters::GetPreparedLetter( |
72 |
module => 'reserves', |
73 |
letter_code => 'CANCEL_HOLD_ON_LOST', |
74 |
branchcode => $library->branchcode, # FIXME Is it what we want? |
75 |
lang => $patron->lang, |
76 |
tables => { |
77 |
branches => $library->branchcode, |
78 |
borrowers => $patron->borrowernumber, |
79 |
items => $item->itemnumber, |
80 |
biblio => $hold->biblionumber, |
81 |
biblioitems => $hold->biblionumber, |
82 |
reserves => $hold->unblessed, |
83 |
}, |
84 |
); |
85 |
if ( $letter ) { |
86 |
my $admin_email_address = $library->branchemail || C4::Context->preference('KohaAdminEmailAddress'); |
87 |
|
88 |
C4::Letters::EnqueueLetter( |
89 |
{ letter => $letter, |
90 |
borrowernumber => $patron->borrowernumber, |
91 |
message_transport_type => 'email', |
92 |
from_address => $admin_email_address, |
93 |
} |
94 |
); |
95 |
unless ( C4::Members::GetNoticeEmailAddress( $patron->borrowernumber ) ) { |
96 |
push @messages, {type => 'alert', code => 'no_email_address', }; |
97 |
} |
98 |
push @messages, { type => 'message', code => 'letter_enqueued' }; |
99 |
} else { |
100 |
push @messages, { type => 'error', code => 'no_template_notice' }; |
101 |
} |
102 |
} |
103 |
$hold->cancel; |
104 |
if ( $item->homebranch ne $item->holdingbranch ) { |
105 |
C4::Items::ModItemTransfer( $item->itemnumber, $item->holdingbranch, $item->homebranch ); |
106 |
} |
107 |
|
108 |
if ( my $yaml = C4::Context->preference('UpdateItemWhenLostFromHoldList') ) { |
109 |
$yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt |
110 |
my $assignments; |
111 |
eval { $assignments = YAML::Load($yaml); }; |
112 |
if ($@) { |
113 |
warn "Unable to parse UpdateItemWhenLostFromHoldList syspref : $@" if $@; |
114 |
} |
115 |
else { |
116 |
eval { |
117 |
C4::Items::ModItem( $assignments, undef, $item->itemnumber ); |
118 |
}; |
119 |
warn "Unable to modify item itemnumber=" . $item->itemnumber . ": $@" if $@; |
120 |
} |
121 |
} |
122 |
|
123 |
} elsif ( not $item ) { |
124 |
push @messages, { type => 'alert', code => 'hold_placed_at_biblio_level'}; |
125 |
} # else the url parameters have been modified and the user is not allowed to continue |
126 |
} |
127 |
|
128 |
|
50 |
my $today = dt_from_string; |
129 |
my $today = dt_from_string; |
51 |
|
130 |
|
52 |
if ( $startdate ) { |
131 |
if ( $startdate ) { |
Lines 91-101
if ($enddate_iso) {
Link Here
|
91 |
|
170 |
|
92 |
my $strsth = |
171 |
my $strsth = |
93 |
"SELECT min(reservedate) as l_reservedate, |
172 |
"SELECT min(reservedate) as l_reservedate, |
|
|
173 |
reserves.reserve_id, |
94 |
reserves.borrowernumber as borrowernumber, |
174 |
reserves.borrowernumber as borrowernumber, |
|
|
175 |
|
95 |
GROUP_CONCAT(DISTINCT items.holdingbranch |
176 |
GROUP_CONCAT(DISTINCT items.holdingbranch |
96 |
ORDER BY items.itemnumber SEPARATOR '|') l_holdingbranch, |
177 |
ORDER BY items.itemnumber SEPARATOR '|') l_holdingbranch, |
97 |
reserves.biblionumber, |
178 |
reserves.biblionumber, |
98 |
reserves.branchcode as l_branch, |
179 |
reserves.branchcode as l_branch, |
|
|
180 |
items.itemnumber, |
181 |
items.holdingbranch, |
182 |
items.homebranch, |
99 |
GROUP_CONCAT(DISTINCT items.itype |
183 |
GROUP_CONCAT(DISTINCT items.itype |
100 |
ORDER BY items.itemnumber SEPARATOR '|') l_itype, |
184 |
ORDER BY items.itemnumber SEPARATOR '|') l_itype, |
101 |
GROUP_CONCAT(DISTINCT items.location |
185 |
GROUP_CONCAT(DISTINCT items.location |
Lines 167-172
while ( my $data = $sth->fetchrow_hashref ) {
Link Here
|
167 |
pullcount => $data->{icount} <= $data->{rcount} ? $data->{icount} : $data->{rcount}, |
251 |
pullcount => $data->{icount} <= $data->{rcount} ? $data->{icount} : $data->{rcount}, |
168 |
itypes => [split('\|', $data->{l_itype})], |
252 |
itypes => [split('\|', $data->{l_itype})], |
169 |
locations => [split('\|', $data->{l_location})], |
253 |
locations => [split('\|', $data->{l_location})], |
|
|
254 |
reserve_id => $data->{reserve_id}, |
255 |
holdingbranch => $data->{holdingbranch}, |
256 |
homebranch => $data->{homebranch}, |
257 |
itemnumber => $data->{itemnumber}, |
170 |
} |
258 |
} |
171 |
); |
259 |
); |
172 |
} |
260 |
} |
Lines 180-185
$template->param(
Link Here
|
180 |
"BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, |
268 |
"BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, |
181 |
HoldsToPullStartDate => C4::Context->preference('HoldsToPullStartDate') || PULL_INTERVAL, |
269 |
HoldsToPullStartDate => C4::Context->preference('HoldsToPullStartDate') || PULL_INTERVAL, |
182 |
HoldsToPullEndDate => C4::Context->preference('ConfirmFutureHolds') || 0, |
270 |
HoldsToPullEndDate => C4::Context->preference('ConfirmFutureHolds') || 0, |
|
|
271 |
messages => \@messages, |
183 |
); |
272 |
); |
184 |
|
273 |
|
185 |
output_html_with_http_headers $input, $cookie, $template->output; |
274 |
output_html_with_http_headers $input, $cookie, $template->output; |