Lines 22-31
Link Here
|
22 |
|
22 |
|
23 |
use Modern::Perl; |
23 |
use Modern::Perl; |
24 |
|
24 |
|
|
|
25 |
use List::MoreUtils qw( none ); |
26 |
|
25 |
use CGI qw ( -utf8 ); |
27 |
use CGI qw ( -utf8 ); |
26 |
use URI; |
28 |
use URI; |
27 |
use C4::Reserves qw( CanItemBeReserved AddReserve CanBookBeReserved ); |
29 |
use C4::Reserves qw( CanItemBeReserved AddReserve CanBookBeReserved ); |
28 |
use C4::Auth qw( checkauth ); |
30 |
use C4::Auth qw( get_template_and_user ); |
|
|
31 |
use C4::Output qw( output_html_with_http_headers ); |
29 |
|
32 |
|
30 |
use Koha::Items; |
33 |
use Koha::Items; |
31 |
use Koha::Patrons; |
34 |
use Koha::Patrons; |
Lines 33-39
use Koha::HoldGroup;
Link Here
|
33 |
|
36 |
|
34 |
my $input = CGI->new(); |
37 |
my $input = CGI->new(); |
35 |
|
38 |
|
36 |
checkauth( $input, 0, { reserveforothers => 'place_holds' }, 'intranet' ); |
39 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
|
|
40 |
{ |
41 |
template_name => 'reserve/placerequest.tt', |
42 |
query => $input, |
43 |
type => 'intranet', |
44 |
flagsrequired => { reserveforothers => 'place_holds' }, |
45 |
} |
46 |
); |
37 |
|
47 |
|
38 |
my @reqbib = $input->multi_param('reqbib'); |
48 |
my @reqbib = $input->multi_param('reqbib'); |
39 |
my @biblionumbers = $input->multi_param('biblionumber'); |
49 |
my @biblionumbers = $input->multi_param('biblionumber'); |
Lines 54-64
my $multi_holds = $input->param('multi_holds');
Link Here
|
54 |
my $hold_group_param = $input->param('hold_group') || undef; |
64 |
my $hold_group_param = $input->param('hold_group') || undef; |
55 |
my $hold_group; |
65 |
my $hold_group; |
56 |
|
66 |
|
|
|
67 |
my $confirm = $input->param('confirm'); |
68 |
my @confirm_biblionumbers = $input->multi_param('confirm_biblionumbers'); |
69 |
|
57 |
my $patron = Koha::Patrons->find($borrowernumber); |
70 |
my $patron = Koha::Patrons->find($borrowernumber); |
58 |
|
71 |
|
59 |
my $holds_to_place_count = $input->param('holds_to_place_count') || 1; |
72 |
my $holds_to_place_count = $input->param('holds_to_place_count') || 1; |
60 |
|
73 |
|
61 |
my %bibinfos = (); |
74 |
my %bibinfos = (); |
|
|
75 |
my $multi_hold = @holdable_bibs > 1; |
62 |
foreach my $bibnum (@holdable_bibs) { |
76 |
foreach my $bibnum (@holdable_bibs) { |
63 |
my %bibinfo = (); |
77 |
my %bibinfo = (); |
64 |
$bibinfo{title} = $input->param("title_$bibnum"); |
78 |
$bibinfo{title} = $input->param("title_$bibnum"); |
Lines 73-79
if ( $op eq 'cud-placerequest' && $patron ) {
Link Here
|
73 |
$hold_group = Koha::HoldGroup->new->store; |
87 |
$hold_group = Koha::HoldGroup->new->store; |
74 |
} |
88 |
} |
75 |
|
89 |
|
|
|
90 |
if ( C4::Context->preference('PreventReservesOnSamePeriod') && !$confirm ) { |
91 |
my %overlap_reserves; |
92 |
foreach my $biblionumber ( keys %bibinfos ) { |
93 |
next if exists $overlap_reserves{$biblionumber}; |
94 |
|
95 |
if (@checkitems) { |
96 |
for my $checkitem (@checkitems) { |
97 |
my $item = Koha::Items->find($checkitem); |
98 |
next if $biblionumber ne $item->biblionumber; |
99 |
|
100 |
my $overlapping_reserves = |
101 |
C4::Reserves::ReservesOnSamePeriod( $biblionumber, $checkitem, $startdate, $expirationdate ); |
102 |
if ( $overlapping_reserves && 0 < scalar @$overlapping_reserves ) { |
103 |
$overlap_reserves{$biblionumber} = { |
104 |
title => $multi_hold ? $bibinfos{$biblionumber}->{title} : $title, |
105 |
}; |
106 |
} |
107 |
} |
108 |
} else { |
109 |
my $overlapping_reserves = |
110 |
C4::Reserves::ReservesOnSamePeriod( $biblionumber, undef, $startdate, $expirationdate ); |
111 |
if ( $overlapping_reserves && 0 < scalar @$overlapping_reserves ) { |
112 |
$overlap_reserves{$biblionumber} = { |
113 |
title => $multi_hold ? $bibinfos{$biblionumber}->{title} : $title, |
114 |
}; |
115 |
} |
116 |
} |
117 |
} |
118 |
|
119 |
if ( scalar keys %overlap_reserves ) { |
120 |
my %params = $input->Vars; |
121 |
delete $params{csrf_token}; |
122 |
my @params; |
123 |
foreach my $name ( sort keys %params ) { |
124 |
my @values = split( "\0", $params{$name} ); |
125 |
foreach my $value (@values) { |
126 |
push @params, { name => $name, value => $value }; |
127 |
} |
128 |
} |
129 |
$template->param( params => \@params ); |
130 |
|
131 |
$template->param( |
132 |
borrowernumber => $borrowernumber, |
133 |
biblionumbers => \@biblionumbers, |
134 |
overlap_reserves => \%overlap_reserves, |
135 |
); |
136 |
|
137 |
output_html_with_http_headers $input, $cookie, $template->output; |
138 |
exit; |
139 |
} |
140 |
} |
141 |
|
76 |
foreach my $biblionumber ( keys %bibinfos ) { |
142 |
foreach my $biblionumber ( keys %bibinfos ) { |
|
|
143 |
next if ( $confirm && none { $_ eq $biblionumber } @confirm_biblionumbers ); |
77 |
|
144 |
|
78 |
my $can_override = C4::Context->preference('AllowHoldPolicyOverride'); |
145 |
my $can_override = C4::Context->preference('AllowHoldPolicyOverride'); |
79 |
if (@checkitems) { |
146 |
if (@checkitems) { |