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) = bibitems($biblio);
60 my @itemresults = ItemInfo($env, $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 => {catalogue => 1},
89 ($template, $loggedinuser, $cookie)
90 = get_template_and_user({template_name => "serials/routing-preview.tmpl",
94 flagsrequired => {catalogue => 1},
99 # my $firstdate = "$serials[0]->{'serialseq'} ($serials[0]->{'planneddate'})";
102 for(my $i=0;$i<$routing;$i++){
103 $data=borrdata('',$routinglist[$i]->{'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;