Skip to content
Browse files

templatified:set templatedirectory in koha.conf to use the templates

  • Loading branch information...
1 parent 643f730 commit 0f24c709006dd90652d3ccf26303b3a9ff355fcf dnmeid committed Sep 17, 2002
Showing with 301 additions and 772 deletions.
  1. +23 −50 boraccount.pl
  2. +10 −128 imemberentry.pl
  3. +47 −142 jmemberentry.pl
  4. +30 −40 member.pl
  5. +191 −412 memberentry.pl
View
73 boraccount.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-#wrriten 11/1/2000 by chris@katipo.oc.nz
+#writen 11/1/2000 by chris@katipo.oc.nz
#script to display borrowers account details
@@ -25,74 +25,47 @@
use C4::Output;
use CGI;
use C4::Search;
+use HTML::Template;
+
my $input=new CGI;
+my $theme = $input->param('theme'); # only used if allowthemeoverride is set
+my %tmpldata = pathtotemplate ( template => 'boraccount.tmpl', theme => $theme );
+my $template = HTML::Template->new(filename => $tmpldata{'path'}, die_on_bad_params => 0);
my $bornum=$input->param('bornum');
#get borrower details
my $data=borrdata('',$bornum);
-
#get account details
my %bor;
$bor{'borrowernumber'}=$bornum;
my ($numaccts,$accts,$total)=getboracctrecord('',\%bor);
+my @accountrows; # this is for the tmpl-loop
-
-print $input->header;
-print startpage();
-print startmenu('member');
-print <<printend
-<FONT SIZE=6><em>Account for $data->{'firstname'} $data->{'surname'}</em></FONT><P>
-<a href=/cgi-bin/koha/maninvoice.pl?bornum=$bornum><image src=/images/create-man-invoice.gif border=0></a>
- &nbsp; <a href=/cgi-bin/koha/mancredit.pl?bornum=$bornum><image src=/images/create-man-credit.gif border=0></a>
-<center>
-<p>
-<TABLE CELLSPACING=0 CELLPADDING=5 border=1 >
-<TR VALIGN=TOP>
-<td bgcolor="99cc33" background="/images/background-mem.gif" colspan=2><B>FINES & CHARGES</TD>
-<td bgcolor="99cc33" background="/images/background-mem.gif" colspan=1><B>AMOUNT</TD>
-<td bgcolor="99cc33" background="/images/background-mem.gif" colspan=1><B>STILL OWING</TD>
-</TR>
-
-printend
-;
for (my $i=0;$i<$numaccts;$i++){
$accts->[$i]{'amount'}+=0.00;
$accts->[$i]{'amountoutstanding'}+=0.00;
- print <<printend
- <tr VALIGN=TOP >
- <td>$accts->[$i]{'date'}</td>
- <TD>$accts->[$i]{'description'}
-printend
-;
+ my %row = ( 'date' => $accts->[$i]{'date'},
+ 'description' => $accts->[$i]{'description'},
+ 'amount' => $accts->[$i]{'amount'},
+ 'amountoutstanding' => $accts->[$i]{'amountoutstanding'} );
+
if ($accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU'){
- print "$accts->[$i]{'title'}";
+ $row{'printtitle'}=1;
+ $row{'title'} = $accts->[$i]{'title'};
}
- print <<printend
- </td>
- <td>$accts->[$i]{'amount'}</td>
- <TD>$accts->[$i]{'amountoutstanding'}</td>
-</tr>
-printend
-;
+ push(@accountrows, \%row);
}
-print <<printend
-<tr VALIGN=TOP >
-<TD></td>
-<TD colspan=2><b>Total Due</b></td>
-
-<TD><b>$total</b></td>
-
-</tr>
-</table>
-<br clear=all>
-<p> &nbsp; </p>
-printend
-;
-print endmenu('member');
-print endpage();
+$template->param( startmenumember => startmenu('member'),
+ endmenumember => endmenu('member'),
+ firstname => $data->{'firstname'},
+ surname => $data->{'surname'},
+ bornum => $bornum,
+ total => $total,
+ accounts => \@accountrows );
+print "Content-Type: text/html\n\n", $template->output;
View
138 imemberentry.pl
@@ -25,142 +25,24 @@
use C4::Output;
use CGI;
use C4::Search;
-
+use HTML::Template;
my $input = new CGI;
+
+my $theme = $input->param('theme'); # only used if allowthemeoverride is set
+my %tmpldata = pathtotemplate ( template => 'imemberentry.tmpl', theme => $theme );
+my $template = HTML::Template->new(filename => $tmpldata{'path'}, die_on_bad_params => 0);
+
my $member=$input->param('bornum');
if ($member eq ''){
$member=NewBorrowerNumber();
}
my $type=$input->param('type');
-print $input->header;
-print startpage();
-print startmenu('member');
my $data=borrdata('',$member);
-print <<printend
-<BLOCKQUOTE>
-
-<FONT SIZE=6><em>Add New Institution</em></FONT><br>
-<form action=/cgi-bin/koha/newimember.pl method=post>
-<input type=hidden name=joining value="">
-<input type=hidden name=expiry value="">
-<input type=hidden name=type value="borrowers">
-<input type=hidden name=borrowernumber value="$member">
-<input type=hidden name=updtype value=I>
-<table border=0 cellspacing=0 cellpadding=5 >
-
-
-<tr valign=top><td ><input type=reset value="Clear all Fields"></td></tr><tr>
-<TR align=right><td COLSPAN=2 ALIGN=RIGHT ><font size=3 face='arial,helvetica'>
-<STRONG>Member# $member, Card Number*</STRONG> </TD><TD align=right><input type=text name=cardnumber_institution size=20 value=" "><br>
-</td></TR>
-<tr><td>&nbsp; </TD></TR>
-
-<tr valign=top bgcolor="99cc33" ><td COLSPAN=5 background="/images/background-mem.gif">
-<B>INSTITUTION DETAILS</b></td> <td COLSPAN=2 ALIGN=RIGHT background="/images/background-mem.gif">
-
-</td></tr>
-<tr valign=top bgcolor=white>
-
-<td colspan=3><input type=text name=institution_name size=50 value=""></td>
-</tr>
-<tr valign=top bgcolor=white>
-
-<td><FONT SIZE=2>Institution Name</FONT></td>
-</tr>
-<tr><td>&nbsp; </TD></TR>
-
-
- <tr valign=top bgcolor="99cc33" ><td COLSPAN=5 background="/images/background-mem.gif">
- <B>INSTITUTION ADDRESS</b></td></tr>
- <tr valign=top bgcolor=white>
- <td><input type=text name=address size=40 value="">
- <td><input type=text name=city size=20 value=""></td>
- <td>
- <SELECT NAME="area" SIZE="1">
- <OPTION value=L
-
- >L - Levin
- <OPTION value=F>F - Foxton
- <OPTION value=S>S - Shannon
- <OPTION value=H>H - Horowhenua
- <OPTION value=K>K - Kapiti
- <OPTION value=O>O - Out of District
- <OPTION value=X>X - Temporary Visitor
- <OPTION value=Z>Z - Interloan Libraries
- <OPTION value=V>V - Villlage</SELECT></td></tr>
- <tr valign=top bgcolor=white>
- <td ><FONT SIZE=2>Postal Address*</FONT></td>
- <td><FONT SIZE=2>Town*</FONT></td>
- <td><FONT SIZE=2>Area</FONT></td>
- </tr>
- <tr><td>&nbsp; </TD></TR>
- <tr valign=top bgcolor="99cc33" ><td COLSPAN=5 background="/images/background-mem.gif">
- <B>CONTACT DETAILS</b></td></tr>
- <tr valign=top bgcolor=white>
- <td COLSPAN=3 ><input type=text name=contactname size=40 value=""></td>
- </tr>
-
- <tr valign=top bgcolor=white>
- <td COLSPAN=3 ><FONT SIZE=2>Contact Name*</td></tr>
-
- <tr valign=top bgcolor=white>
-
- <td ><input type=text name=phoneday size=20 value=""></td>
- <td><input type=text name=faxnumber size=20 value=""></td>
- <td ><input type=text name=emailaddress size=20 value=""></td></tr>
-
- <tr valign=top bgcolor=white>
-
- <td><FONT SIZE=2>Phone (day)</td>
- <td><FONT SIZE=2>Fax</td>
- <td><FONT SIZE=2>Email</td></tr>
- <tr><td>&nbsp; </TD></TR>
-
-
- <tr valign=top bgcolor=white>
-
-
- <td COLSPAN=4><textarea name=altnotes wrap=physical cols=70 rows=3></textarea></td></tr>
- </tr>
- <tr valign=top bgcolor=white>
- <td><FONT SIZE=2>Notes</font></td></tr>
- <tr><td>&nbsp; </TD></TR>
-
-
- <tr valign=top bgcolor="99cc33" >
-
- <td COLSPAN=5 background="/images/background-mem.gif"><B>LIBRARY USE</B></td>
- </tr>
-
-
- <tr valign=top >
-
-
- <td COLSPAN=5><textarea name=borrowernotes wrap=physical cols=70 rows=3></textarea></td></tr>
- <tr><td>&nbsp; </TD></TR>
- <tr valign=top bgcolor=white>
- <td ><FONT SIZE=2>Notes</font></td>
- </tr><tr valign=top bgcolor=white>
-
-
- <td COLSPAN=5 align=right >
- <input type=image src="/images/save-changes.gif" WIDTH=188 HEIGHT=44 ALT="Add New Member" border=0 ></td>
- </tr>
- </TABLE>
- </table>
- </form>
-
-
-
- <br clear=all>
-
- <p> &nbsp; </p>
-
+$template->param( startmenumember => startmenu('member'),
+ endmenumember => endmenu('member'),
+ member => $member );
-printend
-;
-print endmenu('member');
-print endpage();
+print "Content-Type: text/html\n\n", $template->output;
View
189 jmemberentry.pl
@@ -25,160 +25,65 @@
use C4::Output;
use CGI;
use C4::Search;
-
+use HTML::Template;
my $input = new CGI;
+
+my $theme = $input->param('theme'); # only used if allowthemeoverride is set
+my %tmpldata = pathtotemplate ( template => 'jmemberentry.tmpl', theme => $theme );
+my $template = HTML::Template->new(filename => $tmpldata{'path'}, die_on_bad_params => 0);
+
my $member=$input->param('bornum');
if ($member eq ''){
$member=NewBorrowerNumber();
}
my $type=$input->param('type');
-print $input->header;
-print startpage();
-print startmenu('member');
my $data=borrdata('',$member);
-print <<printend
-<BLOCKQUOTE>
-
-<FONT SIZE=6><em>Add New Junior Member </em></font><br>
-<form action=/cgi-bin/koha/newjmember.pl method=post>
-<!--<input type=hidden name=joining value="">
-<input type=hidden name=expiry value="">
-<input type=hidden name=type value="borrowers">-->
-<input type=hidden name=borrowernumber value=$member>
-<input type=hidden name=updtype value=I>
-<input type=hidden name=area value="$data->{'area'}">
-<input type=hidden name=city value="$data->{'city'}">
-<input type=hidden name=street value="$data->{'address'}">
-<input type=hidden name=streetaddress value="$data->{'streetaddress'}">
-<input type=hidden name=streetcity value="$data->{'streetcity'}">
-<input type=hidden name=phone value="$data->{'phone'}">
-<input type=hidden name=phoneday value="$data->{'phoneday'}">
-
-<input type=hidden name=faxnumber value="$data->{'faxnumber'}">
-<input type=hidden name=emailaddress value="$data->{'emailaddress'}">
-<input type=hidden name=contactname value="$data->{'contactname'}">
-<input type=hidden name=altphone value"$data->{'altphone'}">
-<table border=0 cellspacing=0 cellpadding=5 >
-
-
-<tr valign=top><td COLSPAN=1><input type=reset value="Clear all Fields"></td></tr>
-<tr valign=top bgcolor="99cc33" ><td COLSPAN=5 background="/images/background-mem.gif">
-<tr valign=top bgcolor="99cc33" ><td COLSPAN=5 background="/images/background-mem.gif">
-<B>PARENT OR GUARDIAN </b></td></tr>
-<tr valign=top bgcolor=white>
-<td><SELECT NAME="title" SIZE="1">
-<OPTION value=" ">No Title
-<OPTION value=Miss
-printend
-;
-if ($data->{'title'} eq 'Miss'){
- print " Selected";
-}
-print ">Miss
-<OPTION value=Mrs";
-if ($data->{'title'} eq 'Mrs'){
- print " Selected";
-}
-print ">Mrs
-<OPTION value=Ms";
-if ($data->{'title'} eq 'Ms'){
- print " Selected";
-}
-print ">Ms
-<OPTION value=Mr";
-if ($data->{'title'} eq 'Mr'){
- print " Selected";
-}
-print ">Mr
-<OPTION value=Dr";
-if ($data->{'title'} eq 'Dr'){
- print " Selected";
-}
-print ">Dr
-<OPTION value=Sir";
-if ($data->{'title'} eq 'Sir'){
- print " Selected";
-}
-print <<printend
- >Sir
-</SELECT>
-</td>
-
-<td><input type=text name=firstname_guardian size=20 value="$data->{'firstname'}"></td>
-<td colspan=2><input type=text name=surname_guardian size=20 value="$data->{'surname'}"></td>
-<td><input type=text name=guardian_number size=20 value="$data->{'cardnumber'}"></td></tr>
-<tr valign=top bgcolor=white>
-<td><FONT SIZE=2>Title</FONT></td>
-
-<td><FONT SIZE=2>Given Names*</FONT></td>
-<td colspan=2><FONT SIZE=2>Surname*</FONT></td>
-<td><FONT SIZE=2>Membership No.</FONT></td>
-</tr>
-
-<tr><td>&nbsp; </TD></TR>
+my @titles = ('Miss', 'Mrs', 'Ms', 'Mr', 'Dr', 'Sir');
+my @titledata;
+while (@titles) {
+ my $title = shift @titles;
+ my %row = ('title' => $title);
+ if ($data->{'title'} eq $title) {
+ $row{'selected'}=' selected';
+ } else {
+ $row{'selected'}='';
+ }
+ push(@titledata, \%row);
+}
-printend
-;
+# get the data for children
my $cmember1=NewBorrowerNumber();
+my @cmemdata;
for (my $i=0;$i<3;$i++){
-my $cmember=$cmember1+$i;
-my $count=$i+1;
-print <<printend
-<tr valign=top bgcolor="99cc33" ><td COLSPAN=5 background="/images/background-mem.gif">
-<B>CHILD $count </b></td></TR>
-<tr valign=top></tr>
-
-<TR><td COLSPAN=4 ALIGN=RIGHT ><font size=3 face='arial,helvetica'>
-<STRONG>Member# $cmember, Card Number*</STRONG> </TD><TD><input type=text name=cardnumber_child_$i size=20 value=""><br>
-<input type=hidden name=bornumber_child_$i value=$cmember>
-</td></TR>
-<tr bgcolor=white>
-
-
-<td><input type=text name=firstname_child_$i size=20 value=""></td>
-<td><input type=text name=surname_child_$i size=20 value=""></td>
-<td>
-<input type=text name=dateofbirth_child_$i size=10 value="">
-</TD><TD>
- <input type="radio" name="sex_child_$i" value="F">F
- <input type="radio" name="sex_child_$i" value="M">M* </td>
- <TD align=right>
- <input type=text name=school_child_$i size=20 value="">
- </TD>
- </tr>
- <tr valign=top bgcolor=white>
- <td><FONT SIZE=2>Given Names*</FONT></td>
- <td><FONT SIZE=2>Surname*</FONT></td>
-
- <td><FONT SIZE=2>Date of Birth<BR> (dd/mm/yy)*</FONT></td>
- <td><FONT SIZE=2>&nbsp;</FONT></td>
- <td><FONT SIZE=2>School</FONT></td></tr>
-
-
-
-
- <tr valign=top bgcolor=white>
-
- <td COLSPAN=5><textarea name=altnotes_child_$i wrap=physical cols=70 rows=3></textarea></td></tr><tr valign=top bgcolor=white>
-
- <td><FONT SIZE=2>Notes</font></td>
- </tr>
- <tr><td>&nbsp; </TD></TR>
-printend
-;
+ my %row;
+ $row{'cmember'}=$cmember1+$i;
+ $row{'i'}=$i;
+ $row{'count'}=$i+1;
+ push(@cmemdata, \%row);
}
-print <<printend
- <tr valign=top bgcolor=white><td COLSPAN=5 align=right >
- <input type=image src="/images/save-changes.gif" WIDTH=188 HEIGHT=44 ALT="Add New Member" border=0 ></td>
- </tr>
- </TABLE>
- </table>
-
-printend
-;
-print endmenu('member');
-print endpage();
+
+$template->param( startmenumember => startmenu('member'),
+ endmenumember => endmenu('member'),
+ member => $member,
+ firstname => $data->{'firstname'},
+ surname => $data->{'surname'},
+ cardnumber => $data->{'cardnumber'},
+ area => $data->{'area'},
+ city => $data->{'city'},
+ address => $data->{'address'},
+ streetaddress => $data->{'streetaddress'},
+ streetcity => $data->{'streetcity'},
+ phone => $data->{'phone'},
+ phoneday => $data->{'phoneday'},
+ faxnumber => $data->{'faxnumber'},
+ emailaddress => $data->{'emailaddress'},
+ contactname => $data->{'contactname'},
+ altphone => $data->{'altphone'},
+ titleloop => \@titledata,
+ cmemloop => \@cmemdata );
+
+print "Content-Type: text/html\n\n", $template->output;
View
70 member.pl
@@ -25,54 +25,44 @@
use C4::Output;
use CGI;
use C4::Search;
-
+use HTML::Template;
my $input = new CGI;
+
+my $theme = $input->param('theme'); # only used if allowthemeoverride is set
+my %tmpldata = pathtotemplate ( template => 'member.tmpl', theme => $theme, language => 'fi' );
+my $template = HTML::Template->new( filename => $tmpldata{'path'},
+ die_on_bad_params => 0,
+ loop_context_vars => 1 );
+
my $member=$input->param('member');
$member=~ s/\,//g;
-print $input->header;
-#start the page and read in includes
-print startpage();
-print startmenu('member');
-my @inputs=(["text","member",$member],
- ["reset","reset","clr"]);
-print mkheadr(2,'Member Search');
-print mkformnotable("/cgi-bin/koha/member.pl",@inputs);
-print <<printend
-printend
-;
-print "You Searched for $member<p>";
-print mktablehdr;
-print mktablerow(8,'#99cc33',bold('Card'),bold('Surname'),bold('Firstname'),bold('Category')
-,bold('Address'),bold('OD/Issues'),bold('Charges'),bold('Notes'),'/images/background-mem.gif');
my $env;
my ($count,$results)=BornameSearch($env,$member,'web');
-#print $count;
-my $toggle="white";
+
+my @resultsdata;
for (my $i=0; $i < $count; $i++){
#find out stats
my ($od,$issue,$fines)=borrdata2($env,$results->[$i]{'borrowernumber'});
- $fines=$fines+0;
- if ($toggle eq 'white'){
- $toggle="#ffffcc";
- } else {
- $toggle="white";
- }
- #mklink("/cgi-bin/koha/memberentry.pl?bornum=".$results->[$i]{'borrowernumber'},$results->[$i]{'cardnumber'}),
- print mktablerow(8,$toggle,mklink("/cgi-bin/koha/moremember.pl?bornum=".$results->[$i]{'borrowernumber'},$results->[$i]{'cardnumber'}),
- $results->[$i]{'surname'},$results->[$i]{'firstname'},
- $results->[$i]{'categorycode'},$results->[$i]{'streetaddress'}." ".$results->[$i]{'city'},"$od/$issue",$fines,
- $results->[$i]{'borrowernotes'});
+
+ my %row = (
+ borrowernumber => $results->[$i]{'borrowernumber'},
+ cardnumber => $results->[$i]{'cardnumber'},
+ surname => $results->[$i]{'surname'},
+ firstname => $results->[$i]{'firstname'},
+ categorycode => $results->[$i]{'categorycode'},
+ streetaddress => $results->[$i]{'streetaddress'},
+ city => $results->[$i]{'city'},
+ odissue => "$od/$issue",
+ fines => $fines,
+ borrowernotes => $results->[$i]{'borrowernotes'});
+ push(@resultsdata, \%row);
}
-print mktableft;
-print <<printend
-<form action=/cgi-bin/koha/simpleredirect.pl method=post>
-<input type=image src="/images/button-add-member.gif" WIDTH=188 HEIGHT=44 ALT="Add New Member" BORDER=0 ></a><br>
-<INPUT TYPE="radio" name="chooseform" value="adult" checked>Adult
-<INPUT TYPE="radio" name="chooseform" value="organisation" >Organisation
-</form>
-printend
-;
-print endmenu('member');
-print endpage();
+
+$template->param( startmenumember => join ('', startmenu('member')),
+ endmenumember => join ('', endmenu('member')),
+ member => $member,
+ resultsloop => \@resultsdata );
+
+print "Content-Type: text/html\n\n", $template->output;
View
603 memberentry.pl
@@ -27,432 +27,211 @@
use C4::Search;
use C4::Database;
use C4::Koha;
+use HTML::Template;
my $input = new CGI;
+
+my $theme = $input->param('theme'); # only used if allowthemeoverride is set
+my %tmpldata = pathtotemplate ( template => 'memberentry.tmpl', theme => $theme );
+my $template = HTML::Template->new(filename => $tmpldata{'path'}, die_on_bad_params => 0);
+
my $member=$input->param('bornum');
if ($member eq ''){
$member=NewBorrowerNumber();
}
-my $type=$input->param('type');
+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
-<form action=/cgi-bin/koha/newmember.pl method=post>
-<input type=hidden name=joining value="$data->{'dateenrolled'}">
-<input type=hidden name=expiry value="$data->{'expiry'}">
-<input type=hidden name=type value="borrowers">
-<input type=hidden name=borrowernumber value="$member">
-printend
-;
-if ($type eq 'Add'){
- print "<input type=hidden name=updtype value=I>";
-} else {
- print "<input type=hidden name=updtype value=M>";
-}
-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 { # this else goes down the whole script
+ if ($type ne 'Add'){
+ $template->param( header => 'Update Member Details'); # bad templating style
} else {
- $cardnumber = $cardnumber + 1;
+ $template->param( header => 'Add New Member');
}
-
- 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<br>";
- $sum = $sum + ($temp1*$temp2); # mult each char 1-7 by its corresponding weighting
- $i++; # increment counter
+
+ my $data=borrdata('',$member);
+
+ if ($type eq 'Add'){
+ $template->param( updtype => 'I');
+ } else {
+ $template->param( updtype => 'M');
+ }
+
+ 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<br>";
+ $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'};
+ }
+
+ if ($data->{'sex'} eq 'F'){
+ $template->param(female => 1);
+ }
+
+ my @titles = ('Miss', 'Mrs', 'Ms', 'Mr', 'Dr', 'Sir');
+ my @titledata;
+ while (@titles) {
+ my %row;
+ my $title = shift @titles;
+ $row{'title'} = $title;
+ if ($data->{'title'} eq $title) {
+ $row{'selected'}=' selected';
+ } else {
+ $row{'selected'}='';
+ }
+ push(@titledata, \%row);
+ }
+
+ my ($categories,$labels)=ethnicitycategories();
+ my $ethnicitycategoriescount=$#{$categories};
+ my $ethcatpopup;
+ if ($ethnicitycategoriescount>=0) {
+ $ethcatpopup = popup_menu(-name=>'ethnicity',
+ -values=>$categories,
+ -default=>$data->{'ethnicity'},
+ -labels=>$labels);
+ $template->param(ethcatpopup => $ethcatpopup); # bad style, has to be fixed
+ }
+
+ ($categories,$labels)=borrowercategories();
+ my $catcodepopup = CGI::popup_menu(-name=>'categorycode',
+ -values=>$categories,
+ -default=>$data->{'categorycode'},
+ -labels=>$labels);
+
+ my @areas = ('L','F','S','H','K','O','X','Z','V');
+ my %arealabels = ('L' => 'Levin',
+ 'F' => 'Foxton',
+ 'S' => 'Shannon',
+ 'H' => 'Horowhenua',
+ 'K' => 'Kapiti',
+ 'O' => 'Out of District',
+ 'X' => 'Temporary Visitor',
+ 'Z' => 'Interloan Libraries',
+ 'V' => 'Village');
+
+ my @areadata;
+ while (@areas) {
+ my %row;
+ my $shortcut = shift @areas;
+ $row{'shortcut'} = $shortcut;
+ if ($data->{'area'} eq $shortcut) {
+ $row{'selected'}=' selected';
+ } else {
+ $row{'selected'}='';
+ }
+ $row{'area'}=$arealabels{$shortcut};
+ push(@areadata, \%row);
+ }
+
+
+ my @relationships = ('workplace', 'relative','friend', 'neighbour');
+ my @relshipdata;
+ while (@relationships) {
+ my $relship = shift @relationships;
+ my %row = ('relationship' => $relship);
+ if ($data->{'altrelationship'} eq $relship) {
+ $row{'selected'}=' selected';
+ } else {
+ $row{'selected'}='';
+ }
+ push(@relshipdata, \%row);
+ }
+
+ # %flags: keys=$data-keys, datas=[formname, HTML-explanation]
+ my %flags = ('gonenoaddress' => ['gna', 'Gone no address'],
+ 'lost' => ['lost', 'Lost'],
+ 'debarred' => ['debarred', 'Debarred']);
+
+ my @flagdata;
+ foreach (keys(%flags)) {
+ my $key = $_;
+ my %row = ('key' => $key,
+ 'name' => $flags{$key}[0],
+ 'html' => $flags{$key}[1]);
+ if ($data->{$key}) {
+ $row{'yes'}=' checked';
+ $row{'no'}='';
+ } else {
+ $row{'yes'}='';
+ $row{'no'}=' checked';
+ }
+ push(@flagdata, \%row);
}
- 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 <<printend
-
-<table border=0 cellspacing=0 cellpadding=5 >
-
-
-<tr valign=top><td COLSPAN=2><input type=reset value="Clear all Fields"></td><td COLSPAN=3 ALIGN=RIGHT ><font size=4 face='arial,helvetica'>
-Member# $member, Card Number* <input type=text name=cardnumber size=10 value="$cardnumber"><br>
-</td></tr>
-
-
-<tr valign=top ><td COLSPAN=3 background="/images/background-mem.gif">
-<B>MEMBER PERSONAL DETAILS</b></td> <td COLSPAN=2 ALIGN=RIGHT background="/images/background-mem.gif">
-* <input type="radio" name="sex" value="F"
-printend
-;
-if ($data->{'sex'} eq 'F'){
- print " checked";
-}
-print <<printend
->F
-<input type="radio" name="sex" value="M"
-printend
-;
-if ($data->{'sex'} eq 'M'){
- print " checked";
-}
-print <<printend
->M
-&nbsp; &nbsp; <B>Date of Birth</B> (dd/mm/yy)
-<input type=text name=dateofbirth size=10 value="$data->{'dateofbirth'}">
-</td></tr>
-<tr valign=top bgcolor=white>
-<td><SELECT NAME="title" SIZE="1">
-<OPTION value=" ">No Title
-<OPTION value=Miss
-printend
-;
-if ($data->{'title'} eq 'Miss'){
- print " Selected";
-}
-print ">Miss
-<OPTION value=Mrs";
-if ($data->{'title'} eq 'Mrs'){
- print " Selected";
-}
-print ">Mrs
-<OPTION value=Ms";
-if ($data->{'title'} eq 'Ms'){
- print " Selected";
-}
-print ">Ms
-<OPTION value=Mr";
-if ($data->{'title'} eq 'Mr'){
- print " Selected";
-}
-print ">Mr
-<OPTION value=Dr";
-if ($data->{'title'} eq 'Dr'){
- print " Selected";
-}
-print ">Dr
-<OPTION value=Sir";
-if ($data->{'title'} eq 'Sir'){
- print " Selected";
-}
-print <<printend
->Sir
-</SELECT>
-</td>
-
-<td><input type=text name=initials size=5 value="$data->{'initials'}"></td>
-<td><input type=text name=firstname size=20 value="$data->{'firstname'}"></td>
-<td><input type=text name=surname size=20 value="$data->{'surname'}"></td>
-<td><input type=text name=othernames size=20 value="$data->{'othernames'}"></td></tr>
-<tr valign=top bgcolor=white>
-<td><FONT SIZE=2>Title</FONT></td>
-<td><FONT SIZE=2>Initials</FONT></td>
-<td><FONT SIZE=2>Given Names*</FONT></td>
-<td><FONT SIZE=2>Surname*</FONT></td>
-<td><FONT SIZE=2>Prefered Name</FONT></td>
-</tr>
-
-<tr><td>&nbsp; </TD></TR>
-<tr valign=top bgcolor=white>
-<td colspan=2>
-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
-</td>
-<td colspan=2><input type=text name=ethnicnotes size=40 ></td>
-<td>
-printend
-;
-} else {
- print "</td><td colspan=2>&nbsp;</td><td>\n";
-}
-($categories,$labels)=borrowercategories();
-print $input->popup_menu(-name=>'categorycode',
- -values=>$categories,
- -default=>$data->{'categorycode'},
- -labels=>$labels);
-
-
-
-my $ethnicitylabels='';
-if ($ethnicitycategoriescount>=0) {
- $ethnicitylabels=qq|
-<td colspan=2><FONT SIZE=2>Ethnicity</FONT></td>
-<td colspan=2><FONT SIZE=2>Ethnicity Notes</FONT></td>
-|;
-} else {
- $ethnicitylabels="<td colspan=2>&nbsp;</td><td colspan=2>&nbsp;</td>";
-}
-print <<printend
-
-</td>
-</tr>
-<tr valign=top bgcolor=white>
-$ethnicitylabels
-<td><FONT SIZE=2>Membership Category*</FONT></td>
-</tr>
-<tr><td>&nbsp; </TD></TR>
-
-<tr valign=top bgcolor="99cc33" ><td COLSPAN=5 background="/images/background-mem.gif">
-<B>MEMBER ADDRESS</b></td></tr>
-<tr valign=top bgcolor=white>
-<td COLSPAN=3><input type=text name=address size=40 value="$data->{'streetaddress'}">
-<td><input type=text name=city size=20 value="$data->{'city'}"></td>
-<td>
-<SELECT NAME="area" SIZE="1">
-printend
-;
-
-print "
-<OPTION value=L";
-if ($data->{'area'} eq 'L'){
- print " Selected";
-}
-print ">L - Levin
-<OPTION value=F";
-if ($data->{'area'} eq 'F'){
- print " Selected";
-}
-print ">F - Foxton
-<OPTION value=S";
-if ($data->{'area'} eq 'S'){
- print " Selected";
-}
-print ">S - Shannon
-<OPTION value=H";
-if ($data->{'area'} eq 'H'){
- print " Selected";
-}
-print ">H - Horowhenua
-<OPTION value=K";
-if ($data->{'area'} eq 'K'){
- print " Selected";
-}
-print ">K - Kapiti
-<OPTION value=O";
-if ($data->{'area'} eq 'O'){
- print " Selected";
-}
-print ">O - Out of District
-<OPTION value=X";
-if ($data->{'area'} eq 'X'){
- print " Selected";
-}
-print ">X - Temporary Visitor
-<OPTION value=Z";
-if ($data->{'area'} eq 'Z'){
- print " Selected";
-}
-print ">Z - Interloan Libraries
-<OPTION value=V";
-if ($data->{'area'} eq 'V'){
- print " Selected";
-}
-print ">V - Villlage";
-print <<printend
-</SELECT></td></tr>
-<tr valign=top bgcolor=white>
-<td COLSPAN=3><FONT SIZE=2>Postal Address*</FONT></td>
-<td><FONT SIZE=2>Town*</FONT></td>
-<td><FONT SIZE=2>Area</FONT></td>
-</tr>
-<tr><td>&nbsp; </TD></TR>
-<tr valign=top bgcolor=white>
-
-<td COLSPAN=3><input type=text name=streetaddress size=40 value="$data->{'physstreet'}"></td>
-<td><input type=text name=streetcity size=20 value="$data->{'streetcity'}"></td>
-</tr>
-</tr>
-<tr valign=top bgcolor=white>
-
-<td COLSPAN=3><FONT SIZE=2>Street Address if different</FONT></td>
-<td><FONT SIZE=2>Town</FONT></td>
-</tr>
-<tr><td>&nbsp; </TD></TR>
-<tr valign=top bgcolor="99cc33" ><td COLSPAN=5 background="/images/background-mem.gif">
-<B>MEMBER CONTACT DETAILS</b></td></tr>
-
-
-<tr valign=top bgcolor=white>
-<td COLSPAN=2 ><input type=text name=phone size=20 value="$data->{'phone'}"></td>
-<td><input type=text name=phoneday size=20 value="$data->{'phoneday'}"></td>
-<td><input type=text name=faxnumber size=20 value="$data->{'faxnumber'}"></td>
-<td><input type=text name=emailaddress size=20 value="$data->{'emailaddress'}"></td></tr>
-
-<tr valign=top bgcolor=white>
-<td COLSPAN=2 ><FONT SIZE=2>Phone (Home)</td>
-<td><FONT SIZE=2>Phone (day)</td>
-<td><FONT SIZE=2>Fax</td>
-<td><FONT SIZE=2>Email</td></tr>
-<tr><td>&nbsp; </TD></TR>
-<tr valign=top bgcolor="99cc33" ><td COLSPAN=5 background="/images/background-mem.gif">
-<B>ALTERNATE CONTACT DETAILS</b> </td></tr>
-
-<tr valign=top bgcolor=white>
-<td COLSPAN=3 ><input type=text name=contactname size=40 value="$data->{'contactname'}"></td>
-<td><input type=text name=altphone size=20 value="$data->{'altphone'}"></td>
-<td><select name=altrelationship size=1>
-<option value="workplace"
-printend
-;
-if ($data->{'altrelationship'} eq 'workplace'){
- print " selected ";
-}
-
-print ">Workplace
-<option value=\"relative\"";
-if ($data->{'altrelationship'} eq 'relative'){
- print " selected ";
-}
-print ">Relative
-<option value=\"friend\"";
-if ($data->{'altrelationship'} eq 'workplace'){
- print " selected ";
-}
-print ">Friend
-<option value=\"neighbour\"";
-if ($data->{'altrelationship'} eq 'workplace'){
- print " selected ";
-}
-print <<printend
->Neighbour
-</select></td></tr>
-
-<tr valign=top bgcolor=white>
-<td COLSPAN=3 ><FONT SIZE=2>Name*</td>
-<td><FONT SIZE=2>Phone</td>
-<td><FONT SIZE=2>Relationship*</td></tr>
-
-
-
-<tr><td>&nbsp; </TD></TR>
-
-
-<tr valign=top bgcolor=white>
-
-<td><FONT SIZE=2>Notes</font></td>
-<td COLSPAN=4><textarea name=altnotes wrap=physical cols=70 rows=3>$data->{'altnotes'}</textarea></td></tr>
-</tr>
-
-
-<tr><td>&nbsp; </TD></TR>
-
-
-<tr valign=top bgcolor="99cc33" >
-
-<td COLSPAN=5 background="/images/background-mem.gif"><B>LIBRARY USE</B></td>
-</tr>
-
-
-<tr valign=top >
-
-<td><FONT SIZE=2>Notes</font></td>
-<td COLSPAN=4><textarea name=borrowernotes wrap=physical cols=70 rows=3>$data->{'borrowernotes'}</textarea></td></tr>
-<tr><td>&nbsp; </TD></TR>
-<tr valign=top bgcolor=white><td COLSPAN=5 align=right >
-printend
-;
-if ($modify){
- print <<printend
- <tr><td><Font size=2>FLAGS</font></td></tr>
- <tr><td>Gone No Address</td>
- <td><input type=radio name=gna value=1
-printend
-;
- if ($data->{'gonenoaddress'} eq '1'){
- print " checked";
- }
- print ">Yes <input type=radio name=gna value=0";
- if ($data->{'gonenoaddress'} eq '0'){
- print " checked";
- }
- print ">No</td></tr>\n";
- print "<tr><td>Lost</td><td><input type=radio name=lost value=1";
- if ($data->{'lost'} eq '1'){
- print " checked";
- }
- print ">Yes<input type=radio name=lost value=0";
- if ($data->{'lost'} eq '0'){
- print " checked";
- }
- print ">No</td></tr>\n";
- print "<tr><td>Debarred</td><td><input type=radio name=debarred value=1";
- if ($data->{'debarred'} eq '1'){
- print " checked";
- }
- print ">Yes<input type=radio name=debarred value=0";
- if ($data->{'debarred'} eq '0'){
- print " checked";
- }
- print ">No</td></tr>\n";
-}
-if ($type ne 'modify'){
- print <<printend
-<tr><td></td><td><input type=image src="/images/save-changes.gif" WIDTH=188 HEIGHT=44 ALT="Add New Member" border=0 ></td>
-printend
-;
-} else {
-print <<printend
-<td><td></td><td><input type=image src="/images/save-changes.gif" WIDTH=188 HEIGHT=44 ALT="Add New Member" border=0 ></td>
-printend
-;
-}
-print <<printend
-</form>
-</tr>
-</TABLE>
-</table>
- </form>
-
-
+ if ($modify){
+ $template->param( modify => 1 );
+ }
+
+ $template->param( startmenumember => join ('', startmenu('member')),
+ endmenumember => join ('', endmenu('member')),
+ member => $member,
+ firstname => $data->{'firstname'},
+ surname => $data->{'surname'},
+ othernames => $data->{'othernames'},
+ initials => $data->{'initials'},
+ ethcatpopup => $ethcatpopup,
+ catcodepopup => $catcodepopup,
+ streetaddress => $data->{'physstreet'},
+ streetcity => $data->{'streetcity'},
+ city => $data->{'city'},
+ phone => $data->{'phone'},
+ phoneday => $data->{'phoneday'},
+ faxnumber => $data->{'faxnumber'},
+ emailaddress => $data->{'emailaddress'},
+ contactname => $data->{'contactname'},
+ altphone => $data->{'altphone'},
+ altnotes => $data->{'altnotes'},
+ borrowernotes => $data->{'borrowernotes'},
+ flagloop => \@flagdata,
+ relshiploop => \@relshipdata,
+ titleloop => \@titledata,
+ arealoop => \@areadata,
+ dateenrolled => $data->{'dateenrolled'},
+ expiry => $data->{'expiry'},
+ cardnumber => $cardnumber,
+ dateofbirth => $data->{'dateofbirth'});
+
+ print "Content-Type: text/html\n\n", $template->output;
+
-printend
-;
-print endmenu('member');
-print endpage();
}

0 comments on commit 0f24c70

Please sign in to comment.
Something went wrong with that request. Please try again.