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

(-)a/C4/Circulation.pm (-5 / +5 lines)
Lines 2891-2897 sub CanBookBeRenewed { Link Here
2891
        );
2891
        );
2892
2892
2893
        return ( 0, "too_many" )
2893
        return ( 0, "too_many" )
2894
          if not $issuing_rule->{renewalsallowed} or $issuing_rule->{renewalsallowed} <= $issue->renewals;
2894
          if not $issuing_rule->{renewalsallowed} or $issuing_rule->{renewalsallowed} <= $issue->renewals_count;
2895
2895
2896
        return ( 0, "too_unseen" )
2896
        return ( 0, "too_unseen" )
2897
          if C4::Context->preference('UnseenRenewals') &&
2897
          if C4::Context->preference('UnseenRenewals') &&
Lines 3148-3155 sub AddRenewal { Link Here
3148
3148
3149
        # Update the issues record to have the new due date, and a new count
3149
        # Update the issues record to have the new due date, and a new count
3150
        # of how many times it has been renewed.
3150
        # of how many times it has been renewed.
3151
        my $renews = ( $issue->renewals || 0 ) + 1;
3151
        my $renews = ( $issue->renewals_count || 0 ) + 1;
3152
        my $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, unseen_renewals = ?, lastreneweddate = ? WHERE issue_id = ?");
3152
        my $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals_count = ?, unseen_renewals = ?, lastreneweddate = ? WHERE issue_id = ?");
3153
3153
3154
        eval{
3154
        eval{
3155
            $sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $unseen_renewals, $lastreneweddate, $issue->issue_id );
3155
            $sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $unseen_renewals, $lastreneweddate, $issue->issue_id );
Lines 3277-3283 sub GetRenewCount { Link Here
3277
    );
3277
    );
3278
    $sth->execute( $bornum, $itemno );
3278
    $sth->execute( $bornum, $itemno );
3279
    my $data = $sth->fetchrow_hashref;
3279
    my $data = $sth->fetchrow_hashref;
3280
    $renewcount = $data->{'renewals'} if $data->{'renewals'};
3280
    $renewcount = $data->{'renewals_count'} if $data->{'renewals_count'};
3281
    $unseencount = $data->{'unseen_renewals'} if $data->{'unseen_renewals'};
3281
    $unseencount = $data->{'unseen_renewals'} if $data->{'unseen_renewals'};
3282
    # $item and $borrower should be calculated
3282
    # $item and $borrower should be calculated
3283
    my $branchcode = _GetCircControlBranch($item->unblessed, $patron->unblessed);
3283
    my $branchcode = _GetCircControlBranch($item->unblessed, $patron->unblessed);
Lines 4071-4077 sub ProcessOfflineReturn { Link Here
4071
                $itemnumber,
4071
                $itemnumber,
4072
                $operation->{timestamp},
4072
                $operation->{timestamp},
4073
            );
4073
            );
4074
            $item->renewals(0);
4074
            $item->renewals_count(0);
4075
            $item->onloan(undef);
4075
            $item->onloan(undef);
4076
            $item->store({ log_action => 0 });
4076
            $item->store({ log_action => 0 });
4077
            return "Success.";
4077
            return "Success.";
