3 # Routing Preview.pl script used to view a routing list after creation
4 # lets one print out routing slip and create (in this instance) the heirarchy
5 # of reserves for the serial
22 my $subscriptionid = $query->param('subscriptionid');
23 my $issue = $query->param('issue');
25 my $ok = $query->param('ok');
26 my $edit = $query->param('edit');
27 my $delete = $query->param('delete');
28 my $dbh = C4::Context->dbh;
31 delroutingmember($routingid,$subscriptionid);
32 my $sth = $dbh->prepare("UPDATE serial SET routingnotes = NULL WHERE subscriptionid = ?");
33 $sth->execute($subscriptionid);
34 print $query->redirect("routing.pl?subscriptionid=$subscriptionid&op=new");
38 print $query->redirect("routing.pl?subscriptionid=$subscriptionid");
41 my ($routing, @routinglist) = getroutinglist($subscriptionid);
42 my $subs = GetSubscription($subscriptionid);
43 my ($count,@serials) = GetSerials($subscriptionid);
44 my ($template, $loggedinuser, $cookie);
47 # get biblio information....
48 my $biblio = $subs->{'biblionumber'};
50 # get existing reserves .....
51 my ($count,$reserves) = GetReservesFromBiblionumber($biblio);
52 my $totalcount = $count;
53 foreach my $res (@$reserves) {
54 if ($res->{'found'} eq 'W') {
58 my ($count2,@bibitems) = GetBiblioItemByBiblioNumber($biblio);
59 my @itemresults = GetItemsInfo($subs->{'biblionumber'}, 'intra');
60 my $branch = $itemresults[0]->{'holdingbranch'};
63 my $title = $subs->{'bibliotitle'};
64 for(my $i=0;$i<$routing;$i++){
65 my $sth = $dbh->prepare("SELECT * FROM reserves WHERE biblionumber = ? AND borrowernumber = ?
66 AND cancellationdate is NULL AND (found <> 'F' or found is NULL)");
67 $sth->execute($biblio,$routinglist[$i]->{'borrowernumber'});
68 my $data = $sth->fetchrow_hashref;
70 # warn "$routinglist[$i]->{'borrowernumber'} is the same as $data->{'borrowernumber'}";
71 if($routinglist[$i]->{'borrowernumber'} == $data->{'borrowernumber'}){
72 ModReserve($routinglist[$i]->{'ranking'},$biblio,$routinglist[$i]->{'borrowernumber'},$branch);
74 AddReserve($branch,$routinglist[$i]->{'borrowernumber'},$biblio,$const,\@bibitems,$routinglist[$i]->{'ranking'},$notes,$title);
79 ($template, $loggedinuser, $cookie)
80 = get_template_and_user({template_name => "serials/routing-preview-slip.tmpl",
84 flagsrequired => {serials => 1},
87 $template->param("libraryname"=>C4::Context->preference("LibraryName"));
89 ($template, $loggedinuser, $cookie)
90 = get_template_and_user({template_name => "serials/routing-preview.tmpl",
94 flagsrequired => {serials => 1},
99 # my $firstdate = "$serials[0]->{'serialseq'} ($serials[0]->{'planneddate'})";
102 for(my $i=0;$i<$routing;$i++){
103 $data=GetMember($routinglist[$i]->{'borrowernumber'},'borrowernumber');
104 $data->{'location'}=$data->{'streetaddress'};
105 $data->{'name'}="$data->{'firstname'} $data->{'surname'}";
106 $data->{'routingid'}=$routinglist[$i]->{'routingid'};
107 $data->{'subscriptionid'}=$subscriptionid;
108 push(@results, $data);
111 my $routingnotes = $serials[0]->{'routingnotes'};
112 $routingnotes =~ s/\n/\<br \/\>/g;
115 title => $subs->{'bibliotitle'},
117 subscriptionid => $subscriptionid,
118 memberloop => \@results,
119 routingnotes => $routingnotes,
122 output_html_with_http_headers $query, $cookie, $template->output;