#!/usr/bin/perl #script to set up screen for modification of borrower details #written 20/12/99 by chris@katipo.co.nz use strict; use C4::Output; use CGI; use C4::Search; use C4::Database; 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   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(); }