From 19f29ffd0434aa7c1d5a52ed10fb5736e3657f2d Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 18 Dec 2023 14:19:02 -0500 Subject: [PATCH] Bug 28530: Update database, add new schema file Signed-off-by: Andrew Fuerste-Henry --- Koha/Schema/Result/LibraryFloatLimit.pm | 123 ++++++++++++++++++ .../data/mysql/atomicupdate/bug_28530.pl | 40 ++++++ installer/data/mysql/kohastructure.sql | 15 ++- installer/data/mysql/mandatory/sysprefs.sql | 1 + .../admin/preferences/circulation.pref | 6 + 5 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 Koha/Schema/Result/LibraryFloatLimit.pm create mode 100755 installer/data/mysql/atomicupdate/bug_28530.pl diff --git a/Koha/Schema/Result/LibraryFloatLimit.pm b/Koha/Schema/Result/LibraryFloatLimit.pm new file mode 100644 index 00000000000..9013ee43cb7 --- /dev/null +++ b/Koha/Schema/Result/LibraryFloatLimit.pm @@ -0,0 +1,123 @@ +use utf8; +package Koha::Schema::Result::LibraryFloatLimit; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::LibraryFloatLimit + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("library_float_limits"); + +=head1 ACCESSORS + +=head2 branchcode + + data_type: 'varchar' + is_foreign_key: 1 + is_nullable: 0 + size: 10 + +=head2 itemtype + + data_type: 'varchar' + is_foreign_key: 1 + is_nullable: 0 + size: 10 + +=head2 float_limit + + data_type: 'integer' + is_nullable: 1 + +=cut + +__PACKAGE__->add_columns( + "branchcode", + { data_type => "varchar", is_foreign_key => 1, is_nullable => 0, size => 10 }, + "itemtype", + { data_type => "varchar", is_foreign_key => 1, is_nullable => 0, size => 10 }, + "float_limit", + { data_type => "integer", is_nullable => 1 }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("branchcode", "itemtype"); + +=head1 RELATIONS + +=head2 branchcode + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "branchcode", + "Koha::Schema::Result::Branch", + { branchcode => "branchcode" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + +=head2 itemtype + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "itemtype", + "Koha::Schema::Result::Itemtype", + { itemtype => "itemtype" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-12-19 18:47:35 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:AnpZIyNq9oO1vmDSXmQEMQ + +=head2 koha_object_class + +=cut + +sub koha_object_class { + 'Koha::Library::FloatLimit'; +} + +=head2 koha_objects_class + +=cut + +sub koha_objects_class { + 'Koha::Library::FloatLimits'; +} + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; diff --git a/installer/data/mysql/atomicupdate/bug_28530.pl b/installer/data/mysql/atomicupdate/bug_28530.pl new file mode 100755 index 00000000000..605d50f84fd --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_28530.pl @@ -0,0 +1,40 @@ +use Modern::Perl; + +return { + bug_number => "28530", + description => "Add library float limits", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{ + ALTER TABLE branchtransfers MODIFY COLUMN `reason` enum('Manual','StockrotationAdvance','StockrotationRepatriation','ReturnToHome','ReturnToHolding','RotatingCollection','Reserve','LostReserve','CancelReserve','TransferCancellation','Recall','RecallCancellation', 'LibraryFloatLimit') DEFAULT NULL COMMENT 'what triggered the transfer' + } + ); + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('UseLibraryFloatLimits', '0', '', 'Enables library float limits', 'YesNo'); + } + ); + say $out "Added new system preference 'UseLibraryFloatLimits'"; + + unless ( TableExists('library_float_limits') ) { + $dbh->do( + q{ + CREATE TABLE `library_float_limits` ( + `branchcode` varchar(10) NOT NULL, + `itemtype` varchar(10) NOT NULL, + `float_limit` int(11) NULL DEFAULT NULL, + PRIMARY KEY (`branchcode`,`itemtype`), + CONSTRAINT `library_float_limits_ibfk_bc` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `library_float_limits_ibfk_it` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + } + ); + } + say $out "Added new table 'library_float_limits'"; + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 14cef909b3a..93128a6223a 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1701,7 +1701,7 @@ CREATE TABLE `branchtransfers` ( `datecancelled` datetime DEFAULT NULL COMMENT 'the date the transfer was cancelled', `tobranch` varchar(10) NOT NULL DEFAULT '' COMMENT 'the branch the transfer was going to', `comments` longtext DEFAULT NULL COMMENT 'any comments related to the transfer', - `reason` enum('Manual','StockrotationAdvance','StockrotationRepatriation','ReturnToHome','ReturnToHolding','RotatingCollection','Reserve','LostReserve','CancelReserve','TransferCancellation','Recall','RecallCancellation') DEFAULT NULL COMMENT 'what triggered the transfer', + `reason` enum('Manual','StockrotationAdvance','StockrotationRepatriation','ReturnToHome','ReturnToHolding','RotatingCollection','Reserve','LostReserve','CancelReserve','TransferCancellation','Recall','RecallCancellation','LibraryFloatLimit') DEFAULT NULL COMMENT 'what triggered the transfer', `cancellation_reason` enum('Manual','StockrotationAdvance','StockrotationRepatriation','ReturnToHome','ReturnToHolding','RotatingCollection','Reserve','LostReserve','CancelReserve','ItemLost','WrongTransfer','RecallCancellation') DEFAULT NULL COMMENT 'what triggered the transfer cancellation', PRIMARY KEY (`branchtransfer_id`), KEY `frombranch` (`frombranch`), @@ -6418,6 +6418,19 @@ CREATE TABLE `transport_cost` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `library_float_limits`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `library_float_limits` ( + `branchcode` varchar(10) NOT NULL, + `itemtype` varchar(10) NOT NULL, + `float_limit` int(11) NULL DEFAULT NULL, + PRIMARY KEY (`branchcode`,`itemtype`), + CONSTRAINT `library_float_limits_ibfk_bc` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `library_float_limits_ibfk_it` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `uploaded_files` -- diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 2d76cd072e0..58e33bb13a9 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -837,6 +837,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('useDischarge','0','','Allows librarians to discharge borrowers and borrowers to request a discharge','YesNo'), ('UseEmailReceipts','0','','Send email receipts for payments and write-offs','YesNo'), ('UseICUStyleQuotes','0','1','Tell Koha whether to use ICU style quotes ({) or default (") when tracing subjects .','YesNo'), +('UseLibraryFloatLimits', '0', '', 'Enables library float limits', 'YesNo'), ('UseLocationAsAQInSIP', '0', '', 'Use permanent_location instead of homebranch for AQ in SIP response', 'YesNo'), ('UseOCLCEncodingLevels','0',NULL,'If enabled, include OCLC encoding levels in leader value builder dropdown for position 17.','YesNo'), ('UseRecalls','0',NULL,'Enable or disable recalls','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 3ba6d9b0367..f067894671d 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 @@ -267,6 +267,12 @@ Circulation: 1: Use 0: "Don't use" - the transport cost matrix for calculating optimal holds filling between libraries. + - + - pref: UseLibraryFloatLimits + choices: + 1: Use + 0: "Don't use" + - library float limits to determine if an item should be transferred to another library. - - Use the calendar and circulation rules of - pref: CircControl -- 2.30.2