View | Details | Raw Unified | Return to bug 37587
Collapse All | Expand All

(-)a/reserve/placerequest.pl (-20 / +16 lines)
Lines 3-9 Link Here
3
#script to place reserves/requests
3
#script to place reserves/requests
4
#written 2/1/00 by chris@katipo.oc.nz
4
#written 2/1/00 by chris@katipo.oc.nz
5
5
6
7
# Copyright 2000-2002 Katipo Communications
6
# Copyright 2000-2002 Katipo Communications
8
#
7
#
9
# This file is part of Koha.
8
# This file is part of Koha.
Lines 26-42 use Modern::Perl; Link Here
26
use CGI qw ( -utf8 );
25
use CGI qw ( -utf8 );
27
use URI;
26
use URI;
28
use C4::Reserves qw( CanItemBeReserved AddReserve CanBookBeReserved );
27
use C4::Reserves qw( CanItemBeReserved AddReserve CanBookBeReserved );
29
use C4::Auth qw( checkauth );
28
use C4::Auth     qw( checkauth );
30
29
31
use Koha::Items;
30
use Koha::Items;
32
use Koha::Patrons;
31
use Koha::Patrons;
33
32
34
my $input = CGI->new();
33
my $input = CGI->new();
35
34
36
checkauth($input, 0, { reserveforothers => 'place_holds' }, 'intranet');
35
checkauth( $input, 0, { reserveforothers => 'place_holds' }, 'intranet' );
37
36
38
my @reqbib         = $input->multi_param('reqbib');
37
my @reqbib         = $input->multi_param('reqbib');
39
my @biblionumbers   = $input->multi_param('biblionumber');
38
my @biblionumbers  = $input->multi_param('biblionumber');
40
my @holdable_bibs  = $input->multi_param('holdable_bibs');
39
my @holdable_bibs  = $input->multi_param('holdable_bibs');
41
my $borrowernumber = $input->param('borrowernumber');
40
my $borrowernumber = $input->param('borrowernumber');
42
my $notes          = $input->param('notes');
41
my $notes          = $input->param('notes');
Lines 44-50 my $branch = $input->param('pickup'); Link Here
44
my $startdate      = $input->param('reserve_date') || '';
43
my $startdate      = $input->param('reserve_date') || '';
45
my @rank           = $input->multi_param('rank-request');
44
my @rank           = $input->multi_param('rank-request');
46
my $title          = $input->param('title');
45
my $title          = $input->param('title');
47
my @checkitems = $input->multi_param('checkitem');
46
my @checkitems     = $input->multi_param('checkitem');
48
my $item_group_id  = $input->param('item_group_id');
47
my $item_group_id  = $input->param('item_group_id');
49
my $expirationdate = $input->param('expiration_date');
48
my $expirationdate = $input->param('expiration_date');
50
my $itemtype       = $input->param('itemtype') || undef;
49
my $itemtype       = $input->param('itemtype') || undef;
Lines 52-78 my $non_priority = $input->param('non_priority'); Link Here
52
my $op             = $input->param('op') || q{};
51
my $op             = $input->param('op') || q{};
53
my $multi_holds    = $input->param('multi_holds');
52
my $multi_holds    = $input->param('multi_holds');
54
53
55
my $patron = Koha::Patrons->find( $borrowernumber );
54
my $patron = Koha::Patrons->find($borrowernumber);
56
55
57
my $holds_to_place_count = $input->param('holds_to_place_count') || 1;
56
my $holds_to_place_count = $input->param('holds_to_place_count') || 1;
58
57
59
my %bibinfos = ();
58
my %bibinfos = ();
60
foreach my $bibnum ( @holdable_bibs ) {
59
foreach my $bibnum (@holdable_bibs) {
61
    my %bibinfo = ();
60
    my %bibinfo = ();
62
    $bibinfo{title}  = $input->param("title_$bibnum");
61
    $bibinfo{title}    = $input->param("title_$bibnum");
63
    $bibinfo{rank}   = $input->param("rank_$bibnum");
62
    $bibinfo{rank}     = $input->param("rank_$bibnum");
64
    $bibinfo{pickup} = $input->param("pickup_$bibnum");
63
    $bibinfo{pickup}   = $input->param("pickup_$bibnum");
65
    $bibinfos{$bibnum} = \%bibinfo;
64
    $bibinfos{$bibnum} = \%bibinfo;
66
}
65
}
67
66
68
69
70
if ( $op eq 'cud-placerequest' && $patron ) {
67
if ( $op eq 'cud-placerequest' && $patron ) {
71
    my %failed_holds;
68
    my %failed_holds;
72
    foreach my $biblionumber ( keys %bibinfos ) {
69
    foreach my $biblionumber ( keys %bibinfos ) {
73
70
74
        my $can_override = C4::Context->preference('AllowHoldPolicyOverride');
71
        my $can_override = C4::Context->preference('AllowHoldPolicyOverride');
75
        if ( @checkitems ) {
72
        if (@checkitems) {
76
73
77
            my $hold_priority = $rank[0];
74
            my $hold_priority = $rank[0];
78
75
Lines 116-124 if ( $op eq 'cud-placerequest' && $patron ) { Link Here
116
                }
113
                }
117
            }
114
            }
118
115
119
        } elsif (@biblionumbers > 1 || $multi_holds) {
116
        } elsif ( @biblionumbers > 1 || $multi_holds ) {
120
            my $bibinfo = $bibinfos{$biblionumber};
117
            my $bibinfo = $bibinfos{$biblionumber};
121
            if ( $can_override || CanBookBeReserved($patron->borrowernumber, $biblionumber)->{status} eq 'OK' ) {
118
            if ( $can_override || CanBookBeReserved( $patron->borrowernumber, $biblionumber )->{status} eq 'OK' ) {
122
                AddReserve(
119
                AddReserve(
123
                    {
120
                    {
124
                        branchcode       => $bibinfo->{pickup},
121
                        branchcode       => $bibinfo->{pickup},
Lines 137-145 if ( $op eq 'cud-placerequest' && $patron ) { Link Here
137
                );
134
                );
138
            }
135
            }
139
        } else {
136
        } else {
137
140
            # place a request on 1st available
138
            # place a request on 1st available
141
            for ( my $i = 0 ; $i < $holds_to_place_count ; $i++ ) {
139
            for ( my $i = 0 ; $i < $holds_to_place_count ; $i++ ) {
142
                if ( $can_override || CanBookBeReserved($patron->borrowernumber, $biblionumber)->{status} eq 'OK' ) {
140
                if ( $can_override || CanBookBeReserved( $patron->borrowernumber, $biblionumber )->{status} eq 'OK' ) {
143
                    AddReserve(
141
                    AddReserve(
144
                        {
142
                        {
145
                            branchcode       => $branch,
143
                            branchcode       => $branch,
Lines 162-168 if ( $op eq 'cud-placerequest' && $patron ) { Link Here
162
        }
160
        }
163
    }
161
    }
164
162
165
    my $redirect_url = URI->new("request.pl");
163
    my $redirect_url     = URI->new("request.pl");
166
    my @failed_hold_msgs = ();
164
    my @failed_hold_msgs = ();
167
165
168
    #NOTE: Deduplicate failed hold reason statuses/codes
166
    #NOTE: Deduplicate failed hold reason statuses/codes
Lines 171-178 if ( $op eq 'cud-placerequest' && $patron ) { Link Here
171
    }
169
    }
172
    $redirect_url->query_form( biblionumber => [@biblionumbers], failed_holds => \@failed_hold_msgs );
170
    $redirect_url->query_form( biblionumber => [@biblionumbers], failed_holds => \@failed_hold_msgs );
173
    print $input->redirect($redirect_url);
171
    print $input->redirect($redirect_url);
174
}
172
} elsif ( $borrowernumber eq '' ) {
175
elsif ( $borrowernumber eq '' ) {
176
    print $input->header();
173
    print $input->header();
177
    print "Invalid borrower number please try again";
174
    print "Invalid borrower number please try again";
178
175
179
- 

Return to bug 37587