(-)a/C4/ILSDI/Services.pm (-1 / +1 lines)
Lines 697-703 sub RenewLoan { Link Here
697
697
698
    # Hashref building
698
    # Hashref building
699
    my $out;
699
    my $out;
700
    $out->{'renewals'} = $issue->renewals;
700
    $out->{'renewals'} = $issue->renewals_count;
701
    $out->{date_due}   = dt_from_string($issue->date_due)->strftime('%Y-%m-%d %H:%M');
701
    $out->{date_due}   = dt_from_string($issue->date_due)->strftime('%Y-%m-%d %H:%M');
702
    $out->{'success'}  = $renewal[0];
702
    $out->{'success'}  = $renewal[0];
703
    $out->{'error'}    = $renewal[1];
703
    $out->{'error'}    = $renewal[1];
(-)a/C4/Members.pm (-2 / +2 lines)
Lines 266-272 sub GetAllIssues { Link Here
266
266
267
    my $dbh = C4::Context->dbh;
267
    my $dbh = C4::Context->dbh;
268
    my $query =
268
    my $query =
269
'SELECT issues.*, items.*, biblio.*, biblioitems.*, issues.timestamp as issuestimestamp, issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp,borrowers.firstname,borrowers.surname
269
'SELECT issues.*, items.*, biblio.*, biblioitems.*, issues.timestamp as issuestimestamp, issues.renewals_count AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp,borrowers.firstname,borrowers.surname
270
  FROM issues
270
  FROM issues
271
  LEFT JOIN items on items.itemnumber=issues.itemnumber
271
  LEFT JOIN items on items.itemnumber=issues.itemnumber
272
  LEFT JOIN borrowers on borrowers.borrowernumber=issues.issuer_id
272
  LEFT JOIN borrowers on borrowers.borrowernumber=issues.issuer_id
Lines 274-280 sub GetAllIssues { Link Here
274
  LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber
274
  LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber
275
  WHERE issues.borrowernumber=?
275
  WHERE issues.borrowernumber=?
276
  UNION ALL
276
  UNION ALL
277
  SELECT old_issues.*, items.*, biblio.*, biblioitems.*, old_issues.timestamp as issuestimestamp, old_issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp,borrowers.firstname,borrowers.surname
277
  SELECT old_issues.*, items.*, biblio.*, biblioitems.*, old_issues.timestamp as issuestimestamp, old_issues.renewals_count AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp,borrowers.firstname,borrowers.surname
278
  FROM old_issues
278
  FROM old_issues
279
  LEFT JOIN items on items.itemnumber=old_issues.itemnumber
279
  LEFT JOIN items on items.itemnumber=old_issues.itemnumber
280
  LEFT JOIN borrowers on borrowers.borrowernumber=old_issues.issuer_id
280
  LEFT JOIN borrowers on borrowers.borrowernumber=old_issues.issuer_id
(-)a/Koha/REST/V1/Checkouts.pm (-1 / +1 lines)
Lines 193-199 sub allows_renewal { Link Here
193
            openapi => {
193
            openapi => {
194
                allows_renewal => $renewable,
194
                allows_renewal => $renewable,
195
                max_renewals => $rule->rule_value,
195
                max_renewals => $rule->rule_value,
196
                current_renewals => $checkout->renewals,
196
                current_renewals => $checkout->renewals_count,
197
                unseen_renewals => $checkout->unseen_renewals,
197
                unseen_renewals => $checkout->unseen_renewals,
198
                error => $error
198
                error => $error
199
            }
199
            }
(-)a/api/v1/swagger/definitions/checkout.yaml (-1 / +1 lines)
Lines 36-42 properties: Link Here
36
      - "null"
36
      - "null"
37
    format: date-time
37
    format: date-time
38
    description: Date the item was last renewed
38
    description: Date the item was last renewed
39
  renewals:
39
  renewals_count:
40
    type:
40
    type:
41
      - integer
41
      - integer
42
      - "null"
42
      - "null"
(-)a/installer/data/mysql/atomicupdate/bug_30275.pl (+6 lines)
Lines 21-26 return { Link Here
21
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
21
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
22
            });
22
            });
23
            say $out "Added new table 'checkout_renewals'";
23
            say $out "Added new table 'checkout_renewals'";
24
25
            $dbh->do(q{ ALTER TABLE `issues` CHANGE `renewals` `renewals_count` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of times the item was renewed' });
26
            say $out "Renamed `issues.renewals` to `issues.renewals_count`";
27
28
            $dbh->do(q{ ALTER TABLE `old_issues` CHANGE `renewals` `renewals_count` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of times the item was renewed' });
29
            say $out "Renamed `old_issues.renewals` to `old_issues.renewals_count`";
24
        }
30
        }
25
    },
31
    },
26
}
32
}
(-)a/installer/data/mysql/kohastructure.sql (-2 / +2 lines)
Lines 3022-3028 CREATE TABLE `issues` ( Link Here
3022
  `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'foreign key, linking to the branches table for the location the item was checked out',
3022
  `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'foreign key, linking to the branches table for the location the item was checked out',
3023
  `returndate` datetime DEFAULT NULL COMMENT 'date the item was returned, will be NULL until moved to old_issues',
3023
  `returndate` datetime DEFAULT NULL COMMENT 'date the item was returned, will be NULL until moved to old_issues',
3024
  `lastreneweddate` datetime DEFAULT NULL COMMENT 'date the item was last renewed',
3024
  `lastreneweddate` datetime DEFAULT NULL COMMENT 'date the item was last renewed',
3025
  `renewals` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of times the item was renewed',
3025
  `renewals_count` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of times the item was renewed',
3026
  `unseen_renewals` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of consecutive times the item was renewed without being seen',
3026
  `unseen_renewals` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of consecutive times the item was renewed without being seen',
3027
  `auto_renew` tinyint(1) DEFAULT 0 COMMENT 'automatic renewal',
3027
  `auto_renew` tinyint(1) DEFAULT 0 COMMENT 'automatic renewal',
3028
  `auto_renew_error` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'automatic renewal error',
3028
  `auto_renew_error` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'automatic renewal error',
Lines 3921-3927 CREATE TABLE `old_issues` ( Link Here
3921
  `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'foreign key, linking to the branches table for the location the item was checked out',
3921
  `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'foreign key, linking to the branches table for the location the item was checked out',
3922
  `returndate` datetime DEFAULT NULL COMMENT 'date the item was returned',
3922
  `returndate` datetime DEFAULT NULL COMMENT 'date the item was returned',
3923
  `lastreneweddate` datetime DEFAULT NULL COMMENT 'date the item was last renewed',
3923
  `lastreneweddate` datetime DEFAULT NULL COMMENT 'date the item was last renewed',
3924
  `renewals` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of times the item was renewed',
3924
  `renewals_count` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of times the item was renewed',
3925
  `unseen_renewals` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of consecutive times the item was renewed without being seen',
3925
  `unseen_renewals` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of consecutive times the item was renewed without being seen',
3926
  `auto_renew` tinyint(1) DEFAULT 0 COMMENT 'automatic renewal',
3926
  `auto_renew` tinyint(1) DEFAULT 0 COMMENT 'automatic renewal',
3927
  `auto_renew_error` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'automatic renewal error',
3927
  `auto_renew_error` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'automatic renewal error',
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt (-1 / +1 lines)
Lines 90-96 Link Here
90
                    [% INCLUDE 'patron-title.inc' patron=checkout.issuer %]
90
                    [% INCLUDE 'patron-title.inc' patron=checkout.issuer %]
91
                    </a>
91
                    </a>
92
                    [% END %]</td>
92
                    [% END %]</td>
93
                <td>[% IF checkout.renewals %]
93
                <td>[% IF checkout.renewals_count %]
94
                        Yes[% IF checkout.lastreneweddate %], <small>last on: [% checkout.lastreneweddate |$KohaDates  with_hours => 1 %]</small>
94
                        Yes[% IF checkout.lastreneweddate %], <small>last on: [% checkout.lastreneweddate |$KohaDates  with_hours => 1 %]</small>
95
                            [% END %]
95
                            [% END %]
96
                    [% ELSE %]
96
                    [% ELSE %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt (-1 / +1 lines)
Lines 109-115 Link Here
109
          </td>
109
          </td>
110
110
111
          <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% issue.itemnumber | uri %]&amp;biblionumber=[% issue.biblionumber | uri %]&amp;bi=[% issue.biblioitemnumber | uri %]#item[% issue.itemnumber | uri %]">[% issue.barcode | html %]</a></td>
111
          <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% issue.itemnumber | uri %]&amp;biblionumber=[% issue.biblionumber | uri %]&amp;bi=[% issue.biblioitemnumber | uri %]#item[% issue.itemnumber | uri %]">[% issue.barcode | html %]</a></td>
112
          <td>[% issue.renewals | html %]</td>
112
          <td>[% issue.renewals_count | html %]</td>
113
          <td data-order="[% issue.issuedate | html %]">
113
          <td data-order="[% issue.issuedate | html %]">
114
              [% issue.issuedate |$KohaDates  with_hours => 1 %]
114
              [% issue.issuedate |$KohaDates  with_hours => 1 %]
115
          </td>
115
          </td>
(-)a/misc/recreateIssueStatistics.pl (-3 / +3 lines)
Lines 60-66 if ($issues == 1) { Link Here
60
    foreach my $table ('issues', 'old_issues') {
60
    foreach my $table ('issues', 'old_issues') {
61
	# Getting issues
61
	# Getting issues
62
	print "looking for missing issues from $table\n";
62
	print "looking for missing issues from $table\n";
63
	my $query = "SELECT borrowernumber, branchcode, itemnumber, issuedate, renewals, lastreneweddate from $table where itemnumber is not null";
63
	my $query = "SELECT borrowernumber, branchcode, itemnumber, issuedate, renewals_count, lastreneweddate from $table where itemnumber is not null";
64
	my $sth = $dbh->prepare($query);
64
	my $sth = $dbh->prepare($query);
65
	$sth->execute;
65
	$sth->execute;
66
	# Looking for missing issues
66
	# Looking for missing issues
Lines 92-98 if ($issues == 1) { Link Here
92
		}
92
		}
93
93
94
		# Looking for missing renewals
94
		# Looking for missing renewals
95
		if ($hashref->{'renewals'} && $hashref->{'renewals'} > 0 ) {
95
		if ($hashref->{'renewals_count'} && $hashref->{'renewals_count'} > 0 ) {
96
		    # This is the not-so accurate part :
96
		    # This is the not-so accurate part :
97
		    # We assume that there are missing renewals, based on the last renewal date
97
		    # We assume that there are missing renewals, based on the last renewal date
98
		    # Maybe should this be deactivated by default ?
98
		    # Maybe should this be deactivated by default ?
Lines 100-106 if ($issues == 1) { Link Here
100
		    my $substh = $dbh->prepare($ctnquery);
100
		    my $substh = $dbh->prepare($ctnquery);
101
		    $substh->execute($hashref->{'borrowernumber'}, $hashref->{'itemnumber'}, $hashref->{'lastreneweddate'});
101
		    $substh->execute($hashref->{'borrowernumber'}, $hashref->{'itemnumber'}, $hashref->{'lastreneweddate'});
102
102
103
		    my $missingrenewalscount = $hashref->{'renewals'} - $substh->fetchrow_hashref->{'cnt'};
103
		    my $missingrenewalscount = $hashref->{'renewals_count'} - $substh->fetchrow_hashref->{'cnt'};
104
		    print "We assume $missingrenewalscount renewals are missing. Creating them\n" if ($missingrenewalscount > 0);
104
		    print "We assume $missingrenewalscount renewals are missing. Creating them\n" if ($missingrenewalscount > 0);
105
		    for (my $i = 0; $i < $missingrenewalscount; $i++) {
105
		    for (my $i = 0; $i < $missingrenewalscount; $i++) {
106
106
(-)a/offline_circ/download.pl (-1 / +1 lines)
Lines 66-72 my $issues_query = q{SELECT Link Here
66
    items.itemcallnumber AS callnumber,
66
    items.itemcallnumber AS callnumber,
67
    issues.date_due AS date_due,
67
    issues.date_due AS date_due,
68
    issues.issuedate AS issuedate,
68
    issues.issuedate AS issuedate,
69
    issues.renewals AS renewals,
69
    issues.renewals_count AS renewals,
70
    issues.unseen_renewals AS unseen_renewals,
70
    issues.unseen_renewals AS unseen_renewals,
71
    borrowers.cardnumber AS cardnumber,
71
    borrowers.cardnumber AS cardnumber,
72
    CONCAT(borrowers.surname, ', ', borrowers.firstname) AS borrower_name
72
    CONCAT(borrowers.surname, ', ', borrowers.firstname) AS borrower_name
(-)a/t/db_dependent/SIP/ILS.t (-3 / +2 lines)
Lines 275-281 subtest checkout => sub { Link Here
275
    AddIssue( $patron->unblessed, $item->barcode, undef, 0 );
275
    AddIssue( $patron->unblessed, $item->barcode, undef, 0 );
276
    my $checkout = $item->checkout;
276
    my $checkout = $item->checkout;
277
    ok( defined($checkout), "Checkout added");
277
    ok( defined($checkout), "Checkout added");
278
    is( $checkout->renewals, 0, "Correct renewals");
278
    is( $checkout->renewals_count, 0, "Correct renewals");
279
279
280
    my $ils = C4::SIP::ILS->new({ id => $library->branchcode });
280
    my $ils = C4::SIP::ILS->new({ id => $library->branchcode });
281
    my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber );
281
    my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber );
Lines 284-290 subtest checkout => sub { Link Here
284
    is( $transaction->{screen_msg},"Item already checked out to you: renewing item.","We get a success message when issue is renewed");
284
    is( $transaction->{screen_msg},"Item already checked out to you: renewing item.","We get a success message when issue is renewed");
285
285
286
    $checkout->discard_changes();
286
    $checkout->discard_changes();
287
    is( $checkout->renewals, 1, "Renewals has been reduced");
287
    is( $checkout->renewals_count, 1, "Renewals has been reduced");
288
};
288
};
289
289
290
subtest renew_all => sub {
290
subtest renew_all => sub {
291
- 

Return to bug 30275