Bug 8851 - strange blue bar above serials results
[koha.git] / reserve / renewscript.pl
blobdbdced9c809712b0cf52207d6a9e45c7b7b77c4d
1 #!/usr/bin/perl
3 #written 18/1/2000 by chris@katipo.co.nz
4 #script to renew items from the web
6 # Copyright 2000-2002 Katipo Communications
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
13 # version.
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along
20 # with Koha; if not, write to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 use strict;
23 use warnings;
24 use CGI;
25 use C4::Circulation;
26 use C4::Context;
27 use C4::Items;
28 use C4::Auth;
29 use URI::Escape;
30 use Koha::DateUtils;
31 my $input = new CGI;
33 #Set Up User_env
34 # And assures user is loggedin and has correct accreditations.
36 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
38 template_name => "members/moremember.tmpl",
39 query => $input,
40 type => "intranet",
41 authnotrequired => 0,
42 flagsrequired => { circulate => 'circulate_remaining_permissions' },
43 debug => 0,
48 # find items to renew, all items or a selection of items
51 my @data;
52 if ( $input->param('renew_all') ) {
53 @data = $input->param('all_items[]');
55 else {
56 @data = $input->param('items[]');
59 my @barcodes;
60 if ( $input->param('return_all') ) {
61 @barcodes = $input->param('all_barcodes[]');
63 else {
64 @barcodes = $input->param('barcodes[]');
67 my $branch = $input->param('branch');
68 my $datedue;
69 if ( $input->param('newduedate') ) {
70 $datedue = dt_from_string( $input->param('newduedate') );
71 $datedue->set_hour(23);
72 $datedue->set_minute(59);
75 # warn "barcodes : @barcodes";
77 # renew items
79 my $cardnumber = $input->param("cardnumber");
80 my $borrowernumber = $input->param("borrowernumber");
81 my $exemptfine = $input->param("exemptfine") || 0;
82 my $override_limit = $input->param("override_limit") || 0;
83 my $failedrenews = q{};
84 foreach my $itemno (@data) {
86 # check status before renewing issue
87 my ( $renewokay, $error ) =
88 CanBookBeRenewed( $borrowernumber, $itemno, $override_limit );
89 if ($renewokay) {
90 AddRenewal( $borrowernumber, $itemno, $branch, $datedue );
92 else {
93 $failedrenews .= "&failedrenew=$itemno";
96 my $failedreturn = q{};
97 foreach my $barcode (@barcodes) {
99 # check status before renewing issue
101 #System Preference Handling During Check-in In Patron Module
102 my $itemnumber;
103 $itemnumber = GetItemnumberFromBarcode($barcode);
104 if ($itemnumber) {
105 if ( C4::Context->preference("InProcessingToShelvingCart") ) {
106 my $item = GetItem($itemnumber);
107 if ( $item->{'location'} eq 'PROC' ) {
108 $item->{'location'} = 'CART';
109 ModItem( $item, $item->{'biblionumber'},
110 $item->{'itemnumber'} );
114 if ( C4::Context->preference("ReturnToShelvingCart") ) {
115 my $item = GetItem($itemnumber);
116 $item->{'location'} = 'CART';
117 ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} );
121 my ( $returned, $messages, $issueinformation, $borrower ) =
122 AddReturn( $barcode, $branch, $exemptfine );
123 $failedreturn .= "&failedreturn=$barcode" unless ($returned);
127 # redirection to the referrer page
129 if ( $input->param('destination') eq "circ" ) {
130 $cardnumber = uri_escape($cardnumber);
131 print $input->redirect( '/cgi-bin/koha/circ/circulation.pl?findborrower='
132 . $cardnumber
133 . $failedrenews
134 . $failedreturn );
136 else {
137 print $input->redirect(
138 '/cgi-bin/koha/members/moremember.pl?borrowernumber='
139 . $borrowernumber
140 . $failedrenews
141 . $failedreturn );