From 083498c71808992989c13a1f499499ecd3b41e6d Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 5 Dec 2019 08:54:49 -0500 Subject: [PATCH] Bug 24857: Update Database We have a partner that needs Volume Level Holds. This is a feature that some ILSs have that allows the creation of volumes at the bibliographic level, with items being optionally assigned to a given volume. This facilitates the ability to place holds at a volume level, rather than on a specific item or any available item on a record. Test Plan: 1) Apply the patches for this bug 2) Run updatedatabase.pl 3) Restart all the things! 4) Enable the new syspref EnableVolumes 5) Browse to detail.pl for a record with items 6) Note the new volumes tab 7) Test creating, editing and deleting volumes 8) On the Holdings tab, select one or more items using the checkboxes 8) Note new selection options for setting a volume for items, and for clearing a volume for items. 9) Test adding and clearing the volume set for items Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Rebecca Coert --- .../data/mysql/atomicupdate/volumes.perl | 40 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 31 ++++++++++++++ installer/data/mysql/sysprefs.sql | 1 + .../admin/preferences/circulation.pref | 6 +++ 4 files changed, 78 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/volumes.perl diff --git a/installer/data/mysql/atomicupdate/volumes.perl b/installer/data/mysql/atomicupdate/volumes.perl new file mode 100644 index 0000000000..7f60669fe8 --- /dev/null +++ b/installer/data/mysql/atomicupdate/volumes.perl @@ -0,0 +1,40 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if ( CheckVersion( $DBversion ) ) { + $dbh->do(q{ + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('EnableVolumes','0','','Enable volumes feature','YesNo'); + }); + + unless ( TableExists('volumes') ) { + $dbh->do(q{ + CREATE TABLE `volumes` ( -- information related to bibliographic records in Koha + `id` int(11) NOT NULL auto_increment, -- primary key, unique identifier assigned by Koha + `biblionumber` INT(11) NOT NULL default 0, -- foreign key linking this table to the biblio table + `display_order` INT(4) NOT NULL default 0, -- specifies the 'sort order' for volumes + `description` MEDIUMTEXT default NULL, -- equivilent to enumchron + `created_on` TIMESTAMP NULL, -- Time and date the volume was created + `updated_on` TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- Time and date of the latest change on the volume (description) + PRIMARY KEY (`id`), + CONSTRAINT `volumes_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + }); + } + + unless ( TableExists('volume_items') ) { + $dbh->do(q{ + CREATE TABLE `volume_items` ( -- information related to bibliographic records in Koha + `id` int(11) NOT NULL auto_increment, -- primary key, unique identifier assigned by Koha + `volume_id` int(11) NOT NULL default 0, -- foreign key making this table a 1 to 1 join from items to volumes + `itemnumber` int(11) NOT NULL default 0, -- foreign key linking this table to the items table + PRIMARY KEY (`id`), + UNIQUE KEY (volume_id,itemnumber), + CONSTRAINT `volume_items_iifk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `volume_items_vifk_1` FOREIGN KEY (`volume_id`) REFERENCES `volumes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + }); + } + + # Always end with this (adjust the bug info) + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug XXXXX - Add ability to define volumes for items on a record)\n"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 35c643fa38..5db85f7b17 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1746,6 +1746,37 @@ CREATE TABLE `patronimage` ( -- information related to patron images CONSTRAINT `patronimage_fk1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +-- +-- Table structure for table `volumes` +-- + +DROP TABLE IF EXISTS `volumes`; +CREATE TABLE `volumes` ( -- information related to bibliographic records in Koha + `id` int(11) NOT NULL auto_increment, -- primary key, unique identifier assigned by Koha + `biblionumber` INT(11) NOT NULL default 0, -- foreign key linking this table to the biblio table + `display_order` INT(4) NOT NULL default 0, -- specifies the 'sort order' for volumes + `description` MEDIUMTEXT default NULL, -- equivilent to enumchron + `created_on` TIMESTAMP NULL, -- Time and date the volume was created + `updated_on` TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- Time and date of the latest change on the volume (description) + PRIMARY KEY (`id`), + CONSTRAINT `volumes_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- Table structure for table `volume_items` +-- + +DROP TABLE IF EXISTS `volume_items`; +CREATE TABLE `volume_items` ( -- information related to bibliographic records in Koha + `id` int(11) NOT NULL auto_increment, -- primary key, unique identifier assigned by Koha + `volume_id` int(11) NOT NULL default 0, -- foreign key making this table a 1 to 1 join from items to volumes + `itemnumber` int(11) NOT NULL default 0, -- foreign key linking this table to the items table + PRIMARY KEY (`id`), + UNIQUE KEY (volume_id,itemnumber), + CONSTRAINT `volume_items_iifk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `volume_items_vifk_1` FOREIGN KEY (`volume_id`) REFERENCES `volumes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + -- -- Table structure for table `reserves` -- diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 0924a4271d..a95a46165a 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -693,6 +693,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('UseICU','0','1','Tell Koha if ICU indexing is in use for Zebra or not.','YesNo'), ('UseTransportCostMatrix','0','','Use Transport Cost Matrix when filling holds','YesNo'), ('UseWYSIWYGinSystemPreferences','0','','Show WYSIWYG editor when editing certain HTML system preferences.','YesNo'), +('EnableVolumes','0','','Enable volumes feature','YesNo'), ('viewISBD','1','','Allow display of ISBD view of bibiographic records','YesNo'), ('viewLabeledMARC','0','','Allow display of labeled MARC view of bibiographic records','YesNo'), ('viewMARC','1','','Allow display of MARC view of bibiographic records','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index 1e2c4bf1ba..b3e8a48622 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -621,6 +621,12 @@ Circulation: no: "Don't store" - the last patron to return an item. This setting is independent of opacreadinghistory/AnonymousPatron. Holds policy: + - + - pref: EnableVolumes + choices: + yes: Enable + no: "Don't enable" + - volumes feature to allow collecting groups of items on a record into volumes. - - In the staff client, split the holds queue into separate tables by - pref: HoldsSplitQueue -- 2.24.1 (Apple Git-126)