X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=moremember.pl;h=b838559e3b67a6087e84966719c26001dcddd4b1;hb=e339f5d64ba06180925f551da12fd5a8cdffd444;hp=7e1ed589f7df1cb8b3a13364462ec3b8dd2882d5;hpb=5849a03b30119d7b20f086ce8a535b951df6f9bd;p=koha_fer diff --git a/moremember.pl b/moremember.pl index 7e1ed589f7..b838559e3b 100755 --- a/moremember.pl +++ b/moremember.pl @@ -1,312 +1,211 @@ #!/usr/bin/perl -#script to do a borrower enquiery/brin up borrower details etc -#written 20/12/99 by chris@katipo.co.nz -#Displays all the detailas about a borrower -#needs html removed and to use the C4::Output more, but its tricky -#last modified 21/1/2000 by chris@katipo.co.nz -#modifiecd 31/1/2001 by chris@katipo.co.nz to not allow items on request -#to be renewed +# $Id$ + +# script to do a borrower enquiry/bring up borrower details etc +# Displays all the details about a borrower +# written 20/12/99 by chris@katipo.co.nz +# last modified 21/1/2000 by chris@katipo.co.nz +# modified 31/1/2001 by chris@katipo.co.nz +# to not allow items on request to be renewed +# +# needs html removed and to use the C4::Output more, but its tricky +# + + +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + use strict; +use C4::Auth; +use C4::Context; use C4::Output; +use C4::Interface::CGI::Output; +use C4::Interface::CGI::Template; use CGI; use C4::Search; use Date::Manip; +use C4::Date; use C4::Reserves2; use C4::Circulation::Renewals2; use C4::Circulation::Circ2; +use C4::Koha; +use HTML::Template; + +my $dbh = C4::Context->dbh; + my $input = new CGI; + +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "members/moremember.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + debug => 1, + }); + my $bornum=$input->param('bornum'); -my %env; -print $input->header; #start the page and read in includes -print startpage(); -print startmenu('member'); + my $data=borrdata('',$bornum); -my @temp=split('-',$data->{'dateenrolled'}); -$data->{'dateenrolled'}="$temp[2]/$temp[1]/$temp[0]"; -@temp=split('-',$data->{'expiry'}); -$data->{'expiry'}="$temp[2]/$temp[1]/$temp[0]"; -@temp=split('-',$data->{'dateofbirth'}); -$data->{'dateofbirth'}="$temp[2]/$temp[1]/$temp[0]"; -if ($data->{'ethnicity'} eq 'maori'){ - $data->{'ethnicity'} = 'Maori'; -} -if ($data->{'ethnicity'}eq 'european'){ - $data->{'ethnicity'} = 'European/Pakeha'; -} -if ($data->{'ethnicity'}eq 'pi'){ - $data->{'ethnicity'} = 'Pacific Islander'; -} -if ($data->{'ethnicity'}eq 'asian'){ - $data->{'ethnicity'} = 'Asian'; -} -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'}; - $data->{'city'}=$data2->{'city'}; - $data->{'physstreet'}=$data2->{'phystreet'}; - $data->{'streetcity'}=$data2->{'streetcity'}; - $data->{'phone'}=$data2->{'phone'}; - $data->{'phoneday'}=$data2->{'phoneday'}; -} -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'}

-Ethnicity: $data->{'ethnicity'}, $data->{'ethnotes'}
-DoB: $data->{'dateofbirth'}
-Sex: $data->{'sex'}

+$template->param($data->{'categorycode'} => 1); # in template => instutitional (A for Adult & C for children) -Alternative Contact:$data->{'contactname'}
-Phone: $data->{'altphone'}
-Relationship: $data->{'altrelationship'}
-Notes: $data->{'altnotes'}

