Backing down the required version of Graphics::Magick
[koha.git] / reserve / placerequest.pl
blob36f8ecd1f0d1a6e9bc82294ed0a839470682216c
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
21 # with Koha; if not, write to the Free Software Foundation, Inc.,
22 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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');
54 my $expirationdate = $input->param('expiration_date');
56 my $multi_hold = $input->param('multi_hold');
57 my $biblionumbers = $multi_hold ? $input->param('biblionumbers') : ($biblionumber . '/');
58 my $bad_bibs = $input->param('bad_bibs');
60 my %bibinfos = ();
61 my @biblionumbers = split '/', $biblionumbers;
62 foreach my $bibnum (@biblionumbers) {
63 my %bibinfo = ();
64 $bibinfo{title} = $input->param("title_$bibnum");
65 $bibinfo{rank} = $input->param("rank_$bibnum");
66 $bibinfos{$bibnum} = \%bibinfo;
69 my $found;
71 # if we have an item selectionned, and the pickup branch is the same as the holdingbranch
72 # of the document, we force the value $rank and $found .
73 if ($checkitem ne ''){
74 $rank[0] = '0' unless C4::Context->preference('ReservesNeedReturns');
75 my $item = $checkitem;
76 $item = GetItem($item);
77 if ( $item->{'holdingbranch'} eq $branch ){
78 $found = 'W' unless C4::Context->preference('ReservesNeedReturns');
82 if ($type eq 'str8' && $borrowernumber ne ''){
84 foreach my $biblionumber (keys %bibinfos) {
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++;
97 my $const;
99 if ($multi_hold) {
100 my $bibinfo = $bibinfos{$biblionumber};
101 AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'a',[$biblionumber],
102 $bibinfo->{rank},$startdate,$expirationdate,$notes,$bibinfo->{title},$checkitem,$found);
103 } else {
104 if ($input->param('request') eq 'any'){
105 # place a request on 1st available
106 AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'a',\@realbi,$rank[0],$startdate,$expirationdate,$notes,$title,$checkitem,$found);
107 } elsif ($reqbib[0] ne ''){
108 # FIXME : elsif probably never reached, (see top of the script)
109 # place a request on a given item
110 AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'o',\@reqbib,$rank[0],$startdate,$expirationdate,$notes,$title,$checkitem, $found);
111 } else {
112 AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'a',\@realbi,$rank[0],$startdate,$expirationdate,$notes,$title,$checkitem, $found);
117 if ($multi_hold) {
118 if ($bad_bibs) {
119 $biblionumbers .= $bad_bibs;
121 print $input->redirect("request.pl?biblionumbers=$biblionumbers&multi_hold=1");
122 } else {
123 print $input->redirect("request.pl?biblionumber=$biblionumber");
125 } elsif ($borrowernumber eq ''){
126 print $input->header();
127 print "Invalid card number please try again";
128 print $input->Dump;