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