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

(-)a/Koha/Patron.pm (-24 / +8 lines)
Lines 1059-1071 sub generate_userid { Link Here
1059
    my @relationships = $patron->add_guarantor(
1059
    my @relationships = $patron->add_guarantor(
1060
        {
1060
        {
1061
            borrowernumber => $borrowernumber,
1061
            borrowernumber => $borrowernumber,
1062
            surname        => $surname,
1063
            firstname      => $firstname,
1064
            relationships  => $relationship,
1062
            relationships  => $relationship,
1065
        }
1063
        }
1066
    );
1064
    );
1067
1065
1068
    Adds a new guarantor to a patron, requires either an id ( borrowernumber ) or surname.
1066
    Adds a new guarantor to a patron.
1069
1067
1070
=cut
1068
=cut
1071
1069
Lines 1073-1101 sub add_guarantor { Link Here
1073
    my ( $self, $params ) = @_;
1071
    my ( $self, $params ) = @_;
1074
1072
1075
    my $guarantor_id = $params->{guarantor_id};
1073
    my $guarantor_id = $params->{guarantor_id};
1076
    my $surname      = $params->{surname};
1077
    my $firstname    = $params->{firstname};
1078
    my $relationship = $params->{relationship};
1074
    my $relationship = $params->{relationship};
1079
1075
1080
    if ($guarantor_id) {
1076
    return Koha::Patron::Relationship->new(
1081
        return Koha::Patron::Relationship->new(
1077
        {
1082
            {
1078
            guarantee_id => $self->id,
1083
                guarantee_id => $self->id,
1079
            guarantor_id => $guarantor_id,
1084
                guarantor_id => $guarantor_id,
1080
            relationship => $relationship
1085
                relationship => $relationship
1081
        }
1086
            }
1082
    )->store();
1087
        )->store();
1088
    }
1089
    elsif ($surname) {
1090
        return Koha::Patron::Relationship->new(
1091
            {
1092
                guarantee_id => $self->id,
1093
                surname      => $surname,
1094
                firstname    => $firstname,
1095
                relationship => $relationship
1096
            }
1097
        )->store();
1098
    }
1099
}
1083
}
1100
1084
1101
=head2 Internal methods
1085
=head2 Internal methods
(-)a/Koha/Patrons/Import.pm (-8 / +1 lines)
Lines 215-226 sub import_patrons { Link Here
215
215
216
        my $relationship        = $borrower{relationship};
216
        my $relationship        = $borrower{relationship};
217
        my $guarantor_id        = $borrower{guarantor_id};
217
        my $guarantor_id        = $borrower{guarantor_id};
218
        my $guarantor_firstname = $borrower{guarantor_firstname};
219
        my $guarantor_surname   = $borrower{guarantor_surname};
220
        delete $borrower{relationship};
218
        delete $borrower{relationship};
221
        delete $borrower{guarantor_id};
219
        delete $borrower{guarantor_id};
222
        delete $borrower{guarantor_firstname};
223
        delete $borrower{guarantor_surname};
224
220
225
        if ($borrowernumber) {
221
        if ($borrowernumber) {
226
222
Lines 359-373 sub import_patrons { Link Here
359
        }
355
        }
360
356
361
        # Add a guarantor if we are given a relationship
357
        # Add a guarantor if we are given a relationship
362
        if ( $relationship ) {
358
        if ( $guarantor_id ) {
363
            $guarantor_id ||= undef;
364
            Koha::Patron::Relationship->new(
359
            Koha::Patron::Relationship->new(
365
                {
360
                {
366
                    guarantee_id => $borrowernumber,
361
                    guarantee_id => $borrowernumber,
367
                    relationship => $relationship,
362
                    relationship => $relationship,
368
                    guarantor_id => $guarantor_id,
363
                    guarantor_id => $guarantor_id,
369
                    firstname    => $guarantor_firstname,
370
                    surname      => $guarantor_surname,
371
                }
364
                }
372
            )->store();
365
            )->store();
373
        }
366
        }
(-)a/Koha/Schema/Result/BorrowerRelationship.pm (-16 / +2 lines)
Lines 47-62 __PACKAGE__->table("borrower_relationships"); Link Here
47
  is_nullable: 0
47
  is_nullable: 0
48
  size: 100
48
  size: 100
49
49
50
=head2 surname
51
52
  data_type: 'mediumtext'
53
  is_nullable: 1
54
55
=head2 firstname
56
57
  data_type: 'mediumtext'
58
  is_nullable: 1
59
60
=cut
50
=cut
61
51
62
__PACKAGE__->add_columns(
52
__PACKAGE__->add_columns(
Lines 68-77 __PACKAGE__->add_columns( Link Here
68
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
58
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
69
  "relationship",
59
  "relationship",
70
  { data_type => "varchar", is_nullable => 0, size => 100 },
60
  { data_type => "varchar", is_nullable => 0, size => 100 },
71
  "surname",
72
  { data_type => "mediumtext", is_nullable => 1 },
73
  "firstname",
74
  { data_type => "mediumtext", is_nullable => 1 },
75
);
61
);
76
62
77
=head1 PRIMARY KEY
63
=head1 PRIMARY KEY
Lines 124-131 __PACKAGE__->belongs_to( Link Here
124
);
110
);
125
111
126
112
127
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2018-07-17 11:22:45
113
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2018-07-18 10:52:59
128
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:YKFiZSR3WRi1nvtLOdGV9A
114
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:R8RThgcrct40Zq0UMW3TWQ
129
115
130
116
131
# You can replace this text with custom code or comments, and it will be preserved on regeneration
117
# You can replace this text with custom code or comments, and it will be preserved on regeneration
(-)a/installer/data/mysql/atomicupdate/bug_14570.sql (-6 / +4 lines)
Lines 3-10 CREATE TABLE `borrower_relationships` ( Link Here
3
      guarantor_id INT(11) NULL DEFAULT NULL,
3
      guarantor_id INT(11) NULL DEFAULT NULL,
4
      guarantee_id INT(11) NOT NULL,
4
      guarantee_id INT(11) NOT NULL,
5
      relationship VARCHAR(100) COLLATE utf8_unicode_ci NOT NULL,
5
      relationship VARCHAR(100) COLLATE utf8_unicode_ci NOT NULL,
6
      surname MEDIUMTEXT COLLATE utf8_unicode_ci NULL DEFAULT NULL,
7
      firstname MEDIUMTEXT COLLATE utf8_unicode_ci NULL DEFAULT NULL,
8
      PRIMARY KEY (id),
6
      PRIMARY KEY (id),
9
      CONSTRAINT r_guarantor FOREIGN KEY ( guarantor_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE,
7
      CONSTRAINT r_guarantor FOREIGN KEY ( guarantor_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE,
10
      CONSTRAINT r_guarantee FOREIGN KEY ( guarantee_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE
8
      CONSTRAINT r_guarantee FOREIGN KEY ( guarantee_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE
Lines 12-19 CREATE TABLE `borrower_relationships` ( Link Here
12
10
13
UPDATE borrowers LEFT JOIN borrowers guarantor ON ( borrowers.guarantorid = guarantor.borrowernumber ) SET borrowers.guarantorid = NULL WHERE guarantor.borrowernumber IS NULL;
11
UPDATE borrowers LEFT JOIN borrowers guarantor ON ( borrowers.guarantorid = guarantor.borrowernumber ) SET borrowers.guarantorid = NULL WHERE guarantor.borrowernumber IS NULL;
14
12
15
INSERT INTO borrower_relationships ( guarantor_id, guarantee_id, relationship, surname, firstname ) SELECT guarantorid, borrowernumber, relationship, contactname, contactfirstname FROM borrowers WHERE guarantorid IS NOT NULL OR contactname != "";
13
INSERT INTO borrower_relationships ( guarantor_id, guarantee_id, relationship ) SELECT guarantorid, borrowernumber, relationship FROM borrowers WHERE guarantorid IS NOT NULL;
16
14
17
ALTER TABLE borrowers DROP guarantorid, DROP relationship, DROP contactname, DROP contactfirstname, DROP contacttitle;
15
ALTER TABLE borrowers DROP guarantorid;
18
ALTER TABLE deletedborrowers DROP guarantorid, DROP relationship, DROP contactname, DROP contactfirstname, DROP contacttitle;
16
ALTER TABLE deletedborrowers DROP guarantorid;
19
ALTER TABLE borrowermodification DROP guarantorid, DROP relationship, DROP contactname, DROP contactfirstname, DROP contacttitle;
17
ALTER TABLE borrowermodification DROP guarantorid;
(-)a/installer/data/mysql/kohastructure.sql (-2 / +8 lines)
Lines 579-585 CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/borrower Link Here
579
  `lost` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having lost their card
579
  `lost` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having lost their card
580
  `debarred` date default NULL, -- until this date the patron can only check-in (no loans, no holds, etc.), is a fine based on days instead of money (YYYY-MM-DD)
580
  `debarred` date default NULL, -- until this date the patron can only check-in (no loans, no holds, etc.), is a fine based on days instead of money (YYYY-MM-DD)
581
  `debarredcomment` VARCHAR(255) DEFAULT NULL, -- comment on the stop of patron
581
  `debarredcomment` VARCHAR(255) DEFAULT NULL, -- comment on the stop of patron
582
  `contactname` LONGTEXT, -- used for children and profesionals to include surname or last name of guarantor or organization name
583
  `contactfirstname` MEDIUMTEXT, -- used for children to include first name of guarantor
584
  `contacttitle` MEDIUMTEXT, -- used for children to include title (Mr., Mrs., etc) of guarantor
582
  `borrowernotes` LONGTEXT, -- a note on the patron/borrower's account that is only visible in the staff client
585
  `borrowernotes` LONGTEXT, -- a note on the patron/borrower's account that is only visible in the staff client
586
  `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarantor
583
  `sex` varchar(1) default NULL, -- patron/borrower's gender
587
  `sex` varchar(1) default NULL, -- patron/borrower's gender
584
  `password` varchar(60) default NULL, -- patron/borrower's encrypted password
588
  `password` varchar(60) default NULL, -- patron/borrower's encrypted password
585
  `flags` int(11) default NULL, -- will include a number associated with the staff member's permissions
589
  `flags` int(11) default NULL, -- will include a number associated with the staff member's permissions
Lines 1604-1610 CREATE TABLE `borrowers` ( -- this table includes information about your patrons Link Here
1604
  `lost` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having lost their card
1608
  `lost` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having lost their card
1605
  `debarred` date default NULL, -- until this date the patron can only check-in (no loans, no holds, etc.), is a fine based on days instead of money (YYYY-MM-DD)
1609
  `debarred` date default NULL, -- until this date the patron can only check-in (no loans, no holds, etc.), is a fine based on days instead of money (YYYY-MM-DD)
1606
  `debarredcomment` VARCHAR(255) DEFAULT NULL, -- comment on the stop of the patron
1610
  `debarredcomment` VARCHAR(255) DEFAULT NULL, -- comment on the stop of the patron
1611
  `contactname` LONGTEXT, -- used for children and profesionals to include surname or last name of guarantor or organization name
1612
  `contactfirstname` MEDIUMTEXT, -- used for children to include first name of guarantor
1613
  `contacttitle` MEDIUMTEXT, -- used for children to include title (Mr., Mrs., etc) of guarantor
1607
  `borrowernotes` LONGTEXT, -- a note on the patron/borrower's account that is only visible in the staff client
1614
  `borrowernotes` LONGTEXT, -- a note on the patron/borrower's account that is only visible in the staff client
1615
  `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarantor
1608
  `sex` varchar(1) default NULL, -- patron/borrower's gender
1616
  `sex` varchar(1) default NULL, -- patron/borrower's gender
1609
  `password` varchar(60) default NULL, -- patron/borrower's Bcrypt encrypted password
1617
  `password` varchar(60) default NULL, -- patron/borrower's Bcrypt encrypted password
1610
  `flags` int(11) default NULL, -- will include a number associated with the staff member's permissions
1618
  `flags` int(11) default NULL, -- will include a number associated with the staff member's permissions
Lines 4106-4113 CREATE TABLE `borrower_relationships` ( Link Here
4106
      guarantor_id INT(11) NULL DEFAULT NULL,
4114
      guarantor_id INT(11) NULL DEFAULT NULL,
4107
      guarantee_id INT(11) NOT NULL,
4115
      guarantee_id INT(11) NOT NULL,
4108
      relationship VARCHAR(100) COLLATE utf8_unicode_ci NOT NULL,
4116
      relationship VARCHAR(100) COLLATE utf8_unicode_ci NOT NULL,
4109
      surname MEDIUMTEXT COLLATE utf8_unicode_ci NULL DEFAULT NULL,
4110
      firstname MEDIUMTEXT COLLATE utf8_unicode_ci NULL DEFAULT NULL,
4111
      PRIMARY KEY (id),
4117
      PRIMARY KEY (id),
4112
      CONSTRAINT r_guarantor FOREIGN KEY ( guarantor_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE,
4118
      CONSTRAINT r_guarantor FOREIGN KEY ( guarantor_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE,
4113
      CONSTRAINT r_guarantee FOREIGN KEY ( guarantee_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE
4119
      CONSTRAINT r_guarantee FOREIGN KEY ( guarantee_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-127 / +126 lines)
Lines 308-352 Link Here
308
                <fieldset class="rows">
308
                <fieldset class="rows">
309
                    <ol>
309
                    <ol>
310
                        [% IF category_type == 'P' %]
310
                        [% IF category_type == 'P' %]
311
                            [% IF ( r.guarantor_id ) %]
311
                            <li id="contact-details">
312
                                <li id="contact-details">
313
                            [% ELSE %]
314
                                <li id="contact-details" style="display: none">
315
                            [% END %]
316
                                <span class="label">Organization #:</span> [% IF ( r.guarantor_id ) %] <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% r.guarantor_id %]" target="blank">[% r.guarantor_id %]</a>[% END %]
312
                                <span class="label">Organization #:</span> [% IF ( r.guarantor_id ) %] <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% r.guarantor_id %]" target="blank">[% r.guarantor_id %]</a>[% END %]
317
                            </li>
313
                            </li>
318
314
319
                            <li>
315
                            <li>
320
                                <label for="guarantor_surname">Organization name: </label>
316
                                <label for="guarantor_surname">Organization name: </label>
321
                                [% IF ( r.guarantor_id ) %]
317
                                <span>[% r.guarantor.surname %]</span>
322
                                    <span>[% r.guarantor.surname %]</span>
323
                                [% END %]
324
                            </li>
318
                            </li>
325
                        [% ELSE %]
319
                        [% ELSE %]
326
                            [% IF ( r.guarantor_id ) %]
320
                            <li id="contact-details">
327
                                <li id="contact-details">
328
                            [% ELSE %]
329
                                <li id="contact-details" style="display: none">
330
                            [% END %]
331
332
                                <span class="label">Patron #:</span>
321
                                <span class="label">Patron #:</span>
333
                                [% IF ( r.guarantor_id ) %]
322
                                <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% r.guarantor_id %]" target="blank">[% r.guarantor_id %]</a>
334
                                    <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% r.guarantor_id %]" target="blank">[% r.guarantor_id %]</a>
335
                                [% END %]
336
337
                            </li>
323
                            </li>
338
324
339
                            [% IF r.surname || r.guarantor.surname %]
325
                            [% IF r.guarantor.surname %]
340
                                <li>
326
                                <li>
341
                                    <label for="guarantor_surname">Surname: </label>
327
                                    <label for="guarantor_surname">Surname: </label>
342
                                    <span>[% r.surname || r.guarantor.surname %]</span>
328
                                    <span>[% r.guarantor.surname %]</span>
343
                                </li>
329
                                </li>
344
                            [% END %]
330
                            [% END %]
345
331
346
                            [% IF r.firstname || r.guarantor.firstname  %]
332
                            [% IF r.guarantor.firstname  %]
347
                                <li>
333
                                <li>
348
                                    <label for="guarantor_firstname">First name: </label>
334
                                    <label for="guarantor_firstname">First name: </label>
349
                                    <span>[% r.firstname || r.guarantor.firstname %]</span>
335
                                    <span>[% r.guarantor.firstname %]</span>
350
                                </li>
336
                                </li>
351
                            [% END %]
337
                            [% END %]
352
338
Lines 401-444 Link Here
401
            </ol>
387
            </ol>
402
        </fieldset>
388
        </fieldset>
403
389
404
        <fieldset class="rows">
405
            <legend>Add new guarantor</legend>
406
            <ol>
390
            <ol>
407
                <input type="hidden" id="guarantor_id" value=""/>
391
                <input type="hidden" id="guarantor_id" value="" />
408
392
                <input name="guarantor_surname" id="guarantor_surname" type="hidden" />
409
                [% IF catetory_type == 'P' %]
393
                <input name="guarantor_firstname" id="guarantor_firstname" type="hidden" />
410
                    <li>
411
                        <label for="guarantor_surname">Organization name: </label>
412
                        <input name="guarantor_surname" id="guarantor_surname" type="hidden" size="20"/>
413
                    </li>
414
                [% ELSE %]
415
                    <li>
416
                        <label for="guarantor_surname">Surname: </label>
417
                        <input name="guarantor_surname" id="guarantor_surname" type="text" size="20" />
418
                    </li>
419
420
                    <li>
421
                        <label for="guarantor_firstname">First name: </label>
422
                        <input name="guarantor_firstname" id="guarantor_firstname" type="text" size="20" />
423
                    </li>
424
425
                    [% IF ( possible_relationships ) %]
426
                        <li>
427
                            <label for="relationship">Relationship: </label>
428
                            <select name="relationship" id="relationship" >
429
                                [% FOREACH pr IN possible_relationships.split('\|') %]
430
                                    <option value="[% pr %]">[% pr %]</option>
431
                                [% END %]
432
                            </select>
433
                        </li>
434
                    [% END %]
435
                [% END %]
436
394
437
                <li>
395
                <li>
438
                    <span class="label">&nbsp;</span>
396
                    <a href="#" id="guarantor_search" class="btn btn-sm"><i class="fa fa-search"></i> Search</a>
439
                    <a href="#" id="guarantor_add" class="btn btn-sm"><i class="fa fa-plus"></i> Add guarantor</a>
440
                    <a href="#" id="guarantor_search" class="btn btn-sm"><i class="fa fa-search"></i> Set to patron</a>
441
                    <a href="#" id="guarantor_clear">Clear</a>
442
                </li>
397
                </li>
443
398
444
                [% IF relationships && Koha.Preference('AllowStaffToSetCheckoutsVisibilityForGuarantor') %]
399
                [% IF relationships && Koha.Preference('AllowStaffToSetCheckoutsVisibilityForGuarantor') %]
Lines 457-463 Link Here
457
                    </li>
412
                    </li>
458
                [% END %]
413
                [% END %]
459
            </ol>
414
            </ol>
460
        </fieldset>
461
    </fieldset>
415
    </fieldset>
462
[% END %]
416
[% END %]
463
417
Lines 471-554 Link Here
471
[% END # nostreet && nocity etc group%]
425
[% END # nostreet && nocity etc group%]
472
426
473
[% UNLESS nophone && nophonepro && nomobile && noemail && noemailpro && nofax %]
427
[% UNLESS nophone && nophonepro && nomobile && noemail && noemailpro && nofax %]
474
  <fieldset class="rows" id="memberentry_contact">
428
    <fieldset class="rows" id="memberentry_contact">
475
    <legend id="contact_lgd">Contact</legend><ol>
429
        <legend id="contact_lgd">Contact</legend><ol>
476
        [% UNLESS nophone %]
477
      <li>
478
      [% IF ( mandatoryphone ) %]
479
      <label for="phone" class="required">
480
      [% ELSE %]
481
      <label for="phone">
482
      [% END %]
483
      Primary phone: </label>
484
        <input type="text" id="phone" name="phone" value="[% phone | html %]" />
485
	  [% IF ( mandatoryphone ) %]<span class="required">Required</span>[% END %]<div class="hint">Shows on transit slips</div>
486
430
487
    </li>
431
        [% UNLESS nocontactname %]
432
            <li>
433
                [% IF ( mandatorycontactname ) %]
434
                    <label for="contactname" class="required">
435
                [% ELSE %]
436
                    <label for="contactname">
437
                [% END %]
438
                Guarantor surname: </label>
439
                <input type="text" id="contactname" name="contactname" value="[% contactname | html %]" />
440
                [% IF ( mandatorycontactname ) %]<span class="required">Required</span>[% END %]<div class="hint">Non-patron guarantor surname</div>
441
            </li>
442
        [% END %]
443
444
        [% UNLESS nocontactfirstname %]
445
            <li>
446
                [% IF ( mandatorycontactfirstname ) %]
447
                    <label for="contactfirstname" class="required">
448
                [% ELSE %]
449
                    <label for="contactfirstname">
450
                [% END %]
451
                Guarantor first name: </label>
452
                <input type="text" id="contactfirstname" name="contactfirstname" value="[% contactfirstname | html %]" />
453
                [% IF ( mandatorycontactfirstname ) %]<span class="required">Required</span>[% END %]<div class="hint">Non-patron guarantor first name</div>
454
            </li>
455
        [% END %]
456
457
		[% UNLESS norelationship %]
458
			[% IF possible_relationships %]
459
                <li>
460
                    <label for="relationship">Relationship: </label>
461
                    <select class="relationship" name="relationship">
462
                        <option value=""></option>
463
                        [% FOREACH pr IN possible_relationships.split('\|') %]
464
                            [% IF pr == relationship %]
465
                                <option value="[% pr %]" selected="selected">[% pr %]</option>
466
                            [% ELSE %]
467
                                <option value="[% pr %]">[% pr %]</option>
468
                            [% END %]
469
                        [% END %]
470
                    </select>
471
                </li>
472
			[% END %]
473
		[% END %]
474
475
        [% UNLESS nophone %]
476
            <li>
477
                [% IF ( mandatoryphone ) %]
478
                    <label for="phone" class="required">
479
                [% ELSE %]
480
                    <label for="phone">
481
                [% END %]
482
                Primary phone: </label>
483
                <input type="text" id="phone" name="phone" value="[% phone | html %]" />
484
                [% IF ( mandatoryphone ) %]<span class="required">Required</span>[% END %]<div class="hint">Shows on transit slips</div>
485
            </li>
488
        [% END %]
486
        [% END %]
487
489
        [% UNLESS nophonepro %]
488
        [% UNLESS nophonepro %]
490
    <li>
489
            <li>
491
      [% IF ( mandatoryphonepro ) %]
490
                [% IF ( mandatoryphonepro ) %]
492
      <label for="phonepro" class="required">
491
                    <label for="phonepro" class="required">
493
      [% ELSE %]
492
                [% ELSE %]
494
      <label for="phonepro">
493
                    <label for="phonepro">
495
      [% END %]
494
                [% END %]
496
      Secondary phone: </label>
495
                Secondary phone: </label>
497
    <input type="text" id="phonepro" name="phonepro" value="[% phonepro | html %]" />
496
                <input type="text" id="phonepro" name="phonepro" value="[% phonepro | html %]" />
498
	  [% IF ( mandatoryphonepro ) %]<span class="required">Required</span>[% END %]
497
                [% IF ( mandatoryphonepro ) %]<span class="required">Required</span>[% END %]
499
    </li>
498
            </li>
500
        [% END %]
499
        [% END %]
500
501
        [% UNLESS nomobile %]
501
        [% UNLESS nomobile %]
502
    <li>
502
            <li>
503
      [% IF ( mandatorymobile ) %]
503
                [% IF ( mandatorymobile ) %]
504
      <label for="mobile" class="required">
504
                    <label for="mobile" class="required">
505
      [% ELSE %]
505
                [% ELSE %]
506
      <label for="mobile">
506
                    <label for="mobile">
507
      [% END %]
507
                [% END %]
508
      Other phone: </label>
508
                Other phone: </label>
509
        <input type="text" id="mobile" name="mobile" value="[% mobile | html %]" />
509
                <input type="text" id="mobile" name="mobile" value="[% mobile | html %]" />
510
	  [% IF ( mandatorymobile ) %]<span class="required">Required</span>[% END %]
510
                [% IF ( mandatorymobile ) %]<span class="required">Required</span>[% END %]
511
    </li>
511
            </li>
512
        [% END %]
512
        [% END %]
513
        [% UNLESS noemail %]
514
    <li>
515
      [% IF ( mandatoryemail ) %]
516
      <label for="email" class="required">
517
      [% ELSE %]
518
      <label for="email">
519
      [% END %]
520
      Primary email: </label>
521
        <input type="text" id="email" name="email" size="45" value="[% email | html %]" />
522
	  [% IF ( mandatoryemail ) %]<span class="required">Required</span>[% END %]<div class="hint">Shows on transit slips</div>
523
513
524
    </li>
514
        [% UNLESS noemail %]
515
            <li>
516
                [% IF ( mandatoryemail ) %]
517
                    <label for="email" class="required">
518
                [% ELSE %]
519
                    <label for="email">
520
                [% END %]
521
                Primary email: </label>
522
                <input type="text" id="email" name="email" size="45" value="[% email | html %]" />
523
                [% IF ( mandatoryemail ) %]<span class="required">Required</span>[% END %]<div class="hint">Shows on transit slips</div>
524
            </li>
525
        [% END %]
525
        [% END %]
526
526
        [% UNLESS noemailpro %]
527
        [% UNLESS noemailpro %]
527
    <li>
528
            <li>
528
      [% IF ( mandatoryemailpro ) %]
529
                [% IF ( mandatoryemailpro ) %]
529
      <label for="emailpro" class="required">
530
                    <label for="emailpro" class="required">
530
      [% ELSE %]
531
                [% ELSE %]
531
      <label for="emailpro">
532
                    <label for="emailpro">
532
      [% END %]
533
                [% END %]
533
      Secondary email: </label>
534
                Secondary email: </label>
534
        <input type="text" id="emailpro" name="emailpro" size="45" value="[% emailpro | html %]" />
535
                <input type="text" id="emailpro" name="emailpro" size="45" value="[% emailpro | html %]" />
535
	  [% IF ( mandatoryemailpro ) %]<span class="required">Required</span>[% END %]
536
                [% IF ( mandatoryemailpro ) %]<span class="required">Required</span>[% END %]
536
    </li>
537
            </li>
537
        [% END %]
538
        [% END %]
539
538
        [% UNLESS nofax %]
540
        [% UNLESS nofax %]
539
    <li>
541
            <li>
540
      [% IF ( mandatoryfax ) %]
542
                [% IF ( mandatoryfax ) %]
541
      <label for="fax" class="required">
543
                    <label for="fax" class="required">
542
      [% ELSE %]
544
                [% ELSE %]
543
      <label for="fax">
545
                    <label for="fax">
544
      [% END %]
546
                [% END %]
545
      Fax: </label>
547
                Fax: </label>
546
        <input type="text" id="fax" name="fax" value="[% fax | html %]" />
548
                <input type="text" id="fax" name="fax" value="[% fax | html %]" />
547
	  [% IF ( mandatoryfax ) %]<span class="required">Required</span>[% END %]
549
                [% IF ( mandatoryfax ) %]<span class="required">Required</span>[% END %]
548
    </li>
550
            </li>
549
        [% END %]
551
        [% END %]
550
	</ol>
552
    </ol>
551
  </fieldset>
553
</fieldset>
552
[%END # hide fieldset %]
554
[%END # hide fieldset %]
553
555
554
<!-- ************************ STEP_1 *********************** -->
556
<!-- ************************ STEP_1 *********************** -->
Lines 1254-1262 Link Here
1254
1256
1255
            [% IF guarantor %]
1257
            [% IF guarantor %]
1256
                select_user( '[% guarantor.borrowernumber %]', [% To.json( guarantor.unblessed ) %] );
1258
                select_user( '[% guarantor.borrowernumber %]', [% To.json( guarantor.unblessed ) %] );
1257
                $('#guarantor_add').ready(function() {
1258
                    $('#guarantor_add').click();
1259
                });
1260
            [% END %]
1259
            [% END %]
1261
1260
1262
        });
1261
        });
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-brief.tt (-25 / +16 lines)
Lines 42-76 Link Here
42
                [% IF ( dateofbirth ) %]<li><span class="label">Date of birth:</span>[% dateofbirth | $KohaDates %]</li>[% END %]
42
                [% 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 %][% END %]</li>[% END %][% END %]
43
                [% IF ( sex ) %]<li><span class="label">Gender:</span>[% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex %][% END %]</li>[% END %][% END %]
44
            [% END %]
44
            [% END %]
45
    [% IF ( isguarantee ) %]
45
46
        [% IF ( guaranteeloop ) %]
46
            [% 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 %]">[% guaranteeloo.name %]  </a></li>[% END %]</ul></li>
48
        [% END %]
49
    [% ELSE %]
50
        [% IF guarantees %]
51
            <li>
52
                <span class="label">Guarantees:</span>
53
                <ul>
54
                    [% FOREACH guarantee IN guarantees %]
55
                        <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantee.borrowernumber %]">[% guarantee.firstname %] [% guarantee.surname %]</a></li>
56
                    [% END %]
57
                </ul>
58
            </li>
59
        [% ELSIF guarantor_relationships %]
60
            [% FOREACH gr IN guarantor_relationships %]
61
                <li>
47
                <li>
62
                    <span class="label">Guarantor:</span>
48
                    <span class="label">Guarantees:</span>
63
                    [% IF gr.guarantor_id %]
49
                    <ul>
50
                        [% FOREACH guarantee IN guarantees %]
51
                            <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantee.borrowernumber %]">[% guarantee.firstname %] [% guarantee.surname %]</a></li>
52
                        [% END %]
53
                    </ul>
54
                </li>
55
            [% ELSIF guarantor_relationships %]
56
                [% FOREACH gr IN guarantor_relationships %]
57
                    <li>
58
                        <span class="label">Guarantor:</span>
64
                        [% SET guarantor = gr.guarantor %]
59
                        [% SET guarantor = gr.guarantor %]
65
                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantor.id %]">[% guarantor.firstname %] [% guarantor.surname %]</a>
60
                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantor.id %]">[% guarantor.firstname %] [% guarantor.surname %]</a>
66
                    [% ELSE %]
61
                    </li>
67
                        [% gr.firstname %] [% gr.surname %]
62
                [% END %]
68
                    [% END %]
69
                </li>
70
            [% END %]
63
            [% END %]
71
        [% END %]
64
	    </ol>
72
    [% END %]
73
	</ol>
74
	</div>
65
	</div>
75
    </div>
66
    </div>
76
    </div>
67
    </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-7 / +3 lines)
Lines 222-234 Link Here
222
                                            [% FOREACH gr IN guarantor_relationships %]
222
                                            [% FOREACH gr IN guarantor_relationships %]
223
                                                <li>
223
                                                <li>
224
                                                    <span class="label">Guarantor:</span>
224
                                                    <span class="label">Guarantor:</span>
225
                                                    [% IF gr.guarantor_id %]
225
                                                    [% SET guarantor = gr.guarantor %]
226
                                                        [% SET guarantor = gr.guarantor %]
226
                                                    [% IF logged_in_user.can_see_patron_infos( guarantor ) %]
227
                                                        [% IF logged_in_user.can_see_patron_infos( guarantor ) %]
227
                                                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantor.id %]">[% guarantor.firstname | html %] [% guarantor.surname | html %]</a>
228
                                                            <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantor.id %]">[% guarantor.firstname | html %] [% guarantor.surname | html %]</a>
229
                                                        [% END %]
230
                                                    [% ELSE %]
231
                                                        [% gr.firstname | html %] [% gr.surname | html %]
232
                                                    [% END %]
228
                                                    [% END %]
233
                                                </li>
229
                                                </li>
234
                                            [% END %]
230
                                            [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/members.js (-39 / +28 lines)
Lines 170-176 function select_user(borrowernumber, borrower) { Link Here
170
    $('#guarantor_surname').val(borrower.surname);
170
    $('#guarantor_surname').val(borrower.surname);
171
    $('#guarantor_firstname').val(borrower.firstname);
171
    $('#guarantor_firstname').val(borrower.firstname);
172
172
173
    $('#guarantor_add').click();
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();
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("");
194
195
    var guarantor_relationship = $('#relationship').val();
196
    fieldset.find('.new_guarantor_relationship').first().val( guarantor_relationship );
197
    $('#relationship').find('option:eq(0)').prop('selected', true);;
198
199
    $('#guarantor_relationships').append( fieldset );
200
    fieldset.show();
174
201
175
    return 0;
202
    return 0;
176
}
203
}
Lines 256-299 $(document).ready(function(){ Link Here
256
        $(this).parents('fieldset').first().remove();
283
        $(this).parents('fieldset').first().remove();
257
    });
284
    });
258
285
259
    $('#guarantor_add').on('click', function(e) {
260
        e.preventDefault();
261
        var fieldset = $('#guarantor_template').clone();
262
        fieldset.removeAttr('id');
263
264
        var guarantor_id = $('#guarantor_id').val();
265
        if ( guarantor_id ) {
266
            fieldset.find('.new_guarantor_id').first().val( guarantor_id );
267
            fieldset.find('.new_guarantor_id_text').first().text( guarantor_id );
268
        } else {
269
            fieldset.find('.guarantor_id').first().hide();
270
        }
271
        $('#guarantor_id').val("");
272
273
        var guarantor_surname = $('#guarantor_surname').val();
274
        fieldset.find('.new_guarantor_surname').first().val( guarantor_surname );
275
        fieldset.find('.new_guarantor_surname_text').first().text( guarantor_surname );
276
        $('#guarantor_surname').val("");
277
278
        var guarantor_firstname = $('#guarantor_firstname').val();
279
        fieldset.find('.new_guarantor_firstname').first().val( guarantor_firstname );
280
        fieldset.find('.new_guarantor_firstname_text').first().text( guarantor_firstname );
281
        $('#guarantor_firstname').val("");
282
283
        var guarantor_relationship = $('#relationship').val();
284
        fieldset.find('.new_guarantor_relationship').first().val( guarantor_relationship );
285
        $('#relationship').find('option:eq(0)').prop('selected', true);;
286
287
        $('#guarantor_relationships').append( fieldset );
288
        fieldset.show();
289
    });
290
291
    $("#guarantor_clear").click(function(e) {
292
        e.preventDefault();
293
        $("#contact-details").hide().find('a').remove();
294
        $("#guarantor_id, #guarantor_surname, #guarantor_firstname").val("");
295
    });
296
297
    $(document.body).on('change','select[name="select_city"]',function(){
286
    $(document.body).on('change','select[name="select_city"]',function(){
298
        $('select[name="select_city"]').val( $(this).val() );
287
        $('select[name="select_city"]').val( $(this).val() );
299
        var myRegEx=new RegExp(/(.*)\|(.*)\|(.*)\|(.*)/);
288
        var myRegEx=new RegExp(/(.*)\|(.*)\|(.*)\|(.*)/);
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt (-2 / +2 lines)
Lines 121-127 Link Here
121
                                    Guaranteed by
121
                                    Guaranteed by
122
                                    [% FOREACH gr IN patron.guarantor_relationships %]
122
                                    [% FOREACH gr IN patron.guarantor_relationships %]
123
                                        [% SET g = gr.guarantor %]
123
                                        [% SET g = gr.guarantor %]
124
                                        [% g.firstname || gr.firstname %] [% g.surname || gr.surname %]
124
                                        [% g.firstname %] [% g.surname %]
125
                                        [%- IF ! loop.last %], [% END %]
125
                                        [%- IF ! loop.last %], [% END %]
126
                                    [% END %]
126
                                    [% END %]
127
                                </span>
127
                                </span>
Lines 1002-1008 Link Here
1002
                }
1002
                }
1003
            });
1003
            });
