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

(-)a/Koha/Patron/Relationship.pm (-1 / +3 lines)
Lines 22-27 use Try::Tiny qw( catch try ); Link Here
22
22
23
use Koha::Database;
23
use Koha::Database;
24
use Koha::Exceptions::Patron::Relationship;
24
use Koha::Exceptions::Patron::Relationship;
25
use Koha::AuthorisedValues;
25
26
26
use base qw(Koha::Object);
27
use base qw(Koha::Object);
27
28
Lines 47-53 Overloaded method that makes some checks before storing on the DB Link Here
47
sub store {
48
sub store {
48
    my ( $self ) = @_;
49
    my ( $self ) = @_;
49
50
50
    my @valid_relationships = split /\|/, C4::Context->preference('borrowerRelationship'), -1;
51
    my $auth_values = C4::Koha::GetAuthorisedValues('BOR_RELATIONSHIP');
52
    my @valid_relationships = map { $_->{authorised_value} } @$auth_values;
51
    @valid_relationships = ('') unless @valid_relationships;
53
    @valid_relationships = ('') unless @valid_relationships;
52
54
53
    Koha::Exceptions::Patron::Relationship::InvalidRelationship->throw(
55
    Koha::Exceptions::Patron::Relationship::InvalidRelationship->throw(
(-)a/about.pl (-1 / +3 lines)
Lines 613-619 if($tab eq 'sysinfo') { Link Here
613
                SELECT relationship FROM borrowers WHERE relationship IS NOT NULL) a
613
                SELECT relationship FROM borrowers WHERE relationship IS NOT NULL) a
614
        });
614
        });
615
615
616
        my %valid_relationships = map { $_ => 1 } split( /,|\|/, C4::Context->preference('borrowerRelationship') );
616
        my $borrower_relationships = C4::Koha::GetAuthorisedValues('BOR_RELATIONSHIP');
617
        my @relationship_names = map { $_->{'authorised_value'} } @$borrower_relationships;
618
        my %valid_relationships = map { $_ => 1 } @relationship_names;
617
        $valid_relationships{ _bad_data } = 1; # we handle this case in another way
619
        $valid_relationships{ _bad_data } = 1; # we handle this case in another way
618
620
619
        my $wrong_relationships = [ grep { !$valid_relationships{ $_->[0] } } @{$existing_relationships} ];
621
        my $wrong_relationships = [ grep { !$valid_relationships{ $_->[0] } } @{$existing_relationships} ];
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc (-1 / +1 lines)
Lines 11-17 Link Here
11
    [% END %]
11
    [% END %]
12
12
13
    [% IF CAN_user_borrowers_edit_borrowers %]
13
    [% IF CAN_user_borrowers_edit_borrowers %]
14
        [% IF patron.is_adult AND Koha.Preference("borrowerRelationship") %]
14
        [% IF patron.is_adult AND AuthorisedValues.Get( 'BOR_RELATIONSHIP' ) %]
15
            <a id="addchild" class="btn btn-default" href="/cgi-bin/koha/members/memberentry.pl?op=add_form&amp;guarantor_id=[% patron.borrowernumber | html %]"><i class="fa fa-plus"></i> Add guarantee</a>
15
            <a id="addchild" class="btn btn-default" href="/cgi-bin/koha/members/memberentry.pl?op=add_form&amp;guarantor_id=[% patron.borrowernumber | html %]"><i class="fa fa-plus"></i> Add guarantee</a>
16
        [% END %]
16
        [% END %]
17
        <a id="changepassword" class="btn btn-default" href="/cgi-bin/koha/members/member-password.pl?member=[% patron.borrowernumber | html %]"><i class="fa fa-lock"></i> Change password</a>
17
        <a id="changepassword" class="btn btn-default" href="/cgi-bin/koha/members/member-password.pl?member=[% patron.borrowernumber | html %]"><i class="fa fa-lock"></i> Change password</a>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt (-2 / +2 lines)
