@@ -, +, @@
non-koha patrons as guarantors, bring back contact fields
---
Koha/Patron.pm | 32 +--
Koha/Patrons/Import.pm | 9 +-
Koha/Schema/Result/BorrowerRelationship.pm | 18 +-
installer/data/mysql/atomicupdate/bug_14570.sql | 10 +-
installer/data/mysql/kohastructure.sql | 10 +-
.../prog/en/modules/members/memberentrygen.tt | 253 ++++++++++-----------
.../prog/en/modules/members/moremember-brief.tt | 41 ++--
.../prog/en/modules/members/moremember.tt | 10 +-
koha-tmpl/intranet-tmpl/prog/js/members.js | 67 +++---
.../bootstrap/en/modules/opac-memberentry.tt | 4 +-
.../opac-tmpl/bootstrap/en/modules/opac-privacy.tt | 2 +-
members/memberentry.pl | 10 +-
t/db_dependent/Patron/Relationships.t | 18 +-
13 files changed, 204 insertions(+), 280 deletions(-)
--- a/Koha/Patron.pm
+++ a/Koha/Patron.pm
@@ -1059,13 +1059,11 @@ sub generate_userid {
my @relationships = $patron->add_guarantor(
{
borrowernumber => $borrowernumber,
- surname => $surname,
- firstname => $firstname,
relationships => $relationship,
}
);
- Adds a new guarantor to a patron, requires either an id ( borrowernumber ) or surname.
+ Adds a new guarantor to a patron.
=cut
@@ -1073,29 +1071,15 @@ sub add_guarantor {
my ( $self, $params ) = @_;
my $guarantor_id = $params->{guarantor_id};
- my $surname = $params->{surname};
- my $firstname = $params->{firstname};
my $relationship = $params->{relationship};
- if ($guarantor_id) {
- return Koha::Patron::Relationship->new(
- {
- guarantee_id => $self->id,
- guarantor_id => $guarantor_id,
- relationship => $relationship
- }
- )->store();
- }
- elsif ($surname) {
- return Koha::Patron::Relationship->new(
- {
- guarantee_id => $self->id,
- surname => $surname,
- firstname => $firstname,
- relationship => $relationship
- }
- )->store();
- }
+ return Koha::Patron::Relationship->new(
+ {
+ guarantee_id => $self->id,
+ guarantor_id => $guarantor_id,
+ relationship => $relationship
+ }
+ )->store();
}
=head2 Internal methods
--- a/Koha/Patrons/Import.pm
+++ a/Koha/Patrons/Import.pm
@@ -215,12 +215,8 @@ sub import_patrons {
my $relationship = $borrower{relationship};
my $guarantor_id = $borrower{guarantor_id};
- my $guarantor_firstname = $borrower{guarantor_firstname};
- my $guarantor_surname = $borrower{guarantor_surname};
delete $borrower{relationship};
delete $borrower{guarantor_id};
- delete $borrower{guarantor_firstname};
- delete $borrower{guarantor_surname};
if ($borrowernumber) {
@@ -359,15 +355,12 @@ sub import_patrons {
}
# Add a guarantor if we are given a relationship
- if ( $relationship ) {
- $guarantor_id ||= undef;
+ if ( $guarantor_id ) {
Koha::Patron::Relationship->new(
{
guarantee_id => $borrowernumber,
relationship => $relationship,
guarantor_id => $guarantor_id,
- firstname => $guarantor_firstname,
- surname => $guarantor_surname,
}
)->store();
}
--- a/Koha/Schema/Result/BorrowerRelationship.pm
+++ a/Koha/Schema/Result/BorrowerRelationship.pm
@@ -47,16 +47,6 @@ __PACKAGE__->table("borrower_relationships");
is_nullable: 0
size: 100
-=head2 surname
-
- data_type: 'mediumtext'
- is_nullable: 1
-
-=head2 firstname
-
- data_type: 'mediumtext'
- is_nullable: 1
-
=cut
__PACKAGE__->add_columns(
@@ -68,10 +58,6 @@ __PACKAGE__->add_columns(
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"relationship",
{ data_type => "varchar", is_nullable => 0, size => 100 },
- "surname",
- { data_type => "mediumtext", is_nullable => 1 },
- "firstname",
- { data_type => "mediumtext", is_nullable => 1 },
);
=head1 PRIMARY KEY
@@ -124,8 +110,8 @@ __PACKAGE__->belongs_to(
);
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2018-07-17 11:22:45
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:YKFiZSR3WRi1nvtLOdGV9A
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2018-07-18 10:52:59
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:R8RThgcrct40Zq0UMW3TWQ
# 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
+++ a/installer/data/mysql/atomicupdate/bug_14570.sql
@@ -3,8 +3,6 @@ CREATE TABLE `borrower_relationships` (
guarantor_id INT(11) NULL DEFAULT NULL,
guarantee_id INT(11) NOT NULL,
relationship VARCHAR(100) COLLATE utf8_unicode_ci NOT NULL,
- surname MEDIUMTEXT COLLATE utf8_unicode_ci NULL DEFAULT NULL,
- firstname MEDIUMTEXT COLLATE utf8_unicode_ci NULL DEFAULT NULL,
PRIMARY KEY (id),
CONSTRAINT r_guarantor FOREIGN KEY ( guarantor_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT r_guarantee FOREIGN KEY ( guarantee_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE
@@ -12,8 +10,8 @@ CREATE TABLE `borrower_relationships` (
UPDATE borrowers LEFT JOIN borrowers guarantor ON ( borrowers.guarantorid = guarantor.borrowernumber ) SET borrowers.guarantorid = NULL WHERE guarantor.borrowernumber IS NULL;
-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 != "";
+INSERT INTO borrower_relationships ( guarantor_id, guarantee_id, relationship ) SELECT guarantorid, borrowernumber, relationship FROM borrowers WHERE guarantorid IS NOT NULL;
-ALTER TABLE borrowers DROP guarantorid, DROP relationship, DROP contactname, DROP contactfirstname, DROP contacttitle;
-ALTER TABLE deletedborrowers DROP guarantorid, DROP relationship, DROP contactname, DROP contactfirstname, DROP contacttitle;
-ALTER TABLE borrowermodification DROP guarantorid, DROP relationship, DROP contactname, DROP contactfirstname, DROP contacttitle;
+ALTER TABLE borrowers DROP guarantorid;
+ALTER TABLE deletedborrowers DROP guarantorid;
+ALTER TABLE borrowermodification DROP guarantorid;
--- a/installer/data/mysql/kohastructure.sql
+++ a/installer/data/mysql/kohastructure.sql
@@ -579,7 +579,11 @@ CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/borrower
`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
`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)
`debarredcomment` VARCHAR(255) DEFAULT NULL, -- comment on the stop of patron
+ `contactname` LONGTEXT, -- used for children and profesionals to include surname or last name of guarantor or organization name
+ `contactfirstname` MEDIUMTEXT, -- used for children to include first name of guarantor
+ `contacttitle` MEDIUMTEXT, -- used for children to include title (Mr., Mrs., etc) of guarantor
`borrowernotes` LONGTEXT, -- a note on the patron/borrower's account that is only visible in the staff client
+ `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarantor
`sex` varchar(1) default NULL, -- patron/borrower's gender
`password` varchar(60) default NULL, -- patron/borrower's encrypted password
`flags` int(11) default NULL, -- will include a number associated with the staff member's permissions
@@ -1604,7 +1608,11 @@ CREATE TABLE `borrowers` ( -- this table includes information about your patrons
`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
`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)
`debarredcomment` VARCHAR(255) DEFAULT NULL, -- comment on the stop of the patron
+ `contactname` LONGTEXT, -- used for children and profesionals to include surname or last name of guarantor or organization name
+ `contactfirstname` MEDIUMTEXT, -- used for children to include first name of guarantor
+ `contacttitle` MEDIUMTEXT, -- used for children to include title (Mr., Mrs., etc) of guarantor
`borrowernotes` LONGTEXT, -- a note on the patron/borrower's account that is only visible in the staff client
+ `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarantor
`sex` varchar(1) default NULL, -- patron/borrower's gender
`password` varchar(60) default NULL, -- patron/borrower's Bcrypt encrypted password
`flags` int(11) default NULL, -- will include a number associated with the staff member's permissions
@@ -4106,8 +4114,6 @@ CREATE TABLE `borrower_relationships` (
guarantor_id INT(11) NULL DEFAULT NULL,
guarantee_id INT(11) NOT NULL,
relationship VARCHAR(100) COLLATE utf8_unicode_ci NOT NULL,
- surname MEDIUMTEXT COLLATE utf8_unicode_ci NULL DEFAULT NULL,
- firstname MEDIUMTEXT COLLATE utf8_unicode_ci NULL DEFAULT NULL,
PRIMARY KEY (id),
CONSTRAINT r_guarantor FOREIGN KEY ( guarantor_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE,
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
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
@@ -308,45 +308,31 @@