Browse Source

frantic work on members

master
chris 22 years ago
parent
commit
fe9e2c1558
  1. 12
      C4/Circulation/Borrower.pm
  2. 3
      C4/Output.pm
  3. 12
      C4/Search.pm
  4. 55
      insertdata.pl
  5. 13
      memberentry.pl
  6. 153
      newmember.pl

12
C4/Circulation/Borrower.pm

@ -22,7 +22,7 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
$VERSION = 0.01;
@ISA = qw(Exporter);
@EXPORT = qw(&findborrower &Borenq &findoneborrower);
@EXPORT = qw(&findborrower &Borenq &findoneborrower &NewBorrowerNumber);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
# your exported package globals go here,
@ -284,6 +284,14 @@ sub modifyuser {
#return;
}
sub NewBorrowerNumber {
my $dbh=C4Connect;
my $sth=$dbh->prepare("Select max(borrowernumber) from borrowers");
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$data->{'max(borrowernumber)'}++;
return($data->{'max(borrowernumber)'});
}
END { } # module clean-up code here (global destructor)

3
C4/Output.pm

@ -195,6 +195,9 @@ sub mkformnotable{
if ($inputs[$i][0] eq 'reset'){
$string.="<input type=reset name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
}
if ($inputs[$i][0] eq 'submit'){
$string.="<input type=submit name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
}
}
$string=$string."</form>";
}

12
C4/Search.pm

