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

(-)a/C4/Circulation.pm (-4 / +50 lines)
Lines 2745-2750 sub CanBookBeRenewed { Link Here
2745
    return ( 0, "too_many" )
2745
    return ( 0, "too_many" )
2746
      if not $issuing_rule or $issuing_rule->renewalsallowed <= $issue->renewals;
2746
      if not $issuing_rule or $issuing_rule->renewalsallowed <= $issue->renewals;
2747
2747
2748
    return ( 0, "too_unseen" )
2749
      if C4::Context->preference('UnseenRenewals') &&
2750
        $issuing_rule->unseen_renewals_allowed &&
2751
        $issuing_rule->unseen_renewals_allowed <= $issue->unseen_renewals;
2752
2748
    my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
2753
    my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
2749
    my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
2754
    my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
2750
    $patron         = Koha::Patrons->find($borrowernumber); # FIXME Is this really useful?
2755
    $patron         = Koha::Patrons->find($borrowernumber); # FIXME Is this really useful?
Lines 2835-2841 sub CanBookBeRenewed { Link Here
2835
2840
2836
=head2 AddRenewal
2841
=head2 AddRenewal
2837
2842
2838
  &AddRenewal($borrowernumber, $itemnumber, $branch, [$datedue], [$lastreneweddate]);
2843
  &AddRenewal($borrowernumber, $itemnumber, $branch, [$datedue], [$lastreneweddate], [$seen]);
2839
2844
2840
Renews a loan.
2845
Renews a loan.
2841
2846
Lines 2855-2860 this parameter is not supplied, lastreneweddate is set to the current date. Link Here
2855
If C<$datedue> is the empty string, C<&AddRenewal> will calculate the due date automatically
2860
If C<$datedue> is the empty string, C<&AddRenewal> will calculate the due date automatically
2856
from the book's item type.
2861
from the book's item type.
2857
2862
2863
C<$seen> is a boolean flag indicating if the item was seen or not during the renewal. This
2864
informs the incrementing of the unseen_renewals column. If this flag is not supplied, we
2865
fallback to a true value
2866
2858
=cut
2867
=cut
2859
2868
2860
sub AddRenewal {
2869
sub AddRenewal {
Lines 2863-2868 sub AddRenewal { Link Here
2863
    my $branch          = shift;
2872
    my $branch          = shift;
2864
    my $datedue         = shift;
2873
    my $datedue         = shift;
2865
    my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz);
2874
    my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz);
2875
    my $seen            = shift;
2876
2877
    # Fallback on a 'seen' renewal
2878
    $seen = defined $seen && $seen == 0 ? 0 : 1;
2866
2879
2867
    my $item_object   = Koha::Items->find($itemnumber) or return;
2880
    my $item_object   = Koha::Items->find($itemnumber) or return;
2868
    my $biblio = $item_object->biblio;
2881
    my $biblio = $item_object->biblio;
Lines 2915-2929 sub AddRenewal { Link Here
2915
            }
2928
            }
2916
        );
2929
        );
2917
2930
2931
        # Increment the unseen renewals, if appropriate
2932
        # We only do so if the syspref is enabled and
2933
        # a maximum value has been set in the circ rules
2934
        my $unseen_renewals = $issue->unseen_renewals;
2935
        if (C4::Context->preference('UnseenRenewals')) {
2936
            my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule(
2937
                {   categorycode => $patron->categorycode,
2938
                    itemtype     => $item_object->effective_itemtype,
2939
                    branchcode   => $circ_library->branchcode
2940
                }
2941
            );
2942
            if (!$seen && $issuing_rule && $issuing_rule->unseen_renewals_allowed) {
2943
                $unseen_renewals++;
2944
            } else {
2945
                # If the renewal is seen, unseen should revert to 0
2946
                $unseen_renewals = 0;
2947
            }
2948
        }
2949
2918
        # Update the issues record to have the new due date, and a new count
2950
        # Update the issues record to have the new due date, and a new count
2919
        # of how many times it has been renewed.
2951
        # of how many times it has been renewed.
2920
        my $renews = $issue->renewals + 1;
2952
        my $renews = $issue->renewals + 1;
2921
        my $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, lastreneweddate = ?
2953
        my $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, unseen_renewals = ?, lastreneweddate = ?
2922
                                WHERE borrowernumber=?
2954
                                WHERE borrowernumber=?
2923
                                AND itemnumber=?"
2955
                                AND itemnumber=?"
2924
        );
2956
        );
2925
2957
2926
        $sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $lastreneweddate, $borrowernumber, $itemnumber );
2958
        $sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $unseen_renewals, $lastreneweddate, $borrowernumber, $itemnumber );
2927
2959
2928
        # Update the renewal count on the item, and tell zebra to reindex
2960
        # Update the renewal count on the item, and tell zebra to reindex
2929
        $renews = $item_object->renewals + 1;
2961
        $renews = $item_object->renewals + 1;
