|
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 53-63
my $op = $input->param('op') || q{};
Link Here
|
| 53 |
my $multi_holds = $input->param('multi_holds'); |
63 |
my $multi_holds = $input->param('multi_holds'); |
| 54 |
my $hold_group_param = $input->param('hold_group') || undef; |
64 |
my $hold_group_param = $input->param('hold_group') || undef; |
| 55 |
|
65 |
|
|
|
66 |
my $confirm = $input->param('confirm'); |
| 67 |
my @confirm_biblionumbers = $input->multi_param('confirm_biblionumbers'); |
| 68 |
|
| 56 |
my $patron = Koha::Patrons->find($borrowernumber); |
69 |
my $patron = Koha::Patrons->find($borrowernumber); |
| 57 |
|
70 |
|
| 58 |
my $holds_to_place_count = $input->param('holds_to_place_count') || 1; |
71 |
my $holds_to_place_count = $input->param('holds_to_place_count') || 1; |
| 59 |
|
72 |
|
| 60 |
my %bibinfos = (); |
73 |
my %bibinfos = (); |
|
|
74 |
my $multi_hold = @holdable_bibs > 1; |
| 61 |
foreach my $bibnum (@holdable_bibs) { |
75 |
foreach my $bibnum (@holdable_bibs) { |
| 62 |
my %bibinfo = (); |
76 |
my %bibinfo = (); |
| 63 |
$bibinfo{title} = $input->param("title_$bibnum"); |
77 |
$bibinfo{title} = $input->param("title_$bibnum"); |
|
Lines 70-76
if ( $op eq 'cud-placerequest' && $patron ) {
Link Here
|
| 70 |
my %failed_holds; |
84 |
my %failed_holds; |
| 71 |
my @successful_hold_ids; |
85 |
my @successful_hold_ids; |
| 72 |
|
86 |
|
|
|
87 |
if ( C4::Context->preference('PreventReservesOnSamePeriod') && !$confirm ) { |
| 88 |
my %overlap_reserves; |
| 89 |
foreach my $biblionumber ( keys %bibinfos ) { |
| 90 |
next if exists $overlap_reserves{$biblionumber}; |
| 91 |
|
| 92 |
if (@checkitems) { |
| 93 |
for my $checkitem (@checkitems) { |
| 94 |
my $item = Koha::Items->find($checkitem); |
| 95 |
next if $biblionumber ne $item->biblionumber; |
| 96 |
|
| 97 |
my $overlapping_reserves = |
| 98 |
C4::Reserves::ReservesOnSamePeriod( $biblionumber, $checkitem, $startdate, $expirationdate ); |
| 99 |
if ( $overlapping_reserves && 0 < scalar @$overlapping_reserves ) { |
| 100 |
$overlap_reserves{$biblionumber} = { |
| 101 |
title => $multi_hold ? $bibinfos{$biblionumber}->{title} : $title, |
| 102 |
}; |
| 103 |
} |
| 104 |
} |
| 105 |
} else { |
| 106 |
my $overlapping_reserves = |
| 107 |
C4::Reserves::ReservesOnSamePeriod( $biblionumber, undef, $startdate, $expirationdate ); |
| 108 |
if ( $overlapping_reserves && 0 < scalar @$overlapping_reserves ) { |
| 109 |
$overlap_reserves{$biblionumber} = { |
| 110 |
title => $multi_hold ? $bibinfos{$biblionumber}->{title} : $title, |
| 111 |
}; |
| 112 |
} |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
if ( scalar keys %overlap_reserves ) { |
| 117 |
my %params = $input->Vars; |
| 118 |
delete $params{csrf_token}; |
| 119 |
my @params; |
| 120 |
foreach my $name ( sort keys %params ) { |
| 121 |
my @values = split( "\0", $params{$name} ); |
| 122 |
foreach my $value (@values) { |
| 123 |
push @params, { name => $name, value => $value }; |
| 124 |
} |
| 125 |
} |
| 126 |
$template->param( params => \@params ); |
| 127 |
|
| 128 |
$template->param( |
| 129 |
borrowernumber => $borrowernumber, |
| 130 |
biblionumbers => \@biblionumbers, |
| 131 |
overlap_reserves => \%overlap_reserves, |
| 132 |
); |
| 133 |
|
| 134 |
output_html_with_http_headers $input, $cookie, $template->output; |
| 135 |
exit; |
| 136 |
} |
| 137 |
} |
| 138 |
|
| 73 |
foreach my $biblionumber ( keys %bibinfos ) { |
139 |
foreach my $biblionumber ( keys %bibinfos ) { |
|
|
140 |
next if ( $confirm && none { $_ eq $biblionumber } @confirm_biblionumbers ); |
| 74 |
|
141 |
|
| 75 |
my $can_override = C4::Context->preference('AllowHoldPolicyOverride'); |
142 |
my $can_override = C4::Context->preference('AllowHoldPolicyOverride'); |
| 76 |
if (@checkitems) { |
143 |
if (@checkitems) { |