@ -16,7 +16,7 @@ $VERSION = 0.01;
@ISA = qw(Exporter);
@EXPORT = qw(&CatSearch &BornameSearch &ItemInfo &KeywordSearch &subsearch
&itemdata &bibdata &GetItems &borrdata &getacctlist &itemnodata &itemcount
&OpacSearch &borrdata2);
&OpacSearch &borrdata2 &NewBorrowerNumber);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
# your exported package globals go here,
@ -52,6 +52,16 @@ my $priv_func = sub {
# make all your functions, whether exported or not;
sub NewBorrowerNumber {
my $dbh=C4Connect;
my $sth=$dbh->prepare("Select max(borrowernumber) from borrowers");
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$data->{'max(borrowernumber)'}++;
return($data->{'max(borrowernumber)'});
}
sub OpacSearch {
my ($env,$type,$search,$num,$offset)=@_;
my $dbh = &C4Connect;

55
insertdata.pl

@ -24,58 +24,3 @@ my $env;
foreach my $key (@names){
$data{$key}=$input->param($key);
}
my $updtype = $data{'updtype'};
if ($data{'type'} eq 'biblio'){
$data{'serial'}=~ s/No/0/;
$data{'serial'}=~ s/Yes/1/;
my $bibnum=getmax('biblio','biblionumber');
my $num=$bibnum->{'max'};
$num++;
$data{'biblionumber'}=$num;
} elsif ($data{'type'} eq 'borrowers') {
# required fields
$data{dateofbirth} = &UnixDate(&ParseDate($data{dateofbirth}),"%Y-%m-%d");
my @reqflds = ("cardnumber","surname","firstname",
"streetaddress","phone","altstreetaddress","altphone","dateofbirth","contactname");
my $probflds = checkflds($env,\@reqflds,\%data);
if (@$probflds[0] ne "") {
$problems = "The following required fields are missing: <br>";
$problems = $problems.join(", ",@$probflds)."<br>";
}
$data{cardnumber} = uc ($data{cardnumber});
my $validcard = checkdigit($env,$data{cardnumber});
if ($validcard ne "1") {
$problems = $problems."The card number failed the check digit check.<br>";
}
if ($problems eq "") {
if ($updtype eq "M") {
$keyfld = "borrowernumber";
} else {
my $bornum=getmax('borrowers','borrowernumber');
my $num=$bornum->{'max(borrowernumber)'};
$num++;
$data{'borrowernumber'}=$num;
$data{'branchcode'}="L";
}
}
} elsif ($data{'type'} eq "accountlines") {
$keyfld = "accountno\tborrowernumber";
$keyval = $data{'accountno'}."\t".$data{'borrowernumber'};
}
if ($problems eq "") {
if ($updtype eq "M") {
if ($keyval eq "") {
&sqlupdate($data{'type'},$keyfld,$data{$keyfld},%data);
} else {
&sqlupdate($data{'type'},$keyfld,$keyval,%data);
}
} else {
&sqlinsert($data{'type'},%data);
}
} else {
print "<strong>The following problems occured with the data:</strong><br>";
print $problems;
print "<br><br><strong>Please press the back key to fix this problem.</strong>";
}

13
memberentry.pl

@ -11,6 +11,9 @@ use C4::Search;
my $input = new CGI;
my $member=$input->param('bornum');
if ($member eq ''){
$member=NewBorrowerNumber();
}
my $type=$input->param('type');
print $input->header;
@ -28,8 +31,14 @@ print <<printend
<input type=hidden name=type value="borrowers">
<input type=hidden name=borrowernumber="$member">
<input type=hidden name=updtype value="M">
printend
;
if ($type eq 'Add'){
print "<input type=hidden name=updtype value=I>";
} else {
print "<input type=hidden name=updtype value=M>";
}
print <<printend
<table border=0 cellspacing=0 cellpadding=5 >

153
newmember.pl

@ -25,78 +25,109 @@ print startmenu('member');
my $main="#99cc33";
my $image="/images/background-mem.gif";
if ($insert eq ''){
my $ok=0;
#check that all compulsary fields are entered
my $string="The following compulsary fields have been left blank. Please push the back button
and try again<p>";
if ($data{'cardnumber'} eq ''){
$string.=" Cardnumber<br>";
$ok=1;
}
#we are printing confirmation page
print mkheadr(1,'Confirm New Adult Member');
print mktablehdr;
print mktablerow(2,$main,bold('NEW MEMBER'),"",$image);
my $name=$data{'title'}." ";
if ($data{'othernames'} ne ''){
$name.=$data{'othernames'}." ";
} else {
$name.=$data{'firstname'}." ";
if ($data{'sex'} eq ''){
$string.=" Gender <br>";
$ok=1;
}
$name.="$data{'surname'} ( $data{'firstname'}, $data{'initials'})";
print mktablerow(2,'white',bold('Name'),$name);
print mktablerow(2,$main,bold('MEMBERSHIP DETAILS'),"",$image);
print mktablerow(2,'white',bold('Membership Number'),$data{'borrowernumber'});
print mktablerow(2,'white',bold('Cardnumber'),$data{'cardnumber'});
print mktablerow(2,'white',bold('Membership Category'),$data{'category'});
print mktablerow(2,'white',bold('Area'),$data{'area'});
print mktablerow(2,'white',bold('Fee'),$data{'fee'});
$data{'joining'}=ParseDate('today');
print mktablerow(2,'white',bold('Joining Date'),$data{'joining'});
$data{'expiry'}=ParseDate('in 1 year');
print mktablerow(2,'white',bold('Expiry Date'),$data{'expiry'});
print mktablerow(2,'white',bold('Joining Branch'),$data{'joinbranch'});
print mktablerow(2,$main,bold('PERSONAL DETAILS'),"",$image);
my $ethnic=$data{'ethnicity'}." ".$data{'ethnicnotes'};
print mktablerow(2,'white',bold('Ethnicity'),$ethnic);
print mktablerow(2,'white',bold('Date of Birth'),$data{'dateofbirth'});
my $sex;
if ($data{'sex'} eq 'm'){
$sex="Male";
} else {
$sex="Female";
if ($data{'firstname'} eq ''){
$string.=" Given Names<br>";
$ok=1;
}
print mktablerow(2,'white',bold('Sex'),$sex);
print mktablerow(2,$main,bold('MEMBER ADDRESS'),"",$image);
my $postal=$data{'address'}."<br>".$data{'city'};
my $home;
if ($data{'streetaddress'} ne ''){
$home=$data{'streetaddress'}."<br>".$data{'streetcity'};
} else {
$home=$postal;
if ($data{'surname'} eq ''){
$string.=" Surname<br>";
$ok=1;
}
if ($data{'address'} eq ''){
$string.=" Postal Street Address<br>";
$ok=1;
}
print mktablerow(2,'white',bold('Postal Address'),$postal);
print mktablerow(2,'white',bold('Home Address'),$home);
print mktablerow(2,$main,bold('MEMBER CONTACT DETAILS'),"",$image);
print mktablerow(2,'white',bold('Phone (Home)'),$data{'phone'});
print mktablerow(2,'white',bold('Phone (Daytime)'),$data{'phoneday'});
print mktablerow(2,'white',bold('Fax'),$data{'faxnumber'});
print mktablerow(2,'white',bold('Email'),$data{'emailaddress'});
print mktablerow(2,$main,bold('ALTERNATIVE CONTACT DETAILS'),"",$image);
print mktablerow(2,'white',bold('Name'),$data{'contactname'});
print mktablerow(2,'white',bold('Phone'),$data{'altphone'});
print mktablerow(2,'white',bold('Relationship'),$data{'relation'});
print mktablerow(2,'white',bold('Notes'),$data{'altnotes'});
print mktablerow(2,$main,bold('Notes'),"",$image);
print mktablerow(2,'white',bold('General Notes'),$data{'borrowernotes'});
if ($data{'city'} eq ''){
$string.=" Postal City<br>";
$ok=1;
}
if ($data{'contactname'} eq ''){
$string.=" Alternate Contact<br>";
$ok=1;
}
#we are printing confirmation page
print mkheadr(1,'Confirm New Adult Member');
if ($ok ==0){
print mktablehdr;
print mktablerow(2,$main,bold('NEW MEMBER'),"",$image);
my $name=$data{'title'}." ";
if ($data{'othernames'} ne ''){
$name.=$data{'othernames'}." ";
} else {
$name.=$data{'firstname'}." ";
}
$name.="$data{'surname'} ( $data{'firstname'}, $data{'initials'})";
print mktablerow(2,'white',bold('Name'),$name);
print mktablerow(2,$main,bold('MEMBERSHIP DETAILS'),"",$image);
print mktablerow(2,'white',bold('Membership Number'),$data{'borrowernumber'});
print mktablerow(2,'white',bold('Cardnumber'),$data{'cardnumber'});
print mktablerow(2,'white',bold('Membership Category'),$data{'category'});
print mktablerow(2,'white',bold('Area'),$data{'area'});
print mktablerow(2,'white',bold('Fee'),$data{'fee'});
$data{'joining'}=ParseDate('today');
print mktablerow(2,'white',bold('Joining Date'),$data{'joining'});
$data{'expiry'}=ParseDate('in 1 year');
print mktablerow(2,'white',bold('Expiry Date'),$data{'expiry'});
print mktablerow(2,'white',bold('Joining Branch'),$data{'joinbranch'});
print mktablerow(2,$main,bold('PERSONAL DETAILS'),"",$image);
my $ethnic=$data{'ethnicity'}." ".$data{'ethnicnotes'};
print mktablerow(2,'white',bold('Ethnicity'),$ethnic);
print mktablerow(2,'white',bold('Date of Birth'),$data{'dateofbirth'});
my $sex;
if ($data{'sex'} eq 'm'){
$sex="Male";
} else {
$sex="Female";
}
print mktablerow(2,'white',bold('Sex'),$sex);
print mktablerow(2,$main,bold('MEMBER ADDRESS'),"",$image);
my $postal=$data{'address'}."<br>".$data{'city'};
my $home;
if ($data{'streetaddress'} ne ''){
$home=$data{'streetaddress'}."<br>".$data{'streetcity'};
} else {
$home=$postal;
}
print mktablerow(2,'white',bold('Postal Address'),$postal);
print mktablerow(2,'white',bold('Home Address'),$home);
print mktablerow(2,$main,bold('MEMBER CONTACT DETAILS'),"",$image);
print mktablerow(2,'white',bold('Phone (Home)'),$data{'phone'});
print mktablerow(2,'white',bold('Phone (Daytime)'),$data{'phoneday'});
print mktablerow(2,'white',bold('Fax'),$data{'faxnumber'});
print mktablerow(2,'white',bold('Email'),$data{'emailaddress'});
print mktablerow(2,$main,bold('ALTERNATIVE CONTACT DETAILS'),"",$image);
print mktablerow(2,'white',bold('Name'),$data{'contactname'});
print mktablerow(2,'white',bold('Phone'),$data{'altphone'});
print mktablerow(2,'white',bold('Relationship'),$data{'relation'});
print mktablerow(2,'white',bold('Notes'),$data{'altnotes'});
print mktablerow(2,$main,bold('Notes'),"",$image);
print mktablerow(2,'white',bold('General Notes'),$data{'borrowernotes'});
print mktableft;
#set up form to post data thru for modification or insertion
my $i=0;
my @inputs;
while (my ($key, $value) = each %data) {
$inputs[$i]=["hidden","$key","$value"];
$i++;
print mktableft;
#set up form to post data thru for modification or insertion
my $i=0;
my @inputs;
while (my ($key, $value) = each %data) {
$inputs[$i]=["hidden","$key","$value"];
$i++;
}
$inputs[$i]=["submit","submit","submit"];
print mkformnotable("/cgi-bin/koha/insertdata.pl",@inputs);
} else {
print $string;
}
print mkformnotable("/cgi-bin/koha/member.pl",@inputs);
}
#print $input->dump;

Loading…
Cancel
Save