Lines 49-55
my $startdate = $input->param('reserve_date') || '';
Link Here
|
49 |
my @rank = $input->multi_param('rank-request'); |
49 |
my @rank = $input->multi_param('rank-request'); |
50 |
my $type = $input->param('type'); |
50 |
my $type = $input->param('type'); |
51 |
my $title = $input->param('title'); |
51 |
my $title = $input->param('title'); |
52 |
my $checkitem = $input->param('checkitem'); |
52 |
my @checkitems = $input->multi_param('checkitem'); |
53 |
my $expirationdate = $input->param('expiration_date'); |
53 |
my $expirationdate = $input->param('expiration_date'); |
54 |
my $itemtype = $input->param('itemtype') || undef; |
54 |
my $itemtype = $input->param('itemtype') || undef; |
55 |
my $non_priority = $input->param('non_priority'); |
55 |
my $non_priority = $input->param('non_priority'); |
Lines 62-67
$biblionumbers ||= $biblionumber . '/';
Link Here
|
62 |
|
62 |
|
63 |
my $bad_bibs = $input->param('bad_bibs'); |
63 |
my $bad_bibs = $input->param('bad_bibs'); |
64 |
my $holds_to_place_count = $input->param('holds_to_place_count') || 1; |
64 |
my $holds_to_place_count = $input->param('holds_to_place_count') || 1; |
|
|
65 |
$holds_to_place_count = scalar( @checkitems ) if @checkitems; |
65 |
|
66 |
|
66 |
my %bibinfos = (); |
67 |
my %bibinfos = (); |
67 |
my @biblionumbers = split '/', $biblionumbers; |
68 |
my @biblionumbers = split '/', $biblionumbers; |
Lines 72-78
foreach my $bibnum (@biblionumbers) {
Link Here
|
72 |
$bibinfos{$bibnum} = \%bibinfo; |
73 |
$bibinfos{$bibnum} = \%bibinfo; |
73 |
} |
74 |
} |
74 |
|
75 |
|
75 |
my $found; |
76 |
my @found; |
|
|
77 |
unless ( C4::Context->preference('ReservesNeedReturns') ) { |
78 |
foreach my $checkitem ( @checkitems ) { |
79 |
# if we have an item selected, and the pickup branch is the same as |
80 |
# the holdingbranch of the doc, we force the value $rank and $found |
81 |
$rank[0] = '0'; |
82 |
my $item = Koha::Items->find( $checkitem ); |
83 |
push @found, ( $item->holdingbranch eq $branch ? 'W' : undef ); |
84 |
} |
85 |
} |
76 |
|
86 |
|
77 |
if ( $type eq 'str8' && $borrower ) { |
87 |
if ( $type eq 'str8' && $borrower ) { |
78 |
|
88 |
|
Lines 91-104
if ( $type eq 'str8' && $borrower ) {
Link Here
|
91 |
} |
101 |
} |
92 |
|
102 |
|
93 |
my $can_override = C4::Context->preference('AllowHoldPolicyOverride'); |
103 |
my $can_override = C4::Context->preference('AllowHoldPolicyOverride'); |
94 |
if ( defined $checkitem && $checkitem ne '' ) { |
104 |
if ( @checkitems and @checkitems == 1 ) { |
95 |
|
105 |
# item-level hold |
96 |
my $item = Koha::Items->find($checkitem); |
106 |
my $item = Koha::Items->find( $checkitems[0] ); |
97 |
|
|
|
98 |
if ( $item->biblionumber ne $biblionumber ) { |
99 |
$biblionumber = $item->biblionumber; |
100 |
} |
101 |
|
102 |
my $can_item_be_reserved = CanItemBeReserved($borrower->{'borrowernumber'}, $item->itemnumber, $branch)->{status}; |
107 |
my $can_item_be_reserved = CanItemBeReserved($borrower->{'borrowernumber'}, $item->itemnumber, $branch)->{status}; |
103 |
|
108 |
|
104 |
if ( $can_item_be_reserved eq 'OK' || ( $can_item_be_reserved ne 'itemAlreadyOnHold' && $can_override ) ) { |
109 |
if ( $can_item_be_reserved eq 'OK' || ( $can_item_be_reserved ne 'itemAlreadyOnHold' && $can_override ) ) { |
Lines 112-119
if ( $type eq 'str8' && $borrower ) {
Link Here
|
112 |
expiration_date => $expirationdate, |
117 |
expiration_date => $expirationdate, |
113 |
notes => $notes, |
118 |
notes => $notes, |
114 |
title => $title, |
119 |
title => $title, |
115 |
itemnumber => $checkitem, |
120 |
itemnumber => $checkitems[0], |
116 |
found => $found, |
121 |
found => $found[0], |
117 |
itemtype => $itemtype, |
122 |
itemtype => $itemtype, |
118 |
non_priority => $non_priority, |
123 |
non_priority => $non_priority, |
119 |
} |
124 |
} |
Lines 121-127
if ( $type eq 'str8' && $borrower ) {
Link Here
|
121 |
|
126 |
|
122 |
} |
127 |
} |
123 |
|
128 |
|
124 |
} elsif (@biblionumbers > 1) { |
129 |
} elsif ( @biblionumbers > 1 ) { |
|
|
130 |
# hold on multiple titles (multi-hold) |
125 |
my $bibinfo = $bibinfos{$biblionumber}; |
131 |
my $bibinfo = $bibinfos{$biblionumber}; |
126 |
if ( $can_override || CanBookBeReserved($borrower->{'borrowernumber'}, $biblionumber)->{status} eq 'OK' ) { |
132 |
if ( $can_override || CanBookBeReserved($borrower->{'borrowernumber'}, $biblionumber)->{status} eq 'OK' ) { |
127 |
AddReserve( |
133 |
AddReserve( |
Lines 134-141
if ( $type eq 'str8' && $borrower ) {
Link Here
|
134 |
expiration_date => $expirationdate, |
140 |
expiration_date => $expirationdate, |
135 |
notes => $notes, |
141 |
notes => $notes, |
136 |
title => $bibinfo->{title}, |
142 |
title => $bibinfo->{title}, |
137 |
itemnumber => $checkitem, |
143 |
itemnumber => undef, |
138 |
found => $found, |
144 |
found => undef, |
139 |
itemtype => $itemtype, |
145 |
itemtype => $itemtype, |
140 |
non_priority => $non_priority, |
146 |
non_priority => $non_priority, |
141 |
} |
147 |
} |
Lines 144-163
if ( $type eq 'str8' && $borrower ) {
Link Here
|
144 |
} else { |
150 |
} else { |
145 |
# place a request on 1st available |
151 |
# place a request on 1st available |
146 |
for ( my $i = 0 ; $i < $holds_to_place_count ; $i++ ) { |
152 |
for ( my $i = 0 ; $i < $holds_to_place_count ; $i++ ) { |
|
|
153 |
my $item; |
154 |
if ( $checkitems[$i] ) { |
155 |
$item = Koha::Items->find( $checkitems[$i] ); |
156 |
} |
147 |
if ( $can_override || CanBookBeReserved($borrower->{'borrowernumber'}, $biblionumber)->{status} eq 'OK' ) { |
157 |
if ( $can_override || CanBookBeReserved($borrower->{'borrowernumber'}, $biblionumber)->{status} eq 'OK' ) { |
148 |
AddReserve( |
158 |
AddReserve( |
149 |
{ |
159 |
{ |
150 |
branchcode => $branch, |
160 |
branchcode => $branch, |
151 |
borrowernumber => $borrower->{'borrowernumber'}, |
161 |
borrowernumber => $borrower->{'borrowernumber'}, |
152 |
biblionumber => $biblionumber, |
162 |
biblionumber => ( $item ? $item->biblionumber : $biblionumber ), |
153 |
priority => $rank[0], |
163 |
priority => $rank[0], |
154 |
reservation_date => $startdate, |
164 |
reservation_date => $startdate, |
155 |
expiration_date => $expirationdate, |
165 |
expiration_date => $expirationdate, |
156 |
notes => $notes, |
166 |
notes => $notes, |
157 |
title => $title, |
167 |
title => $title, |
158 |
itemnumber => $checkitem, |
168 |
itemnumber => $checkitems[$i], |
159 |
found => $found, |
169 |
found => $found[$i], |
160 |
itemtype => $itemtype, |
170 |
itemtype => ( $item ? $item->effective_itemtype : undef ), |
161 |
non_priority => $non_priority, |
171 |
non_priority => $non_priority, |
162 |
} |
172 |
} |
163 |
); |
173 |
); |