Lines 31-78
use C4::Output;
Link Here
|
31 |
use C4::Reserves; |
31 |
use C4::Reserves; |
32 |
use C4::Circulation; |
32 |
use C4::Circulation; |
33 |
use C4::Members; |
33 |
use C4::Members; |
34 |
use C4::Auth qw/checkauth/; |
34 |
use C4::Auth; |
35 |
use Koha::Patrons; |
35 |
use Koha::Patrons; |
36 |
|
36 |
|
37 |
my $input = CGI->new(); |
37 |
my $input = CGI->new(); |
38 |
|
38 |
|
39 |
checkauth($input, 0, { reserveforothers => 'place_holds' }, 'intranet'); |
39 |
my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( |
40 |
|
40 |
{ |
41 |
my @bibitems = $input->multi_param('biblioitem'); |
41 |
template_name => "reserve/placerequest.tt", |
42 |
my @reqbib = $input->multi_param('reqbib'); |
42 |
query => $input, |
43 |
my $biblionumber = $input->param('biblionumber'); |
43 |
type => "intranet", |
44 |
my $borrowernumber = $input->param('borrowernumber'); |
44 |
authnotrequired => 0, |
45 |
my $notes = $input->param('notes'); |
45 |
flagsrequired => { reserveforothers => 'place_holds' }, |
46 |
my $branch = $input->param('pickup'); |
46 |
} |
47 |
my $startdate = $input->param('reserve_date') || ''; |
47 |
); |
48 |
my @rank = $input->multi_param('rank-request'); |
48 |
|
49 |
my $type = $input->param('type'); |
49 |
my $biblionumber=$input->param('biblionumber'); |
50 |
my $title = $input->param('title'); |
50 |
my $borrowernumber=$input->param('borrowernumber'); |
51 |
my $checkitem = $input->param('checkitem'); |
51 |
my $notes=$input->param('notes'); |
|
|
52 |
my $branch=$input->param('pickup'); |
53 |
my $startdate=$input->param('reserve_date') || ''; |
54 |
my @rank=$input->param('rank-request'); |
55 |
my $title=$input->param('title'); |
56 |
my $checkitem=$input->param('checkitem'); |
52 |
my $expirationdate = $input->param('expiration_date'); |
57 |
my $expirationdate = $input->param('expiration_date'); |
53 |
my $itemtype = $input->param('itemtype') || undef; |
58 |
my $itemtype = $input->param('itemtype') || undef; |
54 |
|
59 |
my $confirm = $input->param('confirm'); |
55 |
my $borrower = Koha::Patrons->find( $borrowernumber ); |
60 |
my @confirm_biblionumbers = $input->param('confirm_biblionumbers'); |
56 |
$borrower = $borrower->unblessed if $borrower; |
|
|
57 |
|
61 |
|
58 |
my $multi_hold = $input->param('multi_hold'); |
62 |
my $multi_hold = $input->param('multi_hold'); |
59 |
my $biblionumbers = $multi_hold ? $input->param('biblionumbers') : ($biblionumber . '/'); |
63 |
my $biblionumbers = $multi_hold ? $input->param('biblionumbers') : ($biblionumber . '/'); |
60 |
my $bad_bibs = $input->param('bad_bibs'); |
64 |
my $bad_bibs = $input->param('bad_bibs'); |
61 |
my $holds_to_place_count = $input->param('holds_to_place_count') || 1; |
65 |
my $holds_to_place_count = $input->param('holds_to_place_count') || 1; |
62 |
|
66 |
|
|
|
67 |
my $borrower = Koha::Patrons->find( $borrowernumber ); |
68 |
$borrower = $borrower->unblessed if $borrower; |
69 |
unless ($borrower) { |
70 |
print $input->header(); |
71 |
print "Invalid borrower number please try again"; |
72 |
exit; |
73 |
} |
74 |
|
63 |
my %bibinfos = (); |
75 |
my %bibinfos = (); |
64 |
my @biblionumbers = split '/', $biblionumbers; |
76 |
my @biblionumbers = split '/', $biblionumbers; |
65 |
foreach my $bibnum (@biblionumbers) { |
77 |
foreach my $bibnum (@biblionumbers) { |
66 |
my %bibinfo = (); |
78 |
my %bibinfo; |
67 |
$bibinfo{title} = $input->param("title_$bibnum"); |
79 |
$bibinfo{title} = $input->param("title_$bibnum"); |
|
|
80 |
|
68 |
$bibinfo{rank} = $input->param("rank_$bibnum"); |
81 |
$bibinfo{rank} = $input->param("rank_$bibnum"); |
69 |
$bibinfos{$bibnum} = \%bibinfo; |
82 |
$bibinfos{$bibnum} = \%bibinfo; |
70 |
} |
83 |
} |
71 |
|
84 |
|
72 |
my $found; |
85 |
my $found; |
73 |
|
86 |
|
74 |
# if we have an item selectionned, and the pickup branch is the same as the holdingbranch |
87 |
# if we have an item selectionned, and the pickup branch is the same as the |
75 |
# of the document, we force the value $rank and $found . |
88 |
# holdingbranch of the document, we force the value $rank and $found . |
76 |
if (defined $checkitem && $checkitem ne ''){ |
89 |
if (defined $checkitem && $checkitem ne ''){ |
77 |
$holds_to_place_count = 1; |
90 |
$holds_to_place_count = 1; |
78 |
$rank[0] = '0' unless C4::Context->preference('ReservesNeedReturns'); |
91 |
$rank[0] = '0' unless C4::Context->preference('ReservesNeedReturns'); |
Lines 83-125
if (defined $checkitem && $checkitem ne ''){
Link Here
|
83 |
} |
96 |
} |
84 |
} |
97 |
} |
85 |
|
98 |
|
86 |
if ( $type eq 'str8' && $borrower ) { |
99 |
my $overlap_reserves = {}; |
87 |
|
100 |
foreach my $biblionumber (keys %bibinfos) { |
88 |
foreach my $biblionumber ( keys %bibinfos ) { |
101 |
next if ($confirm && !grep { $_ eq $biblionumber } @confirm_biblionumbers); |
89 |
my $count = @bibitems; |
|
|
90 |
@bibitems = sort @bibitems; |
91 |
my $i2 = 1; |
92 |
my @realbi; |
93 |
$realbi[0] = $bibitems[0]; |
94 |
for ( my $i = 1 ; $i < $count ; $i++ ) { |
95 |
my $i3 = $i2 - 1; |
96 |
if ( $realbi[$i3] ne $bibitems[$i] ) { |
97 |
$realbi[$i2] = $bibitems[$i]; |
98 |
$i2++; |
99 |
} |
100 |
} |
101 |
|
102 |
|
102 |
if ( defined $checkitem && $checkitem ne '' ) { |
103 |
my ($reserve_title, $reserve_rank); |
103 |
my $item = GetItem($checkitem); |
104 |
if ($multi_hold) { |
104 |
if ( $item->{'biblionumber'} ne $biblionumber ) { |
105 |
my $bibinfo = $bibinfos{$biblionumber}; |
105 |
$biblionumber = $item->{'biblionumber'}; |
106 |
$reserve_rank = $bibinfo->{rank}; |
106 |
} |
107 |
$reserve_title = $bibinfo->{title}; |
107 |
} |
108 |
} else { |
|
|
109 |
$reserve_rank = $rank[0]; |
110 |
$reserve_title = $title; |
111 |
} |
108 |
|
112 |
|
109 |
if ($multi_hold) { |
113 |
if (defined $checkitem && $checkitem ne '') { |
110 |
my $bibinfo = $bibinfos{$biblionumber}; |
114 |
my $item = GetItem($checkitem); |
111 |
AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,[$biblionumber], |
115 |
if ($item->{'biblionumber'} ne $biblionumber) { |
112 |
$bibinfo->{rank},$startdate,$expirationdate,$notes,$bibinfo->{title},$checkitem,$found); |
116 |
$biblionumber = $item->{'biblionumber'}; |
113 |
} else { |
|
|
114 |
# place a request on 1st available |
115 |
for ( my $i = 0 ; $i < $holds_to_place_count ; $i++ ) { |
116 |
AddReserve( $branch, $borrower->{'borrowernumber'}, |
117 |
$biblionumber, \@realbi, $rank[0], $startdate, $expirationdate, $notes, $title, |
118 |
$checkitem, $found, $itemtype ); |
119 |
} |
120 |
} |
117 |
} |
121 |
} |
118 |
} |
122 |
|
119 |
|
|
|
120 |
if (!$confirm && |
121 |
ReservesOnSamePeriod($biblionumber, $checkitem, $startdate, $expirationdate) && |
122 |
C4::Context->preference("PreventReservesOnSamePeriod")) { |
123 |
$overlap_reserves->{$biblionumber} = { |
124 |
title => $reserve_title , |
125 |
checkitem => $checkitem, |
126 |
rank => $reserve_rank |
127 |
}; |
128 |
next; |
129 |
} |
130 |
|
131 |
AddReserve($branch, $borrower->{'borrowernumber'}, $biblionumber, undef, |
132 |
$reserve_rank, $startdate, $expirationdate, $notes, $reserve_title, |
133 |
$checkitem, $found); |
134 |
} |
135 |
|
136 |
if (scalar keys %$overlap_reserves) { |
137 |
$template->param( |
138 |
borrowernumber => $borrowernumber, |
139 |
biblionumbers => $biblionumbers, |
140 |
biblionumber => $biblionumber, |
141 |
overlap_reserves => $overlap_reserves, |
142 |
reserve_date => $startdate, |
143 |
expiration_date => $expirationdate, |
144 |
notes => $notes, |
145 |
rank_request => \@rank, |
146 |
pickup => $branch, |
147 |
multi_hold => $multi_hold, |
148 |
); |
149 |
|
150 |
output_html_with_http_headers $input, $cookie, $template->output; |
151 |
} else { |
123 |
if ($multi_hold) { |
152 |
if ($multi_hold) { |
124 |
if ($bad_bibs) { |
153 |
if ($bad_bibs) { |
125 |
$biblionumbers .= $bad_bibs; |
154 |
$biblionumbers .= $bad_bibs; |
Lines 129-140
if ( $type eq 'str8' && $borrower ) {
Link Here
|
129 |
else { |
158 |
else { |
130 |
print $input->redirect("request.pl?biblionumber=$biblionumber"); |
159 |
print $input->redirect("request.pl?biblionumber=$biblionumber"); |
131 |
} |
160 |
} |
132 |
} |
161 |
exit; |
133 |
elsif ( $borrowernumber eq '' ) { |
|
|
134 |
print $input->header(); |
135 |
print "Invalid borrower number please try again"; |
136 |
|
137 |
# Not sure that Dump() does HTML escaping. Use firebug or something to trace |
138 |
# instead. |
139 |
#print $input->Dump; |
140 |
} |
162 |
} |