Lines 3005-3012 sub GetRenewCount { Link Here
3005
    my ( $bornum, $itemno ) = @_;
3037
    my ( $bornum, $itemno ) = @_;
3006
    my $dbh           = C4::Context->dbh;
3038
    my $dbh           = C4::Context->dbh;
3007
    my $renewcount    = 0;
3039
    my $renewcount    = 0;
3040
    my $unseencount    = 0;
3008
    my $renewsallowed = 0;
3041
    my $renewsallowed = 0;
3042
    my $unseenallowed = 0;
3009
    my $renewsleft    = 0;
3043
    my $renewsleft    = 0;
3044
    my $unseenleft    = 0;
3010
3045
3011
    my $patron = Koha::Patrons->find( $bornum );
3046
    my $patron = Koha::Patrons->find( $bornum );
3012
    my $item   = Koha::Items->find($itemno);
3047
    my $item   = Koha::Items->find($itemno);
Lines 3025-3030 sub GetRenewCount { Link Here
3025
    $sth->execute( $bornum, $itemno );
3060
    $sth->execute( $bornum, $itemno );
3026
    my $data = $sth->fetchrow_hashref;
3061
    my $data = $sth->fetchrow_hashref;
3027
    $renewcount = $data->{'renewals'} if $data->{'renewals'};
3062
    $renewcount = $data->{'renewals'} if $data->{'renewals'};
3063
    $unseencount = $data->{'unseen_renewals'} if $data->{'unseen_renewals'};
3028
    # $item and $borrower should be calculated
3064
    # $item and $borrower should be calculated
3029
    my $branchcode = _GetCircControlBranch($item->unblessed, $patron->unblessed);
3065
    my $branchcode = _GetCircControlBranch($item->unblessed, $patron->unblessed);
3030
3066
Lines 3036-3044 sub GetRenewCount { Link Here
3036
    );
3072
    );
3037
3073
3038
    $renewsallowed = $issuing_rule ? $issuing_rule->renewalsallowed : 0;
3074
    $renewsallowed = $issuing_rule ? $issuing_rule->renewalsallowed : 0;
3075
    $unseenallowed = $issuing_rule ? $issuing_rule->unseen_renewals_allowed : 0;
3039
    $renewsleft    = $renewsallowed - $renewcount;
3076
    $renewsleft    = $renewsallowed - $renewcount;
3077
    $unseenleft    = $unseenallowed - $unseencount;
3040
    if($renewsleft < 0){ $renewsleft = 0; }
3078
    if($renewsleft < 0){ $renewsleft = 0; }
3041
    return ( $renewcount, $renewsallowed, $renewsleft );
3079
    if($unseenleft < 0){ $unseenleft = 0; }
3080
    return (
3081
        $renewcount,
3082
        $renewsallowed,
3083
        $renewsleft,
3084
        $unseencount,
3085
        $unseenallowed,
3086
        $unseenleft
3087
    );
3042
}
3088
}
3043
3089
3044
=head2 GetSoonestRenewDate
3090
=head2 GetSoonestRenewDate
(-)a/C4/ILSDI/Services.pm (-1 / +1 lines)
Lines 644-650 sub RenewLoan { Link Here
644
644
645
    # Add renewal if possible
645
    # Add renewal if possible
646
    my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber );
646
    my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber );
647
    if ( $renewal[0] ) { AddRenewal( $borrowernumber, $itemnumber ); }
647
    if ( $renewal[0] ) { AddRenewal( $borrowernumber, $itemnumber, undef, undef, undef, 0 ); }
648
648
649
    my $issue = $item->checkout;
649
    my $issue = $item->checkout;
650
    return unless $issue; # FIXME should be handled
650
    return unless $issue; # FIXME should be handled
(-)a/C4/SIP/ILS/Transaction/Renew.pm (+1 lines)
Lines 51-56 sub do_renew_for { Link Here
51
    } else {
51
    } else {
52
        $renewerror=~s/on_reserve/Item unavailable due to outstanding holds/;
52
        $renewerror=~s/on_reserve/Item unavailable due to outstanding holds/;
53
        $renewerror=~s/too_many/Item has reached maximum renewals/;
53
        $renewerror=~s/too_many/Item has reached maximum renewals/;
54
        $renewerror=~s/too_unseen/Item has reached maximum consecutive renewals without being seen/;
54
        $renewerror=~s/item_denied_renewal/Item renewal is not allowed/;
55
        $renewerror=~s/item_denied_renewal/Item renewal is not allowed/;
55
        $self->screen_msg($renewerror);
56
        $self->screen_msg($renewerror);
56
        $self->renewal_ok(0);
57
        $self->renewal_ok(0);
(-)a/Koha/REST/V1/Checkouts.pm (-1 / +3 lines)
Lines 107-112 sub renew { Link Here
107
    my $c = shift->openapi->valid_input or return;
107
    my $c = shift->openapi->valid_input or return;
108
108
109
    my $checkout_id = $c->validation->param('checkout_id');
109
    my $checkout_id = $c->validation->param('checkout_id');
110
    my $seen = $c->validation->param('seen') || 1;
110
    my $checkout = Koha::Checkouts->find( $checkout_id );
111
    my $checkout = Koha::Checkouts->find( $checkout_id );
111
112
112
    unless ($checkout) {
113
    unless ($checkout) {
Lines 129-135 sub renew { Link Here
129
        );
130
        );
130
    }
131
    }
131
132
132
    AddRenewal($borrowernumber, $itemnumber, $checkout->branchcode);
133
    AddRenewal($borrowernumber, $itemnumber, $checkout->branchcode, undef, undef, $seen);
133
    $checkout = Koha::Checkouts->find($checkout_id);
134
    $checkout = Koha::Checkouts->find($checkout_id);
134
135
135
    $c->res->headers->location( $c->req->url->to_string );
136
    $c->res->headers->location( $c->req->url->to_string );
Lines 177-182 sub allows_renewal { Link Here
177
            allows_renewal => $renewable,
178
            allows_renewal => $renewable,
178
            max_renewals => $rule->renewalsallowed,
179
            max_renewals => $rule->renewalsallowed,
179
            current_renewals => $checkout->renewals,
180
            current_renewals => $checkout->renewals,
181
            unseen_renewals => $checkout->unseen_renewals,
180
            error => $error
182
            error => $error
181
        }
183
        }
182
    );
184
    );
(-)a/api/v1/swagger/definitions/checkout.json (+4 lines)
Lines 35-40 Link Here
35
      "type": ["integer", "null"],
35
      "type": ["integer", "null"],
36
      "description": "Number of renewals"
36
      "description": "Number of renewals"
37
    },
37
    },
38
    "unseen_renewals": {
39
      "type": ["integer", "null"],
40
      "description": "Number of consecutive unseen renewals"
41
    },
