[Koha-cvs] koha/serials distributedto.pl
Antoine Farnault
antoine at koha-fr.org
Wed Jul 12 18:47:15 CEST 2006
CVSROOT: /sources/koha
Module name: koha
Changes by: Antoine Farnault <toins> 06/07/12 16:47:15
Modified files:
serials : distributedto.pl
Log message:
Pod added, SQL code move on Serials.pm
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/serials/distributedto.pl?cvsroot=koha&r1=1.1&r2=1.2
Patches:
Index: distributedto.pl
===================================================================
RCS file: /sources/koha/koha/serials/distributedto.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- distributedto.pl 19 Jan 2006 12:46:58 -0000 1.1
+++ distributedto.pl 12 Jul 2006 16:47:15 -0000 1.2
@@ -17,6 +17,36 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
+# $Id: distributedto.pl,v 1.2 2006/07/12 16:47:15 toins Exp $
+
+=head1 NAME
+
+distributedto
+
+=head1 DESCRIPTION
+
+this script is launched as a popup. It allows to choose for who the subscription can be distributed.
+
+=head1 PARAMETERS
+
+=over 4
+
+=item searchfield
+to filter on the members.
+
+=item distributedto
+to know if there are already some members to in the distributed list
+
+=item subscriptionid
+to know what subscription this scrpit have to distribute.
+
+=item SaveList
+
+=back
+
+=cut
+
+
use strict;
use CGI;
use C4::Date;
@@ -26,24 +56,8 @@
use C4::Interface::CGI::Output;
use C4::Search;
use HTML::Template;
-
-sub StringSearch {
- my ($searchstring)=@_;
- my $dbh = C4::Context->dbh;
- $searchstring=~ s/\'/\\\'/g;
- my @data=split(' ',$searchstring);
- my $count=@data;
- my $sth=$dbh->prepare("Select surname,firstname from borrowers where (surname like ?) order by surname");
- $sth->execute("$data[0]%");
- my @results;
- my $cnt=0;
- while (my $data=$sth->fetchrow_hashref){
- push(@results,$data);
- $cnt ++;
- }
- $sth->finish;
- return($cnt,\@results);
-}
+use C4::Serials;
+use C4::Members;
my $input = new CGI;
my $searchfield=$input->param('searchfield');
@@ -54,17 +68,10 @@
my $SaveList=$input->param('SaveList');
my $dbh = C4::Context->dbh;
-unless ($distributedto) {
- # read the previous distributedto
- my $sth = $dbh->prepare('select distributedto from subscription where subscriptionid=?');
- $sth->execute($subscriptionid);
- ($distributedto) = $sth->fetchrow;
-}
+$distributedto = GetDistributedTo($subscriptionid) unless $distributedto;
+
+SetDistributedto($distributedto,$subscriptionid) if ($SaveList) ;
-if ($SaveList) {
- my $sth = $dbh->prepare("update subscription set distributedto=? where subscriptionid=?");
- $sth->execute($distributedto,$subscriptionid);
-}
my ($template, $borrowernumber, $cookie)
= get_template_and_user({template_name => "serials/distributedto.tmpl",
query => $input,
@@ -74,10 +81,7 @@
debug => 1,
});
-my $env;
-my $count=0;
-my $results;
-($count,$results)=StringSearch($searchfield) if $searchfield;
+my ($count,$results)=GetBorrowersFromSurname($searchfield) if $searchfield;
my $toggle="0";
my @loop_data =();
for (my $i=0; $i < $count; $i++){
@@ -99,4 +103,3 @@
subscriptionid => $subscriptionid,
);
output_html_with_http_headers $input, $cookie, $template->output;
-
More information about the Koha-cvs
mailing list