From 4a2cf4f5abe1525b286fd74c0f21b6c3903acd2f 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/ --- 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 bfd1494ee8..abb4b2b356 100644 --- a/C4/Members/AttributeTypes.pm +++ b/C4/Members/AttributeTypes.pm @@ -39,6 +39,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(); @@ -109,6 +110,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'} = ''; @@ -151,6 +153,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'}; @@ -192,6 +195,7 @@ sub store { opac_display = ?, opac_editable = ?, staff_searchable = ?, + mandatory = ?, authorised_value_category = ?, display_checkout = ?, category_code = ?, @@ -205,13 +209,14 @@ sub store { opac_display, opac_editable, staff_searchable, + mandatory, authorised_value_category, display_checkout, category_code, class, code ) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); } $sth->execute( @@ -221,6 +226,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, @@ -364,6 +370,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