@@ -, +, @@ --- C4/Circulation.pm | 14 +++++++------- C4/ILSDI/Services.pm | 2 +- C4/Members.pm | 4 ++-- Koha/REST/V1/Checkouts.pm | 2 +- installer/data/mysql/atomicupdate/bug_30275.pl | 3 +++ installer/data/mysql/kohastructure.sql | 2 +- .../prog/en/modules/catalogue/issuehistory.tt | 2 +- .../prog/en/modules/members/readingrec.tt | 2 +- misc/recreateIssueStatistics.pl | 6 +++--- offline_circ/download.pl | 2 +- t/db_dependent/SIP/ILS.t | 4 ++-- 11 files changed, 23 insertions(+), 20 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -2740,7 +2740,7 @@ sub CanBookBeRenewed { ); return ( 0, "too_many" ) - if not $issuing_rule->{renewalsallowed} or $issuing_rule->{renewalsallowed} <= $issue->renewals; + if not $issuing_rule->{renewalsallowed} or $issuing_rule->{renewalsallowed} <= $issue->renewals_count; return ( 0, "too_unseen" ) if C4::Context->preference('UnseenRenewals') && @@ -2961,8 +2961,8 @@ sub AddRenewal { # Update the issues record to have the new due date, and a new count # of how many times it has been renewed. - my $renews = ( $issue->renewals || 0 ) + 1; - my $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, unseen_renewals = ?, lastreneweddate = ? WHERE issue_id = ?"); + my $renews = ( $issue->renewals_count || 0 ) + 1; + my $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals_count = ?, unseen_renewals = ?, lastreneweddate = ? WHERE issue_id = ?"); eval{ $sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $unseen_renewals, $lastreneweddate, $issue->issue_id ); @@ -2974,8 +2974,8 @@ sub AddRenewal { } # Update the renewal count on the item, and tell zebra to reindex - $renews = ( $item_object->renewals || 0 ) + 1; - $item_object->renewals($renews); + $renews = ( $item_object->renewals_count || 0 ) + 1; + $item_object->renewals_count($renews); $item_object->onloan($datedue); $item_object->store({ log_action => 0 }); @@ -3090,7 +3090,7 @@ sub GetRenewCount { ); $sth->execute( $bornum, $itemno ); my $data = $sth->fetchrow_hashref; - $renewcount = $data->{'renewals'} if $data->{'renewals'}; + $renewcount = $data->{'renewals_count'} if $data->{'renewals_count'}; $unseencount = $data->{'unseen_renewals'} if $data->{'unseen_renewals'}; # $item and $borrower should be calculated my $branchcode = _GetCircControlBranch($item->unblessed, $patron->unblessed); @@ -3884,7 +3884,7 @@ sub ProcessOfflineReturn { $itemnumber, $operation->{timestamp}, ); - $item->renewals(0); + $item->renewals_count(0); $item->onloan(undef); $item->store({ log_action => 0 }); return "Success."; --- a/C4/ILSDI/Services.pm +++ a/C4/ILSDI/Services.pm @@ -694,7 +694,7 @@ sub RenewLoan { # Hashref building my $out; - $out->{'renewals'} = $issue->renewals; + $out->{'renewals'} = $issue->renewals_count; $out->{date_due} = dt_from_string($issue->date_due)->strftime('%Y-%m-%d %H:%M'); $out->{'success'} = $renewal[0]; $out->{'error'} = $renewal[1]; --- a/C4/Members.pm +++ a/C4/Members.pm @@ -266,7 +266,7 @@ sub GetAllIssues { my $dbh = C4::Context->dbh; my $query = -'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 +'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 FROM issues LEFT JOIN items on items.itemnumber=issues.itemnumber LEFT JOIN borrowers on borrowers.borrowernumber=issues.issuer_id @@ -274,7 +274,7 @@ sub GetAllIssues { LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber WHERE issues.borrowernumber=? UNION ALL - 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 + 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 FROM old_issues LEFT JOIN items on items.itemnumber=old_issues.itemnumber LEFT JOIN borrowers on borrowers.borrowernumber=old_issues.issuer_id --- a/Koha/REST/V1/Checkouts.pm +++ a/Koha/REST/V1/Checkouts.pm @@ -193,7 +193,7 @@ sub allows_renewal { openapi => { allows_renewal => $renewable, max_renewals => $rule->rule_value, - current_renewals => $checkout->renewals, + current_renewals => $checkout->renewals_count, unseen_renewals => $checkout->unseen_renewals, error => $error } --- a/installer/data/mysql/atomicupdate/bug_30275.pl +++ a/installer/data/mysql/atomicupdate/bug_30275.pl @@ -21,6 +21,9 @@ return { ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; }); say $out "Added new table 'checkout_renewals'"; + + $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' }); + say $out "Renamed `issues.renewals` to `issues.renewals_count`"; } }, } --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -3006,7 +3006,7 @@ CREATE TABLE `issues` ( `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', `returndate` datetime DEFAULT NULL COMMENT 'date the item was returned, will be NULL until moved to old_issues', `lastreneweddate` datetime DEFAULT NULL COMMENT 'date the item was last renewed', - `renewals` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of times the item was renewed', + `renewals_count` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of times the item was renewed', `unseen_renewals` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of consecutive times the item was renewed without being seen', `auto_renew` tinyint(1) DEFAULT 0 COMMENT 'automatic renewal', `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 +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt @@ -90,7 +90,7 @@ [% INCLUDE 'patron-title.inc' patron=checkout.issuer %] [% END %] -