View | Details | Raw Unified | Return to bug 15407
Collapse All | Expand All

(-)a/C4/Members.pm (-31 / +2 lines)
Lines 88-94 BEGIN { Link Here
88
        &GetBorNotifyAcctRecord
88
        &GetBorNotifyAcctRecord
89
89
90
        &GetborCatFromCatType
90
        &GetborCatFromCatType
91
        &GetBorrowercategory
92
        GetBorrowerCategorycode
91
        GetBorrowerCategorycode
93
        &GetBorrowercategoryList
92
        &GetBorrowercategoryList
94
93
Lines 676-683 sub ModMember { Link Here
676
        # ok if its an adult (type) it may have borrowers that depend on it as a guarantor
675
        # ok if its an adult (type) it may have borrowers that depend on it as a guarantor
677
        # so when we update information for an adult we should check for guarantees and update the relevant part
676
        # so when we update information for an adult we should check for guarantees and update the relevant part
678
        # of their records, ie addresses and phone numbers
677
        # of their records, ie addresses and phone numbers
679
        my $borrowercategory= GetBorrowercategory( $data{'category_type'} );
678
        my $borrowercategory = Koha::Patron::Categories->find($data{'category_type'});
680
        if ( exists  $borrowercategory->{'category_type'} && $borrowercategory->{'category_type'} eq ('A' || 'S') ) {
679
        if ( $borrowercategory && $borrowercategory->category_type eq ('A' || 'S') ) {
681
            # is adult check guarantees;
680
            # is adult check guarantees;
682
            UpdateGuarantees(%data);
681
            UpdateGuarantees(%data);
683
        }
682
        }
Lines 1564-1597 sub GetborCatFromCatType { Link Here
1564
    return ( \@codes, \%labels );
1563
    return ( \@codes, \%labels );
1565
}
1564
}
1566
1565
1567
=head2 GetBorrowercategory
1568
1569
  $hashref = &GetBorrowercategory($categorycode);
1570
1571
Given the borrower's category code, the function returns the corresponding
1572
data hashref for a comprehensive information display.
1573
1574
=cut
1575
1576
sub GetBorrowercategory {
1577
    my ($catcode) = @_;
1578
    my $dbh       = C4::Context->dbh;
1579
    if ($catcode){
1580
        my $sth       =
1581
        $dbh->prepare(
1582
    "SELECT description,dateofbirthrequired,upperagelimit,category_type 
1583
    FROM categories 
1584
    WHERE categorycode = ?"
1585
        );
1586
        $sth->execute($catcode);
1587
        my $data =
1588
        $sth->fetchrow_hashref;
1589
        return $data;
1590
    } 
1591
    return;  
1592
}    # sub getborrowercategory
1593
1594
1595
=head2 GetBorrowerCategorycode
1566
=head2 GetBorrowerCategorycode
1596
1567
1597
    $categorycode = &GetBorrowerCategoryCode( $borrowernumber );
1568
    $categorycode = &GetBorrowerCategoryCode( $borrowernumber );
(-)a/members/memberentry.pl (-5 / +6 lines)
Lines 41-46 use C4::Branch; # GetBranches Link Here
41
use C4::Form::MessagingPreferences;
41
use C4::Form::MessagingPreferences;
42
use Koha::Borrower::Debarments;
42
use Koha::Borrower::Debarments;
43
use Koha::DateUtils;
43
use Koha::DateUtils;
44
use Koha::Patron::Categories;
44
use Email::Valid;
45
use Email::Valid;
45
use Module::Load;
46
use Module::Load;
46
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
47
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
Lines 145-153 $template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 ); Link Here
145
my $categorycode  = $input->param('categorycode') || $borrower_data->{'categorycode'};
146
my $categorycode  = $input->param('categorycode') || $borrower_data->{'categorycode'};
146
my $category_type = $input->param('category_type') || '';
147
my $category_type = $input->param('category_type') || '';
147
unless ($category_type or !($categorycode)){
148
unless ($category_type or !($categorycode)){
148
    my $borrowercategory = GetBorrowercategory($categorycode);
149
    my $borrowercategory = Koha::Patron::Categories->find($categorycode);
149
    $category_type    = $borrowercategory->{'category_type'};
150
    $category_type    = $borrowercategory->category_type;
150
    my $category_name = $borrowercategory->{'description'}; 
151
    my $category_name = $borrowercategory->description;
151
    $template->param("categoryname"=>$category_name);
152
    $template->param("categoryname"=>$category_name);
152
}
153
}
153
$category_type="A" unless $category_type; # FIXME we should display a error message instead of a 500 error !
154
$category_type="A" unless $category_type; # FIXME we should display a error message instead of a 500 error !
Lines 290-297 if ($op eq 'save' || $op eq 'insert'){ Link Here
290
291
291
    if ( $newdata{dateofbirth} ) {
292
    if ( $newdata{dateofbirth} ) {
292
        my $age = GetAge($newdata{dateofbirth});
293
        my $age = GetAge($newdata{dateofbirth});
293
        my $borrowercategory=GetBorrowercategory($newdata{'categorycode'});   
294
        my $borrowercategory = Koha::Patron::Categories->find($newdata{categorycode});
294
        my ($low,$high) = ($borrowercategory->{'dateofbirthrequired'}, $borrowercategory->{'upperagelimit'});
295
        my ($low,$high) = ($borrowercategory->dateofbirthrequired, $borrowercategory->upperagelimit);
295
        if (($high && ($age > $high)) or ($age < $low)) {
296
        if (($high && ($age > $high)) or ($age < $low)) {
296
            push @errors, 'ERROR_age_limitations';
297
            push @errors, 'ERROR_age_limitations';
297
            $template->param( age_low => $low);
298
            $template->param( age_low => $low);
(-)a/members/update-child.pl (-5 / +6 lines)
Lines 33-38 use C4::Context; Link Here
33
use C4::Auth;
33
use C4::Auth;
34
use C4::Output;
34
use C4::Output;
35
use C4::Members;
35
use C4::Members;
36
use Koha::Patron::Categories;
36
37
37
# use Smart::Comments;
38
# use Smart::Comments;
38
39
Lines 66-73 if ( $op eq 'multi' ) { Link Here
66
        my $row;
67
        my $row;
67
        $row->{catcode} = $k;
68
        $row->{catcode} = $k;
68
        $row->{catdesc} = $labels->{$k};
69
        $row->{catdesc} = $labels->{$k};
69
        my $borcat = GetBorrowercategory( $row->{catcode} );
70
        my $borcat = Koha::Patron::Categories->find($row->{catcode});
70
        $row->{cattype} = $borcat->{'category_type'};
71
        $row->{cattype} = $borcat->category_type;
71
        push @rows, $row;
72
        push @rows, $row;
72
    }
73
    }
73
    $template->param(
74
    $template->param(
Lines 83-91 elsif ( $op eq 'update' ) { Link Here
83
    my $member = GetMember('borrowernumber'=>$borrowernumber);
84
    my $member = GetMember('borrowernumber'=>$borrowernumber);
84
    $member->{'guarantorid'}  = 0;
85
    $member->{'guarantorid'}  = 0;
85
    $member->{'categorycode'} = $catcode;
86
    $member->{'categorycode'} = $catcode;
86
    my $borcat = GetBorrowercategory($catcode);
87
    my $borcat = Koha::Patron::Categories->find($catcode);
87
    $member->{'category_type'} = $borcat->{'category_type'};
88
    $member->{'category_type'} = $borcat->category_type;
88
    $member->{'description'}   = $borcat->{'description'};
89
    $member->{'description'}   = $borcat->description;
89
    delete $member->{password};
90
    delete $member->{password};
90
    ModMember(%$member);
91
    ModMember(%$member);
91
92
(-)a/t/db_dependent/ILSDI_Services.t (-2 / +3 lines)
Lines 2-9 Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use C4::Members qw/AddMember GetMember GetBorrowercategory/;
5
use C4::Members qw/AddMember GetMember/;
6
use C4::Branch;
6
use C4::Branch;
7
use Koha::Patron::Categories;
7
use CGI qw ( -utf8 );
8
use CGI qw ( -utf8 );
8
9
9
use Test::More tests => 15;
10
use Test::More tests => 15;
Lines 30-36 my %data = ( Link Here
30
);
31
);
31
32
32
# Crate patron category
33
# Crate patron category
33
unless ( GetBorrowercategory('UT') ) {
34
unless ( Koha::Patron::Categories->find('UT') ) {
34
    $dbh->do("INSERT INTO categories
35
    $dbh->do("INSERT INTO categories
35
    (categorycode,description,enrolmentperiod,upperagelimit,enrolmentfee,overduenoticerequired,reservefee,category_type,default_privacy)
36
    (categorycode,description,enrolmentperiod,upperagelimit,enrolmentfee,overduenoticerequired,reservefee,category_type,default_privacy)
36
        VALUES
37
        VALUES
(-)a/t/db_dependent/Reserves.t (-1 / +2 lines)
Lines 32-37 use Koha::Holds; Link Here
32
use t::lib::Mocks;
32
use t::lib::Mocks;
33
33
34
use Koha::DateUtils;
34
use Koha::DateUtils;
35
use Koha::Patron::Categories;
35
36
36
use Data::Dumper;
37
use Data::Dumper;
37
BEGIN {
38
BEGIN {
Lines 61-67 foreach my $addbra ('CPL', 'FPL', 'RPL') { Link Here
61
62
62
# Add categories if not existing
63
# Add categories if not existing
63
foreach my $addcat ('S', 'PT') {
64
foreach my $addcat ('S', 'PT') {
64
    $dbh->do("INSERT INTO categories (categorycode,hidelostitems,category_type) VALUES (?,?,?)",undef,($addcat, 0, $addcat eq 'S'? 'S': 'A')) unless GetBorrowercategory($addcat);
65
    $dbh->do("INSERT INTO categories (categorycode,hidelostitems,category_type) VALUES (?,?,?)",undef,($addcat, 0, $addcat eq 'S'? 'S': 'A')) unless Koha::Patron::Categories->find($addcat);
65
}
66
}
66
67
67
# Create a helper biblio
68
# Create a helper biblio
(-)a/tools/import_borrowers.pl (-1 / +2 lines)
Lines 49-54 use C4::Reports::Guided; Link Here
49
use C4::Templates;
49
use C4::Templates;
50
use Koha::Borrower::Debarments;
50
use Koha::Borrower::Debarments;
51
use Koha::DateUtils;
51
use Koha::DateUtils;
52
use Koha::Patron::Categories;
52
53
53
use Text::CSV;
54
use Text::CSV;
54
# Text::CSV::Unicode, even in binary mode, fails to parse lines with these diacriticals:
55
# Text::CSV::Unicode, even in binary mode, fails to parse lines with these diacriticals:
Lines 178-184 if ( $uploadborrowers && length($uploadborrowers) > 0 ) { Link Here
178
        #warn join(':',%borrower);
179
        #warn join(':',%borrower);
179
        if ($borrower{categorycode}) {
180
        if ($borrower{categorycode}) {
180
            push @missing_criticals, {key=>'categorycode', line=>$. , lineraw=>$borrowerline, value=>$borrower{categorycode}, category_map=>1}
181
            push @missing_criticals, {key=>'categorycode', line=>$. , lineraw=>$borrowerline, value=>$borrower{categorycode}, category_map=>1}
181
                unless GetBorrowercategory($borrower{categorycode});
182
                unless Koha::Patron::Categories->find($borrower{categorycode});
182
        } else {
183
        } else {
183
            push @missing_criticals, {key=>'categorycode', line=>$. , lineraw=>$borrowerline};
184
            push @missing_criticals, {key=>'categorycode', line=>$. , lineraw=>$borrowerline};
184
        }
185
        }
(-)a/tools/modborrowers.pl (-1 / +2 lines)
Lines 36-41 use C4::Members::AttributeTypes qw/GetAttributeTypes_hashref/; Link Here
36
use C4::Output;
36
use C4::Output;
37
use List::MoreUtils qw /any uniq/;
37
use List::MoreUtils qw /any uniq/;
38
use Koha::List::Patron;
38
use Koha::List::Patron;
39
use Koha::Patron::Categories;
39
40
40
my $input = new CGI;
41
my $input = new CGI;
41
my $op = $input->param('op') || 'show_form';
42
my $op = $input->param('op') || 'show_form';
Lines 362-368 sub GetBorrowerInfos { Link Here
362
            }
363
            }
363
            $borrower->{$_} = $userdate || '';
364
            $borrower->{$_} = $userdate || '';
364
        }
365
        }
365
        $borrower->{category_description} = GetBorrowercategory( $borrower->{categorycode} )->{description};
366
        $borrower->{category_description} = Koha::Patron::Categories->find( $borrower->{categorycode} )->{description};
366
        my $attr_loop = C4::Members::Attributes::GetBorrowerAttributes( $borrower->{borrowernumber} );
367
        my $attr_loop = C4::Members::Attributes::GetBorrowerAttributes( $borrower->{borrowernumber} );
367
        $borrower->{patron_attributes} = $attr_loop;
368
        $borrower->{patron_attributes} = $attr_loop;
368
    }
369
    }
(-)a/tools/overduerules.pl (-3 / +2 lines)
Lines 117-124 if ($op eq 'save') { Link Here
117
117
118
    foreach my $bor (keys %temphash){
118
    foreach my $bor (keys %temphash){
119
        # get category name if we need it for an error message
119
        # get category name if we need it for an error message
120
        my $bor_category = GetBorrowercategory($bor);
120
        my $bor_category = Koha::Patron::Categories->find($bor);
121
        my $bor_category_name = defined($bor_category) ? $bor_category->{description} : $bor;
121
        my $bor_category_name = $bor_category ? $bor_category->description : $bor;
122
122
123
        # Do some Checking here : delay1 < delay2 <delay3 all of them being numbers
123
        # Do some Checking here : delay1 < delay2 <delay3 all of them being numbers
124
        # Raise error if not true
124
        # Raise error if not true
125
- 

Return to bug 15407