Bugzilla – Attachment 187971 Details for
Bug 40517
Allow grouping existing holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40517: Add visual_group_id to hold_groups
Bug-40517-Add-visualgroupid-to-holdgroups.patch (text/plain), 4.68 KB, created by
Pedro Amorim
on 2025-10-16 08:41:43 UTC
(
hide
)
Description:
Bug 40517: Add visual_group_id to hold_groups
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2025-10-16 08:41:43 UTC
Size:
4.68 KB
patch
obsolete
>From 3152aca2d1a3cacd3c0bc426c5b37414d014eefd Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@openfifth.co.uk> >Date: Thu, 17 Jul 2025 14:42:56 +0000 >Subject: [PATCH] Bug 40517: Add visual_group_id to hold_groups > >Signed-off-by: Anneli <anneli.osterman@koha-suomi.fi> >Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com> >--- > Koha/Patron.pm | 8 +++++++- > api/v1/swagger/definitions/hold_group.yaml | 3 +++ > .../atomicupdate/bug_40517_-_hold_group_table_updates.pl | 9 ++++++++- > installer/data/mysql/kohastructure.sql | 1 + > svc/holds | 1 + > 5 files changed, 20 insertions(+), 2 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 6001c3684f7..745355819d5 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -1957,9 +1957,15 @@ sub create_hold_group { > hold_ids => \@already_in_group_holds, > ) if @already_in_group_holds && !$force_grouped; > >+ my @existing_ids = $self->_result->hold_groups->get_column('visual_hold_group_id')->all; >+ my $next_available_visual_hold_group_id = 1; >+ while ( grep { $_ == $next_available_visual_hold_group_id } @existing_ids ) { >+ $next_available_visual_hold_group_id++; >+ } >+ > my $hold_group_rs = $self->_result->create_related( > 'hold_groups', >- {} >+ { visual_hold_group_id => $next_available_visual_hold_group_id } > ); > foreach my $hold_id (@$hold_ids) { > my $hold = Koha::Holds->find($hold_id); >diff --git a/api/v1/swagger/definitions/hold_group.yaml b/api/v1/swagger/definitions/hold_group.yaml >index cb9d34cc88e..271c262b58b 100644 >--- a/api/v1/swagger/definitions/hold_group.yaml >+++ b/api/v1/swagger/definitions/hold_group.yaml >@@ -7,6 +7,9 @@ properties: > borrowernumber: > type: integer > description: Patron this hold group belongs to >+ visual_hold_group_id: >+ type: integer >+ description: Visual ID for this hold group, in the context of the related patron > holds: > type: > - array >diff --git a/installer/data/mysql/atomicupdate/bug_40517_-_hold_group_table_updates.pl b/installer/data/mysql/atomicupdate/bug_40517_-_hold_group_table_updates.pl >index e520c378a40..0d7511eb763 100755 >--- a/installer/data/mysql/atomicupdate/bug_40517_-_hold_group_table_updates.pl >+++ b/installer/data/mysql/atomicupdate/bug_40517_-_hold_group_table_updates.pl >@@ -3,7 +3,7 @@ use Koha::Installer::Output qw(say_warning say_success say_info); > > return { > bug_number => "40517", >- description => "Add 'borrower' column to hold_groups", >+ description => "Add 'borrower' and 'visual_hold_group_id' column to hold_groups", > up => sub { > my ($args) = @_; > my ( $dbh, $out ) = @$args{qw(dbh out)}; >@@ -27,5 +27,12 @@ return { > ); > say_success( $out, "Added column 'borrowernumber' to hold_groups" ); > } >+ >+ unless ( column_exists( 'hold_groups', 'visual_hold_group_id' ) ) { >+ $dbh->do( >+ q{ALTER TABLE hold_groups ADD COLUMN visual_hold_group_id int(11) DEFAULT NULL COMMENT 'visual ID for this hold group, in the context of the related patron' AFTER borrowernumber} >+ ); >+ say_success( $out, "Added column 'visual_hold_group_id' to hold_groups" ); >+ } > }, > }; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 5da6ad17509..330155a4f77 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -3552,6 +3552,7 @@ DROP TABLE IF EXISTS `hold_groups`; > CREATE TABLE `hold_groups` ( > `hold_group_id` int(10) unsigned NOT NULL AUTO_INCREMENT, > `borrowernumber` int(11) DEFAULT NULL COMMENT 'foreign key, linking this to the borrowers table', >+ `visual_hold_group_id` int(11) DEFAULT NULL COMMENT 'visual ID for this hold group, in the context of the related patron', > KEY `hold_groups_borrowernumber` (`borrowernumber`), > CONSTRAINT `hold_groups_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE, > PRIMARY KEY (`hold_group_id`) >diff --git a/svc/holds b/svc/holds >index 1f9acb167a6..864841851a9 100755 >--- a/svc/holds >+++ b/svc/holds >@@ -114,6 +114,7 @@ while ( my $h = $holds_rs->next() ) { > reservenotes => $h->reservenotes(), > itemtype_limit => $itemtype_limit, > hold_group_id => $h->hold_group_id, >+ visual_hold_group_id => $h->hold_group ? $h->hold_group->visual_hold_group_id : q{}, > reservedate_formatted => $h->reservedate() > ? output_pref( { dt => dt_from_string( $h->reservedate() ), dateonly => 1 } ) > : q{}, >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40517
:
184640
|
184641
|
184642
|
184643
|
184644
|
184645
|
184646
|
184729
|
184732
|
184733
|
184734
|
184735
|
184736
|
184737
|
184738
|
184739
|
185217
|
186672
|
186673
|
186674
|
186675
|
186676
|
186677
|
186678
|
186679
|
186680
|
186745
|
186746
|
186747
|
186748
|
186749
|
186750
|
186751
|
186752
|
186753
|
187789
|
187790
|
187791
|
187792
|
187793
|
187794
|
187795
|
187796
|
187797
|
187801
|
187802
|
187803
|
187804
|
187805
|
187806
|
187807
|
187808
|
187809
|
187810
|
187811
|
187812
|
187965
|
187966
|
187967
|
187968
|
187969
|
187970
| 187971 |
187972
|
187973
|
187974
|
187975
|
187976
|
188293
|
188294
|
188343
|
188422