From b68fd5d3da633e33ed842a713e90055add0d90ad Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 9 Aug 2022 15:22:30 +0200 Subject: [PATCH] Bug 31330: Routing preview - Use the library from the selected issue --- .../modules/serials/routing-preview-slip.tt | 3 ++- .../en/modules/serials/routing-preview.tt | 9 ++++--- .../prog/en/modules/serials/routing.tt | 10 +++---- serials/routing-preview.pl | 25 ++++++++--------- serials/routing.pl | 27 ++++--------------- 5 files changed, 30 insertions(+), 44 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing-preview-slip.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing-preview-slip.tt index bf7ad526d92..9e0e2e0d881 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing-preview-slip.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing-preview-slip.tt @@ -1,5 +1,6 @@ [% USE Koha %] [% USE raw %] +[% USE KohaDates %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Routing slip preview › Serials › Koha @@ -17,7 +18,7 @@

[% libraryname | html %]

- Title: [% title | html %]
[% issue | html %] + Title: [% title | html %]
[% serial.serialseq | html %] ([% serial.publisheddate | $KohaDates %]) Name diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing-preview.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing-preview.tt index 783cd17d679..0567da88eef 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing-preview.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing-preview.tt @@ -1,5 +1,6 @@ [% USE raw %] [% SET footerjs = 1 %] +[% USE KohaDates %] [% INCLUDE 'doc-head-open.inc' %] Preview routing list › Serials › Koha [% INCLUDE 'doc-head-close.inc' %] @@ -34,7 +35,7 @@
    -
  1. Issue:[% issue | html %]
  2. +
  3. Issue:[% serial.serialseq | html %] ([% serial.publisheddate | $KohaDates %])
  4. List member: [% FOREACH memberloo IN memberloop %] @@ -49,7 +50,7 @@ [% INCLUDE 'csrf-token.inc' %] - + @@ -57,7 +58,7 @@ [% INCLUDE 'csrf-token.inc' %] - + @@ -65,7 +66,7 @@ [% INCLUDE 'csrf-token.inc' %] - + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing.tt index 0100346ed94..6b9fc8f8cda 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing.tt @@ -51,12 +51,12 @@
    1. - + [% FOREACH serial IN serials %] + [% IF ( serial.serialid == serialid ) %] + [% ELSE %] - + [% END %] [% END %] [% issue | html %]
    2. diff --git a/serials/routing-preview.pl b/serials/routing-preview.pl index aa44f7e28b6..0c5ed4907e3 100755 --- a/serials/routing-preview.pl +++ b/serials/routing-preview.pl @@ -26,15 +26,15 @@ use C4::Output qw( output_html_with_http_headers ); use C4::Reserves qw( AddReserve ModReserve ); use C4::Context; use C4::Serials qw( delroutingmember getroutinglist GetSubscription GetSerials check_routing ); -use URI::Escape; use Koha::Biblios; use Koha::Libraries; use Koha::Patrons; +use Koha::Serial::Items; my $query = CGI->new; my $subscriptionid = $query->param('subscriptionid'); -my $issue = $query->param('issue'); +my $serialid = $query->param('serialid'); my $routingid; my $op = $query->param('op') || q{}; my $dbh = C4::Context->dbh; @@ -50,6 +50,7 @@ if($op eq 'cud-edit'){ print $query->redirect("routing.pl?subscriptionid=$subscriptionid"); } +my $serial = Koha::Serials->find($serialid); my @routinglist = getroutinglist($subscriptionid); my $subs = GetSubscription($subscriptionid); my ($tmp ,@serials) = GetSerials($subscriptionid); @@ -61,12 +62,13 @@ if($op eq 'cud-save_and_preview'){ my $biblionumber = $subs->{'bibnum'}; my $biblio = Koha::Biblios->find( $biblionumber ); - my $items = $biblio->items->search_ordered; - my $branch = - $items->count - ? $items->next->holding_branch->branchcode - : $subs->{branchcode}; - $library = Koha::Libraries->find($branch); + my $branchcode = $subs->{branchcode}; + my $serialitem = Koha::Serial::Items->search( { serialid => $serialid } )->next; + if ( $serialitem ) { + my $item = Koha::Items->find($serialitem->itemnumber); + $branchcode = $item->holdingbranch || $branchcode; + } + $library = Koha::Libraries->find($branchcode); if (C4::Context->preference('RoutingListAddReserves')){ @@ -82,12 +84,12 @@ if($op eq 'cud-save_and_preview'){ rank => $routing->{ranking}, biblionumber => $biblionumber, borrowernumber => $routing->{borrowernumber}, - branchcode => $branch + branchcode => $branchcode, }); } else { AddReserve( { - branchcode => $branch, + branchcode => $branchcode, borrowernumber => $routing->{borrowernumber}, biblionumber => $biblionumber, priority => $routing->{ranking}, @@ -134,8 +136,7 @@ $routingnotes =~ s/\n/\
      /g; $template->param( title => $subs->{'bibliotitle'}, - issue => $issue, - issue_escaped => URI::Escape::uri_escape_utf8($issue), + serial => $serial, subscriptionid => $subscriptionid, memberloop => $memberloop, routingnotes => $routingnotes, diff --git a/serials/routing.pl b/serials/routing.pl index b8cd66e8800..1cec6335931 100755 --- a/serials/routing.pl +++ b/serials/routing.pl @@ -36,8 +36,6 @@ use C4::Context; use C4::Serials qw( GetSubscription delroutingmember addroutingmember getroutinglist GetSerials GetLatestSerials check_routing ); use Koha::Patrons; -use URI::Escape; - my $query = CGI->new; my $subscriptionid = $query->param('subscriptionid'); my $serialseq = $query->param('serialseq'); @@ -45,8 +43,7 @@ my $routingid = $query->param('routingid'); my $borrowernumbers = $query->param('borrowernumbers'); my $notes = $query->param('notes'); my $op = $query->param('op') || q{}; -my $date_selected = $query->param('date_selected'); -$date_selected ||= q{}; +my $serialid = $query->param('serialid'); my $dbh = C4::Context->dbh; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( @@ -81,28 +78,13 @@ if ( $op eq 'cud-add_new_recipients' ) { if($op eq 'cud-save'){ my $sth = $dbh->prepare('UPDATE serial SET routingnotes = ? WHERE subscriptionid = ?'); $sth->execute($notes,$subscriptionid); - my $urldate = URI::Escape::uri_escape_utf8($date_selected); - print $query->redirect("routing-preview.pl?subscriptionid=$subscriptionid&issue=$urldate"); + print $query->redirect("routing-preview.pl?subscriptionid=$subscriptionid&serialid=$serialid"); } my @routinglist = getroutinglist($subscriptionid); my ($count,@serials) = GetSerials($subscriptionid); -my $serialdates = GetLatestSerials($subscriptionid,$count); - -my $dates = []; -foreach my $dateseq (@{$serialdates}) { - my $d = {}; - $d->{publisheddate} = $dateseq->{publisheddate}; - $d->{serialseq} = $dateseq->{serialseq}; - $d->{serialid} = $dateseq->{serialid}; - if($date_selected eq $dateseq->{serialid}){ - $d->{selected} = ' selected'; - } else { - $d->{selected} = q{}; - } - push @{$dates}, $d; -} +my $serials = GetLatestSerials($subscriptionid,$count); my $member_loop = []; for my $routing ( @routinglist ) { @@ -125,10 +107,11 @@ for my $routing ( @routinglist ) { $template->param( title => $subs->{bibliotitle}, + serialid => $serialid, subscriptionid => $subscriptionid, memberloop => $member_loop, op => $op eq 'new', - dates => $dates, + serials => $serials, routingnotes => $serials[0]->{'routingnotes'}, hasRouting => check_routing($subscriptionid), (uc(C4::Context->preference("marcflavour"))) => 1 -- 2.34.1
    Name