Bug Fixing 1782 patch

Adding a new routine GetBorrowercategoryList in C4/Member
Displaying categoryname when listing categories in memberentrygen.pl
using categorytype returned with GetMember wherever it is possible.

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
Henri-Damien LAURENT 2008-05-12 16:29:45 +02:00 committed by Joshua Ferraro
parent 3a699f97d0
commit 9fb4a72122
15 changed files with 103 additions and 120 deletions

View File

@ -67,6 +67,7 @@ BEGIN {
&GetborCatFromCatType
&GetBorrowercategory
&GetBorrowercategoryList
&GetBorrowersWhoHaveNotBorrowedSince
&GetBorrowersWhoHaveNeverBorrowed
@ -1367,18 +1368,29 @@ sub GetBorrowercategory {
$sth->finish();
return $data;
}
else {
my $sth =
$dbh->prepare(
"SELECT *
FROM categories order by description"
return;
} # sub getborrowercategory
=head2 GetBorrowercategoryList
$arrayref_hashref = &GetBorrowercategoryList;
If no category code provided, the function returns all the categories.
=cut
sub GetBorrowercategoryList {
my $dbh = C4::Context->dbh;
my $sth =
$dbh->prepare(
"SELECT *
FROM categories
ORDER BY description"
);
$sth->execute;
my $data =
$sth->fetchall_arrayref({});
$sth->finish();
return $data;
}
$sth->execute;
my $data =
$sth->fetchall_arrayref({});
$sth->finish();
return $data;
} # sub getborrowercategory
=head2 ethnicitycategories

View File

@ -399,9 +399,7 @@ if ($borrowernumber) {
reservloop => \@reservloop ,
WaitingReserveLoop => \@WaitingReserveLoop,
);
$borrowercategory = GetBorrowercategory( $borrower->{'categorycode'} );
$category_type = $borrowercategory->{'category_type'};
( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' );
$template->param( adultborrower => 1 ) if ( $borrower->{'category_type'} eq 'A' );
}
# make the issued books table.

View File

@ -1,8 +1,6 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
<title>Koha &rsaquo; Patrons &rsaquo;
<!-- TMPL_IF NAME="opadd" --> Add<!--TMPL_IF Name="I"--> Organisation <!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult <!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child <!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional <!--/TMPL_IF --><!--TMPL_IF Name="S"--> Staff <!--/TMPL_IF -->
patron <!-- TMPL_VAR NAME="surname" -->, <!-- TMPL_VAR name="firstname" --><!-- TMPL_ELSE -->Modify<!--TMPL_IF Name="I"--> Organisation <!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult <!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child <!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional <!--/TMPL_IF --><!--TMPL_IF Name="S"--> Staff<!--/TMPL_IF -->
patron <!-- TMPL_VAR NAME="surname" -->, <!-- TMPL_VAR name="firstname" --><!-- /TMPL_IF --></title>
<!-- TMPL_IF NAME="opadd" --> Add<!-- TMPL_ELSE --> Modify<!--/TMPL_IF--> <!--TMPL_IF Name="categoryname"--> <!--TMPL_VAR Name="categoryname"--> patron<!-- TMPL_ELSE --><!--TMPL_IF Name="I"--> Organisation patron<!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult patron<!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child patron<!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional patron<!--/TMPL_IF --><!--TMPL_IF Name="S"--> Staff patron<!--/TMPL_IF --><!--/TMPL_IF --><!--TMPL_UNLESS Name="opadd"--> <!-- TMPL_VAR NAME="surname" -->, <!-- TMPL_VAR name="firstname" --><!--/TMPL_UNLESS--></title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<script type="text/javascript" src="<!-- TMPL_VAR NAME='themelang' -->/js/members.js"></script>
<!-- TMPL_INCLUDE NAME="calendar.inc" -->
@ -57,11 +55,11 @@ patron <!-- TMPL_VAR NAME="surname" -->, <!-- TMPL_VAR name="firstname" --><!--
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> &rsaquo;
<!-- TMPL_IF NAME="opadd" -->
Add<!--TMPL_IF Name="I"--> Organisation <!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult <!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child <!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional <!--/TMPL_IF --> <!--TMPL_IF Name="S"--> Staff <!--/TMPL_IF -->
patron <!-- TMPL_VAR NAME="surname" --> <!-- TMPL_VAR name="firstname" -->
Add<!--TMPL_IF Name="categoryname"--> <!--TMPL_VAR Name="categoryname"--> patron<!-- TMPL_ELSE --><!--TMPL_IF Name="I"--> Organisation patron<!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult patron<!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child patron<!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional patron<!--/TMPL_IF --><!--TMPL_IF Name="S"--> Staff patron<!--/TMPL_IF --><!--/TMPL_IF -->
<!-- TMPL_VAR NAME="surname" --> <!-- TMPL_VAR name="firstname" -->
<!-- TMPL_ELSE -->
<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->"><!-- TMPL_VAR name="firstname" --> <!-- TMPL_VAR NAME="surname" --></a> &rsaquo; <strong>Modify<!--TMPL_IF Name="I"--> Organisation <!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult <!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child <!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional <!--/TMPL_IF --><!--TMPL_IF Name="S"-->Staff <!--/TMPL_IF -->
patron </strong><!-- /TMPL_IF --></div>
<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->"><!-- TMPL_VAR name="firstname" --> <!-- TMPL_VAR NAME="surname" --></a> &rsaquo; <strong>Modify<!--TMPL_IF Name="categoryname"--> <!--TMPL_VAR Name="categoryname"--> patron<!-- TMPL_ELSE --><!--TMPL_IF Name="I"--> Organisation patron<!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult patron<!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child patron<!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional patron<!--/TMPL_IF --><!--TMPL_IF Name="S"--> Staff patron<!--/TMPL_IF --><!--/TMPL_IF -->
</strong><!-- /TMPL_IF --></div>
<!-- TMPL_IF NAME="opadd" --><div id="doc" class="yui-t7"><!-- TMPL_ELSE --><div id="doc3" class="yui-t2"><!-- /TMPL_IF -->
@ -72,12 +70,11 @@ patron </strong><!-- /TMPL_IF --></div>
<!-- TMPL_IF NAME="opadd" -->
<h1>
<!--TMPL_IF Name="I"--> Add Organisation patron <!--/TMPL_IF --><!--TMPL_IF Name="A"--> Add Adult patron <!--/TMPL_IF --><!--TMPL_IF Name="C"--> Add Child patron <!--/TMPL_IF --><!--TMPL_IF Name="P"--> Add Professional patron <!--/TMPL_IF --><!--TMPL_IF Name="S"--> Add Staff patron <!--/TMPL_IF -->
<!-- TMPL_VAR name="firstname" --> <!-- TMPL_VAR NAME="surname" -->
Add<!--TMPL_IF Name="categoryname"--> <!--TMPL_VAR Name="categoryname"--> patron<!-- TMPL_ELSE --><!--TMPL_IF Name="I"--> Organisation patron<!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult patron<!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child patron<!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional patron<!--/TMPL_IF --><!--TMPL_IF Name="S"--> Staff patron<!--/TMPL_IF --><!--/TMPL_IF --> <!-- TMPL_VAR name="firstname" --> <!-- TMPL_VAR NAME="surname" -->
</h1>
<!-- TMPL_ELSE -->
<h1 >
<!--TMPL_IF Name="I"--> Modify Organisation patron <!--/TMPL_IF --><!--TMPL_IF Name="A"--> Modify Adult patron <!--/TMPL_IF --><!--TMPL_IF Name="C"--> Modify Child patron <!--/TMPL_IF --><!--TMPL_IF Name="P"--> Modify Professional patron <!--/TMPL_IF --><!--TMPL_IF Name="S"--> Modify Staff patron <!--/TMPL_IF -->
<h1>
Modify<!--TMPL_IF Name="categoryname"--> <!--TMPL_VAR Name="categoryname"--> patron<!-- TMPL_ELSE --><!--TMPL_IF Name="I"--> Organisation patron<!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult patron<!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child patron<!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional patron<!--/TMPL_IF --><!--TMPL_IF Name="S"--> Staff patron<!--/TMPL_IF --><!--/TMPL_IF -->
<!-- TMPL_VAR name="firstname" --> <!-- TMPL_VAR NAME="surname" -->
</h1>
<!-- /TMPL_IF -->

View File

@ -86,9 +86,7 @@ for (my $i=0;$i<$numaccts;$i++){
push(@accountrows, \%row);
}
my $borrowercategory = GetBorrowercategory( $data->{'categorycode'} );
my $category_type = $borrowercategory->{'category_type'};
( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' );
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
$template->param( picture => 1 ) if $picture;

View File

@ -53,26 +53,21 @@ my $borrowernumber=$input->param('borrowernumber');
my $description=$input->param('description');
my $category_type=$input->param('category_type');
if ( $data{'surname'} eq '')
{
$data=GetMember($borrowernumber,'borrowernumber');
%data=%$data;
}
my $borrowercategory = GetBorrowercategory($data{'categorycode'});
$data=GetMember($borrowernumber,'borrowernumber');
$template->param( borrowernumber => $borrowernumber,#register number
#transform value in capital or capital for first letter of the word
firstname => ucfirst($data{'firstname'}),
surname => uc($data{'surname'}),
categorycode => $data{'categorycode'},
title => $data{'title'},
category_type => $borrowercategory ->{'category_type'},
"title_".$data{'title'} => " SELECTED ",
dateofbirth => format_date($data{'dateofbirth'}),
description => $borrowercategory->{'description'}
);
$template->param(Institution => 1) if ($category_type eq "I");
output_html_with_http_headers $input, $cookie, $template->output;
firstname => ucfirst($data->{'firstname'}),
surname => uc($data->{'surname'}),
categorycode => $data->{'categorycode'},
title => $data->{'title'},
category_type => $data->{'category_type'},
"title_".$data->{'title'} => " SELECTED ",
dateofbirth => format_date($data->{'dateofbirth'}),
description => $data->{'description'}
);
$template->param(Institution => 1) if ($category_type eq "I");
output_html_with_http_headers $input, $cookie, $template->output;
# Local Variables:
# tab-width: 8

View File

@ -45,42 +45,32 @@ if ($add){
manualinvoice($borrowernumber,$itemnum,$desc,$type,$amount);
print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
} else {
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "members/mancredit.tmpl",
query => $input,
type => "intranet",
authnotrequired => 0,
flagsrequired => {borrowers => 1},
debug => 1,
});
my $borrowercategory = GetBorrowercategory( $data->{'categorycode'} );
my $category_type = $borrowercategory->{'category_type'};
( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' );
my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
$template->param( picture => 1 ) if $picture;
= get_template_and_user({template_name => "members/mancredit.tmpl",
query => $input,
type => "intranet",
authnotrequired => 0,
flagsrequired => {borrowers => 1},
debug => 1,
});
$template->param( adultborrower => 1 ) if ( $data->{category_type} eq 'A' );
my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
$template->param( picture => 1 ) if $picture;
$template->param(
borrowernumber => $borrowernumber,
firstname => $data->{'firstname'},
surname => $data->{'surname'},
cardnumber => $data->{'cardnumber'},
categorycode => $data->{'categorycode'},
category_type => $data->{'category_type'},
category_description => $data->{'description'},
address => $data->{'address'},
address2 => $data->{'address2'},
city => $data->{'city'},
zipcode => $data->{'zipcode'},
phone => $data->{'phone'},
email => $data->{'email'},
);
print $input->header(
-type => 'utf-8',
-cookie => $cookie
),$template->output;
borrowernumber => $borrowernumber,
firstname => $data->{'firstname'},
surname => $data->{'surname'},
cardnumber => $data->{'cardnumber'},
categorycode => $data->{'categorycode'},
category_type => $data->{'category_type'},
category_description => $data->{'description'},
address => $data->{'address'},
address2 => $data->{'address2'},
city => $data->{'city'},
zipcode => $data->{'zipcode'},
phone => $data->{'phone'},
email => $data->{'email'},
);
print $input->header( -type => 'utf-8', -cookie => $cookie),$template->output;
}

