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

(-)a/C4/Members.pm (-35 lines)
Lines 552-592 sub GetMemberIssuesAndFines { Link Here
552
}
552
}
553
553
554
554
555
=head2 columns
556
557
  my @columns = C4::Member::columns();
558
559
Returns an array of borrowers' table columns on success,
560
and an empty array on failure.
561
562
=cut
563
564
sub columns {
565
566
    # Pure ANSI SQL goodness.
567
    my $sql = 'SELECT * FROM borrowers WHERE 1=0;';
568
569
    # Get the database handle.
570
    my $dbh = C4::Context->dbh;
571
572
    # Run the SQL statement to load STH's readonly properties.
573
    my $sth = $dbh->prepare($sql);
574
    my $rv = $sth->execute();
575
576
    # This only fails if the table doesn't exist.
577
    # This will always be called AFTER an install or upgrade,
578
    # so borrowers will exist!
579
    my @data;
580
    if ($sth->{NUM_OF_FIELDS}>0) {
581
        @data = @{$sth->{NAME}};
582
    }
583
    else {
584
        @data = ();
585
    }
586
    return @data;
587
}
588
589
590
=head2 ModMember
555
=head2 ModMember
591
556
592
  my $success = ModMember(borrowernumber => $borrowernumber,
557
  my $success = ModMember(borrowernumber => $borrowernumber,
(-)a/t/db_dependent/Members/columns.t (-24 lines)
Lines 1-24 Link Here
1
#!/usr/bin/perl
2
#
3
# This is to test C4/Members
4
# It requires a working Koha database with the sample data
5
6
use Modern::Perl;
7
8
use Test::More tests => 2;
9
10
BEGIN {
11
    use_ok('C4::Members');
12
}
13
14
my @borrowers_columns = C4::Members::columns;
15
ok(
16
    $#borrowers_columns > 1,
17
    'C4::Member->column returned a reasonable number of columns ('
18
      . ( $#borrowers_columns + 1 ) . ')'
19
  )
20
  or diag(
21
'WARNING: Check that the borrowers table exists and has the correct fields defined.'
22
  );
23
24
exit;
(-)a/tools/import_borrowers.pl (-2 / +2 lines)
Lines 48-53 use C4::Members::Messaging; Link Here
48
use C4::Reports::Guided;
48
use C4::Reports::Guided;
49
use C4::Templates;
49
use C4::Templates;
50
use Koha::Patron::Debarments;
50
use Koha::Patron::Debarments;
51
use Koha::Patrons;
51
use Koha::DateUtils;
52
use Koha::DateUtils;
52
53
53
use Text::CSV;
54
use Text::CSV;
Lines 61-67 use CGI qw ( -utf8 ); Link Here
61
my (@errors, @feedback);
62
my (@errors, @feedback);
62
my $extended = C4::Context->preference('ExtendedPatronAttributes');
63
my $extended = C4::Context->preference('ExtendedPatronAttributes');
63
my $set_messaging_prefs = C4::Context->preference('EnhancedMessagingPreferences');
64
my $set_messaging_prefs = C4::Context->preference('EnhancedMessagingPreferences');
64
my @columnkeys = C4::Members::columns();
65
my @columnkeys = Koha::Patrons->columns();
65
@columnkeys = map { $_ ne 'borrowernumber' ? $_ : () } @columnkeys;
66
@columnkeys = map { $_ ne 'borrowernumber' ? $_ : () } @columnkeys;
66
if ($extended) {
67
if ($extended) {
67
    push @columnkeys, 'patron_attributes';
68
    push @columnkeys, 'patron_attributes';
68
- 

Return to bug 16889