From 30412ec5cff7f0ce134fdb6310f4a7b125eaa209 Mon Sep 17 00:00:00 2001 From: rangi Date: Tue, 23 May 2006 00:46:32 +0000 Subject: [PATCH] Code to display list of organisations/institutions if memberofinstitution is set to yes --- C4/Members.pm | 27 +++++++++++++++++++++++++-- members/memberentry.pl | 26 ++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index c21f1411f4..b1864a8cb8 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -19,6 +19,8 @@ package C4::Members; # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA +# $Id$ + use strict; require Exporter; use C4::Context; @@ -56,7 +58,7 @@ C4::Members - Perl Module containing convenience functions for member handling &getboracctrecord &borrowercategories &getborrowercategory &fixEthnicity - ðnicitycategories + ðnicitycategories get_institutions ); @@ -947,6 +949,27 @@ sub fixEthnicity($) { 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; diff --git a/members/memberentry.pl b/members/memberentry.pl index a71c6cb452..cebf78167f 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -59,6 +59,8 @@ my ($template, $loggedinuser, $cookie) 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( "mandatory$_" => 1); $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 @@ SELECT upperagelimit, 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 @@ if ($delete){ -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 @@ if ($delete){ # 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; -- 2.39.5