[Koha-cvs] koha C4/Members.pm members/memberentry.pl

Chris Cormack chris at katipo.co.nz
Tue May 23 02:46:32 CEST 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch: 	
Changes by:	Chris Cormack <rangi at savannah.gnu.org>	06/05/23 00:46:32

Modified files:
	C4             : Members.pm 
	members        : memberentry.pl 

Log message:
	Code to display list of organisations/institutions if memberofinstitution is set to yes

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/koha/C4/Members.pm.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/koha/koha/members/memberentry.pl.diff?tr1=1.20&tr2=1.21&r1=text&r2=text

Patches:
Index: koha/C4/Members.pm
diff -u koha/C4/Members.pm:1.15 koha/C4/Members.pm:1.16
--- koha/C4/Members.pm:1.15	Mon May 22 23:25:37 2006
+++ koha/C4/Members.pm	Tue May 23 00:46:32 2006
@@ -19,6 +19,8 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
+# $Id: Members.pm,v 1.16 2006/05/23 00:46:32 rangi Exp $
+
 use strict;
 require Exporter;
 use C4::Context;
@@ -28,7 +30,7 @@
 
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
 
-$VERSION = do { my @v = '$Revision: 1.15 $' =~ /\d+/g; shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
+$VERSION = do { my @v = '$Revision: 1.16 $' =~ /\d+/g; shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
 
 =head1 NAME
 
@@ -56,7 +58,7 @@
 	&getboracctrecord
 	&borrowercategories &getborrowercategory
 	&fixEthnicity
-	&ethnicitycategories
+	&ethnicitycategories get_institutions
     );
 
 
@@ -947,6 +949,27 @@
     my $data=$sth->fetchrow_hashref;
     $sth->finish;
     return $data->{'name'};
-}
+} # sub fixEthnicity
+
+=head2 get_institutions
+  
+  $insitutions = get_institutions();
+
+Just returns a list of all the borrowers of type I, borrownumber and name
+  
+=cut
+#'
+
+sub get_institutions {
+    my $dbh = C4::Context->dbh();
+    my $sth = $dbh->prepare("SELECT borrowernumber,surname FROM borrowers WHERE categorycode=? ORDER BY surname");
+    $sth->execute('I');
+    my %orgs;
+    while (my $data = $sth->fetchrow_hashref()){
+	$orgs{$data->{'borrowernumber'}}=$data;
+    }
+    $sth->finish();
+    return(\%orgs);
 
+} # sub get_institutions
 1;
Index: koha/members/memberentry.pl
diff -u koha/members/memberentry.pl:1.20 koha/members/memberentry.pl:1.21
--- koha/members/memberentry.pl:1.20	Fri Apr 21 14:32:09 2006
+++ koha/members/memberentry.pl	Tue May 23 00:46:32 2006
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# $Id: memberentry.pl,v 1.20 2006/04/21 14:32:09 plg Exp $
+# $Id: memberentry.pl,v 1.21 2006/05/23 00:46:32 rangi Exp $
 
 # Copyright 2006 SAN OUEST PROVENCE et Paul POULAIN
 #
@@ -59,6 +59,8 @@
 
 my $borrowerid=$input->param('borrowerid');
 my $guarantorid=$input->param('guarantorid');
+my $borrowernumber=$input->param('borrowernumber');
+my $actionType=$input->param('actionType') || '';
 my $modify=$input->param('modify');
 my $delete=$input->param('delete');
 my $op=$input->param('op');
@@ -87,6 +89,7 @@
 
 $template->param( "checked" => 1) if ($nodouble eq 1);
 
+
 # if a add or modify is requested => check validity of data.
 if ($op eq 'add' or $op eq 'modify') {
 	my @names=$input->param;
@@ -228,6 +231,7 @@
 
 if ($delete){
 	print $input->redirect("/cgi-bin/koha/deletemem.pl?member=$borrowerid");
+	print $input->redirect("/cgi-bin/koha/deletemem.pl?member=$borrowernumber");
 } else {  # this else goes down the whole script
 	# retrieve previous values : either in DB or in CGI, in case of errors in values
 	my $data;
@@ -384,6 +388,26 @@
 					   -override => 1,	
  					   -default => $default,
 					);
+       my $CGIorganisations;
+       my $member_of_institution;
+       if (C4::Context->preference("memberofinstitution")){
+	   my $organisations=get_institutions();
+	   my @orgs;
+	   my %orgs;
+	   foreach my $organisation (keys %$organisations) {
+	       push @orgs,$organisation;
+	       $orgs{$organisation}=$organisations->{$organisation}->{'surname'};
+	   }
+	       
+	   $member_of_institution=1;
+	   
+	   $CGIorganisations = CGI::scrolling_list( -name=>'organisations',
+	       -values=>\@orgs,
+	       -size=>5,
+	       -multiple=>'true'
+	       -labels=>\%orgs,
+	   );
+       }
 
 
 # --------------------------------------------------------------------------------------------------------
@@ -490,6 +514,8 @@
 # 				city_choice       => $city_choice ,#check if the city was selected
 		nok 		=> $nok,#flag to konw if an error 
 		CGIbranch => $CGIbranch,
+	        memberofinstution => $member_of_institution,
+	        CGIorganisations => $CGIorganisations,
 		);
 	#$template->param(Institution => 1) if ($categorycode eq "I");
 	output_html_with_http_headers $input, $cookie, $template->output;





More information about the Koha-cvs mailing list