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