Translation updates for Koha 3.22.0 release
[koha.git] / reserve / renewscript.pl
blobac31e166071df82d293c41dbb2a5fb033701c6f0
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
11 # under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
15 # Koha is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use strict;
23 use warnings;
24 use CGI qw ( -utf8 );
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.tt",
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 returning 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_utf8($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 );