From adf958a3872dcd0f01afba76d052432bcfac6c80 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 Signed-off-by: Kris Becker --- 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 | 3 +- .../admin/preferences/circulation.pref | 8 +- 5 files changed, 186 insertions(+), 3 deletions(-) create mode 100644 Koha/Schema/Result/LibraryFloatLimit.pm create mode 100644 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 0000000000..739ec290aa --- /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 100644 index 0000000000..605d50f84f --- /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 5440bd82fd..aa7f97354b 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1713,7 +1713,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`), @@ -6576,6 +6576,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 c4bb3ca9a7..2d5b4ca14c 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -854,6 +854,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'), @@ -874,4 +875,4 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('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'), ('z3950Status','','','This syspref allows to define custom YAML based rules for marking items unavailable in z3950 results.','Textarea') -; +; \ No newline at end of file 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 7192181ea4..d183b8dc66 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 @@ -286,6 +286,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 @@ -1514,4 +1520,4 @@ Circulation: choices: 1: Enable 0: Disable - - "the curbside pickup module." + - "the curbside pickup module." \ No newline at end of file -- 2.39.5