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

(-)a/C4/Auth_with_ldap.pm (-1 lines)
Lines 461-467 C4::Auth - Authenticates Koha users Link Here
461
		| contactname         | mediumtext   | YES  |     | NULL    |                |
461
		| contactname         | mediumtext   | YES  |     | NULL    |                |
462
		| contactfirstname    | text         | YES  |     | NULL    |                |
462
		| contactfirstname    | text         | YES  |     | NULL    |                |
463
		| contacttitle        | text         | YES  |     | NULL    |                |
463
		| contacttitle        | text         | YES  |     | NULL    |                |
464
		| guarantorid         | int(11)      | YES  | MUL | NULL    |                |
465
		| borrowernotes       | mediumtext   | YES  |     | NULL    |                |
464
		| borrowernotes       | mediumtext   | YES  |     | NULL    |                |
466
		| relationship        | varchar(100) | YES  |     | NULL    |                |
465
		| relationship        | varchar(100) | YES  |     | NULL    |                |
467
		| ethnicity           | varchar(50)  | YES  |     | NULL    |                |
466
		| ethnicity           | varchar(50)  | YES  |     | NULL    |                |
(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 758-764 sub CanBookBeIssued { Link Here
758
    my $no_issues_charge_guarantees = C4::Context->preference("NoIssuesChargeGuarantees");
758
    my $no_issues_charge_guarantees = C4::Context->preference("NoIssuesChargeGuarantees");
759
    $no_issues_charge_guarantees = undef unless looks_like_number( $no_issues_charge_guarantees );
759
    $no_issues_charge_guarantees = undef unless looks_like_number( $no_issues_charge_guarantees );
760
    if ( defined $no_issues_charge_guarantees ) {
760
    if ( defined $no_issues_charge_guarantees ) {
761
        my @guarantees = $patron->guarantees();
761
        my @guarantees = map { $_->guarantee } $patron->guarantee_relationships();
762
        my $guarantees_non_issues_charges;
762
        my $guarantees_non_issues_charges;
763
        foreach my $g ( @guarantees ) {
763
        foreach my $g ( @guarantees ) {
764
            $guarantees_non_issues_charges += $g->account->non_issues_charges;
764
            $guarantees_non_issues_charges += $g->account->non_issues_charges;
(-)a/C4/Members.pm (-7 / +7 lines)
Lines 183-189 sub patronflags { Link Here
183
    $no_issues_charge_guarantees = undef unless looks_like_number( $no_issues_charge_guarantees );
183
    $no_issues_charge_guarantees = undef unless looks_like_number( $no_issues_charge_guarantees );
184
    if ( defined $no_issues_charge_guarantees ) {
184
    if ( defined $no_issues_charge_guarantees ) {
185
        my $p = Koha::Patrons->find( $patroninformation->{borrowernumber} );
185
        my $p = Koha::Patrons->find( $patroninformation->{borrowernumber} );
186
        my @guarantees = $p->guarantees();
186
        my @guarantees = map { $_->guarantee } $p->guarantee_relationships;
187
        my $guarantees_non_issues_charges;
187
        my $guarantees_non_issues_charges;
188
        foreach my $g ( @guarantees ) {
188
        foreach my $g ( @guarantees ) {
189
            $guarantees_non_issues_charges += $g->account->non_issues_charges;
189
            $guarantees_non_issues_charges += $g->account->non_issues_charges;
Lines 404-421 sub GetBorrowersToExpunge { Link Here
404
            FROM   borrowers
404
            FROM   borrowers
405
            JOIN   categories USING (categorycode)
405
            JOIN   categories USING (categorycode)
406
            LEFT JOIN (
406
            LEFT JOIN (
407
                SELECT guarantorid
407
                SELECT guarantor_id
408
                FROM borrowers
408
                FROM borrower_relationships
409
                WHERE guarantorid IS NOT NULL
409
                WHERE guarantor_id IS NOT NULL
410
                    AND guarantorid <> 0
410
                    AND guarantor_id <> 0
411
            ) as tmp ON borrowers.borrowernumber=tmp.guarantorid
411
            ) as tmp ON borrowers.borrowernumber=tmp.guarantor_id
412
            LEFT JOIN old_issues USING (borrowernumber)
412
            LEFT JOIN old_issues USING (borrowernumber)
413
            LEFT JOIN issues USING (borrowernumber)|;
413
            LEFT JOIN issues USING (borrowernumber)|;
414
    if ( $filterpatronlist  ){
414
    if ( $filterpatronlist  ){
415
        $query .= q| LEFT JOIN patron_list_patrons USING (borrowernumber)|;
415
        $query .= q| LEFT JOIN patron_list_patrons USING (borrowernumber)|;
416
    }
416
    }
417
    $query .= q| WHERE  category_type <> 'S'
417
    $query .= q| WHERE  category_type <> 'S'
418
        AND tmp.guarantorid IS NULL
418
        AND tmp.guarantor_id IS NULL
419
    |;
419
    |;
420
    my @query_params;
420
    my @query_params;
421
    if ( $filterbranch && $filterbranch ne "" ) {
421
    if ( $filterbranch && $filterbranch ne "" ) {
(-)a/C4/SIP/ILS/Patron.pm (-1 lines)
Lines 620-626 __END__ Link Here
620
| contactname         | mediumtext   | YES  |     | NULL    |                |
620
| contactname         | mediumtext   | YES  |     | NULL    |                |
621
| contactfirstname    | text         | YES  |     | NULL    |                |
621
| contactfirstname    | text         | YES  |     | NULL    |                |
622
| contacttitle        | text         | YES  |     | NULL    |                |
622
| contacttitle        | text         | YES  |     | NULL    |                |
623
| guarantorid         | int(11)      | YES  | MUL | NULL    |                |
624
| borrowernotes       | mediumtext   | YES  |     | NULL    |                |
623
| borrowernotes       | mediumtext   | YES  |     | NULL    |                |
625
| relationship        | varchar(100) | YES  |     | NULL    |                |
624
| relationship        | varchar(100) | YES  |     | NULL    |                |
626
| ethnicity           | varchar(50)  | YES  |     | NULL    |                |
625
| ethnicity           | varchar(50)  | YES  |     | NULL    |                |
(-)a/Koha/Object.pm (-2 / +6 lines)
Lines 72-79 sub new { Link Here
72
            next if not exists $attributes->{$column_name} or defined $attributes->{$column_name};
72
            next if not exists $attributes->{$column_name} or defined $attributes->{$column_name};
73
            delete $attributes->{$column_name};
73
            delete $attributes->{$column_name};
74
        }
74
        }
75
        $self->{_result} = $schema->resultset( $class->_type() )
75
76
          ->new($attributes);
76
        eval {
77
            $self->{_result} =
78
              $schema->resultset( $class->_type() )->new($attributes);
79
        };
80
        Carp::cluck("ERROR: $@") if $@;
77
    }
81
    }
78
82
79
    croak("No _type found! Koha::Object must be subclassed!")
83
    croak("No _type found! Koha::Object must be subclassed!")
(-)a/Koha/Patron.pm (-33 / +88 lines)
Lines 30-45 use C4::Context; Link Here
30
use C4::Log;
30
use C4::Log;
31
use Koha::AuthUtils;
31
use Koha::AuthUtils;
32
use Koha::Checkouts;
32
use Koha::Checkouts;
33
use Koha::Old::Checkouts;
33
use Koha::Database;
34
use Koha::Database;
34
use Koha::DateUtils;
35
use Koha::DateUtils;
35
use Koha::Exceptions::Password;
36
use Koha::Exceptions::Password;
36
use Koha::Holds;
37
use Koha::Holds;
37
use Koha::Old::Checkouts;
38
use Koha::Patrons;
38
use Koha::Patron::Categories;
39
use Koha::Patron::Categories;
40
use Koha::Patron::Relationships;
39
use Koha::Patron::HouseboundProfile;
41
use Koha::Patron::HouseboundProfile;
40
use Koha::Patron::HouseboundRole;
42
use Koha::Patron::HouseboundRole;
41
use Koha::Patron::Images;
43
use Koha::Patron::Images;
42
use Koha::Patrons;
43
use Koha::Virtualshelves;
44
use Koha::Virtualshelves;
44
use Koha::Club::Enrollments;
45
use Koha::Club::Enrollments;
45
use Koha::Account;
46
use Koha::Account;
Lines 198-204 sub store { Link Here
198
199
199
            # Set default values if not set
200
            # Set default values if not set
200
            $self->sms_provider_id(undef) unless $self->sms_provider_id;
201
            $self->sms_provider_id(undef) unless $self->sms_provider_id;
201
            $self->guarantorid(undef)     unless $self->guarantorid;
202
202
203
            unless ( $self->in_storage ) {    #AddMember
203
            unless ( $self->in_storage ) {    #AddMember
204
204
Lines 363-403 sub category { Link Here
363
    return Koha::Patron::Category->_new_from_dbic( $self->_result->categorycode );
363
    return Koha::Patron::Category->_new_from_dbic( $self->_result->categorycode );
364
}
364
}
365
365
366
=head3 guarantor
366
=head3 image
367
368
Returns a Koha::Patron object for this patron's guarantor
369
367
370
=cut
368
=cut
371
369
372
sub guarantor {
373
    my ( $self ) = @_;
374
375
    return unless $self->guarantorid();
376
377
    return Koha::Patrons->find( $self->guarantorid() );
378
}
379
380
sub image {
370
sub image {
381
    my ( $self ) = @_;
371
    my ( $self ) = @_;
382
372
383
    return scalar Koha::Patron::Images->find( $self->borrowernumber );
373
    return scalar Koha::Patron::Images->find( $self->borrowernumber );
384
}
374
}
385
375
376
=head3 library
377
378
Returns a Koha::Library object representing the patron's home library.
379
380
=cut
381
386
sub library {
382
sub library {
387
    my ( $self ) = @_;
383
    my ( $self ) = @_;
388
    return Koha::Library->_new_from_dbic($self->_result->branchcode);
384
    return Koha::Library->_new_from_dbic($self->_result->branchcode);
389
}
385
}
390
386
391
=head3 guarantees
387
=head3 guarantor_relationships
388
389
Returns Koha::Patron::Relationships object for this patron's guarantors
392
390
393
Returns the guarantees (list of Koha::Patron) of this patron
391
Returns the set of relationships for the patrons that are guarantors for this patron.
392
393
This is returned instead of a Koha::Patron object because the guarantor
394
may not exist as a patron in Koha. If this is true, the guarantors name
395
exists in the Koha::Patron::Relationship object and will have no guarantor_id.
394
396
395
=cut
397
=cut
396
398
397
sub guarantees {
399
sub guarantor_relationships {
398
    my ( $self ) = @_;
400
    my ($self) = @_;
399
401
400
    return Koha::Patrons->search( { guarantorid => $self->borrowernumber }, { order_by => { -asc => ['surname','firstname'] } } );
402
    return Koha::Patron::Relationships->search( { guarantee_id => $self->id } );
403
}
404
405
=head3 guarantee_relationships
406
407
Returns Koha::Patron::Relationships object for this patron's guarantors
408
409
Returns the set of relationships for the patrons that are guarantees for this patron.
410
411
The method returns Koha::Patron::Relationship objects for the sake
412
of consistency with the guantors method.
413
A guarantee by definition must exist as a patron in Koha.
414
415
=cut
416
417
sub guarantee_relationships {
418
    my ($self) = @_;
419
420
    return Koha::Patron::Relationships->search(
421
        { guarantor_id => $self->id },
422
        {
423
            prefetch => 'guarantee',
424
            order_by => { -asc => [ 'guarantee.surname', 'guarantee.firstname' ] },
425
        }
426
    );
401
}
427
}
402
428
403
=head3 housebound_profile
429
=head3 housebound_profile
Lines 435-457 Returns the siblings of this patron. Link Here
435
=cut
461
=cut
436
462
437
sub siblings {
463
sub siblings {
438
    my ( $self ) = @_;
464
    my ($self) = @_;
439
465
440
    my $guarantor = $self->guarantor;
466
    my @guarantors = $self->guarantor_relationships()->guarantors();
441
467
442
    return unless $guarantor;
468
    return unless @guarantors;
443
469
444
    return Koha::Patrons->search(
470
    my @siblings =
445
        {
471
      map { $_->guarantee_relationships()->guarantees() } @guarantors;
446
            guarantorid => {
472
447
                '!=' => undef,
473
    return unless @siblings;
448
                '=' => $guarantor->id,
474
449
            },
475
    my %seen;
450
            borrowernumber => {
476
    @siblings =
451
                '!=' => $self->borrowernumber,
477
      grep { !$seen{ $_->id }++ && ( $_->id != $self->id ) } @siblings;
452
            }
478
453
        }
479
    return wantarray ? @siblings : Koha::Patrons->search( { borrowernumber => { -in => [ map { $_->id } @siblings ] } } );
454
    );
455
}
480
}
456
481
457
=head3 merge_with
482
=head3 merge_with
Lines 1237-1242 my $is_child = $patron->is_child Link Here
1237
Return true if the patron has a category with a type Child (C)
1262
Return true if the patron has a category with a type Child (C)
1238
1263
1239
=cut
1264
=cut
1265
1240
sub is_child {
1266
sub is_child {
1241
    my( $self ) = @_;
1267
    my( $self ) = @_;
1242
    return $self->category->category_type eq 'C' ? 1 : 0;
1268
    return $self->category->category_type eq 'C' ? 1 : 0;
Lines 1308-1313 sub generate_userid { Link Here
1308
1334
1309
}
1335
}
1310
1336
1337
1338
=head3 add_guarantor
1339
1340
    my @relationships = $patron->add_guarantor(
1341
        {
1342
            borrowernumber => $borrowernumber,
1343
            relationships  => $relationship,
1344
        }
1345
    );
1346
1347
    Adds a new guarantor to a patron.
1348
1349
=cut
1350
1351
sub add_guarantor {
1352
    my ( $self, $params ) = @_;
1353
1354
    my $guarantor_id = $params->{guarantor_id};
1355
    my $relationship = $params->{relationship};
1356
1357
    return Koha::Patron::Relationship->new(
1358
        {
1359
            guarantee_id => $self->id,
1360
            guarantor_id => $guarantor_id,
1361
            relationship => $relationship
1362
        }
1363
    )->store();
1364
}
1365
1311
=head2 Internal methods
1366
=head2 Internal methods
1312
1367
1313
=head3 _type
1368
=head3 _type
(-)a/Koha/Patron/Relationship.pm (+73 lines)
Line 0 Link Here
1
package Koha::Patron::Relationship;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Carp;
21
22
use Koha::Database;
23
24
use base qw(Koha::Object);
25
26
=head1 NAME
27
28
Koha::Patron::Relationship - A class to represent relationships between patrons
29
30
Patrons in Koha may be guarantors or guarantees. This class models that relationship
31
and provides a way to access those relationships.
32
33
=head1 API
34
35
=head2 Class Methods
36
37
=cut
38
39
=head3 guarantor
40
41
Returns the Koha::Patron object for the guarantor, if there is one
42
43
=cut
44
45
sub guarantor {
46
    my ( $self ) = @_;
47
48
    return unless $self->guarantor_id;
49
50
    return scalar Koha::Patrons->find( $self->guarantor_id );
51
}
52
53
=head3 guarantee
54
55
Returns the Koha::Patron object for the guarantee
56
57
=cut
58
59
sub guarantee {
60
    my ( $self ) = @_;
61
62
    return scalar Koha::Patrons->find( $self->guarantee_id );
63
}
64
65
=head3 type
66
67
=cut
68
69
sub _type {
70
    return 'BorrowerRelationship';
71
}
72
73
1;
(-)a/Koha/Patron/Relationships.pm (+99 lines)
Line 0 Link Here
1
package Koha::Patron::Relationships;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Carp;
21
use List::MoreUtils qw( uniq );
22
23
use Koha::Database;
24
use Koha::Patrons;
25
use Koha::Patron::Relationship;
26
27
use base qw(Koha::Objects);
28
29
=head1 NAME
30
31
Koha::Patron::Relationships - Koha Patron Relationship Object set class
32
33
=head1 API
34
35
=head2 Class Methods
36
37
=cut
38
39
=head3 guarantors
40
41
Returns all the guarantors in this set of relationships as a list of Koha::Patron objects
42
or as a Koha::Patrons object depending on the calling context
43
44
=cut
45
46
sub guarantors {
47
    my ($self) = @_;
48
49
    my $rs = $self->_resultset();
50
51
    my @guarantor_ids = $rs->get_column('guarantor_id')->all();
52
    # Guarantors may not have a guarantor_id, strip out undefs
53
    @guarantor_ids = grep { defined $_ } @guarantor_ids;
54
    @guarantor_ids = uniq( @guarantor_ids );
55
56
    my $guarantors = Koha::Patrons->search( { borrowernumber => \@guarantor_ids } );
57
58
    return wantarray ? $guarantors->as_list : $guarantors;
59
}
60
61
=head3 guarantees
62
63
Returns all the guarantees in this set of relationships as a list of Koha::Patron objects
64
or as a Koha::Patrons object depending on the calling context
65
66
=cut
67
68
sub guarantees {
69
    my ($self) = @_;
70
71
    my $rs = $self->_resultset();
72
73
    my @guarantee_ids = uniq( $rs->get_column('guarantee_id')->all() );
74
75
    my $guarantees = Koha::Patrons->search(
76
        { borrowernumber => \@guarantee_ids },
77
        {
78
            order_by => { -asc => [ 'surname', 'firstname' ] }
79
        },
80
    );
81
82
    return wantarray ? $guarantees->as_list : $guarantees;
83
}
84
85
=cut
86
87
=head3 type
88
89
=cut
90
91
sub _type {
92
    return 'BorrowerRelationship';
93
}
94
95
sub object_class {
96
    return 'Koha::Patron::Relationship';
97
}
98
99
1;
(-)a/Koha/Patrons.pm (-12 lines)
Lines 125-142 sub search_upcoming_membership_expires { Link Here
125
    );
125
    );
126
}
126
}
127
127
128
=head3 guarantor
129
130
Returns a Koha::Patron object for this borrower's guarantor
131
132
=cut
133
134
sub guarantor {
135
    my ( $self ) = @_;
136
137
    return Koha::Patrons->find( $self->guarantorid() );
138
}
139
140
=head3 search_patrons_to_anonymise
128
=head3 search_patrons_to_anonymise
141
129
142
    my $patrons = Koha::Patrons->search_patrons_to_anonymise( { before => $older_than_date, [ library => $library ] } );
130
    my $patrons = Koha::Patrons->search_patrons_to_anonymise( { before => $older_than_date, [ library => $library ] } );
(-)a/Koha/Patrons/Import.pm (+16 lines)
Lines 213-218 sub import_patrons { Link Here
213
            next LINE;
213
            next LINE;
214
        }
214
        }
215
215
216
        my $relationship        = $borrower{relationship};
217
        my $guarantor_id        = $borrower{guarantor_id};
218
        delete $borrower{relationship};
219
        delete $borrower{guarantor_id};
220
216
        if ($borrowernumber) {
221
        if ($borrowernumber) {
217
222
218
            # borrower exists
223
            # borrower exists
Lines 349-354 sub import_patrons { Link Here
349
                );
354
                );
350
            }
355
            }
351
        }
356
        }
357
358
        # Add a guarantor if we are given a relationship
359
        if ( $guarantor_id ) {
360
            Koha::Patron::Relationship->new(
361
                {
362
                    guarantee_id => $borrowernumber,
363
                    relationship => $relationship,
364
                    guarantor_id => $guarantor_id,
365
                }
366
            )->store();
367
        }
352
    }
368
    }
353
369
354
    return {
370
    return {
(-)a/Koha/REST/V1/Auth.pm (-1 / +1 lines)
Lines 284-290 sub allow_guarantor { Link Here
284
        return;
284
        return;
285
    }
285
    }
286
286
287
    my $guarantees = $user->guarantees->as_list;
287
    my $guarantees = $user->guarantee_relationships->guarantees->as_list;
288
    foreach my $guarantee (@{$guarantees}) {
288
    foreach my $guarantee (@{$guarantees}) {
289
        return 1 if check_object_ownership($c, $guarantee);
289
        return 1 if check_object_ownership($c, $guarantee);
290
    }
290
    }
(-)a/Koha/Schema/Result/Borrower.pm (-6 lines)
Lines 1419-1430 __PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber"); Link Here
1419
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-09-20 13:00:20
1419
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-09-20 13:00:20
1420
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QT6EPIG26F/kNK6prauRgw
1420
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QT6EPIG26F/kNK6prauRgw
1421
1421
1422
__PACKAGE__->belongs_to(
1423
    "guarantor",
1424
    "Koha::Schema::Result::Borrower",
1425
    { borrowernumber => "guarantorid" },
1426
);
1427
1428
__PACKAGE__->add_columns(
1422
__PACKAGE__->add_columns(
1429
    '+lost' => { is_boolean => 1 },
1423
    '+lost' => { is_boolean => 1 },
1430
    '+gonenoaddress' => { is_boolean => 1 }
1424
    '+gonenoaddress' => { is_boolean => 1 }
(-)a/Koha/Schema/Result/BorrowerRelationship.pm (+118 lines)
Line 0 Link Here
1
use utf8;
2
package Koha::Schema::Result::BorrowerRelationship;
3
4
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7
=head1 NAME
8
9
Koha::Schema::Result::BorrowerRelationship
10
11
=cut
12
13
use strict;
14
use warnings;
15
16
use base 'DBIx::Class::Core';
17
18
=head1 TABLE: C<borrower_relationships>
19
20
=cut
21
22
__PACKAGE__->table("borrower_relationships");
23
24
=head1 ACCESSORS
25
26
=head2 id
27
28
  data_type: 'integer'
29
  is_auto_increment: 1
30
  is_nullable: 0
31
32
=head2 guarantor_id
33
34
  data_type: 'integer'
35
  is_foreign_key: 1
36
  is_nullable: 1
37
38
=head2 guarantee_id
39
40
  data_type: 'integer'
41
  is_foreign_key: 1
42
  is_nullable: 0
43
44
=head2 relationship
45
46
  data_type: 'varchar'
47
  is_nullable: 0
48
  size: 100
49
50
=cut
51
52
__PACKAGE__->add_columns(
53
  "id",
54
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
55
  "guarantor_id",
56
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
57
  "guarantee_id",
58
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
59
  "relationship",
60
  { data_type => "varchar", is_nullable => 0, size => 100 },
61
);
62
63
=head1 PRIMARY KEY
64
65
=over 4
66
67
=item * L</id>
68
69
=back
70
71
=cut
72
73
__PACKAGE__->set_primary_key("id");
74
75
=head1 RELATIONS
76
77
=head2 guarantee
78
79
Type: belongs_to
80
81
Related object: L<Koha::Schema::Result::Borrower>
82
83
=cut
84
85
__PACKAGE__->belongs_to(
86
  "guarantee",
87
  "Koha::Schema::Result::Borrower",
88
  { borrowernumber => "guarantee_id" },
89
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
90
);
91
92
=head2 guarantor
93
94
Type: belongs_to
95
96
Related object: L<Koha::Schema::Result::Borrower>
97
98
=cut
99
100
__PACKAGE__->belongs_to(
101
  "guarantor",
102
  "Koha::Schema::Result::Borrower",
103
  { borrowernumber => "guarantor_id" },
104
  {
105
    is_deferrable => 1,
106
    join_type     => "LEFT",
107
    on_delete     => "CASCADE",
108
    on_update     => "CASCADE",
109
  },
110
);
111
112
113
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2018-07-18 10:52:59
114
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:R8RThgcrct40Zq0UMW3TWQ
115
116
117
# You can replace this text with custom code or comments, and it will be preserved on regeneration
118
1;
(-)a/api/v1/swagger/definitions/patron.json (-4 lines)
Lines 159-168 Link Here
159
      "readOnly": true,
159
      "readOnly": true,
160
      "description": "If any restriction applies to the patron"
160
      "description": "If any restriction applies to the patron"
161
    },
161
    },
162
    "guarantor_id": {
163
      "type": ["integer", "null"],
164
      "description": "patron_id used for children or professionals to link them to guarantor or organizations"
165
    },
166
    "staff_notes": {
162
    "staff_notes": {
167
      "type": ["string", "null"],
163
      "type": ["string", "null"],
168
      "description": "a note on the patron's account"
164
      "description": "a note on the patron's account"
(-)a/circ/circulation.pl (-8 / +6 lines)
Lines 565-578 my $view = $batch Link Here
565
    : 'circview';
565
    : 'circview';
566
566
567
my @relatives;
567
my @relatives;
568
if ( $borrowernumber ) {
568
if ( $patron ) {
569
    if ( $patron ) {
569
    if ( my @guarantors = $patron->guarantor_relationships()->guarantors() ) {
570
        if ( my $guarantor = $patron->guarantor ) {
570
        push( @relatives, $_->id ) for @guarantors;
571
            push @relatives, $guarantor->borrowernumber;
571
        push( @relatives, $_->id ) for $patron->siblings();
572
            push @relatives, $_->borrowernumber for $patron->siblings;
572
    } else {
573
        } else {
573
        push( @relatives, $_->id ) for $patron->guarantee_relationships()->guarantees();
574
            push @relatives, $_->borrowernumber for $patron->guarantees;
575
        }
576
    }
574
    }
577
}
575
}
578
my $relatives_issues_count =
576
my $relatives_issues_count =
(-)a/installer/data/mysql/atomicupdate/bug_14570.perl (+52 lines)
Line 0 Link Here
1
$DBversion = 'XXX';  # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    # you can use $dbh here like:
4
    # $dbh->do( "ALTER TABLE biblio ADD COLUMN badtaste int" );
5
    unless (TableExists('borrower_relationships')){
6
        $dbh->do(q{
7
            CREATE TABLE `borrower_relationships` (
8
                  id INT(11) NOT NULL AUTO_INCREMENT,
9
                  guarantor_id INT(11) NOT NULL,
10
                  guarantee_id INT(11) NOT NULL,
11
                  relationship VARCHAR(100) NOT NULL,
12
                  PRIMARY KEY (id),
13
                  CONSTRAINT r_guarantor FOREIGN KEY ( guarantor_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE,
14
                  CONSTRAINT r_guarantee FOREIGN KEY ( guarantee_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE
15
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
16
        });
17
18
        $dbh->do(q{
19
            UPDATE borrowers
20
            LEFT JOIN borrowers guarantor ON ( borrowers.guarantorid = guarantor.borrowernumber )
21
            SET borrowers.guarantorid = NULL WHERE guarantor.borrowernumber IS NULL;
22
        });
23
24
        $dbh->do(q{
25
            INSERT INTO borrower_relationships ( guarantor_id, guarantee_id, relationship )
26
            SELECT guarantorid, borrowernumber, relationship FROM borrowers WHERE guarantorid IS NOT NULL;
27
        });
28
29
    }
30
31
     if( column_exists( 'borrowers', 'guarantorid' ) ) {
32
        $dbh->do(q{
33
            ALTER TABLE borrowers DROP guarantorid;
34
        });
35
     }
36
37
     if( column_exists( 'deletedborrowers', 'guarantorid' ) ) {
38
        $dbh->do(q{
39
            ALTER TABLE deletedborrowers DROP guarantorid;
40
        });
41
     }
42
43
     if( column_exists( 'borrower_modifications', 'guarantorid' ) ) {
44
        $dbh->do(q{
45
            ALTER TABLE borrower_modifications DROP guarantorid;
46
        });
47
     }
48
49
    # Always end with this (adjust the bug info)
50
    SetVersion( $DBversion );
51
    print "Upgrade to $DBversion done (Bug 14570 - Make it possible to add multiple guarantors to a record)\n";
52
}
(-)a/installer/data/mysql/kohastructure.sql (-8 / +15 lines)
Lines 595-601 CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/borrower Link Here
595
  `contactname` LONGTEXT, -- used for children and profesionals to include surname or last name of guarantor or organization name
595
  `contactname` LONGTEXT, -- used for children and profesionals to include surname or last name of guarantor or organization name
596
  `contactfirstname` MEDIUMTEXT, -- used for children to include first name of guarantor
596
  `contactfirstname` MEDIUMTEXT, -- used for children to include first name of guarantor
597
  `contacttitle` MEDIUMTEXT, -- used for children to include title (Mr., Mrs., etc) of guarantor
597
  `contacttitle` MEDIUMTEXT, -- used for children to include title (Mr., Mrs., etc) of guarantor
598
  `guarantorid` int(11) default NULL, -- borrowernumber used for children or professionals to link them to guarantors or organizations
599
  `borrowernotes` LONGTEXT, -- a note on the patron/borrower's account that is only visible in the staff client
598
  `borrowernotes` LONGTEXT, -- a note on the patron/borrower's account that is only visible in the staff client
600
  `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarantor
599
  `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarantor
601
  `sex` varchar(1) default NULL, -- patron/borrower's gender
600
  `sex` varchar(1) default NULL, -- patron/borrower's gender
Lines 1625-1631 CREATE TABLE `borrowers` ( -- this table includes information about your patrons Link Here
1625
  `contactname` LONGTEXT, -- used for children and profesionals to include surname or last name of guarantor or organization name
1624
  `contactname` LONGTEXT, -- used for children and profesionals to include surname or last name of guarantor or organization name
1626
  `contactfirstname` MEDIUMTEXT, -- used for children to include first name of guarantor
1625
  `contactfirstname` MEDIUMTEXT, -- used for children to include first name of guarantor
1627
  `contacttitle` MEDIUMTEXT, -- used for children to include title (Mr., Mrs., etc) of guarantor
1626
  `contacttitle` MEDIUMTEXT, -- used for children to include title (Mr., Mrs., etc) of guarantor
1628
  `guarantorid` int(11) default NULL, -- borrowernumber used for children or professionals to link them to guarantors or organizations
1629
  `borrowernotes` LONGTEXT, -- a note on the patron/borrower's account that is only visible in the staff client
1627
  `borrowernotes` LONGTEXT, -- a note on the patron/borrower's account that is only visible in the staff client
1630
  `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarantor
1628
  `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarantor
1631
  `sex` varchar(1) default NULL, -- patron/borrower's gender
1629
  `sex` varchar(1) default NULL, -- patron/borrower's gender
Lines 1660-1666 CREATE TABLE `borrowers` ( -- this table includes information about your patrons Link Here
1660
  KEY `categorycode` (`categorycode`),
1658
  KEY `categorycode` (`categorycode`),
1661
  KEY `branchcode` (`branchcode`),
1659
  KEY `branchcode` (`branchcode`),
1662
  UNIQUE KEY `userid` (`userid`),
1660
  UNIQUE KEY `userid` (`userid`),
1663
  KEY `guarantorid` (`guarantorid`),
1664
  KEY `surname_idx` (`surname` (191)),
1661
  KEY `surname_idx` (`surname` (191)),
1665
  KEY `firstname_idx` (`firstname` (191)),
1662
  KEY `firstname_idx` (`firstname` (191)),
1666
  KEY `othernames_idx` (`othernames` (191)),
1663
  KEY `othernames_idx` (`othernames` (191)),
Lines 3434-3445 CREATE TABLE IF NOT EXISTS `borrower_modifications` ( Link Here
3434
  `lost` tinyint(1) DEFAULT NULL,
3431
  `lost` tinyint(1) DEFAULT NULL,
3435
  `debarred` date DEFAULT NULL,
3432
  `debarred` date DEFAULT NULL,
3436
  `debarredcomment` varchar(255) DEFAULT NULL,
3433
  `debarredcomment` varchar(255) DEFAULT NULL,
3437
  `contactname` LONGTEXT,
3438
  `contactfirstname` MEDIUMTEXT,
3439
  `contacttitle` MEDIUMTEXT,
3440
  `guarantorid` int(11) DEFAULT NULL,
3441
  `borrowernotes` LONGTEXT,
3434
  `borrowernotes` LONGTEXT,
3442
  `relationship` varchar(100) DEFAULT NULL,
3443
  `sex` varchar(1) DEFAULT NULL,
3435
  `sex` varchar(1) DEFAULT NULL,
3444
  `password` varchar(30) DEFAULT NULL,
3436
  `password` varchar(30) DEFAULT NULL,
3445
  `flags` int(11) DEFAULT NULL,
3437
  `flags` int(11) DEFAULT NULL,
Lines 4135-4140 CREATE TABLE IF NOT EXISTS club_fields ( Link Here
4135
  CONSTRAINT club_fields_ibfk_4 FOREIGN KEY (club_id) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE
4127
  CONSTRAINT club_fields_ibfk_4 FOREIGN KEY (club_id) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE
4136
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4128
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4137
4129
4130
--
4131
-- Table structure for table 'guarantors_guarantees'
4132
--
4133
4134
DROP TABLE IF EXISTS borrower_relationships;
4135
CREATE TABLE `borrower_relationships` (
4136
      id INT(11) NOT NULL AUTO_INCREMENT,
4137
      guarantor_id INT(11) NULL DEFAULT NULL,
4138
      guarantee_id INT(11) NOT NULL,
4139
      relationship VARCHAR(100) NOT NULL,
4140
      PRIMARY KEY (id),
4141
      CONSTRAINT r_guarantor FOREIGN KEY ( guarantor_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE,
4142
      CONSTRAINT r_guarantee FOREIGN KEY ( guarantee_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE
4143
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4144
4138
--
4145
--
4139
-- Table structure for table `illrequests`
4146
-- Table structure for table `illrequests`
4140
--
4147
--
(-)a/koha-tmpl/intranet-tmpl/prog/en/columns.def (-1 lines)
Lines 7-13 Link Here
7
<field name="borrowers.othernames">Other name</field>
7
<field name="borrowers.othernames">Other name</field>
8
<field name="borrowers.sex">Gender</field>
8
<field name="borrowers.sex">Gender</field>
9
<field name="borrowers.relationship">Relationship</field>
9
<field name="borrowers.relationship">Relationship</field>
10
<field name="borrowers.guarantorid">Guarantor borrower number</field>
11
<field name="borrowers.streetnumber">Street number</field>
10
<field name="borrowers.streetnumber">Street number</field>
12
<field name="borrowers.streettype">Street type</field>
11
<field name="borrowers.streettype">Street type</field>
13
<field name="borrowers.address">Address</field>
12
<field name="borrowers.address">Address</field>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc (-10 / +6 lines)
Lines 6-26 Link Here
6
[% USE AuthorisedValues %]
6
[% USE AuthorisedValues %]
7
<div id="toolbar" class="btn-toolbar">
7
<div id="toolbar" class="btn-toolbar">
8
    [% IF CAN_user_borrowers_edit_borrowers %]
8
    [% IF CAN_user_borrowers_edit_borrowers %]
9
        [% IF ( guarantor ) %]
9
        <a id="editpatron" class="btn btn-default btn-sm" href="/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% patron.borrowernumber | html %]&amp;categorycode=[% patron.categorycode | html %]">
10
            <a id="editpatron" class="btn btn-default btn-sm" href="/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% patron.borrowernumber | html %]&amp;guarantorid=[% guarantor.borrowernumber | html %]&amp;categorycode=[% patron.categorycode | html %]">
10
            <i class="fa fa-pencil"></i> Edit
11
        [% ELSE %]
11
        </a>
12
            <a id="editpatron" class="btn btn-default btn-sm" href="/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% patron.borrowernumber | html %]&amp;categorycode=[% patron.categorycode | html %]">
13
        [% END %]
14
        <i class="fa fa-pencil"></i> Edit</a>
15
    [% END %]
12
    [% END %]
16
13
17
    [% IF CAN_user_borrowers_edit_borrowers %]
14
    [% IF CAN_user_borrowers_edit_borrowers %]
18
        [% IF patron.is_adult AND Koha.Preference("borrowerRelationship") %]
15
        [% IF patron.is_adult AND Koha.Preference("borrowerRelationship") %]
19
            <a id="addchild" class="btn btn-default btn-sm" href="/cgi-bin/koha/members/memberentry.pl?op=add&amp;guarantorid=[% patron.borrowernumber | html %]"><i class="fa fa-plus"></i> Add child</a>
16
            <a id="addchild" class="btn btn-default btn-sm" href="/cgi-bin/koha/members/memberentry.pl?op=add&amp;guarantor_id=[% patron.borrowernumber | html %]"><i class="fa fa-plus"></i> Add child</a>
20
        [% END %]
21
        [% IF CAN_user_borrowers_edit_borrowers %]
22
            <a id="changepassword" class="btn btn-default btn-sm" href="/cgi-bin/koha/members/member-password.pl?member=[% patron.borrowernumber | html %]"><i class="fa fa-lock"></i> Change password</a>
23
        [% END %]
17
        [% END %]
18
19
        <a id="changepassword" class="btn btn-default btn-sm" href="/cgi-bin/koha/members/member-password.pl?member=[% patron.borrowernumber | html %]"><i class="fa fa-lock"></i> Change password</a>
24
        <a id="duplicate" class="btn btn-default btn-sm" href="/cgi-bin/koha/members/memberentry.pl?op=duplicate&amp;borrowernumber=[% patron.borrowernumber | html %]&amp;categorycode=[% patron.categorycode | html %]"><i class="fa fa-copy"></i> Duplicate</a>
20
        <a id="duplicate" class="btn btn-default btn-sm" href="/cgi-bin/koha/members/memberentry.pl?op=duplicate&amp;borrowernumber=[% patron.borrowernumber | html %]&amp;categorycode=[% patron.categorycode | html %]"><i class="fa fa-copy"></i> Duplicate</a>
25
    [% END %]
21
    [% END %]
26
22
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-1 / +1 lines)
Lines 808-814 No patron matched <span class="ex">[% message | html %]</span> Link Here
808
    </li>
808
    </li>
809
809
810
    [% IF relatives_issues_count %]
810
    [% IF relatives_issues_count %]
811
        <li><a id="relatives-issues-tab" href="#relatives-issues">Relatives' checkouts</a></li>
811
        <li><a id="relatives-issues-tab" href="#relatives-issues">[% relatives_issues_count %] Relatives' checkouts</a></li>
812
    [% END %]
812
    [% END %]
813
813
814
    <li>
814
    <li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-170 / +233 lines)
Lines 1-5 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE To %]
3
[% USE Koha %]
4
[% USE Koha %]
4
[% USE KohaDates %]
5
[% USE KohaDates %]
5
[% USE Branches %]
6
[% USE Branches %]
Lines 312-424 Link Here
312
	</fieldset>
313
	</fieldset>
313
[% END # hide fieldset %]
314
[% END # hide fieldset %]
314
315
315
[% IF ( showguarantor ) %]
316
[% IF show_guarantor || guarantor %]
316
    <input type="hidden" id="guarantorid" name="guarantorid"   value="[% guarantorid | html %]" />
317
    [% SET possible_relationships = Koha.Preference('borrowerRelationship') %]
317
    [% UNLESS step_6 %]
318
    <fieldset class="rows">
318
        <input type="hidden" name="branchcode" value="[% branchcode | html %]" />
319
        <legend>Guarantor information</legend>
319
    [% END %]
320
320
    <fieldset id="memberentry_guarantor" class="rows">
321
        <span id="guarantor_relationships">
321
        <legend id="guarantor_lgd">Guarantor information</legend>
322
            [% FOREACH r IN relationships %]
322
        <ol>
323
                <fieldset class="rows">
323
[% IF ( P ) %]
324
                    <ol>
324
	        [% IF ( guarantorid ) %]
325
                        [% IF category_type == 'P' %]
325
	        <li id="contact-details">
326
                            <li id="contact-details">
326
	        [% ELSE %]
327
                                <span class="label">Organization #:</span> [% IF ( r.guarantor_id ) %] <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% r.guarantor_id | $raw %]" target="blank">[% r.guarantor_id | $raw %]</a>[% END %]
327
	        <li id="contact-details" style="display: none">
328
                            </li>
328
	        [% END %]
329
329
	            <span class="label">Organization #:</span> [% IF ( guarantorid ) %] <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantorid | html %]" target="blank">[% guarantorid | html %]</a>[% END %]
330
                            <li>
330
	        </li>
331
                                <label for="guarantor_surname">Organization name: </label>
331
	        <li>
332
                                <span>[% r.guarantor.surname | html %]</span>
332
	            <label for="contactname">Organization name: </label>
333
                            </li>
333
	            [% IF ( guarantorid ) %]
334
                        [% ELSE %]
334
	            <span>[% contactname | html %]</span>
335
                            <li id="contact-details">
335
	            <input name="contactname" id="contactname" type="hidden" size="20" value="[% contactname | html %]" />
336
                                <span class="label">Patron #:</span>
336
	            [% ELSE %]
337
                                <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% r.guarantor_id | $raw %]" target="blank">[% r.guarantor_id | $raw %]</a>
337
                    <input name="contactname" id="contactname" type="text" size="20" value="[% contactname | html %]" />
338
                            </li>
338
	            [% END %]
339
339
	        </li>
340
                            [% IF r.guarantor.surname %]
340
[% ELSE %]
341
                                <li>
341
 [% IF ( C ) %]
342
                                    <label for="guarantor_surname">Surname: </label>
342
 [% IF ( guarantorid ) %]
343
                                    <span>[% r.guarantor.surname | html %]</span>
343
 <li id="contact-details">
344
                                </li>
344
 [% ELSE %]
345
                            [% END %]
345
 <li id="contact-details" style="display: none">
346
346
 [% END %]
347
                            [% IF r.guarantor.firstname %]
347
     <span class="label">Patron #:</span>
348
                                <li>
348
     [% IF guarantorid %]
349
                                    <label for="guarantor_firstname">First name: </label>
349
        [% IF logged_in_user.can_see_patron_infos( guarantor ) %]
350
                                    <span>[% r.guarantor.firstname | html %]</span>
350
            <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantorid | html %]" target="blank">[% guarantorid | html %]</a>
351
                                </li>
351
        [% ELSE %]
352
                            [% END %]
352
            [% guarantorid | html %]
353
353
        [% END %]
354
                            <li>
354
    [% END %]
355
                                <label for="relationship">Relationship: </label>
355
 </li>
356
                                <span>[% r.relationship | html %]</span>
356
        [% UNLESS nocontactname %]
357
                            </li>
357
 <li>
358
358
     <label for="contactname">Surname: </label>
359
                            <li>
359
     [% IF ( guarantorid ) %]
360
                                <label for="delete_guarantor-[% r.id | $raw %]">Delete: </label>
360
     <span>[% contactname | html %]</span>
361
                                <input type="checkbox" id="delete_guarantor-[% r.id | $raw %]" name="delete_guarantor" value="[% r.id | $raw %]" />
361
     <input name="contactname" id="contactname" type="hidden" size="20" value="[% contactname | html %]" />
362
                            </li>
362
     [% ELSE %]
363
                        [% END %]
363
        <input name="contactname" id="contactname" type="text" size="20" value="[% contactname | html %]" />
364
                    </ol>
364
     [% END %]
365
                </fieldset>
365
 </li>
366
            [% END # END relationships foreach %]
366
        [% END %]
367
        </span>
367
        [% UNLESS nocontactfirstname %]
368
368
 <li>
369
        <fieldset class="rows guarantor" id="guarantor_template">
369
     <label for="contactfirstname">First name: </label>
370
            <ol>
370
     [% IF ( guarantorid ) %]
371
                <li class="guarantor_id">
371
     <span>[% contactfirstname | html %]</span>
372
                    <span class="label">Patron #:</span>
372
     <input name="contactfirstname" id="contactfirstname" type="hidden" size="20" value="[% contactfirstname | html %]" />
373
                    <span class="new_guarantor_id_text"></span>
373
     [% ELSE %]
374
                    <input type="hidden" class="new_guarantor_id" name="new_guarantor_id" value=""/>
374
        <input name="contactfirstname" id="contactfirstname" type="text" size="20" value="[% contactfirstname | html %]" />
375
                </li>
375
     [% END %]
376
376
 </li>
377
                <li>
377
        [% END %]
378
                    <label for="guarantor_surname">Surname: </label>
378
 [% IF ( relshiploop ) %]
379
                    <span class="new_guarantor_surname_text"></span>
379
 <li>
380
                </li>
380
     <label for="relationship">Relationship: </label>
381
381
     <select name="relationship" id="relationship" >
382
                <li>
382
         [% FOREACH relshiploo IN relshiploop %]
383
                    <label for="guarantor_firstname">First name: </label>
383
         [% IF ( relshiploo.selected ) %]
384
                    <span class="new_guarantor_firstname_text"></span>
384
         <option value="[% relshiploo.relationship | html %]" selected="selected" >[% relshiploo.relationship | html %]</option>
385
                </li>
385
         [% ELSE %]
386
386
         <option value="[% relshiploo.relationship | html %]">[% relshiploo.relationship | html %]</option>
387
                <li>
387
         [% END %]
388
                    <label for="guarantor_relationship">Relationship: </label>
388
         [% END %]
389
                    <select class="new_guarantor_relationship" name="new_guarantor_relationship">
389
     </select>
390
                        [% FOREACH pr IN possible_relationships.split('\|') %]
390
 </li>
391
                            <option value="[% pr | html %]">[% pr | html %]</option>
391
 [% END %]
392
                        [% END %]
392
 [% END %]
393
                    </select>
393
[% END %]
394
                </li>
394
        <li>
395
395
            <span class="label">&nbsp;</span>
396
                <li>
396
            [% IF ( guarantorid ) %]
397
                    <label for="guarantor_cancel">&nbsp;</label>
397
            <input id="guarantorsearch" type="button" value="Change" onclick="Dopopguarantor('guarantor_search.pl');" />
398
                    <span><a href="#" class="guarantor_cancel">Cancel</a></span>
398
            [% ELSE %]
399
                </li>
399
            <input id="guarantorsearch" type="button" value="Set to patron" onclick="Dopopguarantor('guarantor_search.pl');" />
400
            </ol>
400
            [% END %]
401
        </fieldset>
401
            <input id="guarantordelete" type="button" value="Delete" />
402
402
        </li>
403
            <ol>
403
    [% IF guarantorid && Koha.Preference('AllowStaffToSetCheckoutsVisibilityForGuarantor') %]
404
                <input type="hidden" id="guarantor_id" value="" />
404
        <li>
405
                <input name="guarantor_surname" id="guarantor_surname" type="hidden" />
405
            <label for="privacy_guarantor_checkouts">Show checkouts to guarantor</label>
406
                <input name="guarantor_firstname" id="guarantor_firstname" type="hidden" />
406
            <select name="privacy_guarantor_checkouts" id="privacy_guarantor_checkouts">
407
407
                [% IF privacy_guarantor_checkouts %]
408
                <li>
408
                    <option value="0">No</option>
409
                    <a href="#" id="guarantor_search" class="btn btn-sm"><i class="fa fa-search"></i> Search</a>
409
                    <option value="1" selected>Yes</option>
410
                </li>
410
                [% ELSE %]
411
411
                    <option value="0" selected>No</option>
412
                [% IF relationships && Koha.Preference('AllowStaffToSetCheckoutsVisibilityForGuarantor') %]
412
                    <option value="1">Yes</option>
413
                    <li>
414
                        <label for="privacy_guarantor_checkouts">Show checkouts to guarantors</label>
415
                        <select name="privacy_guarantor_checkouts" id="privacy_guarantor_checkouts">
416
                            [% IF privacy_guarantor_checkouts %]
417
                                <option value="0">No</option>
418
                                <option value="1" selected>Yes</option>
419
                            [% ELSE %]
420
                                <option value="0" selected>No</option>
421
                                <option value="1">Yes</option>
422
                            [% END %]
423
                        </select>
424
                        <div class="hint">Allow guarantors of this patron to view this patron's checkouts from the OPAC</div>
425
                    </li>
413
                [% END %]
426
                [% END %]
414
            </select>
427
            </ol>
415
            <div class="hint">Allow guarantor of this patron to view this patron's checkouts from the OPAC</div>
416
        </li>
417
    [% END %]
418
        </ol>
419
    </fieldset>
428
    </fieldset>
420
421
[% END %]
429
[% END %]
430
431
422
[% UNLESS noaddress && noaddress2 && nocity && nostate && nozipcode && nocountry %]
432
[% UNLESS noaddress && noaddress2 && nocity && nostate && nozipcode && nocountry %]
423
    [% SWITCH Koha.Preference( 'AddressFormat' ) %]
433
    [% SWITCH Koha.Preference( 'AddressFormat' ) %]
424
        [% CASE 'de' %]
434
        [% CASE 'de' %]
Lines 429-512 Link Here
429
[% END # nostreet && nocity etc group%]
439
[% END # nostreet && nocity etc group%]
430
440
431
[% UNLESS nophone && nophonepro && nomobile && noemail && noemailpro && nofax %]
441
[% UNLESS nophone && nophonepro && nomobile && noemail && noemailpro && nofax %]
432
  <fieldset class="rows" id="memberentry_contact">
442
    <fieldset class="rows" id="memberentry_contact">
433
    <legend id="contact_lgd">Contact</legend><ol>
443
        <legend id="contact_lgd">Contact</legend><ol>
434
        [% UNLESS nophone %]
435
      <li>
436
      [% IF ( mandatoryphone ) %]
437
      <label for="phone" class="required">
438
      [% ELSE %]
439
      <label for="phone">
440
      [% END %]
441
      Primary phone: </label>
442
        <input type="text" id="phone" name="phone" value="[% phone | html %]" />
443
	  [% IF ( mandatoryphone ) %]<span class="required">Required</span>[% END %]<div class="hint">Shows on transit slips</div>
444
444
445
    </li>
445
        [% UNLESS nocontactname %]
446
            <li>
447
                [% IF ( mandatorycontactname ) %]
448
                    <label for="contactname" class="required">
449
                [% ELSE %]
450
                    <label for="contactname">
451
                [% END %]
452
                Guarantor surname: </label>
453
                <input type="text" id="contactname" name="contactname" value="[% contactname | html %]" />
454
                [% IF ( mandatorycontactname ) %]<span class="required">Required</span>[% END %]<div class="hint">Non-patron guarantor surname</div>
455
            </li>
446
        [% END %]
456
        [% END %]
457
458
        [% UNLESS nocontactfirstname %]
459
            <li>
460
                [% IF ( mandatorycontactfirstname ) %]
461
                    <label for="contactfirstname" class="required">
462
                [% ELSE %]
463
                    <label for="contactfirstname">
464
                [% END %]
465
                Guarantor first name: </label>
466
                <input type="text" id="contactfirstname" name="contactfirstname" value="[% contactfirstname | html %]" />
467
                [% IF ( mandatorycontactfirstname ) %]<span class="required">Required</span>[% END %]<div class="hint">Non-patron guarantor first name</div>
468
            </li>
469
        [% END %]
470
471
		[% UNLESS norelationship %]
472
			[% IF possible_relationships %]
473
                <li>
474
                    <label for="relationship">Relationship: </label>
475
                    <select class="relationship" name="relationship">
476
                        <option value=""></option>
477
                        [% FOREACH pr IN possible_relationships.split('\|') %]
478
                            [% IF pr == relationship %]
479
                                <option value="[% pr %]" selected="selected">[% pr %]</option>
480
                            [% ELSE %]
481
                                <option value="[% pr %]">[% pr %]</option>
482
                            [% END %]
483
                        [% END %]
484
                    </select>
485
                </li>
486
			[% END %]
487
		[% END %]
488
489
        [% UNLESS nophone %]
490
            <li>
491
                [% IF ( mandatoryphone ) %]
492
                    <label for="phone" class="required">
493
                [% ELSE %]
494
                    <label for="phone">
495
                [% END %]
496
                Primary phone: </label>
497
                <input type="text" id="phone" name="phone" value="[% phone | html %]" />
498
                [% IF ( mandatoryphone ) %]<span class="required">Required</span>[% END %]<div class="hint">Shows on transit slips</div>
499
            </li>
500
        [% END %]
501
447
        [% UNLESS nophonepro %]
502
        [% UNLESS nophonepro %]
448
    <li>
503
            <li>
449
      [% IF ( mandatoryphonepro ) %]
504
                [% IF ( mandatoryphonepro ) %]
450
      <label for="phonepro" class="required">
505
                    <label for="phonepro" class="required">
451
      [% ELSE %]
506
                [% ELSE %]
452
      <label for="phonepro">
507
                    <label for="phonepro">
453
      [% END %]
508
                [% END %]
454
      Secondary phone: </label>
509
                Secondary phone: </label>
455
    <input type="text" id="phonepro" name="phonepro" value="[% phonepro | html %]" />
510
                <input type="text" id="phonepro" name="phonepro" value="[% phonepro | html %]" />
456
	  [% IF ( mandatoryphonepro ) %]<span class="required">Required</span>[% END %]
511
                [% IF ( mandatoryphonepro ) %]<span class="required">Required</span>[% END %]
457
    </li>
512
            </li>
458
        [% END %]
513
        [% END %]
514
459
        [% UNLESS nomobile %]
515
        [% UNLESS nomobile %]
460
    <li>
516
            <li>
461
      [% IF ( mandatorymobile ) %]
517
                [% IF ( mandatorymobile ) %]
462
      <label for="mobile" class="required">
518
                    <label for="mobile" class="required">
463
      [% ELSE %]
519
                [% ELSE %]
464
      <label for="mobile">
520
                    <label for="mobile">
465
      [% END %]
521
                [% END %]
466
      Other phone: </label>
522
                Other phone: </label>
467
        <input type="text" id="mobile" name="mobile" value="[% mobile | html %]" />
523
                <input type="text" id="mobile" name="mobile" value="[% mobile | html %]" />
468
	  [% IF ( mandatorymobile ) %]<span class="required">Required</span>[% END %]
524
                [% IF ( mandatorymobile ) %]<span class="required">Required</span>[% END %]
469
    </li>
525
            </li>
470
        [% END %]
526
        [% END %]
471
        [% UNLESS noemail %]
472
    <li>
473
      [% IF ( mandatoryemail ) %]
474
      <label for="email" class="required">
475
      [% ELSE %]
476
      <label for="email">
477
      [% END %]
478
      Primary email: </label>
479
        <input type="text" id="email" name="email" size="45" value="[% email | html %]" />
480
	  [% IF ( mandatoryemail ) %]<span class="required">Required</span>[% END %]<div class="hint">Shows on transit slips</div>
481
527
482
    </li>
528
        [% UNLESS noemail %]
529
            <li>
530
                [% IF ( mandatoryemail ) %]
531
                    <label for="email" class="required">
532
                [% ELSE %]
533
                    <label for="email">
534
                [% END %]
535
                Primary email: </label>
536
                <input type="text" id="email" name="email" size="45" value="[% email | html %]" />
537
                [% IF ( mandatoryemail ) %]<span class="required">Required</span>[% END %]<div class="hint">Shows on transit slips</div>
538
            </li>
483
        [% END %]
539
        [% END %]
540
484
        [% UNLESS noemailpro %]
541
        [% UNLESS noemailpro %]
485
    <li>
542
            <li>
486
      [% IF ( mandatoryemailpro ) %]
543
                [% IF ( mandatoryemailpro ) %]
487
      <label for="emailpro" class="required">
544
                    <label for="emailpro" class="required">
488
      [% ELSE %]
545
                [% ELSE %]
489
      <label for="emailpro">
546
                    <label for="emailpro">
490
      [% END %]
547
                [% END %]
491
      Secondary email: </label>
548
                Secondary email: </label>
492
        <input type="text" id="emailpro" name="emailpro" size="45" value="[% emailpro | html %]" />
549
                <input type="text" id="emailpro" name="emailpro" size="45" value="[% emailpro | html %]" />
493
	  [% IF ( mandatoryemailpro ) %]<span class="required">Required</span>[% END %]
550
                [% IF ( mandatoryemailpro ) %]<span class="required">Required</span>[% END %]
494
    </li>
551
            </li>
495
        [% END %]
552
        [% END %]
553
496
        [% UNLESS nofax %]
554
        [% UNLESS nofax %]
497
    <li>
555
            <li>
498
      [% IF ( mandatoryfax ) %]
556
                [% IF ( mandatoryfax ) %]
499
      <label for="fax" class="required">
557
                    <label for="fax" class="required">
500
      [% ELSE %]
558
                [% ELSE %]
501
      <label for="fax">
559
                    <label for="fax">
502
      [% END %]
560
                [% END %]
503
      Fax: </label>
561
                Fax: </label>
504
        <input type="text" id="fax" name="fax" value="[% fax | html %]" />
562
                <input type="text" id="fax" name="fax" value="[% fax | html %]" />
505
	  [% IF ( mandatoryfax ) %]<span class="required">Required</span>[% END %]
563
                [% IF ( mandatoryfax ) %]<span class="required">Required</span>[% END %]
506
    </li>
564
            </li>
507
        [% END %]
565
        [% END %]
508
	</ol>
566
    </ol>
509
  </fieldset>
567
</fieldset>
510
[%END # hide fieldset %]
568
[%END # hide fieldset %]
511
569
512
<!-- ************************ STEP_1 *********************** -->
570
<!-- ************************ STEP_1 *********************** -->
Lines 1204-1209 Link Here
1204
                    update_category_code( category_code );
1262
                    update_category_code( category_code );
1205
                }
1263
                }
1206
            [% END %]
1264
            [% END %]
1265
1266
            [% IF guarantor %]
1267
                select_user( '[% guarantor.borrowernumber %]', [% To.json( guarantor.unblessed ) | $raw %] );
1268
            [% END %]
1269
1207
        });
1270
        });
1208
1271
1209
        function update_cardnumber_warning(size){
1272
        function update_cardnumber_warning(size){
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-brief.tt (-10 / +21 lines)
Lines 1-3 Link Here
1
[% USE raw %]
1
[% USE Koha %]
2
[% USE Koha %]
2
[% USE KohaDates %]
3
[% USE KohaDates %]
3
[% SET footerjs = 1 %]
4
[% SET footerjs = 1 %]
Lines 42-57 Link Here
42
                [% IF ( dateofbirth ) %]<li><span class="label">Date of birth:</span>[% dateofbirth | $KohaDates %]</li>[% END %]
43
                [% IF ( dateofbirth ) %]<li><span class="label">Date of birth:</span>[% dateofbirth | $KohaDates %]</li>[% END %]
43
                [% IF ( sex ) %]<li><span class="label">Gender:</span>[% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex | html %][% END %]</li>[% END %][% END %]
44
                [% IF ( sex ) %]<li><span class="label">Gender:</span>[% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex | html %][% END %]</li>[% END %][% END %]
44
            [% END %]
45
            [% END %]
45
    [% IF ( isguarantee ) %]
46
46
        [% IF ( guaranteeloop ) %]
47
            [% IF guarantees %]
47
            <li><span class="label">Guarantees:</span><ul>[% FOREACH guaranteeloo IN guaranteeloop %]<li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guaranteeloo.borrowernumber | html %]">[% guaranteeloo.name | html %]  </a></li>[% END %]</ul></li>
48
                <li>
48
        [% END %]
49
                    <span class="label">Guarantees:</span>
49
    [% ELSE %]
50
                    <ul>
50
        [% IF ( guarantor.borrowernumber ) %]
51
                        [% FOREACH guarantee IN guarantees %]
51
            <li><span class="label">Guarantor:</span><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantor.borrowernumber | html %]">[% guarantor.surname | html %], [% guarantor.firstname | html %]</a></li>
52
                            <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantee.borrowernumber | $raw %]">[% guarantee.firstname | html %] [% guarantee.surname | html %]</a></li>
52
        [% END %]
53
                        [% END %]
53
    [% END %]
54
                    </ul>
54
	</ol>
55
                </li>
56
            [% ELSIF guarantor_relationships %]
57
                [% FOREACH gr IN guarantor_relationships %]
58
                    <li>
59
                        <span class="label">Guarantor:</span>
60
                        [% SET guarantor = gr.guarantor %]
61
                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantor.id | $raw %]">[% guarantor.firstname | html %] [% guarantor.surname | html %]</a>
62
                    </li>
63
                [% END %]
64
            [% END %]
65
	    </ol>
55
	</div>
66
	</div>
56
    </div>
67
    </div>
57
    </div>
68
    </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-9 / +10 lines)
Lines 239-253 Link Here
239
                                                    [% END %]
239
                                                    [% END %]
240
                                                </ul>
240
                                                </ul>
241
                                            </li>
241
                                            </li>
242
                                        [% ELSIF guarantor %]
242
                                        [% ELSIF guarantor_relationships %]
243
                                            <li>
243
                                            [% FOREACH gr IN guarantor_relationships %]
244
                                                <span class="label">Guarantor:</span>
244
                                                <li>
245
                                                [% IF guarantor.borrowernumber AND logged_in_user.can_see_patron_infos( guarantor ) %]
245
                                                    <span class="label">Guarantor:</span>
246
                                                    <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantor.borrowernumber | html %]">[% guarantor.firstname | html %] [% guarantor.surname | html %]</a>
246
                                                    [% SET guarantor = gr.guarantor %]
247
                                                [% ELSE %]
247
                                                    [% IF logged_in_user.can_see_patron_infos( guarantor ) %]
248
                                                    [% guarantor.firstname | html %] [% guarantor.surname | html %]
248
                                                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantor.id | $raw %]">[% guarantor.firstname | html %] [% guarantor.surname | html %]</a>
249
                                                [% END %]
249
                                                    [% END %]
250
                                            </li>
250
                                                </li>
251
                                            [% END %]
251
                                        [% END %]
252
                                        [% END %]
252
                                    </ol>
253
                                    </ol>
253
                                </div> [% # /div.rows %]
254
                                </div> [% # /div.rows %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/members.js (-51 / +41 lines)
Lines 129-138 function Dopop(link) { Link Here
129
    var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=no,top');
129
    var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=no,top');
130
}
130
}
131
131
132
function Dopopguarantor(link) {
133
    var newin=window.open(link,'popup','width=800,height=500,resizable=no,toolbar=false,scrollbars=yes,top');
134
}
135
136
function clear_entry(node) {
132
function clear_entry(node) {
137
    var original = $(node).parent();
133
    var original = $(node).parent();
138
    $("textarea", original).attr('value', '');
134
    $("textarea", original).attr('value', '');
Lines 170-217 function update_category_code(category_code) { Link Here
170
}
166
}
171
167
172
function select_user(borrowernumber, borrower) {
168
function select_user(borrowernumber, borrower) {
173
    var form = $('#entryform').get(0);
169
    $('#guarantor_id').val(borrower.borrowernumber);
174
    if (form.guarantorid.value) {
170
    $('#guarantor_surname').val(borrower.surname);
175
        $("#contact-details, #quick_add_form #contact-details").find('a').remove();
171
    $('#guarantor_firstname').val(borrower.firstname);
176
        $("#contactname, #contactfirstname, #quick_add_form #contactname, #quick_add_form #contactfirstname").parent().find('span').remove();
172
173
    var fieldset = $('#guarantor_template').clone();
174
    fieldset.removeAttr('id');
175
176
    var guarantor_id = $('#guarantor_id').val();
177
    if ( guarantor_id ) {
178
        fieldset.find('.new_guarantor_id').first().val( guarantor_id );
179
        fieldset.find('.new_guarantor_id_text').first().text( guarantor_id );
180
    } else {
181
        fieldset.find('.guarantor_id').first().hide();
177
    }
182
    }
183
    $('#guarantor_id').val("");
184
185
    var guarantor_surname = $('#guarantor_surname').val();
186
    fieldset.find('.new_guarantor_surname').first().val( guarantor_surname );
187
    fieldset.find('.new_guarantor_surname_text').first().text( guarantor_surname );
188
    $('#guarantor_surname').val("");
189
190
    var guarantor_firstname = $('#guarantor_firstname').val();
191
    fieldset.find('.new_guarantor_firstname').first().val( guarantor_firstname );
192
    fieldset.find('.new_guarantor_firstname_text').first().text( guarantor_firstname );
193
    $('#guarantor_firstname').val("");
178
194
179
    var id = borrower.borrowernumber;
195
    var guarantor_relationship = $('#relationship').val();
180
    form.guarantorid.value = id;
196
    fieldset.find('.new_guarantor_relationship').first().val( guarantor_relationship );
181
    $('#contact-details, #quick_add_form #contact-details')
197
    $('#relationship').find('option:eq(0)').prop('selected', true);;
182
        .show()
198
183
        .find('span')
199
    $('#guarantor_relationships').append( fieldset );
184
        .after('<a target="blank" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=' + id + '">' + id + '</a>');
200
    fieldset.show();
185
186
    $(form.contactname)
187
        .val(borrower.surname)
188
        .before('<span>' + borrower.surname + '</span>').get(0).type = 'hidden';
189
    $("#quick_add_form #contactname").val(borrower.surname).before('<span>'+borrower.surname+'</span.').attr({type:"hidden"});
190
    $(form.contactfirstname,"#quick_add_form #contactfirstname")
191
        .val(borrower.firstname)
192
        .before('<span>' + borrower.firstname + '</span>').get(0).type = 'hidden';
193
    $("#quick_add_form #contactfirstname").val(borrower.firstname).before('<span>'+borrower.firstname+'</span.').attr({type:"hidden"});
194
195
    form.streetnumber.value = borrower.streetnumber;
196
    form.address.value = borrower.address;
197
    form.address2.value = borrower.address2;
198
    form.city.value = borrower.city;
199
    form.state.value = borrower.state;
200
    form.zipcode.value = borrower.zipcode;
201
    form.country.value = borrower.country;
202
    form.branchcode.value = borrower.branchcode;
203
204
    $("#quick_add_form #streetnumber").val(borrower.streetnumber);
205
    $("#quick_add_form #address").val(borrower.address);
206
    $("#quick_add_form #address2").val(borrower.address2);
207
    $("#quick_add_form #city").val(borrower.city);
208
    $("#quick_add_form #state").val(borrower.state);
209
    $("#quick_add_form #zipcode").val(borrower.zipcode);
210
    $("#quick_add_form #country").val(borrower.country);
211
    $("#quick_add_form select[name='branchcode']").val(borrower.branchcode);
212
213
    form.guarantorsearch.value = LABEL_CHANGE;
214
    $("#quick_add_form #guarantorsearch").val(LABEL_CHANGE);
215
201
216
    return 0;
202
    return 0;
217
}
203
}
Lines 284-296 $(document).ready(function(){ Link Here
284
    });
270
    });
285
271
286
    $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit");
272
    $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit");
287
    $("#guarantordelete").click(function() {
273
288
        $("#quick_add_form #contact-details, #contact-details").hide().find('a').remove();
274
    $('#guarantor_template').hide();
289
        $("#quick_add_form #guarantorid, #quick_add_form  #contactname, #quick_add_form #contactfirstname, #guarantorid, #contactname, #contactfirstname").each(function () { this.value = ""; });
275
290
        $("#quick_add_form #contactname, #quick_add_form #contactfirstname, #contactname, #contactfirstname")
276
    $('#guarantor_search').on('click', function(e) {
291
            .each(function () { this.type = 'text'; })
277
        e.preventDefault();
292
            .parent().find('span').remove();
278
        var newin = window.open('guarantor_search.pl','popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=yes,top');
293
        $("#quick_add_form #guarantorsearch, #guarantorsearch").val(LABEL_SET_TO_PATRON);
279
    });
280
281
    $('#guarantor_relationships').on('click', '.guarantor_cancel', function(e) {
282
        e.preventDefault();
283
        $(this).parents('fieldset').first().remove();
294
    });
284
    });
295
285
296
    $(document.body).on('change','select[name="select_city"]',function(){
286
    $(document.body).on('change','select[name="select_city"]',function(){
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt (-3 / +8 lines)
Lines 100-106 Link Here
100
                    <div class="alert">You typed in the wrong characters in the box before submitting. Please try again.</div>
100
                    <div class="alert">You typed in the wrong characters in the box before submitting. Please try again.</div>
101
                [% END %]
101
                [% END %]
102
102
103
                [% IF borrower.guarantorid && !Koha.Preference('OPACPrivacy') && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
103
                [% IF patron.guarantor_relationships && !Koha.Preference('OPACPrivacy') && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
104
                    <fieldset class="rows" id="memberentry_privacy">
104
                    <fieldset class="rows" id="memberentry_privacy">
105
                        <legend id="privacy_legend">Privacy</legend>
105
                        <legend id="privacy_legend">Privacy</legend>
106
                        <ol>
106
                        <ol>
Lines 119-125 Link Here
119
                                    <span id="update_privacy_guarantor_checkouts_message" class="alert" style="display:none"></span>
119
                                    <span id="update_privacy_guarantor_checkouts_message" class="alert" style="display:none"></span>
120
                                </span>
120
                                </span>
121
                                <span class="hint">
121
                                <span class="hint">
122
                                    Your guarantor is <i>[% guarantor.firstname | html %] [% guarantor.surname | html %]</i>
122
                                    Guaranteed by
123
                                    [% FOREACH gr IN patron.guarantor_relationships %]
124
                                        [% SET g = gr.guarantor %]
125
                                        [% g.firstname | html %] [% g.surname | html %]
126
                                        [%- IF ! loop.last %], [% END %]
127
                                    [% END %]
123
                                </span>
128
                                </span>
124
                            </li>
129
                            </li>
125
                        </ol>
130
                        </ol>
Lines 1010-1016 Link Here
1010
                }
1015
                }
1011
            });
1016
            });
1012
1017
1013
            [% IF borrower.guarantorid && !Koha.Preference('OPACPrivacy') && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
1018
            [% IF patron.guarantor_relationships && !Koha.Preference('OPACPrivacy') && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
1014
                $('#update_privacy_guarantor_checkouts').click( function() {
1019
                $('#update_privacy_guarantor_checkouts').click( function() {
1015
                    $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_guarantor_checkouts: $('#privacy_guarantor_checkouts').val() }, null, 'json')
1020
                    $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_guarantor_checkouts: $('#privacy_guarantor_checkouts').val() }, null, 'json')
1016
                     .done(function( data ) {
1021
                     .done(function( data ) {
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-privacy.tt (-2 / +7 lines)
Lines 71-77 Link Here
71
                                        </select>
71
                                        </select>
72
                                    </div>
72
                                    </div>
73
73
74
                                    [% IF borrower.guarantorid && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
74
                                    [% IF borrower.guarantor_relationships && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
75
                                        <div>
75
                                        <div>
76
                                            <label for="privacy_guarantor_checkouts">Allow your guarantor to view your current checkouts?</label>
76
                                            <label for="privacy_guarantor_checkouts">Allow your guarantor to view your current checkouts?</label>
77
                                            <select name="privacy_guarantor_checkouts">
77
                                            <select name="privacy_guarantor_checkouts">
Lines 84-90 Link Here
84
                                                [% END %]
84
                                                [% END %]
85
                                            </select>
85
                                            </select>
86
                                            <span class="hint">
86
                                            <span class="hint">
87
                                                Your guarantor is <i>[% borrower.guarantor.firstname | html %] [% borrower.guarantor.surname | html %]</i>
87
                                                Guaranteed by
88
                                                [% FOREACH gr IN borrower.guarantor_relationships %]
89
                                                    [% SET g = gr.guarantor %]
90
                                                    [% g.firstname | html %] [% g.surname | html %]
91
                                                    [%- IF ! loop.last %], [% END %]
92
                                                [% END %]
88
                                            </span>
93
                                            </span>
89
                                        </div>
94
                                        </div>
90
                                    [% END %]
95
                                    [% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (-5 / +5 lines)
Lines 429-452 Link Here
429
429
430
                                    <tbody>
430
                                    <tbody>
431
                                        [% FOREACH r IN relatives %]
431
                                        [% FOREACH r IN relatives %]
432
                                            [% FOREACH i IN r.issues %]
432
                                            [% FOREACH c IN r.checkouts %]
433
                                                <tr>
433
                                                <tr>
434
                                                    <td>
434
                                                    <td>
435
                                                        <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% i.item.biblio.biblionumber | html %]">
435
                                                        <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% i.item.biblio.biblionumber | html %]">
436
                                                            [% i.item.biblio.title | html %][% IF ( i.item.enumchron ) %] [% i.item.enumchron | html %][% END %]
436
                                                            [% c.item.biblio.title | html %][% IF ( c.item.enumchron ) %] [% c.item.enumchron | html %][% END %]
437
                                                        </a>
437
                                                        </a>
438
                                                    </td>
438
                                                    </td>
439
439
440
                                                    <td>
440
                                                    <td>
441
                                                        [% i.date_due | $KohaDates %]
441
                                                        [% c.date_due | $KohaDates %]
442
                                                    </td>
442
                                                    </td>
443
443
444
                                                    <td>
444
                                                    <td>
445
                                                        [% i.item.barcode | html %]
445
                                                        [% c.item.barcode | html %]
446
                                                    </td>
446
                                                    </td>
447
447
448
                                                    <td>
448
                                                    <td>
449
                                                        [% i.item.itemcallnumber | html %]
449
                                                        [% c.item.itemcallnumber | html %]
450
                                                    </td>
450
                                                    </td>
451
451
452
                                                    <td>
452
                                                    <td>
(-)a/members/deletemem.pl (-3 / +3 lines)
Lines 84-90 if (C4::Context->preference("IndependentBranches")) { Link Here
84
84
85
my $op = $input->param('op') || 'delete_confirm';
85
my $op = $input->param('op') || 'delete_confirm';
86
my $dbh = C4::Context->dbh;
86
my $dbh = C4::Context->dbh;
87
my $is_guarantor = $dbh->selectrow_array("SELECT COUNT(*) FROM borrowers WHERE guarantorid=?", undef, $member);
87
my $is_guarantor = $patron->guarantee_relationships->count;
88
if ( $op eq 'delete_confirm' or $countissues > 0 or $charges or $is_guarantor ) {
88
if ( $op eq 'delete_confirm' or $countissues > 0 or $charges or $is_guarantor ) {
89
89
90
    $template->param(
90
    $template->param(
Lines 96-103 if ( $op eq 'delete_confirm' or $countissues > 0 or $charges or $is_guarantor ) Link Here
96
    if ( $charges > 0 ) {
96
    if ( $charges > 0 ) {
97
        $template->param(charges => $charges);
97
        $template->param(charges => $charges);
98
    }
98
    }
99
    if ($is_guarantor) {
99
    if ( $is_guarantor ) {
100
        $template->param(guarantees => 1);
100
        $template->param( guarantees => 1 );
101
    }
101
    }
102
102
103
    # This is silly written but reflect the same conditions as above
103
    # This is silly written but reflect the same conditions as above
(-)a/members/memberentry.pl (-51 / +67 lines)
Lines 83-89 if ( C4::Context->preference('SMSSendDriver') eq 'Email' ) { Link Here
83
    $template->param( sms_providers => \@providers );
83
    $template->param( sms_providers => \@providers );
84
}
84
}
85
85
86
my $guarantorid    = $input->param('guarantorid');
87
my $actionType     = $input->param('actionType') || '';
86
my $actionType     = $input->param('actionType') || '';
88
my $modify         = $input->param('modify');
87
my $modify         = $input->param('modify');
89
my $delete         = $input->param('delete');
88
my $delete         = $input->param('delete');
Lines 99-111 $nodouble = 1 if ($op eq 'modify' or $op eq 'duplicate'); # FIXME hack to rep Link Here
99
                                     # isn't a duplicate.  Marking FIXME because this
98
                                     # isn't a duplicate.  Marking FIXME because this
100
                                     # script needs to be refactored.
99
                                     # script needs to be refactored.
101
my $nok           = $input->param('nok');
100
my $nok           = $input->param('nok');
102
my $guarantorinfo = $input->param('guarantorinfo');
103
my $step          = $input->param('step') || 0;
101
my $step          = $input->param('step') || 0;
104
my @errors;
102
my @errors;
105
my $borrower_data;
103
my $borrower_data;
106
my $NoUpdateLogin;
104
my $NoUpdateLogin;
107
my $userenv = C4::Context->userenv;
105
my $userenv = C4::Context->userenv;
108
106
107
## Deal with guarantor stuff
108
$template->param( relationships => scalar $patron->guarantor_relationships ) if $patron;
109
110
my $guarantor_id = $input->param('guarantor_id');
111
my $guarantor = Koha::Patrons->find( $guarantor_id ) if $guarantor_id;
112
$template->param( guarantor => $guarantor );
113
114
my @delete_guarantor = $input->multi_param('delete_guarantor');
115
foreach my $id ( @delete_guarantor ) {
116
    my $r = Koha::Patron::Relationships->find( $id );
117
    $r->delete() if $r;
118
}
119
109
## Deal with debarments
120
## Deal with debarments
110
$template->param(
121
$template->param(
111
    debarments => scalar GetDebarments( { borrowernumber => $borrowernumber } ) );
122
    debarments => scalar GetDebarments( { borrowernumber => $borrowernumber } ) );
Lines 137-150 $template->param("uppercasesurnames" => C4::Context->preference('uppercasesurnam Link Here
137
my $check_BorrowerMandatoryField=C4::Context->preference("BorrowerMandatoryField");
148
my $check_BorrowerMandatoryField=C4::Context->preference("BorrowerMandatoryField");
138
my @field_check=split(/\|/,$check_BorrowerMandatoryField);
149
my @field_check=split(/\|/,$check_BorrowerMandatoryField);
139
foreach (@field_check) {
150
foreach (@field_check) {
140
	$template->param( "mandatory$_" => 1);    
151
    $template->param( "mandatory$_" => 1 );
141
}
152
}
142
# function to designate unwanted fields
153
# function to designate unwanted fields
143
my $check_BorrowerUnwantedField=C4::Context->preference("BorrowerUnwantedField");
154
my $check_BorrowerUnwantedField=C4::Context->preference("BorrowerUnwantedField");
144
@field_check=split(/\|/,$check_BorrowerUnwantedField);
155
@field_check=split(/\|/,$check_BorrowerUnwantedField);
145
foreach (@field_check) {
156
foreach (@field_check) {
146
    next unless m/\w/o;
157
    next unless m/\w/o;
147
	$template->param( "no$_" => 1);
158
    $template->param( "no$_" => 1 );
148
}
159
}
149
$template->param( "add" => 1 ) if ( $op eq 'add' );
160
$template->param( "add" => 1 ) if ( $op eq 'add' );
150
$template->param( "quickadd" => 1 ) if ( $quickadd );
161
$template->param( "quickadd" => 1 ) if ( $quickadd );
Lines 225-230 if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) Link Here
225
        qr/^add_debarment$/, qr/^debarred_expiration$/, # We already dealt with debarments previously
236
        qr/^add_debarment$/, qr/^debarred_expiration$/, # We already dealt with debarments previously
226
        qr/^housebound_chooser$/, qr/^housebound_deliverer$/,
237
        qr/^housebound_chooser$/, qr/^housebound_deliverer$/,
227
        qr/^select_city$/,
238
        qr/^select_city$/,
239
        qr/^new_guarantor_/,
240
        qr/^guarantor_firstname$/,
241
        qr/^guarantor_surname$/,
242
        qr/^delete_guarantor$/,
228
    );
243
    );
229
    for my $regexp (@keys_to_delete) {
244
    for my $regexp (@keys_to_delete) {
230
        for (keys %newdata) {
245
        for (keys %newdata) {
Lines 249-274 if ( ( $op eq 'insert' ) and !$nodouble ) { Link Here
249
    }
264
    }
250
}
265
}
251
266
252
  #recover all data from guarantor address phone ,fax... 
253
if ( $guarantorid ) {
254
    if (my $guarantor = Koha::Patrons->find( $guarantorid )) {
255
        my $guarantordata = $guarantor->unblessed;
256
        $category_type = $guarantordata->{categorycode} eq 'I' ? 'P' : 'C';
257
        $guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'};
258
        $newdata{'contactfirstname'}= $guarantordata->{'firstname'};
259
        $newdata{'contactname'}     = $guarantordata->{'surname'};
260
        $newdata{'contacttitle'}    = $guarantordata->{'title'};
261
        if ( $op eq 'add' ) {
262
	        foreach (qw(streetnumber address streettype address2
263
                        zipcode country city state phone phonepro mobile fax email emailpro branchcode
264
                        B_streetnumber B_streettype B_address B_address2
265
                        B_city B_state B_zipcode B_country B_email B_phone)) {
266
		        $newdata{$_} = $guarantordata->{$_};
267
	        }
268
        }
269
    }
270
}
271
272
###############test to take the right zipcode, country and city name ##############
267
###############test to take the right zipcode, country and city name ##############
273
# set only if parameter was passed from the form
268
# set only if parameter was passed from the form
274
$newdata{'city'}    = $input->param('city')    if defined($input->param('city'));
269
$newdata{'city'}    = $input->param('city')    if defined($input->param('city'));
Lines 436-441 if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ Link Here
436
            # Lot of code will need to be removed from this script to handle exceptions raised by Koha::Patron->store
431
            # Lot of code will need to be removed from this script to handle exceptions raised by Koha::Patron->store
437
            warn "Patron creation failed! - $@"; # Maybe we must die instead of just warn
432
            warn "Patron creation failed! - $@"; # Maybe we must die instead of just warn
438
        } else {
433
        } else {
434
            add_guarantors( $patron, $input );
439
            $borrowernumber = $patron->borrowernumber;
435
            $borrowernumber = $patron->borrowernumber;
440
        }
436
        }
441
437
Lines 538-543 if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ Link Here
538
534
539
        $patron->update_password($newdata{userid}, $newdata{password});
535
        $patron->update_password($newdata{userid}, $newdata{password});
540
536
537
        add_guarantors( $patron, $input );
541
        if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) {
538
        if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) {
542
            C4::Members::Attributes::SetBorrowerAttributes($borrowernumber, $extended_patron_attributes);
539
            C4::Members::Attributes::SetBorrowerAttributes($borrowernumber, $extended_patron_attributes);
543
        }
540
        }
Lines 636-646 foreach my $category_type (qw(C A S P I X)) { Link Here
636
        'categoryloop'   => \@categoryloop
633
        'categoryloop'   => \@categoryloop
637
      };
634
      };
638
}
635
}
639
636
$template->param(
640
$template->param('typeloop' => \@typeloop,
637
    typeloop      => \@typeloop,
641
        no_categories => $no_categories);
638
    no_categories => $no_categories,
642
if($no_categories){ $no_add = 1; }
639
);
643
644
640
645
my $cities = Koha::Cities->search( {}, { order_by => 'city_name' } );
641
my $cities = Koha::Cities->search( {}, { order_by => 'city_name' } );
646
my $roadtypes = C4::Koha::GetAuthorisedValues( 'ROADTYPE' );
642
my $roadtypes = C4::Koha::GetAuthorisedValues( 'ROADTYPE' );
Lines 665-688 while (@relationships) { Link Here
665
  push(@relshipdata, \%row);
661
  push(@relshipdata, \%row);
666
}
662
}
667
663
668
my %flags = ( 'gonenoaddress' => ['gonenoaddress' ],
664
my %flags = (
669
        'lost'          => ['lost']);
665
    'gonenoaddress' => ['gonenoaddress'],
666
    'lost'          => ['lost']
667
);
670
668
671
 
672
my @flagdata;
669
my @flagdata;
673
foreach (keys(%flags)) {
670
foreach ( keys(%flags) ) {
674
	my $key = $_;
671
    my $key = $_;
675
	my %row =  ('key'   => $key,
672
    my %row = (
676
		    'name'  => $flags{$key}[0]);
673
        'key'  => $key,
677
	if ($data{$key}) {
674
        'name' => $flags{$key}[0]
678
		$row{'yes'}=' checked';
675
    );
679
		$row{'no'}='';
676
    if ( $data{$key} ) {
680
    }
677
        $row{'yes'} = ' checked';
681
	else {
678
        $row{'no'}  = '';
682
		$row{'yes'}='';
679
    }
683
		$row{'no'}=' checked';
680
    else {
684
	}
681
        $row{'yes'} = '';
685
	push @flagdata,\%row;
682
        $row{'no'}  = ' checked';
683
    }
684
    push @flagdata, \%row;
686
}
685
}
687
686
688
# get Branch Loop
687
# get Branch Loop
Lines 758-764 if (C4::Context->preference('EnhancedMessagingPreferences')) { Link Here
758
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
757
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
759
}
758
}
760
759
761
$template->param( "showguarantor"  => ($category_type=~/A|I|S|X/) ? 0 : 1); # associate with step to know where you are
760
$template->param( "show_guarantor" => ( $category_type =~ /A|I|S|X/ ) ? 0 : 1 ); # associate with step to know where you are
762
$debug and warn "memberentry step: $step";
761
$debug and warn "memberentry step: $step";
763
$template->param(%data);
762
$template->param(%data);
764
$template->param( "step_$step"  => 1) if $step;	# associate with step to know where u are
763
$template->param( "step_$step"  => 1) if $step;	# associate with step to know where u are
Lines 772-788 $template->param( Link Here
772
  check_member    => $check_member,#to know if the borrower already exist(=>1) or not (=>0) 
771
  check_member    => $check_member,#to know if the borrower already exist(=>1) or not (=>0) 
773
  "op$op"   => 1);
772
  "op$op"   => 1);
774
773
775
$guarantorid = $borrower_data->{'guarantorid'} || $guarantorid;
776
my $guarantor = $guarantorid ? Koha::Patrons->find( $guarantorid ) : undef;
777
$template->param(
774
$template->param(
778
  patron => $patron, # Used by address include templates now
775
  patron => $patron, # Used by address include templates now
779
  nodouble  => $nodouble,
776
  nodouble  => $nodouble,
780
  borrowernumber  => $borrowernumber, #register number
777
  borrowernumber  => $borrowernumber, #register number
781
  guarantor   => $guarantor,
782
  guarantorid => $guarantorid,
783
  relshiploop => \@relshipdata,
778
  relshiploop => \@relshipdata,
784
  btitle=> $default_borrowertitle,
779
  btitle=> $default_borrowertitle,
785
  guarantorinfo   => $guarantorinfo,
786
  flagloop  => \@flagdata,
780
  flagloop  => \@flagdata,
787
  category_type =>$category_type,
781
  category_type =>$category_type,
788
  modify          => $modify,
782
  modify          => $modify,
Lines 910-915 sub patron_attributes_form { Link Here
910
904
911
}
905
}
912
906
907
sub add_guarantors {
908
    my ( $patron, $input ) = @_;
909
910
    my @new_guarantor_id           = $input->multi_param('new_guarantor_id');
911
    my @new_guarantor_relationship = $input->multi_param('new_guarantor_relationship');
912
913
    for ( my $i = 0 ; $i < scalar @new_guarantor_id; $i++ ) {
914
        my $guarantor_id = $new_guarantor_id[$i];
915
        my $relationship = $new_guarantor_relationship[$i];
916
917
        next unless $guarantor_id;
918
919
        $patron->add_guarantor(
920
            {
921
                guarantee_id => $patron->id,
922
                guarantor_id => $guarantor_id,
923
                relationship => $relationship,
924
            }
925
        );
926
    }
927
}
928
913
# Local Variables:
929
# Local Variables:
914
# tab-width: 8
930
# tab-width: 8
915
# End:
931
# End:
(-)a/members/moremember.pl (-15 / +13 lines)
Lines 162-183 if ( $patron->is_debarred ) { Link Here
162
$data->{ "sex_".$data->{'sex'}."_p" } = 1 if defined $data->{sex};
162
$data->{ "sex_".$data->{'sex'}."_p" } = 1 if defined $data->{sex};
163
163
164
my @relatives;
164
my @relatives;
165
if ( my $guarantor = $patron->guarantor ) {
165
my $guarantor_relationships = $patron->guarantor_relationships;
166
    $template->param( guarantor => $guarantor );
166
my @guarantees              = $patron->guarantee_relationships->guarantees;
167
    push @relatives, $guarantor->borrowernumber;
167
my @guarantors              = $guarantor_relationships->guarantors;
168
    push @relatives, $_->borrowernumber for $patron->siblings;
168
if (@guarantors) {
169
} elsif ( $patron->contactname || $patron->contactfirstname ) {
169
    push( @relatives, $_->id ) for @guarantors;
170
    $template->param(
170
    push( @relatives, $_->id ) for $patron->siblings();
171
        guarantor => {
172
            firstname => $patron->contactfirstname,
173
            surname   => $patron->contactname,
174
        }
175
    );
176
} else {
177
    my @guarantees = $patron->guarantees;
178
    $template->param( guarantees => \@guarantees );
179
    push @relatives, $_->borrowernumber for @guarantees;
180
}
171
}
172
else {
173
    push( @relatives, $_->id ) for @guarantees;
174
}
175
$template->param(
176
    guarantor_relationships => $guarantor_relationships,
177
    guarantees              => \@guarantees,
178
);
181
179
182
my $relatives_issues_count =
180
my $relatives_issues_count =
183
  Koha::Database->new()->schema()->resultset('Issue')
181
  Koha::Database->new()->schema()->resultset('Issue')
(-)a/members/update-child.pl (-7 / +11 lines)
Lines 33-38 use C4::Auth; Link Here
33
use C4::Output;
33
use C4::Output;
34
use Koha::Patrons;
34
use Koha::Patrons;
35
use Koha::Patron::Categories;
35
use Koha::Patron::Categories;
36
use Koha::Patrons;
36
37
37
# use Smart::Comments;
38
# use Smart::Comments;
38
39
Lines 68-74 if ( $op eq 'multi' ) { Link Here
68
    );
69
    );
69
    output_html_with_http_headers $input, $cookie, $template->output;
70
    output_html_with_http_headers $input, $cookie, $template->output;
70
}
71
}
71
72
elsif ( $op eq 'update' ) {
72
elsif ( $op eq 'update' ) {
73
    my $patron         = Koha::Patrons->find( $borrowernumber );
73
    my $patron         = Koha::Patrons->find( $borrowernumber );
74
    output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
74
    output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
Lines 84-90 elsif ( $op eq 'update' ) { Link Here
84
    # But we should not hit that with a normal use of the interface
84
    # But we should not hit that with a normal use of the interface
85
    die "You are doing something wrong updating this child" unless $adult_category;
85
    die "You are doing something wrong updating this child" unless $adult_category;
86
86
87
    $patron->guarantorid(undef);
87
    $_->delete() for $patron->guarantor_relationships();
88
88
    $patron->categorycode($adult_category->categorycode);
89
    $patron->categorycode($adult_category->categorycode);
89
    $patron->store;
90
    $patron->store;
90
91
Lines 92-103 elsif ( $op eq 'update' ) { Link Here
92
    # We could redirect with a friendly message
93
    # We could redirect with a friendly message
93
    if ( $patron_categories->count > 1 ) {
94
    if ( $patron_categories->count > 1 ) {
94
        $template->param(
95
        $template->param(
95
                SUCCESS        => 1,
96
            SUCCESS        => 1,
96
                borrowernumber => $borrowernumber,
97
            borrowernumber => $borrowernumber,
97
                );
98
        );
98
        output_html_with_http_headers $input, $cookie, $template->output;
99
        output_html_with_http_headers $input, $cookie, $template->output;
99
    } else {
100
    }
100
        print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber");
101
    else {
102
        print $input->redirect(
103
            "/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber"
104
        );
101
    }
105
    }
102
}
106
}
103
107
(-)a/misc/cronjobs/j2a.pl (-12 / +59 lines)
Lines 95-100 C<juv2adult.pl> - Suggests that you read this help. :) Link Here
95
C<juv2adult.pl> -b=<branchcode> -f=<categorycode> -t=<categorycode>  - Processes a single branch, and updates the patron categories from fromcat to tocat.
95
C<juv2adult.pl> -b=<branchcode> -f=<categorycode> -t=<categorycode>  - Processes a single branch, and updates the patron categories from fromcat to tocat.
96
96
97
C<juv2adult.pl> -f=<categorycode> -t=<categorycode> -v -n - Processes all branches, shows all messages, and reports the patrons who would be affected. Takes no action on the database.
97
C<juv2adult.pl> -f=<categorycode> -t=<categorycode> -v -n - Processes all branches, shows all messages, and reports the patrons who would be affected. Takes no action on the database.
98
98
=cut
99
=cut
99
100
100
# These variables are set by command line options.
101
# These variables are set by command line options.
Lines 163-174 $verbose and print "The age limit for category $fromcat is $agelimit\n"; Link Here
163
my $itsyourbirthday = "$year-$mon-$mday";
164
my $itsyourbirthday = "$year-$mon-$mday";
164
165
165
if ( not $noaction ) {
166
if ( not $noaction ) {
167
    # Start a transaction since we need to delete from relationships and update borrowers atomically
168
    $dbh->{AutoCommit} = 0;
169
170
    my $success = 1;
166
    if ($mybranch) {    #yep, we received a specific branch to work on.
171
    if ($mybranch) {    #yep, we received a specific branch to work on.
167
        $verbose and print "Looking for patrons of $mybranch to update from $fromcat to $tocat that were born before $itsyourbirthday\n";
172
        $verbose and print "Looking for patrons of $mybranch to update from $fromcat to $tocat that were born before $itsyourbirthday\n";
168
        my $query = qq|
173
        my $where = qq|
169
            UPDATE borrowers
170
            SET guarantorid ='0',
171
                categorycode = ?
172
            WHERE dateofbirth <= ?
174
            WHERE dateofbirth <= ?
173
              AND dateofbirth != '0000-00-00'
175
              AND dateofbirth != '0000-00-00'
174
              AND branchcode = ?
176
              AND branchcode = ?
Lines 177-186 if ( not $noaction ) { Link Here
177
                FROM categories
179
                FROM categories
178
                WHERE category_type = 'C'
180
                WHERE category_type = 'C'
179
                  AND categorycode = ?
181
                  AND categorycode = ?
180
              )|;
182
              )
183
        |;
184
185
        my $query = qq|
186
            DELETE relationships FROM relationships
187
            LEFT JOIN borrowers ON ( borrowers.borrowernumber = relationships.guarantee_id )
188
            $where
189
        |;
181
        my $sth = $dbh->prepare($query);
190
        my $sth = $dbh->prepare($query);
191
        $sth->execute( $itsyourbirthday, $mybranch, $fromcat )
192
          or $success = 0;
193
194
        $query = qq|
195
            UPDATE borrowers
196
            SET categorycode = ?
197
            $where
198
        |;
199
        $sth = $dbh->prepare($query);
182
        my $res = $sth->execute( $tocat, $itsyourbirthday, $mybranch, $fromcat )
200
        my $res = $sth->execute( $tocat, $itsyourbirthday, $mybranch, $fromcat )
183
          or die "can't execute";
201
          or $success = 0;
202
203
        if ( $success ) {
204
            $dbh->commit;
205
        } else {
206
            $dbh->rollback;
207
            die "can't execute";
208
        }
184
209
185
        if ( $res eq '0E0' ) {
210
        if ( $res eq '0E0' ) {
186
            print "No patrons updated\n";
211
            print "No patrons updated\n";
Lines 191-200 if ( not $noaction ) { Link Here
191
    }
216
    }
192
    else {    # branch was not supplied, processing all branches
217
    else {    # branch was not supplied, processing all branches
193
        $verbose and print "Looking in all branches for patrons to update from $fromcat to $tocat that were born before $itsyourbirthday\n";
218
        $verbose and print "Looking in all branches for patrons to update from $fromcat to $tocat that were born before $itsyourbirthday\n";
194
        my $query = qq|
219
        my $where = qq|
195
            UPDATE borrowers
196
            SET guarantorid = '0',
197
                categorycode = ?
198
            WHERE dateofbirth <= ?
220
            WHERE dateofbirth <= ?
199
              AND dateofbirth!='0000-00-00'
221
              AND dateofbirth!='0000-00-00'
200
              AND categorycode IN (
222
              AND categorycode IN (
Lines 202-211 if ( not $noaction ) { Link Here
202
                FROM categories
224
                FROM categories
203
                WHERE category_type = 'C'
225
                WHERE category_type = 'C'
204
                  AND categorycode = ?
226
                  AND categorycode = ?
205
              )|;
227
              )
228
        |;
229
230
        my $query = qq|
231
            DELETE relationships FROM relationships
232
            LEFT JOIN borrowers ON ( borrowers.borrowernumber = relationships.guarantee_id )
233
            $where
234
        |;
206
        my $sth = $dbh->prepare($query);
235
        my $sth = $dbh->prepare($query);
236
        $sth->execute( $itsyourbirthday, $fromcat )
237
          or $success = 0;
238
239
        $query = qq|
240
            UPDATE borrowers
241
            SET categorycode = ?
242
            $where
243
        |;
244
        $sth = $dbh->prepare($query);
207
        my $res = $sth->execute( $tocat, $itsyourbirthday, $fromcat )
245
        my $res = $sth->execute( $tocat, $itsyourbirthday, $fromcat )
208
          or die "can't execute";
246
          or $success = 0;
247
        $dbh->commit;
248
249
        if ( $success ) {
250
            $dbh->commit;
251
        } else {
252
            $dbh->rollback;
253
            die "can't execute";
254
        }
209
255
210
        if ( $res eq '0E0' ) {
256
        if ( $res eq '0E0' ) {
211
            print "No patrons updated\n";
257
            print "No patrons updated\n";
Lines 267-272 else { Link Here
267
        my $sth = $dbh->prepare($query);
313
        my $sth = $dbh->prepare($query);
268
        $sth->execute( $itsyourbirthday, $fromcat )
314
        $sth->execute( $itsyourbirthday, $fromcat )
269
          or die "Couldn't execute statement: " . $sth->errstr;
315
          or die "Couldn't execute statement: " . $sth->errstr;
316
        $dbh->commit;
270
317
271
        while ( my @res = $sth->fetchrow_array() ) {
318
        while ( my @res = $sth->fetchrow_array() ) {
272
            my $firstname = $res[0];
319
            my $firstname = $res[0];
(-)a/opac/opac-memberentry.pl (-2 / +2 lines)
Lines 315-321 elsif ( $action eq 'edit' ) { #Display logged in borrower's data Link Here
315
315
316
    $template->param(
316
    $template->param(
317
        borrower  => $borrower,
317
        borrower  => $borrower,
318
        guarantor => scalar Koha::Patrons->find($borrowernumber)->guarantor(),
319
        hidden => GetHiddenFields( $mandatory, 'modification' ),
318
        hidden => GetHiddenFields( $mandatory, 'modification' ),
320
        csrf_token => Koha::Token->new->generate_csrf({
319
        csrf_token => Koha::Token->new->generate_csrf({
321
            session_id => scalar $cgi->cookie('CGISESSID'),
320
            session_id => scalar $cgi->cookie('CGISESSID'),
Lines 336-342 my $captcha = random_string("CCCCC"); Link Here
336
335
337
$template->param(
336
$template->param(
338
    captcha        => $captcha,
337
    captcha        => $captcha,
339
    captcha_digest => md5_base64($captcha)
338
    captcha_digest => md5_base64($captcha),
339
    patron         => Koha::Patrons->find( $borrowernumber ),
340
);
340
);
341
341
342
output_html_with_http_headers $cgi, $cookie, $template->output, undef, { force_no_caching => 1 };
342
output_html_with_http_headers $cgi, $cookie, $template->output, undef, { force_no_caching => 1 };
(-)a/opac/opac-user.pl (-8 / +7 lines)
Lines 39-44 use Koha::Holds; Link Here
39
use Koha::Database;
39
use Koha::Database;
40
use Koha::ItemTypes;
40
use Koha::ItemTypes;
41
use Koha::Patron::Attribute::Types;
41
use Koha::Patron::Attribute::Types;
42
use Koha::Patrons;
42
use Koha::Patron::Messages;
43
use Koha::Patron::Messages;
43
use Koha::Patron::Discharge;
44
use Koha::Patron::Discharge;
44
use Koha::Patrons;
45
use Koha::Patrons;
Lines 338-351 my $patron_messages = Koha::Patron::Messages->search( Link Here
338
if (   C4::Context->preference('AllowPatronToSetCheckoutsVisibilityForGuarantor')
339
if (   C4::Context->preference('AllowPatronToSetCheckoutsVisibilityForGuarantor')
339
    || C4::Context->preference('AllowStaffToSetCheckoutsVisibilityForGuarantor') )
340
    || C4::Context->preference('AllowStaffToSetCheckoutsVisibilityForGuarantor') )
340
{
341
{
341
    my @relatives =
342
    my @relatives;
342
      Koha::Database->new()->schema()->resultset("Borrower")->search(
343
    # Filter out guarantees that don't want guarantor to see checkouts
343
        {
344
    foreach my $gr ( $patron->guarantee_relationships() ) {
344
            privacy_guarantor_checkouts => 1,
345
        my $g = $gr->guarantee;
345
            'me.guarantorid'           => $borrowernumber
346
        push( @relatives, $g ) if $g->privacy_guarantor_checkouts;
346
        },
347
    }
347
        { prefetch => [ { 'issues' => { 'item' => 'biblio' } } ] }
348
      );
349
    $template->param( relatives => \@relatives );
348
    $template->param( relatives => \@relatives );
350
}
349
}
351
350
(-)a/t/Patron.t (-22 / +2 lines)
Lines 95-106 my $patron = Koha::Patron->new( Link Here
95
        lost                => '0',
95
        lost                => '0',
96
        debarred            => '2015-04-19',
96
        debarred            => '2015-04-19',
97
        debarredcomment     => 'You are debarred',
97
        debarredcomment     => 'You are debarred',
98
        contactname         => 'myContactname',
99
        contactfirstname    => 'myContactfirstname',
100
        contacttitle        => 'myContacttitle',
101
        guarantorid         => '123454321',
102
        borrowernotes       => 'borrowernotes',
98
        borrowernotes       => 'borrowernotes',
103
        relationship        => 'myRelationship',
104
        sex                 => 'M',
99
        sex                 => 'M',
105
        password            => 'hfkurhfe976634èj!',
100
        password            => 'hfkurhfe976634èj!',
106
        flags               => '55555',
101
        flags               => '55555',
Lines 125-131 my $patron = Koha::Patron->new( Link Here
125
120
126
# patron Accessor tests
121
# patron Accessor tests
127
subtest 'Accessor tests' => sub {
122
subtest 'Accessor tests' => sub {
128
    plan tests => 65;
123
    plan tests => 60;
129
    is( $patron->borrowernumber, '12345',                           'borrowernumber accessor returns correct value' );
124
    is( $patron->borrowernumber, '12345',                           'borrowernumber accessor returns correct value' );
130
    is( $patron->cardnumber,     '1234567890',                      'cardnumber accessor returns correct value' );
125
    is( $patron->cardnumber,     '1234567890',                      'cardnumber accessor returns correct value' );
131
    is( $patron->surname,        'mySurname',                       'surname accessor returns correct value' );
126
    is( $patron->surname,        'mySurname',                       'surname accessor returns correct value' );
Lines 166-177 subtest 'Accessor tests' => sub { Link Here
166
    is( $patron->lost,           '0',                               'lost accessor returns correct value' );
161
    is( $patron->lost,           '0',                               'lost accessor returns correct value' );
167
    is( $patron->debarred,       '2015-04-19',                      'debarred accessor returns correct value' );
162
    is( $patron->debarred,       '2015-04-19',                      'debarred accessor returns correct value' );
168
    is( $patron->debarredcomment,     'You are debarred',      'debarredcomment accessor returns correct value' );
163
    is( $patron->debarredcomment,     'You are debarred',      'debarredcomment accessor returns correct value' );
169
    is( $patron->contactname,         'myContactname',         'contactname accessor returns correct value' );
170
    is( $patron->contactfirstname,    'myContactfirstname',    'contactfirstname accessor returns correct value' );
171
    is( $patron->contacttitle,        'myContacttitle',        'contacttitle accessor returns correct value' );
172
    is( $patron->guarantorid,         '123454321',             'guarantorid accessor returns correct value' );
173
    is( $patron->borrowernotes,       'borrowernotes',         'borrowernotes accessor returns correct value' );
164
    is( $patron->borrowernotes,       'borrowernotes',         'borrowernotes accessor returns correct value' );
174
    is( $patron->relationship,        'myRelationship',        'relationship accessor returns correct value' );
175
    is( $patron->sex,                 'M',                     'sex accessor returns correct value' );
165
    is( $patron->sex,                 'M',                     'sex accessor returns correct value' );
176
    is( $patron->password,            'hfkurhfe976634èj!',    'password accessor returns correct value' );
166
    is( $patron->password,            'hfkurhfe976634èj!',    'password accessor returns correct value' );
177
    is( $patron->flags,               '55555',                 'flags accessor returns correct value' );
167
    is( $patron->flags,               '55555',                 'flags accessor returns correct value' );
Lines 195-201 subtest 'Accessor tests' => sub { Link Here
195
185
196
# patron Set tests
186
# patron Set tests
197
subtest 'Set tests' => sub {
187
subtest 'Set tests' => sub {
198
    plan tests => 65;
188
    plan tests => 60;
199
189
200
    $patron->set(
190
    $patron->set(
201
        {
191
        {
Lines 239-250 subtest 'Set tests' => sub { Link Here
239
            lost                => '1',
229
            lost                => '1',
240
            debarred            => '2016-04-19',
230
            debarred            => '2016-04-19',
241
            debarredcomment     => 'You are still debarred',
231
            debarredcomment     => 'You are still debarred',
242
            contactname         => 'SmyContactname',
243
            contactfirstname    => 'SmyContactfirstname',
244
            contacttitle        => 'SmyContacttitle',
245
            guarantorid         => '223454321',
246
            borrowernotes       => 'Sborrowernotes',
232
            borrowernotes       => 'Sborrowernotes',
247
            relationship        => 'SmyRelationship',
248
            sex                 => 'F',
233
            sex                 => 'F',
249
            password            => 'zerzerzer#',
234
            password            => 'zerzerzer#',
250
            flags               => '666666',
235
            flags               => '666666',
Lines 307-318 subtest 'Set tests' => sub { Link Here
307
    is( $patron->lost,                '1',                                'lost field set ok' );
292
    is( $patron->lost,                '1',                                'lost field set ok' );
308
    is( $patron->debarred,            '2016-04-19',                       'debarred field set ok' );
293
    is( $patron->debarred,            '2016-04-19',                       'debarred field set ok' );
309
    is( $patron->debarredcomment,     'You are still debarred',           'debarredcomment field set ok' );
294
    is( $patron->debarredcomment,     'You are still debarred',           'debarredcomment field set ok' );
310
    is( $patron->contactname,         'SmyContactname',                   'contactname field set ok' );
311
    is( $patron->contactfirstname,    'SmyContactfirstname',              'contactfirstname field set ok' );
312
    is( $patron->contacttitle,        'SmyContacttitle',                  'contacttitle field set ok' );
313
    is( $patron->guarantorid,         '223454321',                        'guarantorid field set ok' );
314
    is( $patron->borrowernotes,       'Sborrowernotes',                   'borrowernotes field set ok' );
295
    is( $patron->borrowernotes,       'Sborrowernotes',                   'borrowernotes field set ok' );
315
    is( $patron->relationship,        'SmyRelationship',                  'relationship field set ok' );
316
    is( $patron->sex,                 'F',                                'sex field set ok' );
296
    is( $patron->sex,                 'F',                                'sex field set ok' );
317
    is( $patron->password,            'zerzerzer#',                       'password field set ok' );
297
    is( $patron->password,            'zerzerzer#',                       'password field set ok' );
318
    is( $patron->flags,               '666666',                           'flags field set ok' );
298
    is( $patron->flags,               '666666',                           'flags field set ok' );
(-)a/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t (-7 / +19 lines)
Lines 26-31 use C4::Accounts qw( manualinvoice ); Link Here
26
use C4::Circulation qw( CanBookBeIssued );
26
use C4::Circulation qw( CanBookBeIssued );
27
use Koha::Account::Lines;
27
use Koha::Account::Lines;
28
use Koha::Account::Offsets;
28
use Koha::Account::Offsets;
29
use Koha::Patron::Relationship;
29
30
30
my $schema = Koha::Database->new->schema;
31
my $schema = Koha::Database->new->schema;
31
$schema->storage->txn_begin;
32
$schema->storage->txn_begin;
Lines 52-63 my $patron = $builder->build_object( Link Here
52
        }
53
        }
53
    }
54
    }
54
);
55
);
55
my $guarantee = $builder->build(
56
57
my $guarantee = $builder->build_object(
56
    {
58
    {
57
        source => 'Borrower',
59
        class => 'Koha::Patrons',
58
        value  => {
60
        value => {
59
            guarantorid => $patron->borrowernumber,
61
            patron_category => $patron_category->{categorycode},
60
            categorycode => $patron_category->{categorycode},
62
        }
63
    }
64
);
65
66
my $r = $builder->build_object(
67
    {
68
        class => 'Koha::Patron::Relationships',
69
        value => {
70
            guarantor_id => $patron->id,
71
            guarantee_id => $guarantee->id,
72
            relationship => 'parent',
61
        }
73
        }
62
    }
74
    }
63
);
75
);
Lines 68-78 t::lib::Mocks::mock_preference( 'AllowFineOverride', '' ); Link Here
68
my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->{barcode} );
80
my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->{barcode} );
69
is( $issuingimpossible->{DEBT_GUARANTEES}, undef, "Patron can check out item" );
81
is( $issuingimpossible->{DEBT_GUARANTEES}, undef, "Patron can check out item" );
70
82
71
manualinvoice( $guarantee->{borrowernumber}, undef, undef, 'L', 10.00 );
83
manualinvoice( $guarantee->id, undef, undef, 'L', 10.00 );
72
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->{barcode} );
84
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->{barcode} );
73
is( $issuingimpossible->{DEBT_GUARANTEES} + 0, '10.00' + 0, "Patron cannot check out item due to debt for guarantee" );
85
is( $issuingimpossible->{DEBT_GUARANTEES} + 0, '10.00' + 0, "Patron cannot check out item due to debt for guarantee" );
74
86
75
my $accountline = Koha::Account::Lines->search({ borrowernumber => $guarantee->{borrowernumber} })->next();
87
my $accountline = Koha::Account::Lines->search({ borrowernumber => $guarantee->id })->next();
76
is( $accountline->amountoutstanding, "10.000000", "Found 10.00 amount outstanding" );
88
is( $accountline->amountoutstanding, "10.000000", "Found 10.00 amount outstanding" );
77
is( $accountline->accounttype, "L", "Account type is L" );
89
is( $accountline->accounttype, "L", "Account type is L" );
78
90
(-)a/t/db_dependent/Items.t (-1 / +5 lines)
Lines 504-510 subtest 'SearchItems test' => sub { Link Here
504
504
505
subtest 'Koha::Item(s) tests' => sub {
505
subtest 'Koha::Item(s) tests' => sub {
506
506
507
    plan tests => 5;
507
    plan tests => 7;
508
508
509
    $schema->storage->txn_begin();
509
    $schema->storage->txn_begin();
510
510
Lines 543-548 subtest 'Koha::Item(s) tests' => sub { Link Here
543
    is( ref($holdingbranch), 'Koha::Library', "Got Koha::Library from holding_branch method" );
543
    is( ref($holdingbranch), 'Koha::Library', "Got Koha::Library from holding_branch method" );
544
    is( $holdingbranch->branchcode(), $library2->{branchcode}, "Home branch code matches holdingbranch" );
544
    is( $holdingbranch->branchcode(), $library2->{branchcode}, "Home branch code matches holdingbranch" );
545
545
546
    my $biblio = $item->biblio();
547
    is( ref($biblio), 'Koha::Biblio', "Got Koha::Biblio from biblio method" );
548
    is( $biblio->title(), 'Silence in the library', 'Title matches biblio title' );
549
546
    $schema->storage->txn_rollback;
550
    $schema->storage->txn_rollback;
547
};
551
};
548
552
(-)a/t/db_dependent/Koha/Patrons.t (-38 / +106 lines)
Lines 34-39 use C4::Auth qw(checkpw_hash); Link Here
34
use Koha::Holds;
34
use Koha::Holds;
35
use Koha::Patrons;
35
use Koha::Patrons;
36
use Koha::Patron::Categories;
36
use Koha::Patron::Categories;
37
use Koha::Patron::Relationship;
37
use Koha::Database;
38
use Koha::Database;
38
use Koha::DateUtils;
39
use Koha::DateUtils;
39
use Koha::Virtualshelves;
40
use Koha::Virtualshelves;
Lines 84-104 subtest 'library' => sub { Link Here
84
85
85
subtest 'guarantees' => sub {
86
subtest 'guarantees' => sub {
86
    plan tests => 13;
87
    plan tests => 13;
87
    my $guarantees = $new_patron_1->guarantees;
88
    my $guarantees = $new_patron_1->guarantee_relationships;
88
    is( ref($guarantees), 'Koha::Patrons', 'Koha::Patron->guarantees should return a Koha::Patrons result set in a scalar context' );
89
    is( ref($guarantees), 'Koha::Patron::Relationships', 'Koha::Patron->guarantees should return a Koha::Patrons result set in a scalar context' );
89
    is( $guarantees->count, 0, 'new_patron_1 should have 0 guarantee' );
90
    is( $guarantees->count, 0, 'new_patron_1 should have 0 guarantee relationships' );
90
    my @guarantees = $new_patron_1->guarantees;
91
    my @guarantees = $new_patron_1->guarantee_relationships;
91
    is( ref(\@guarantees), 'ARRAY', 'Koha::Patron->guarantees should return an array in a list context' );
92
    is( ref(\@guarantees), 'ARRAY', 'Koha::Patron->guarantee_relationships should return an array in a list context' );
92
    is( scalar(@guarantees), 0, 'new_patron_1 should have 0 guarantee' );
93
    is( scalar(@guarantees), 0, 'new_patron_1 should have 0 guarantee' );
93
94
94
    my $guarantee_1 = $builder->build({ source => 'Borrower', value => { guarantorid => $new_patron_1->borrowernumber }});
95
    my $guarantee_1 = $builder->build({ source => 'Borrower' });
95
    my $guarantee_2 = $builder->build({ source => 'Borrower', value => { guarantorid => $new_patron_1->borrowernumber }});
96
    my $relationship_1 = Koha::Patron::Relationship->new( { guarantor_id => $new_patron_1->id, guarantee_id => $guarantee_1->{borrowernumber} } )->store();
97
    my $guarantee_2 = $builder->build({ source => 'Borrower' });
98
    my $relationship_2 = Koha::Patron::Relationship->new( { guarantor_id => $new_patron_1->id, guarantee_id => $guarantee_2->{borrowernumber} } )->store();
96
99
97
    $guarantees = $new_patron_1->guarantees;
100
    $guarantees = $new_patron_1->guarantee_relationships;
98
    is( ref($guarantees), 'Koha::Patrons', 'Koha::Patron->guarantees should return a Koha::Patrons result set in a scalar context' );
101
    is( ref($guarantees), 'Koha::Patron::Relationships', 'Koha::Patron->guarantee_relationships should return a Koha::Patrons result set in a scalar context' );
99
    is( $guarantees->count, 2, 'new_patron_1 should have 2 guarantees' );
102
    is( $guarantees->count, 2, 'new_patron_1 should have 2 guarantees' );
100
    @guarantees = $new_patron_1->guarantees;
103
    @guarantees = $new_patron_1->guarantee_relationships;
101
    is( ref(\@guarantees), 'ARRAY', 'Koha::Patron->guarantees should return an array in a list context' );
104
    is( ref(\@guarantees), 'ARRAY', 'Koha::Patron->guarantee_relationships should return an array in a list context' );
102
    is( scalar(@guarantees), 2, 'new_patron_1 should have 2 guarantees' );
105
    is( scalar(@guarantees), 2, 'new_patron_1 should have 2 guarantees' );
103
    $_->delete for @guarantees;
106
    $_->delete for @guarantees;
104
107
Lines 108-147 subtest 'guarantees' => sub { Link Here
108
111
109
    my $guarantor = $builder->build_object( { class => 'Koha::Patrons' } );
112
    my $guarantor = $builder->build_object( { class => 'Koha::Patrons' } );
110
113
111
    my $order_guarantee1 = $builder->build_object( { class => 'Koha::Patrons' ,  value => {
114
    my $order_guarantee1 = $builder->build_object(
112
            surname => 'Zebra',
115
        {
113
            guarantorid => $guarantor->borrowernumber
116
            class => 'Koha::Patrons',
117
            value => {
118
                surname     => 'Zebra',
119
            }
114
        }
120
        }
115
    })->borrowernumber;
121
    )->borrowernumber;
122
    $builder->build_object(
123
        {
124
            class => 'Koha::Patron::Relationships',
125
            value => {
126
                guarantor_id  => $guarantor->id,
127
                guarantee_id => $order_guarantee1
128
            }
129
        }
130
    );
116
131
117
    my $order_guarantee2 = $builder->build_object( { class => 'Koha::Patrons' ,  value => {
132
    my $order_guarantee2 = $builder->build_object(
118
            surname => 'Yak',
133
        {
119
            guarantorid => $guarantor->borrowernumber
134
            class => 'Koha::Patrons',
135
            value => {
136
                surname     => 'Yak',
137
            }
120
        }
138
        }
121
    })->borrowernumber;
139
    )->borrowernumber;
140
    $builder->build_object(
141
        {
142
            class => 'Koha::Patron::Relationships',
143
            value => {
144
                guarantor_id  => $guarantor->id,
145
                guarantee_id => $order_guarantee2
146
            }
147
        }
148
    );
122
149
123
    my $order_guarantee3 = $builder->build_object( { class => 'Koha::Patrons' ,  value => {
150
    my $order_guarantee3 = $builder->build_object(
124
            surname => 'Xerus',
151
        {
125
            firstname => 'Walrus',
152
            class => 'Koha::Patrons',
126
            guarantorid => $guarantor->borrowernumber
153
            value => {
154
                surname     => 'Xerus',
155
                firstname   => 'Walrus',
156
            }
127
        }
157
        }
128
    })->borrowernumber;
158
    )->borrowernumber;
159
    $builder->build_object(
160
        {
161
            class => 'Koha::Patron::Relationships',
162
            value => {
163
                guarantor_id  => $guarantor->id,
164
                guarantee_id => $order_guarantee3
165
            }
166
        }
167
    );
129
168
130
    my $order_guarantee4 = $builder->build_object( { class => 'Koha::Patrons' ,  value => {
169
    my $order_guarantee4 = $builder->build_object(
131
            surname => 'Xerus',
170
        {
132
            firstname => 'Vulture',
171
            class => 'Koha::Patrons',
133
            guarantorid => $guarantor->borrowernumber
172
            value => {
173
                surname     => 'Xerus',
174
                firstname   => 'Vulture',
175
                guarantorid => $guarantor->borrowernumber
176
            }
177
        }
178
    )->borrowernumber;
179
    $builder->build_object(
180
        {
181
            class => 'Koha::Patron::Relationships',
182
            value => {
183
                guarantor_id  => $guarantor->id,
184
                guarantee_id => $order_guarantee4
185
            }
134
        }
186
        }
135
    })->borrowernumber;
187
    );
136
188
137
    my $order_guarantee5 = $builder->build_object( { class => 'Koha::Patrons' ,  value => {
189
    my $order_guarantee5 = $builder->build_object(
138
            surname => 'Xerus',
190
        {
139
            firstname => 'Unicorn',
191
            class => 'Koha::Patrons',
140
            guarantorid => $guarantor->borrowernumber
192
            value => {
193
                surname     => 'Xerus',
194
                firstname   => 'Unicorn',
195
                guarantorid => $guarantor->borrowernumber
196
            }
141
        }
197
        }
142
    })->borrowernumber;
198
    )->borrowernumber;
199
    my $r = $builder->build_object(
200
        {
201
            class => 'Koha::Patron::Relationships',
202
            value => {
203
                guarantor_id  => $guarantor->id,
204
                guarantee_id => $order_guarantee5
205
            }
206
        }
207
    );
143
208
144
    $guarantees = $guarantor->guarantees();
209
    $guarantees = $guarantor->guarantee_relationships->guarantees;
145
210
146
    is( $guarantees->next()->borrowernumber, $order_guarantee5, "Return first guarantor alphabetically" );
211
    is( $guarantees->next()->borrowernumber, $order_guarantee5, "Return first guarantor alphabetically" );
147
    is( $guarantees->next()->borrowernumber, $order_guarantee4, "Return second guarantor alphabetically" );
212
    is( $guarantees->next()->borrowernumber, $order_guarantee4, "Return second guarantor alphabetically" );
Lines 161-175 subtest 'siblings' => sub { Link Here
161
    plan tests => 7;
226
    plan tests => 7;
162
    my $siblings = $new_patron_1->siblings;
227
    my $siblings = $new_patron_1->siblings;
163
    is( $siblings, undef, 'Koha::Patron->siblings should not crashed if the patron has no guarantor' );
228
    is( $siblings, undef, 'Koha::Patron->siblings should not crashed if the patron has no guarantor' );
164
    my $guarantee_1 = $builder->build( { source => 'Borrower', value => { guarantorid => $new_patron_1->borrowernumber } } );
229
    my $guarantee_1 = $builder->build( { source => 'Borrower' } );
230
    my $relationship_1 = Koha::Patron::Relationship->new( { guarantor_id => $new_patron_1->borrowernumber, guarantee_id => $guarantee_1->{borrowernumber} } )->store();
165
    my $retrieved_guarantee_1 = Koha::Patrons->find($guarantee_1);
231
    my $retrieved_guarantee_1 = Koha::Patrons->find($guarantee_1);
166
    $siblings = $retrieved_guarantee_1->siblings;
232
    $siblings = $retrieved_guarantee_1->siblings;
167
    is( ref($siblings), 'Koha::Patrons', 'Koha::Patron->siblings should return a Koha::Patrons result set in a scalar context' );
233
    is( ref($siblings), 'Koha::Patrons', 'Koha::Patron->siblings should return a Koha::Patrons result set in a scalar context' );
168
    my @siblings = $retrieved_guarantee_1->siblings;
234
    my @siblings = $retrieved_guarantee_1->siblings;
169
    is( ref( \@siblings ), 'ARRAY', 'Koha::Patron->siblings should return an array in a list context' );
235
    is( ref( \@siblings ), 'ARRAY', 'Koha::Patron->siblings should return an array in a list context' );
170
    is( $siblings->count,  0,       'guarantee_1 should not have siblings yet' );
236
    is( $siblings->count,  0,       'guarantee_1 should not have siblings yet' );
171
    my $guarantee_2 = $builder->build( { source => 'Borrower', value => { guarantorid => $new_patron_1->borrowernumber } } );
237
    my $guarantee_2 = $builder->build( { source => 'Borrower' } );
172
    my $guarantee_3 = $builder->build( { source => 'Borrower', value => { guarantorid => $new_patron_1->borrowernumber } } );
238
    my $relationship_2 = Koha::Patron::Relationship->new( { guarantor_id => $new_patron_1->borrowernumber, guarantee_id => $guarantee_2->{borrowernumber} } )->store();
239
    my $guarantee_3 = $builder->build( { source => 'Borrower' } );
240
    my $relationship_3 = Koha::Patron::Relationship->new( { guarantor_id => $new_patron_1->borrowernumber, guarantee_id => $guarantee_3->{borrowernumber} } )->store();
173
    $siblings = $retrieved_guarantee_1->siblings;
241
    $siblings = $retrieved_guarantee_1->siblings;
174
    is( $siblings->count,               2,                               'guarantee_1 should have 2 siblings' );
242
    is( $siblings->count,               2,                               'guarantee_1 should have 2 siblings' );
175
    is( $guarantee_2->{borrowernumber}, $siblings->next->borrowernumber, 'guarantee_2 should exist in the guarantees' );
243
    is( $guarantee_2->{borrowernumber}, $siblings->next->borrowernumber, 'guarantee_2 should exist in the guarantees' );
(-)a/t/db_dependent/Members.t (-11 / +6 lines)
Lines 27-32 use Koha::Database; Link Here
27
use Koha::Holds;
27
use Koha::Holds;
28
use Koha::List::Patron;
28
use Koha::List::Patron;
29
use Koha::Patrons;
29
use Koha::Patrons;
30
use Koha::Patron::Relationship;
30
31
31
use t::lib::Mocks;
32
use t::lib::Mocks;
32
use t::lib::TestBuilder;
33
use t::lib::TestBuilder;
Lines 40-48 $schema->storage->txn_begin; Link Here
40
my $builder = t::lib::TestBuilder->new;
41
my $builder = t::lib::TestBuilder->new;
41
my $dbh = C4::Context->dbh;
42
my $dbh = C4::Context->dbh;
42
43
43
# Remove invalid guarantorid's as long as we have no FK
44
$dbh->do("UPDATE borrowers b1 LEFT JOIN borrowers b2 ON b2.borrowernumber=b1.guarantorid SET b1.guarantorid=NULL where b1.guarantorid IS NOT NULL AND b2.borrowernumber IS NULL");
45
46
my $library1 = $builder->build({
44
my $library1 = $builder->build({
47
    source => 'Branch',
45
    source => 'Branch',
48
});
46
});
Lines 232-238 my $borrower1 = $builder->build({ Link Here
232
            categorycode=>'STAFFER',
230
            categorycode=>'STAFFER',
233
            branchcode => $library3->{branchcode},
231
            branchcode => $library3->{branchcode},
234
            dateexpiry => '2015-01-01',
232
            dateexpiry => '2015-01-01',
235
            guarantorid=> undef,
236
        },
233
        },
237
});
234
});
238
my $bor1inlist = $borrower1->{borrowernumber};
235
my $bor1inlist = $borrower1->{borrowernumber};
Lines 242-248 my $borrower2 = $builder->build({ Link Here
242
            categorycode=>'STAFFER',
239
            categorycode=>'STAFFER',
243
            branchcode => $library3->{branchcode},
240
            branchcode => $library3->{branchcode},
244
            dateexpiry => '2015-01-01',
241
            dateexpiry => '2015-01-01',
245
            guarantorid=> undef,
246
        },
242
        },
247
});
243
});
248
244
Lines 252-258 my $guarantee = $builder->build({ Link Here
252
            categorycode=>'KIDclamp',
248
            categorycode=>'KIDclamp',
253
            branchcode => $library3->{branchcode},
249
            branchcode => $library3->{branchcode},
254
            dateexpiry => '2015-01-01',
250
            dateexpiry => '2015-01-01',
255
            guarantorid=> undef, # will be filled later
256
        },
251
        },
257
});
252
});
258
253
Lines 287-293 $patstodel = GetBorrowersToExpunge( {not_borrowed_since => '2016-01-02', patron_ Link Here
287
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by last issue date');
282
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by last issue date');
288
283
289
Koha::Patrons->find($bor1inlist)->set({ categorycode => 'CIVILIAN' })->store;
284
Koha::Patrons->find($bor1inlist)->set({ categorycode => 'CIVILIAN' })->store;
290
Koha::Patrons->find($guarantee->{borrowernumber})->set({ guarantorid => $bor1inlist })->store;
285
my $relationship = Koha::Patron::Relationship->new( { guarantor_id => $bor1inlist, guarantee_id => $guarantee->{borrowernumber} } )->store();
291
286
292
$patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} );
287
$patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} );
293
ok( scalar(@$patstodel)== 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted from list');
288
ok( scalar(@$patstodel)== 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted from list');
Lines 297-303 $patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02', patron_list Link Here
297
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by expirationdate and list');
292
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by expirationdate and list');
298
$patstodel = GetBorrowersToExpunge( {not_borrowed_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } );
293
$patstodel = GetBorrowersToExpunge( {not_borrowed_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } );
299
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by last issue date');
294
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by last issue date');
300
Koha::Patrons->find($guarantee->{borrowernumber})->set({ guarantorid => undef })->store;
295
$relationship->delete();
301
296
302
$builder->build({
297
$builder->build({
303
        source => 'Issue',
298
        source => 'Issue',
Lines 325-333 is( scalar(@$patstodel),2,'Borrowers without issues deleted by last issue date') Link Here
325
320
326
# Test GetBorrowersToExpunge and TrackLastPatronActivity
321
# Test GetBorrowersToExpunge and TrackLastPatronActivity
327
$dbh->do(q|UPDATE borrowers SET lastseen=NULL|);
322
$dbh->do(q|UPDATE borrowers SET lastseen=NULL|);
328
$builder->build({ source => 'Borrower', value => { lastseen => '2016-01-01 01:01:01', categorycode => 'CIVILIAN', guarantorid => undef } } );
323
$builder->build({ source => 'Borrower', value => { lastseen => '2016-01-01 01:01:01', categorycode => 'CIVILIAN' } } );
329
$builder->build({ source => 'Borrower', value => { lastseen => '2016-02-02 02:02:02', categorycode => 'CIVILIAN', guarantorid => undef } } );
324
$builder->build({ source => 'Borrower', value => { lastseen => '2016-02-02 02:02:02', categorycode => 'CIVILIAN' } } );
330
$builder->build({ source => 'Borrower', value => { lastseen => '2016-03-03 03:03:03', categorycode => 'CIVILIAN', guarantorid => undef } } );
325
$builder->build({ source => 'Borrower', value => { lastseen => '2016-03-03 03:03:03', categorycode => 'CIVILIAN' } } );
331
$patstodel = GetBorrowersToExpunge( { last_seen => '1999-12-12' });
326
$patstodel = GetBorrowersToExpunge( { last_seen => '1999-12-12' });
332
is( scalar @$patstodel, 0, 'TrackLastPatronActivity - 0 patrons must be deleted' );
327
is( scalar @$patstodel, 0, 'TrackLastPatronActivity - 0 patrons must be deleted' );
333
$patstodel = GetBorrowersToExpunge( { last_seen => '2016-02-15' });
328
$patstodel = GetBorrowersToExpunge( { last_seen => '2016-02-15' });
(-)a/t/db_dependent/Patron/Relationships.t (+167 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 59;
21
22
use C4::Context;
23
24
use t::lib::TestBuilder;
25
26
BEGIN {
27
    use_ok('Koha::Objects');
28
    use_ok('Koha::Patrons');
29
    use_ok('Koha::Patron::Relationship');
30
    use_ok('Koha::Patron::Relationships');
31
}
32
33
# Start transaction
34
my $dbh = C4::Context->dbh;
35
$dbh->{AutoCommit} = 0;
36
$dbh->{RaiseError} = 1;
37
38
my $builder = t::lib::TestBuilder->new();
39
40
# Father
41
my $kyle = Koha::Patrons->find(
42
    $builder->build(
43
        {
44
            source => 'Borrower',
45
            value  => {
46
                firstname => 'Kyle',
47
                surname   => 'Hall',
48
            }
49
        }
50
    )->{borrowernumber}
51
);
52
53
# Mother
54
my $chelsea = Koha::Patrons->find(
55
    $builder->build(
56
        {
57
            source => 'Borrower',
58
            value  => {
59
                firstname => 'Chelsea',
60
                surname   => 'Hall',
61
            }
62
        }
63
    )->{borrowernumber}
64
);
65
66
# Children
67
my $daria = Koha::Patrons->find(
68
    $builder->build(
69
        {
70
            source => 'Borrower',
71
            value  => {
72
                firstname => 'Daria',
73
                surname   => 'Hall',
74
            }
75
        }
76
    )->{borrowernumber}
77
);
78
79
my $kylie = Koha::Patrons->find(
80
    $builder->build(
81
        {
82
            source => 'Borrower',
83
            value  => {
84
                firstname => 'Kylie',
85
                surname   => 'Hall',
86
            }
87
        }
88
    )->{borrowernumber}
89
);
90
91
Koha::Patron::Relationship->new({ guarantor_id => $kyle->id, guarantee_id => $daria->id, relationship => 'father' })->store();
92
Koha::Patron::Relationship->new({ guarantor_id => $kyle->id, guarantee_id => $kylie->id, relationship => 'father' })->store();
93
Koha::Patron::Relationship->new({ guarantor_id => $chelsea->id, guarantee_id => $daria->id, relationship => 'mother' })->store();
94
Koha::Patron::Relationship->new({ guarantor_id => $chelsea->id, guarantee_id => $kylie->id, relationship => 'mother' })->store();
95
96
my @gr;
97
98
@gr = $kyle->guarantee_relationships();
99
is( @gr, 2, 'Found 2 guarantee relationships for father' );
100
is( $gr[0]->guarantor_id, $kyle->id, 'Guarantor matches for first relationship' );
101
is( $gr[0]->guarantee_id, $daria->id, 'Guarantee matches for first relationship' );
102
is( $gr[0]->relationship, 'father', 'Relationship is father' );
103
is( ref($gr[0]->guarantee), 'Koha::Patron', 'Method guarantee returns a Koha::Patron' );
104
is( $gr[0]->guarantee->id, $daria->id, 'Koha::Patron returned is the correct guarantee' );
105
is( ref($gr[0]->guarantor), 'Koha::Patron', 'Method guarantor returns a Koha::Patron' );
106
is( $gr[0]->guarantor->id, $kyle->id, 'Koha::Patron returned is the correct guarantor' );
107
108
is( $gr[1]->guarantor_id, $kyle->id, 'Guarantor matches for first relationship' );
109
is( $gr[1]->guarantee_id, $kylie->id, 'Guarantee matches for first relationship' );
110
is( $gr[1]->relationship, 'father', 'Relationship is father' );
111
is( ref($gr[1]->guarantee), 'Koha::Patron', 'Method guarantee returns a Koha::Patron' );
112
is( $gr[1]->guarantee->id, $kylie->id, 'Koha::Patron returned is the correct guarantee' );
113
is( ref($gr[1]->guarantor), 'Koha::Patron', 'Method guarantor returns a Koha::Patron' );
114
is( $gr[1]->guarantor->id, $kyle->id, 'Koha::Patron returned is the correct guarantor' );
115
116
@gr = $chelsea->guarantee_relationships();
117
is( @gr, 2, 'Found 2 guarantee relationships for mother' );
118
is( $gr[0]->guarantor_id, $chelsea->id, 'Guarantor matches for first relationship' );
119
is( $gr[0]->guarantee_id, $daria->id, 'Guarantee matches for first relationship' );
120
is( $gr[0]->relationship, 'mother', 'Relationship is mother' );
121
is( ref($gr[0]->guarantee), 'Koha::Patron', 'Method guarantee returns a Koha::Patron' );
122
is( $gr[0]->guarantee->id, $daria->id, 'Koha::Patron returned is the correct guarantee' );
123
is( ref($gr[0]->guarantor), 'Koha::Patron', 'Method guarantor returns a Koha::Patron' );
124
is( $gr[0]->guarantor->id, $chelsea->id, 'Koha::Patron returned is the correct guarantor' );
125
126
is( $gr[1]->guarantor_id, $chelsea->id, 'Guarantor matches for first relationship' );
127
is( $gr[1]->guarantee_id, $kylie->id, 'Guarantee matches for first relationship' );
128
is( $gr[1]->relationship, 'mother', 'Relationship is mother' );
129
is( ref($gr[1]->guarantee), 'Koha::Patron', 'Method guarantee returns a Koha::Patron' );
130
is( $gr[1]->guarantee->id, $kylie->id, 'Koha::Patron returned is the correct guarantee' );
131
is( ref($gr[1]->guarantor), 'Koha::Patron', 'Method guarantor returns a Koha::Patron' );
132
is( $gr[1]->guarantor->id, $chelsea->id, 'Koha::Patron returned is the correct guarantor' );
133
134
@gr = $daria->guarantor_relationships();
135
is( @gr, 2, 'Found 4 guarantor relationships for child' );
136
is( $gr[0]->guarantor_id, $kyle->id, 'Guarantor matches for first relationship' );
137
is( $gr[0]->guarantee_id, $daria->id, 'Guarantee matches for first relationship' );
138
is( $gr[0]->relationship, 'father', 'Relationship is father' );
139
is( ref($gr[0]->guarantee), 'Koha::Patron', 'Method guarantee returns a Koha::Patron' );
140
is( $gr[0]->guarantee->id, $daria->id, 'Koha::Patron returned is the correct guarantee' );
141
is( ref($gr[0]->guarantor), 'Koha::Patron', 'Method guarantor returns a Koha::Patron' );
142
is( $gr[0]->guarantor->id, $kyle->id, 'Koha::Patron returned is the correct guarantor' );
143
144
is( $gr[1]->guarantor_id, $chelsea->id, 'Guarantor matches for first relationship' );
145
is( $gr[1]->guarantee_id, $daria->id, 'Guarantee matches for first relationship' );
146
is( $gr[1]->relationship, 'mother', 'Relationship is mother' );
147
is( ref($gr[1]->guarantee), 'Koha::Patron', 'Method guarantee returns a Koha::Patron' );
148
is( $gr[1]->guarantee->id, $daria->id, 'Koha::Patron returned is the correct guarantee' );
149
is( ref($gr[1]->guarantor), 'Koha::Patron', 'Method guarantor returns a Koha::Patron' );
150
is( $gr[1]->guarantor->id, $chelsea->id, 'Koha::Patron returned is the correct guarantor' );
151
152
my @siblings = $daria->siblings;
153
is( @siblings, 1, 'Method siblings called in list context returns list' );
154
is( ref($siblings[0]), 'Koha::Patron', 'List contains a Koha::Patron' );
155
is( $siblings[0]->firstname, 'Kylie', 'Sibling from list first name matches correctly' );
156
is( $siblings[0]->surname, 'Hall', 'Sibling from list surname matches correctly' );
157
is( $siblings[0]->id, $kylie->id, 'Sibling from list patron id matches correctly' );
158
159
my $siblings = $daria->siblings;
160
my $sibling = $siblings->next();
161
is( ref($siblings), 'Koha::Patrons', 'Calling siblings in scalar context results in a Koha::Patrons object' );
162
is( ref($sibling), 'Koha::Patron', 'Method next returns a Koha::Patron' );
163
is( $sibling->firstname, 'Kylie', 'Sibling from scalar first name matches correctly' );
164
is( $sibling->surname, 'Hall', 'Sibling from scalar surname matches correctly' );
165
is( $sibling->id, $kylie->id, 'Sibling from scalar patron id matches correctly' );
166
167
1;
(-)a/tools/import_borrowers.pl (-1 / +1 lines)
Lines 62-67 my $extended = C4::Context->preference('ExtendedPatronAttributes'); Link Here
62
62
63
my @columnkeys = map { $_ ne 'borrowernumber' ? $_ : () } Koha::Patrons->columns();
63
my @columnkeys = map { $_ ne 'borrowernumber' ? $_ : () } Koha::Patrons->columns();
64
push( @columnkeys, 'patron_attributes' ) if $extended;
64
push( @columnkeys, 'patron_attributes' ) if $extended;
65
push( @columnkeys, qw( relationship guarantor_id  guarantor_firstname guarantor_surname ) );
65
66
66
my $input = CGI->new();
67
my $input = CGI->new();
67
68
68
- 

Return to bug 14570