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
40 my $subscriptionid = $query->param('subscriptionid');
41 my $issue = $query->param('issue');
43 my $ok = $query->param('ok');
44 my $edit = $query->param('edit');
45 my $delete = $query->param('delete');
46 my $dbh = C4
::Context
->dbh;
49 delroutingmember
($routingid,$subscriptionid);
50 my $sth = $dbh->prepare("UPDATE serial SET routingnotes = NULL WHERE subscriptionid = ?");
51 $sth->execute($subscriptionid);
52 print $query->redirect("routing.pl?subscriptionid=$subscriptionid&op=new");
56 print $query->redirect("routing.pl?subscriptionid=$subscriptionid");
59 my @routinglist = getroutinglist
($subscriptionid);
60 my $subs = GetSubscription
($subscriptionid);
61 my ($tmp ,@serials) = GetSerials
($subscriptionid);
62 my ($template, $loggedinuser, $cookie);
65 # get biblio information....
66 my $biblio = $subs->{'biblionumber'};
67 my ($count2,@bibitems) = GetBiblioItemByBiblioNumber
($biblio);
68 my @itemresults = GetItemsInfo
( $subs->{biblionumber
} );
69 my $branch = $itemresults[0]->{'holdingbranch'};
70 my $branchname = GetBranchName
($branch);
72 if (C4
::Context
->preference('RoutingListAddReserves')){
73 # get existing reserves .....
74 my $reserves = GetReservesFromBiblionumber
({ biblionumber
=> $biblio });
75 my $count = scalar( @
$reserves );
76 my $totalcount = $count;
77 foreach my $res (@
$reserves) {
78 if ($res->{'found'} eq 'W') {
84 my $title = $subs->{'bibliotitle'};
85 for my $routing ( @routinglist ) {
86 my $sth = $dbh->prepare('SELECT * FROM reserves WHERE biblionumber = ? AND borrowernumber = ? LIMIT 1');
87 $sth->execute($biblio,$routing->{borrowernumber
});
88 my $reserve = $sth->fetchrow_hashref;
90 if($routing->{borrowernumber
} == $reserve->{borrowernumber
}){
92 rank
=> $routing->{ranking
},
93 biblionumber
=> $biblio,
94 borrowernumber
=> $routing->{borrowernumber
},
98 AddReserve
($branch,$routing->{borrowernumber
},$biblio,$const,\
@bibitems,$routing->{ranking
}, undef, undef, $notes,$title);
103 ($template, $loggedinuser, $cookie)
104 = get_template_and_user
({template_name
=> "serials/routing-preview-slip.tt",
107 authnotrequired
=> 0,
108 flagsrequired
=> {serials
=> '*'},
111 $template->param("libraryname"=>$branchname);
113 ($template, $loggedinuser, $cookie)
114 = get_template_and_user
({template_name
=> "serials/routing-preview.tt",
117 authnotrequired
=> 0,
118 flagsrequired
=> {serials
=> '*'},
124 for my $routing (@routinglist) {
125 my $member = GetMember
( borrowernumber
=> $routing->{borrowernumber
} );
126 $member->{name
} = "$member->{firstname} $member->{surname}";
127 push @
{$memberloop}, $member;
130 my $routingnotes = $serials[0]->{'routingnotes'};
131 $routingnotes =~ s/\n/\<br \/\
>/g
;
134 title
=> $subs->{'bibliotitle'},
136 issue_escaped
=> URI
::Escape
::uri_escape_utf8
($issue),
137 subscriptionid
=> $subscriptionid,
138 memberloop
=> $memberloop,
139 routingnotes
=> $routingnotes,
140 generalroutingnote
=> C4
::Context
->preference('RoutingListNote'),
141 hasRouting
=> check_routing
($subscriptionid),
142 (uc(C4
::Context
->preference("marcflavour"))) => 1
145 output_html_with_http_headers
$query, $cookie, $template->output;