38
    "auto_renew": {
42
    "auto_renew": {
39
      "type": "boolean",
43
      "type": "boolean",
40
      "description": "Auto renewal"
44
      "description": "Auto renewal"
(-)a/api/v1/swagger/parameters.json (+3 lines)
Lines 29-34 Link Here
29
  "checkout_id_pp": {
29
  "checkout_id_pp": {
30
    "$ref": "parameters/checkout.json#/checkout_id_pp"
30
    "$ref": "parameters/checkout.json#/checkout_id_pp"
31
  },
31
  },
32
  "seen_pp": {
33
    "$ref": "parameters/checkout.json#/seen_pp"
34
  },
32
  "match": {
35
  "match": {
33
    "name": "_match",
36
    "name": "_match",
34
    "in": "query",
37
    "in": "query",
(-)a/api/v1/swagger/parameters/checkout.json (+7 lines)
Lines 5-9 Link Here
5
    "description": "Internal checkout identifier",
5
    "description": "Internal checkout identifier",
6
    "required": true,
6
    "required": true,
7
    "type": "integer"
7
    "type": "integer"
8
  },
9
  "seen_pp": {
10
    "name": "seen",
11
    "in": "query",
12
    "description": "Item was seen flag",
13
    "required": false,
14
    "type": "integer"
8
  }
15
  }
9
}
16
}
(-)a/api/v1/swagger/paths/checkouts.json (-3 / +4 lines)
Lines 81-89 Link Here
81
      "x-mojo-to": "Checkouts#renew",
81
      "x-mojo-to": "Checkouts#renew",
82
      "operationId": "renewCheckout",
82
      "operationId": "renewCheckout",
83
      "tags": ["patrons", "checkouts"],
83
      "tags": ["patrons", "checkouts"],
84
      "parameters": [{
84
      "parameters": [
85
        "$ref": "../parameters.json#/checkout_id_pp"
85
        { "$ref": "../parameters.json#/checkout_id_pp" },
86
      }],
86
        { "$ref": "../parameters.json#/seen_pp" }
87
      ],
87
      "produces": ["application/json"],
88
      "produces": ["application/json"],
88
      "responses": {
89
      "responses": {
89
        "201": {
90
        "201": {
(-)a/circ/renew.pl (-1 / +9 lines)
Lines 44-49 my ( $template, $librarian, $cookie, $flags ) = get_template_and_user( Link Here
44
my $schema = Koha::Database->new()->schema();
44
my $schema = Koha::Database->new()->schema();
45
45
46
my $barcode        = $cgi->param('barcode');
46
my $barcode        = $cgi->param('barcode');
47
my $unseen         = $cgi->param('unseen') || 0;
47
$barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespae
48
$barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespae
48
$barcode = barcodedecode($barcode) if( $barcode && C4::Context->preference('itemBarcodeInputFilter'));
49
$barcode = barcodedecode($barcode) if( $barcode && C4::Context->preference('itemBarcodeInputFilter'));
49
my $override_limit = $cgi->param('override_limit');
50
my $override_limit = $cgi->param('override_limit');
Lines 99-105 if ($barcode) { Link Here
99
                    if ( $cgi->param('renewonholdduedate') ) {
100
                    if ( $cgi->param('renewonholdduedate') ) {
100
                        $date_due = dt_from_string( scalar $cgi->param('renewonholdduedate'));
101
                        $date_due = dt_from_string( scalar $cgi->param('renewonholdduedate'));
101
                    }
102
                    }
102
                    $date_due = AddRenewal( undef, $item->itemnumber(), $branchcode, $date_due );
103
                    $date_due = AddRenewal(
104
                        undef,
105
                        $item->itemnumber(),
106
                        $branchcode,
107
                        $date_due,
108
                        undef,
109
                        !$unseen
110
                    );
103
                    $template->param( date_due => $date_due );
111
                    $template->param( date_due => $date_due );
104
                }
112
                }
105
            }
113
            }
(-)a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss (+12 lines)
Lines 1019-1024 div { Link Here
1019
        width: auto;
1019
        width: auto;
1020
    }
1020
    }
1021
1021
1022
    .renew_formfield {
1023
        margin-bottom: 1em;
1024
    }
1025
1022
    .circmessage {
1026
    .circmessage {
1023
        margin-bottom: .3em;
1027
        margin-bottom: .3em;
1024
        padding: 0 .4em .4em;
1028
        padding: 0 .4em .4em;
Lines 2418-2423 li { Link Here
2418
    position: relative;
2422
    position: relative;
2419
}
2423
}
2420
2424
2425
#renew_as_unseen_label {
2426
    margin-left: 1em;
2427
}
2428
2429
#renew_as_unseen_checkbox {
2430
    margin-right: 1em;
2431
}
2432
2421
#clearscreen {
2433
#clearscreen {
2422
    position: absolute;
2434
    position: absolute;
2423
    right: 0;
2435
    right: 0;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc (+4 lines)
Lines 48-53 Link Here
48
                        [% END %]
48
                        [% END %]
49
                    [% END %]
49
                    [% END %]
50
                    [% IF ( CAN_user_circulate_circulate_remaining_permissions ) %]
50
                    [% IF ( CAN_user_circulate_circulate_remaining_permissions ) %]
51
                        [% IF Koha.Preference( 'UnseenRenewals' ) %]
52
                            <label id="renew_as_unseen_label" for="override_limit">Renew as &quot;unseen&quot; if appropriate:</label>
53
                            <input type="checkbox" name="renew_as_unseen" id="renew_as_unseen_checkbox" value="1" />
54
                        [% END %]
51
                        <button class="btn btn-default" id="RenewCheckinChecked"><i class="fa fa-check"></i> Renew or check in selected items</button>
55
                        <button class="btn btn-default" id="RenewCheckinChecked"><i class="fa fa-check"></i> Renew or check in selected items</button>
52
                        <button class="btn btn-default" id="RenewAll"><i class="fa fa-book"></i> Renew all</button>
