From daa6fd7d509922a863bae4d251c62d3b3fe236ba Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 15 Oct 2025 09:10:40 +0000 Subject: [PATCH] Bug 40504: Add 'managedby' to illrequests This also includes a 'manager' accessor which returns the Koha::Patron object Signed-off-by: Jeremy Evans --- Koha/ILL/Request.pm | 16 ++++++++++++++++ Koha/Schema/Result/Illrequest.pm | 12 ++++++++++++ admin/columns_settings.yml | 3 +++ api/v1/swagger/definitions/ill_request.yaml | 9 +++++++++ api/v1/swagger/paths/ill_requests.yaml | 1 + ill/ill-requests.pl | 1 + installer/data/mysql/kohastructure.sql | 3 +++ .../prog/en/includes/ill-list-table.inc | 1 + .../prog/en/modules/ill/ill-requests.tt | 16 ++++++++++++++++ .../intranet-tmpl/prog/js/ill-list-table.js | 12 ++++++++++++ 10 files changed, 74 insertions(+) diff --git a/Koha/ILL/Request.pm b/Koha/ILL/Request.pm index 5e76fc5889e..de045632940 100644 --- a/Koha/ILL/Request.pm +++ b/Koha/ILL/Request.pm @@ -1404,6 +1404,22 @@ sub get_type_disclaimer_date { return $attr->value; } +=head3 manager + + my $manager = $request->manager(); + +Return the Koha::Patron object found by $self->managedby + +=cut + +sub manager { + my ($self) = @_; + + my $manager_rs = $self->_result->manager; + return unless $manager_rs; + return Koha::Patron->_new_from_dbic($manager_rs); +} + =head3 check_limits my $ok = $requests->check_limits( { diff --git a/Koha/Schema/Result/Illrequest.pm b/Koha/Schema/Result/Illrequest.pm index 8f6347ee04d..85ab63d439e 100644 --- a/Koha/Schema/Result/Illrequest.pm +++ b/Koha/Schema/Result/Illrequest.pm @@ -469,6 +469,18 @@ __PACKAGE__->belongs_to( }, ); +__PACKAGE__->belongs_to( + "manager", + "Koha::Schema::Result::Borrower", + { borrowernumber => "managedby" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); + =head2 koha_object_class Missing POD for koha_object_class. diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml index 6c5624bee9b..a630915dad4 100644 --- a/admin/columns_settings.yml +++ b/admin/columns_settings.yml @@ -1156,6 +1156,9 @@ modules: columnname: orderid - columnname: patron + - + columnname: managedby + is_hidden: 1 - columnname: biblio_id - diff --git a/api/v1/swagger/definitions/ill_request.yaml b/api/v1/swagger/definitions/ill_request.yaml index 9c6459b915b..07bb3af1f11 100644 --- a/api/v1/swagger/definitions/ill_request.yaml +++ b/api/v1/swagger/definitions/ill_request.yaml @@ -18,6 +18,10 @@ properties: type: - integer - "null" + managedby: + type: + - integer + - "null" description: Internal patron id due_date: type: @@ -140,6 +144,11 @@ properties: - object - "null" description: The linked patron object (x-koha-embed) + manager: + type: + - object + - "null" + description: The linked patron object (x-koha-embed) _strings: type: - object diff --git a/api/v1/swagger/paths/ill_requests.yaml b/api/v1/swagger/paths/ill_requests.yaml index 7927a56629a..e31efd3ed92 100644 --- a/api/v1/swagger/paths/ill_requests.yaml +++ b/api/v1/swagger/paths/ill_requests.yaml @@ -31,6 +31,7 @@ - library - id_prefix - patron + - manager collectionFormat: csv produces: - application/json diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl index dec7439dec2..75088d6f0eb 100755 --- a/ill/ill-requests.pl +++ b/ill/ill-requests.pl @@ -305,6 +305,7 @@ if ($backends_available) { ? $params->{status_alias} : "-1"; $request->status_alias($alias); + $request->managedby( $params->{managedby} ); $request->store; my $backend_result = { error => 0, diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index ce39d6a933f..ba4265f0e12 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -3760,6 +3760,7 @@ DROP TABLE IF EXISTS `illrequests`; CREATE TABLE `illrequests` ( `illrequest_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ILL request number', `borrowernumber` int(11) DEFAULT NULL COMMENT 'Patron associated with request', + `managedby` int(11) DEFAULT NULL COMMENT 'Staff member manager of request', `biblio_id` int(11) DEFAULT NULL COMMENT 'Potential bib linked to request', `deleted_biblio_id` int(11) DEFAULT NULL COMMENT 'Deleted bib linked to request', `due_date` datetime DEFAULT NULL COMMENT 'Custom date due specified by backend, leave NULL for default date_due calculation', @@ -3781,6 +3782,7 @@ CREATE TABLE `illrequests` ( `batch_id` int(11) DEFAULT NULL COMMENT 'Optional ID of batch that this request belongs to', PRIMARY KEY (`illrequest_id`), KEY `illrequests_bnfk` (`borrowernumber`), + KEY `illrequests_manfk` (`managedby`), KEY `illrequests_bcfk_2` (`branchcode`), KEY `illrequests_safk` (`status_alias`), KEY `illrequests_bibfk` (`biblio_id`), @@ -3788,6 +3790,7 @@ CREATE TABLE `illrequests` ( CONSTRAINT `illrequests_bcfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `illrequests_bibfk` FOREIGN KEY (`biblio_id`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `illrequests_bnfk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `illrequests_manfk` FOREIGN KEY (`managedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `illrequests_ibfk` FOREIGN KEY (`batch_id`) REFERENCES `illbatches` (`ill_batch_id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `illrequests_safk` FOREIGN KEY (`status_alias`) REFERENCES `authorised_values` (`authorised_value`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table.inc index bf314c26e10..15854e60d19 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table.inc @@ -19,6 +19,7 @@ Request type Order ID Patron + Managed by Bibliographic record ID Library Status diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt index 6b82dae88df..d49f74248f5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt @@ -7,6 +7,7 @@ [% USE TablesSettings %] [% USE Price %] [% PROCESS 'i18n.inc' %] +[% PROCESS 'manageable-mixin.inc' %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Patron ID:</label> <input name="borrowernumber" id="borrowernumber" type="text" value="[% request.borrowernumber | html %]" /> </li> + [% PROCESS select_manager_form + manager => request.manager + required_permission => CAN_user_ill + %] <li class="biblio_id"> <label for="biblio_id" class="biblio_id">Bibliographic record ID:</label> <input name="biblio_id" id="biblio_id" type="text" value="[% request.biblio_id | html %]" /> @@ -642,6 +647,10 @@ <a href="[% borrowerlink | url %]" title="View borrower details"> [% request.patron.firstname _ " " _ request.patron.surname _ " [" _ request.patron.cardnumber _ "]" | html %] </a> </li> [% END %] + [% PROCESS select_manager_show + manager => request.manager + display => "fieldset" + %] [% IF request.biblio_id %] <li class="biblio_id"> <span class="label biblio_id">Bibliographic record ID:</span> @@ -1117,6 +1126,13 @@ [% INCLUDE 'js-patron-format.inc' %] [% INCLUDE 'calendar.inc' %] [% INCLUDE 'select2.inc' %] + [% IF op == 'edit_action' %] + [% INCLUDE 'select_manager.inc' + add_modal => 1 + manager => request.manager + filter => 'ill_users' + %] + [% END %] [% IF metadata_enrichment_services %] <script> var ill_check_availability_syspref = '[% Koha.Preference('ILLCheckAvailability') | html %]'; diff --git a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js index 7c97255c61b..81a7a841d03 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js +++ b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js @@ -294,6 +294,7 @@ $(document).ready(function () { "library", "id_prefix", "patron", + "manager", ], order: [[0, "desc"]], stateSave: true, // remember state on page reload @@ -411,6 +412,17 @@ $(document).ready(function () { : ""; }, }, + { + data: "manager.firstname:manager.surname:manager.cardnumber", + render: function (data, type, row, meta) { + return row.manager + ? $patron_to_html(row.manager, { + display_cardnumber: true, + url: true, + }) + : __("Nobody"); + }, + }, { data: "biblio_id", orderable: true, -- 2.39.5