From 0f24c709006dd90652d3ccf26303b3a9ff355fcf Mon Sep 17 00:00:00 2001 From: dnmeid Date: Tue, 17 Sep 2002 15:08:42 +0000 Subject: [PATCH] templatified:set templatedirectory in koha.conf to use the templates --- boraccount.pl | 73 ++---- imemberentry.pl | 138 +---------- jmemberentry.pl | 189 ++++----------- member.pl | 70 +++--- memberentry.pl | 603 +++++++++++++++--------------------------------- 5 files changed, 301 insertions(+), 772 deletions(-) diff --git a/boraccount.pl b/boraccount.pl index 2b345df7b6..704f41200a 100755 --- a/boraccount.pl +++ b/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 strict; 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 <Account for $data->{'firstname'} $data->{'surname'}

- -   -

-

- - - - - - - -printend -; for (my $i=0;$i<$numaccts;$i++){ $accts->[$i]{'amount'}+=0.00; $accts->[$i]{'amountoutstanding'}+=0.00; - print < - - - - -printend -; + push(@accountrows, \%row); } -print < - - - - - - -
FINES & CHARGESAMOUNTSTILL OWING
$accts->[$i]{'date'}$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 < - $accts->[$i]{'amount'}$accts->[$i]{'amountoutstanding'}
Total Due$total
-
-

 

-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; \ No newline at end of file diff --git a/imemberentry.pl b/imemberentry.pl index f1c0ccecf9..4910ce04a9 100755 --- a/imemberentry.pl +++ b/imemberentry.pl @@ -25,142 +25,24 @@ use strict; 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 < - -Add New Institution
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Member# $member, Card Number*
-
 
-INSTITUTION DETAILS - -
Institution Name
 
- INSTITUTION ADDRESS
- -
Postal Address*Town*Area
 
- CONTACT DETAILS
Contact Name*
Phone (day)FaxEmail
 
Notes
 
LIBRARY USE
 
Notes
-
- -
- - - -
- -

 

- +$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; diff --git a/jmemberentry.pl b/jmemberentry.pl index 75c986e591..48212fc553 100755 --- a/jmemberentry.pl +++ b/jmemberentry.pl @@ -25,160 +25,65 @@ use strict; 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 < - -Add New Junior Member
-
- - - - - - - - - - - - - - -{'altphone'}"> - - - - - - - - - - - - - - - - - - - - +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 -; + my %row; + $row{'cmember'}=$cmember1+$i; + $row{'i'}=$i; + $row{'count'}=$i+1; + push(@cmemdata, \%row); } -print < - -
-
-PARENT OR GUARDIAN
-
TitleGiven Names*Surname*Membership No.
 
-CHILD $count
-Member# $cmember, Card Number*
- -
- - - F - M* - -
Given Names*Surname*Date of Birth
(dd/mm/yy)*
 School
Notes
 
-
- - -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; diff --git a/member.pl b/member.pl index 8e7fc43199..ace4d02790 100755 --- a/member.pl +++ b/member.pl @@ -25,54 +25,44 @@ use strict; 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 <"; -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 < -
-Adult -Organisation - -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; diff --git a/memberentry.pl b/memberentry.pl index 815643ecc5..68093c7c26 100755 --- a/memberentry.pl +++ b/memberentry.pl @@ -27,432 +27,211 @@ use CGI; 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 -; -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 { # 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
"; - $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
"; + $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 < - - - -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 < - - - - - - + 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(); } -- 2.39.5