1004
1004
1005
            [% IF borrower.guarantorid && !Koha.Preference('OPACPrivacy') && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
1005
            [% IF patron.guarantor_relationships && !Koha.Preference('OPACPrivacy') && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
1006
                $('#update_privacy_guarantor_checkouts').click( function() {
1006
                $('#update_privacy_guarantor_checkouts').click( function() {
1007
                    $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_guarantor_checkouts: $('#privacy_guarantor_checkouts').val() }, null, 'json')
1007
                    $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_guarantor_checkouts: $('#privacy_guarantor_checkouts').val() }, null, 'json')
1008
                     .done(function( data ) {
1008
                     .done(function( data ) {
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-privacy.tt (-1 / +1 lines)
Lines 87-93 Link Here
87
                                                Guaranteed by
87
                                                Guaranteed by
88
                                                [% FOREACH gr IN borrower.guarantor_relationships %]
88
                                                [% FOREACH gr IN borrower.guarantor_relationships %]
89
                                                    [% SET g = gr.guarantor %]
89
                                                    [% SET g = gr.guarantor %]
90
                                                    [% g.firstname || gr.firstname %] [% g.surname || gr.surname %]
90
                                                    [% g.firstname %] [% g.surname %]
91
                                                    [%- IF ! loop.last %], [% END %]
91
                                                    [%- IF ! loop.last %], [% END %]
92
                                                [% END %]
92
                                                [% END %]
93
                                            </span>
93
                                            </span>
(-)a/members/memberentry.pl (-7 / +3 lines)
Lines 896-918 sub add_guarantors { Link Here
896
    my ( $patron, $input ) = @_;
896
    my ( $patron, $input ) = @_;
897
897
898
    my @new_guarantor_id           = $input->multi_param('new_guarantor_id');
898
    my @new_guarantor_id           = $input->multi_param('new_guarantor_id');
899
    my @new_guarantor_surname      = $input->multi_param('new_guarantor_surname');
900
    my @new_guarantor_firstname    = $input->multi_param('new_guarantor_firstname');
901
    my @new_guarantor_relationship = $input->multi_param('new_guarantor_relationship');
899
    my @new_guarantor_relationship = $input->multi_param('new_guarantor_relationship');
902
900
903
    for ( my $i = 0 ; $i < scalar @new_guarantor_id; $i++ ) {
901
    for ( my $i = 0 ; $i < scalar @new_guarantor_id; $i++ ) {
904
        my $guarantor_id = $new_guarantor_id[$i];
902
        my $guarantor_id = $new_guarantor_id[$i];
905
        my $surname      = $new_guarantor_surname[$i];
906
        my $firstname    = $new_guarantor_firstname[$i];
907
        my $relationship = $new_guarantor_relationship[$i];
903
        my $relationship = $new_guarantor_relationship[$i];
908
904
905
        next unless $guarantor_id;
906
909
        $patron->add_guarantor(
907
        $patron->add_guarantor(
910
            {
908
            {
911
                guarantee_id => $patron->id,
909
                guarantee_id => $patron->id,
912
                guarantor_id => $guarantor_id,
910
                guarantor_id => $guarantor_id,
913
                surname      => $surname,
911
                relationship => $relationship,
914
                firstname    => $firstname,
915
                relationship => $relationship
916
            }
912
            }
917
        );
913
        );
918
    }
914
    }
(-)a/t/db_dependent/Patron/Relationships.t (-17 / +2 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 67;
20
use Test::More tests => 59;
21
21
22
use C4::Context;
22
use C4::Context;
23
23
Lines 92-101 Koha::Patron::Relationship->new({ guarantor_id => $kyle->id, guarantee_id => $da Link Here
92
Koha::Patron::Relationship->new({ guarantor_id => $kyle->id, guarantee_id => $kylie->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();
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();
94
Koha::Patron::Relationship->new({ guarantor_id => $chelsea->id, guarantee_id => $kylie->id, relationship => 'mother' })->store();
95
Koha::Patron::Relationship->new({ firstname => 'John', surname => 'Hall', guarantee_id => $daria->id, relationship => 'grandfather' })->store();
96
Koha::Patron::Relationship->new({ firstname => 'Debra', surname => 'Hall', guarantee_id => $daria->id, relationship => 'grandmother' })->store();
97
Koha::Patron::Relationship->new({ firstname => 'John', surname => 'Hall', guarantee_id => $kylie->id, relationship => 'grandfather' })->store();
98
Koha::Patron::Relationship->new({ firstname => 'Debra', surname => 'Hall', guarantee_id => $kylie->id, relationship => 'grandmother' })->store();
99
95
100
my @gr;
96
my @gr;
101
97
Lines 136-142 is( ref($gr[1]->guarantor), 'Koha::Patron', 'Method guarantor returns a Koha::Pa Link Here
136
is( $gr[1]->guarantor->id, $chelsea->id, 'Koha::Patron returned is the correct guarantor' );
132
is( $gr[1]->guarantor->id, $chelsea->id, 'Koha::Patron returned is the correct guarantor' );
137
133
138
@gr = $daria->guarantor_relationships();
134
@gr = $daria->guarantor_relationships();
139
is( @gr, 4, 'Found 4 guarantor relationships for child' );
135
is( @gr, 2, 'Found 4 guarantor relationships for child' );
140
is( $gr[0]->guarantor_id, $kyle->id, 'Guarantor matches for first relationship' );
136
is( $gr[0]->guarantor_id, $kyle->id, 'Guarantor matches for first relationship' );
141
is( $gr[0]->guarantee_id, $daria->id, 'Guarantee matches for first relationship' );
137
is( $gr[0]->guarantee_id, $daria->id, 'Guarantee matches for first relationship' );
142
is( $gr[0]->relationship, 'father', 'Relationship is father' );
138
is( $gr[0]->relationship, 'father', 'Relationship is father' );
Lines 153-168 is( $gr[1]->guarantee->id, $daria->id, 'Koha::Patron returned is the correct gua Link Here
153
is( ref($gr[1]->guarantor), 'Koha::Patron', 'Method guarantor returns a Koha::Patron' );
149
is( ref($gr[1]->guarantor), 'Koha::Patron', 'Method guarantor returns a Koha::Patron' );
154
is( $gr[1]->guarantor->id, $chelsea->id, 'Koha::Patron returned is the correct guarantor' );
150
is( $gr[1]->guarantor->id, $chelsea->id, 'Koha::Patron returned is the correct guarantor' );
155
151
156
is( $gr[2]->guarantor_id, undef, 'Grandfather has no id, not a Koha patron' );
157
is( $gr[2]->firstname, 'John', 'Grandfather has first name of John' );
158
is( $gr[2]->surname, 'Hall', 'Grandfather has surname of Hall' );
159
is( $gr[2]->guarantor, undef, 'Calling guarantor method for Grandfather returns undef' );
160
161
is( $gr[3]->guarantor_id, undef, 'Grandmother has no id, not a Koha patron' );
162
is( $gr[3]->firstname, 'Debra', 'Grandmother has first name of John' );
163
is( $gr[3]->surname, 'Hall', 'Grandmother has surname of Hall' );
164
is( $gr[3]->guarantor, undef, 'Calling guarantor method for Grandmother returns undef' );
165
166
my @siblings = $daria->siblings;
152
my @siblings = $daria->siblings;
167
is( @siblings, 1, 'Method siblings called in list context returns list' );
153
is( @siblings, 1, 'Method siblings called in list context returns list' );
168
is( ref($siblings[0]), 'Koha::Patron', 'List contains a Koha::Patron' );
154
is( ref($siblings[0]), 'Koha::Patron', 'List contains a Koha::Patron' );
169
- 

Return to bug 14570