3 # This file is part of Koha
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA 02111-1307 USA
21 script used to create a routing list for a serial subscription
22 In this instance it is in fact a setting up of a list of reserves for the item
23 where the hierarchical order can be changed on the fly and a routing list can be
45 my $subscriptionid = $query->param('subscriptionid');
46 my $serialseq = $query->param('serialseq');
47 my $routingid = $query->param('routingid');
48 my $borrowernumber = $query->param('borrowernumber');
49 my $notes = $query->param('notes');
50 my $op = $query->param('op') || q{};
51 my $date_selected = $query->param('date_selected');
52 my $dbh = C4::Context->dbh;
55 delroutingmember($routingid,$subscriptionid);
59 addroutingmember($borrowernumber,$subscriptionid);
62 my $sth = $dbh->prepare("UPDATE serial SET routingnotes = ? WHERE subscriptionid = ?");
63 $sth->execute($notes,$subscriptionid);
64 my $urldate = URI::Escape::uri_escape($date_selected);
65 print $query->redirect("routing-preview.pl?subscriptionid=$subscriptionid&issue=$urldate");
68 my ($routing, @routinglist) = getroutinglist($subscriptionid);
69 my $subs = GetSubscription($subscriptionid);
70 my ($count,@serials) = GetSerials($subscriptionid);
71 my ($serialdates) = GetLatestSerials($subscriptionid,$count);
75 foreach my $dateseq (@$serialdates) {
76 $dates[$i]->{'planneddate'} = $dateseq->{'planneddate'};
77 $dates[$i]->{'serialseq'} = $dateseq->{'serialseq'};
78 $dates[$i]->{'serialid'} = $dateseq->{'serialid'};
79 if($date_selected eq $dateseq->{'serialid'}){
80 $dates[$i]->{'selected'} = ' selected';
82 $dates[$i]->{'selected'} = '';
87 my ($template, $loggedinuser, $cookie)
88 = get_template_and_user({template_name => "serials/routing.tmpl",
92 flagsrequired => {serials => 1},
97 # for(my $i = 0;$i<@serials; $i++){
98 # if($serials[$i]->{'serialseq'} eq $serialseq){
99 # $date = $serials[$i]->{'planneddate'}
103 # $serialseq = $serials[0]->{'serialseq'};
104 # $date = $serials[0]->{'planneddate'};
107 # my $issue = "$serialseq ($date)";
111 for(my $i=0;$i<$routing;$i++){
112 $data=GetMember('borrowernumber' => $routinglist[$i]->{'borrowernumber'});
113 $data->{'location'}=$data->{'branchcode'};
114 if ($data->{firstname} ) {
115 $data->{name} = $data->{firstname} . q| |;
120 if ($data->{surname} ) {
121 $data->{name} .= $data->{surname};
123 $data->{'routingid'}=$routinglist[$i]->{'routingid'};
124 $data->{'subscriptionid'}=$subscriptionid;
125 if (! $routinglist[$i]->{routingid} ) {
126 $routinglist[$i]->{routingid} = q||;
128 my $rankingbox = '<select name="itemrank" onchange="reorder_item('
129 . $subscriptionid . ',' .$routinglist[$i]->{'routingid'} . ',this.options[this.selectedIndex].value)">';
130 for(my $j=1; $j <= $routing; $j++) {
131 $rankingbox .= "<option ";
132 if($routinglist[$i]->{ranking} && $routinglist[$i]->{ranking} == $j){
133 $rankingbox .= " selected=\"selected\"";
135 $rankingbox .= " value=\"$j\">$j</option>";
137 $rankingbox .= "</select>";
138 $data->{'routingbox'} = $rankingbox;
140 push(@results, $data);
143 # for adding routing list
148 # for modify routing list default
153 title => $subs->{'bibliotitle'},
154 subscriptionid => $subscriptionid,
155 memberloop => \@results,
158 routingnotes => $serials[0]->{'routingnotes'},
161 output_html_with_http_headers $query, $cookie, $template->output;