3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
18 # Routing Preview.pl script used to view a routing list after creation
19 # lets one print out routing slip and create (in this instance) the heirarchy
20 # of reserves for the serial
41 my $subscriptionid = $query->param('subscriptionid');
42 my $issue = $query->param('issue');
44 my $ok = $query->param('ok');
45 my $edit = $query->param('edit');
46 my $delete = $query->param('delete');
47 my $dbh = C4
::Context
->dbh;
50 delroutingmember
($routingid,$subscriptionid);
51 my $sth = $dbh->prepare("UPDATE serial SET routingnotes = NULL WHERE subscriptionid = ?");
52 $sth->execute($subscriptionid);
53 print $query->redirect("routing.pl?subscriptionid=$subscriptionid&op=new");
57 print $query->redirect("routing.pl?subscriptionid=$subscriptionid");
60 my @routinglist = getroutinglist
($subscriptionid);
61 my $subs = GetSubscription
($subscriptionid);
62 my ($tmp ,@serials) = GetSerials
($subscriptionid);
63 my ($template, $loggedinuser, $cookie);
66 # get biblio information....
67 my $biblionumber = $subs->{'biblionumber'};
68 my ($count2,@bibitems) = GetBiblioItemByBiblioNumber
($biblionumber);
69 my @itemresults = GetItemsInfo
( $subs->{biblionumber
} );
70 my $branch = $itemresults[0]->{'holdingbranch'};
71 my $branchname = Koha
::Libraries
->find($branch)->branchname;
73 if (C4
::Context
->preference('RoutingListAddReserves')){
74 # get existing reserves .....
76 my $biblio = Koha
::Biblios
->find( $biblionumber );
77 my $holds = $biblio->current_holds;
78 my $count = $holds->count;
79 while ( my $hold = $holds->next ) {
80 $count-- if $hold->is_waiting;
83 my $title = $subs->{'bibliotitle'};
84 for my $routing ( @routinglist ) {
85 my $sth = $dbh->prepare('SELECT * FROM reserves WHERE biblionumber = ? AND borrowernumber = ? LIMIT 1');
86 $sth->execute($biblionumber,$routing->{borrowernumber
});
87 my $reserve = $sth->fetchrow_hashref;
89 if($routing->{borrowernumber
} == $reserve->{borrowernumber
}){
91 rank
=> $routing->{ranking
},
92 biblionumber
=> $biblionumber,
93 borrowernumber
=> $routing->{borrowernumber
},
97 AddReserve
($branch,$routing->{borrowernumber
},$biblionumber,\
@bibitems,$routing->{ranking
}, undef, undef, $notes,$title);
102 ($template, $loggedinuser, $cookie)
103 = get_template_and_user
({template_name
=> "serials/routing-preview-slip.tt",
106 authnotrequired
=> 0,
107 flagsrequired
=> {serials
=> '*'},
110 $template->param("libraryname"=>$branchname);
112 ($template, $loggedinuser, $cookie)
113 = get_template_and_user
({template_name
=> "serials/routing-preview.tt",
116 authnotrequired
=> 0,
117 flagsrequired
=> {serials
=> '*'},
123 for my $routing (@routinglist) {
124 my $member = GetMember
( borrowernumber
=> $routing->{borrowernumber
} );
125 $member->{name
} = "$member->{firstname} $member->{surname}";
126 push @
{$memberloop}, $member;
129 my $routingnotes = $serials[0]->{'routingnotes'};
130 $routingnotes =~ s/\n/\<br \/\
>/g
;
133 title
=> $subs->{'bibliotitle'},
135 issue_escaped
=> URI
::Escape
::uri_escape_utf8
($issue),
136 subscriptionid
=> $subscriptionid,
137 memberloop
=> $memberloop,
138 routingnotes
=> $routingnotes,
139 generalroutingnote
=> C4
::Context
->preference('RoutingListNote'),
140 hasRouting
=> check_routing
($subscriptionid),
141 (uc(C4
::Context
->preference("marcflavour"))) => 1
144 output_html_with_http_headers
$query, $cookie, $template->output;