BZ 4028 : OPAC search history available to non-logged-in users
[koha.git] / reserve / placerequest.pl
blobb299c174026b2f9379167de3ad832ba604b0e1be
1 #!/usr/bin/perl
3 #script to place reserves/requests
4 #writen 2/1/00 by chris@katipo.oc.nz
7 # Copyright 2000-2002 Katipo Communications
9 # This file is part of Koha.
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License along with
21 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA 02111-1307 USA
24 use strict;
25 use warnings;
26 use C4::Biblio;
27 use C4::Items;
28 use CGI;
29 use C4::Output;
30 use C4::Reserves;
31 use C4::Circulation;
32 use C4::Members;
34 my $input = new CGI;
35 #print $input->header;
38 my @bibitems=$input->param('biblioitem');
39 # FIXME I think reqbib does not exist anymore, it's used in line 82, to AddReserve of contraint type 'o'
40 # I bet it's a 2.x feature, reserving a given biblioitem, that is useless in Koha 3.0
41 # we can remove this line, the AddReserve of constrainttype 'o',
42 # and probably remove the reserveconstraint table as well, I never could fill anything in this table.
43 my @reqbib=$input->param('reqbib');
44 my $biblionumber=$input->param('biblionumber');
45 my $borrower=$input->param('member');
46 my $notes=$input->param('notes');
47 my $branch=$input->param('pickup');
48 my $startdate=$input->param('reserve_date') || '';
49 my @rank=$input->param('rank-request');
50 my $type=$input->param('type');
51 my $title=$input->param('title');
52 my $borrowernumber=GetMember('cardnumber'=>$borrower);
53 my $checkitem=$input->param('checkitem');
55 my $multi_hold = $input->param('multi_hold');
56 my $biblionumbers = $multi_hold ? $input->param('biblionumbers') : ($biblionumber . '/');
57 my $bad_bibs = $input->param('bad_bibs');
59 my %bibinfos = ();
60 my @biblionumbers = split '/', $biblionumbers;
61 foreach my $bibnum (@biblionumbers) {
62 my %bibinfo = ();
63 $bibinfo{title} = $input->param("title_$bibnum");
64 $bibinfo{rank} = $input->param("rank_$bibnum");
65 $bibinfos{$bibnum} = \%bibinfo;
68 my $found;
70 # if we have an item selectionned, and the pickup branch is the same as the holdingbranch
71 # of the document, we force the value $rank and $found .
72 if ($checkitem ne ''){
73 $rank[0] = '0' unless C4::Context->preference('ReservesNeedReturns');
74 my $item = $checkitem;
75 $item = GetItem($item);
76 if ( $item->{'holdingbranch'} eq $branch ){
77 $found = 'W' unless C4::Context->preference('ReservesNeedReturns');
81 if ($type eq 'str8' && $borrowernumber ne ''){
83 foreach my $biblionumber (keys %bibinfos) {
84 my $count=@bibitems;
85 @bibitems=sort @bibitems;
86 my $i2=1;
87 my @realbi;
88 $realbi[0]=$bibitems[0];
89 for (my $i=1;$i<$count;$i++) {
90 my $i3=$i2-1;
91 if ($realbi[$i3] ne $bibitems[$i]) {
92 $realbi[$i2]=$bibitems[$i];
93 $i2++;
96 my $const;
98 if ($multi_hold) {
99 my $bibinfo = $bibinfos{$biblionumber};
100 AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'a',[$biblionumber],
101 $bibinfo->{rank},$startdate,$notes,$bibinfo->{title},$checkitem,$found);
102 } else {
103 if ($input->param('request') eq 'any'){
104 # place a request on 1st available
105 AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'a',\@realbi,$rank[0],$startdate,$notes,$title,$checkitem,$found);
106 } elsif ($reqbib[0] ne ''){
107 # FIXME : elsif probably never reached, (see top of the script)
108 # place a request on a given item
109 AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'o',\@reqbib,$rank[0],$startdate,$notes,$title,$checkitem, $found);
110 } else {
111 AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'a',\@realbi,$rank[0],$startdate,$notes,$title,$checkitem, $found);
116 if ($multi_hold) {
117 if ($bad_bibs) {
118 $biblionumbers .= $bad_bibs;
120 print $input->redirect("request.pl?biblionumbers=$biblionumbers&multi_hold=1");
121 } else {
122 print $input->redirect("request.pl?biblionumber=$biblionumber");
124 } elsif ($borrowernumber eq ''){
125 print $input->header();
126 print "Invalid card number please try again";
127 print $input->Dump;