From b2ea62777a98c5c1f7de58d15b98c61f73019882 Mon Sep 17 00:00:00 2001 From: Julian Maurice 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: - Make a search, in the results list you have a column 'Routing lists' (if not, consider setting RoutingSerials syspref). If the subscription doesn't have a routing list, you should have a 'New' link. Otherwise you have an 'Edit(X)' link, where X is the number of routing lists. - Choose a subscription which have no routing lists and click on 'New' - You are on the routing list creation page. Enter a title for the routing list and click on 'Save'. - 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. - Click on 'Save' to finish routing list modifications. - 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. - Click on 'Preview'. - You will be asked to choose a serial. Pick the one you want to print the routing list for and click on 'Continue'. - 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). - 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: - In the serials list, click on 'Print list'. - You will be asked to choose a routing list. Pick one and click on 'Continue'. - ... (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 --- C4/Items.pm | 2 +- C4/Serials.pm | 214 +++++----------- C4/Serials/RoutingLists.pm | 274 +++++++++++++++++++++ installer/data/mysql/kohastructure.sql | 46 ++-- installer/data/mysql/updatedatabase.pl | 67 +++++ .../prog/en/includes/serials-menu.inc | 4 +- .../prog/en/includes/serials-toolbar.inc | 7 + .../prog/en/modules/serials/member-search.tt | 26 +- .../en/modules/serials/routing-preview-slip.tt | 116 +++++++-- .../prog/en/modules/serials/routing-preview.tt | 57 ----- .../prog/en/modules/serials/routing.tt | 97 -------- .../prog/en/modules/serials/routinglist.tt | 194 +++++++++++++++ .../prog/en/modules/serials/routinglists.tt | 69 ++++++ .../prog/en/modules/serials/serials-collection.tt | 13 +- .../prog/en/modules/serials/serials-search.tt | 16 +- serials/member-search.pl | 5 +- 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 | 7 +- serials/serials-search.pl | 5 +- serials/subscription-detail.pl | 3 +- 25 files changed, 1172 insertions(+), 698 deletions(-) create mode 100644 C4/Serials/RoutingLists.pm 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 33143a5..b96a597 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -174,7 +174,7 @@ sub GetItem { ($data->{'serialseq'} , $data->{'publisheddate'}) = $ssth->fetchrow_array(); } #if we don't have an items.itype, use biblioitems.itemtype. - 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 49325cb..e46a549 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -51,13 +51,12 @@ BEGIN { &ReNewSubscription &GetLateOrMissingIssues &GetSerialInformation &AddItem2Serial &PrepareSerialsData &GetNextExpected &ModNextExpected + &GetSerial &GetSerialItemnumber &UpdateClaimdateIssues &GetSuppliersWithLateIssues &getsupplierbyserialid &GetDistributedTo &SetDistributedTo - &getroutinglist &delroutingmember &addroutingmember - &reorder_members - &check_routing &updateClaim &removeMissingIssue + &updateClaim &removeMissingIssue &CountIssues HasItems &GetSubscriptionsFromBorrower @@ -137,6 +136,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(); @@ -2077,161 +2130,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) 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/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 0d2700b..2a8fb4b 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2155,21 +2155,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/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 7e00df3..03e15ae 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -9732,6 +9732,73 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $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 DISTINCT subscriptionid + FROM tmp_subscriptionroutinglist + }; + my $sth = $dbh->prepare($query); + $sth->execute(); + my $results = $sth->fetchall_arrayref( {} ); + $query = qq{ + INSERT INTO subscriptionroutinglist (subscriptionid, title) + 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'); + 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"); + print "Upgrade to $DBversion done (New subscription routing list system).\n"; + SetVersion($DBversion); +} + + =head1 FUNCTIONS =head2 TableExists($table) 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 ) %] -
  • Edit routing list
  • +
  • Edit routing list
  • [% ELSE %] -
  • Create routing list
  • +
  • Create routing list
  • [% 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 d02781a..941c7ba 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/serials/member-search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/member-search.tt index 93357b4..d81b84b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/member-search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/member-search.tt @@ -2,14 +2,15 @@ Koha › Member Search › [% bookselname %] [% INCLUDE 'doc-head-close.inc' %]