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
15 # with Koha; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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 ($count,$reserves) = GetReservesFromBiblionumber
($biblio);
75 my $totalcount = $count;
76 foreach my $res (@
$reserves) {
77 if ($res->{'found'} eq 'W') {
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($biblio,$routing->{borrowernumber
});
87 my $reserve = $sth->fetchrow_hashref;
89 if($routing->{borrowernumber
} == $reserve->{borrowernumber
}){
90 ModReserve
($routing->{ranking
},$biblio,$routing->{borrowernumber
},$branch);
92 AddReserve
($branch,$routing->{borrowernumber
},$biblio,$const,\
@bibitems,$routing->{ranking
}, undef, undef, $notes,$title);
97 ($template, $loggedinuser, $cookie)
98 = get_template_and_user
({template_name
=> "serials/routing-preview-slip.tmpl",
101 authnotrequired
=> 0,
102 flagsrequired
=> {serials
=> '*'},
105 $template->param("libraryname"=>$branchname);
107 ($template, $loggedinuser, $cookie)
108 = get_template_and_user
({template_name
=> "serials/routing-preview.tmpl",
111 authnotrequired
=> 0,
112 flagsrequired
=> {serials
=> '*'},
118 for my $routing (@routinglist) {
119 my $member = GetMember
( borrowernumber
=> $routing->{borrowernumber
} );
120 $member->{name
} = "$member->{firstname} $member->{surname}";
121 push @
{$memberloop}, $member;
124 my $routingnotes = $serials[0]->{'routingnotes'};
125 $routingnotes =~ s/\n/\<br \/\
>/g
;
128 title
=> $subs->{'bibliotitle'},
130 issue_escaped
=> URI
::Escape
::uri_escape
($issue),
131 subscriptionid
=> $subscriptionid,
132 memberloop
=> $memberloop,
133 routingnotes
=> $routingnotes,
134 generalroutingnote
=> C4
::Context
->preference('RoutingListNote'),
135 hasRouting
=> check_routing
($subscriptionid),
138 output_html_with_http_headers
$query, $cookie, $template->output;