From ea35a2b0d860dff699e2255b18dc4601a678b915 Mon Sep 17 00:00:00 2001 From: Kyle M Hall 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. " /> +
  • + /> + Check to make this field required when creating or updating patron records. +
  • +
  • /> 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 @@
  • Password must be at least characters long.
  • - -
  • The attribute value - is already is use by another patron record.
  • + +
  • The attribute value + is already is use by another patron record.
  • + + +
  • The additional attribute is required.
  • @@ -936,9 +939,11 @@ - () + class="required"> () + _mandatory" name="_mandatory" value="" /> + _description" name="_description" value="" /> _code" name="_code" value="" /> " id="_password" name="_password" />) + Required Clear 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