Bug 11879: Add a new field to patron record: main contact method

This patch adds the "Main Contact Method" field in the borrower
modification form.

This field is useful for reporting purposes, or to
know which contact method to use first when trying to contact a borrower.

Test plan:
0) Apply patch
1) updatedatabase.pl
2) In the staff client, edit a patron's contact info. There should be a new dropdown select to choose the main contact method
3) In the opac page, edit the personal details.There should be a new dropdown select to choose the main contact method.
4) Save the form. It should work.

Sponsored-by: CCSR ( http://www.ccsr.qc.ca )
Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Bin Wen 2019-12-18 11:52:49 -05:00 committed by Jonathan Druart
parent 58946fc432
commit 975c48fb4a
6 changed files with 171 additions and 0 deletions

View File

@ -0,0 +1,17 @@
$DBversion = 'XXX'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
if( !column_exists( 'borrowers', 'primary_contact_method' ) ) {
$dbh->do( "ALTER TABLE `borrowers` ADD COLUMN `primary_contact_method` VARCHAR(45) NULL DEFAULT NULL AFTER `anonymized`" );
}
if( !column_exists( 'deletedborrowers', 'primary_contact_method' ) ) {
$dbh->do( "ALTER TABLE `deletedborrowers` ADD COLUMN `primary_contact_method` VARCHAR(45) NULL DEFAULT NULL AFTER `anonymized`" );
}
if( !column_exists( 'borrower_modifications', 'primary_contact_method' ) ) {
$dbh->do( "ALTER TABLE `borrower_modifications` ADD COLUMN `primary_contact_method` VARCHAR(45) NULL DEFAULT NULL AFTER `gdpr_proc_consent`" );
}
SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 11879 - Add a new field to patron record: main contact method)\n";
}

View File