56
                        <button class="btn btn-default" id="RenewAll"><i class="fa fa-book"></i> Renew all</button>
53
                    [% END %]
57
                    [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc (+3 lines)
Lines 11-16 Link Here
11
    var RETURN_CLAIMED_NOTES = _("Notes about return claim");
11
    var RETURN_CLAIMED_NOTES = _("Notes about return claim");
12
    var NOT_CHECKED_OUT = _("not checked out");
12
    var NOT_CHECKED_OUT = _("not checked out");
13
    var TOO_MANY_RENEWALS = _("too many renewals");
13
    var TOO_MANY_RENEWALS = _("too many renewals");
14
    var TOO_MANY_UNSEEN = _("too many consecutive renewals without being seen by the library");
14
    var ON_RESERVE = _("on hold");
15
    var ON_RESERVE = _("on hold");
15
    var REASON_UNKNOWN = _("reason unknown");
16
    var REASON_UNKNOWN = _("reason unknown");
16
    var TODAYS_CHECKOUTS = _("Today's checkouts");
17
    var TODAYS_CHECKOUTS = _("Today's checkouts");
Lines 18-23 Link Here
18
    var BY = _("by _AUTHOR_");
19
    var BY = _("by _AUTHOR_");
19
    var ON_HOLD = _("On hold");
20
    var ON_HOLD = _("On hold");
20
    var NOT_RENEWABLE = _("Not renewable");
21
    var NOT_RENEWABLE = _("Not renewable");
22
    var NOT_RENEWABLE_UNSEEN = _("Must be renewed at the library");
21
    var NOT_RENEWABLE_TOO_SOON = _("No renewal before %s");
23
    var NOT_RENEWABLE_TOO_SOON = _("No renewal before %s");
22
    var NOT_RENEWABLE_AUTO_TOO_SOON = _("Scheduled for automatic renewal");
24
    var NOT_RENEWABLE_AUTO_TOO_SOON = _("Scheduled for automatic renewal");
23
    var NOT_RENEWABLE_AUTO_TOO_LATE = _("Can no longer be auto-renewed - number of checkout days exceeded");
25
    var NOT_RENEWABLE_AUTO_TOO_LATE = _("Can no longer be auto-renewed - number of checkout days exceeded");
Lines 26-31 Link Here
26
    var NOT_RENEWABLE_AUTO_RENEW = _("Scheduled for automatic renewal");
28
    var NOT_RENEWABLE_AUTO_RENEW = _("Scheduled for automatic renewal");
27
    var NOT_RENEWABLE_DENIED = _("Renewal denied by syspref");
29
    var NOT_RENEWABLE_DENIED = _("Renewal denied by syspref");
28
    var RENEWALS_REMAINING = _("%s of %s renewals remaining");
30
    var RENEWALS_REMAINING = _("%s of %s renewals remaining");
31
    var UNSEEN_REMAINING = _("%s of %s unseen renewals remaining");
29
    var HOLD_IS_SUSPENDED = _("Hold is <strong>suspended</strong>");
32
    var HOLD_IS_SUSPENDED = _("Hold is <strong>suspended</strong>");
30
    var UNTIL = _("until %s");
33
    var UNTIL = _("until %s");
31
    var NEXT_AVAILABLE_ITYPE = _("Next available %s item");
34
    var NEXT_AVAILABLE_ITYPE = _("Next available %s item");
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+1 lines)
Lines 1030-1035 Link Here
1030
        var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]";
1030
        var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]";
1031
        var ClaimReturnedLostValue = "[% Koha.Preference('ClaimReturnedLostValue') | html %]";
1031
        var ClaimReturnedLostValue = "[% Koha.Preference('ClaimReturnedLostValue') | html %]";
1032
        var ClaimReturnedChargeFee = "[% Koha.Preference('ClaimReturnedChargeFee') | html %]";
1032
        var ClaimReturnedChargeFee = "[% Koha.Preference('ClaimReturnedChargeFee') | html %]";
1033
        var UnseenRenewals = "[% Koha.Preference('UnseenRenewals') | html %]";
1033
        var ClaimReturnedWarningThreshold = "[% Koha.Preference('ClaimReturnedWarningThreshold') | html %]";
1034
        var ClaimReturnedWarningThreshold = "[% Koha.Preference('ClaimReturnedWarningThreshold') | html %]";
1034
        var MSG_DT_LOADING_RECORDS = _("Loading... you may continue scanning.");
1035
        var MSG_DT_LOADING_RECORDS = _("Loading... you may continue scanning.");
1035
        var interface = "[% interface | html %]";
1036
        var interface = "[% interface | html %]";
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt (-4 / +25 lines)
Lines 52-57 Link Here
52
                                    </form>
52
                                    </form>
53
                                [% END %]
53
                                [% END %]
54
54
55
                            [% ELSIF error == "too_unseen" %]
56
57
                                <p>[% INCLUDE 'biblio-title.inc' biblio=item.biblio %] ( [% item.barcode | html %] ) has been renewed the maximum number of consecutive times without being seen by the library )</p>
58
59
                                [% IF Koha.Preference('AllowRenewalLimitOverride') %]
60
                                    <form method="post" action="/cgi-bin/koha/circ/renew.pl">
61
                                        <input type="hidden" name="barcode" value="[% item.barcode | html %]"/>
62
                                        <input type="hidden" name="override_limit" value="1" />
63
                                        <button type="submit" class="approve"><i class="fa fa-check"></i> Override limit and renew</button>
64
                                    </form>
65
                                [% END %]
66
55
                            [% ELSIF error == "too_soon" %]
67
                            [% ELSIF error == "too_soon" %]
56
68
57
                                <p>[% INCLUDE 'biblio-title.inc' biblio=item.biblio %] ( [% item.barcode | html %] ) cannot be renewed before [% soonestrenewdate | $KohaDates %]. </p>
69
                                <p>[% INCLUDE 'biblio-title.inc' biblio=item.biblio %] ( [% item.barcode | html %] ) cannot be renewed before [% soonestrenewdate | $KohaDates %]. </p>
