3 # Routing.pl script used to create a routing list for a serial subscription
4 # In this instance it is in fact a setting up of a list of reserves for the item
5 # where the hierarchical order can be changed on the fly and a routing list can be
14 use C4::Interface::CGI::Output;
21 my $subscriptionid = $query->param('subscriptionid');
22 my $serialseq = $query->param('serialseq');
23 my $routingid = $query->param('routingid');
24 my $bornum = $query->param('bornum');
25 my $notes = $query->param('notes');
26 my $op = $query->param('op');
27 my $date_selected = $query->param('date_selected');
28 my $dbh = C4::Context->dbh;
31 delroutingmember($routingid,$subscriptionid);
35 addroutingmember($bornum,$subscriptionid);
38 my $sth = $dbh->prepare("UPDATE serial SET routingnotes = ? WHERE subscriptionid = ?");
39 $sth->execute($notes,$subscriptionid);
40 print $query->redirect("routing-preview.pl?subscriptionid=$subscriptionid&issue=$date_selected");
43 my ($routing, @routinglist) = getroutinglist($subscriptionid);
44 my $subs = GetSubscription($subscriptionid);
45 my ($count,@serials) = old_getserials($subscriptionid);
46 my ($serialdates) = GetLatestSerials($subscriptionid,$count);
50 foreach my $dateseq (@$serialdates) {
51 $dates[$i]->{'planneddate'} = $dateseq->{'planneddate'};
52 $dates[$i]->{'serialseq'} = $dateseq->{'serialseq'};
53 $dates[$i]->{'serialid'} = $dateseq->{'serialid'};
54 if($date_selected eq $dateseq->{'serialid'}){
55 $dates[$i]->{'selected'} = ' selected';
57 $dates[$i]->{'selected'} = '';
62 my ($template, $loggedinuser, $cookie)
63 = get_template_and_user({template_name => "serials/routing.tmpl",
67 flagsrequired => {catalogue => 1},
72 # for(my $i = 0;$i<@serials; $i++){
73 # if($serials[$i]->{'serialseq'} eq $serialseq){
74 # $date = $serials[$i]->{'planneddate'}
78 # $serialseq = $serials[0]->{'serialseq'};
79 # $date = $serials[0]->{'planneddate'};
82 # my $issue = "$serialseq ($date)";
86 for(my $i=0;$i<$routing;$i++){
87 $data=borrdata('',$routinglist[$i]->{'borrowernumber'});
88 $data->{'location'}=$data->{'streetaddress'};
89 $data->{'name'}="$data->{'firstname'} $data->{'surname'}";
90 $data->{'routingid'}=$routinglist[$i]->{'routingid'};
91 $data->{'subscriptionid'}=$subscriptionid;
92 my $rankingbox = '<select name="itemrank" onchange="reorder_item('.$subscriptionid.','.$routinglist[$i]->{'routingid'}.',this.options[this.selectedIndex].value)">';
93 for(my $j=1; $j <= $routing; $j++) {
94 $rankingbox .= "<option ";
95 if($routinglist[$i]->{'ranking'} == $j){
96 $rankingbox .= " selected='SELECTED'";
98 $rankingbox .= " value='$j'>$j</option>";
100 $rankingbox .= "</select>";
101 $data->{'routingbox'} = $rankingbox;
103 push(@results, $data);
105 # warn Dumper(@results);
106 # for adding routing list
111 # for modify routing list default
116 title => $subs->{'bibliotitle'},
117 subscriptionid => $subscriptionid,
118 memberloop => \@results,
121 routingnotes => $serials[0]->{'routingnotes'},
124 output_html_with_http_headers $query, $cookie, $template->output;