From cfa6e15169b24d7368d29cd6d20d3f207523ea84 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 28 Feb 2020 10:37:05 -0500 Subject: [PATCH] Bug 24860: Add reserves.item_group_it This feature builds upon bug 24857 and allows placing holds that target a specific item group of a record. It is patterned after the feature that allows limiting hold selection by itemtype ( AllowHoldItemTypeSelection ). Test Plan: 1) Apply bug 24857 and this bug's patches 2) Run updatedatabase.pl 3) Restart all the things! 4) Enable the sysprefs EnableVolumes and EnableVolumeHolds 5) Create a record, items and item groups, with each item being assigned to an item group 6) Place a hold for a patron 7) Note the new selector to choose an item group in addition to record and item level holds 8) Place an item group level hold 9) Check in an item from the record that is not part of that item group 10) Note the hold is not trapped for that item 11) Check in an item from the record that *is* part of that item group 12) Note the hold is trapped for that item 13) Place an item group level hold for another item 14) Run the holds queue builder 15) Note the holds queue targets only items from that item group 16) Check out all the items of that item group to other patrosn 17) Re-run the holds queue builder 18) Note the holds queue no longer has a line for that hold, as all items that could fill that hold are now unavailable Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Rebecca Coert Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- .../data/mysql/atomicupdate/bug_24860.perl | 21 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 4 ++++ 2 files changed, 25 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_24860.perl diff --git a/installer/data/mysql/atomicupdate/bug_24860.perl b/installer/data/mysql/atomicupdate/bug_24860.perl new file mode 100644 index 0000000000..5e7c72bc3d --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_24860.perl @@ -0,0 +1,21 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if ( CheckVersion( $DBversion ) ) { + unless ( column_exists( 'reserves', 'item_group_id' ) ) { + $dbh->do(q{ + ALTER TABLE reserves + ADD COLUMN `item_group_id` int(11) NULL default NULL AFTER biblionumber, + ADD CONSTRAINT `reserves_ibfk_ig` FOREIGN KEY (`item_group_id`) REFERENCES `item_groups` (`item_group_id`) ON DELETE SET NULL ON UPDATE CASCADE; + }); + } + + unless ( column_exists( 'old_reserves', 'item_group_id' ) ) { + $dbh->do(q{ + ALTER TABLE old_reserves + ADD COLUMN `item_group_id` int(11) NULL default NULL AFTER biblionumber, + ADD CONSTRAINT `old_reserves_ibfk_ig` FOREIGN KEY (`item_group_id`) REFERENCES `item_groups` (`item_group_id`) ON DELETE SET NULL ON UPDATE SET NULL; + }); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 24860 - Add ability to place item group level holds)\n"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index e88c75f5d4..4fa9db4705 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -4101,6 +4101,7 @@ CREATE TABLE `old_reserves` ( `borrowernumber` int(11) DEFAULT NULL COMMENT 'foreign key from the borrowers table defining which patron this hold is for', `reservedate` date DEFAULT NULL COMMENT 'the date the hold was places', `biblionumber` int(11) DEFAULT NULL COMMENT 'foreign key from the biblio table defining which bib record this hold is on', + `item_group_id` int(11) NULL default NULL COMMENT 'foreign key from the item_groups table defining if this is an item group level hold', `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'foreign key from the branches table defining which branch the patron wishes to pick this hold up at', `desk_id` int(11) DEFAULT NULL COMMENT 'foreign key from the desks table defining which desk the patron should pick this hold up at', `notificationdate` date DEFAULT NULL COMMENT 'currently unused', @@ -4127,6 +4128,7 @@ CREATE TABLE `old_reserves` ( KEY `old_reserves_itemnumber` (`itemnumber`), KEY `old_reserves_branchcode` (`branchcode`), KEY `old_reserves_itemtype` (`itemtype`), + CONSTRAINT `old_reserves_ibfk_ig` FOREIGN KEY (`item_group_id`) REFERENCES `item_groups` (`item_group_id`) ON DELETE SET NULL ON UPDATE SET NULL, CONSTRAINT `old_reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL, CONSTRAINT `old_reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE SET NULL, CONSTRAINT `old_reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL, @@ -4547,6 +4549,7 @@ CREATE TABLE `reserves` ( `borrowernumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from the borrowers table defining which patron this hold is for', `reservedate` date DEFAULT NULL COMMENT 'the date the hold was placed', `biblionumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from the biblio table defining which bib record this hold is on', + `item_group_id` int(11) NULL default NULL COMMENT 'foreign key from the item_groups table defining if this is an item group level hold', `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'foreign key from the branches table defining which branch the patron wishes to pick this hold up at', `desk_id` int(11) DEFAULT NULL COMMENT 'foreign key from the desks table defining which desk the patron should pick this hold up at', `notificationdate` date DEFAULT NULL COMMENT 'currently unused', @@ -4575,6 +4578,7 @@ CREATE TABLE `reserves` ( KEY `branchcode` (`branchcode`), KEY `desk_id` (`desk_id`), KEY `itemtype` (`itemtype`), + CONSTRAINT `reserves_ibfk_ig` FOREIGN KEY (`item_group_id`) REFERENCES `item_groups` (`item_group_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE, -- 2.39.5