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

(-)a/C4/Members.pm (-29 lines)
Lines 81-87 BEGIN { Link Here
81
        &GetBorNotifyAcctRecord
81
        &GetBorNotifyAcctRecord
82
82
83
        &GetborCatFromCatType
83
        &GetborCatFromCatType
84
        &GetBorrowercategory
85
        GetBorrowerCategorycode
84
        GetBorrowerCategorycode
86
        &GetBorrowercategoryList
85
        &GetBorrowercategoryList
87
86
Lines 1455-1488 sub GetborCatFromCatType { Link Here
1455
    return ( \@codes, \%labels );
1454
    return ( \@codes, \%labels );
1456
}
1455
}
1457
1456
1458
=head2 GetBorrowercategory
1459
1460
  $hashref = &GetBorrowercategory($categorycode);
1461
1462
Given the borrower's category code, the function returns the corresponding
1463
data hashref for a comprehensive information display.
1464
1465
=cut
1466
1467
sub GetBorrowercategory {
1468
    my ($catcode) = @_;
1469
    my $dbh       = C4::Context->dbh;
1470
    if ($catcode){
1471
        my $sth       =
1472
        $dbh->prepare(
1473
    "SELECT description,dateofbirthrequired,upperagelimit,category_type 
1474
    FROM categories 
1475
    WHERE categorycode = ?"
1476
        );
1477
        $sth->execute($catcode);
1478
        my $data =
1479
        $sth->fetchrow_hashref;
1480
        return $data;
1481
    } 
1482
    return;  
1483
}    # sub getborrowercategory
1484
1485
1486
=head2 GetBorrowerCategorycode
1457
=head2 GetBorrowerCategorycode
1487
1458
1488
    $categorycode = &GetBorrowerCategoryCode( $borrowernumber );
1459
    $categorycode = &GetBorrowerCategoryCode( $borrowernumber );
(-)a/members/memberentry.pl (-5 / +6 lines)
Lines 42-47 use C4::Form::MessagingPreferences; Link Here
42
use Koha::Patron::Debarments;
42
use Koha::Patron::Debarments;
43
use Koha::Cities;
43
use Koha::Cities;
44
use Koha::DateUtils;
44
use Koha::DateUtils;
45
use Koha::Patron::Categories;
45
use Email::Valid;
46
use Email::Valid;
46
use Module::Load;
47
use Module::Load;
47
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
48
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
Lines 152-160 $template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 ); Link Here
152
my $categorycode  = $input->param('categorycode') || $borrower_data->{'categorycode'};
153
my $categorycode  = $input->param('categorycode') || $borrower_data->{'categorycode'};
153
my $category_type = $input->param('category_type') || '';
154
my $category_type = $input->param('category_type') || '';
154
unless ($category_type or !($categorycode)){
155
unless ($category_type or !($categorycode)){
155
    my $borrowercategory = GetBorrowercategory($categorycode);
156
    my $borrowercategory = Koha::Patron::Categories->find($categorycode);
156
    $category_type    = $borrowercategory->{'category_type'};
157
    $category_type    = $borrowercategory->category_type;
157
    my $category_name = $borrowercategory->{'description'}; 
158
    my $category_name = $borrowercategory->description;
158
    $template->param("categoryname"=>$category_name);
159
    $template->param("categoryname"=>$category_name);
159
}
160
}
160
$category_type="A" unless $category_type; # FIXME we should display a error message instead of a 500 error !
161
$category_type="A" unless $category_type; # FIXME we should display a error message instead of a 500 error !
Lines 297-304 if ($op eq 'save' || $op eq 'insert'){ Link Here
297
298
298
    if ( $newdata{dateofbirth} ) {
299
    if ( $newdata{dateofbirth} ) {
299
        my $age = GetAge($newdata{dateofbirth});
300
        my $age = GetAge($newdata{dateofbirth});
300
        my $borrowercategory=GetBorrowercategory($newdata{'categorycode'});   
301
        my $borrowercategory = Koha::Patron::Categories->find($newdata{categorycode});
301
        my ($low,$high) = ($borrowercategory->{'dateofbirthrequired'}, $borrowercategory->{'upperagelimit'});
302
        my ($low,$high) = ($borrowercategory->dateofbirthrequired, $borrowercategory->upperagelimit);
302
        if (($high && ($age > $high)) or ($age < $low)) {
303
        if (($high && ($age > $high)) or ($age < $low)) {
303
            push @errors, 'ERROR_age_limitations';
304
            push @errors, 'ERROR_age_limitations';
304
            $template->param( age_low => $low);
305
            $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/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::Patron::Debarments;
50
use Koha::Patron::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 371-377 sub GetBorrowerInfos { Link Here
371
            }
372
            }
372
            $borrower->{$_} = $userdate || '';
373
            $borrower->{$_} = $userdate || '';
373
        }
374
        }
374
        $borrower->{category_description} = GetBorrowercategory( $borrower->{categorycode} )->{description};
375
        $borrower->{category_description} = Koha::Patron::Categories->find( $borrower->{categorycode} )->{description};
375
        my $attr_loop = C4::Members::Attributes::GetBorrowerAttributes( $borrower->{borrowernumber} );
376
        my $attr_loop = C4::Members::Attributes::GetBorrowerAttributes( $borrower->{borrowernumber} );
376
        $borrower->{patron_attributes} = $attr_loop;
377
        $borrower->{patron_attributes} = $attr_loop;
377
    }
378
    }
(-)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