From bcd49711eedcb95aace112e4ebbfd7391e0f595e Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 8 Mar 2022 11:26:19 +0000 Subject: [PATCH] Bug 24857: Database updates This adds the new tables, syspref, and a new permission --- .../atomicupdate/bug_24857_item_groups.pl | 49 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 31 ++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../data/mysql/mandatory/userpermissions.sql | 1 + .../prog/en/includes/permissions.inc | 5 ++ .../admin/preferences/circulation.pref | 8 ++- 6 files changed, 94 insertions(+), 1 deletion(-) create mode 100755 installer/data/mysql/atomicupdate/bug_24857_item_groups.pl diff --git a/installer/data/mysql/atomicupdate/bug_24857_item_groups.pl b/installer/data/mysql/atomicupdate/bug_24857_item_groups.pl new file mode 100755 index 0000000000..1e6d87e2e6 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_24857_item_groups.pl @@ -0,0 +1,49 @@ +use Modern::Perl; + +return { + bug_number => "24857", + description => "Add ability to group items on a record", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + $dbh->do(q{ + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('EnableItemGroups','0','','Enable the item groups feature','YesNo'); + }); + + $dbh->do(q{ + INSERT INTO permissions (module_bit, code, description) VALUES + ( 9, 'manage_item_groups', 'Create, update and delete item groups, add or remove items from a item groups'); + }); + + unless ( TableExists('item_groups') ) { + $dbh->do(q{ + CREATE TABLE `item_groups` ( + `item_group_id` INT(11) NOT NULL auto_increment COMMENT "id for the items group", + `biblio_id` INT(11) NOT NULL DEFAULT 0 COMMENT "id for the bibliographic record the group belongs to", + `display_order` INT(4) NOT NULL DEFAULT 0 COMMENT "The 'sort order' for item_groups", + `description` MEDIUMTEXT default NULL COMMENT "A group description", + `created_on` TIMESTAMP NULL COMMENT "Time and date the group was created", + `updated_on` TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT "Time and date of the latest change on the group", + PRIMARY KEY (`item_group_id`), + CONSTRAINT `item_groups_ibfk_1` FOREIGN KEY (`biblio_id`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + }); + } + + unless ( TableExists('item_group_items') ) { + $dbh->do(q{ + CREATE TABLE `item_group_items` ( + `item_group_items_id` int(11) NOT NULL auto_increment COMMENT "id for the group/item link", + `item_group_id` INT(11) NOT NULL DEFAULT 0 COMMENT "foreign key making this table a 1 to 1 join from items to item groups", + `item_id` INT(11) NOT NULL DEFAULT 0 COMMENT "foreign key linking this table to the items table", + PRIMARY KEY (`item_group_items_id`), + UNIQUE KEY (`item_id`), + CONSTRAINT `item_group_items_iifk_1` FOREIGN KEY (`item_id`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `item_group_items_gifk_1` FOREIGN KEY (`item_group_id`) REFERENCES `item_groups` (`item_group_id`) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + }); + } + }, +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 51b6241c07..645b2de752 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1855,6 +1855,37 @@ CREATE TABLE `club_fields` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `item_groups` +-- + +DROP TABLE IF EXISTS `item_groups`; +CREATE TABLE `item_groups` ( + `item_group_id` INT(11) NOT NULL auto_increment COMMENT "id for the items group", + `biblio_id` INT(11) NOT NULL DEFAULT 0 COMMENT "id for the bibliographic record the group belongs to", + `display_order` INT(4) NOT NULL DEFAULT 0 COMMENT "The 'sort order' for item_groups", + `description` MEDIUMTEXT default NULL COMMENT "A group description", + `created_on` TIMESTAMP NULL COMMENT "Time and date the group was created", + `updated_on` TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT "Time and date of the latest change on the group", + PRIMARY KEY (`item_group_id`), + CONSTRAINT `item_groups_ibfk_1` FOREIGN KEY (`biblio_id`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- Table structure for table `item_group_items` +-- + +DROP TABLE IF EXISTS `item_group_items`; +CREATE TABLE `item_group_items` ( + `item_group_items_id` int(11) NOT NULL auto_increment COMMENT "id for the group/item link", + `item_group_id` INT(11) NOT NULL DEFAULT 0 COMMENT "foreign key making this table a 1 to 1 join from items to item groups", + `item_id` INT(11) NOT NULL DEFAULT 0 COMMENT "foreign key linking this table to the items table", + PRIMARY KEY (`item_group_items_id`), + UNIQUE KEY (`item_id`), + CONSTRAINT `item_group_items_iifk_1` FOREIGN KEY (`item_id`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `item_group_items_gifk_1` FOREIGN KEY (`item_group_id`) REFERENCES `item_groups` (`item_group_id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + -- -- Table structure for table `club_holds` -- diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 581e6be18b..8a1f3073b5 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -205,6 +205,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('EnableOpacSearchHistory','1','YesNo','Enable or disable opac search history',''), ('EnablePointOfSale','0',NULL,'Enable the point of sale feature to allow anonymous transactions with the accounting system. (Requires UseCashRegisters)','YesNo'), ('EnableSearchHistory','0','','Enable or disable search history','YesNo'), +('EnableItemGroups','0','','Enable the item groups feature','YesNo'), ('EnhancedMessagingPreferences','1','','If ON, allows patrons to select to receive additional messages about items due or nearly due.','YesNo'), ('EnhancedMessagingPreferencesOPAC', '1', NULL, 'If ON, show patrons messaging setting on the OPAC.', 'YesNo'), ('expandedSearchOption','0',NULL,'If ON, set advanced search to be expanded by default','YesNo'), diff --git a/installer/data/mysql/mandatory/userpermissions.sql b/installer/data/mysql/mandatory/userpermissions.sql index 6241c1a1ff..3a3f7f9b4e 100644 --- a/installer/data/mysql/mandatory/userpermissions.sql +++ b/installer/data/mysql/mandatory/userpermissions.sql @@ -50,6 +50,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES ( 9, 'edit_items', 'Edit items'), ( 9, 'edit_items_restricted', 'Limit item modification to subfields defined in the SubfieldsToAllowForRestrictedEditing preference (please note that edit_item is still required)'), ( 9, 'delete_all_items', 'Delete all items at once'), + ( 9, 'manage_item_groups', 'Create, update and delete item groups, add or remove items from a item groups'), (10, 'payout', 'Perform account payout action'), (10, 'refund', 'Perform account refund action'), (10, 'discount', 'Perform account discount action'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc index 445221fa52..3e70c155bc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -338,6 +338,11 @@ Fast cataloging ([% name | html %]) + [%- CASE 'manage_item_groups' -%] + + Create, update and delete item groups, add or remove items from an item group + + ([% name | html %]) [%- CASE 'remaining_permissions' -%] Remaining permissions for managing fines and fees 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 6810f251c5..954098388b 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 @@ -666,7 +666,13 @@ Circulation: - 'the last patron to return an item. This setting is independent of the opacreadinghistory and AnonymousPatron system preferences.' Holds policy: - - - In the staff interface, split the holds queue into separate tables by + - pref: EnableItemGroups + choices: + yes: Enable + no: "Don't enable" + - the item groups feature to allow collecting groups of items on a record together. + - + - In the staff client, split the holds queue into separate tables by - pref: HoldsSplitQueue choices: nothing: nothing -- 2.30.2