Bugzilla – Attachment 97519 Details for
Bug 7957
Routing lists: manage several routing list for each subscription, and export them as CSV
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7957: Routing lists enhancements
Bug-7957-Routing-lists-enhancements.patch (text/plain), 103.75 KB, created by
Julian Maurice
on 2020-01-17 14:10:30 UTC
(
hide
)
Description:
Bug 7957: Routing lists enhancements
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2020-01-17 14:10:30 UTC
Size:
103.75 KB
patch
obsolete
>From 579aa677a8110ad61207f34de7a27be480970199 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Tue, 17 Apr 2012 14:08:46 +0200 >Subject: [PATCH] Bug 7957: Routing lists enhancements > >- Manage several routing list per subscription >- Export a routing list as CSV > >Test plan: > >Run the updatedatabase.pl script >Existing routing lists should have been imported in a routing list named >'import' > >From the serials-home.pl page: > 1 Make a search, in the results list you have a column 'Actions' that > should contain a "New/Edit routing list" link" (if not, consider > setting RoutingSerials syspref). If the subscription doesn't have a > routing list, you should have a 'New routing list' link. Otherwise > you have an 'Edit routing lists (X)' link, where X is the number of > routing lists. > 2 Choose a subscription which have no routing lists and click on 'New > routing list' > 3 You are on the routing list creation page. Enter a title for the > routing list and click on 'Save'. > 4 The routing list has been created and now you are on the routing > list modification page. The behaviour of this page is quite the same > as before. A sensible change is that reordering borrowers doesn't > reload the page each time you make a change. > 5 Click on 'Save' to finish routing list modifications. > 6 Now you are on the routing lists management page. You can edit a > routing list by clicking on its title, preview it, export it, and > delete it by clicking on the corresponding link. > 7 Click on 'Preview'. > 8 You will be asked to choose a serial. Pick the one you want to print > the routing list for and click on 'Continue'. > 9 If RoutingListAddReserves is OFF, the routing list is displayed and > you just have to click on 'Print'. If the syspref is ON, you will > have to click on 'Confirm and print', an alert will show telling you > that holds will be placed on the serial you chose. Click 'OK' and > you will be able to print the slip. Now check if the holds have been > placed. (It works only if an item is attached to this serial). > 10 Go back to the routing lists management page (routinglists.pl) and > click on 'Export'. Download the CSV and check that it contains > correct data. > >From serials-collection.pl page: > 11 In the serials list, click on 'Print list'. > 12 You will be asked to choose a routing list. Pick one and click on > 'Continue'. > 13 ... (same behaviour as above) > >Try to add and delete routing lists to show if links are correctly >updated in serials-home.pl, serials-collection.pl and >subscription-detail.pl > >Signed-off-by: Paola Rossi <paola.rossi@cineca.it> >Signed-off-by: Aleisha <aleishaamohia@hotmail.com> >--- > C4/Serials.pm | 235 ++++--------- > C4/Serials/RoutingLists.pm | 309 ++++++++++++++++++ > acqui/newordersubscription.pl | 3 +- > .../data/mysql/atomicupdate/bug_7957.perl | 67 ++++ > installer/data/mysql/kohastructure.sql | 45 ++- > .../prog/en/includes/serials-menu.inc | 4 +- > .../prog/en/modules/members/routing-lists.tt | 71 ++-- > .../modules/serials/routing-preview-slip.tt | 122 +++++-- > .../en/modules/serials/routing-preview.tt | 68 ---- > .../prog/en/modules/serials/routing.tt | 135 -------- > .../prog/en/modules/serials/routinglist.tt | 204 ++++++++++++ > .../prog/en/modules/serials/routinglists.tt | 71 ++++ > .../en/modules/serials/serials-collection.tt | 12 +- > .../prog/en/modules/serials/serials-search.tt | 16 +- > serials/reorder_members.pl | 37 --- > serials/routing-preview-slip.pl | 151 +++++++++ > serials/routing-preview.pl | 144 -------- > serials/routing.pl | 133 -------- > serials/routinglist.pl | 120 +++++++ > serials/routinglists.pl | 81 +++++ > serials/serials-collection.pl | 14 +- > serials/serials-edit.pl | 1 - > serials/serials-search.pl | 3 +- > serials/subscription-detail.pl | 3 +- > t/db_dependent/Serials.t | 49 ++- > t/db_dependent/Serials/RoutingLists.t | 240 ++++++++++++++ > 26 files changed, 1537 insertions(+), 801 deletions(-) > create mode 100644 C4/Serials/RoutingLists.pm > create mode 100644 installer/data/mysql/atomicupdate/bug_7957.perl > delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing-preview.tt > delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing.tt > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/serials/routinglist.tt > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/serials/routinglists.tt > delete mode 100755 serials/reorder_members.pl > create mode 100755 serials/routing-preview-slip.pl > delete mode 100755 serials/routing-preview.pl > delete mode 100755 serials/routing.pl > create mode 100755 serials/routinglist.pl > create mode 100755 serials/routinglists.pl > create mode 100644 t/db_dependent/Serials/RoutingLists.t > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 2b9e1a62a5..8083ab26da 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -78,11 +78,10 @@ BEGIN { > &GetSerialInformation &AddItem2Serial > &PrepareSerialsData &GetNextExpected &ModNextExpected > &GetPreviousSerialid >+ GetSerial GetSerialItemnumber > > &GetSuppliersWithLateIssues >- &getroutinglist &delroutingmember &addroutingmember >- &reorder_members >- &check_routing &updateClaim >+ &updateClaim > &CountIssues > HasItems > &subscriptionCurrentlyOnOrder >@@ -162,6 +161,60 @@ sub GetSubscriptionHistoryFromSubscriptionId { > return $results; > } > >+=head2 GetSerial >+ >+ my $serial = &GetSerial($serialid); >+ >+This sub returns serial informations (ie. in serial table) for given $serialid >+It returns a hashref where each key is a sql column. >+ >+=cut >+ >+sub GetSerial { >+ my ($serialid) = @_; >+ >+ return unless $serialid; >+ >+ my $dbh = C4::Context->dbh; >+ my $query = qq{ >+ SELECT * >+ FROM serial >+ WHERE serialid = ? >+ }; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($serialid); >+ return $sth->fetchrow_hashref; >+} >+ >+=head2 GetSerialItemnumber >+ >+ my $itemnumber = GetSerialItemnumber($serialid); >+ >+Returns the itemnumber associated to $serialid or undef if there is no item. >+ >+=cut >+ >+sub GetSerialItemnumber { >+ my ($serialid) = @_; >+ >+ return unless $serialid; >+ my $itemnumber; >+ >+ my $dbh = C4::Context->dbh; >+ my $query = qq{ >+ SELECT itemnumber >+ FROM serialitems >+ WHERE serialid = ? >+ }; >+ my $sth = $dbh->prepare($query); >+ my $rv = $sth->execute($serialid); >+ if ($rv) { >+ my $result = $sth->fetchrow_hashref; >+ $itemnumber = $result->{itemnumber}; >+ } >+ return $itemnumber; >+} >+ > =head2 GetSerialInformation > > $data = GetSerialInformation($serialid); >@@ -657,7 +710,7 @@ sub GetSerials { > my @serials; > my $statuses = join( ',', ( ARRIVED, MISSING_STATUSES, NOT_ISSUED ) ); > my $query = "SELECT serialid,serialseq, status, publisheddate, >- publisheddatetext, planneddate,notes, routingnotes >+ publisheddatetext, planneddate, notes > FROM serial > WHERE subscriptionid = ? AND status NOT IN ( $statuses ) > ORDER BY IF(publisheddate IS NULL,planneddate,publisheddate) DESC"; >@@ -678,7 +731,7 @@ sub GetSerials { > > # OK, now add the last 5 issues arrives/missing > $query = "SELECT serialid,serialseq, status, planneddate, publisheddate, >- publisheddatetext, notes, routingnotes >+ publisheddatetext, notes > FROM serial > WHERE subscriptionid = ? > AND status IN ( $statuses ) >@@ -726,7 +779,7 @@ sub GetSerials2 { > my $dbh = C4::Context->dbh; > my $query = q| > SELECT serialid,serialseq, status, planneddate, publisheddate, >- publisheddatetext, notes, routingnotes >+ publisheddatetext, notes > FROM serial > WHERE subscriptionid=? > | >@@ -1084,13 +1137,13 @@ sub ModSerialStatus { > #It is a usual serial > # 1st, get previous status : > my $dbh = C4::Context->dbh; >- my $query = "SELECT serial.subscriptionid,serial.status,subscription.periodicity,serial.routingnotes >+ my $query = "SELECT serial.subscriptionid,serial.status,subscription.periodicity > FROM serial, subscription > WHERE serial.subscriptionid=subscription.subscriptionid > AND serialid=?"; > my $sth = $dbh->prepare($query); > $sth->execute($serialid); >- my ( $subscriptionid, $oldstatus, $periodicity, $routingnotes ) = $sth->fetchrow; >+ my ( $subscriptionid, $oldstatus, $periodicity ) = $sth->fetchrow; > my $frequency = GetSubscriptionFrequency($periodicity); > > # change status & update subscriptionhistory >@@ -1101,12 +1154,12 @@ sub ModSerialStatus { > my $query = ' > UPDATE serial > SET serialseq = ?, publisheddate = ?, publisheddatetext = ?, >- planneddate = ?, status = ?, notes = ?, routingnotes = ? >+ planneddate = ?, status = ?, notes = ? > WHERE serialid = ? > '; > $sth = $dbh->prepare($query); > $sth->execute( $serialseq, $publisheddate, $publisheddatetext, >- $planneddate, $status, $notes, $routingnotes, $serialid ); >+ $planneddate, $status, $notes, $serialid ); > $query = "SELECT * FROM subscription WHERE subscriptionid = ?"; > $sth = $dbh->prepare($query); > $sth->execute($subscriptionid); >@@ -1162,7 +1215,7 @@ sub ModSerialStatus { > $sth = $dbh->prepare($query); > $sth->execute( $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1, $newinnerloop2, $newinnerloop3, $subscriptionid ); > my $newnote = C4::Context->preference('PreserveSerialNotes') ? $notes : ""; >- NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, 1, $nextpubdate, $nextpubdate, undef, $newnote, $routingnotes ); >+ NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, 1, $nextpubdate, $nextpubdate, undef, $newnote ); > # check if an alert must be sent... (= a letter is defined & status became "arrived" > if ( $subscription->{letter} && $status == ARRIVED && $oldstatus != ARRIVED ) { > require C4::Letters; >@@ -1541,7 +1594,7 @@ sub ReNewSubscription { > > =head2 NewIssue > >-NewIssue($serialseq,$subscriptionid,$biblionumber,$status, $planneddate, $publisheddate, $notes, $routingnotes) >+NewIssue($serialseq,$subscriptionid,$biblionumber,$status, $planneddate, $publisheddate, $notes) > > Create a new issue stored on the database. > Note : we have to update the recievedlist and missinglist on subscriptionhistory for this subscription. >@@ -1551,7 +1604,7 @@ returns the serial id > > sub NewIssue { > my ( $serialseq, $subscriptionid, $biblionumber, $status, $planneddate, >- $publisheddate, $publisheddatetext, $notes, $routingnotes ) = @_; >+ $publisheddate, $publisheddatetext, $notes ) = @_; > ### FIXME biblionumber CAN be provided by subscriptionid. So Do we STILL NEED IT ? > > return unless ($subscriptionid); >@@ -1573,7 +1626,6 @@ sub NewIssue { > publisheddate => $publisheddate, > publisheddatetext => $publisheddatetext, > notes => $notes, >- routingnotes => $routingnotes > } > )->store(); > >@@ -1886,161 +1938,6 @@ sub updateClaim { > {}, CLAIMED, @$serialids ); > } > >-=head2 check_routing >- >-$result = &check_routing($subscriptionid) >- >-this function checks to see if a serial has a routing list and returns the count of routingid >-used to show either an 'add' or 'edit' link >- >-=cut >- >-sub check_routing { >- my ($subscriptionid) = @_; >- >- return unless ($subscriptionid); >- >- my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare( >- "SELECT count(routingid) routingids FROM subscription LEFT JOIN subscriptionroutinglist >- ON subscription.subscriptionid = subscriptionroutinglist.subscriptionid >- WHERE subscription.subscriptionid = ? GROUP BY routingid ORDER BY ranking ASC >- " >- ); >- $sth->execute($subscriptionid); >- my $line = $sth->fetchrow_hashref; >- my $result = $line->{'routingids'}; >- return $result; >-} >- >-=head2 addroutingmember >- >-addroutingmember($borrowernumber,$subscriptionid) >- >-this function takes a borrowernumber and subscriptionid and adds the member to the >-routing list for that serial subscription and gives them a rank on the list >-of either 1 or highest current rank + 1 >- >-=cut >- >-sub addroutingmember { >- my ( $borrowernumber, $subscriptionid ) = @_; >- >- return unless ($borrowernumber and $subscriptionid); >- >- my $rank; >- my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare( "SELECT max(ranking) rank FROM subscriptionroutinglist WHERE subscriptionid = ?" ); >- $sth->execute($subscriptionid); >- while ( my $line = $sth->fetchrow_hashref ) { >- if ( $line->{'rank'} > 0 ) { >- $rank = $line->{'rank'} + 1; >- } else { >- $rank = 1; >- } >- } >- $sth = $dbh->prepare( "INSERT INTO subscriptionroutinglist (subscriptionid,borrowernumber,ranking) VALUES (?,?,?)" ); >- $sth->execute( $subscriptionid, $borrowernumber, $rank ); >-} >- >-=head2 reorder_members >- >-reorder_members($subscriptionid,$routingid,$rank) >- >-this function is used to reorder the routing list >- >-it takes the routingid of the member one wants to re-rank and the rank it is to move to >-- it gets all members on list puts their routingid's into an array >-- removes the one in the array that is $routingid >-- then reinjects $routingid at point indicated by $rank >-- then update the database with the routingids in the new order >- >-=cut >- >-sub reorder_members { >- my ( $subscriptionid, $routingid, $rank ) = @_; >- my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare( "SELECT * FROM subscriptionroutinglist WHERE subscriptionid = ? ORDER BY ranking ASC" ); >- $sth->execute($subscriptionid); >- my @result; >- while ( my $line = $sth->fetchrow_hashref ) { >- push( @result, $line->{'routingid'} ); >- } >- >- # To find the matching index >- my $i; >- my $key = -1; # to allow for 0 being a valid response >- for ( $i = 0 ; $i < @result ; $i++ ) { >- if ( $routingid == $result[$i] ) { >- $key = $i; # save the index >- last; >- } >- } >- >- # if index exists in array then move it to new position >- if ( $key > -1 && $rank > 0 ) { >- my $new_rank = $rank - 1; # $new_rank is what you want the new index to be in the array >- my $moving_item = splice( @result, $key, 1 ); >- splice( @result, $new_rank, 0, $moving_item ); >- } >- for ( my $j = 0 ; $j < @result ; $j++ ) { >- my $sth = $dbh->prepare( "UPDATE subscriptionroutinglist SET ranking = '" . ( $j + 1 ) . "' WHERE routingid = '" . $result[$j] . "'" ); >- $sth->execute; >- } >- return; >-} >- >-=head2 delroutingmember >- >-delroutingmember($routingid,$subscriptionid) >- >-this function either deletes one member from routing list if $routingid exists otherwise >-deletes all members from the routing list >- >-=cut >- >-sub delroutingmember { >- >- # if $routingid exists then deletes that row otherwise deletes all with $subscriptionid >- my ( $routingid, $subscriptionid ) = @_; >- my $dbh = C4::Context->dbh; >- if ($routingid) { >- my $sth = $dbh->prepare("DELETE FROM subscriptionroutinglist WHERE routingid = ?"); >- $sth->execute($routingid); >- reorder_members( $subscriptionid, $routingid ); >- } else { >- my $sth = $dbh->prepare("DELETE FROM subscriptionroutinglist WHERE subscriptionid = ?"); >- $sth->execute($subscriptionid); >- } >- return; >-} >- >-=head2 getroutinglist >- >-@routinglist = getroutinglist($subscriptionid) >- >-this gets the info from the subscriptionroutinglist for $subscriptionid >- >-return : >-the routinglist as an array. Each element of the array contains a hash_ref containing >-routingid - a unique id, borrowernumber, ranking, and biblionumber of subscription >- >-=cut >- >-sub getroutinglist { >- my ($subscriptionid) = @_; >- my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare( >- 'SELECT routingid, borrowernumber, ranking, biblionumber >- FROM subscription >- JOIN subscriptionroutinglist ON subscription.subscriptionid = subscriptionroutinglist.subscriptionid >- WHERE subscription.subscriptionid = ? ORDER BY ranking ASC' >- ); >- $sth->execute($subscriptionid); >- my $routinglist = $sth->fetchall_arrayref({}); >- return @{$routinglist}; >-} >- > =head2 countissuesfrom > > $result = countissuesfrom($subscriptionid,$startdate) >diff --git a/C4/Serials/RoutingLists.pm b/C4/Serials/RoutingLists.pm >new file mode 100644 >index 0000000000..c90998eed8 >--- /dev/null >+++ b/C4/Serials/RoutingLists.pm >@@ -0,0 +1,309 @@ >+package C4::Serials::RoutingLists; >+ >+# Copyright 2012 Biblibre >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use C4::Context; >+ >+use Koha::Biblios; >+use Koha::Patrons; >+use Koha::I18N; >+ >+use vars qw($VERSION @ISA @EXPORT_OK); >+ >+BEGIN { >+ $VERSION = 3.01; >+ require Exporter; >+ @ISA = qw(Exporter); >+ @EXPORT_OK = qw( >+ &AddRoutingList >+ &ModRoutingList >+ &DelRoutingList >+ &GetRoutingList >+ &GetRoutingLists >+ &GetRoutingListsCount >+ &GetRoutingListAsCSV >+ ); >+} >+ >+=head1 NAME >+ >+C4::Serials::RoutingLists >+ >+=head1 SYNOPSYS >+ >+use C4::Serials::RoutingLists; >+ >+=head1 DESCRIPTION >+ >+This module provides subroutines to deal with subscriptions routing lists >+ >+=head1 FUNCTIONS >+ >+=head2 AddRoutingList >+ >+$routinglistid = &AddRoutingList($subscriptionid, $title); >+ >+this function create a new routing list for a subscription. >+ >+=cut >+ >+sub AddRoutingList { >+ my ($subscriptionid, $title) = @_; >+ >+ return unless $subscriptionid and $title; >+ >+ my $dbh = C4::Context->dbh(); >+ my $query = qq{ >+ INSERT INTO subscriptionroutinglist (subscriptionid, title) >+ VALUES (?, ?) >+ }; >+ my $sth = $dbh->prepare($query); >+ my $rv = $sth->execute($subscriptionid, $title); >+ >+ return unless $rv; >+ return $dbh->last_insert_id(undef, undef, 'subscriptionroutinglist', undef); >+} >+ >+=head2 ModRoutingList >+ >+&ModRoutingList($routinglistid, $subscriptionid, $title, $notes, @borrowernumbers); >+ >+this function modifies a routing list. >+ >+=cut >+ >+sub ModRoutingList { >+ my ($routinglistid, $subscriptionid, $title, $notes, @borrowernumbers) = @_; >+ >+ return unless $routinglistid; >+ >+ my $dbh = C4::Context->dbh; >+ my $query = 'UPDATE subscriptionroutinglist'; >+ my @setstrings = (); >+ my @setargs = (); >+ if($subscriptionid) { >+ push @setstrings, 'subscriptionid = ?'; >+ push @setargs, $subscriptionid; >+ } >+ if($title) { >+ push @setstrings, 'title = ?'; >+ push @setargs, $title; >+ } >+ if($notes) { >+ push @setstrings, 'notes = ?'; >+ push @setargs, $notes; >+ } >+ >+ if(@setstrings) { >+ $query .= ' SET ' . join(',', @setstrings); >+ $query .= ' WHERE routinglistid = ?'; >+ my $sth = $dbh->prepare($query); >+ $sth->execute(@setargs, $routinglistid); >+ } >+ >+ $query = qq{ >+ DELETE FROM subscriptionrouting >+ WHERE routinglistid = ? >+ }; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($routinglistid); >+ >+ if(@borrowernumbers > 0){ >+ $query = qq{ >+ INSERT INTO subscriptionrouting (routinglistid, borrowernumber, ranking) >+ VALUES (?, ?, ?) >+ }; >+ $sth = $dbh->prepare($query); >+ my $i = 1; >+ foreach (@borrowernumbers) { >+ $sth->execute($routinglistid, $_, $i); >+ $i++; >+ } >+ } >+} >+ >+=head2 DelRoutingList >+ >+&DelRoutingList($routinglistid); >+ >+this function delete a routing list. >+ >+=cut >+ >+sub DelRoutingList { >+ my ($routinglistid) = @_; >+ >+ return unless $routinglistid; >+ >+ my $dbh = C4::Context->dbh; >+ my $query = qq{ >+ DELETE FROM subscriptionroutinglist >+ WHERE routinglistid = ? >+ }; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($routinglistid); >+} >+ >+ >+=head2 GetRoutingList >+ >+$routinglist = &GetRoutingList($routinglistid); >+ >+this function get infos from subscriptionroutinglist table. >+The 'borrowers' keys contains the list of borrowernumbers attached >+to this routing list. >+ >+=cut >+ >+sub GetRoutingList { >+ my ($routinglistid) = @_; >+ >+ return unless $routinglistid; >+ >+ my $dbh = C4::Context->dbh; >+ my $query = qq{ >+ SELECT * >+ FROM subscriptionroutinglist >+ WHERE routinglistid = ? >+ }; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($routinglistid); >+ my $result = $sth->fetchrow_hashref; >+ >+ $query = qq{ >+ SELECT borrowernumber >+ FROM subscriptionrouting >+ WHERE routinglistid = ? >+ ORDER BY ranking ASC >+ }; >+ $sth = $dbh->prepare($query); >+ $sth->execute($routinglistid); >+ while (my $row = $sth->fetchrow_hashref) { >+ push @{$result->{borrowers}}, $row->{borrowernumber}; >+ } >+ >+ return $result; >+} >+ >+=head2 GetRoutingLists >+ >+@routinglists = &GetRoutingLists($subscriptionid); >+ >+this function get all routing lists for a subscription. >+ >+=cut >+ >+sub GetRoutingLists { >+ my ($subscriptionid) = @_; >+ >+ return () unless $subscriptionid; >+ >+ my $dbh = C4::Context->dbh; >+ my $query = qq{ >+ SELECT routinglistid >+ FROM subscriptionroutinglist >+ WHERE subscriptionid = ? >+ }; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($subscriptionid); >+ my @results; >+ while (my $row = $sth->fetchrow_hashref) { >+ my $routinglistid = $row->{routinglistid}; >+ push @results, GetRoutingList($routinglistid); >+ } >+ >+ return @results; >+} >+ >+=head2 GetRoutingListsCount >+ >+$count = &GetRoutingListsCount($subscriptionid); >+ >+this function return the number of routing lists for a subscription. >+ >+=cut >+ >+sub GetRoutingListsCount { >+ my ($subscriptionid) = @_; >+ >+ return unless $subscriptionid; >+ >+ my $dbh = C4::Context->dbh; >+ my $query = qq{ >+ SELECT COUNT(*) AS count >+ FROM subscriptionroutinglist >+ WHERE subscriptionid = ? >+ }; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($subscriptionid); >+ my $result = $sth->fetchrow_hashref; >+ >+ return $result->{count}; >+} >+ >+=head2 GetRoutingListAsCSV >+ >+$csv_output = &GetRoutingListAsCSV($routinglistid); >+ >+this function return the routing list as a CSV file. >+ >+=cut >+ >+sub GetRoutingListAsCSV { >+ my ($routinglistid) = @_; >+ >+ return unless $routinglistid; >+ >+ require C4::Serials; >+ require C4::Templates; >+ require Text::CSV::Encoded; >+ >+ my $csv = Text::CSV::Encoded->new( {encoding => "utf8" } ); >+ my $output; >+ >+ my $routinglist = GetRoutingList($routinglistid); >+ my $subscription = C4::Serials::GetSubscription($routinglist->{'subscriptionid'}); >+ my $biblio = Koha::Biblios->find($subscription->{'biblionumber'}); >+ >+ $csv->combine( >+ __('Subscription title'), >+ __('Routing list'), >+ __('Surname'), >+ __('First name'), >+ __('Notes'), >+ ); >+ $output .= $csv->string() . "\n"; >+ >+ foreach (@{$routinglist->{borrowers}}) { >+ my $patron = Koha::Patrons->find($_); >+ $csv->combine( >+ $biblio->title, >+ $routinglist->{'title'}, >+ $patron->surname, >+ $patron->firstname, >+ $routinglist->{'notes'}, >+ ); >+ $output .= $csv->string() . "\n"; >+ } >+ >+ return $output; >+} >+ >+1; >diff --git a/acqui/newordersubscription.pl b/acqui/newordersubscription.pl >index 51151af7f2..adc3dfd18b 100755 >--- a/acqui/newordersubscription.pl >+++ b/acqui/newordersubscription.pl >@@ -24,6 +24,7 @@ use C4::Auth; > use C4::Context; > use C4::Output; > use C4::Serials; >+use C4::Serials::RoutingLists qw( GetRoutingListsCount ); > > use Koha::Acquisition::Booksellers; > >@@ -71,7 +72,7 @@ foreach my $sub (@subscriptions) { > > # to toggle between create or edit routing list options > if ($routing) { >- $sub->{routingedit} = check_routing( $sub->{subscriptionid} ); >+ $sub->{routingedit} = GetRoutingListsCount( $sub->{subscriptionid} ); > } > } > >diff --git a/installer/data/mysql/atomicupdate/bug_7957.perl b/installer/data/mysql/atomicupdate/bug_7957.perl >new file mode 100644 >index 0000000000..2f8ca30016 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_7957.perl >@@ -0,0 +1,67 @@ >+use Modern::Perl; >+use C4::Context; >+ >+my $dbh = C4::Context->dbh; >+$dbh->do("RENAME TABLE subscriptionroutinglist TO tmp_subscriptionroutinglist"); >+$dbh->do(" >+ CREATE TABLE subscriptionroutinglist ( >+ routinglistid int(11) NOT NULL AUTO_INCREMENT, >+ subscriptionid int(11) NOT NULL, >+ title varchar(256) NOT NULL, >+ notes text default NULL, >+ PRIMARY KEY (routinglistid), >+ CONSTRAINT subscriptionroutinglist_ibfk_1 FOREIGN KEY (subscriptionid) >+ REFERENCES subscription (subscriptionid) ON DELETE CASCADE >+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 >+"); >+$dbh->do(" >+ CREATE TABLE subscriptionrouting ( >+ routinglistid int(11) NOT NULL, >+ borrowernumber int(11) NOT NULL, >+ ranking int(11) DEFAULT NULL, >+ PRIMARY KEY (routinglistid, borrowernumber), >+ CONSTRAINT subscriptionrouting_ibfk_1 FOREIGN KEY (routinglistid) >+ REFERENCES subscriptionroutinglist (routinglistid) ON DELETE CASCADE, >+ CONSTRAINT subscriptionrouting_ibfk_2 FOREIGN KEY (borrowernumber) >+ REFERENCES borrowers (borrowernumber) ON DELETE CASCADE >+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 >+"); >+ >+# Migrate data from old subscriptionroutinglist table >+my $query = qq{ >+ SELECT serial.subscriptionid, serial.routingnotes >+ FROM tmp_subscriptionroutinglist >+ LEFT JOIN serial ON (tmp_subscriptionroutinglist.subscriptionid = serial.subscriptionid) >+ GROUP BY serial.subscriptionid >+}; >+my $sth = $dbh->prepare($query); >+$sth->execute(); >+my $results = $sth->fetchall_arrayref( {} ); >+$query = qq{ >+ INSERT INTO subscriptionroutinglist (subscriptionid, title, notes) >+ VALUES (?, ?, ?) >+}; >+$sth = $dbh->prepare($query); >+$query = qq{ >+ SELECT borrowernumber, ranking >+ FROM tmp_subscriptionroutinglist >+ WHERE subscriptionid = ? >+}; >+my $select_sth = $dbh->prepare($query); >+$query = qq{ >+ INSERT INTO subscriptionrouting (routinglistid, borrowernumber, ranking) >+ VALUES(?, ?, ?) >+}; >+my $insert_sth = $dbh->prepare($query); >+foreach ( @$results ) { >+ $sth->execute($_->{subscriptionid}, 'import', $_->{routingnotes}); >+ my $routinglistid = $dbh->last_insert_id(undef, undef, 'subscriptionroutinglist', undef); >+ $select_sth->execute($_->{subscriptionid}); >+ my $routings = $select_sth->fetchall_arrayref( {} ); >+ foreach (@$routings) { >+ $insert_sth->execute($routinglistid, $_->{borrowernumber}, $_->{ranking}); >+ } >+} >+ >+$dbh->do("DROP TABLE tmp_subscriptionroutinglist"); >+$dbh->do("ALTER TABLE serial DROP COLUMN routingnotes"); >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 56d5d27d5a..ac75dd8799 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -1473,7 +1473,6 @@ CREATE TABLE `serial` ( -- issues related to subscriptions > publisheddatetext varchar(100) default NULL, -- date published (descriptive) > `claimdate` date default NULL, -- date claimed > claims_count int(11) default 0, -- number of claims made related to this issue >- `routingnotes` MEDIUMTEXT, -- notes from the routing list > PRIMARY KEY (`serialid`) > ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; > >@@ -2056,22 +2055,38 @@ CREATE TABLE `subscriptionhistory` ( > ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; > > -- >--- Table structure for table `subscriptionroutinglist` >+-- Table structure for table subscriptionroutinglist > -- > >-DROP TABLE IF EXISTS `subscriptionroutinglist`; >-CREATE TABLE `subscriptionroutinglist` ( -- information related to the routing lists attached to subscriptions >- `routingid` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha >- `borrowernumber` int(11) NOT NULL, -- foreign key from the borrowers table, defines with patron is on the routing list >- `ranking` int(11) default NULL, -- where the patron stands in line to receive the serial >- `subscriptionid` int(11) NOT NULL, -- foreign key from the subscription table, defines which subscription this routing list is for >- PRIMARY KEY (`routingid`), >- UNIQUE (`subscriptionid`, `borrowernumber`), >- CONSTRAINT `subscriptionroutinglist_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) >- ON DELETE CASCADE ON UPDATE CASCADE, >- CONSTRAINT `subscriptionroutinglist_ibfk_2` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`) >- ON DELETE CASCADE ON UPDATE CASCADE >-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; >+DROP TABLE IF EXISTS subscriptionroutinglist; >+CREATE TABLE subscriptionroutinglist ( >+ routinglistid int(11) NOT NULL AUTO_INCREMENT, -- unique identifier assigned by Koha >+ subscriptionid int(11) NOT NULL, -- foreign key from the subscription table, >+ -- defines which subscription this routing list is for >+ title varchar(256) NOT NULL, -- title of this routing list >+ notes text default NULL, -- notes for this routing list >+ PRIMARY KEY (routinglistid), >+ CONSTRAINT subscriptionroutinglist_ibfk_1 FOREIGN KEY (subscriptionid) >+ REFERENCES subscription (subscriptionid) ON DELETE CASCADE >+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; >+ >+-- >+-- Table structure for subscriptionrouting >+-- >+ >+DROP TABLE IF EXISTS subscriptionrouting; >+CREATE TABLE subscriptionrouting ( >+ routinglistid int(11) NOT NULL, -- foreign key from the subscriptionroutinglist >+ -- table, defines which routing list is affected >+ borrowernumber int(11) NOT NULL, -- foreign key from the borrowers table, >+ -- defines which patron is on the routing list >+ ranking int(11) DEFAULT NULL, -- where the patron stands in line to receive the serial >+ PRIMARY KEY (routinglistid, borrowernumber), >+ CONSTRAINT subscriptionrouting_ibfk_1 FOREIGN KEY (routinglistid) >+ REFERENCES subscriptionroutinglists (routinglistid) ON DELETE CASCADE, >+ CONSTRAINT subscriptionrouting_ibfk_2 FOREIGN KEY (borrowernumber) >+ REFERENCES borrowers (borrowernumber) ON DELETE CASCADE >+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; > > -- > -- Table structure for table `systempreferences` >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc >index 4a7fffd043..4797fff9aa 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc >@@ -6,9 +6,9 @@ > [% UNLESS closed %] > [% IF ( routing && CAN_user_serials_routing ) %] > [% IF ( hasRouting ) %] >- <li><a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscriptionid | uri %]">Edit routing list</a></li> >+ <li><a href="/cgi-bin/koha/serials/routinglists.pl?subscriptionid=[% subscriptionid | uri %]">Edit routing list</a></li> > [% ELSE %] >- <li><a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscriptionid | uri %]&op=new">Create routing list</a></li> >+ <li><a href="/cgi-bin/koha/serials/routinglist.pl?subscriptionid=[% subscriptionid | uri %]&op=new">Create routing list</a></li> > [% END %] > [% END %] > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/routing-lists.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/routing-lists.tt >index bc256ff6e0..468ed25dbb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/routing-lists.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/routing-lists.tt >@@ -30,54 +30,49 @@ > > [% SET routinglists = patron.get_routing_lists %] > <h1> >-[% UNLESS ( routinglists ) %] >+[% IF routinglists.size == 0 %] > 0 subscription routing lists >-[% ELSIF ( routinglists.count == 1 ) %] >-[% routinglists.count | html %] subscription routing list >+[% ELSIF ( routinglists.size == 1 ) %] >+[% routinglists.size | html %] subscription routing list > [% ELSE %] >-[% routinglists.count | html %] subscription routing lists >+[% routinglists.size | html %] subscription routing lists > [% END %] > </h1> > > <div id="subscriptions"> >- >-[% IF ( routinglists ) %] >+ [% IF ( routinglists.size > 0 ) %] > <table id="subscriptiont"> >- <thead> >- <tr> >- <th>Subscription title</th> >- <th>Position</th> >- <th>Routing list</th> >- </tr> >- </thead> >- <tbody> >+ <thead> >+ <tr> >+ <th>Subscription title</th> >+ <th>Routing list</th> >+ <th>Actions</th> >+ </tr> >+ </thead> >+ <tbody> > [% FOREACH routinglist IN routinglists %] >- <tr> >- <td> >- <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% routinglist.subscription.subscriptionid | uri %]"> >- [% routinglist.subscription.biblio.title | html %] >- </a> >- </td> >- <td> >- [% routinglist.ranking | html %] >- </td> >- <td> >- <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% routinglist.subscription.subscriptionid | uri %]"> >- Edit routing list >- </a> >- <input type="hidden" name="biblionumber" value="[% routinglist.subscription.biblionumber | html %]" /> >- <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" /> >- </td> >- </tr> >- [% END %] >- </tbody> >+ <tr> >+ <td> >+ <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% routinglist.subscriptionid | uri %]"> >+ <strong> >+ [% routinglist.bibliotitle | html %] >+ </strong> >+ </a> >+ </td> >+ <td>[% routinglist.title | html %]</td> >+ <td> >+ <a href="/cgi-bin/koha/serials/routinglist.pl?routinglistid=[% routinglist.routinglistid | uri %]"><strong> >+ Edit routing list >+ </strong> >+ </a> >+ </td> >+ </tr> >+ [% END %] >+ </tbody> > </table> >-[% ELSE %] >+ [% ELSE %] > <p>Patron does not belong to any subscription routing lists.</p> >- <input type="hidden" name="biblionumber" value="[% routinglist.subscription.biblionumber | html %]" /> >- <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" /> >-[% END %] >- >+ [% END %] > </div> > > </main> >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 9caefcca57..acaced35c8 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,3 +1,4 @@ >+[% USE Branches %] > [% USE Koha %] > [% USE raw %] > [% SET footerjs = 1 %] >@@ -12,36 +13,106 @@ > <body id="ser_routing-preview-slip" class="ser"> > <div class="container-fluid"> > >-<table> >- <tr> >- <td colspan="2"><h3>[% libraryname | html %]</h3></td> >- </tr> >- <tr> >- <td colspan="2"><b>Title:</b> [% title | html %]<br />[% issue | html %]</td> >- </tr> >- <tr> >- <td><b>Name</b></td> >- <td><b>Date due</b></td> >- </tr> >- [% FOREACH memberloo IN memberloop %] >- <tr> >- <td>[% memberloo.name | html %]</td> >- <td> </td> >- </tr> >+[% IF (missing_parameter_routinglistid or missing_parameter_serialid) %] >+ <h1>Routing list preview for <em>[% title | html %]</em></h1> >+ >+ <form action="" method="get"> >+ [% IF (missing_parameter_routinglistid) %] >+ <input type="hidden" name="serialid" value="[% serialid | html %]" /> >+ <label for="routinglist">Please select a routing list</label> >+ <select id="routinglist" name="routinglistid"> >+ [% FOREACH routinglist IN routinglists %] >+ <option value="[% routinglist.routinglistid | html %]"> >+ [% routinglist.title | html %] >+ </option> >+ [% END %] >+ </select> >+ [% ELSE %] >+ <input type="hidden" name="routinglistid" value="[% routinglistid | html %]" /> >+ <label for="serial">Please select a serial</label> >+ <select id="serial" name="serialid"> >+ [% FOREACH serial IN serials %] >+ <option value="[% serial.serialid | html %]"> >+ [% serial.serialseq | html %] ([% serial.planneddate | html %]) >+ </option> >+ [% END %] >+ </select> >+ [% END %] >+ <input type="submit" value="Continue" /> >+ </form> >+[% ELSE %] >+ [% IF (error_no_item) %] >+ <div class="error noprint"> >+ <p>Holds cannot be placed on this serial. There is no item attached to it.</p> >+ </div> > [% END %] >-</table> >+ <table> >+ [% IF branchcode %] >+ <tr> >+ <td colspan="2"><h3>[% Branches.GetName(branchcode) | html %]</h3></td> >+ </tr> >+ [% END %] >+ <tr> >+ <td colspan="2"> >+ <b>Title:</b> [% title | html %]<br /> >+ [% serial.serialseq | html %] ([% serial.planneddate | html %]) >+ </td> >+ </tr> >+ <tr> >+ <td colspan="2"> >+ <b>Routing list:</b> [% routinglisttitle | html %] >+ </td> >+ </tr> >+ <tr> >+ <td><b>Name</b></td> >+ <td><b>Date due</b></td> >+ </tr> >+ [% FOREACH member IN memberloop %] >+ <tr> >+ <td>[% member.surname | html %], [% member.firstname | html %]</td> >+ <td> </td> >+ </tr> >+ [% END %] >+ </table> > >-<div id="routingnotes"> >- <p id="generalroutingnote">[% Koha.Preference('RoutingListNote') | $raw %]</p> >- <p id="routingnote">[% routingnotes | html %]</p> >-</div> >+ <div id="routingnotes"> >+ <p id="generalroutingnote">[% Koha.Preference('RoutingListNote') | $raw %]</p> >+ <p id="routingnote">[% routingnotes | html %]</p> >+ </div> > >- <div id="closewindow" class="noprint"><a class="btn btn-default btn-default" id="print_slip" href="#"><i class="fa fa-print"></i> Print</a> <a class="btn btn-default btn-default close" href="#">Close</a></div> >+ [% IF (need_confirm) %] >+ [%# RoutingListAddReserves is ON %] >+ <script type="text/javascript"> >+ //<![CDATA[ >+ function ask_confirm() { >+ var msg = _("Holds will be placed for all borrowers in this list."); >+ msg += "\n"; >+ msg += _("Do you want to continue?"); >+ return confirm(msg); >+ } >+ //]]> >+ </script> >+ <form action="" method="get" onsubmit="return ask_confirm()"> >+ <input type="hidden" name="routinglistid" value="[% routinglistid | html %]" /> >+ <input type="hidden" name="serialid" value="[% serialid | html %]" /> >+ <input type="hidden" name="confirm" value="1" /> >+ <input type="submit" value="Confirm and print" /> >+ <input type="button" value="Cancel" onclick="window.close()" /> >+ </form> >+ [% ELSE %] >+ <div id="closewindow" class="noprint"> >+ <a class="btn btn-default" id="print_slip" href="#"><i class="fa fa-print"></i> Print</a> >+ <a class="btn btn-default close" href="#">Close</a> >+ </div> >+ [% END %] >+[% END %] >+ >+ </div> > > [% MACRO jsinclude BLOCK %] >- <script type="text/javascript"> >- $(document).ready(function(){ >- $("#print_slip").on("click",function(e){ >+ <script> >+ $(document).ready(function () { >+ $('#print_slip').on('click', function (e) { > e.preventDefault(); > window.print(); > self.close(); >@@ -49,5 +120,4 @@ > }); > </script> > [% END %] >- > [% INCLUDE 'intranet-bottom.inc' popup_window=1 %] >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 >deleted file mode 100644 >index 23af9667b0..0000000000 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing-preview.tt >+++ /dev/null >@@ -1,68 +0,0 @@ >-[% SET footerjs = 1 %] >-[% INCLUDE 'doc-head-open.inc' %] >-<title>Koha › Serials › Preview routing list</title> >-[% INCLUDE 'doc-head-close.inc' %] >-</head> >- >-<body id="ser_routing-preview" class="ser"> >-[% INCLUDE 'header.inc' %] >-[% INCLUDE 'serials-search.inc' %] >- >-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> › <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscriptionid | html %]"><i>[% title | html %]</i></a> › Preview routing list</div> >- >-<div class="main container-fluid"> >- <div class="row"> >- <div class="col-sm-10 col-sm-push-2"> >- <main> >- >-<h2>Preview routing list for <i>[% title | html %]</i></h2> >- >-<form method="post" action="routing-preview.pl"> >-<input type="hidden" id="subscriptionid" name="subscriptionid" value="[% subscriptionid | html %]" /> >- <input type="hidden" id="issue_escaped" name="issue_escaped" value="[% issue_escaped | html %]" /> >-<fieldset class="rows"> >- <ol> >- <li><span class="label">Issue:</span>[% issue | html %]</li> >- <li><span class="label">List member:</span><table style="clear:none;margin:0;"> >- <tr><th>Name</th></tr> >-[% FOREACH memberloo IN memberloop %] >- <tr><td>[% memberloo.surname | html %], [% memberloo.firstname | html %]</td></tr> >-[% END %] >- </table></li> >- <li><span class="label">Notes:</span>[% routingnotes | html %]</li> >- </ol> >-</fieldset> >- >-<fieldset class="action"> >- <input type="submit" name="ok" id="save_and_preview" class="button" value="Save and preview routing slip" /> >-<input type="submit" name="edit" class="button" value="Edit" /> >-<input type="submit" name="delete" class="button" value="Delete" /></fieldset> >-</form> >- >- </main> >- </div> <!-- /.col-sm-10.col-sm-push-2 --> >- >- <div class="col-sm-2 col-sm-pull-10"> >- <aside> >- [% INCLUDE 'serials-menu.inc' %] >- </aside> >- </div> <!-- /.col-sm-2.col-sm-pull-10 --> >- </div> <!-- /.row --> >- >-[% MACRO jsinclude BLOCK %] >- <script> >- $(document).ready(function(){ >- $("#save_and_preview").on("click",function(e){ >- e.preventDefault(); >- print_slip( $("#subscriptionid").val(), $("#issue_escaped").val() ); >- }); >- }); >- function print_slip(subscriptionid,issue){ >- var myurl = 'routing-preview.pl?ok=1&subscriptionid='+subscriptionid+'&issue='+issue; >- window.open(myurl,'PrintSlip','width=500,height=500,toolbar=no,scrollbars=yes'); >- window.location.href='subscription-detail.pl?subscriptionid=' + subscriptionid; >- } >- </script> >-[% END %] >- >-[% INCLUDE 'intranet-bottom.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 >deleted file mode 100644 >index 0652f90343..0000000000 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing.tt >+++ /dev/null >@@ -1,135 +0,0 @@ >-[% USE KohaDates %] >-[% SET footerjs = 1 %] >-[% INCLUDE 'doc-head-open.inc' %] >-<title>Koha › Serials › [% title | html %] › [% IF ( op ) %]Create routing list[% ELSE %]Edit routing list[% END %]</title> >-[% INCLUDE 'doc-head-close.inc' %] >-</head> >-<body id="ser_routing" class="ser"> >-[% INCLUDE 'header.inc' %] >-[% INCLUDE 'serials-search.inc' %] >- >-<div id="breadcrumbs"> >- <a href="/cgi-bin/koha/mainpage.pl">Home</a> >- › <a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> >- [% UNLESS blocking_error %] >- › <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscriptionid | uri %]"><i>[% title | html %]</i></a> >- › [% IF ( op ) %]Create routing list[% ELSE %]Edit routing list[% END %] >- [% END %] >-</div> >- >-<div class="main container-fluid"> >- <div class="row"> >- <div class="col-sm-10 col-sm-push-2"> >- <main> >-[% INCLUDE 'blocking_errors.inc' %] >- >-[% IF ( op ) %] >-<h1>Create routing list for <i>[% title | html %]</i></h1> >-[% ELSE %] >-<h1>Edit routing list for <i>[% title | html %]</i></h1> >-[% END %] >- >-<form method="post" action="routing.pl"> >-<input type="hidden" name="op" value="save" /> >-<input type="hidden" name="subscriptionid" value="[% subscriptionid | html %]" /> >-<fieldset class="rows"> >- <ol> >- <li><label for="date_selected">Issue: </label> >-<select name="date_selected" id="date_selected"> >- [% FOREACH date IN dates %] >- [% IF ( date.selected ) %] >- <option value="[% date.serialseq | html %] ([% date.publisheddate | html %])" selected="selected">[% date.serialseq | html %] ([% date.publisheddate | $KohaDates %])</option> >- [% ELSE %] >- <option value="[% date.serialseq | html %] ([% date.publisheddate | html %])">[% date.serialseq | html %] ([% date.publisheddate | $KohaDates %])</option> >- [% END %] >-[% END %] >-</select> [% issue | html %]</li> >- >-<li> >- <span class="label">Recipients:</span> >- [% IF memberloop %] >- <table style="clear:none;margin:0;"> >- <tr><th>Name</th> >- <th>Rank</th> >- <th>Delete</th> >- </tr> >- [% USE m_loop = iterator(memberloop) %] >- [% FOREACH member IN m_loop %] >- <tr><td>[% member.name | html %]</td> >- <td> >- <select name="itemrank" class="itemrank" data-subscriptionid="[% subscriptionid | html %]" data-routingid="[% member.routingid | html %]"> >- [% rankings = [1 .. m_loop.size] %] >- [% SET cur_rank = loop.count() %] >- [% FOREACH r IN rankings %] >- [% IF r == cur_rank %] >- <option selected="selected" value="[% r | html %]">[% r | html %]</option> >- [% ELSE %] >- <option value="[% r | html %]">[% r | html %]</option> >- [% END %] >- [% END %] >- </select> >- </td> >- <td><a class="btn btn-default btn-xs" href="/cgi-bin/koha/serials/routing.pl?routingid=[% member.routingid | html %]&subscriptionid=[% subscriptionid | html %]&op=delete"><i class="fa fa-trash"></i> Delete</a></td> >- </tr> >- [% END %] >- </table> >- [% END %] >- >- <p style="margin-left:10em;"> >- <a href="#" id="add_recipients"><i class="fa fa-plus"></i> Add recipients</a> >- [% IF memberloop %] >- <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscriptionid | uri %]&op=delete"><i class="fa fa-trash"></i> Delete all</a> >- [% END %] >- </p> >-</li> >- >- <li><label for="notes">Notes:</label><textarea name="notes" id="notes" rows="3" cols="50">[% routingnotes | html %]</textarea></li> >- </ol> >- >-</fieldset> >-<fieldset class="action"><input type="submit" name="submit" value="Save" /></fieldset> >-</form> >- >- </main> >- </div> <!-- /.col-sm-10.col-sm-push-2 --> >- >- <div class="col-sm-2 col-sm-pull-10"> >- <aside> >- [% INCLUDE 'serials-menu.inc' %] >- </aside> >- </div> <!-- /.col-sm-2.col-sm-pull-10 --> >- </div> <!-- /.row --> >-[% MACRO jsinclude BLOCK %] >- <script> >- $(document).ready(function(){ >- $("#add_recipients").on("click",function(e){ >- e.preventDefault(); >- userPopup(); >- }); >- $(".itemrank").on("change",function(){ >- var subscriptionid = $(this).data("subscriptionid"); >- var routingid = $(this).data("routingid"); >- reorder_item( subscriptionid, routingid, $(this).val()); >- }); >- }); >- function reorder_item(sid,rid,rank){ >- var mylocation = 'reorder_members.pl?subscriptionid='+sid+'&routingid='+rid+'&rank='+rank; >- window.location.href=mylocation; >- } >- >- function userPopup() { >- window.open("/cgi-bin/koha/serials/add_user_search.pl", >- 'PatronPopup', >- 'width=740,height=450,location=yes,toolbar=no,' >- + 'scrollbars=yes,resize=yes' >- ); >- } >- >- function add_user(borrowernumber) { >- var myurl = "routing.pl?subscriptionid="+[% subscriptionid | html %]+"&borrowernumber="+borrowernumber+"&op=add"; >- window.location.href = myurl; >- } >- </script> >-[% END %] >- >-[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routinglist.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routinglist.tt >new file mode 100644 >index 0000000000..b04dd61040 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routinglist.tt >@@ -0,0 +1,204 @@ >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Serials › Routing list</title> >+[% INCLUDE 'doc-head-close.inc' %] >+<script type="text/javascript"> >+//<![CDATA[ >+[% UNLESS ( new ) %] >+var max_rank = [% max_rank %]; >+ >+function IncMaxRank(){ >+ max_rank = max_rank + 1; >+ var option = '<option value="' + max_rank + '">' + max_rank + '</option>'; >+ $('select[name="ranking"]').append(option); >+} >+ >+function DecMaxRank(){ >+ max_rank = max_rank - 1; >+ $('select[name="ranking"] option[value="'+(max_rank+1)+'"]').remove(); >+} >+ >+function updateTable(){ >+ var ids = $("#borrowersids").val().split(":"); >+ // split returns an array with one empty string if string is empty >+ if(ids[0] == "") >+ ids.splice(0,1); >+ >+ var new_trs = new Array(); >+ for(var i=0; i<ids.length; i++){ >+ var tr = $("#ranking"+ids[i]).parents("tr"); >+ new_trs.push("<tr>"+$(tr).html()+"</tr>"); >+ } >+ $("#borrowers tbody").html(new_trs.join(" ")); >+ var i=0; >+ $("select[name='ranking']").each(function(){ >+ $(this).val(i+1); >+ i++; >+ var borrowernumber = $(this).attr('id').replace("ranking",""); >+ $(this).change(function(){ >+ reorderBorrower(borrowernumber, $(this).val()); >+ }); >+ }); >+ if(i < max_rank) >+ DecMaxRank(); >+ >+ if(max_rank == 0){ >+ $("#borrowers").hide(); >+ $("#noborrowersp").show(); >+ } >+} >+ >+// delete borrower if rank <= 0 >+function reorderBorrower(borrowernumber, rank){ >+ var ids = $("#borrowersids").val().split(":"); >+ for(var i=0; i<ids.length; i++){ >+ if(ids[i] == borrowernumber){ >+ ids.splice(i, 1); >+ break; >+ } >+ } >+ if(rank > 0){ >+ ids.splice(rank-1, 0, borrowernumber); >+ } >+ $("#borrowersids").val(ids.join(":")); >+ updateTable(); >+} >+ >+function add_user(borrowernumber, borrowername){ >+ // Check if we have already this borrower >+ var ids = $("#borrowersids").val(); >+ var re = new RegExp("(^"+borrowernumber+"$)|(^"+borrowernumber+":)|(:"+borrowernumber+"$)|(:"+borrowernumber+":)"); >+ if(ids.match(re)) >+ return -1; >+ >+ IncMaxRank(); >+ var tr = '<tr>'; >+ tr += '<td>' + borrowername + '</td>'; >+ tr += '<td><select name="ranking" id="ranking' + borrowernumber + '">'; >+ for(var i=0; i<(max_rank-1); i++){ >+ tr += '<option value="' + (i+1) + '">' + (i+1) + '</option>'; >+ } >+ tr += '<option selected="selected" value="' + (max_rank) + '">' + (max_rank) + '</option>'; >+ tr += '</select></td>'; >+ tr += '<td><a style="cursor:pointer" onclick="delBorrower('+borrowernumber+');">Delete</a></td>'; >+ tr += '</tr>'; >+ $("#borrowers tbody").append(tr); >+ $("#ranking"+borrowernumber).change(function(){ >+ reorderBorrower(borrowernumber, $(this).val()); >+ }); >+ >+ if(ids.length != 0) >+ ids += ':'; >+ ids += borrowernumber; >+ $("#borrowersids").val(ids); >+ >+ $("#borrowers").show(); >+ $("#noborrowersp").hide(); >+ >+ return 0; >+} >+ >+function delBorrower(borrowernumber){ >+ reorderBorrower(borrowernumber, 0); >+} >+ >+function SearchMember(){ >+ window.open("/cgi-bin/koha/serials/add_user_search.pl", >+ 'PatronPopup', >+ 'width=740,height=450,location=yes,toolbar=no,scrollbars=yes,resize=yes' >+ ); >+} >+ >+$(document).ready(function() { >+ updateTable(); >+}); >+[% END %] >+ >+//]]> >+</script> >+</head> >+ >+<body> >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'serials-search.inc' %] >+ >+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> › Routing list</div> >+ >+<div class="main container-fluid"> >+ >+<div class="row"> >+ <div class="col-sm-10 col-sm-push-2"> >+ <main> >+ [% INCLUDE 'serials-toolbar.inc' %] >+ [% IF ( new ) %] >+ <h1>Create routing list</h1> >+ >+ <form action="/cgi-bin/koha/serials/routinglist.pl" method="get"> >+ <input type="hidden" name="op" value="savenew" /> >+ <input type="hidden" name="subscriptionid" value="[% subscriptionid %]" /> >+ <label for="title">Title: </label> >+ <input type="text" id="title" name="title" /> >+ <input type="submit" value="Save" /> >+ </form> >+ [% ELSE %] >+ <h1>Routing list '[% title %]'</h1> >+ <a style="cursor:pointer" onclick="SearchMember();">Add a borrower</a> >+ [% IF ( borrowers_loop ) %] >+ <table id="borrowers"> >+ [% ELSE %] >+ <table id="borrowers" style="display:none"> >+ [% END %] >+ <thead> >+ <tr> >+ <th>Name</th> >+ <th>Rank</th> >+ <th> </th> >+ </tr> >+ </thead> >+ <tbody> >+ [% FOREACH borrower IN borrowers_loop %] >+ <tr> >+ <td>[% borrower.surname %], [% borrower.firstname %]</td> >+ <td> >+ <select name="ranking" id="ranking[% borrower.borrowernumber %]"> >+ [% FOREACH ranking_loo IN borrower.ranking_loop %] >+ [% IF ( ranking_loo.selected ) %] >+ <option selected="selected" value="[% ranking_loo.rank %]">[% ranking_loo.rank %]</option> >+ [% ELSE %] >+ <option value="[% ranking_loo.rank %]">[% ranking_loo.rank %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </td> >+ <td><a style="cursor:pointer" onclick="delBorrower([% borrower.borrowernumber %]);">Delete</a></td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ [% UNLESS ( borrowers_loop ) %] >+ <p id="noborrowersp">There are no borrowers in this routing list.</p> >+ [% END %] >+ <form action="/cgi-bin/koha/serials/routinglist.pl" method="post"> >+ <input type="hidden" id="borrowersids" name="borrowersids" value="[% borrowersids %]" /> >+ <input type="hidden" name="op" value="mod" /> >+ <input type="hidden" name="routinglistid" value="[% routinglistid %]" /> >+ <div> >+ <label for="title">Title: </label> >+ <input type="text" id="title" name="title" value="[% title %]"/> >+ </div> >+ <div> >+ <label for="notes">Notes: </label><br /> >+ <textarea id="notes" name="notes">[% notes %]</textarea><br /> >+ </div> >+ <input type="submit" value="Save" /> >+ <input type="button" value="Cancel" onclick="window.location.href='/cgi-bin/koha/serials/routinglists.pl?subscriptionid=[% subscriptionid %]';" /> >+ </form> >+ [% END %]<!-- new --> >+ </main> >+ </div> >+ <div class="col-sm-2 col-sm-pull-10"> >+ <aside> >+ [% INCLUDE 'serials-menu.inc' %] >+ </aside> >+ </div> >+</div> >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routinglists.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routinglists.tt >new file mode 100644 >index 0000000000..46bcc8f10d >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routinglists.tt >@@ -0,0 +1,71 @@ >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Serials › Routing lists</title> >+[% INCLUDE 'doc-head-close.inc' %] >+<script type="text/javascript"> >+//<![CDATA[ >+ >+function previewSlip(routinglistid){ >+ window.open("/cgi-bin/koha/serials/routing-preview-slip.pl?routinglistid="+routinglistid, 'PreviewSlip', 'menubar=no,status=no,toolbar=no'); >+} >+ >+function confirmDelete(){ >+ return confirm(_("Are you sure you want to delete this routing list?")); >+} >+ >+//]]> >+</script> >+</head> >+ >+<body> >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'serials-search.inc' %] >+ >+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> › Routing lists</div> >+ >+<div class="main container-fluid"> >+ >+<div class="row"> >+ <div class="col-sm-10 col-sm-push-2"> >+ <main> >+ [% INCLUDE 'serials-toolbar.inc' %] >+ <h1>Routing lists for <em>[% title %]</em></h1> >+ >+ <a href="/cgi-bin/koha/serials/routinglist.pl?op=new&subscriptionid=[% subscriptionid %]">New routing list</a> >+ >+ [% IF ( routinglists_loop ) %] >+ <table> >+ <thead> >+ <tr> >+ <th>Title</th> >+ <th>No. of borrowers</th> >+ <th>Notes</th> >+ <th> </th> >+ </tr> >+ </thead> >+ <tbody> >+ [% FOREACH routinglist IN routinglists_loop %] >+ <tr> >+ <td><a href="/cgi-bin/koha/serials/routinglist.pl?routinglistid=[% routinglist.routinglistid %]">[% routinglist.title %]</a></td> >+ <td>[% routinglist.borrowers.size || 0 %]</td> >+ <td>[% routinglist.notes %]</td> >+ <td> >+ <a style="cursor:pointer" onclick="previewSlip([% routinglist.routinglistid %]);">Preview</a> | >+ <a style="text-decoration:none" href="/cgi-bin/koha/serials/routinglists.pl?op=export&routinglistid=[% routinglist.routinglistid %]">Export</a> | >+ <a style="text-decoration:none" onclick="return confirmDelete();" href="/cgi-bin/koha/serials/routinglists.pl?op=del&routinglistid=[% routinglist.routinglistid %]">Delete</a></td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ [% ELSE %] >+ <p>There are no routing lists for this subscription.</p> >+ [% END %] >+ >+ </main> >+ </div> >+ <div class="col-sm-2 col-sm-pull-10"> >+ <aside> >+ [% INCLUDE 'serials-menu.inc' %] >+ </aside> >+ </div> >+</div> >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt >index 7d4310d406..4a66903eb1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt >@@ -65,10 +65,10 @@ > [% IF ( subscription.abouttoexpire ) || ( subscription.subscriptionexpired ) %]<td class="problem actions">[% ELSE %]<td class="actions">[% END %] > [% UNLESS subscription.closed %] > [% IF ( routing && CAN_user_serials_routing ) %] >- [% IF ( subscription.hasRouting ) %] >- <a class="btn btn-default btn-xs" href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid | html %]"><i class="fa fa-pencil"></i> Edit routing list</a> >+ [% IF ( subscription.routinglistscount ) %] >+ <a class="btn btn-default btn-xs" href="/cgi-bin/koha/serials/routinglists.pl?subscriptionid=[% subscription.subscriptionid | html %]"><i class="fa fa-pencil"></i> Edit routing list</a> > [% ELSE %] >- <a class="btn btn-default btn-xs" href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid | html %]&op=new"><i class="fa fa-plus"></i> Create routing list</a> >+ <a class="btn btn-default btn-xs" href="/cgi-bin/koha/serials/routinglist.pl?subscriptionid=[% subscription.subscriptionid | html %]&op=new"><i class="fa fa-plus"></i> New routing list</a> > [% END %] > [% END %] > [% IF ( subscription.abouttoexpire ) %]<a class="btn btn-default btn-xs" href="/cgi-bin/koha/serials/subscription-renew.pl?subscriptionid=[% subscription.subscriptionid | html %]" onclick="popup([% subscription.subscriptionid | html %]); return false;"><i class="fa fa-refresh"></i> Renew</a> >@@ -242,7 +242,7 @@ > </td> > [% IF ( routing ) %] > <td class="actions"> >- <a href="" onclick="print_slip([% serial.subscriptionid | html %], '[% serial.serialseq.replace("'", "\\'") | html %] ([% serial.publisheddate | $KohaDates %])'); return false" class="btn btn-default btn-xs"><i class="fa fa-print"></i> Print list</a> >+ <a href="" onclick="print_slip([% serial.serialid | html %]); return false;" class="btn btn-default btn-xs"><i class="fa fa-print"></i> Print list</a> > </td> > [% END %] > </tr> >@@ -280,8 +280,8 @@ > > <script> > >- function print_slip(subscriptionid,issue){ >- var myurl = 'routing-preview.pl?ok=1&subscriptionid='+subscriptionid+'&issue='+issue; >+ function print_slip(serialid){ >+ var myurl = '/cgi-bin/koha/serials/routing-preview-slip.pl?serialid=' + serialid; > window.open(myurl,'PrintSlip','width=500,height=500,toolbar=no,scrollbars=yes'); > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt >index b7c9bdb7cb..9e1ebc7818 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt >@@ -170,15 +170,13 @@ > [% IF ( routing && CAN_user_serials_routing ) %] > [% IF ( subscription.cannotedit ) %] > [% ELSE %] >- [% IF ( subscription.routingedit ) %] >- <li> >- <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid | uri %]"><i class="fa fa-pencil"></i> Edit routing list ([% subscription.routingedit | html %])</a> >- </li> >- [% ELSE %] >- <li> >- <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid | uri %]&op=new"> <i class="fa fa-plus"></i> New routing list</a> >- </li> >- [% END %] >+ <li> >+ [% IF ( subscription.routinglistscount ) %] >+ <a href="/cgi-bin/koha/serials/routinglists.pl?subscriptionid=[% subscription.subscriptionid | uri %]"><i class="fa fa-pencil"></i> Edit routing list ([% subscription.routinglistscount | html %])</a> >+ [% ELSE %] >+ <a href="/cgi-bin/koha/serials/routinglist.pl?subscriptionid=[% subscription.subscriptionid | uri %]&op=new"> <i class="fa fa-plus"></i> New routing list</a> >+ [% END %] >+ </li> > [% END %] > [% END # IF ( routing && CAN_user_serials_routing ) %] > >diff --git a/serials/reorder_members.pl b/serials/reorder_members.pl >deleted file mode 100755 >index 7edeb80909..0000000000 >--- a/serials/reorder_members.pl >+++ /dev/null >@@ -1,37 +0,0 @@ >-#!/usr/bin/perl >-# This file is part of Koha. >-# >-# Koha is free software; you can redistribute it and/or modify it >-# under the terms of the GNU General Public License as published by >-# the Free Software Foundation; either version 3 of the License, or >-# (at your option) any later version. >-# >-# Koha is distributed in the hope that it will be useful, but >-# WITHOUT ANY WARRANTY; without even the implied warranty of >-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >-# GNU General Public License for more details. >-# >-# You should have received a copy of the GNU General Public License >-# along with Koha; if not, see <http://www.gnu.org/licenses>. >- >-# Routing.pl script used to create a routing list for a serial subscription >-# In this instance it is in fact a setting up of a list of reserves for the item >-# where the hierarchical order can be changed on the fly and a routing list can be >-# printed out >-use Modern::Perl; >-use CGI qw ( -utf8 ); >-use C4::Auth qw( checkauth ); >-use C4::Serials qw( reorder_members ); >- >-my $query = CGI->new; >-my $subscriptionid = $query->param('subscriptionid'); >-my $routingid = $query->param('routingid'); >-my $rank = $query->param('rank'); >- >-checkauth( $query, 0, { serials => 'routing' }, 'intranet' ); >- >-reorder_members( $subscriptionid, $routingid, $rank ); >- >-print $query->redirect( >- "/cgi-bin/koha/serials/routing.pl?subscriptionid=$subscriptionid"); >- >diff --git a/serials/routing-preview-slip.pl b/serials/routing-preview-slip.pl >new file mode 100755 >index 0000000000..712d1f6584 >--- /dev/null >+++ b/serials/routing-preview-slip.pl >@@ -0,0 +1,151 @@ >+#!/usr/bin/perl >+ >+# Copyright 2011 BibLibre SARL >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+=head1 NAME >+ >+routing-preview-slip.pl >+ >+=head1 DESCRIPTION >+ >+Preview a routing list for printing. >+ >+=cut >+ >+use Modern::Perl; >+ >+use CGI; >+use C4::Auth; >+use C4::Output; >+ >+use C4::Biblio; >+use C4::Members; >+use C4::Serials; >+use C4::Serials::RoutingLists qw/GetRoutingList GetRoutingLists/; >+ >+use Koha::Biblios; >+use Koha::Patrons; >+ >+my $input = new CGI; >+my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( { >+ template_name => 'serials/routing-preview-slip.tt', >+ query => $input, >+ type => 'intranet', >+ authnotrequired => 0, >+ flagsrequired => { 'serials' => 'routing' }, >+ debug => 1, >+} ); >+ >+my $routinglistid = $input->param('routinglistid'); >+my $serialid = $input->param('serialid'); >+ >+if (!$routinglistid and !$serialid) { >+ exit; >+} >+ >+if (!$routinglistid) { >+ my $serial = GetSerial($serialid); >+ my $subscription = GetSubscription($serial->{subscriptionid}); >+ my $biblio = Koha::Biblios->find($subscription->{subscriptionid}); >+ my @routinglists = GetRoutingLists($subscription->{subscriptionid}); >+ $template->param( >+ missing_parameter_routinglistid => 1, >+ serialid => $serialid, >+ title => $biblio->title, >+ routinglists => \@routinglists >+ ); >+ output_html_with_http_headers $input, $cookie, $template->output; >+ exit; >+} elsif (!$serialid) { >+ my $routinglist = GetRoutingList($routinglistid); >+ my $subscription = GetSubscription($routinglist->{subscriptionid}); >+ my $biblio = Koha::Biblios->find($subscription->{subscriptionid}); >+ my @serials = GetSerials2($subscription->{subscriptionid}, [1,2,3,4,5,6,7]); >+ $template->param( >+ missing_parameter_serialid => 1, >+ routinglistid => $routinglistid, >+ title => $biblio->title, >+ serials => \@serials >+ ); >+ output_html_with_http_headers $input, $cookie, $template->output; >+ exit; >+} >+ >+my $routinglist = GetRoutingList($routinglistid); >+my $subscription = GetSubscription($routinglist->{subscriptionid}); >+my $serial = GetSerial($serialid); >+my $biblio = Koha::Biblios->find($subscription->{biblionumber}); >+my @memberloop; >+foreach (@{$routinglist->{borrowers}}) { >+ my $patron = Koha::Patrons->find($_); >+ push @memberloop, { >+ surname => $patron->surname, >+ firstname => $patron->firstname, >+ }; >+} >+ >+my $no_holds = $input->param('no_holds'); >+if(C4::Context->preference('RoutingListAddReserves') and !$no_holds) { >+ my $confirm = $input->param('confirm'); >+ if ($confirm) { >+ require C4::Reserves; >+ require C4::Items; >+ my $itemnumber = GetSerialItemnumber($serialid); >+ my $item = Koha::Items->find($itemnumber); >+ if ($item) { >+ my $rank = 1; >+ foreach my $borrowernumber ( @{$routinglist->{borrowers}} ) { >+ my @holds = Koha::Holds->search({ >+ borrowernumber => $borrowernumber, >+ biblionumber => $item->biblionumber >+ }); >+ if (@holds) { >+ C4::Reserves::ModReserve({ >+ rank => $rank, >+ biblionumber => $item->biblionumber, >+ borrowernumber => $borrowernumber, >+ branchcode => $item->holdingbranch, >+ itemnumber => $itemnumber, >+ }); >+ } else { >+ C4::Reserves::AddReserve($item->holdingbranch, $borrowernumber, >+ $item->biblionumber, undef, $rank, undef, >+ undef, undef, $biblio->title, $itemnumber); >+ } >+ $rank++; >+ } >+ } else { >+ $template->param(error_no_item => 1); >+ } >+ } else { >+ $template->param(need_confirm => 1); >+ } >+} >+ >+$template->param( >+ routinglistid => $routinglistid, >+ serialid => $serialid, >+ branchcode => $subscription->{branchcode}, >+ title => $biblio->{title}, >+ serial => $serial, >+ memberloop => \@memberloop, >+ routingnotes => $routinglist->{notes}, >+ generalroutingnote => C4::Context->preference('RoutingListNote'), >+ routinglisttitle => $routinglist->{title}, >+); >+ >+output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/serials/routing-preview.pl b/serials/routing-preview.pl >deleted file mode 100755 >index 7ddbfe5054..0000000000 >--- a/serials/routing-preview.pl >+++ /dev/null >@@ -1,144 +0,0 @@ >-#!/usr/bin/perl >- >-# This file is part of Koha. >-# >-# Koha is free software; you can redistribute it and/or modify it >-# under the terms of the GNU General Public License as published by >-# the Free Software Foundation; either version 3 of the License, or >-# (at your option) any later version. >-# >-# Koha is distributed in the hope that it will be useful, but >-# WITHOUT ANY WARRANTY; without even the implied warranty of >-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >-# GNU General Public License for more details. >-# >-# You should have received a copy of the GNU General Public License >-# along with Koha; if not, see <http://www.gnu.org/licenses>. >- >-# Routing Preview.pl script used to view a routing list after creation >-# lets one print out routing slip and create (in this instance) the hierarchy >-# of reserves for the serial >-use Modern::Perl; >-use CGI qw ( -utf8 ); >-use C4::Koha; >-use C4::Auth; >-use C4::Output; >-use C4::Acquisition; >-use C4::Reserves; >-use C4::Circulation; >-use C4::Context; >-use C4::Members; >-use C4::Biblio; >-use C4::Items; >-use C4::Serials; >-use URI::Escape; >- >-use Koha::Biblios; >-use Koha::Libraries; >-use Koha::Patrons; >- >-my $query = new CGI; >-my $subscriptionid = $query->param('subscriptionid'); >-my $issue = $query->param('issue'); >-my $routingid; >-my $ok = $query->param('ok'); >-my $edit = $query->param('edit'); >-my $delete = $query->param('delete'); >-my $dbh = C4::Context->dbh; >- >-if($delete){ >- delroutingmember($routingid,$subscriptionid); >- my $sth = $dbh->prepare("UPDATE serial SET routingnotes = NULL WHERE subscriptionid = ?"); >- $sth->execute($subscriptionid); >- print $query->redirect("routing.pl?subscriptionid=$subscriptionid&op=new"); >-} >- >-if($edit){ >- print $query->redirect("routing.pl?subscriptionid=$subscriptionid"); >-} >- >-my @routinglist = getroutinglist($subscriptionid); >-my $subs = GetSubscription($subscriptionid); >-my ($tmp ,@serials) = GetSerials($subscriptionid); >-my ($template, $loggedinuser, $cookie); >- >-my $library; >-if($ok){ >- # get biblio information.... >- my $biblionumber = $subs->{'bibnum'}; >- my @itemresults = GetItemsInfo( $biblionumber ); >- my $branch = @itemresults ? $itemresults[0]->{'holdingbranch'} : $subs->{branchcode}; >- $library = Koha::Libraries->find($branch); >- >- if (C4::Context->preference('RoutingListAddReserves')){ >- # get existing reserves ..... >- >- my $biblio = Koha::Biblios->find( $biblionumber ); >- my $holds = $biblio->current_holds; >- my $count = $holds->count; >- while ( my $hold = $holds->next ) { >- $count-- if $hold->is_waiting; >- } >- my $notes; >- my $title = $subs->{'bibliotitle'}; >- for my $routing ( @routinglist ) { >- my $sth = $dbh->prepare('SELECT * FROM reserves WHERE biblionumber = ? AND borrowernumber = ? LIMIT 1'); >- $sth->execute($biblionumber,$routing->{borrowernumber}); >- my $reserve = $sth->fetchrow_hashref; >- >- if($routing->{borrowernumber} == $reserve->{borrowernumber}){ >- ModReserve({ >- rank => $routing->{ranking}, >- biblionumber => $biblionumber, >- borrowernumber => $routing->{borrowernumber}, >- branchcode => $branch >- }); >- } else { >- AddReserve($branch,$routing->{borrowernumber},$biblionumber,undef,$routing->{ranking}, undef, undef, $notes,$title); >- } >- } >- } >- >- ($template, $loggedinuser, $cookie) >-= get_template_and_user({template_name => "serials/routing-preview-slip.tt", >- query => $query, >- type => "intranet", >- authnotrequired => 0, >- flagsrequired => {serials => '*'}, >- debug => 1, >- }); >-} else { >- ($template, $loggedinuser, $cookie) >-= get_template_and_user({template_name => "serials/routing-preview.tt", >- query => $query, >- type => "intranet", >- authnotrequired => 0, >- flagsrequired => {serials => '*'}, >- debug => 1, >- }); >-} >- >-$template->param( libraryname => $library->branchname ) if $library; >- >-my $memberloop = []; >-for my $routing (@routinglist) { >- my $member = Koha::Patrons->find( $routing->{borrowernumber} )->unblessed; >- $member->{name} = "$member->{firstname} $member->{surname}"; >- push @{$memberloop}, $member; >-} >- >-my $routingnotes = $serials[0]->{'routingnotes'}; >-$routingnotes =~ s/\n/\<br \/\>/g; >- >-$template->param( >- title => $subs->{'bibliotitle'}, >- issue => $issue, >- issue_escaped => URI::Escape::uri_escape_utf8($issue), >- subscriptionid => $subscriptionid, >- memberloop => $memberloop, >- routingnotes => $routingnotes, >- hasRouting => check_routing($subscriptionid), >- (uc(C4::Context->preference("marcflavour"))) => 1 >- ); >- >-output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/serials/routing.pl b/serials/routing.pl >deleted file mode 100755 >index 8d893f66de..0000000000 >--- a/serials/routing.pl >+++ /dev/null >@@ -1,133 +0,0 @@ >-#!/usr/bin/perl >- >-# This file is part of Koha >-# >-# Koha is free software; you can redistribute it and/or modify it >-# under the terms of the GNU General Public License as published by >-# the Free Software Foundation; either version 3 of the License, or >-# (at your option) any later version. >-# >-# Koha is distributed in the hope that it will be useful, but >-# WITHOUT ANY WARRANTY; without even the implied warranty of >-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >-# GNU General Public License for more details. >-# >-# You should have received a copy of the GNU General Public License >-# along with Koha; if not, see <http://www.gnu.org/licenses>. >- >- >-=head1 Routing.pl >- >-script used to create a routing list for a serial subscription >-In this instance it is in fact a setting up of a list of reserves for the item >-where the hierarchical order can be changed on the fly and a routing list can be >-printed out >- >-=cut >- >-use Modern::Perl; >-use CGI qw ( -utf8 ); >-use C4::Koha; >-use C4::Auth; >-use C4::Output; >-use C4::Acquisition; >-use C4::Output; >-use C4::Context; >- >-use C4::Members; >-use C4::Serials; >-use Koha::Patrons; >- >-use URI::Escape; >- >-my $query = new CGI; >-my $subscriptionid = $query->param('subscriptionid'); >-my $serialseq = $query->param('serialseq'); >-my $routingid = $query->param('routingid'); >-my $borrowernumber = $query->param('borrowernumber'); >-my $notes = $query->param('notes'); >-my $op = $query->param('op') || q{}; >-my $date_selected = $query->param('date_selected'); >-$date_selected ||= q{}; >-my $dbh = C4::Context->dbh; >- >-my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >- { >- template_name => 'serials/routing.tt', >- query => $query, >- type => 'intranet', >- authnotrequired => 0, >- flagsrequired => { serials => 'routing' }, >- } >-); >- >-my $subs = GetSubscription($subscriptionid); >- >-output_and_exit( $query, $cookie, $template, 'unknown_subscription') >- unless $subs; >- >-if($op eq 'delete'){ >- delroutingmember($routingid,$subscriptionid); >-} >- >-if($op eq 'add'){ >- addroutingmember($borrowernumber,$subscriptionid); >-} >-if($op eq '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"); >-} >- >-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 $member_loop = []; >-for my $routing ( @routinglist ) { >- my $member = Koha::Patrons->find( $routing->{borrowernumber} )->unblessed; >- $member->{location} = $member->{branchcode}; >- if ($member->{firstname} ) { >- $member->{name} = $member->{firstname} . q| |; >- } >- else { >- $member->{name} = q{}; >- } >- if ($member->{surname} ) { >- $member->{name} .= $member->{surname}; >- } >- $member->{routingid}=$routing->{routingid} || q{}; >- $member->{ranking} = $routing->{ranking} || q{}; >- >- push(@{$member_loop}, $member); >-} >- >-$template->param( >- title => $subs->{bibliotitle}, >- subscriptionid => $subscriptionid, >- memberloop => $member_loop, >- op => $op eq 'new', >- dates => $dates, >- routingnotes => $serials[0]->{'routingnotes'}, >- hasRouting => check_routing($subscriptionid), >- (uc(C4::Context->preference("marcflavour"))) => 1 >- >- ); >- >-output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/serials/routinglist.pl b/serials/routinglist.pl >new file mode 100755 >index 0000000000..62c5d2e4a8 >--- /dev/null >+++ b/serials/routinglist.pl >@@ -0,0 +1,120 @@ >+#!/usr/bin/perl >+ >+# Copyright 2011 BibLibre SARL >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+=head1 NAME >+ >+routinglist.pl >+ >+=head1 DESCRIPTION >+ >+Create or modify a routing list >+ >+=cut >+ >+use Modern::Perl; >+ >+use CGI; >+use C4::Auth; >+use C4::Output; >+ >+use C4::Members; >+use C4::Serials; >+use C4::Serials::RoutingLists qw/AddRoutingList ModRoutingList GetRoutingList/; >+ >+use Koha::Patrons; >+ >+my $input = new CGI; >+my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( { >+ template_name => 'serials/routinglist.tt', >+ query => $input, >+ type => 'intranet', >+ authnotrequired => 0, >+ flagsrequired => { serials => 'routing' }, >+ debug => 1, >+} ); >+ >+my $op = $input->param('op'); >+my $routinglistid; >+ >+if($op && $op eq 'new') { >+ my $subscriptionid = $input->param('subscriptionid'); >+ $template->param( >+ new => 1, >+ subscriptionid => $subscriptionid, >+ ); >+ output_html_with_http_headers $input, $cookie, $template->output; >+ exit; >+} >+ >+if($op && $op eq 'savenew') { >+ my $title = $input->param('title'); >+ my $subscriptionid = $input->param('subscriptionid'); >+ >+ $routinglistid = AddRoutingList($subscriptionid, $title); >+ print $input->redirect('/cgi-bin/koha/serials/routinglist.pl?routinglistid=' >+ . $routinglistid); >+ exit; >+} else { >+ $routinglistid = $input->param('routinglistid'); >+} >+ >+if($op && $op eq 'mod') { >+ my $borrowersids = $input->param('borrowersids'); >+ my $title = $input->param('title'); >+ my $notes = $input->param('notes'); >+ my @borrowernumbers = split /:/, $borrowersids; >+ ModRoutingList($routinglistid, undef, $title, $notes, @borrowernumbers); >+ my $routinglist = GetRoutingList($routinglistid); >+ print $input->redirect("/cgi-bin/koha/serials/routinglists.pl?subscriptionid=".$routinglist->{'subscriptionid'}); >+ exit; >+} >+ >+my $routinglist = GetRoutingList($routinglistid); >+my @borrowers; >+my $rank = 1; >+foreach my $borrowernumber (@{$routinglist->{borrowers}}) { >+ my @ranking_loop; >+ for(my $i = 0 ; $i < scalar(@{$routinglist->{borrowers}}) ; $i++){ >+ my $selected = 0; >+ $selected = 1 if ($rank == $i+1); >+ push @ranking_loop, { >+ rank => $i+1, >+ selected => $selected, >+ }; >+ } >+ my $patron = Koha::Patrons->find($borrowernumber); >+ push @borrowers, { >+ borrowernumber => $borrowernumber, >+ surname => $patron->surname, >+ firstname => $patron->firstname, >+ ranking_loop => \@ranking_loop >+ }; >+ $rank ++; >+} >+ >+$template->param( >+ borrowers_loop => \@borrowers, >+ borrowersids => join(':', map ($_->{borrowernumber}, @borrowers)), >+ max_rank => scalar(@borrowers), >+ title => $routinglist->{title}, >+ notes => $routinglist->{notes}, >+ subscriptionid => $routinglist->{subscriptionid}, >+ routinglistid => $routinglistid, >+); >+ >+output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/serials/routinglists.pl b/serials/routinglists.pl >new file mode 100755 >index 0000000000..3ba5170165 >--- /dev/null >+++ b/serials/routinglists.pl >@@ -0,0 +1,81 @@ >+#!/usr/bin/perl >+ >+# Copyright 2011 BibLibre SARL >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+=head1 NAME >+ >+routinglists.pl >+ >+=head1 DESCRIPTION >+ >+View all routing lists for a subscription >+ >+=cut >+ >+use Modern::Perl; >+ >+use CGI; >+use C4::Auth; >+use C4::Output; >+ >+use C4::Biblio; >+use C4::Serials; >+use C4::Serials::RoutingLists qw/GetRoutingLists GetRoutingList DelRoutingList GetRoutingListAsCSV/; >+ >+use Koha::Biblios; >+ >+my $input = new CGI; >+my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( { >+ template_name => 'serials/routinglists.tt', >+ query => $input, >+ type => 'intranet', >+ authnotrequired => 0, >+ flagsrequired => { serials => 'routing' }, >+ debug => 1, >+} ); >+ >+my $subscriptionid = $input->param('subscriptionid'); >+my $op = $input->param('op'); >+ >+if($op && $op eq "export") { >+ my $routinglistid = $input->param('routinglistid'); >+ print $input->header( >+ -type => 'text/csv', >+ -attachment => 'routinglist' . $routinglistid . '.csv', >+ ); >+ print GetRoutingListAsCSV($routinglistid); >+ exit; >+} elsif($op && $op eq "del") { >+ my $routinglistid = $input->param('routinglistid'); >+ if(!defined $subscriptionid){ >+ my $routinglist = GetRoutingList($routinglistid); >+ $subscriptionid = $routinglist->{subscriptionid}; >+ } >+ DelRoutingList($routinglistid); >+} >+ >+my $subscription = GetSubscription($subscriptionid); >+my $biblio = Koha::Biblios->find($subscription->{biblionumber}); >+my @routinglists = GetRoutingLists($subscriptionid); >+ >+$template->param( >+ subscriptionid => $subscriptionid, >+ routinglists_loop => \@routinglists, >+ title => $biblio->title, >+); >+ >+output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl >index d9ab11a61e..eb50bb9822 100755 >--- a/serials/serials-collection.pl >+++ b/serials/serials-collection.pl >@@ -24,6 +24,7 @@ use CGI qw ( -utf8 ); > use C4::Auth; > use C4::Koha; > use C4::Serials; >+use C4::Serials::RoutingLists qw/GetRoutingListsCount/; > use C4::Letters; > use C4::Output; > use C4::Context; >@@ -59,7 +60,7 @@ if($op eq 'gennext' && @subscriptionid){ > my $subscriptionid = $subscriptionid[0]; > my $sth = $dbh->prepare(" > SELECT publisheddate, publisheddatetext, serialid, serialseq, >- planneddate, notes, routingnotes >+ planneddate, notes > FROM serial > WHERE status = 1 AND subscriptionid = ? > "); >@@ -91,7 +92,7 @@ if($op eq 'gennext' && @subscriptionid){ > ## Creating the new issue > NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, > 1, $planneddate, $nextpublisheddate, undef, >- $issue->{notes}, $issue->{routingnotes} ); >+ $issue->{notes} ); > > ## Updating the subscription seq status > my $squery = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=? >@@ -130,7 +131,7 @@ if (@subscriptionid){ > my $numberpattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subs->{numberpattern}); > $subs->{frequency} = $frequency; > $subs->{numberpattern} = $numberpattern; >- $subs->{'hasRouting'} = check_routing($subscriptionid); >+ $subs->{'hasRouting'} = GetRoutingListsCount($subscriptionid); > push @$subscriptiondescs,$subs; > my $tmpsubscription= GetFullSubscription($subscriptionid); > @subscriptioninformation=(@$tmpsubscription,@subscriptioninformation); >@@ -158,9 +159,10 @@ my $yearmax=($subscriptions->[0]{year} eq "manage" && scalar(@$subscriptions)>1) > my $yearmin=$subscriptions->[scalar(@$subscriptions)-1]{year}; > my $subscriptionidlist=""; > foreach my $subscription (@$subscriptiondescs){ >- $subscriptionidlist.=$subscription->{'subscriptionid'}."," ; >- $biblionumber = $subscription->{'bibnum'} unless ($biblionumber); >- $subscription->{'hasRouting'} = check_routing($subscription->{'subscriptionid'}); >+ $subscriptionidlist.=$subscription->{'subscriptionid'}."," ; >+ $biblionumber = $subscription->{'bibnum'} unless ($biblionumber); >+ $subscription->{routinglistscount} >+ = GetRoutingListsCount($subscription->{subscriptionid}); > } > > chop $subscriptionidlist; >diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl >index 749e126216..d6a19c2c70 100755 >--- a/serials/serials-edit.pl >+++ b/serials/serials-edit.pl >@@ -239,7 +239,6 @@ if ( $op and $op eq 'serialchangestatus' ) { > $pub_date, > $publisheddatetexts[$i], > $notes[$i], >- $serialdatalist[0]->{'routingnotes'} > ); > } > } >diff --git a/serials/serials-search.pl b/serials/serials-search.pl >index fe9347eb03..16fb85072b 100755 >--- a/serials/serials-search.pl >+++ b/serials/serials-search.pl >@@ -36,6 +36,7 @@ use C4::Koha qw( GetAuthorisedValues ); > use C4::Output; > use C4::Serials; > use Koha::AdditionalFields; >+use C4::Serials::RoutingLists qw/GetRoutingListsCount/; > > use Koha::DateUtils; > use Koha::SharedContent; >@@ -151,7 +152,7 @@ else > # to toggle between create or edit routing list options > if ($routing) { > for my $subscription ( @subscriptions) { >- $subscription->{routingedit} = check_routing( $subscription->{subscriptionid} ); >+ $subscription->{routinglistscount} = GetRoutingListsCount($subscription->{subscriptionid}); > } > } > >diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl >index b7137bdbc7..f49982491c 100755 >--- a/serials/subscription-detail.pl >+++ b/serials/subscription-detail.pl >@@ -22,6 +22,7 @@ use C4::Auth; > use C4::Budgets; > use C4::Koha; > use C4::Serials; >+use C4::Serials::RoutingLists qw/GetRoutingListsCount/; > use C4::Output; > use C4::Context; > use C4::Search qw/enabled_staff_search_views/; >@@ -107,7 +108,7 @@ elsif ( $op and $op eq "share" ) { > $subs->{mana_id} = $result->{id}; > } > >-my $hasRouting = check_routing($subscriptionid); >+my $hasRouting = GetRoutingListsCount($subscriptionid); > > (undef, $cookie, undef, undef) > = checkauth($query, 0, {catalogue => 1}, "intranet"); >diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t >index 735af75430..0f870c2d20 100755 >--- a/t/db_dependent/Serials.t >+++ b/t/db_dependent/Serials.t >@@ -18,7 +18,7 @@ use Koha::DateUtils; > use Koha::Acquisition::Booksellers; > use t::lib::Mocks; > use t::lib::TestBuilder; >-use Test::More tests => 49; >+use Test::More tests => 48; > > BEGIN { > use_ok('C4::Serials'); >@@ -163,7 +163,7 @@ subtest 'Values should not be erased on editing' => sub { > ); > my ( undef, undef, $itemnumber ) = C4::Items::AddItemFromMarc( $item_record, $biblionumber ); > my $serialid = C4::Serials::NewIssue( "serialseq", $subscriptionid, $biblionumber, >- 1, undef, undef, "publisheddatetext", "notes", "routingnotes" ); >+ 1, undef, undef, "publisheddatetext", "notes" ); > C4::Serials::AddItem2Serial( $serialid, $itemnumber ); > my $serial_info = C4::Serials::GetSerialInformation($serialid); > my ($itemcallnumber_info) = grep { $_->{kohafield} eq 'items.itemcallnumber' } >@@ -282,13 +282,6 @@ subtest 'test_updateClaim' => sub { > is($late_or_missing_issues_1_2[0]->{status}, 3, 'Got the expected unchanged claim status from update claim'); > }; > >-is(C4::Serials::check_routing(), undef, 'test checking route'); >-is(C4::Serials::check_routing($subscriptionid), 0, 'There should not have any routing list for the subscription'); >-# TODO really test this check_routing subroutine >- >-is(C4::Serials::addroutingmember(),undef, 'test adding route member'); >- >- > # Unit tests for statuses management (Bug 11689) > $subscriptionid = NewSubscription( > undef, "", undef, undef, $budget_id, $biblionumber, >@@ -400,3 +393,41 @@ subtest "NewSubscription" => sub { > ); > ok($subscriptionid, "Sending empty string instead of undef to reflect use of the interface"); > }; >+ >+subtest 'GetSerial' => sub { >+ plan tests => 6; >+ >+ my $serial; >+ >+ $serial = GetSerial; >+ ok(not (defined $serial), 'GetSerial() returns undef'); >+ >+ $serial = GetSerial(-1); >+ ok(not (defined $serial), 'GetSerial(-1) returns undef'); >+ >+ my ($total_issues, @serials) = C4::Serials::GetSerials( $subscriptionid ); >+ $serial = GetSerial($serials[0]->{serialid}); >+ is($serial->{serialid}, $serials[0]->{serialid}, 'serialid is ok'); >+ is($serial->{serialseq}, $serials[0]->{serialseq}, 'serialseq is ok'); >+ is($serial->{status}, $serials[0]->{status}, 'status is ok'); >+ is($serial->{notes}, $serials[0]->{notes}, 'notes is ok'); >+}; >+ >+subtest 'GetSerialItemnumber' => sub { >+ plan tests => 3; >+ >+ my $itemnumber; >+ >+ $itemnumber = GetSerialItemnumber; >+ ok(not (defined $itemnumber), 'GetSerialItemnumber() returns undef'); >+ >+ $itemnumber = GetSerialItemnumber(-1); >+ ok(not (defined $itemnumber), 'GetSerialItemnumber(-1) returns undef'); >+ >+ my $item_itemnumber = C4::Items::AddItem({}, $biblionumber); >+ my ($total_issues, @serials) = C4::Serials::GetSerials( $subscriptionid ); >+ AddItem2Serial($serials[0]->{serialid}, $item_itemnumber); >+ $itemnumber = GetSerialItemnumber($serials[0]->{serialid}); >+ is($itemnumber, $item_itemnumber, >+ 'GetSerialItemnumber($serialid) returns itemnumber'); >+}; >diff --git a/t/db_dependent/Serials/RoutingLists.t b/t/db_dependent/Serials/RoutingLists.t >new file mode 100644 >index 0000000000..ea492d4b07 >--- /dev/null >+++ b/t/db_dependent/Serials/RoutingLists.t >@@ -0,0 +1,240 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use Test::More tests => 7; >+ >+use C4::Serials; >+use C4::Serials::RoutingLists; >+ >+use C4::Biblio; >+use C4::Members; >+ >+use Koha::Database; >+ >+my $dbh = C4::Context->dbh; >+$dbh->{AutoCommit} = 0; >+ >+my $record = MARC::Record->new; >+my $field = C4::Context->preference('marcflavour') eq 'UNIMARC' >+ ? MARC::Field->new(200, '', '', a => 'Title') >+ : MARC::Field->new(245, '', '', a => 'Title'); >+$record->append_fields($field); >+my ($biblionumber) = AddBiblio($record, ''); >+ >+my $subscriptionid = C4::Serials::NewSubscription(undef, '', (undef)x3, >+ $biblionumber, '2015-04-23', (undef)x10, '', '', (undef)x6, 0, '', 0, >+ undef, undef, 0, undef, undef, 0); >+ >+my $schema = Koha::Database->new->schema; >+my $categorycode = $schema->resultset('Category')->search->first->categorycode; >+my $branchcode = $schema->resultset('Branch')->search->first->branchcode; >+ >+my $borrowernumber1 = C4::Members::AddMember( >+ surname => 'Doe', >+ firstname => 'John', >+ categorycode => $categorycode, >+ branchcode => $branchcode, >+); >+my $borrowernumber2 = C4::Members::AddMember( >+ surname => 'Smith', >+ firstname => 'Jane', >+ categorycode => $categorycode, >+ branchcode => $branchcode, >+); >+ >+subtest 'AddRoutingList' => sub { >+ plan tests => 9; >+ >+ my $routinglistid; >+ >+ $routinglistid = C4::Serials::RoutingLists::AddRoutingList; >+ ok(not (defined $routinglistid), >+ 'AddRoutingList with bad parameters should return undef'); >+ >+ $routinglistid = C4::Serials::RoutingLists::AddRoutingList(-1); >+ ok(not (defined $routinglistid), >+ 'AddRoutingList with bad parameters should return undef'); >+ >+ $routinglistid = C4::Serials::RoutingLists::AddRoutingList($subscriptionid); >+ ok(not (defined $routinglistid), >+ 'AddRoutingList with bad parameters should return undef'); >+ >+ $routinglistid = C4::Serials::RoutingLists::AddRoutingList($subscriptionid, ''); >+ ok(not (defined $routinglistid), >+ 'AddRoutingList with bad parameters should return undef'); >+ >+ $routinglistid = C4::Serials::RoutingLists::AddRoutingList($subscriptionid, 'Title'); >+ ok((defined $routinglistid), >+ 'AddRoutingList with good parameters should return an id'); >+ >+ my $routinglist = C4::Serials::RoutingLists::GetRoutingList($routinglistid); >+ is($routinglist->{routinglistid}, $routinglistid, >+ 'new routing list id is ok'); >+ is($routinglist->{subscriptionid}, $subscriptionid, >+ 'new routing list subscriptionid is ok'); >+ is($routinglist->{title}, >+ 'Title', 'new routing list title is ok'); >+ ok(not (defined $routinglist->{notes}), >+ 'new routing list has not notes'); >+}; >+ >+subtest 'ModRoutingList' => sub { >+ plan tests => 5; >+ >+ my ($routinglist, $expected); >+ >+ my $routinglistid = C4::Serials::RoutingLists::AddRoutingList($subscriptionid, 'Title'); >+ >+ C4::Serials::RoutingLists::ModRoutingList($routinglistid); >+ $routinglist = C4::Serials::RoutingLists::GetRoutingList($routinglistid); >+ $expected = { >+ routinglistid => $routinglistid, >+ subscriptionid => $subscriptionid, >+ title => 'Title', >+ notes => undef, >+ }; >+ is_deeply($routinglist, $expected, 'routing list is as expected'); >+ >+ C4::Serials::RoutingLists::ModRoutingList($routinglistid, undef, 'Title 2'); >+ $routinglist = C4::Serials::RoutingLists::GetRoutingList($routinglistid); >+ $expected = { >+ routinglistid => $routinglistid, >+ subscriptionid => $subscriptionid, >+ title => 'Title 2', >+ notes => undef, >+ }; >+ is_deeply($routinglist, $expected, 'routing list is as expected'); >+ >+ C4::Serials::RoutingLists::ModRoutingList($routinglistid, undef, undef, 'notes'); >+ $routinglist = C4::Serials::RoutingLists::GetRoutingList($routinglistid); >+ $expected = { >+ routinglistid => $routinglistid, >+ subscriptionid => $subscriptionid, >+ title => 'Title 2', >+ notes => 'notes', >+ }; >+ is_deeply($routinglist, $expected, 'routing list is as expected'); >+ >+ C4::Serials::RoutingLists::ModRoutingList($routinglistid, undef, undef, >+ undef, $borrowernumber1, $borrowernumber2); >+ $routinglist = C4::Serials::RoutingLists::GetRoutingList($routinglistid); >+ $expected = { >+ routinglistid => $routinglistid, >+ subscriptionid => $subscriptionid, >+ title => 'Title 2', >+ notes => 'notes', >+ borrowers => [$borrowernumber1, $borrowernumber2], >+ }; >+ is_deeply($routinglist, $expected, 'routing list is as expected'); >+ >+ C4::Serials::RoutingLists::ModRoutingList($routinglistid); >+ $routinglist = C4::Serials::RoutingLists::GetRoutingList($routinglistid); >+ $expected = { >+ routinglistid => $routinglistid, >+ subscriptionid => $subscriptionid, >+ title => 'Title 2', >+ notes => 'notes', >+ }; >+ is_deeply($routinglist, $expected, 'routing list is as expected'); >+}; >+ >+subtest 'DelRoutingList' => sub { >+ plan tests => 1; >+ >+ my $routinglist; >+ >+ my $routinglistid = C4::Serials::RoutingLists::AddRoutingList($subscriptionid, 'Title'); >+ C4::Serials::RoutingLists::DelRoutingList($routinglistid); >+ $routinglist = C4::Serials::RoutingLists::GetRoutingList($routinglistid); >+ ok(not (defined $routinglist), 'routing list is deleted'); >+}; >+ >+subtest 'GetRoutingList' => sub { >+ plan tests => 3; >+ >+ my $routinglist; >+ >+ $routinglist = C4::Serials::RoutingLists::GetRoutingList; >+ ok (not (defined $routinglist), 'GetRoutingList() returns undef'); >+ >+ $routinglist = C4::Serials::RoutingLists::GetRoutingList(-1); >+ ok (not (defined $routinglist), 'GetRoutingList(-1) returns undef'); >+ >+ my $routinglistid = C4::Serials::RoutingLists::AddRoutingList($subscriptionid, 'Title'); >+ $routinglist = C4::Serials::RoutingLists::GetRoutingList($routinglistid); >+ ok ((defined $routinglist), 'GetRoutingList($routinglistid) returns undef'); >+}; >+ >+subtest 'GetRoutingLists' => sub { >+ plan tests => 4; >+ >+ my (@routinglists, $routinglistid); >+ >+ # Remove routing lists from previous tests >+ @routinglists = C4::Serials::RoutingLists::GetRoutingLists($subscriptionid); >+ foreach my $routinglist (@routinglists) { >+ C4::Serials::RoutingLists::DelRoutingList($routinglist->{routinglistid}); >+ } >+ >+ @routinglists = C4::Serials::RoutingLists::GetRoutingLists; >+ is(scalar @routinglists, 0, 'GetRoutingLists() returns an empty list'); >+ >+ @routinglists = C4::Serials::RoutingLists::GetRoutingLists($subscriptionid); >+ is(scalar @routinglists, 0, >+ 'GetRoutingLists($subscriptionid) returns an empty list'); >+ >+ $routinglistid = C4::Serials::RoutingLists::AddRoutingList($subscriptionid, 'list 1'); >+ C4::Serials::RoutingLists::ModRoutingList($routinglistid, undef, undef, >+ undef, $borrowernumber1); >+ $routinglistid = C4::Serials::RoutingLists::AddRoutingList($subscriptionid, 'list 2'); >+ C4::Serials::RoutingLists::ModRoutingList($routinglistid, undef, undef, >+ undef, $borrowernumber1); >+ @routinglists = C4::Serials::RoutingLists::GetRoutingLists($subscriptionid); >+ is(scalar @routinglists, 2, >+ 'GetRoutingLists($subscriptionid) returns all routing lists'); >+ is_deeply($routinglists[0]->{borrowers}, [$borrowernumber1], >+ 'GetRoutingLists returns borrower list for each routing list'); >+}; >+ >+subtest 'GetRoutingListsCount' => sub { >+ plan tests => 3; >+ >+ my $count; >+ >+ # Remove routing lists from previous tests >+ my @routinglists = C4::Serials::RoutingLists::GetRoutingLists($subscriptionid); >+ foreach my $routinglist (@routinglists) { >+ C4::Serials::RoutingLists::DelRoutingList($routinglist->{routinglistid}); >+ } >+ >+ $count = C4::Serials::RoutingLists::GetRoutingListsCount; >+ is($count, undef, 'GetRoutingListsCount() returns undef'); >+ >+ $count = C4::Serials::RoutingLists::GetRoutingListsCount($subscriptionid); >+ is($count, 0, 'GetRoutingListsCount($subscriptionid) returns 0'); >+ >+ C4::Serials::RoutingLists::AddRoutingList($subscriptionid, 'list 1'); >+ C4::Serials::RoutingLists::AddRoutingList($subscriptionid, 'list 2'); >+ $count = C4::Serials::RoutingLists::GetRoutingListsCount($subscriptionid); >+ is($count, 2, 'GetRoutingListsCount($subscriptionid) returns 2'); >+}; >+ >+subtest 'GetRoutingListAsCSV' => sub { >+ plan tests => 1; >+ >+ my $routinglistid = C4::Serials::RoutingLists::AddRoutingList( >+ $subscriptionid, 'list 1'); >+ >+ C4::Serials::RoutingLists::ModRoutingList($routinglistid, undef, undef, >+ 'notes', $borrowernumber1, $borrowernumber2); >+ >+ my $csv = C4::Serials::RoutingLists::GetRoutingListAsCSV($routinglistid); >+ my $expected = >+ q|"Subscription title","Routing list",Surname,Firstname,Notes| . "\n" >+ . q|Title,"list 1",Doe,John,notes| . "\n" >+ . q|Title,"list 1",Smith,Jane,notes| . "\n"; >+ is($csv, $expected, 'csv is as expected'); >+}; >+ >+$dbh->rollback; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7957
:
9259
|
10973
|
13217
|
16614
|
21340
|
22726
|
35709
|
35801
|
35802
|
35803
|
35804
|
35842
|
35860
|
35872
|
35873
|
35874
|
35875
|
38425
|
41762
|
41763
|
41764
|
42427
|
42428
|
42429
|
47633
|
47634
|
47635
|
47659
|
47660
|
47661
|
47662
|
47663
|
47664
|
50226
|
50227
|
50228
|
50265
|
50266
|
50270
|
50273
| 97519 |
97520
|
97521
|
97522
|
97523
|
97524