Lines 398-410 Link Here
398
                [% END # /IF bad_relationships_count %]
398
                [% END # /IF bad_relationships_count %]
399
399
400
                [% IF wrong_relationships %]
400
                [% IF wrong_relationships %]
401
                    <p>The following values have been used for guarantee/guarantor relationships, but do not exist in the 'borrowerRelationship' system preference:</p>
401
                    <p>The following values have been used for guarantee/guarantor relationships, but do not exist in the BOR_RELATIONSHIP authorized value category:</p>
402
                    <ul>
402
                    <ul>
403
                        [% FOR rel IN wrong_relationships %]
403
                        [% FOR rel IN wrong_relationships %]
404
                            <li>[% rel.0 | html %]</li>
404
                            <li>[% rel.0 | html %]</li>
405
                        [% END %]
405
                        [% END %]
406
                    </ul>
406
                    </ul>
407
                    <p>If the relationship is one you want, please add it to the 'borrowerRelationship' system preference, otherwise have your system's administrator correct the values in [% "borrowers.relationship" | $HtmlTags tag="strong" %] and/or [% "borrower_relationships.relationship" | $HtmlTags tag="strong" %] in the database.</p>
407
                    <p>If the relationship is one you want, please add it to the BOR_RELATIONSHIP as an authorized value, otherwise have your system's administrator correct the values in [% "borrowers.relationship" | $HtmlTags tag="strong" %] and/or [% "borrower_relationships.relationship" | $HtmlTags tag="strong" %] in the database.</p>
408
                [% END # /IF wrong_relationships %]
408
                [% END # /IF wrong_relationships %]
409
            [% END # /IF warnRelationships %]
409
            [% END # /IF warnRelationships %]
410
410
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-12 / +12 lines)
Lines 4-9 Link Here
4
[% USE Koha %]
4
[% USE Koha %]
5
[% USE KohaDates %]
5
[% USE KohaDates %]
6
[% USE Branches %]
6
[% USE Branches %]
7
[% USE AuthorisedValues %]
7
[% PROCESS 'member-main-address-style.inc' %]
8
[% PROCESS 'member-main-address-style.inc' %]
8
[% PROCESS 'member-alt-address-style.inc' %]
9
[% PROCESS 'member-alt-address-style.inc' %]
9
[% PROCESS 'member-alt-contact-style.inc' %]
10
[% PROCESS 'member-alt-contact-style.inc' %]
Lines 485-493 legend.collapsed i.fa.fa-caret-down::before { Link Here
485
                                        </ol>
486
                                        </ol>
486
                                    </fieldset> <!-- /#memberentry_identity -->
487
                                    </fieldset> <!-- /#memberentry_identity -->
487
                                [% END # hide fieldset %]
488
                                [% END # hide fieldset %]
488
489
                                [% SET possible_relationships = AuthorisedValues.Get( 'BOR_RELATIONSHIP' ) %]
489
                                [% IF show_guarantor || guarantor %]
490
                                [% IF show_guarantor || guarantor %]
490
                                    [% SET possible_relationships = Koha.Preference('borrowerRelationship') %]
491
                                    <div id="memberentry_guarantor_anchor">
491
                                    <div id="memberentry_guarantor_anchor">
492
                                        <fieldset id="memberentry_guarantor" class="rows">
492
                                        <fieldset id="memberentry_guarantor" class="rows">
493
                                            <legend class="expanded" id="patron_guarantor_lgd">
493
                                            <legend class="expanded" id="patron_guarantor_lgd">
Lines 545-553 legend.collapsed i.fa.fa-caret-down::before { Link Here
545
                                                                        <select class="new_guarantor_relationship" name="new_guarantor_relationship">
545
                                                                        <select class="new_guarantor_relationship" name="new_guarantor_relationship">
546
                                                                    [% END %]
546
                                                                    [% END %]
547
                                                                        <option value=""></option>
547
                                                                        <option value=""></option>
548
                                                                        [% FOREACH pr IN possible_relationships.split('\|') %]
548
                                                                        [% FOREACH pr IN possible_relationships %]
549
                                                                            [% IF pr != "" %]
549
                                                                            [% IF pr.authorised_value != "" %]
550
                                                                                <option value="[% pr | html %]">[% pr | html %]</option>
550
                                                                                <option value="[% pr.authorised_value | html %]">[% pr.authorised_value | html %]</option>
551
                                                                            [% END %]
551
                                                                            [% END %]
552
                                                                        [% END %]
552
                                                                        [% END %]
553
                                                                    </select>
553
                                                                    </select>
Lines 589-597 legend.collapsed i.fa.fa-caret-down::before { Link Here
589
                                                                <select class="new_guarantor_relationship" name="new_guarantor_relationship">
589
                                                                <select class="new_guarantor_relationship" name="new_guarantor_relationship">
590
                                                            [% END %]
590
                                                            [% END %]
591
                                                                <option value="" selected></option>
591
                                                                <option value="" selected></option>
592
                                                                [% FOREACH pr IN possible_relationships.split('\|') %]
592
                                                                [% FOREACH pr IN possible_relationships %]
593
                                                                    [% IF pr != "" %]
593
                                                                    [% IF pr.authorised_value != "" %]
594
                                                                        <option value="[% pr | html %]">[% pr | html %]</option>
594
                                                                        <option value="[% pr.authorised_value | html %]">[% pr.authorised_value | html %]</option>
595
                                                                    [% END %]
595
                                                                    [% END %]
596
                                                                [% END %]
596
                                                                [% END %]
597
                                                            </select>
597
                                                            </select>
Lines 704-714 legend.collapsed i.fa.fa-caret-down::before { Link Here
704
                                                            <select class="relationship" name="relationship">
704
                                                            <select class="relationship" name="relationship">
705
                                                        [% END %]
705
                                                        [% END %]
706
                                                            <option value=""></option>
706
                                                            <option value=""></option>
707
                                                            [% FOREACH pr IN possible_relationships.split('\|') %]
707
                                                            [% FOREACH pr IN possible_relationships %]
708
                                                                [% IF pr == borrower_data.relationship %]
708
                                                                [% IF pr.authorised_value == borrower_data.relationship %]
709
                                                                    <option value="[% pr | html %]" selected="selected">[% pr | html %]</option>
709
                                                                    <option value="[% pr.authorised_value | html %]" selected="selected">[% pr.authorised_value | html %]</option>
710
                                                                [% ELSE %]
710
                                                                [% ELSE %]
711
                                                                    <option value="[% pr | html %]">[% pr | html %]</option>
711
                                                                    <option value="[% pr.authorised_value | html %]">[% pr.authorised_value | html %]</option>
712
                                                                [% END %]
712
                                                                [% END %]
713
                                                            [% END %]
713
                                                            [% END %]
714
                                                        </select>
714
                                                        </select>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-1 / +1 lines)
Lines 191-197 Link Here
191
                                                </li>
191
                                                </li>
192
                                            [% END %]
192
                                            [% END %]
193
                                        [% END %]
193
                                        [% END %]
194
                                        [% IF Koha.Preference("borrowerRelationship") %]
194
                                        [% IF AuthorisedValues.Get( 'BOR_RELATIONSHIP' ) %]
195
                                             <li id="patron-privacyguarantor">
195
                                             <li id="patron-privacyguarantor">
196
                                                <span class="label">Show checkouts to guarantor:</span>
196
                                                <span class="label">Show checkouts to guarantor:</span>
197
                                                [% IF patron.privacy_guarantor_checkouts %]
197
                                                [% IF patron.privacy_guarantor_checkouts %]
(-)a/members/memberentry.pl (-2 / +4 lines)
Lines 688-694 $template->param( Link Here
688
my $default_borrowertitle = '';
688
my $default_borrowertitle = '';
689
unless ( $op eq 'duplicate' ) { $default_borrowertitle=$data{'title'} }
689
unless ( $op eq 'duplicate' ) { $default_borrowertitle=$data{'title'} }
690
690
691
my @relationships = split /,|\|/, C4::Context->preference('borrowerRelationship');
691
# Fetch the authorized values for the BOR_RELATIONSHIP category
692
my $auth_values = C4::Koha::GetAuthorisedValues('BOR_RELATIONSHIP');
693
my @relationships = map { $_->{authorised_value} } @$auth_values;
694
692
my @relshipdata;
695
my @relshipdata;
693
while (@relationships) {
696
while (@relationships) {
694
  my $relship = shift @relationships || '';
697
  my $relship = shift @relationships || '';
695
- 

Return to bug 7223