-printend -; +$data->{'dateenrolled'} = format_date($data->{'dateenrolled'}); +$data->{'expiry'} = format_date($data->{'expiry'}); +$data->{'dateofbirth'} = format_date($data->{'dateofbirth'}); +$data->{'IS_ADULT'} = ($data->{'categorycode'} ne 'I'); -if ($data->{'categorycode'} ne 'C'){ - print " Guarantees:"; - my ($count,$guarantees)=findguarantees($data->{'borrowernumber'}); - for (my $i=0;$i<$count;$i++){ - print "[$i]->{'borrowernumber'}\">$guarantees->[$i]->{'cardnumber'}
"; - } -} else { - print "Guarantor:"; - my ($guarantor)=findguarantor($data->{'borrowernumber'}); - if ($guarantor->{'borrowernumber'} == 0){ - print "no guarantor
"; - } else { - print "{'borrowernumber'}\">$guarantor->{'cardnumber'}
"; - } +$data->{'ethnicity'} = fixEthnicity($data->{'ethnicity'}); + +$data->{&expand_sex_into_predicate($data->{'sex'})} = 1; + +if ($data->{'categorycode'} eq 'C'){ + my $data2=borrdata('',$data->{'guarantor'}); + $data->{'streetaddress'}=$data2->{'streetaddress'}; + $data->{'city'}=$data2->{'city'}; + $data->{'physstreet'}=$data2->{'physstreet'}; + $data->{'streetcity'}=$data2->{'streetcity'}; + $data->{'phone'}=$data2->{'phone'}; + $data->{'phoneday'}=$data2->{'phoneday'}; + $data->{'zipcode'} = $data2->{'zipcode'}; } -print < +if ($data->{'ethnicity'} || $data->{'ethnotes'}) { + $template->param(printethnicityline => 1); +} -General Notes: -$data->{'borrowernotes'} -

-

- - +if ($data->{'categorycode'} ne 'C'){ + $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++){ + push (@guaranteedata, {borrowernumber => $guarantees->[$i]->{'borrowernumber'}, + cardnumber => $guarantees->[$i]->{'cardnumber'}, + name => $guarantees->[$i]->{'firstname'} . " " . $guarantees->[$i]->{'surname'}}); + } + $template->param(guaranteeloop => \@guaranteedata); - -

+} else { + my ($guarantor)=findguarantor($data->{'borrowernumber'}); + unless ($guarantor->{'borrowernumber'} == 0){ + $template->param(guarantorborrowernumber => $guarantor->{'borrowernumber'}, guarantorcardnumber => $guarantor->{'cardnumber'}); + } +} -
- - - - - -printend -; my %bor; $bor{'borrowernumber'}=$bornum; + +# FIXME +# it looks like $numaccts is a temp variable and that the +# for (my $i;$i<$numaccts;$i++) +# can be turned into a foreach loop instead +# 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; - if ($amount2 != 0){ - print ""; - my $item="   "; - @temp=split('-',$accts->[$i]{'date'}); - $accts->[$i]{'date'}="$temp[2]/$temp[1]/$temp[0]"; - if ($accts->[$i]{'accounttype'} ne 'Res'){ - #get item data - #$item= - } - print ""; -# print ""; - print " - - "; - } + my $amount= $accts->[$i]{'amount'} + 0.00; + my $amount2= $accts->[$i]{'amountoutstanding'} + 0.00; + my %row = %$accts->[$i]; + if ($amount2 != 0){ + my $item="   "; + $row{'date'} = format_date($accts->[$i]{'date'}); + + if ($accts->[$i]{'accounttype'} ne 'Res'){ + #get item data + #$item= + } + + # FIXME + # why set this variable if it's not going to be used? + # + my $env; + if ($accts->[$i]{'accounttype'} ne 'Res'){ + my $iteminfo=C4::Circulation::Circ2::getiteminformation($env,$accts->[$i]->{'itemnumber'},''); + # FIXME, seems to me $iteminfo gets not defined + %row = (%row , %$iteminfo) if $iteminfo; + } + } + push (@accountdata, \%row); } -print < - - - - - -
FINES & CHARGES
$accts->[$i]{'date'}$accts->[$i]{'accounttype'}"; - 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'}"; - } - 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(\%env,$issue->[$i]{'itemnumber'},$bornum); - print ""; - print ""; - -# if ($datedue < $today){ -# print ""; -# } else { -# print ""; -# } - #check item is not reserved - my ($rescount,$reserves)=Findgroupreserve($issue->[$i]{'biblionumber'},''); - if ($rescount >0){ - print ""; -# } elsif ($issue->[$i]->{'renewals'} > 0) { -# print ""; - } else { - print " - - "; - } + my $datedue=ParseDate($issue->[$i]{'date_due'}); + $issue->[$i]{'date_due'} = format_date($issue->[$i]{'date_due'}); + my %row = %{$issue->[$i]}; + if ($datedue < $today){ + $row{'red'}=1; #print ""; + } + #find the charge for an item + # FIXME - This is expecting + # &C4::Circulation::Renewals2::calc_charges, but it's getting + # &C4::Circulation::Circ2::calc_charges, which only returns one + # element, so itemtype isn't being set. + # But &C4::Circulation::Renewals2::calc_charges doesn't appear to + # return the correct item type either (or a properly-formatted + # charge, for that matter). + my ($charge,$itemtype)=calc_charges(undef,$dbh,$issue->[$i]{'itemnumber'},$bornum); + $row{'itemtype'}=$itemtype; + $row{'charge'}=$charge; + + #check item is not reserved + my ($restype,$reserves)=CheckReserves($issue->[$i]{'itemnumber'}); + if ($restype){ + print ""; + # } elsif ($issue->[$i]->{'renewals'} > 0) { + # print ""; + } else { + $row{'norenew'}=0; + } + push (@issuedata, \%row); } -print < - - - - - -
ITEMS CURRENTLY ON ISSUE
TitleDueItemtypeChargeRenew
"; - my $datedue=ParseDate($issue->[$i]{'date_due'}); - @temp=split('-',$issue->[$i]{'date_due'}); - $issue->[$i]{'date_due'}="$temp[2]/$temp[1]/$temp[0]"; - if ($datedue < $today){ - print ""; - } - print "$issue->[$i]{'title'} - [$i]->{'itemnumber'}&bib=$issue->[$i]->{'biblionumber'}&bi=$issue->[$i]->{'biblioitemnumber'}> - $issue->[$i]{'barcode'}$issue->[$i]{'date_due'}$itemtype$chargeOverdue   [$i]{'biblionumber'}>On Request - no renewals
Previously Renewed - no renewals
"; - - print "[$i]{'itemnumber'}\" value=y>Y - [$i]{'itemnumber'}\" value=n>N
[$i]{'biblionumber'}>On Request - no renewals
Previously Renewed - no renewals
- -
- -

