From 560d7b7ff759185c706f37b6645cfc2af8ccb7cc Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 2 Jun 2026 14:55:37 -0400 Subject: [PATCH] Bug 42443: Convert transfers to receive page to ajax datatable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updates circ/transferstoreceive.pl to use the new REST API with an ajax DataTable to display transfer to receive. Test Plan: 1) Apply this patch 2) Restart all the things! 3) Set an item in transit to your logged in library ( check it in at another branch so it is sent home, or place a hold to trigger a transfer ) 4) Place a hold on a second transferred item, and a recall on a third 5) Browse to /cgi-bin/koha/circ/transferstoreceive.pl 6) Note the "On hold for" column shows the hold patron, the recall patron or "None" 7) Set TransfersMaxDaysWarning low and note the "days late" badge appears 8) Click "Cancel transfer" and note the transfer is cancelled 9) A library with no incoming transfers will get "No transfers to receive" Signed-off-by: Alex Carver [Acerock7] Signed-off-by: Martin Renvoize Signed-off-by: Tomás Cohen Arazi Signed-off-by: Pedro Amorim --- admin/columns_settings.yml | 20 ++ circ/transferstoreceive.pl | 103 +------- .../en/modules/circ/transferstoreceive.tt | 247 +++++++++++------- 3 files changed, 181 insertions(+), 189 deletions(-) diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml index ab0a311b74..b85af2cfe2 100644 --- a/admin/columns_settings.yml +++ b/admin/columns_settings.yml @@ -2087,6 +2087,26 @@ modules: cannot_be_toggled: 1 cannot_be_modified: 1 + transferstoreceive: + transferstoreceive: + columns: + - + columnname: sentfrom + - + columnname: datesent + - + columnname: title + - + columnname: holdfor + - + columnname: homelibrary + - + columnname: callnumber + - + columnname: action + cannot_be_toggled: 1 + cannot_be_modified: 1 + view_holdsqueue: holds-table: default_sort_order: 3 diff --git a/circ/transferstoreceive.pl b/circ/transferstoreceive.pl index 1b7d135a31..7ff2f0fadc 100755 --- a/circ/transferstoreceive.pl +++ b/circ/transferstoreceive.pl @@ -22,22 +22,11 @@ use CGI qw ( -utf8 ); use C4::Context; use C4::Output qw( output_html_with_http_headers ); use C4::Auth qw( get_template_and_user ); -use C4::Circulation qw( GetTransfersFromTo ); -use C4::Members; -use Date::Calc qw( Add_Delta_Days Date_to_Days Today ); - -use C4::Reserves; -use Koha::Items; -use Koha::ItemTypes; -use Koha::Libraries; use Koha::DateUtils qw( dt_from_string ); -use Koha::BiblioFrameworks; -use Koha::Patrons; -my $input = CGI->new; -my $itemnumber = $input->param('itemnumber'); +my $input = CGI->new; -my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { template_name => "circ/transferstoreceive.tt", query => $input, @@ -46,96 +35,10 @@ my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( } ); -# set the userenv branch -my $default = C4::Context->userenv->{'branch'}; - -# get the all the branches for reference -my $libraries = Koha::Libraries->search( {}, { order_by => 'branchname' } ); -my @branchesloop; -my $latetransfers; -while ( my $library = $libraries->next ) { - my @transferloop; - my %branchloop; - my @gettransfers = GetTransfersFromTo( $library->branchcode, $default ); - - if (@gettransfers) { - $branchloop{'branchname'} = $library->branchname; - $branchloop{'branchcode'} = $library->branchcode; - foreach my $num (@gettransfers) { - my %getransf; - - my ( $sent_year, $sent_month, $sent_day ) = split "-", - $num->{'datesent'}; - $sent_day = ( split " ", $sent_day )[0]; - ( $sent_year, $sent_month, $sent_day ) = Add_Delta_Days( - $sent_year, $sent_month, $sent_day, - C4::Context->preference('TransfersMaxDaysWarning') - ); - my $calcDate = Date_to_Days( $sent_year, $sent_month, $sent_day ); - my $today = Date_to_Days(&Today); - my $diff = $today - $calcDate; - - if ( $today > $calcDate ) { - $latetransfers = 1; - $getransf{'messcompa'} = 1; - $getransf{'diff'} = $diff; - } - - my $item = Koha::Items->find( $num->{itemnumber} ); - my $biblio = $item->biblio; - my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype ); - - $getransf{'datetransfer'} = $num->{'datesent'}; - $getransf{'itemtype'} = $itemtype->description; # FIXME Should not it be translated_description? - %getransf = ( - %getransf, - title => $biblio->title, - subtitle => $biblio->subtitle, - medium => $biblio->medium, - part_number => $biblio->part_number, - part_name => $biblio->part_name, - author => $biblio->author, - biblionumber => $biblio->biblionumber, - itemnumber => $item->itemnumber, - barcode => $item->barcode, - ccode => $item->ccode, - homebranch => $item->homebranch, - holdingbranch => $item->holdingbranch, - itemcallnumber => $item->itemcallnumber, - ); - - # we check if we have a reserve for this transfer - my $holds = $item->current_holds; - if ( my $first_hold = $holds->next ) { - $getransf{patron} = Koha::Patrons->find( $first_hold->borrowernumber ); - } - - # check for a recall for this transfer - if ( C4::Context->preference('UseRecalls') ) { - my $recall = $item->recall; - if ( defined $recall ) { - $getransf{recall} = $recall; - } - } - - push( @transferloop, \%getransf ); - } - - # If we have a return of reservloop we put it in the branchloop sequence - $branchloop{'reserve'} = \@transferloop; - } - push( @branchesloop, \%branchloop ) if %branchloop; -} - $template->param( - branchesloop => \@branchesloop, + branchcode => C4::Context->userenv->{'branch'}, show_date => dt_from_string, TransfersMaxDaysWarning => C4::Context->preference('TransfersMaxDaysWarning'), - latetransfers => $latetransfers ? 1 : 0, ); -# Checking if there is a Fast Cataloging Framework -$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find('FA'); - output_html_with_http_headers $input, $cookie, $template->output; - diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tt index d1c63ee106..221a214c91 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tt @@ -1,9 +1,9 @@ [% USE raw %] [% USE Asset %] -[% USE AuthorisedValues %] [% USE Koha %] [% USE KohaDates %] [% USE Branches %] +[% USE TablesSettings %] [% PROCESS 'i18n.inc' %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] @@ -35,102 +35,171 @@ [% SET aside = Koha.Preference('CircSidebar') ? 'circ-nav' : '' %] [% WRAPPER 'main-container.inc' aside=aside %]

