[Koha-cvs] koha/members moremember.pl [rel_3_0]
Antoine Farnault
antoine at koha-fr.org
Fri Dec 1 18:14:16 CET 2006
CVSROOT: /sources/koha
Module name: koha
Branch: rel_3_0
Changes by: Antoine Farnault <toins> 06/12/01 17:14:16
Modified files:
members : moremember.pl
Log message:
this script need to use C4::Biblio;
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/members/moremember.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.28.2.12&r2=1.28.2.13
Patches:
Index: moremember.pl
===================================================================
RCS file: /sources/koha/koha/members/moremember.pl,v
retrieving revision 1.28.2.12
retrieving revision 1.28.2.13
diff -u -b -r1.28.2.12 -r1.28.2.13
--- moremember.pl 1 Dec 2006 16:54:47 -0000 1.28.2.12
+++ moremember.pl 1 Dec 2006 17:14:16 -0000 1.28.2.13
@@ -17,7 +17,7 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
-# $Id: moremember.pl,v 1.28.2.12 2006/12/01 16:54:47 btoumi Exp $
+# $Id: moremember.pl,v 1.28.2.13 2006/12/01 17:14:16 toins Exp $
=head1 moremember.pl
@@ -46,7 +46,7 @@
use C4::Circulation::Circ2;
use C4::Koha;
use C4::Letters;
-use HTML::Template;
+use C4::Biblio;
my $dbh = C4::Context->dbh;
@@ -54,126 +54,164 @@
my $print = $input->param('print');
my $template_name;
-if($print eq "page"){
+if ( $print eq "page" ) {
$template_name = "members/moremember-print.tmpl";
-} elsif($print eq "slip"){
+}
+elsif ( $print eq "slip" ) {
$template_name = "members/moremember-receipt.tmpl";
-} else {
+}
+else {
$template_name = "members/moremember.tmpl";
}
-my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => $template_name,
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => $template_name,
query => $input,
type => "intranet",
authnotrequired => 0,
- flagsrequired => {borrowers => 1},
+ flagsrequired => { borrowers => 1 },
debug => 1,
- });
+ }
+);
+
+my $borrowernumber = $input->param('borrowernumber');
-my $borrowernumber=$input->param('borrowernumber');
#start the page and read in includes
-my $data=borrdata('',$borrowernumber);
-my $reregistration=$input->param('reregistration');
+my $data = borrdata( '', $borrowernumber );
+my $reregistration = $input->param('reregistration');
+
# re-reregistration function to automatic calcul of date expiry
-($data->{'dateexpiry'}=GetMembeReregistration($data->{'categorycode'},$borrowernumber,$data->{'dateenrolled'}))if ($reregistration eq 'y');
-my (undef,undef,undef,$category_type)=getborrowercategory($data->{'categorycode'});
-$template->param($data->{'categorycode'} => 1); # in template <TMPL_IF name="I"> => instutitional (A for Adult & C for children)
-$data->{'dateenrolled'} = format_date($data->{'dateenrolled'});
-$data->{'dateexpiry'} = format_date($data->{'dateexpiry'});
-$data->{'dateofbirth'} = format_date($data->{'dateofbirth'});
-$data->{'IS_ADULT'} = ($data->{'categorycode'} ne 'I');
-
-if($data->{'debarred'} || $data->{'gonenoaddress'} || $data->{'lost'} || $data->{'borrowernotes'}){
- $template->param(flagged =>1);
-}
-
-$data->{'ethnicity'} = fixEthnicity($data->{'ethnicity'});
-
-$data->{&expand_sex_into_predicate($data->{'sex'})} = 1;
-
-if ($category_type eq 'C' and $data->{'guarantorid'} ne '0' ){
- my $data2=borrdata('',$data->{'guarantorid'});
- $data->{'address'}=$data2->{'address'};
- $data->{'city'}=$data2->{'city'};
- $data->{'B_address'}=$data2->{'B_address'};
- $data->{'B_city'}=$data2->{'B_city'};
- $data->{'phone'}=$data2->{'phone'};
- $data->{'mobile'}=$data2->{'mobile'};
+(
+ $data->{'dateexpiry'} = GetMembeReregistration(
+ $data->{'categorycode'},
+ $borrowernumber, $data->{'dateenrolled'}
+ )
+) if ( $reregistration eq 'y' );
+my ( undef, undef, undef, $category_type ) =
+ getborrowercategory( $data->{'categorycode'} );
+$template->param( $data->{'categorycode'} => 1 )
+ ; # in template <TMPL_IF name="I"> => instutitional (A for Adult & C for children)
+$data->{'dateenrolled'} = format_date( $data->{'dateenrolled'} );
+$data->{'dateexpiry'} = format_date( $data->{'dateexpiry'} );
+$data->{'dateofbirth'} = format_date( $data->{'dateofbirth'} );
+$data->{'IS_ADULT'} = ( $data->{'categorycode'} ne 'I' );
+
+if ( $data->{'debarred'}
+ || $data->{'gonenoaddress'}
+ || $data->{'lost'}
+ || $data->{'borrowernotes'} )
+{
+ $template->param( flagged => 1 );
+}
+
+$data->{'ethnicity'} = fixEthnicity( $data->{'ethnicity'} );
+
+$data->{ &expand_sex_into_predicate( $data->{'sex'} ) } = 1;
+
+if ( $category_type eq 'C' and $data->{'guarantorid'} ne '0' ) {
+ my $data2 = borrdata( '', $data->{'guarantorid'} );
+ $data->{'address'} = $data2->{'address'};
+ $data->{'city'} = $data2->{'city'};
+ $data->{'B_address'} = $data2->{'B_address'};
+ $data->{'B_city'} = $data2->{'B_city'};
+ $data->{'phone'} = $data2->{'phone'};
+ $data->{'mobile'} = $data2->{'mobile'};
$data->{'zipcode'} = $data2->{'zipcode'};
}
-if ($data->{'ethnicity'} || $data->{'ethnotes'}) {
- $template->param(printethnicityline => 1);
+if ( $data->{'ethnicity'} || $data->{'ethnotes'} ) {
+ $template->param( printethnicityline => 1 );
}
-if ($category_type eq 'A'){
- $template->param(isguarantee => 1);
+if ( $category_type eq 'A' ) {
+ $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 ( $count, $guarantees ) = findguarantees( $data->{'borrowernumber'} );
my @guaranteedata;
- for (my $i=0;$i<$count;$i++){
- push (@guaranteedata, {borrowernumber => $guarantees->[$i]->{'borrowernumber'},
+ for ( my $i = 0 ; $i < $count ; $i++ ) {
+ push(
+ @guaranteedata,
+ {
+ borrowernumber => $guarantees->[$i]->{'borrowernumber'},
cardnumber => $guarantees->[$i]->{'cardnumber'},
- name => $guarantees->[$i]->{'firstname'} . " " . $guarantees->[$i]->{'surname'}});
+ name => $guarantees->[$i]->{'firstname'} . " "
+ . $guarantees->[$i]->{'surname'}
}
- $template->param(guaranteeloop => \@guaranteedata);
- ($template->param(adultborrower=>1)) if ($category_type eq 'A');
+ );
+ }
+ $template->param( guaranteeloop => \@guaranteedata );
+ ( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' );
-} else {
- my ($guarantorid)=findguarantor($data->{'borrowernumber'});
- ($template->param(guarantor=>1)) if (($data->{'guarantorid'} > '0'));
- if ($guarantorid->{'borrowernumber'}){
- $template->param(guarantorborrowernumber => $guarantorid->{'borrowernumber'}, guarantorcardnumber => $guarantorid->{'cardnumber'},guarantorfirstname => $guarantorid->{'firstname'},guarantorsurname =>$guarantorid->{'surname'});
+}
+else {
+ my ($guarantorid) = findguarantor( $data->{'borrowernumber'} );
+ ( $template->param( guarantor => 1 ) )
+ if ( ( $data->{'guarantorid'} > '0' ) );
+ if ( $guarantorid->{'borrowernumber'} ) {
+ $template->param(
+ guarantorborrowernumber => $guarantorid->{'borrowernumber'},
+ guarantorcardnumber => $guarantorid->{'cardnumber'},
+ guarantorfirstname => $guarantorid->{'firstname'},
+ guarantorsurname => $guarantorid->{'surname'}
+ );
}
}
#Independant branches management
-my $unvalidlibrarian = ((C4::Context->preference("IndependantBranches")) && (C4::Context->userenv->{flags}!=1) && ($data->{'branchcode'} ne C4::Context->userenv->{branch}));
+my $unvalidlibrarian =
+ ( ( C4::Context->preference("IndependantBranches") )
+ && ( C4::Context->userenv->{flags} != 1 )
+ && ( $data->{'branchcode'} ne C4::Context->userenv->{branch} ) );
my %bor;
-$bor{'borrowernumber'}=$borrowernumber;
+$bor{'borrowernumber'} = $borrowernumber;
# Converts the branchcode to the branch name
my $samebranch;
-if (C4::Context->preference("IndependantBranches")) {
+if ( C4::Context->preference("IndependantBranches") ) {
my $userenv = C4::Context->userenv;
- unless ($userenv->{flags} == 1){
- $samebranch = ($data->{'branchcode'} eq $userenv->{branch});
+ unless ( $userenv->{flags} == 1 ) {
+ $samebranch = ( $data->{'branchcode'} eq $userenv->{branch} );
}
- $samebranch =1 if ($userenv->{flags} == 1);
+ $samebranch = 1 if ( $userenv->{flags} == 1 );
}
-$data->{'branchname'} = ((getbranchdetail($data->{'branchcode'}))->{'branchname'});
+$data->{'branchname'} =
+ ( ( getbranchdetail( $data->{'branchcode'} ) )->{'branchname'} );
# Converts the categorycode to the description
-($data->{'categorycode'},undef,undef) = &getborrowercategory($data->{'categorycode'});
+( $data->{'categorycode'}, undef, undef ) =
+ &getborrowercategory( $data->{'categorycode'} );
+
+my ( $numaccts, $accts, $total ) = getboracctrecord( '', \%bor );
+my $lib1 = &GetSortDetails( "Bsort1", $data->{'sort1'} );
+my $lib2 = &GetSortDetails( "Bsort2", $data->{'sort2'} );
+( $template->param( lib1 => $lib1 ) ) if ($lib1);
+( $template->param( lib2 => $lib2 ) ) if ($lib2);
-my ($numaccts,$accts,$total)= getboracctrecord('',\%bor);
-my $lib1 = &GetSortDetails("Bsort1",$data->{'sort1'});
-my $lib2 = &GetSortDetails("Bsort2",$data->{'sort2'});
-($template->param(lib1 => $lib1))if($lib1);
-($template->param(lib2 => $lib2))if($lib2);
# current issues
#
-my ($count,$issue)=borrissues($borrowernumber);
-my $roaddetails=&GetRoadTypeDetails($data->{'streettype'});
-my $today=ParseDate('today');
+my ( $count, $issue ) = borrissues($borrowernumber);
+my $roaddetails = &GetRoadTypeDetails( $data->{'streettype'} );
+my $today = ParseDate('today');
my @issuedata;
my $totalprice = 0;
my $toggle = 0;
-for (my $i=0;$i<$count;$i++){
- my $datedue=ParseDate($issue->[$i]{'date_due'});
- $issue->[$i]{'date_due'} = format_date($issue->[$i]{'date_due'});
- my %row = %{$issue->[$i]};
+for ( my $i = 0 ; $i < $count ; $i++ ) {
+ my $datedue = ParseDate( $issue->[$i]{'date_due'} );
+ $issue->[$i]{'date_due'} = format_date( $issue->[$i]{'date_due'} );
+ my %row = %{ $issue->[$i] };
$totalprice += $issue->[$i]{'replacementprice'};
- $row{'replacementprice'}=$issue->[$i]{'replacementprice'};
- if ($datedue < $today){
- $row{'red'}=1; #print "<font color=red>";
+ $row{'replacementprice'} = $issue->[$i]{'replacementprice'};
+ if ( $datedue < $today ) {
+ $row{'red'} = 1; #print "<font color=red>";
}
- $row{toggle} = $toggle++%2;
+ $row{toggle} = $toggle++ % 2;
+
#find the charge for an item
# FIXME - This is expecting
# &C4::Circulation::Renewals2::calc_charges, but it's getting
@@ -182,25 +220,28 @@
# 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($dbh,$issue->[$i]{'itemnumber'},$borrowernumber);
+ my ( $charge, $itemtype ) =
+ calc_charges( $dbh, $issue->[$i]{'itemnumber'}, $borrowernumber );
my $itemtypeinfo = getitemtypeinfo($itemtype);
$row{'itemtype_description'} = $itemtypeinfo->{description};
$row{'itemtype_image'} = $itemtypeinfo->{imageurl};
- $row{'charge'}= sprintf("%.2f",$charge);
+ $row{'charge'} = sprintf( "%.2f", $charge );
#check item is not reserved
- my ($restype,$reserves)=CheckReserves($issue->[$i]{'itemnumber'});
- if ($restype){
+ my ( $restype, $reserves ) = CheckReserves( $issue->[$i]{'itemnumber'} );
+ if ($restype) {
+
# print "<TD><a href=/cgi-bin/koha/reserve/request.pl?biblionumber=$issue->[$i]{'biblionumber'}>On Request - no renewals</a></td></tr>";
- # } elsif ($issue->[$i]->{'renewals'} > 0) {
- # print "<TD>Previously Renewed - no renewals</td></tr>";
- $row{'norenew'}=1;
- } else {
- $row{'norenew'}=0;
+# } elsif ($issue->[$i]->{'renewals'} > 0) {
+# print "<TD>Previously Renewed - no renewals</td></tr>";
+ $row{'norenew'} = 1;
+ }
+ else {
+ $row{'norenew'} = 0;
}
- push (@issuedata, \%row);
+ push( @issuedata, \%row );
}
#
@@ -221,7 +262,6 @@
# push (@reservedata, \%row);
# }
-
##################################################################################
# BUILD HTML
# show all reserves of this borrower, and the position of the reservation ....
@@ -294,34 +334,36 @@
$template->param( reservloop => \@reservloop );
}
+
# current alert subscriptions
my $alerts = getalert($borrowernumber);
foreach (@$alerts) {
- $_->{$_->{type}}=1;
- $_->{relatedto} = findrelatedto($_->{type},$_->{externalid});
+ $_->{ $_->{type} } = 1;
+ $_->{relatedto} = findrelatedto( $_->{type}, $_->{externalid} );
}
my $picture;
my $htdocs = C4::Context->config('intrahtdocs');
-$picture = "/borrowerimages/".$borrowernumber.".jpg";
-if (-e $htdocs."$picture")
-{
- $template->param(picture => $picture)
-};
+$picture = "/borrowerimages/" . $borrowernumber . ".jpg";
+if ( -e $htdocs . "$picture" ) {
+ $template->param( picture => $picture );
+}
$template->param($data);
$template->param(
roaddetails => $roaddetails,
borrowernumber => $borrowernumber,
- reregistration =>$reregistration,
- totalprice =>sprintf("%.2f",$totalprice),
- totaldue => sprintf("%.2f",$total),
+ reregistration => $reregistration,
+ totalprice => sprintf( "%.2f", $totalprice ),
+ totaldue => sprintf( "%.2f", $total ),
issueloop => \@issuedata,
unvalidlibrarian => $unvalidlibrarian,
-# reserveloop => \@reservedata,
- intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
+
+ # reserveloop => \@reservedata,
+ intranetcolorstylesheet =>
+ C4::Context->preference("intranetcolorstylesheet"),
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
IntranetNav => C4::Context->preference("IntranetNav"),
patronimages => C4::Context->preference("patronimages"),
intranetreadinghistory => C4::Context->preference("intranetreadinghistory"),
- );
+);
output_html_with_http_headers $input, $cookie, $template->output;
More information about the Koha-cvs
mailing list