From d671335db5b07c2e29643695a7b856a86477303d Mon Sep 17 00:00:00 2001 From: Alex Sassmannshausen Date: Mon, 17 Oct 2016 18:20:44 +0200 Subject: [PATCH] Bug 11897: Add Stock Rotation atomic update schema. * installer/data/mysql/atomicupdate/stockrot_tables.sql: New file. * installer/data/mysql/kohastructure.sql (stockrotationrotas) (stockrotationstages, stockrotationitems): New tables. * installer/data/mysql/sysprefs.sql: Add Stockrotation sysprefs. * installer/data/mysql/userflags.sql: Add Stockrotaiton userflag. * installer/data/mysql/userpermissions.sql: Add Stockrotation userpermissions. * koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref: Add Stockrotation menu. --- .../data/mysql/atomicupdate/stockrot_tables.sql | 61 ++++++++++++++++++++++ installer/data/mysql/kohastructure.sql | 47 +++++++++++++++++ installer/data/mysql/sysprefs.sql | 2 + installer/data/mysql/userflags.sql | 1 + installer/data/mysql/userpermissions.sql | 2 + .../en/modules/admin/preferences/circulation.pref | 13 +++++ 6 files changed, 126 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/stockrot_tables.sql diff --git a/installer/data/mysql/atomicupdate/stockrot_tables.sql b/installer/data/mysql/atomicupdate/stockrot_tables.sql new file mode 100644 index 0000000..ee8cee1 --- /dev/null +++ b/installer/data/mysql/atomicupdate/stockrot_tables.sql @@ -0,0 +1,61 @@ +-- Stock Rotation Rotas + +CREATE TABLE IF NOT EXISTS stockrotationrotas ( + rota_id int(11) auto_increment, -- Stockrotation rota ID + title varchar(100) NOT NULL, -- Title for this rota + description text NOT NULL default '', -- Description for this rota + cyclical tinyint(1) NOT NULL default 0, -- Should items on this rota keep cycling? + active tinyint(1) NOT NULL default 0, -- Is this rota currently active? + PRIMARY KEY (`rota_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +-- Stock Rotation Stages + +CREATE TABLE IF NOT EXISTS stockrotationstages ( + stage_id int(11) auto_increment, -- Unique stage ID + position int(11) NOT NULL, -- The position of this stage within its rota + rota_id int(11) NOT NULL, -- The rota this stage belongs to + branchcode_id varchar(10) NOT NULL, -- Branch this stage relates to + duration int(11) NOT NULL default 4, -- The number of days items shoud occupy this stage + PRIMARY KEY (`stage_id`), + CONSTRAINT `stockrotationstages_rifk` + FOREIGN KEY (`rota_id`) + REFERENCES `stockrotationrotas` (`rota_id`) + ON UPDATE CASCADE ON DELETE CASCADE, + CONSTRAINT `stockrotationstages_bifk` + FOREIGN KEY (`branchcode_id`) + REFERENCES `branches` (`branchcode`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +-- Stock Rotation Items + +CREATE TABLE IF NOT EXISTS stockrotationitems ( + itemnumber_id int(11) NOT NULL, -- Itemnumber to link to a stage & rota + stage_id int(11) NOT NULL, -- stage ID to link the item to + indemand tinyint(1) NOT NULL default 0, -- Should this item be skipped for rotation? + PRIMARY KEY (itemnumber_id), + CONSTRAINT `stockrotationitems_iifk` + FOREIGN KEY (`itemnumber_id`) + REFERENCES `items` (`itemnumber`) + ON UPDATE CASCADE ON DELETE CASCADE, + CONSTRAINT `stockrotationitems_sifk` + FOREIGN KEY (`stage_id`) + REFERENCES `stockrotationstages` (`stage_id`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +-- System preferences + +INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES + ('StockRotation','0','If ON, enables the stock rotation module','','YesNo'), + ('RotationPreventTransfers','0','If ON, prevent any transfers for items on stock rotation rotas, except for stock rotation transfers','','YesNo'); + +-- Permissions + +INSERT IGNORE INTO userflags (bit, flag, flagdesc, defaulton) VALUES + (21, 'stockrotation', 'Manage stockrotation operations', 0); + +INSERT IGNORE INTO permissions (module_bit, code, description) VALUES + (21, 'can_edit_rotas', 'Create, edit and delete rotas'), + (21, 'can_add_items_rotas', 'Add and remove items from rotas'); diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 514c13d..52eb7c6 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -3921,6 +3921,53 @@ CREATE TABLE `article_requests` ( CONSTRAINT `article_requests_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +-- Stock Rotation Rotas + +CREATE TABLE IF NOT EXISTS stockrotationrotas ( + rota_id int(11) auto_increment, -- Stockrotation rota ID + title varchar(100) NOT NULL, -- Title for this rota + description text NOT NULL default '', -- Description for this rota + cyclical tinyint(1) NOT NULL default 0, -- Should items on this rota keep cycling? + active tinyint(1) NOT NULL default 0, -- Is this rota currently active? + PRIMARY KEY (`rota_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +-- Stock Rotation Stages + +CREATE TABLE IF NOT EXISTS stockrotationstages ( + stage_id int(11) auto_increment, -- Unique stage ID + position int(11) NOT NULL, -- The position of this stage within its rota + rota_id int(11) NOT NULL, -- The rota this stage belongs to + branchcode_id varchar(10) NOT NULL, -- Branch this stage relates to + duration int(11) NOT NULL default 4, -- The number of days items shoud occupy this stage + PRIMARY KEY (`stage_id`), + CONSTRAINT `stockrotationstages_rifk` + FOREIGN KEY (`rota_id`) + REFERENCES `stockrotationrotas` (`rota_id`) + ON UPDATE CASCADE ON DELETE CASCADE, + CONSTRAINT `stockrotationstages_bifk` + FOREIGN KEY (`branchcode_id`) + REFERENCES `branches` (`branchcode`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +-- Stock Rotation Items + +CREATE TABLE IF NOT EXISTS stockrotationitems ( + itemnumber_id int(11) NOT NULL, -- Itemnumber to link to a stage & rota + stage_id int(11) NOT NULL, -- stage ID to link the item to + indemand tinyint(1) NOT NULL default 0, -- Should this item be skipped for rotation? + PRIMARY KEY (itemnumber_id), + CONSTRAINT `stockrotationitems_iifk` + FOREIGN KEY (`itemnumber_id`) + REFERENCES `items` (`itemnumber`) + ON UPDATE CASCADE ON DELETE CASCADE, + CONSTRAINT `stockrotationitems_sifk` + FOREIGN KEY (`stage_id`) + REFERENCES `stockrotationstages` (`stage_id`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index ef83c3d..89792d9 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -564,4 +564,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('XSLTResultsDisplay','default','','Enable XSL stylesheet control over results page display on intranet','Free'), ('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'), ('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo') +('StockRotation','0','If ON, enables the stock rotation module','','YesNo') +('RotationPreventTransfers','0','If ON, prevent any transfers for items on stock rotation rotas, except for stock rotation transfers','','YesNo') ; diff --git a/installer/data/mysql/userflags.sql b/installer/data/mysql/userflags.sql index d8e3626..a66243c 100644 --- a/installer/data/mysql/userflags.sql +++ b/installer/data/mysql/userflags.sql @@ -18,4 +18,5 @@ INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES (18,'coursereserves','Course reserves',0), (19, 'plugins', 'Koha plugins', '0'), (20, 'lists', 'Lists', 0) +(21, 'stockrotation', 'Manage stockrotation operations', 0) ; diff --git a/installer/data/mysql/userpermissions.sql b/installer/data/mysql/userpermissions.sql index 6b72278..b9f36c6 100644 --- a/installer/data/mysql/userpermissions.sql +++ b/installer/data/mysql/userpermissions.sql @@ -79,4 +79,6 @@ INSERT INTO permissions (module_bit, code, description) VALUES (19, 'report', 'Use report plugins'), (19, 'configure', 'Configure plugins'), (20, 'delete_public_lists', 'Delete public lists') + (21, 'can_edit_rotas', 'Create, edit and delete rotas') + (21, 'can_add_items_rotas', 'Add and remove items from rotas') ; 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 e69e37f..1bd4998 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 @@ -782,6 +782,19 @@ Circulation: yes: Enable no: Disable - "housebound module" + Stockrotation module: + - + - pref: StockRotation + choices: + yes: Enable + no: Disable + - "Enable the stock rotation module" + - + - pref: RotationPreventTransfers + choices: + yes: Enable + no: Disable + - "Prevent branchtransfers on items in stockrotation rotas" Article Requests: - - pref: ArticleRequests -- 2.1.4