- - - - - - - - - - - - - - - - - - - - -printend -; my ($rescount,$reserves)=FindReserves('',$bornum); #From C4::Reserves2 -for (my $i=0;$i<$rescount;$i++){ - @temp=split('-',$reserves->[$i]{'reservedate'}); - $reserves->[$i]{'reservedate'}="$temp[2]/$temp[1]/$temp[0]"; - print " - - - [$i]{'biblionumber'}> - - - - "; -} -print < - - -
ITEMS REQUESTED
TitleRequestedChargeRemove
[$i]{'biblionumber'}\">$reserves->[$i]{'btitle'}$reserves->[$i]{'reservedate'} -
-
- -

- -

-printend -; +my @reservedata; +foreach my $reserveline (@$reserves) { + $reserveline->{'reservedate2'} = format_date($reserveline->{'reservedate'}); + my $restitle; + my %row = %$reserveline; + if ($reserveline->{'constrainttype'} eq 'o'){ + $restitle=getreservetitle($reserveline->{'biblionumber'},$reserveline->{'borrowernumber'},$reserveline->{'reservedate'},$reserveline->{'rtimestamp'}); + %row = (%row , %$restitle) if $restitle; + } + push (@reservedata, \%row); +} +$template->param($data); +$template->param( + bornum => $bornum, + accountloop => \@accountdata, + issueloop => \@issuedata, + reserveloop => \@reservedata); -print endmenu('member'); -print endpage(); +output_html_with_http_headers $input, $cookie, $template->output;