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