Transfers made to your library as of [% show_date | $KohaDates %]

- [% IF ( branchesloop ) %] -

Your library is the destination for the following transfer(s)

- [% IF ( latetransfers ) %]

Transfers are considered late after [% TransfersMaxDaysWarning | html %] days.

[% END %] -
- [% FOREACH branchesloo IN branchesloop %] - [% IF ( branchesloo.branchcode ) %] -
- - - - - - - - - - - [% FOREACH reser IN branchesloo.reserve %] - - - - - - - - - [% END %] -
Coming from [% branchesloo.branchname | html %]
Date of transferTitleOn hold forHome libraryCall number 
- [% reser.datetransfer | $KohaDates %] - [% IF ( reser.messcompa ) %] - [% tnx('{count} day late', '{count} days late', reser.diff, { count = reser.diff }) %] - [% END %] - - [% INCLUDE 'biblio-title.inc' biblio=reser link = 1 %] [% IF ( reser.author ) %]by [% reser.author | html %][% END %] - [% IF ( reser.itemtype ) %]([% reser.itemtype | html %])[% END %] - [% IF ( reser.ccode ) -%] - Collection: [% AuthorisedValues.GetDescriptionByKohaField(kohafield => 'items.ccode', authorised_value => reser.ccode) | html %] - [%- END %] -
Barcode: [% reser.barcode | html %] -
[% IF ( reser.patron ) %] - - [% reser.patron.surname | html %][% IF ( reser.patron.firstname ) %], [% reser.patron.firstname | html %][% END %] - - [% IF ( reser.patron.phone ) %]
[% reser.patron.phone | html %][% END %] - [% IF ( reser.patron.notice_email_address ) %] -
- [% BLOCK subject %]Hold:[% END %] - [% reser.patron.notice_email_address | html %] - [% END %] - [% IF reser.patron.cardnumber %] -
Card number: [% reser.patron.cardnumber | html %]
- [% END %] - [% ELSIF ( reser.recall ) %] - Recall requested by - [% reser.recall.patron.surname | html %][% IF reser.recall.patron.firstname %], [% reser.recall.patron.firstname | html %][% END %] ([% reser.recall.patron.cardnumber | html %]) - [% ELSE %] -

None

- [% END %] -
[% IF reser.homebranch %][% Branches.GetName( reser.homebranch ) | html %][% END %][% reser.itemcallnumber | html %] Cancel transfer
-
- - [% END %] - [% END %] +

Your library is the destination for the following transfer(s)

+ [% IF ( TransfersMaxDaysWarning ) %]

Transfers are considered late after [% TransfersMaxDaysWarning | html %] days.

[% END %] +
+
+
- [% ELSE %] -

No transfers to receive

- [% END %] + +
[% END %] [% MACRO jsinclude BLOCK %] [% INCLUDE 'datatables.inc' %] - [% END %]