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 100755 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 afbf3f5885..e50a30e1d0 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1721,7 +1721,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`), @@ -6887,6 +6887,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 7721c9b767..ade83085d9 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -879,6 +879,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('useDischarge','0',NULL,'Allows librarians to discharge borrowers and borrowers to request a discharge','YesNo'), ('UseICUStyleQuotes','0',NULL,'Tell Koha whether to use ICU style quotes ({) or default (") when tracing subjects .','YesNo'), ('UseLocationAsAQInSIP', '0', NULL, 'Use permanent_location instead of homebranch for AQ in SIP response', 'YesNo'), +('UseLibraryFloatLimits', '0', '', 'Enables library float limits', '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'), ('UseTransportCostMatrix','0',NULL,'Use Transport Cost Matrix when filling holds','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 af1afdb24c..29d80b0e20 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