Lines 168-177 Link Here
168
                    <fieldset>
180
                    <fieldset>
169
                        <legend>Renew</legend>
181
                        <legend>Renew</legend>
170
182
171
                        <label for="barcode">Enter item barcode: </label>
183
                        [% IF Koha.Preference('UnseenRenewals') %]
172
184
                            <div class="renew_formfield">
173
                        <input name="barcode" id="barcode" size="14" class="focus" type="text" />
185
                                <label for="barcode">Enter item barcode: </label>
174
186
                                <input name="barcode" id="barcode" size="14" class="focus" type="text" />
187
                            </div>
188
                            <div class="renew_formfield">
189
                                <label for="unseen">Record renewal as unseen if appropriate: </label>
190
                                <input value="1" name="unseen" id="unseen" type="checkbox" />
191
                            </div>
192
                        [% ELSE %]
193
                            <label for="barcode">Enter item barcode: </label>
194
                            <input name="barcode" id="barcode" size="14" class="focus" type="text" />
195
                        [% END %]
175
                        <input type="submit" class="submit" value="Submit" />
196
                        <input type="submit" class="submit" value="Submit" />
176
                    </fieldset>
197
                    </fieldset>
177
198
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+1 lines)
Lines 864-869 Link Here
864
        var ClaimReturnedLostValue = "[% Koha.Preference('ClaimReturnedLostValue') | html %]";
864
        var ClaimReturnedLostValue = "[% Koha.Preference('ClaimReturnedLostValue') | html %]";
865
        var ClaimReturnedChargeFee = "[% Koha.Preference('ClaimReturnedChargeFee') | html %]";
865
        var ClaimReturnedChargeFee = "[% Koha.Preference('ClaimReturnedChargeFee') | html %]";
866
        var ClaimReturnedWarningThreshold = "[% Koha.Preference('ClaimReturnedWarningThreshold') | html %]";
866
        var ClaimReturnedWarningThreshold = "[% Koha.Preference('ClaimReturnedWarningThreshold') | html %]";
867
        var UnseenRenewals = "[% Koha.Preference('UnseenRenewals') | html %]";
867
        var interface = "[% interface | html %]";
868
        var interface = "[% interface | html %]";
868
        var theme = "[% theme | html %]";
869
        var theme = "[% theme | html %]";
869
        var borrowernumber = "[% patron.borrowernumber | html %]";
870
        var borrowernumber = "[% patron.borrowernumber | html %]";
(-)a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js (-4 / +22 lines)
Lines 143-151 $(document).ready(function() { Link Here
143
                itemnumber:      itemnumber,
143
                itemnumber:      itemnumber,
144
                borrowernumber:  borrowernumber,
144
                borrowernumber:  borrowernumber,
145
                branchcode:      branchcode,
145
                branchcode:      branchcode,
146
                override_limit:  override_limit,
146
                override_limit:  override_limit
147
            };
147
            };
148
148
149
            if (UnseenRenewals) {
150
                var ren = $("#renew_as_unseen_checkbox");
151
                var renew_unseen = ren.length > 0 && ren.is(':checked') ? 1 : 0;
152
                params.seen = renew_unseen === 1 ? 0 : 1;
153
            }
154
149
            // Determine which due date we need to use
155
            // Determine which due date we need to use
150
            var dueDate = isOnReserve ?
156
            var dueDate = isOnReserve ?
151
                $("#newonholdduedate input").val() :
157
                $("#newonholdduedate input").val() :
