#!/usr/bin/perl #script to set up screen for modification of borrower details #written 20/12/99 by chris@katipo.co.nz # Copyright 2000-2002 Katipo Communications # # This file is part of Koha. # # Koha is free software; you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # # Koha is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along with # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA use strict; use C4::Output; use CGI; use C4::Search; use C4::Database; use C4::Koha; my $input = new CGI; my $member=$input->param('bornum'); if ($member eq ''){ $member=NewBorrowerNumber(); } my $type=$input->param('type'); my $modify=$input->param('modify.x'); my $delete=$input->param('delete.x'); if ($delete){ print $input->redirect("/cgi-bin/koha/deletemem.pl?member=$member"); } else { print $input->header; print startpage(); print startmenu('member'); if ($type ne 'Add'){ print mkheadr(1,'Update Member Details'); } else { print mkheadr(1,'Add New Member'); } my $data=borrdata('',$member); print < printend ; if ($type eq 'Add'){ print ""; } else { print ""; } my $cardnumber=$data->{'cardnumber'}; my %systemprefs=systemprefs(); # FIXME # This logic should probably be moved out of the presentation code. # Not tonight though. # if ($cardnumber eq '' && $systemprefs{'autoMemberNum'} eq '1') { my $dbh=C4Connect; my $query="select max(substring(borrowers.cardnumber,2,7)) from borrowers"; my $sth=$dbh->prepare($query); $sth->execute; my $data=$sth->fetchrow_hashref; $cardnumber=$data->{'max(substring(borrowers.cardnumber,2,7))'}; $sth->finish; $dbh->disconnect; # purpose: generate checksum'd member numbers. # We'll assume we just got the max value of digits 2-8 of member #'s from the database and our job is to # increment that by one, determine the 1st and 9th digits and return the full string. my @weightings = (8,4,6,3,5,2,1); my $sum; my $i = 0; if (! $cardnumber) { # If DB has no values, start at 1000000 $cardnumber = 1000000; } else { $cardnumber = $cardnumber + 1; } while ($i <8) { # step from char 1 to 7. my $temp1 = $weightings[$i]; # read weightings, left to right, 1 char at a time my $temp2 = substr($cardnumber,$i,1); # sequence left to right, 1 char at a time #print "$temp2
"; $sum = $sum + ($temp1*$temp2); # mult each char 1-7 by its corresponding weighting $i++; # increment counter } my $rem = ($sum%11); # remainder of sum/11 (eg. 9999999/11, remainder=2) if ($rem == 10) { # if remainder is 10, use X instead $rem = "X"; } $cardnumber="V$cardnumber$rem"; } else { $cardnumber=$data->{'cardnumber'}; } print < Member# $member, Card Number*
MEMBER PERSONAL DETAILS * {'sex'} eq 'F'){ print " checked"; } print <F {'sex'} eq 'M'){ print " checked"; } print <M     Date of Birth (dd/mm/yy) Title Initials Given Names* Surname* Prefered Name   printend ; my ($categories,$labels)=ethnicitycategories(); my $ethnicitycategoriescount=$#{$categories}; if ($ethnicitycategoriescount>=0) { print $input->popup_menu(-name=>'ethnicity', -values=>$categories, -default=>$data->{'ethnicity'}, -labels=>$labels); print < printend ; } else { print " \n"; } ($categories,$labels)=borrowercategories(); print $input->popup_menu(-name=>'categorycode', -values=>$categories, -default=>$data->{'categorycode'}, -labels=>$labels); my $ethnicitylabels=''; if ($ethnicitycategoriescount>=0) { $ethnicitylabels=qq| Ethnicity Ethnicity Notes |; } else { $ethnicitylabels="  "; } print < $ethnicitylabels Membership Category*   MEMBER ADDRESS Street Address if different Town   MEMBER CONTACT DETAILS Phone (Home) Phone (day) Fax Email   ALTERNATE CONTACT DETAILS Name* Phone Relationship*   Notes   LIBRARY USE Notes   printend ; if ($modify){ print <FLAGS Gone No Address {'gonenoaddress'} eq '1'){ print " checked"; } print ">Yes {'gonenoaddress'} eq '0'){ print " checked"; } print ">No\n"; print "Lost{'lost'} eq '1'){ print " checked"; } print ">Yes{'lost'} eq '0'){ print " checked"; } print ">No\n"; print "Debarred{'debarred'} eq '1'){ print " checked"; } print ">Yes{'debarred'} eq '0'){ print " checked"; } print ">No\n"; } if ($type ne 'modify'){ print < printend ; } else { print < printend ; } print < printend ; print endmenu('member'); print endpage(); }