Bugzilla – Attachment 1790 Details for
Bug 4030
Patron attribute types cannot be made mandatory
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
This patch adds the ability to make a patron attribute type mandatory.
0001-Bugfix-4030-Patron-attribute-types-cannot-be-made.patch (text/plain), 11.78 KB, created by
Chris Cormack
on 2010-03-02 14:00:00 UTC
(
hide
)
Description:
This patch adds the ability to make a patron attribute type mandatory.
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2010-03-02 14:00:00 UTC
Size:
11.78 KB
patch
obsolete
>From ea35a2b0d860dff699e2255b18dc4601a678b915 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle.m.hall@gmail.com> >Date: Mon, 1 Mar 2010 13:59:23 -0500 >Subject: [PATCH] Bugfix 4030 - Patron attribute types cannot be made mandatory > >This add the ability to mark a given Patron Attribute Type as >a mandatory field that must have a value when editing or >creating borrower records. >--- > C4/Members/AttributeTypes.pm | 32 +++++++++++++++++-- > admin/patron-attr-types.pl | 11 ++++++- > .../intranet-tmpl/prog/en/css/staff-global.css | 7 ++++ > .../prog/en/modules/admin/patron-attr-types.tmpl | 5 +++ > .../prog/en/modules/members/memberentrygen.tmpl | 14 ++++++-- > members/memberentry.pl | 10 +++++- > 6 files changed, 68 insertions(+), 11 deletions(-) > >diff --git a/C4/Members/AttributeTypes.pm b/C4/Members/AttributeTypes.pm >index 93c67a5..77b5d0c 100644 >--- a/C4/Members/AttributeTypes.pm >+++ b/C4/Members/AttributeTypes.pm >@@ -40,6 +40,7 @@ my @attribute_types = C4::Members::AttributeTypes::GetAttributeTypes(); > my $attr_type = C4::Members::AttributeTypes->new($code, $description); > $attr_type->code($code); > $attr_type->description($description); >+$attr_type->mandatory($mandatory); > $attr_type->repeatable($repeatable); > $attr_type->unique_id($unique_id); > $attr_type->opac_display($opac_display); >@@ -108,6 +109,7 @@ sub new { > > $self->{'code'} = shift; > $self->{'description'} = shift; >+ $self->{'mandatory'} = 0; > $self->{'repeatable'} = 0; > $self->{'unique_id'} = 0; > $self->{'opac_display'} = 0; >@@ -146,6 +148,7 @@ sub fetch { > > $self->{'code'} = $row->{'code'}; > $self->{'description'} = $row->{'description'}; >+ $self->{'mandatory'} = $row->{'mandatory'}; > $self->{'repeatable'} = $row->{'repeatable'}; > $self->{'unique_id'} = $row->{'unique_id'}; > $self->{'opac_display'} = $row->{'opac_display'}; >@@ -185,14 +188,15 @@ sub store { > opac_display = ?, > password_allowed = ?, > staff_searchable = ?, >- authorised_value_category = ? >+ authorised_value_category = ?, >+ mandatory = ? > WHERE code = ?"); > } else { > $sth = $dbh->prepare_cached("INSERT INTO borrower_attribute_types > (description, repeatable, unique_id, opac_display, password_allowed, >- staff_searchable, authorised_value_category, code) >+ staff_searchable, authorised_value_category, mandatory, code) > VALUES (?, ?, ?, ?, ?, >- ?, ?, ?)"); >+ ?, ?, ?, ? )"); > } > $sth->bind_param(1, $self->{'description'}); > $sth->bind_param(2, $self->{'repeatable'}); >@@ -201,7 +205,8 @@ sub store { > $sth->bind_param(5, $self->{'password_allowed'}); > $sth->bind_param(6, $self->{'staff_searchable'}); > $sth->bind_param(7, $self->{'authorised_value_category'}); >- $sth->bind_param(8, $self->{'code'}); >+ $sth->bind_param(8, $self->{'mandatory'}); >+ $sth->bind_param(9, $self->{'code'}); > $sth->execute; > > } >@@ -243,6 +248,25 @@ sub description { > @_ ? $self->{'description'} = shift : $self->{'description'}; > } > >+=head2 mandatory >+ >+=over 4 >+ >+my $mandatory = $attr_type->mandatory(); >+$attr_type->mandatory($mandatory); >+ >+=back >+ >+Accessor. The C<$mandatory> argument >+is interpreted as a Perl boolean. >+ >+=cut >+ >+sub mandatory { >+ my $self = shift; >+ @_ ? $self->{'mandatory'} = ((shift) ? 1 : 0) : $self->{'mandatory'}; >+} >+ > =head2 repeatable > > =over 4 >diff --git a/admin/patron-attr-types.pl b/admin/patron-attr-types.pl >index be7e891..e8f2328 100755 >--- a/admin/patron-attr-types.pl >+++ b/admin/patron-attr-types.pl >@@ -89,6 +89,9 @@ sub error_add_attribute_type_form { > > $template->param(description => $input->param('description')); > >+ if ($input->param('mandatory')) { >+ $template->param(mandatory_checked => 'checked="checked"'); >+ } > if ($input->param('repeatable')) { > $template->param(repeatable_checked => 'checked="checked"'); > } >@@ -137,6 +140,9 @@ sub add_update_attribute_type { > $attr_type->unique_id($unique_id); > } > >+ my $mandatory = $input->param('mandatory'); >+ $attr_type->mandatory($mandatory); >+ warn "Mand: $mandatory"; > my $opac_display = $input->param('opac_display'); > $attr_type->opac_display($opac_display); > my $staff_searchable = $input->param('staff_searchable'); >@@ -202,7 +208,10 @@ sub edit_attribute_type_form { > > $template->param(code => $code); > $template->param(description => $attr_type->description()); >- >+warn "Attr->mand: " . $attr_type->mandatory(); >+ if ($attr_type->mandatory()) { >+ $template->param(mandatory_checked => 'checked="checked"'); >+ } > if ($attr_type->repeatable()) { > $template->param(repeatable_checked => 'checked="checked"'); > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >index 190c9da..2a3361b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >+++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >@@ -325,6 +325,7 @@ span.problem { > line-height : 1.7em; > } > >+ > fieldset { > border : 2px solid #EEEEEE; > margin : 1em 1em 1em 0; >@@ -392,6 +393,12 @@ div#reserves,div#checkouts { > padding : 1em; > } > >+span.renewals-disabled { >+ color : #990000; >+ font-weight : bold; >+} >+ >+ > .tip { > font-size: 93%; > color : Gray; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tmpl >index 27c82c5..f406bcf 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tmpl >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tmpl >@@ -103,6 +103,11 @@ this feature on.</div> > <input type="text" id="description" name="description" size="50" maxlength="250" > value="<!-- TMPL_VAR name="description" escape="HTML" -->" /> > </li> >+ <li><label for="mandatory">Mandatory: </label> >+ <input type="checkbox" id="mandatory" name="mandatory" <!-- TMPL_VAR name="mandatory_checked" --> /> >+ <span>Check to make this field required when creating or updating patron records.</span> >+ </li> >+ > <li><label for="repeatable">Repeatable: </label> > <input type="checkbox" id="repeatable" name="repeatable" <!-- TMPL_VAR name="repeatable_checked" --> <!-- TMPL_VAR name="repeatable_disabled" --> /> > <span>Check to let a patron record have multiple values of this attribute. >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tmpl >index 503fe54..3a6d021 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tmpl >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tmpl >@@ -135,9 +135,12 @@ > <!-- TMPL_IF NAME="ERROR_short_password" --> > <li id="ERROR_short_password">Password must be at least <!-- TMPL_VAR NAME="minPasswordLength" --> characters long.</li> > <!-- /TMPL_IF --> >- <!-- TMPL_IF NAME="ERROR_extended_unique_id_failed" --> >- <li id="ERROR_extended_unique_id_failed">The attribute value >- <!-- TMPL_VAR NAME="ERROR_extended_unique_id_failed" --> is already is use by another patron record.</li> >+ <!-- TMPL_IF NAME="ERROR_extended_unique_id_failed" --> >+ <li id="ERROR_extended_unique_id_failed">The attribute value >+ <!-- TMPL_VAR NAME="ERROR_extended_unique_id_failed" --> is already is use by another patron record.</li> >+ <!-- /TMPL_IF --> >+ <!-- TMPL_IF NAME="ERROR_extended_mandatory" --> >+ <li id="ERROR_extended_mandatory">The additional attribute <!-- TMPL_VAR NAME="ERROR_extended_mandatory" --> is required.</li> > <!-- /TMPL_IF --> > </ul> > </div> >@@ -936,9 +939,11 @@ > </tr> > <!-- TMPL_LOOP NAME='patron_attributes' --> > <tr> >- <td><!-- TMPL_VAR NAME="code" --> (<!-- TMPL_VAR NAME="description" -->) >+ <td><span <!-- TMPL_IF NAME="mandatory" -->class="required"<!-- /TMPL_IF -->><!-- TMPL_VAR NAME="code" --> (<!-- TMPL_VAR NAME="description" -->)</span> > </td> > <td> >+ <input type="hidden" id="<!-- TMPL_VAR NAME="form_id" -->_mandatory" name="<!-- TMPL_VAR NAME="form_id" -->_mandatory" value="<!-- TMPL_VAR NAME="mandatory" -->" /> >+ <input type="hidden" id="<!-- TMPL_VAR NAME="form_id" -->_description" name="<!-- TMPL_VAR NAME="form_id" -->_description" value="<!-- TMPL_VAR NAME="description" ESCAPE="HTML" -->" /> > <input type="hidden" id="<!-- TMPL_VAR NAME="form_id" -->_code" name="<!-- TMPL_VAR NAME="form_id" -->_code" value="<!-- TMPL_VAR NAME="code" ESCAPE="HTML" -->" /> > <!-- TMPL_IF NAME="use_dropdown" --> > <select id="<!-- TMPL_VAR NAME="form_id" -->" name="<!-- TMPL_VAR NAME="form_id" -->"> >@@ -963,6 +968,7 @@ > (Password: <input type="password" maxlength="64" value="<!-- TMPL_VAR NAME="password" -->" > id="<!-- TMPL_VAR NAME="form_id" -->_password" name="<!-- TMPL_VAR NAME="form_id" -->_password" />) > <!-- /TMPL_IF --> >+ <!-- TMPL_IF NAME="mandatory" --><span class="required">Required</span><!-- /TMPL_IF --> > </td> > <td> > <a href="#" onclick="clear_entry(this); return false;">Clear</a> >diff --git a/members/memberentry.pl b/members/memberentry.pl >index f42e981..438f230 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -269,6 +269,10 @@ if ($op eq 'save' || $op eq 'insert'){ > push @errors, "ERROR_extended_unique_id_failed"; > $template->param(ERROR_extended_unique_id_failed => "$attr->{code}/$attr->{value}"); > } >+ if ( $attr->{mandatory} && !$attr->{value} ) { >+ push @errors, "ERROR_extended_mandatory"; >+ $template->param(ERROR_extended_mandatory => "$attr->{code} ($attr->{description})"); >+ } > } > } > } >@@ -663,12 +667,13 @@ sub parse_extended_patron_attributes { > my %dups = (); > foreach my $key (@patron_attr) { > my $value = $input->param($key); >- next unless defined($value) and $value ne ''; > my $password = $input->param("${key}_password"); > my $code = $input->param("${key}_code"); >+ my $mandatory = $input->param("${key}_mandatory"); >+ my $description = $input->param("${key}_description"); > next if exists $dups{$code}->{$value}; > $dups{$code}->{$value} = 1; >- push @attr, { code => $code, value => $value, password => $password }; >+ push @attr, { code => $code, value => $value, password => $password, mandatory => $mandatory, description => $description }; > } > return \@attr; > } >@@ -697,6 +702,7 @@ sub patron_attributes_form { > my $entry = { > code => $attr_type->code(), > description => $attr_type->description(), >+ mandatory => $attr_type->mandatory(), > repeatable => $attr_type->repeatable(), > password_allowed => $attr_type->password_allowed(), > category => $attr_type->authorised_value_category(), >-- >1.5.6.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 4030
: 1790