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 665-672 sub ModMember { Link Here
665
        # ok if its an adult (type) it may have borrowers that depend on it as a guarantor
664
        # ok if its an adult (type) it may have borrowers that depend on it as a guarantor
666
        # so when we update information for an adult we should check for guarantees and update the relevant part
665
        # so when we update information for an adult we should check for guarantees and update the relevant part
667
        # of their records, ie addresses and phone numbers
666
        # of their records, ie addresses and phone numbers
668
        my $borrowercategory= GetBorrowercategory( $data{'category_type'} );
667
        my $borrowercategory = Koha::Patron::Categories->find($data{'category_type'});
669
        if ( exists  $borrowercategory->{'category_type'} && $borrowercategory->{'category_type'} eq ('A' || 'S') ) {
668
        if ( $borrowercategory && $borrowercategory->category_type eq ('A' || 'S') ) {
670
            # is adult check guarantees;
669
            # is adult check guarantees;
671
            UpdateGuarantees(%data);
670
            UpdateGuarantees(%data);
672
        }
671
        }
Lines 1553-1586 sub GetborCatFromCatType { Link Here
1553
    return ( \@codes, \%labels );
1552
    return ( \@codes, \%labels );
1554
}
1553
}
1555
1554
1556
=head2 GetBorrowercategory
1557
1558
  $hashref = &GetBorrowercategory($categorycode);
1559
1560
Given the borrower's category code, the function returns the corresponding
1561
data hashref for a comprehensive information display.
1562
1563
=cut
1564
1565
sub GetBorrowercategory {
1566
    my ($catcode) = @_;
1567
    my $dbh       = C4::Context->dbh;
1568
    if ($catcode){
1569
        my $sth       =
1570
        $dbh->prepare(
1571
    "SELECT description,dateofbirthrequired,upperagelimit,category_type 
1572
    FROM categories 
1573
    WHERE categorycode = ?"
1574
        );
1575
        $sth->execute($catcode);
1576
        my $data =
1577
        $sth->fetchrow_hashref;
1578
        return $data;
1579
    } 
1580
    return;  
1581
}    # sub getborrowercategory
1582
1583
1584
=head2 GetBorrowerCategorycode
1555
=head2 GetBorrowerCategorycode
1585
1556
1586
    $categorycode = &GetBorrowerCategoryCode( $borrowernumber );
1557
    $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 37-42 use C4::Output; Link Here
37
use List::MoreUtils qw /any uniq/;
37
use List::MoreUtils qw /any uniq/;
38
use Koha::DateUtils qw( dt_from_string );
38
use Koha::DateUtils qw( dt_from_string );
39
use Koha::List::Patron;
39
use Koha::List::Patron;
40
use Koha::Patron::Categories;
40
41
41
my $input = new CGI;
42
my $input = new CGI;
42
my $op = $input->param('op') || 'show_form';
43
my $op = $input->param('op') || 'show_form';
Lines 370-376 sub GetBorrowerInfos { Link Here
370
            }
371
            }
371
            $borrower->{$_} = $userdate || '';
372
            $borrower->{$_} = $userdate || '';
372
        }
373
        }
373
        $borrower->{category_description} = GetBorrowercategory( $borrower->{categorycode} )->{description};
374
        $borrower->{category_description} = Koha::Patron::Categories->find( $borrower->{categorycode} )->{description};
374
        my $attr_loop = C4::Members::Attributes::GetBorrowerAttributes( $borrower->{borrowernumber} );
375
        my $attr_loop = C4::Members::Attributes::GetBorrowerAttributes( $borrower->{borrowernumber} );
375
        $borrower->{patron_attributes} = $attr_loop;
376
        $borrower->{patron_attributes} = $attr_loop;
376
    }
377
    }
(-)a/tools/overduerules.pl (-3 / +2 lines)
Lines 129-136 if ($op eq 'save') { Link Here
129
129
130
    foreach my $bor (keys %temphash){
130
    foreach my $bor (keys %temphash){
131
        # get category name if we need it for an error message
131
        # get category name if we need it for an error message
132
        my $bor_category = GetBorrowercategory($bor);
132
        my $bor_category = Koha::Patron::Categories->find($bor);
133
        my $bor_category_name = defined($bor_category) ? $bor_category->{description} : $bor;
133
        my $bor_category_name = $bor_category ? $bor_category->description : $bor;
134
134
135
        # Do some Checking here : delay1 < delay2 <delay3 all of them being numbers
135
        # Do some Checking here : delay1 < delay2 <delay3 all of them being numbers
136
        # Raise error if not true
136
        # Raise error if not true
137
- 

Return to bug 15407