[Koha-patches] [PATCH 20/54] adding display_checkout field in extended attributes types

paul.poulain at biblibre.com paul.poulain at biblibre.com
Thu Dec 16 11:54:14 CET 2010


From: Paul Poulain <paul.poulain at biblibre.com>

It's a boolean that is used to display or not the left (circ-menu)

(updatedatabase in another patch)
---
 C4/Members/AttributeTypes.pm                       |   31 +++++++++++++++++--
 C4/Members/Attributes.pm                           |    3 +-
 admin/patron-attr-types.pl                         |    9 +++++-
 .../prog/en/modules/admin/patron-attr-types.tmpl   |    5 +++
 4 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/C4/Members/AttributeTypes.pm b/C4/Members/AttributeTypes.pm
index 21d17eb..c539f23 100644
--- a/C4/Members/AttributeTypes.pm
+++ b/C4/Members/AttributeTypes.pm
@@ -102,6 +102,7 @@ sub new {
     $self->{'opac_display'} = 0;
     $self->{'password_allowed'} = 0;
     $self->{'staff_searchable'} = 0;
+    $self->{'display_checkout'} = 0;
     $self->{'authorised_value_category'} = '';
 
     bless $self, $class;
@@ -136,6 +137,7 @@ sub fetch {
     $self->{'opac_display'}              = $row->{'opac_display'};
     $self->{'password_allowed'}          = $row->{'password_allowed'};
     $self->{'staff_searchable'}          = $row->{'staff_searchable'};
+    $self->{'display_checkout'}          = $row->{'display_checkout'};
     $self->{'authorised_value_category'} = $row->{'authorised_value_category'};
 
     bless $self, $class;
@@ -166,14 +168,15 @@ sub store {
                                          opac_display = ?,
                                          password_allowed = ?,
                                          staff_searchable = ?,
-                                         authorised_value_category = ?
+                                         authorised_value_category = ?,
+                                         display_checkout = ?
                                      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, display_checkout,code)
                                         VALUES (?, ?, ?, ?, ?,
-                                                ?, ?, ?)");
+                                                ?, ?, ?, ?)");
     }
     $sth->bind_param(1, $self->{'description'});
     $sth->bind_param(2, $self->{'repeatable'});
@@ -182,7 +185,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->{'display_checkout'});
+    $sth->bind_param(9, $self->{'code'});
     $sth->execute;
 
 }
@@ -288,6 +292,25 @@ sub staff_searchable {
     @_ ? $self->{'staff_searchable'} = ((shift) ? 1 : 0) : $self->{'staff_searchable'};
 }
 
+=head2 display_checkout
+
+=over 4
+
+my $display_checkout = $attr_type->display_checkout();
+$attr_type->display_checkout($display_checkout);
+
+=back
+
+Accessor.  The C<$display_checkout> argument
+is interpreted as a Perl boolean.
+
+=cut
+
+sub display_checkout {
+    my $self = shift;
+    @_ ? $self->{'display_checkout'} = ((shift) ? 1 : 0) : $self->{'display_checkout'};
+}
+
 =head2 authorised_value_category
 
   my $authorised_value_category = $attr_type->authorised_value_category();
diff --git a/C4/Members/Attributes.pm b/C4/Members/Attributes.pm
index 70c34b4..c1f1040 100644
--- a/C4/Members/Attributes.pm
+++ b/C4/Members/Attributes.pm
@@ -72,7 +72,7 @@ sub GetBorrowerAttributes {
     my $opac_only = @_ ? shift : 0;
 
     my $dbh = C4::Context->dbh();
-    my $query = "SELECT code, description, attribute, lib, password
+    my $query = "SELECT code, description, attribute, lib, password, display_checkout
                  FROM borrower_attributes
                  JOIN borrower_attribute_types USING (code)
                  LEFT JOIN authorised_values ON (category = authorised_value_category AND attribute = authorised_value)
@@ -89,6 +89,7 @@ sub GetBorrowerAttributes {
             value             => $row->{'attribute'},  
             value_description => $row->{'lib'},  
             password          => $row->{'password'},
+            display_checkout  => $row->{'display_checkout'},
         }
     }
     return \@results;
diff --git a/admin/patron-attr-types.pl b/admin/patron-attr-types.pl
index 188b040..17ee71a 100755
--- a/admin/patron-attr-types.pl
+++ b/admin/patron-attr-types.pl
@@ -105,6 +105,9 @@ sub error_add_attribute_type_form {
     if ($input->param('staff_searchable')) {
         $template->param(staff_searchable_checked => 'checked="checked"');
     }
+    if ($input->param('display_checkout')) {
+        $template->param(display_checkout_checked => 'checked="checked"');
+    }
 
     $template->param(
         attribute_type_form => 1,
@@ -146,6 +149,8 @@ sub add_update_attribute_type {
     $attr_type->authorised_value_category($authorised_value_category);
     my $password_allowed = $input->param('password_allowed');
     $attr_type->password_allowed($password_allowed);
+    my $display_checkout = $input->param('display_checkout');
+    $attr_type->display_checkout($display_checkout);
 
     if ($op eq 'edit') {
         $template->param(edited_attribute_type => $attr_type->code());
@@ -221,7 +226,9 @@ sub edit_attribute_type_form {
     if ($attr_type->staff_searchable()) {
         $template->param(staff_searchable_checked => 'checked="checked"');
     }
-
+    if ($attr_type->display_checkout()) {
+        $template->param(display_checkout_checked => 'checked="checked"');
+    }
     authorised_value_category_list($template, $attr_type->authorised_value_category());
 
     $template->param(
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 b445c41..e969273 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
@@ -122,6 +122,11 @@ function CheckAttributeTypeForm(f) {
             <input type="checkbox" id="staff_searchable" name="staff_searchable" <!-- TMPL_VAR name="staff_searchable_checked" --> />
             <span>Check to make this attribute staff_searchable in the staff patron search.</span>
        </li>
+       <li><label for="display_checkout">Display in check-out: </label>
+            <input type="checkbox" id="display_checkout" name="display_checkout" <!-- TMPL_VAR name="display_checkout_checked" --> />
+            <span>Check to show this attribute in member check-out.</span>
+       </li>
+       
         <li><label for="authorised_value_category">Authorized value category: </label>
             <select name="authorised_value_category" id="authorised_value_category">
                 <option value=""></option>
-- 
1.7.1



More information about the Koha-patches mailing list