diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 6fcd491820..068093e7a6 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3068,6 +3068,9 @@ sub AddRenewal { my $issue = $item_object->checkout; my $item_unblessed = $item_object->unblessed; + my ($package, $filename, $line) = caller; + my $renewal_type = $filename =~ m/automatic_renewals.pl/ ? "Automatic" : "Manual"; + my $dbh = C4::Context->dbh; return unless $issue; @@ -3206,7 +3209,8 @@ sub AddRenewal { checkout_id => $issue->issue_id, renewer_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef, seen => $seen, - interface => C4::Context->interface + interface => C4::Context->interface, + renewal_type => $renewal_type } )->store(); diff --git a/Koha/Schema/Result/CheckoutRenewal.pm b/Koha/Schema/Result/CheckoutRenewal.pm index bf3cbe1883..9efbd93630 100644 --- a/Koha/Schema/Result/CheckoutRenewal.pm +++ b/Koha/Schema/Result/CheckoutRenewal.pm @@ -69,6 +69,14 @@ the interface this renewal took place on the date and time the renewal took place +=head2 renewal_type + + data_type: 'varchar' + is_nullable: 0 + size: 9 + +whether the renewal was an automatic or manual renewal + =cut __PACKAGE__->add_columns( @@ -89,6 +97,8 @@ __PACKAGE__->add_columns( default_value => \"current_timestamp", is_nullable => 0, }, + "renewal_type", + { data_type => "varchar", is_nullable => 0, size => 9 }, ); =head1 PRIMARY KEY @@ -126,8 +136,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-04-27 19:43:17 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7mjiEx634L5FZyjroACUkg +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-12-06 16:44:53 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:BcbN0Iceh09H2DWEA6CDwA =head2 checkout diff --git a/api/v1/swagger/definitions/renewal.yaml b/api/v1/swagger/definitions/renewal.yaml index 95e6d94816..895fe4811e 100644 --- a/api/v1/swagger/definitions/renewal.yaml +++ b/api/v1/swagger/definitions/renewal.yaml @@ -28,6 +28,10 @@ properties: timestamp: type: string description: Last update time + renewal_type: + type: + - string + - "null" renewer: type: - object diff --git a/installer/data/mysql/atomicupdate/bug_30642-add_renewal_type.pl b/installer/data/mysql/atomicupdate/bug_30642-add_renewal_type.pl new file mode 100644 index 0000000000..cc86ed11b7 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_30642-add_renewal_type.pl @@ -0,0 +1,18 @@ +use Modern::Perl; + +return { + bug_number => "BUG_30642", + description => "Record whether a renewal has been done manually or automatically.", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + if( !column_exists( 'checkout_renewals', 'renewal_type' ) ) { + $dbh->do(q{ + ALTER TABLE checkout_renewals ADD COLUMN `renewal_type` varchar(9) NOT NULL AFTER `timestamp` + }); + + say $out "Added column 'checkout_renewals.column_name'"; + } + }, +}; \ No newline at end of file diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index cda278174e..257574e957 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1714,6 +1714,7 @@ CREATE TABLE `checkout_renewals` ( `seen` tinyint(1) DEFAULT 0 COMMENT 'boolean denoting whether the item was present or not', `interface` varchar(16) NOT NULL COMMENT 'the interface this renewal took place on', `timestamp` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'the date and time the renewal took place', + `renewal_type` varchar(9) NOT NULL COMMENT 'whether the renewal was an automatic or manual renewal', PRIMARY KEY (`renewal_id`), KEY `renewer_id` (`renewer_id`), CONSTRAINT `renewals_renewer_id` FOREIGN KEY (`renewer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/str/checkout_renewals.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/str/checkout_renewals.inc index a8dfcde80b..3dc7138355 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/str/checkout_renewals.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/str/checkout_renewals.inc @@ -2,4 +2,5 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkout_renewals_modal.js b/koha-tmpl/intranet-tmpl/prog/js/checkout_renewals_modal.js index d6448ebabe..4ca4c6cf73 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkout_renewals_modal.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkout_renewals_modal.js @@ -20,6 +20,6 @@ $(document).ready(function(){ }); }); function createLi(renewal) { - return '