View File

@ -75,9 +75,7 @@ if ($add){
debug => 1,
});
my $borrowercategory = GetBorrowercategory( $data->{'categorycode'} );
my $category_type = $borrowercategory->{'category_type'};
( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' );
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
$template->param( picture => 1 ) if $picture;

View File

@ -153,27 +153,25 @@ if ($input->param('newflags')) {
push @loop, \%row;
}
my $borrowercategory = GetBorrowercategory( $bor->{'categorycode'} );
my $category_type = $borrowercategory->{'category_type'};
( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' );
$template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' );
$template->param(borrowernumber => $member,
borrowernumber => $bor->{'borrowernumber'},
cardnumber => $bor->{'cardnumber'},
surname => $bor->{'surname'},
firstname => $bor->{'firstname'},
categorycode => $bor->{'categorycode'},
category_type => $bor->{'category_type'},
category_description => $bor->{'description'},
address => $bor->{'address'},
address2 => $bor->{'address2'},
city => $bor->{'city'},
zipcode => $bor->{'zipcode'},
phone => $bor->{'phone'},
email => $bor->{'email'},
branchcode => $bor->{'branchcode'},
loop => \@loop,
);
$template->param(
borrowernumber => $bor->{'borrowernumber'},
cardnumber => $bor->{'cardnumber'},
surname => $bor->{'surname'},
firstname => $bor->{'firstname'},
categorycode => $bor->{'categorycode'},
category_type => $bor->{'category_type'},
category_description => $bor->{'description'},
address => $bor->{'address'},
address2 => $bor->{'address2'},
city => $bor->{'city'},
zipcode => $bor->{'zipcode'},
phone => $bor->{'phone'},
email => $bor->{'email'},
branchcode => $bor->{'branchcode'},
loop => \@loop,
);
output_html_with_http_headers $input, $cookie, $template->output;

View File

@ -76,9 +76,7 @@ if ( $newpassword && ! $errormsg ) {
$defaultnewpassword.=substr($chars, int(rand(length($chars))),1);
}
my $borrowercategory = GetBorrowercategory( $bor->{'categorycode'} );
my $category_type = $borrowercategory->{'category_type'};
( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' );
$template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' );
my ($picture, $dberror) = GetPatronImage($bor->{'cardnumber'});
$template->param( picture => 1 ) if $picture;

View File

@ -61,7 +61,7 @@ $template->param(
"AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1",
);
if (C4::Context->preference("AddPatronLists")=~/code/){
my $categories=GetBorrowercategory();
my $categories=GetBorrowercategoryList;
$categories->[0]->{'first'}=1;
$template->param(categories=>$categories);
}

View File

@ -102,6 +102,8 @@ my $new_c_type = $category_type; #if we have input param, then we've already cho
unless ($category_type or !($categorycode)){
my $borrowercategory= GetBorrowercategory($categorycode);
$category_type = $borrowercategory->{'category_type'};
my $category_name = $borrowercategory->{'description'};
$template->param("categoryname"=>$category_name);
}
$category_type="A" unless $category_type; # FIXME we should display a error message instead of a 500 error !
@ -149,8 +151,10 @@ if ($op eq 'insert'){
);
# recover the category type if the borrowers is a doublon
my $tmpborrowercategory=GetBorrowercategory($check_category);
$check_categorytype=$tmpborrowercategory->{'category_type'};
if ($check_category) {
my $tmpborrowercategory=GetBorrowercategory($check_category);
$check_categorytype=$tmpborrowercategory->{'category_type'};
}
}
#recover all data from guarantor address phone ,fax...

View File

@ -50,7 +50,7 @@ $template->param(
"AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1",
);
if (C4::Context->preference("AddPatronLists")=~/code/){
my $categories=GetBorrowercategory();
my $categories=GetBorrowercategoryList;
$categories->[0]->{'first'}=1;
$template->param(categories=>$categories);
}

View File

@ -102,8 +102,7 @@ if ( $reregistration eq 'y' ) {
$data->{'dateexpiry'} = ExtendMemberSubscriptionTo( $borrowernumber );
}
my $borrowercategory = GetBorrowercategory( $data->{'categorycode'} );
my $category_type = $borrowercategory->{'category_type'};
my $category_type = $data->{'category_type'};
### $category_type
@ -346,7 +345,7 @@ $template->param(
DHTMLcalendar_dateformat=>C4::Dates->DHTMLcalendar(),
roaddetails => $roaddetails,
borrowernumber => $borrowernumber,
categoryname => $borrowercategory->{description},
categoryname => $data->{'description'},
reregistration => $reregistration,
branch => $branch,
totalprice => sprintf( "%.2f", $totalprice ),

View File

@ -131,9 +131,7 @@ if ( $check == 0 ) {
};
}
my $borrowercategory = GetBorrowercategory( $data->{'categorycode'} );
my $category_type = $borrowercategory->{'category_type'};
( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' );
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
$template->param( picture => 1 ) if $picture;

View File

@ -77,9 +77,7 @@ for (my $i=0;$i<$count;$i++){
push(@loop_reading,\%line);
}
my $borrowercategory = GetBorrowercategory( $data->{'categorycode'} );
my $category_type = $borrowercategory->{'category_type'};
( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' );
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
if (! $limit){
$limit = 'full';
}