@ -1305,6 +1305,7 @@ CREATE TABLE `borrower_modifications` (
`privacy` int(11) DEFAULT NULL,
`extended_attributes` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`gdpr_proc_consent` datetime DEFAULT NULL COMMENT 'data processing consent',
`primary_contact_method` varchar(45) DEFAULT NULL COMMENT 'useful for reporting purposes',
PRIMARY KEY (`verification_token`(191),`borrowernumber`),
KEY `verification_token` (`verification_token`(191)),
KEY `borrowernumber` (`borrowernumber`)
@ -1431,6 +1432,7 @@ CREATE TABLE `borrowers` (
`overdrive_auth_token` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'persist OverDrive auth token',
`anonymized` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'flag for data anonymization',
`autorenew_checkouts` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'flag for allowing auto-renewal',
`primary_contact_method` varchar(45) DEFAULT NULL COMMENT 'useful for reporting purposes',
PRIMARY KEY (`borrowernumber`),
UNIQUE KEY `cardnumber` (`cardnumber`),
UNIQUE KEY `userid` (`userid`),
@ -2437,6 +2439,7 @@ CREATE TABLE `deletedborrowers` (
`overdrive_auth_token` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'persist OverDrive auth token',
`anonymized` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'flag for data anonymization',
`autorenew_checkouts` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'flag for allowing auto-renewal',
`primary_contact_method` varchar(45) DEFAULT NULL COMMENT 'useful for reporting purposes',
KEY `borrowernumber` (`borrowernumber`),
KEY `cardnumber` (`cardnumber`),
KEY `sms_provider_id` (`sms_provider_id`)

View File

@ -764,6 +764,64 @@ legend:hover {
[% END %]
</li>
[% END #/UNLESS nofax %]
<li>
[% IF mandatoryprimary_contact_method %]
<label for="primary_contact_method" class="required">
[% ELSE %]
<label for="primary_contact_method">
[% END %]
Main contact method: </label>
<select id="primary_contact_method" name="primary_contact_method">
<option value=""></option>
[% UNLESS nophone %]
[% IF ( primary_contact_method == 'phone' ) %]
<option value="phone" selected="selected">Primary phone</option>
[% ELSE %]
<option value="phone">Primary phone</option>
[% END %]
[% END %]
[% UNLESS nophonepro %]
[% IF ( primary_contact_method == 'phonepro' ) %]
<option value="phonepro" selected="selected">Secondary phone</option>
[% ELSE %]
<option value="phonepro">Secondary phone</option>
[% END %]
[% END %]
[% UNLESS nomobile %]
[% IF ( primary_contact_method == 'mobile' ) %]
<option value="mobile" selected="selected">Other phone</option>
[% ELSE %]
<option value="mobile">Other phone</option>
[% END %]
[% END %]
[% UNLESS noemail %]
[% IF ( primary_contact_method == 'email' ) %]
<option value="email" selected="selected">Primary email</option>
[% ELSE %]
<option value="email">Primary email</option>
[% END %]
[% END %]
[% UNLESS noemailpro %]
[% IF ( primary_contact_method == 'emailpro' ) %]
<option value="emailpro" selected="selected">Secondary email</option>
[% ELSE %]
<option value="emailpro">Secondary email</option>
[% END %]
[% END %]
[% UNLESS nofax %]
[% IF ( primary_contact_method == 'fax' ) %]
<option value="fax" selected="selected">Fax</option>
[% ELSE %]
<option value="fax">Fax</option>
[% END %]
[% END %]
</select>
[% IF mandatoryprimary_contact_method %]
<span class="required">Required</span>
[% END %]
</li>
</ol>
</fieldset> <!-- /#memberentry_contact -->
[% END # hide fieldset %]

View File

@ -326,6 +326,26 @@
</ul>
</li>
[% END %]
[% IF ( primary_contact_method ) %]
<li>
<span class="label">Main contact method: </span>
[% SWITCH primary_contact_method %]
[% CASE 'phone' %]
Primary phone
[% CASE 'phonepro' %]
Secondary phone
[% CASE 'mobile' %]
Other phone
[% CASE 'email' %]
Primary email
[% CASE 'emailpro' %]
Secondary email
[% CASE 'fax' %]
Fax
[% END %]
</li>
[% END %]
</ol>
</div> [% # /div.rows %]
</div> [% # /div#patron-information %]

View File

@ -578,6 +578,65 @@
<div class="required_label [% required.fax | html %]">Required</div>
</li>
[% END %]
[% UNLESS hidden.defined('primary_contact_method') %]
<li>
[% IF ( mandatory.defined('primary_contact_method') ) %]
<label for="borrower_primary_contact_method" class="required">Main contact method:</label>
[% ELSE %]
<label for="borrower_primary_contact_method">Main contact method:</label>
[% END %]
<select id="borrower_primary_contact_method" name="borrower_primary_contact_method">
<option value=""></option>
[% FOREACH contactprincipalloo IN contactprincipalloop %]
[% IF ( contactprincipalloo.currentis_phone ) %]
[% IF ( borrower.primary_contact_method == 'phone' ) %]
<option value="phone" selected="selected">Primary phone</option>
[% ELSE %]
<option value="phone">Primary phone</option>
[% END %]
[% END %]
[% IF ( contactprincipalloo.currentis_phonepro ) %]
[% IF ( borrower.primary_contact_method == 'phonepro' ) %]
<option value="phonepro" selected="selected">Secondary phone</option>
[% ELSE %]
<option value="phonepro">Secondary phone</option>
[% END %]
[% END %]
[% IF ( contactprincipalloo.currentis_mobile ) %]
[% IF ( borrower.primary_contact_method == 'mobile' ) %]
<option value="mobile" selected="selected">Other phone</option>
[% ELSE %]
<option value="mobile">Other phone</option>
[% END %]
[% END %]
[% IF ( contactprincipalloo.currentis_email ) %]
[% IF ( borrower.primary_contact_method == 'email' ) %]
<option value="email" selected="selected">Primary email</option>
[% ELSE %]
<option value="email">Primary email</option>
[% END %]
[% END %]
[% IF ( contactprincipalloo.currentis_emailpro ) %]
[% IF ( borrower.primary_contact_method == 'emailpro' ) %]
<option value="emailpro" selected="selected">Secondary email</option>
[% ELSE %]
<option value="emailpro">Secondary email</option>
[% END %]
[% END %]
[% IF ( contactprincipalloo.currentis_fax ) %]
[% IF ( borrower.primary_contact_method == 'fax' ) %]
<option value="fax" selected="selected">Fax</option>
[% ELSE %]
<option value="fax">Fax</option>
[% END %]
[% END %]
[% END %]
</select>
[% IF ( mandatory.defined('primary_contact_method') ) %]<span class="required">Required</span>[% END %]
</li>
[% END %]
</ol>
</fieldset>
</div> <!-- /.col -->

View File

@ -102,6 +102,20 @@ $template->param(
defaultCategory => $defaultCategory,
);
my $check_BorrowerMandatoryField=C4::Context->preference("BorrowerMandatoryField");
my @field_check=split(/\|/,$check_BorrowerMandatoryField);
my @contactprincipalloop;
my @fieldArray = qw(phone phonepro mobile email emailpro fax);
foreach my $field (@fieldArray) {
if ( !(grep { $field eq $_ } @field_check)){
push @contactprincipalloop,{
'currentis_' . $field => 1
};
}
}
$template->param('contactprincipalloop' => \@contactprincipalloop);
my $attributes = ParsePatronAttributes($borrowernumber,$cgi);
my $conflicting_attribute = 0;