Bugzilla – Attachment 41762 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), 86.16 KB, created by
Julian Maurice
on 2015-08-21 09:06:45 UTC
(
hide
)
Description:
Bug 7957: Routing lists enhancements
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2015-08-21 09:06:45 UTC
Size:
86.16 KB
patch
obsolete
>From 0bf502aa9952e04e47b27c1e8d6de2513cf1adac 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> >--- > C4/Items.pm | 2 +- > C4/Serials.pm | 238 +++++------------- > C4/Serials/RoutingLists.pm | 274 +++++++++++++++++++++ > acqui/newordersubscription.pl | 3 +- > installer/data/mysql/atomicupdate/bug_7957.perl | 67 +++++ > installer/data/mysql/kohastructure.sql | 46 ++-- > .../prog/en/includes/serials-menu.inc | 4 +- > .../prog/en/includes/serials-toolbar.inc | 7 + > .../prog/en/modules/members/routing-lists.tt | 75 +++--- > .../en/modules/serials/routing-preview-slip.tt | 116 +++++++-- > .../prog/en/modules/serials/routing-preview.tt | 57 ----- > .../prog/en/modules/serials/routing.tt | 111 --------- > .../prog/en/modules/serials/routinglist.tt | 196 +++++++++++++++ > .../prog/en/modules/serials/routinglists.tt | 69 ++++++ > .../prog/en/modules/serials/serials-collection.tt | 13 +- > .../prog/en/modules/serials/serials-search.tt | 16 +- > members/routing-lists.pl | 16 +- > serials/reorder_members.pl | 38 --- > serials/routing-preview-slip.pl | 144 +++++++++++ > serials/routing-preview.pl | 145 ----------- > serials/routing.pl | 128 ---------- > serials/routinglist.pl | 114 +++++++++ > serials/routinglists.pl | 79 ++++++ > serials/serials-collection.pl | 9 +- > serials/serials-search.pl | 5 +- > serials/subscription-detail.pl | 3 +- > t/db_dependent/Serials.t | 6 +- > 27 files changed, 1208 insertions(+), 773 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 > >diff --git a/C4/Items.pm b/C4/Items.pm >index 0e639dc..b00698c 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -176,7 +176,7 @@ sub GetItem { > #if we don't have an items.itype, use biblioitems.itemtype. > # FIXME this should respect the itypes systempreference > # if (C4::Context->preference('item-level_itypes')) { >- if( ! $data->{'itype'} ) { >+ if( $data and ! $data->{'itype'} ) { > my $sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?"); > $sth->execute($data->{'biblionumber'}); > ($data->{'itype'}) = $sth->fetchrow_array; >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 3fcc4a3..cd3de09 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -73,13 +73,12 @@ BEGIN { > &ReNewSubscription &GetLateOrMissingIssues > &GetSerialInformation &AddItem2Serial > &PrepareSerialsData &GetNextExpected &ModNextExpected >+ &GetSerial &GetSerialItemnumber > > &UpdateClaimdateIssues > &GetSuppliersWithLateIssues &getsupplierbyserialid > &GetDistributedTo &SetDistributedTo >- &getroutinglist &delroutingmember &addroutingmember >- &reorder_members >- &check_routing &updateClaim >+ &updateClaim > &CountIssues > HasItems > &GetSubscriptionsFromBorrower >@@ -160,6 +159,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 GetSerialStatusFromSerialId > > $sth = GetSerialStatusFromSerialId(); >@@ -662,7 +715,7 @@ sub GetSerials { > $count = 5 unless ($count); > my @serials; > my $statuses = join( ',', ( ARRIVED, MISSING_STATUSES, NOT_ISSUED ) ); >- my $query = "SELECT serialid,serialseq, status, publisheddate, planneddate,notes, routingnotes >+ my $query = "SELECT serialid,serialseq, status, publisheddate, planneddate,notes > FROM serial > WHERE subscriptionid = ? AND status NOT IN ( $statuses ) > ORDER BY IF(publisheddate<>'0000-00-00',publisheddate,planneddate) DESC"; >@@ -682,7 +735,7 @@ sub GetSerials { > } > > # OK, now add the last 5 issues arrives/missing >- $query = "SELECT serialid,serialseq, status, planneddate, publisheddate,notes, routingnotes >+ $query = "SELECT serialid,serialseq, status, planneddate, publisheddate,notes > FROM serial > WHERE subscriptionid = ? > AND status IN ( $statuses ) >@@ -731,7 +784,7 @@ sub GetSerials2 { > > my $dbh = C4::Context->dbh; > my $query = qq| >- SELECT serialid,serialseq, status, planneddate, publisheddate,notes, routingnotes >+ SELECT serialid,serialseq, status, planneddate, publisheddate,notes > FROM serial > WHERE subscriptionid=$subscription AND status IN ($statuses_string) > ORDER BY publisheddate,serialid DESC >@@ -1990,161 +2043,6 @@ sub getsupplierbyserialid { > return $result; > } > >-=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 = ? 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) >@@ -2282,21 +2180,17 @@ sub GetSubscriptionsFromBorrower { > my ($borrowernumber) = @_; > my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare( >- "SELECT subscription.subscriptionid, biblio.title >- FROM subscription >+ "SELECT subscriptionroutinglist.*, biblio.title AS bibliotitle >+ FROM subscriptionroutinglist >+ JOIN subscriptionrouting ON (subscriptionroutinglist.routinglistid = subscriptionrouting.routinglistid) >+ JOIN subscription ON (subscriptionroutinglist.subscriptionid = subscription.subscriptionid) > JOIN biblio ON biblio.biblionumber = subscription.biblionumber >- JOIN subscriptionroutinglist USING (subscriptionid) >- WHERE subscriptionroutinglist.borrowernumber = ? ORDER BY title ASC >+ WHERE subscriptionrouting.borrowernumber = ? ORDER BY title ASC > " > ); > $sth->execute($borrowernumber); >- my @routinglist; >- my $count = 0; >- while ( my $line = $sth->fetchrow_hashref ) { >- $count++; >- push( @routinglist, $line ); >- } >- return ( $count, @routinglist ); >+ my $routinglists = $sth->fetchall_arrayref({}); >+ return $routinglists ? @$routinglists : (); > } > > >diff --git a/C4/Serials/RoutingLists.pm b/C4/Serials/RoutingLists.pm >new file mode 100644 >index 0000000..0c38313 >--- /dev/null >+++ b/C4/Serials/RoutingLists.pm >@@ -0,0 +1,274 @@ >+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 2 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, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use C4::Context; >+ >+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 >+ ); >+} >+ >+=head2 AddRoutingList >+ >+$routinglistid = &AddRoutingList($subscriptionid, $title); >+ >+this function create a new routing list for a subscription. >+ >+=cut >+ >+sub AddRoutingList { >+ my ($subscriptionid, $title) = @_; >+ >+ my $dbh = C4::Context->dbh(); >+ my $query = qq{ >+ INSERT INTO subscriptionroutinglist (subscriptionid, title) >+ VALUES (?, ?) >+ }; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($subscriptionid, $title); >+ >+ 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) = @_; >+ >+ 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) = @_; >+ >+ 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) = @_; >+ >+ 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) = @_; >+ >+ 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) = @_; >+ >+ require C4::Biblio; >+ require C4::Serials; >+ require C4::Members; >+ 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 = C4::Biblio::GetBiblio($subscription->{'biblionumber'}); >+ >+ my @headers = ("Subscription title", "Routing list", qw(Surname Firstname Notes)); >+ $csv->combine(@headers); >+ $output .= $csv->string() . "\n"; >+ >+ foreach (@{$routinglist->{borrowers}}) { >+ my $member = C4::Members::GetMemberDetails($_); >+ $csv->combine( >+ $biblio->{'title'}, >+ $routinglist->{'title'}, >+ $member->{'surname'}, >+ $member->{'firstname'}, >+ $routinglist->{'notes'}, >+ ); >+ $output .= $csv->string() . "\n"; >+ } >+ >+ return $output; >+} >+ >+1; >diff --git a/acqui/newordersubscription.pl b/acqui/newordersubscription.pl >index 7353dc9..d05a7ff 100755 >--- a/acqui/newordersubscription.pl >+++ b/acqui/newordersubscription.pl >@@ -25,6 +25,7 @@ use C4::Branch; > use C4::Context; > use C4::Output; > use C4::Serials; >+use C4::Serials::RoutingLists qw( GetRoutingListsCount ); > > use Koha::Acquisition::Bookseller; > >@@ -72,7 +73,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 0000000..2f8ca30 >--- /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 13b6a6a..581888b 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -2147,21 +2147,37 @@ CREATE TABLE `subscriptionhistory` ( > ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; > > -- >--- 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 >+-- Table structure for table subscriptionroutinglist >+-- >+ >+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; > > -- >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 b6c4b32..59c3d11 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc >@@ -4,9 +4,9 @@ > [% UNLESS closed %] > [% IF ( routing && CAN_user_serials_routing ) %] > [% IF ( hasRouting ) %] >- <li><a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscriptionid %]">Edit routing list</a></li> >+ <li><a href="/cgi-bin/koha/serials/routinglists.pl?subscriptionid=[% subscriptionid %]">Edit routing list</a></li> > [% ELSE %] >- <li><a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscriptionid %]&op=new">Create routing list</a></li> >+ <li><a href="/cgi-bin/koha/serials/routinglist.pl?subscriptionid=[% subscriptionid %]&op=new">Create routing list</a></li> > [% END %] > [% END %] > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc >index f1d6547..b545f1d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc >@@ -13,6 +13,13 @@ > window.location="subscription-detail.pl?subscriptionid=[% subscriptionid %]&op=reopen"; > } > } >+ function confirm_deletion() { >+ var is_confirmed = confirm(_("Are you sure you want to delete this subscription?")); >+ if (is_confirmed) { >+ window.location="subscription-detail.pl?subscriptionid=[% subscriptionid %]&op=del"; >+ } >+ } >+ > > $(document).ready(function() { > $("#deletesub").click(function(){ >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 87ed8f0..4edb3e9 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 >@@ -22,50 +22,47 @@ > <!-- Search Bar End --> > > <h1> >-[% IF ( countSubscrip ) %] >-[% countSubscrip %] Subscription routing list(s) >+[% IF ( routinglists.size > 0 ) %] >+ [% routinglists.size %] Subscription routing list(s) > [% ELSE %] >-0 Subscription routing lists >+ 0 Subscription routing lists > [% END %] > </h1> > > <div id="subscriptions"> >-[% IF ( subscripLoop ) %] >-<table id="subscriptiont"> >- <thead> >- <tr> >- <th>Subscription title</th> >- <th>Routing list</th> >- </tr> >- </thead> >- <tbody> >-[% FOREACH subscripLoop IN subscripLoop %] >-<tr> >- <td> >- <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscripLoop.subscriptionid %]"><strong> >- [% subscripLoop.title %] >- </strong> >- </a> >- </td> >- <td> >- <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscripLoop.subscriptionid %]"><strong> >- Edit routing list >- </strong> >- </a> >- <input type="hidden" name="biblionumber" value="[% biblionumber %]" /> >- <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" /> >- </td> >- </tr> >- [% END %] >- </tbody> >- </table> >- </form> >- [% ELSE %] >- <p>Patron does not belong to any subscription routing lists.</p> >- <input type="hidden" name="biblionumber" value="[% biblionumber %]" /> >- <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" /> >- [% END %] >- >+ [% IF ( routinglists.size > 0 ) %] >+ <table id="subscriptiont"> >+ <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.subscriptionid %]"> >+ <strong> >+ [% routinglist.bibliotitle %] >+ </strong> >+ </a> >+ </td> >+ <td>[% routinglist.title %]</td> >+ <td> >+ <a href="/cgi-bin/koha/serials/routinglist.pl?routinglistid=[% routinglist.routinglistid %]"><strong> >+ Edit routing list >+ </strong> >+ </a> >+ </td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ [% ELSE %] >+ <p>Patron does not belong to any subscription routing lists.</p> >+ [% END %] > </div> > > >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 5a23158..2a0aa2d 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 >@@ -14,34 +14,100 @@ > <div id="custom-doc" class="yui-t7"> > <div id="bd"> > >-<table> >- <tr> >- <td colspan="2"><h3>[% libraryname %]</h3></td> >- </tr> >- <tr> >- <td colspan="2"><b>Title:</b> [% title |html %]<br />[% issue %]</td> >- </tr> >- <tr> >- <td><b>Name</b></td> >- <td><b>Date due</b></td> >- </tr> >- [% FOREACH memberloo IN memberloop %] >- <tr> >- <td>[% memberloo.name %]</td> >- <td> </td> >- </tr> >+[% IF (missing_parameter_routinglistid or missing_parameter_serialid) %] >+ <h1>Routing list preview for <em>[% title %]</em></h1> >+ >+ <form action="" method="get"> >+ [% IF (missing_parameter_routinglistid) %] >+ <input type="hidden" name="serialid" value="[% serialid %]" /> >+ <label for="routinglist">Please select a routing list</label> >+ <select id="routinglist" name="routinglistid"> >+ [% FOREACH routinglist IN routinglists %] >+ <option value="[% routinglist.routinglistid %]"> >+ [% routinglist.title %] >+ </option> >+ [% END %] >+ </select> >+ [% ELSE %] >+ <input type="hidden" name="routinglistid" value="[% routinglistid %]" /> >+ <label for="serial">Please select a serial</label> >+ <select id="serial" name="serialid"> >+ [% FOREACH serial IN serials %] >+ <option value="[% serial.serialid %]"> >+ [% serial.serialseq %] ([% serial.planneddate %]) >+ </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 (libraryname) %] >+ <tr> >+ <td colspan="2"><h3>[% libraryname %]</h3></td> >+ </tr> >+ [% END %] >+ <tr> >+ <td colspan="2"> >+ <b>Title:</b> [% title |html %]<br /> >+ [% serial.serialseq %] ([% serial.planneddate %]) >+ </td> >+ </tr> >+ <tr> >+ <td colspan="2"> >+ <b>Routing list:</b> [% routinglisttitle %] >+ </td> >+ </tr> >+ <tr> >+ <td><b>Name</b></td> >+ <td><b>Date due</b></td> >+ </tr> >+ [% FOREACH member IN memberloop %] >+ <tr> >+ <td>[% member.surname %], [% member.firstname %]</td> >+ <td> </td> >+ </tr> >+ [% END %] >+ </table> > >-<div id="routingnotes"> >- <p id="generalroutingnote">[% generalroutingnote %]</p> >- <p id="routingnote">[% routingnotes %]</p> >-</div> >+ <div id="routingnotes"> >+ <p id="generalroutingnote">[% generalroutingnote %]</p> >+ <p id="routingnote">[% routingnotes %]</p> >+ </div> > >- <div id="slip-block-links" class="noprint"> >- <a class="button" href="javascript:window.print();self.close()">Print</a> <a class="button" href="javascript:self.close()">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 %]" /> >+ <input type="hidden" name="serialid" value="[% serialid %]" /> >+ <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="slip-block-links" class="noprint"> >+ <a class="button" href="javascript:window.print();self.close()">Print</a> >+ <a class="button" href="javascript:self.close()">Close</a> >+ </div> >+ [% END %] >+[% END %] > >- </div> >+ </div> > > [% INCLUDE 'intranet-bottom.inc' %] >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 6892e1c..0000000 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing-preview.tt >+++ /dev/null >@@ -1,57 +0,0 @@ >-[% INCLUDE 'doc-head-open.inc' %] >-<title>Koha › Serials › Preview routing list</title> >-[% INCLUDE 'doc-head-close.inc' %] >-<script type="text/javascript"> >-<!-- >- >-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> >-</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 %]"><i>[% title |html %]</i></a> › Preview routing list</div> >- >-<div id="doc3" class="yui-t2"> >- >- <div id="bd"> >- <div id="yui-main"> >- <div class="yui-b"> >- >-<h2>Preview routing list for <i>[% title |html %]</i></h2> >- >-<form method="post" action="routing-preview.pl"> >-<input type="hidden" name="subscriptionid" value="[% subscriptionid %]" /> >-<fieldset class="rows"> >- <ol> >- <li><span class="label">Issue:</span>[% issue %]</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 %], [% memberloo.firstname %]</td></tr> >-[% END %] >- </table></li> >- <li><span class="label">Notes:</span>[% routingnotes %]</li> >- </ol> >-</fieldset> >- >-<fieldset class="action"> >-<input type="submit" name="ok" class="button" value="Save and preview routing slip" onclick="print_slip([% subscriptionid %],'[% issue_escaped %]'); return false" /> >-<input type="submit" name="edit" class="button" value="Edit" /> >-<input type="submit" name="delete" class="button" value="Delete" /></fieldset> >-</form> >- >-</div> >-</div> >- >-<div class="yui-b"> >-[% INCLUDE 'serials-menu.inc' %] >-</div> >-</div> >-[% 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 6fccab8..0000000 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing.tt >+++ /dev/null >@@ -1,111 +0,0 @@ >-[% 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' %] >-<script type="text/javascript"> >-<!-- >- >-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 %]+"&borrowernumber="+borrowernumber+"&op=add"; >- window.location.href = myurl; >- } >- >-//--> >-</script> >-</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> › <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscriptionid %]"><i>[% title |html %]</i></a> › [% IF ( op ) %]Create Routing List[% ELSE %]Edit routing list[% END %]</div> >- >-<div id="doc3" class="yui-t2"> >- >- <div id="bd"> >- <div id="yui-main"> >- <div class="yui-b"> >- >- >-[% 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 %]" /> >-<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 %] ([% date.publisheddate %])" selected="selected">[% date.serialseq %] ([% date.publisheddate %])</option>[% ELSE %]<option value="[% date.serialseq %] ([% date.publisheddate %])">[% date.serialseq %] ([% date.publisheddate %])</option>[% END %] >-[% END %] >-</select> [% issue %]</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 %]</td> >- <td> >- <select name="itemrank" onchange="reorder_item([%- subscriptionid -%], [%- member.routingid -%], this.value)"> >- [% rankings = [1 .. m_loop.size] %] >- [% FOREACH r IN rankings %] >- [% IF r == member.ranking %] >- <option selected="selected" value="[% r %]">[% r %]</option> >- [% ELSE %] >- <option value="[% r %]">[% r %]</option> >- [% END %] >- [% END %] >- </select> >- </td> >- <td><a href="/cgi-bin/koha/serials/routing.pl?routingid=[% member.routingid %]&subscriptionid=[% subscriptionid %]&op=delete">Delete</a></td> >- </tr> >- [% END %] >- </table> >- [% END %] >- >- <p style="margin-left:10em;"> >- <input type="button" onclick="userPopup()" value="Add recipients" /> >- [% IF memberloop %] >- <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscriptionid %]&op=delete" class="button">Delete all</a> >- [% END %] >- </p> >-</li> >- >- <li><label for="notes">Notes:</label><textarea name="notes" id="notes" rows="3" cols="50">[% routingnotes %]</textarea></li> >- </ol> >- >-</fieldset> >-<fieldset class="action"><input type="submit" name="submit" value="Save" /></fieldset> >-</form> >- >- >-</div> >-</div> >- >-<div class="yui-b"> >-[% INCLUDE 'serials-menu.inc' %] >-</div> >-</div> >-[% 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 0000000..fb1d377 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routinglist.tt >@@ -0,0 +1,196 @@ >+[% 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 id="doc3" class="yui-t2"> >+ >+<div id="bd"> >+ <div id="yui-main"> >+ <div class="yui-b"> >+ [% 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 is 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 %]" /> >+ <label for="notes">Notes: </label><br /> >+ <textarea id="notes" name="notes">[% notes %]</textarea><br /> >+ <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 --> >+ </div> >+ </div> >+ <div class="yui-b"> >+ [% INCLUDE 'serials-menu.inc' %] >+ </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 0000000..11ab8d8 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routinglists.tt >@@ -0,0 +1,69 @@ >+[% 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 id="doc3" class="yui-t2"> >+ >+<div id="bd"> >+ <div id="yui-main"> >+ <div class="yui-b"> >+ [% 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 is no routing lists for this subscription.</p> >+ [% END %] >+ >+ </div> >+ </div> >+ <div class="yui-b"> >+ [% INCLUDE 'serials-menu.inc' %] >+ </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 4418baf..551a24c 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 >@@ -14,10 +14,11 @@ function generateReceive(subscriptionid) { > document.location = 'serials-collection.pl?op=gennext&subscriptionid='+subscriptionid+'&nbissues='+nbissues; > } > } >-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'); > } >+ > function addsubscriptionid() > { > var tab=new Array(); >@@ -134,10 +135,10 @@ $(document).ready(function() { > [% IF ( routing && CAN_user_serials_routing ) %] > <td> > [% UNLESS subscription.closed %] >- [% IF ( subscription.hasRouting ) %] >- <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid %]">Edit routing list</a> >+ [% IF (subscription.routinglistscount) %] >+ <a href="/cgi-bin/koha/serials/routinglists.pl?subscriptionid=[% subscription.subscriptionid %]">Edit routing lists</a> ([% subscription.routinglistscount %]) > [% ELSE %] >- <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid %]&op=new">Create routing list</a> >+ <a href="/cgi-bin/koha/serials/routinglist.pl?op=new&subscriptionid=[% subscription.subscriptionid %]">New routing list</a> > [% END %] > [% END %] > </td> >@@ -294,7 +295,7 @@ $(document).ready(function() { > </td> > [% IF ( routing ) %] > <td> >- <a href="" onclick="print_slip([% serial.subscriptionid |html %], '[% serial.serialseq |html %] ([% serial.publisheddate | $KohaDates %])'); return false" >Print list</a> >+ <a style="cursor:pointer" onclick="print_slip([% serial.serialid %]);">Print list</a> > </td> > [% END %] > </tr> >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 3b97849..005cdbe 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 >@@ -199,15 +199,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 %]"><i class="icon-pencil"></i> Edit routing list ([% subscription.routingedit %])</a> >- </li> >- [% ELSE %] >- <li> >- <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid %]&op=new"> <i class="icon-plus"></i> New routing list</a> >- </li> >- [% END %] >+ <li> >+ [% IF ( subscription.routinglistscount ) %] >+ <a href="/cgi-bin/koha/serials/routinglists.pl?subscriptionid=[% subscription.subscriptionid %]"><i class="icon-pencil"></i> Edit routing list ([% subscription.routinglistscount %])</a> >+ [% ELSE %] >+ <a href="/cgi-bin/koha/serials/routinglist.pl?subscriptionid=[% subscription.subscriptionid %]&op=new"> <i class="icon-plus"></i> New routing list</a> >+ [% END %] >+ </li> > [% END %] > [% END # IF ( routing && CAN_user_serials_routing ) %] > >diff --git a/members/routing-lists.pl b/members/routing-lists.pl >index b8187b3..503969e 100755 >--- a/members/routing-lists.pl >+++ b/members/routing-lists.pl >@@ -76,22 +76,10 @@ if ($borrowernumber) { > > if ($borrowernumber) { > # new op dev >- my $count; >- my @borrowerSubscriptions; >- ($count, @borrowerSubscriptions) = GetSubscriptionsFromBorrower($borrowernumber ); >- my @subscripLoop; >- >- foreach my $num_res (@borrowerSubscriptions) { >- my %getSubscrip; >- $getSubscrip{subscriptionid} = $num_res->{'subscriptionid'}; >- $getSubscrip{title} = $num_res->{'title'}; >- $getSubscrip{borrowernumber} = $num_res->{'borrowernumber'}; >- push( @subscripLoop, \%getSubscrip ); >- } >+ my @routinglists = GetSubscriptionsFromBorrower($borrowernumber ); > > $template->param( >- countSubscrip => scalar @subscripLoop, >- subscripLoop => \@subscripLoop, >+ routinglists => \@routinglists, > routinglistview => 1 > ); > >diff --git a/serials/reorder_members.pl b/serials/reorder_members.pl >deleted file mode 100755 >index 3e0b86a..0000000 >--- a/serials/reorder_members.pl >+++ /dev/null >@@ -1,38 +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 strict; >-use warnings; >-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 0000000..c7c6bf9 >--- /dev/null >+++ b/serials/routing-preview-slip.pl >@@ -0,0 +1,144 @@ >+#!/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 2 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, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+=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::Branch; >+use C4::Members; >+use C4::Serials; >+use C4::Serials::RoutingLists qw/GetRoutingList GetRoutingLists/; >+ >+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 = GetBiblio($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 = GetBiblio($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 = GetBiblio($subscription->{biblionumber}); >+my $branch = GetBranchDetail($subscription->{branchcode}); >+my @memberloop; >+foreach (@{$routinglist->{borrowers}}) { >+ my $member = GetMemberDetails($_); >+ push @memberloop, { >+ surname => $member->{surname}, >+ firstname => $member->{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 = C4::Items::GetItem($itemnumber); >+ if ($item) { >+ my $rank = 1; >+ foreach my $borrowernumber ( @{$routinglist->{borrowers}} ) { >+ my $reserve = C4::Reserves::GetReserveInfo($borrowernumber, >+ $item->{biblionumber}); >+ if($reserve) { >+ C4::Reserves::ModReserve($rank, $item->{biblionumber}, >+ $borrowernumber, $item->{holdingbranch}, $itemnumber); >+ } else { >+ my @bibitems = GetBiblioItemByBiblioNumber($item->{biblionumber}); >+ C4::Reserves::AddReserve($item->{holdingbranch}, $borrowernumber, >+ $item->{biblionumber}, 'a', \@bibitems, $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, >+ libraryname => $branch->{branchname}, >+ 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 1fd5814..0000000 >--- a/serials/routing-preview.pl >+++ /dev/null >@@ -1,145 +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 heirarchy >-# of reserves for the serial >-use strict; >-use warnings; >-use CGI qw ( -utf8 ); >-use C4::Koha; >-use C4::Auth; >-use C4::Dates; >-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 C4::Branch; >- >-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); >- >-if($ok){ >- # get biblio information.... >- my $biblio = $subs->{'biblionumber'}; >- my ($count2,@bibitems) = GetBiblioItemByBiblioNumber($biblio); >- my @itemresults = GetItemsInfo( $subs->{biblionumber} ); >- my $branch = $itemresults[0]->{'holdingbranch'}; >- my $branchname = GetBranchName($branch); >- >- if (C4::Context->preference('RoutingListAddReserves')){ >- # get existing reserves ..... >- my $reserves = GetReservesFromBiblionumber({ biblionumber => $biblio }); >- my $count = scalar( @$reserves ); >- my $totalcount = $count; >- foreach my $res (@$reserves) { >- if ($res->{'found'} eq 'W') { >- $count--; >- } >- } >- my $const = 'o'; >- 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($biblio,$routing->{borrowernumber}); >- my $reserve = $sth->fetchrow_hashref; >- >- if($routing->{borrowernumber} == $reserve->{borrowernumber}){ >- ModReserve({ >- rank => $routing->{ranking}, >- biblionumber => $biblio, >- borrowernumber => $routing->{borrowernumber}, >- branchcode => $branch >- }); >- } else { >- AddReserve($branch,$routing->{borrowernumber},$biblio,$const,\@bibitems,$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, >- }); >- $template->param("libraryname"=>$branchname); >-} else { >- ($template, $loggedinuser, $cookie) >-= get_template_and_user({template_name => "serials/routing-preview.tt", >- query => $query, >- type => "intranet", >- authnotrequired => 0, >- flagsrequired => {serials => '*'}, >- debug => 1, >- }); >-} >- >-my $memberloop = []; >-for my $routing (@routinglist) { >- my $member = GetMember( borrowernumber => $routing->{borrowernumber} ); >- $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, >- generalroutingnote => C4::Context->preference('RoutingListNote'), >- 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 8f9cb6b..0000000 >--- a/serials/routing.pl >+++ /dev/null >@@ -1,128 +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 strict; >-use warnings; >-use CGI qw ( -utf8 ); >-use C4::Koha; >-use C4::Auth; >-use C4::Dates; >-use C4::Output; >-use C4::Acquisition; >-use C4::Output; >-use C4::Context; >- >-use C4::Members; >-use C4::Serials; >- >-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; >- >-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 $subs = GetSubscription($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 ($template, $loggedinuser, $cookie) >-= get_template_and_user({template_name => 'serials/routing.tt', >- query => $query, >- type => 'intranet', >- authnotrequired => 0, >- flagsrequired => {serials => 'routing'}, >- debug => 1, >- }); >- >-my $member_loop = []; >-for my $routing ( @routinglist ) { >- my $member=GetMember('borrowernumber' => $routing->{borrowernumber}); >- $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 0000000..f8455d3 >--- /dev/null >+++ b/serials/routinglist.pl >@@ -0,0 +1,114 @@ >+#!/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 2 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, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+=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/; >+ >+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); >+} else { >+ $routinglistid = $input->param('routinglistid'); >+} >+ >+if($op && $op eq 'mod') { >+ my $borrowersids = $input->param('borrowersids'); >+ my $notes = $input->param('notes'); >+ my @borrowernumbers = split /:/, $borrowersids; >+ ModRoutingList($routinglistid, undef, undef, $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 $member = GetMemberDetails($borrowernumber); >+ push @borrowers, { >+ borrowernumber => $borrowernumber, >+ surname => $member->{surname}, >+ firstname => $member->{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 0000000..cb646c6 >--- /dev/null >+++ b/serials/routinglists.pl >@@ -0,0 +1,79 @@ >+#!/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 2 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, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+=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/; >+ >+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 = GetBiblio($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 900064a..fa73291 100755 >--- a/serials/serials-collection.pl >+++ b/serials/serials-collection.pl >@@ -26,6 +26,7 @@ use C4::Auth; > use C4::Koha; > use C4::Dates qw/format_date/; > use C4::Serials; >+use C4::Serials::RoutingLists qw/GetRoutingListsCount/; > use C4::Letters; > use C4::Output; > use C4::Context; >@@ -128,7 +129,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); >@@ -147,8 +148,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); >+ $subscriptionidlist.=$subscription->{'subscriptionid'}."," ; >+ $biblionumber = $subscription->{'bibnum'} unless ($biblionumber); >+ $subscription->{routinglistscount} >+ = GetRoutingListsCount($subscription->{subscriptionid}); > } > > # warn "title : $title yearmax : $yearmax nombre d'elements dans le tableau :".scalar(@$subscriptions); >diff --git a/serials/serials-search.pl b/serials/serials-search.pl >index 27ccd42..160f884 100755 >--- a/serials/serials-search.pl >+++ b/serials/serials-search.pl >@@ -35,6 +35,7 @@ use C4::Branch; > use C4::Context; > use C4::Output; > use C4::Serials; >+use C4::Serials::RoutingLists qw/GetRoutingListsCount/; > > use Koha::DateUtils; > >@@ -97,7 +98,9 @@ if ($searched){ > # 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}); >+ $subscription->{branchname} = GetBranchName ( $subscription->{branchcode} ); > } > } > >diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl >index 1453306..846ff8a 100755 >--- a/serials/subscription-detail.pl >+++ b/serials/subscription-detail.pl >@@ -23,6 +23,7 @@ use C4::Budgets; > use C4::Koha; > use C4::Dates qw/format_date/; > use C4::Serials; >+use C4::Serials::RoutingLists qw/GetRoutingListsCount/; > use C4::Output; > use C4::Context; > use C4::Search qw/enabled_staff_search_views/; >@@ -92,7 +93,7 @@ if ($op eq 'del') { > exit; > } > } >-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 4086700..4b252ea 100644 >--- a/t/db_dependent/Serials.t >+++ b/t/db_dependent/Serials.t >@@ -15,7 +15,7 @@ use C4::Bookseller; > use C4::Biblio; > use C4::Budgets; > use Koha::DateUtils; >-use Test::More tests => 46; >+use Test::More tests => 44; > > BEGIN { > use_ok('C4::Serials'); >@@ -186,10 +186,6 @@ is(C4::Serials::updateClaim(),undef, 'test updating claim'); > > is(C4::Serials::getsupplierbyserialid(),undef, 'test getting supplier idea'); > >-is(C4::Serials::check_routing(), undef, 'test checking route'); >- >-is(C4::Serials::addroutingmember(),undef, 'test adding route member'); >- > > # Unit tests for statuses management (Bug 11689) > $subscriptionid = NewSubscription( >-- >1.9.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