3 # Copyright 2013 ByWater Solutions
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 use C4
::Auth qw
/:DEFAULT get_session/;
30 use Koha
::BiblioFrameworks
;
34 my ( $template, $librarian, $cookie, $flags ) = get_template_and_user
(
36 template_name
=> "circ/renew.tt",
40 flagsrequired
=> { circulate
=> "circulate_remaining_permissions" },
44 my $schema = Koha
::Database
->new()->schema();
46 my $barcode = $cgi->param('barcode');
47 $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespae
48 $barcode = barcodedecode
($barcode) if( $barcode && C4
::Context
->preference('itemBarcodeInputFilter'));
49 my $override_limit = $cgi->param('override_limit');
50 my $override_holds = $cgi->param('override_holds');
52 my ( $item, $issue, $borrower );
54 my ( $soonest_renew_date, $latest_auto_renew_date );
57 $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
58 $item = $schema->resultset("Item")->single( { barcode
=> $barcode } );
62 $issue = $item->issue();
66 $borrower = $issue->borrower();
68 if ( ( $borrower->debarred() || q{} ) lt dt_from_string
()->ymd() ) {
70 ( $can_renew, $error ) =
71 CanBookBeRenewed
( $borrower->borrowernumber(),
72 $item->itemnumber(), $override_limit );
74 if ( $error && ($error eq 'on_reserve') ) {
75 if ($override_holds) {
84 if ( $error && ($error eq 'too_soon' or $error eq 'auto_too_soon') ) {
85 $soonest_renew_date = C4
::Circulation
::GetSoonestRenewDate
(
86 $borrower->borrowernumber(),
90 if ( $error && ( $error eq 'auto_too_late' ) ) {
91 $latest_auto_renew_date = C4
::Circulation
::GetLatestAutoRenewDate
(
92 $borrower->borrowernumber(),
97 my $branchcode = C4
::Context
->userenv ? C4
::Context
->userenv->{'branch'} : undef;
99 if ( $cgi->param('renewonholdduedate') ) {
100 $date_due = dt_from_string
( scalar $cgi->param('renewonholdduedate'));
102 $date_due = AddRenewal
( undef, $item->itemnumber(), $branchcode, $date_due );
103 $template->param( date_due
=> $date_due );
107 $error = "patron_restricted";
111 $error = "no_checkout";
121 borrower
=> $borrower,
123 soonestrenewdate
=> $soonest_renew_date,
124 latestautorenewdate
=> $latest_auto_renew_date,
128 # Checking if there is a Fast Cataloging Framework
129 $template->param( fast_cataloging
=> 1 ) if Koha
::BiblioFrameworks
->find( 'FA' );
131 output_html_with_http_headers
( $cgi, $cookie, $template->output );