fix "Add Tag" button in MARC framework editor
[koha.git] / serials / distributedto.pl
blobaf4088b354121fc311f1ad8289745792b5e11d65
1 #!/usr/bin/perl
3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
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.
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.
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
21 =head1 NAME
23 distributedto
25 =head1 DESCRIPTION
27 this script is launched as a popup. It allows to choose for who the subscription can be distributed.
29 =head1 PARAMETERS
31 =over 4
33 =item searchfield
34 to filter on the members.
36 =item distributedto
37 to know if there are already some members to in the distributed list
39 =item subscriptionid
40 to know what subscription this scrpit have to distribute.
42 =item SaveList
44 =back
46 =cut
49 use strict;
50 use CGI;
51 use C4::Dates;
52 use C4::Auth;
53 use C4::Context;
54 use C4::Output;
56 use C4::Serials;
57 use C4::Members;
59 my $input = new CGI;
60 my $searchfield=$input->param('searchfield');
61 defined $searchfield or $searchfield='';
62 my $distributedto=$input->param('distributedto');
63 my $subscriptionid = $input->param('subscriptionid');
64 $searchfield=~ s/\,//g;
65 my $SaveList=$input->param('SaveList');
66 my $dbh = C4::Context->dbh;
68 $distributedto = GetDistributedTo($subscriptionid) unless $distributedto;
70 SetDistributedto($distributedto,$subscriptionid) if ($SaveList) ;
72 my ($template, $borrowernumber, $cookie)
73 = get_template_and_user({template_name => "serials/distributedto.tmpl",
74 query => $input,
75 type => "intranet",
76 authnotrequired => 0,
77 flagsrequired => {serials => 1},
78 debug => 1,
79 });
81 my ($count,$results)=SearchMember($searchfield,"firstname","simple",) if $searchfield;
82 my $toggle="0";
83 my @loop_data =();
84 for (my $i=0; $i < $count; $i++){
85 if ($i % 2){
86 $toggle=1;
87 } else {
88 $toggle=0;
90 my %row_data;
91 $row_data{toggle} = $toggle;
92 $row_data{firstname} = $results->[$i]{'firstname'};
93 $row_data{surname} = $results->[$i]{'surname'};
94 push(@loop_data, \%row_data);
96 $template->param(borlist => \@loop_data,
97 searchfield => $searchfield,
98 distributedto => $distributedto,
99 SaveList => $SaveList,
100 subscriptionid => $subscriptionid,
102 output_html_with_http_headers $input, $cookie, $template->output;