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
14 use C4::Circulation::Circ2;
15 use C4::Interface::CGI::Output;
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);
48 # get biblio information....
49 my $biblio = $subs->{'biblionumber'};
51 # get existing reserves .....
52 my ($count,$reserves) = FindReserves($biblio);
53 my $totalcount = $count;
54 foreach my $res (@$reserves) {
55 if ($res->{'found'} eq 'W') {
59 my ($count2,@bibitems) = GetBiblioItemByBiblioNumber($biblio);
60 my @itemresults = GetItemsInfo($subs->{'biblionumber'}, 'intra');
61 my $branch = $itemresults[0]->{'holdingbranch'};
64 my $title = $subs->{'bibliotitle'};
65 for(my $i=0;$i<$routing;$i++){
66 my $sth = $dbh->prepare("SELECT * FROM reserves WHERE biblionumber = ? AND borrowernumber = ?
67 AND cancellationdate is NULL AND (found <> 'F' or found is NULL)");
68 $sth->execute($biblio,$routinglist[$i]->{'borrowernumber'});
69 my $data = $sth->fetchrow_hashref;
71 # warn "$routinglist[$i]->{'borrowernumber'} is the same as $data->{'borrowernumber'}";
72 if($routinglist[$i]->{'borrowernumber'} == $data->{'borrowernumber'}){
73 UpdateReserve($routinglist[$i]->{'ranking'},$biblio,$routinglist[$i]->{'borrowernumber'},$branch);
75 CreateReserve(\$env,$branch,$routinglist[$i]->{'borrowernumber'},$biblio,$const,\@bibitems,$routinglist[$i]->{'ranking'},$notes,$title);
80 ($template, $loggedinuser, $cookie)
81 = get_template_and_user({template_name => "serials/routing-preview-slip.tmpl",
85 flagsrequired => {serials => 1},
88 $template->param("libraryname"=>C4::Context->preference("LibraryName"));
90 ($template, $loggedinuser, $cookie)
91 = get_template_and_user({template_name => "serials/routing-preview.tmpl",
95 flagsrequired => {serials => 1},
100 # my $firstdate = "$serials[0]->{'serialseq'} ($serials[0]->{'planneddate'})";
103 for(my $i=0;$i<$routing;$i++){
104 $data=borrdata('',$routinglist[$i]->{'borrowernumber'});
105 $data->{'location'}=$data->{'streetaddress'};
106 $data->{'name'}="$data->{'firstname'} $data->{'surname'}";
107 $data->{'routingid'}=$routinglist[$i]->{'routingid'};
108 $data->{'subscriptionid'}=$subscriptionid;
109 push(@results, $data);
112 my $routingnotes = $serials[0]->{'routingnotes'};
113 $routingnotes =~ s/\n/\<br \/\>/g;
116 title => $subs->{'bibliotitle'},
118 subscriptionid => $subscriptionid,
119 memberloop => \@results,
120 routingnotes => $routingnotes,
123 output_html_with_http_headers $query, $cookie, $template->output;