Lines 168-173 $(document).ready(function() { Link Here
168
                        content += NOT_CHECKED_OUT;
174
                        content += NOT_CHECKED_OUT;
169
                    } else if ( data.error == "too_many" ) {
175
                    } else if ( data.error == "too_many" ) {
170
                        content += TOO_MANY_RENEWALS;
176
                        content += TOO_MANY_RENEWALS;
177
                    } else if ( data.error == "too_unseen" ) {
178
                        content += TOO_MANY_UNSEEN;
171
                    } else if ( data.error == "on_reserve" ) {
179
                    } else if ( data.error == "on_reserve" ) {
172
                        content += ON_RESERVE;
180
                        content += ON_RESERVE;
173
                    } else if ( data.error == "restriction" ) {
181
                    } else if ( data.error == "restriction" ) {
Lines 432-437 $(document).ready(function() { Link Here
432
440
433
                            span_style = "display: none";
441
                            span_style = "display: none";
434
                            span_class = "renewals-allowed";
442
                            span_class = "renewals-allowed";
443
                        } else if ( oObj.can_renew_error == "too_unseen" ) {
444
                            msg += "<span class='renewals-disabled'>"
445
                                    + NOT_RENEWABLE_UNSEEN
446
                                    + "</span>";
447
448
                            span_style = "display: none";
449
                            span_class = "renewals-allowed";
435
                        } else if ( oObj.can_renew_error == "restriction" ) {
450
                        } else if ( oObj.can_renew_error == "restriction" ) {
436
                            msg += "<span class='renewals-disabled'>"
451
                            msg += "<span class='renewals-disabled'>"
437
                                    + NOT_RENEWABLE_RESTRICTION
452
                                    + NOT_RENEWABLE_RESTRICTION
Lines 526-534 $(document).ready(function() { Link Here
526
                        }
541
                        }
527
                        content += msg;
542
                        content += msg;
528
                        if ( can_renew || can_force_renew ) {
543
                        if ( can_renew || can_force_renew ) {
529
                            content += "<span class='renewals'>("
544
                            content += "<span class='renewals'>(";
530
                                    + RENEWALS_REMAINING.format( oObj.renewals_remaining, oObj.renewals_allowed )
545
                            content += RENEWALS_REMAINING.format( oObj.renewals_remaining, oObj.renewals_allowed );
531
                                    + ")</span>";
546
                            if (UnseenRenewals && oObj.unseen_allowed) {
547
                                content += " / " + UNSEEN_REMAINING.format( oObj.unseen_remaining, oObj.unseen_allowed );
548
                            }
549
                            content += ")</span>";
532
                        }
550
                        }
533
551
534
                        content += "</span>";
552
                        content += "</span>";
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (-6 / +40 lines)
Lines 81-86 Link Here
81
                                            <li>Your account has expired. Please contact the library for more information.</li>
81
                                            <li>Your account has expired. Please contact the library for more information.</li>
82
                                        [% ELSIF error == 'too_many' %]
82
                                        [% ELSIF error == 'too_many' %]
83
                                            <li>You have renewed this item the maximum number of times allowed.</li>
83
                                            <li>You have renewed this item the maximum number of times allowed.</li>
84
                                        [% ELSIF error == 'too_unseen' %]
85
                                            <li>You have renewed this item the maximum number of consecutive times without it being seen by the library.</li>
84
                                        [% ELSIF error == 'too_soon' %]
86
                                        [% ELSIF error == 'too_soon' %]
85
                                            <li>It is too soon after the checkout date for this item to be renewed.</li>
87
                                            <li>It is too soon after the checkout date for this item to be renewed.</li>
86
                                        [% ELSIF error == 'on_reserve' %]
88
                                        [% ELSIF error == 'on_reserve' %]
Lines 309-335 Link Here
309
                                                        [% IF ISSUE.itemtype_object.rentalcharge_hourly > 0 %]
311
                                                        [% IF ISSUE.itemtype_object.rentalcharge_hourly > 0 %]
310
                                                            <span class="renewalfee label label-warning">[% ISSUE.itemtype_object.rentalcharge_hourly | $Price %] per hour</span>
312
                                                            <span class="renewalfee label label-warning">[% ISSUE.itemtype_object.rentalcharge_hourly | $Price %] per hour</span>
311
                                                        [% END %]
313
                                                        [% END %]
312
                                                        <span class="renewals">([% ISSUE.renewsleft | html %] of [% ISSUE.renewsallowed | html %] renewals remaining)</span>
314
                                                        <span class="renewals">(
315
                                                            [% ISSUE.renewsleft | html %] of [% ISSUE.renewsallowed | html %] renewals remaining
316
                                                            [% IF Koha.Preference('UnseenRenewals') && ISSUE.unseenallowed %]
317
                                                                / [% ISSUE.unseenleft | html %] of [% ISSUE.unseenallowed | html %] renewals left before the item must be seen by the library
318
                                                            [% END %]
319
                                                        )</span>
313
                                                    [% ELSIF ( ISSUE.on_reserve ) %]
320
                                                    [% ELSIF ( ISSUE.on_reserve ) %]
314
                                                        Not renewable <span class="renewals">(on hold)</span>
321
                                                        Not renewable <span class="renewals">(on hold)</span>
315
                                                    [% ELSIF ( ISSUE.too_many ) %]
322
                                                    [% ELSIF ( ISSUE.too_many ) %]
316
                                                        Not renewable
323
                                                        Not renewable
324
                                                    [% ELSIF ( ISSUE.too_unseen ) %]
325
                                                        Item must be seen by the library
317
                                                    [% ELSIF ( ISSUE.norenew_overdue ) %]
326
                                                    [% ELSIF ( ISSUE.norenew_overdue ) %]
318
                                                        Not allowed <span class="renewals">(overdue)</span>
327
                                                        Not allowed <span class="renewals">(overdue)</span>
319
                                                    [% ELSIF ( ISSUE.auto_too_late ) %]
328
                                                    [% ELSIF ( ISSUE.auto_too_late ) %]
320
                                                        No longer renewable
329
                                                        No longer renewable
321
                                                    [% ELSIF ISSUE.auto_too_much_oweing %]
330
                                                    [% ELSIF ISSUE.auto_too_much_oweing %]
322
                                                        Automatic renewal failed, you have unpaid fines.
331
                                                        Automatic renewal failed, you have unpaid fines.
323
                                                        <span class="renewals">([% ISSUE.renewsleft | html %] of [% ISSUE.renewsallowed | html %] renewals remaining)</span>
332
                                                        <span class="renewals">(
333
                                                            [% ISSUE.renewsleft | html %] of [% ISSUE.renewsallowed | html %] renewals remaining
334
                                                            [% IF Koha.Preference('UnseenRenewals') && ISSUE.unseenallowed %]
335
                                                                / [% ISSUE.unseenleft | html %] of [% ISSUE.unseenallowed | html %] renewals left before the item must be seen by the library
336
                                                            [% END %]
337
                                                        )</span>
324
                                                    [% ELSIF ISSUE.auto_account_expired %]
338
                                                    [% ELSIF ISSUE.auto_account_expired %]
325
                                                        Automatic renewal failed, your account is expired.
339
                                                        Automatic renewal failed, your account is expired.
326
                                                        <span class="renewals">([% ISSUE.renewsleft | html %] of [% ISSUE.renewsallowed | html %] renewals remaining)</span>
340
                                                        <span class="renewals">(
341
                                                            [% ISSUE.renewsleft | html %] of [% ISSUE.renewsallowed | html %] renewals remaining
342
                                                            [% IF Koha.Preference('UnseenRenewals') && ISSUE.unseenallowed %]
343
                                                                / [% ISSUE.unseenleft | html %] of [% ISSUE.unseenallowed | html %] renewals left before the item must be seen by the library
344
                                                            [% END %]
345
                                                        )</span>
327
                                                    [% ELSIF ( ISSUE.auto_renew || ISSUE.auto_too_soon ) %]
346
                                                    [% ELSIF ( ISSUE.auto_renew || ISSUE.auto_too_soon ) %]
328
                                                        Automatic renewal
347
                                                        Automatic renewal
329
                                                        <span class="renewals">([% ISSUE.renewsleft | html %] of [% ISSUE.renewsallowed | html %] renewals remaining)</span>
348
                                                        <span class="renewals">(
349
                                                            [% ISSUE.renewsleft | html %] of [% ISSUE.renewsallowed | html %] renewals remaining
350
                                                            [% IF Koha.Preference('UnseenRenewals') && ISSUE.unseenallowed %]
351
                                                                / [% ISSUE.unseenleft | html %] of [% ISSUE.unseenallowed | html %] renewals left before the item must be seen by the library
352
                                                            [% END %]
353
                                                        )</span>
330
                                                    [% ELSIF ( ISSUE.too_soon ) %]
354
                                                    [% ELSIF ( ISSUE.too_soon ) %]
331
                                                        No renewal before [% ISSUE.soonestrenewdate | html %]
355
                                                        No renewal before [% ISSUE.soonestrenewdate | html %]
332
                                                        <span class="renewals">([% ISSUE.renewsleft | html %] of [% ISSUE.renewsallowed | html %] renewals remaining)</span>
356
                                                        <span class="renewals">(
357
                                                            [% ISSUE.renewsleft | html %] of [% ISSUE.renewsallowed | html %] renewals remaining
358
                                                            [% IF Koha.Preference('UnseenRenewals') && ISSUE.unseenallowed %]
359
                                                                / [% ISSUE.unseenleft | html %] of [% ISSUE.unseenallowed | html %] renewals left before the item must be seen by the library
360
                                                            [% END %]
361
                                                        )</span>
333
                                                    [% ELSIF ( ISSUE.item_denied_renewal ) %]
362
                                                    [% ELSIF ( ISSUE.item_denied_renewal ) %]
334
                                                        Renewal not allowed
363
                                                        Renewal not allowed
335
                                                    [% END %]
364
                                                    [% END %]
Lines 582-588 Link Here
582
                                                            [% IF ( canrenew ) %]
611
                                                            [% IF ( canrenew ) %]
583
                                                                <a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&amp;item=[% OVERDUE.itemnumber | uri %]&amp;bornum=[% OVERDUE.borrowernumber | uri %]">Renew</a>
612
                                                                <a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&amp;item=[% OVERDUE.itemnumber | uri %]&amp;bornum=[% OVERDUE.borrowernumber | uri %]">Renew</a>
584
                                                            [% END %]
613
                                                            [% END %]
585
                                                                <span class="renewals">([% OVERDUE.renewsleft | html %] of [% OVERDUE.renewsallowed | html %] renewals remaining)</span>
614
                                                                <span class="renewals">(
615
                                                                    [% OVERDUE.renewsleft | html %] of [% OVERDUE.renewsallowed | html %] renewals remaining
616
                                                                    [% IF Koha.Preference('UnseenRenewals') && ISSUE.unseenallowed %]
617
                                                                        / [% OVERDUE.unseenleft | html %] of [% OVERDUE.unseenallowed | html %] renewals left before the item must be seen by the library
618
                                                                    [% END %]
619
                                                                )</span>
586
                                                        [% ELSIF ( OVERDUE.norenew_overdue ) %]
620
                                                        [% ELSIF ( OVERDUE.norenew_overdue ) %]
587
                                                            Not allowed<span class="renewals">(overdue)</span>
621
                                                            Not allowed<span class="renewals">(overdue)</span>
588
                                                        [% ELSIF ( OVERDUE.onreserve ) %]
622
                                                        [% ELSIF ( OVERDUE.onreserve ) %]
(-)a/misc/cronjobs/automatic_renewals.pl (-1 / +1 lines)
Lines 78-84 while ( my $auto_renew = $auto_renews->next ) { Link Here
78
    # CanBookBeRenewed returns 'auto_renew' when the renewal should be done by this script
78
    # CanBookBeRenewed returns 'auto_renew' when the renewal should be done by this script
79
    my ( $ok, $error ) = CanBookBeRenewed( $auto_renew->borrowernumber, $auto_renew->itemnumber );
79
    my ( $ok, $error ) = CanBookBeRenewed( $auto_renew->borrowernumber, $auto_renew->itemnumber );
80
    if ( $error eq 'auto_renew' ) {
80
    if ( $error eq 'auto_renew' ) {
81
        my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode );
81
        my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode, undef, undef, 0 );
82
        $auto_renew->auto_renew_error(undef)->store;
82
        $auto_renew->auto_renew_error(undef)->store;
83
        push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew;
83
        push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew;
84
    } elsif ( $error eq 'too_many'
84
    } elsif ( $error eq 'too_many'
(-)a/offline_circ/download.pl (+1 lines)
Lines 68-73 my $issues_query = q{SELECT Link Here
68
    issues.date_due AS date_due,
68
    issues.date_due AS date_due,
69
    issues.issuedate AS issuedate,
69
    issues.issuedate AS issuedate,
70
    issues.renewals AS renewals,
70
    issues.renewals AS renewals,
71
    issues.unseen_renewals AS unseen_renewals,
71
    borrowers.cardnumber AS cardnumber,
72
    borrowers.cardnumber AS cardnumber,
72
    CONCAT(borrowers.surname, ', ', borrowers.firstname) AS borrower_name
73
    CONCAT(borrowers.surname, ', ', borrowers.firstname) AS borrower_name
73
    FROM issues
74
    FROM issues
(-)a/opac/opac-renew.pl (-1 / +1 lines)
Lines 82-88 else { Link Here
82
            else {
82
            else {
83
                $branchcode = 'OPACRenew';
83
                $branchcode = 'OPACRenew';
84
            }
84
            }
85
            AddRenewal( $borrowernumber, $itemnumber, $branchcode, undef, undef );
85
            AddRenewal( $borrowernumber, $itemnumber, $branchcode, undef, undef, 0 );
86
            push( @renewed, $itemnumber );
86
            push( @renewed, $itemnumber );
87
        }
87
        }
88
        else {
88
        else {
(-)a/opac/opac-user.pl (-1 / +9 lines)
Lines 209-215 if ( $pending_checkouts->count ) { # Useless test Link Here
209
209
210
        # check if item is renewable
210
        # check if item is renewable
211
        my ($status,$renewerror) = CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'} );
211
        my ($status,$renewerror) = CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'} );
212
        ($issue->{'renewcount'},$issue->{'renewsallowed'},$issue->{'renewsleft'}) = GetRenewCount($borrowernumber, $issue->{'itemnumber'});
212
        (
213
            $issue->{'renewcount'},
214
            $issue->{'renewsallowed'},
215
            $issue->{'renewsleft'},
216
            $issue->{'unseencount'},
217
            $issue->{'unseenallowed'},
218
            $issue->{'unseenleft'}
219
        ) = GetRenewCount($borrowernumber, $issue->{'itemnumber'});
213
        ( $issue->{'renewalfee'}, $issue->{'renewalitemtype'} ) = GetIssuingCharges( $issue->{'itemnumber'}, $borrowernumber );
220
        ( $issue->{'renewalfee'}, $issue->{'renewalitemtype'} ) = GetIssuingCharges( $issue->{'itemnumber'}, $borrowernumber );
214
        $issue->{itemtype_object} = Koha::ItemTypes->find( Koha::Items->find( $issue->{itemnumber} )->effective_itemtype );
221
        $issue->{itemtype_object} = Koha::ItemTypes->find( Koha::Items->find( $issue->{itemnumber} )->effective_itemtype );
215
        if($status && C4::Context->preference("OpacRenewalAllowed")){
222
        if($status && C4::Context->preference("OpacRenewalAllowed")){
Lines 220-225 if ( $pending_checkouts->count ) { # Useless test Link Here
220
227
221
        if ($renewerror) {
228
        if ($renewerror) {
222
            $issue->{'too_many'}       = 1 if $renewerror eq 'too_many';
229
            $issue->{'too_many'}       = 1 if $renewerror eq 'too_many';
230
            $issue->{'too_unseen'}     = 1 if $renewerror eq 'too_unseen';
223
            $issue->{'on_reserve'}     = 1 if $renewerror eq 'on_reserve';
231
            $issue->{'on_reserve'}     = 1 if $renewerror eq 'on_reserve';
224
            $issue->{'norenew_overdue'} = 1 if $renewerror eq 'overdue';
232
            $issue->{'norenew_overdue'} = 1 if $renewerror eq 'overdue';
225
            $issue->{'auto_renew'}     = 1 if $renewerror eq 'auto_renew';
233
            $issue->{'auto_renew'}     = 1 if $renewerror eq 'auto_renew';
(-)a/svc/checkouts (-1 / +11 lines)
Lines 158-164 while ( my $c = $sth->fetchrow_hashref() ) { Link Here
158
      )
158
      )
159
      : undef;
159
      : undef;
160
160
161
    my ( $renewals_count, $renewals_allowed, $renewals_remaining ) =
161
    my (
162
        $renewals_count,
163
        $renewals_allowed,
164
        $renewals_remaining,
165
        $unseen_count,
166
        $unseen_allowed,
167
        $unseen_remaining
168
    ) =
162
      GetRenewCount( $c->{borrowernumber}, $c->{itemnumber} );
169
      GetRenewCount( $c->{borrowernumber}, $c->{itemnumber} );
163
170
164
    my $type_for_stat = Koha::ItemTypes->find( $item_level_itypes ? $c->{itype} : $c->{itemtype} );
171
    my $type_for_stat = Koha::ItemTypes->find( $item_level_itypes ? $c->{itype} : $c->{itemtype} );
Lines 225-230 while ( my $c = $sth->fetchrow_hashref() ) { Link Here
225
        renewals_count      => $renewals_count,
232
        renewals_count      => $renewals_count,
226
        renewals_allowed    => $renewals_allowed,
233
        renewals_allowed    => $renewals_allowed,
227
        renewals_remaining  => $renewals_remaining,
234
        renewals_remaining  => $renewals_remaining,
235
        unseen_count        => $unseen_count,
236
        unseen_allowed      => $unseen_allowed,
237
        unseen_remaining    => $unseen_remaining,
228
238
229
        return_claim_id         => $c->{return_claim_id},
239
        return_claim_id         => $c->{return_claim_id},
230
        return_claim_notes      => $c->{return_claim_notes},
240
        return_claim_notes      => $c->{return_claim_notes},
(-)a/svc/renew (-2 / +2 lines)
Lines 46-51 my $borrowernumber = $input->param('borrowernumber'); Link Here
46
my $override_limit = $input->param('override_limit');
46
my $override_limit = $input->param('override_limit');
47
my $branchcode     = $input->param('branchcode')
47
my $branchcode     = $input->param('branchcode')
48
  || C4::Context->userenv->{'branch'};
48
  || C4::Context->userenv->{'branch'};
49
my $seen           = $input->param('seen');
49
my $date_due;
50
my $date_due;
50
if ( $input->param('date_due') ) {
51
if ( $input->param('date_due') ) {
51
    $date_due = dt_from_string( scalar $input->param('date_due') );
52
    $date_due = dt_from_string( scalar $input->param('date_due') );
Lines 66-72 if ( $data->{error} && $data->{error} eq 'on_reserve' && C4::Context->preference Link Here
66
}
67
}
67
68
68
if ( $data->{renew_okay} ) {
69
if ( $data->{renew_okay} ) {
69
    $date_due = AddRenewal( $borrowernumber, $itemnumber, $branchcode, $date_due );
70
    $date_due = AddRenewal( $borrowernumber, $itemnumber, $branchcode, $date_due, undef, $seen );
70
    $data->{date_due} = output_pref( { dt => $date_due, as_due_date => 1 } );
71
    $data->{date_due} = output_pref( { dt => $date_due, as_due_date => 1 } );
71
}
72
}
72
73
73
- 

Return to bug 24083