From: dnmeid Date: Mon, 30 Sep 2002 14:16:34 +0000 (+0000) Subject: templatified X-Git-Tag: R_1-3-1~187 X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=commitdiff_plain;h=0379fec072d796307f30b94111e407abf4152497;p=koha_gimpoz templatified --- diff --git a/moremember.pl b/moremember.pl index 5126c18690..f37893fdcd 100755 --- a/moremember.pl +++ b/moremember.pl @@ -38,20 +38,21 @@ use C4::Circulation::Renewals2; use C4::Circulation::Circ2; use C4::Koha; use C4::Database; +use HTML::Template; my $dbh=C4Connect; my $input = new CGI; -my $bornum=$input->param('bornum'); +my $theme = $input->param('theme'); # only used if allowthemeoverride is set +my %tmpldata = pathtotemplate ( template => 'moremember.tmpl', theme => $theme ); +my $template = HTML::Template->new(filename => $tmpldata{'path'}, die_on_bad_params => 0); -print $input->header; +my $bornum=$input->param('bornum'); #start the page and read in includes -print startpage(); -print startmenu('member'); -my $data=borrdata('',$bornum); +my $data=borrdata('',$bornum); $data->{'dateenrolled'} = slashifyDate($data->{'dateenrolled'}); $data->{'expiry'} = slashifyDate($data->{'expiry'}); @@ -59,25 +60,6 @@ $data->{'dateofbirth'} = slashifyDate($data->{'dateofbirth'}); $data->{'ethnicity'} = fixEthnicity($data->{'ethnicity'}); -print <$data->{'firstname'} $data->{'surname'}

-

-

- - - - - - -
MEMBERSHIP RECORD
-

- -{'borrowernumber'}> - -


-$data->{'title'} $data->{'othernames'} $data->{'surname'} ($data->{'firstname'}, $data->{'initials'})

