replacing SUPER with NO_LIBRARY_SET for login information
[koha.git] / serials / distributedto.pl
1 #!/usr/bin/perl
2
3 # Copyright 2000-2002 Katipo Communications
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA  02111-1307 USA
19
20 # $Id$
21
22 =head1 NAME
23
24 distributedto
25
26 =head1 DESCRIPTION
27
28 this script is launched as a popup. It allows to choose for who the subscription can be distributed.
29
30 =head1 PARAMETERS
31
32 =over 4
33
34 =item searchfield
35 to filter on the members.
36
37 =item distributedto
38 to know if there are already some members to in the distributed list
39
40 =item subscriptionid
41 to know what subscription this scrpit have to distribute.
42
43 =item SaveList
44
45 =back
46
47 =cut
48
49
50 use strict;
51 use CGI;
52 use C4::Date;
53 use C4::Auth;
54 use C4::Context;
55 use C4::Output;
56
57 use C4::Serials;
58 use C4::Members;
59
60 my $input = new CGI;
61 my $searchfield=$input->param('searchfield');
62 defined $searchfield or $searchfield='';
63 my $distributedto=$input->param('distributedto');
64 my $subscriptionid = $input->param('subscriptionid');
65 $searchfield=~ s/\,//g;
66 my $SaveList=$input->param('SaveList');
67 my $dbh = C4::Context->dbh;
68
69 $distributedto = GetDistributedTo($subscriptionid) unless $distributedto;
70
71 SetDistributedto($distributedto,$subscriptionid) if ($SaveList) ;
72
73 my ($template, $borrowernumber, $cookie)
74     = get_template_and_user({template_name => "serials/distributedto.tmpl",
75                  query => $input,
76                  type => "intranet",
77                  authnotrequired => 0,
78                  flagsrequired => {serials => 1},
79                  debug => 1,
80                  });
81
82 my ($count,$results)=SearchMember($searchfield,"firstname","simple",) if $searchfield;
83 my $toggle="0";
84 my @loop_data =();
85 for (my $i=0; $i < $count; $i++){
86     if ($i % 2){
87             $toggle=1;
88     } else {
89             $toggle=0;
90     }
91     my %row_data;
92     $row_data{toggle} = $toggle;
93     $row_data{firstname} = $results->[$i]{'firstname'};
94     $row_data{surname} = $results->[$i]{'surname'};
95     push(@loop_data, \%row_data);
96 }
97 $template->param(borlist => \@loop_data,
98                 searchfield => $searchfield,
99                 distributedto => $distributedto,
100                 SaveList => $SaveList,
101                 subscriptionid => $subscriptionid,
102                 );
103 output_html_with_http_headers $input, $cookie, $template->output;