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

(-)a/Koha/Patrons/Import.pm (-8 / +8 lines)
Lines 21-26 use namespace::clean; Link Here
21
21
22
use Carp;
22
use Carp;
23
use Text::CSV;
23
use Text::CSV;
24
use Encode qw( decode_utf8 );
24
25
25
use C4::Members;
26
use C4::Members;
26
use C4::Members::Attributes qw(:all);
27
use C4::Members::Attributes qw(:all);
Lines 101-107 sub import_patrons { Link Here
101
        my $status  = $self->text_csv->parse($borrowerline);
102
        my $status  = $self->text_csv->parse($borrowerline);
102
        my @columns = $self->text_csv->fields();
103
        my @columns = $self->text_csv->fields();
103
        if ( !$status ) {
104
        if ( !$status ) {
104
            push @missing_criticals, { badparse => 1, line => $line_number, lineraw => $borrowerline };
105
            push @missing_criticals, { badparse => 1, line => $line_number, lineraw => decode_utf8($borrowerline) };
105
        }
106
        }
106
        elsif ( @columns == @columnkeys ) {
107
        elsif ( @columns == @columnkeys ) {
107
            @borrower{@columnkeys} = @columns;
108
            @borrower{@columnkeys} = @columns;
Lines 125-131 sub import_patrons { Link Here
125
                elsif ( scalar grep { $key eq $_ } @criticals ) {
126
                elsif ( scalar grep { $key eq $_ } @criticals ) {
126
127
127
                    # a critical field is undefined
128
                    # a critical field is undefined
128
                    push @missing_criticals, { key => $key, line => $., lineraw => $borrowerline };
129
                    push @missing_criticals, { key => $key, line => $., lineraw => decode_utf8($borrowerline) };
129
                }
130
                }
130
                else {
131
                else {
131
                    $borrower{$key} = '';
132
                    $borrower{$key} = '';
Lines 483-496 sub check_branch_code { Link Here
483
484
484
    # No branch code
485
    # No branch code
485
    unless( $branchcode ) {
486
    unless( $branchcode ) {
486
        push (@$missing_criticals, { key => 'branchcode', line => $line_number, lineraw => $borrowerline, });
487
        push (@$missing_criticals, { key => 'branchcode', line => $line_number, lineraw => decode_utf8($borrowerline), });
487
        return;
488
        return;
488
    }
489
    }
489
490
490
    # look for branch code
491
    # look for branch code
491
    my $library = Koha::Libraries->find( $branchcode );
492
    my $library = Koha::Libraries->find( $branchcode );
492
    unless( $library ) {
493
    unless( $library ) {
493
        push (@$missing_criticals, { key => 'branchcode', line => $line_number, lineraw => $borrowerline,
494
        push (@$missing_criticals, { key => 'branchcode', line => $line_number, lineraw => decode_utf8($borrowerline),
494
                                     value => $branchcode, branch_map => 1, });
495
                                     value => $branchcode, branch_map => 1, });
495
    }
496
    }
496
}
497
}
Lines 508-521 sub check_borrower_category { Link Here
508
509
509
    # No branch code
510
    # No branch code
510
    unless( $categorycode ) {
511
    unless( $categorycode ) {
511
        push (@$missing_criticals, { key => 'categorycode', line => $line_number, lineraw => $borrowerline, });
512
        push (@$missing_criticals, { key => 'categorycode', line => $line_number, lineraw => decode_utf8($borrowerline), });
512
        return;
513
        return;
513
    }
514
    }
514
515
515
    # Looking for borrower category
516
    # Looking for borrower category
516
    my $category = Koha::Patron::Categories->find($categorycode);
517
    my $category = Koha::Patron::Categories->find($categorycode);
517
    unless( $category ) {
518
    unless( $category ) {
518
        push (@$missing_criticals, { key => 'categorycode', line => $line_number, lineraw => $borrowerline,
519
        push (@$missing_criticals, { key => 'categorycode', line => $line_number, lineraw => decode_utf8($borrowerline),
519
                                     value => $categorycode, category_map => 1, });
520
                                     value => $categorycode, category_map => 1, });
520
    }
521
    }
521
}
522
}
Lines 540-546 sub format_dates { Link Here
540
            $params->{borrower}->{$date_type} = $formatted_date;
541
            $params->{borrower}->{$date_type} = $formatted_date;
541
        } else {
542
        } else {
542
            $params->{borrower}->{$date_type} = '';
543
            $params->{borrower}->{$date_type} = '';
543
            push (@{$params->{missing_criticals}}, { key => $date_type, line => $params->{line}, lineraw => $params->{lineraw}, bad_date => 1 });
544
            push (@{$params->{missing_criticals}}, { key => $date_type, line => $params->{line}, lineraw => decode_utf8($params->{lineraw}), bad_date => 1 });
544
        }
545
        }
545
    }
546
    }
546
}
547
}
547
- 

Return to bug 17359