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
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
26 use C4::Interface::CGI::Output;
31 my ($searchstring)=@_;
32 my $dbh = C4::Context->dbh;
33 $searchstring=~ s/\'/\\\'/g;
34 my @data=split(' ',$searchstring);
36 my $sth=$dbh->prepare("Select surname,firstname from borrowers where (surname like ?) order by surname");
37 $sth->execute("$data[0]%");
40 while (my $data=$sth->fetchrow_hashref){
45 return($cnt,\@results);
49 my $searchfield=$input->param('searchfield');
50 defined $searchfield or $searchfield='';
51 my $distributedto=$input->param('distributedto');
52 my $subscriptionid = $input->param('subscriptionid');
53 $searchfield=~ s/\,//g;
54 my $SaveList=$input->param('SaveList');
55 my $dbh = C4::Context->dbh;
57 unless ($distributedto) {
58 # read the previous distributedto
59 my $sth = $dbh->prepare('select distributedto from subscription where subscriptionid=?');
60 $sth->execute($subscriptionid);
61 ($distributedto) = $sth->fetchrow;
65 my $sth = $dbh->prepare("update subscription set distributedto=? where subscriptionid=?");
66 $sth->execute($distributedto,$subscriptionid);
68 my ($template, $borrowernumber, $cookie)
69 = get_template_and_user({template_name => "bull/distributedto.tmpl",
73 flagsrequired => {cataloguing => 1},
80 ($count,$results)=StringSearch($searchfield) if $searchfield;
83 for (my $i=0; $i < $count; $i++){
90 $row_data{toggle} = $toggle;
91 $row_data{firstname} = $results->[$i]{'firstname'};
92 $row_data{surname} = $results->[$i]{'surname'};
93 push(@loop_data, \%row_data);
95 $template->param(borlist => \@loop_data,
96 searchfield => $searchfield,
97 distributedto => $distributedto,
98 SaveList => $SaveList,
99 subscriptionid => $subscriptionid,
101 output_html_with_http_headers $input, $cookie, $template->output;