- -Card Number: $data->{'cardnumber'}
-printend -; if ($data->{'categorycode'} eq 'C'){ my $data2=borrdata('',$data->{'guarantor'}); $data->{'streetaddress'}=$data2->{'streetaddress'}; @@ -87,79 +69,33 @@ if ($data->{'categorycode'} eq 'C'){ $data->{'phone'}=$data2->{'phone'}; $data->{'phoneday'}=$data2->{'phoneday'}; } -my $ethnicityline=''; + + if ($data->{'ethnicity'} || $data->{'ethnotes'}) { - $ethnicityline="Ethnicity: $data->{'ethnicity'}, $data->{'ethnotes'}
"; + $template->param(printethnicityline => 1); } -print <{'streetaddress'}, $data->{'city'}
-Home Address: $data->{'physstreet'}, $data->{'streetcity'}
-Phone (Home): $data->{'phone'}
-Phone (Daytime): $data->{'phoneday'}
-Fax: $data->{'faxnumber'}
-E-mail: $data->{'emailaddress'}
-Textmessaging:$data->{'textmessaging'}

-Membership Number: $data->{'borrowernumber'}
-Membership: $data->{'categorycode'}
-Area: $data->{'area'}
-Fee:$30/year, Paid
-Joined: $data->{'dateenrolled'}, Expires: $data->{'expiry'}
-Joining Branch: $data->{'homebranch'}

-$ethnicityline -DoB: $data->{'dateofbirth'}
-Sex: $data->{'sex'}

- -Alternative Contact:$data->{'contactname'}
-Phone: $data->{'altphone'}
-Relationship: $data->{'altrelationship'}
-Notes: $data->{'altnotes'}

-printend -; if ($data->{'categorycode'} ne 'C'){ - print " Guarantees:"; + $template->param(isguarantee => 1); # FIXME # It looks like the $i is only being returned to handle walking through # the array, which is probably better done as a foreach loop. # my ($count,$guarantees)=findguarantees($data->{'borrowernumber'}); + my @guaranteedata; for (my $i=0;$i<$count;$i++){ - print "[$i]->{'borrowernumber'}\">$guarantees->[$i]->{'cardnumber'}
"; + push (@guaranteedata, {borrowernumber => $guarantees->[$i]->{'borrowernumber'}, + cardnumber => $guarantees->[$i]->{'cardnumber'}}); } + $template->param(guaranteeloop => \@guaranteedata); + } else { - print "Guarantor:"; my ($guarantor)=findguarantor($data->{'borrowernumber'}); - if ($guarantor->{'borrowernumber'} == 0){ - print "no guarantor
"; - } else { - print "{'borrowernumber'}\">$guarantor->{'cardnumber'}
"; + unless ($guarantor->{'borrowernumber'} == 0){ + $template->param(guarantorborrowernumber => $guarantor->{'borrowernumber'}, guarantorcardnumber => $guarantor->{'cardnumber'}); } } -print < - -General Notes: -$data->{'borrowernotes'} -

-

- - - - -

- -
- - - - - -printend -; my %bor; $bor{'borrowernumber'}=$bornum; @@ -172,23 +108,19 @@ my ($numaccts,$accts,$total)=getboracctrecord('',\%bor); #if ($numaccts > 10){ # $numaccts=10; #} +my @accountdata; for (my$i=0;$i<$numaccts;$i++){ -#if ($accts->[$i]{'accounttype'} ne 'Pay'){ my $amount= $accts->[$i]{'amount'} + 0.00; - my $amount2= $accts->[$i]{'amountoutstanding'} + 0.00; + my $amount2= $accts->[$i]{'amountoutstanding'} + 0.00; + my %row = %$accts->[$i]; if ($amount2 != 0){ - print ""; - my $item="   "; - - $accts->[$i]{'date'} = slashifyDate($accts->[$i]{'date'}); + my $item="   "; + $row{'date'} = slashifyDate($accts->[$i]{'date'}); if ($accts->[$i]{'accounttype'} ne 'Res'){ - #get item data - #$item= + #get item data + #$item= } - print ""; -# print ""; - print " - - "; } + push (@accountdata, \%row); } -print < - - - - -
FINES & CHARGES
$accts->[$i]{'date'}$accts->[$i]{'accounttype'}"; # FIXME # why set this variable if it's not going to be used? @@ -196,72 +128,28 @@ for (my$i=0;$i<$numaccts;$i++){ my $env; if ($accts->[$i]{'accounttype'} ne 'Res'){ my $iteminfo=C4::Circulation::Circ2::getiteminformation($env,$accts->[$i]->{'itemnumber'},''); - print "[$i]->{'itemnumber'}&bib=$iteminfo->{'biblionumber'}&bi=$iteminfo->{'biblioitemnumber'}>$accts->[$i]->{'description'} $accts->[$i]{'title'}"; + # FIXME, seems to me $iteminfo gets not defined + %row = (%row , %$iteminfo) if $iteminfo; } - print "$amount$amount2
- - - -
- -

-

- - - - - - - - - - - - - - - -printend -; my ($count,$issue)=borrissues($bornum); my $today=ParseDate('today'); +my @issuedata; for (my $i=0;$i<$count;$i++){ - print " - - "; #find the charge for an item my ($charge,$itemtype)=calc_charges(undef,$dbh,$issue->[$i]{'itemnumber'},$bornum); - print ""; - print ""; + $row{'itemtype'}=$itemtype; + $row{'charge'}=$charge; -# if ($datedue < $today){ -# print ""; -# } else { -# print ""; -# } #check item is not reserved my ($restype,$reserves)=CheckReserves($issue->[$i]{'itemnumber'}); if ($restype){ @@ -269,50 +157,10 @@ for (my $i=0;$i<$count;$i++){ # } elsif ($issue->[$i]->{'renewals'} > 0) { # print ""; } else { - print " - - "; + $row{'norenew'}=0; } + push (@issuedata, \%row); } -print < - - - - - -
ITEMS CURRENTLY ON ISSUE
TitleDueItemtypeChargeRenew
"; - my $datedue=ParseDate($issue->[$i]{'date_due'}); - + my $datedue=ParseDate($issue->[$i]{'date_due'}); $issue->[$i]{'date_due'} = slashifyDate($issue->[$i]{'date_due'}); - + my %row = %$issue->[$i]; if ($datedue < $today){ - print ""; + $row{'red'}=1; #print ""; } - print "$issue->[$i]{'title'} - [$i]->{'itemnumber'}&bib=$issue->[$i]->{'biblionumber'}&bi=$issue->[$i]->{'biblioitemnumber'}> - $issue->[$i]{'barcode'}$issue->[$i]{'date_due'}$itemtype$chargeOverdue   Previously Renewed - no renewals
"; - - print "[$i]{'itemnumber'}\" value=y>Y - [$i]{'itemnumber'}\" value=n>N
- -
- - -

- - - - - - - - - - - - - - - - - - - - -printend -; my ($rescount,$reserves)=FindReserves('',$bornum); #From C4::Reserves2 @@ -320,42 +168,26 @@ my ($rescount,$reserves)=FindReserves('',$bornum); #From C4::Reserves2 # does it make sense to turn this into a foreach my $i (0..$rescount) # kind of loop? # +my @reservedata; for (my $i=0;$i<$rescount;$i++){ $reserves->[$i]{'reservedate2'} = slashifyDate($reserves->[$i]{'reservedate'}); my $restitle; + my %row = %$reserves->[$i]; if ($reserves->[$i]{'constrainttype'} eq 'o'){ - $restitle=getreservetitle($reserves->[$i]{'biblionumber'},$reserves->[$i]{'borrowernumber'},$reserves->[$i]{'reservedate'},$reserves->[$i]{'timestamp'}); - } - print " - - - [$i]{'biblionumber'}> - - - - "; + $restitle=getreservetitle($reserves->[$i]{'biblionumber'},$reserves->[$i]{'borrowernumber'},$reserves->[$i]{'reservedate'},$reserves->[$i]{'timestamp'}); + %row = (%row , %$restitle); + } + push (@reservedata, \%row); } -print < - - -
ITEMS REQUESTED
TitleRequestedRemove
[$i]{'biblionumber'}\">$reserves->[$i]{'btitle'} $restitle->{'volumeddesc'} $restitle->{'itemtype'}$reserves->[$i]{'reservedate2'} -
-
- -

- -

-printend -; - -print endmenu('member'); -print endpage(); +$dbh->disconnect; +$template->param($data); +$template->param(startmenumember => join('', startmenu('member')), + endmenumember => join('', endmenu('member')), + bornum => $bornum, + accountloop => \@accountdata, + issueloop => \@issuedata, + reserveloop => \@reservedata); -$dbh->disconnect; +print "Content-Type: text/html\n\n", $template->output; diff --git a/overdue.pl b/overdue.pl index c3e2301471..d736f4d152 100755 --- a/overdue.pl +++ b/overdue.pl @@ -22,13 +22,15 @@ use strict; use C4::Output; use CGI; use C4::Database; +use HTML::Template; my $input = new CGI; -print $input->header; my $type=$input->param('type'); -print startpage(); -print startmenu('report'); +my $theme = $input->param('theme'); # only used if allowthemeoverride is set +my %tmpldata = pathtotemplate ( template => 'overdue.tmpl', theme => $theme); +my $template = HTML::Template->new( filename => $tmpldata{'path'}, + die_on_bad_params => 0); my $duedate; my $bornum; my $itemnum; @@ -44,24 +46,13 @@ my $author; my @datearr = localtime(time()); my $todaysdate = (1900+$datearr[5]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.sprintf ("%0.2d", $datearr[3]); -print "Items Overdue as of $todaysdate

"; - -print << "EOF"; - - - - - - - - -EOF - my $dbh=C4Connect; my $query="select date_due,borrowernumber,itemnumber from issues where isnull(returndate) && date_due<'$todaysdate' order by date_due,borrowernumber"; my $sth=$dbh->prepare($query); $sth->execute; + +my @overduedata; while (my $data=$sth->fetchrow_hashref) { $duedate=$data->{'date_due'}; $bornum=$data->{'borrowernumber'}; @@ -90,18 +81,24 @@ while (my $data=$sth->fetchrow_hashref) { $title=$data3->{'title'}; $author=$data3->{'author'}; $sth3->finish; + push (@overduedata, { duedate => $duedate, + bornum => $bornum, + itemnum => $itemnum, + name => $name, + phone => $phone, + email => $email, + biblionumber => $biblionumber, + title => $title, + author => $author }); - if (!$email){ - print ""; - } else { - print ""; - } } $sth->finish; $dbh->disconnect; -print "
Due DatePatronPhoneTitleAuthor
$duedate$name$phone$title$author
$duedate$name$phone$title$author
"; - -print endmenu('report'); -print endpage(); +$template->param( startmenureport => join ('', startmenu('report')), + endmenureport => join ('', endmenu('report')), + todaysdate => $todaysdate, + overdueloop => \@overduedata ); + +print "Content-Type: text/html\n\n", $template->output;