From fc08b18dc3fd715b6c9b091299028472f778dc44 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 17 May 2019 09:14:00 -0500 Subject: [PATCH] Bug 22844: Add the new entry to the patron attr types form Will conflict with bug 20443 \o/ Signed-off-by: David Nind --- C4/Members/AttributeTypes.pm | 23 +++++++++++++++++++++- admin/patron-attr-types.pl | 8 ++++++++ .../prog/en/modules/admin/patron-attr-types.tt | 8 ++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/C4/Members/AttributeTypes.pm b/C4/Members/AttributeTypes.pm index 948acbe3a9..7f02ca5bf0 100644 --- a/C4/Members/AttributeTypes.pm +++ b/C4/Members/AttributeTypes.pm @@ -38,6 +38,7 @@ C4::Members::AttributeTypes - mananage extended patron attribute types $attr_type->opac_display($opac_display); $attr_type->opac_editable($opac_editable); $attr_type->staff_searchable($staff_searchable); + $attr_type->mandatory($mandatory); $attr_type->authorised_value_category($authorised_value_category); $attr_type->store(); $attr_type->delete(); @@ -108,6 +109,7 @@ sub new { $self->{'opac_display'} = 0; $self->{'opac_editable'} = 0; $self->{'staff_searchable'} = 0; + $self->{'mandatory'} = 0; $self->{'display_checkout'} = 0; $self->{'authorised_value_category'} = ''; $self->{'category_code'} = ''; @@ -150,6 +152,7 @@ sub fetch { $self->{'opac_display'} = $row->{'opac_display'}; $self->{'opac_editable'} = $row->{'opac_editable'}; $self->{'staff_searchable'} = $row->{'staff_searchable'}; + $self->{'mandatory'} = $row->{'mandatory'}; $self->{'display_checkout'} = $row->{'display_checkout'}; $self->{'authorised_value_category'} = $row->{'authorised_value_category'}; $self->{'category_code'} = $row->{'category_code'}; @@ -191,6 +194,7 @@ sub store { opac_display = ?, opac_editable = ?, staff_searchable = ?, + mandatory = ?, authorised_value_category = ?, display_checkout = ?, category_code = ?, @@ -204,13 +208,14 @@ sub store { opac_display, opac_editable, staff_searchable, + mandatory, authorised_value_category, display_checkout, category_code, class, code ) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); } $sth->execute( @@ -220,6 +225,7 @@ sub store { $self->{'opac_display'}, $self->{'opac_editable'}, $self->{'staff_searchable'} || 0, + $self->{'mandatory'} || 0, $self->{'authorised_value_category'}, $self->{'display_checkout'}, $self->{'category_code'} || undef, @@ -363,6 +369,21 @@ sub staff_searchable { @_ ? $self->{'staff_searchable'} = ((shift) ? 1 : 0) : $self->{'staff_searchable'}; } +=head2 mandatory + + my $mandatory = $attr_type->mandatory(); + $attr_type->mandatory($mandatory); + +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 display_checkout my $display_checkout = $attr_type->display_checkout(); diff --git a/admin/patron-attr-types.pl b/admin/patron-attr-types.pl index 174bac5926..ed9072bd91 100755 --- a/admin/patron-attr-types.pl +++ b/admin/patron-attr-types.pl @@ -125,6 +125,9 @@ sub error_add_attribute_type_form { if ($input->param('staff_searchable')) { $template->param(staff_searchable_checked => 1); } + if ($input->param('mandatory')) { + $template->param(mandatory_checked => 1); + } if ($input->param('display_checkout')) { $template->param(display_checkout_checked => 'checked="checked"'); } @@ -170,6 +173,8 @@ sub add_update_attribute_type { $attr_type->opac_editable($opac_editable); my $staff_searchable = $input->param('staff_searchable'); $attr_type->staff_searchable($staff_searchable); + my $mandatory = $input->param('mandatory'); + $attr_type->mandatory($mandatory); my $authorised_value_category = $input->param('authorised_value_category'); $attr_type->authorised_value_category($authorised_value_category); my $display_checkout = $input->param('display_checkout'); @@ -254,6 +259,9 @@ sub edit_attribute_type_form { if ($attr_type->staff_searchable()) { $template->param(staff_searchable_checked => 1); } + if ($attr_type->mandatory()) { + $template->param(mandatory_checked => 1); + } if ($attr_type->display_checkout()) { $template->param(display_checkout_checked => 'checked="checked"'); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt index d4cecaafdf..cb3195fa62 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt @@ -132,6 +132,14 @@ [% END %] Check to make this attribute staff_searchable in the staff patron search. +
  • + [% IF ( mandatory_checked ) %] + + [% ELSE %] + + [% END %] + Check to make this attribute mandatory when creating or editing a patron. +
  • [% IF display_checkout_checked %] -- 2.11.0