Bug 10515: make behavior of library category fetchers consistent with other fetchers
[koha_fer] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / patron-attr-types.tt
index b8a8e3e..e561ae5 100644 (file)
@@ -1,5 +1,5 @@
 [% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; Administration &rsaquo; Patron Attribute Types
+<title>Koha &rsaquo; Administration &rsaquo; Patron attribute types
 [% IF ( attribute_type_form ) %]
   [% IF ( edit_attribute_type ) %]
     &rsaquo; Modify patron attribute type
 
 <script type="text/javascript">
 //<![CDATA[
+$(document).ready(function() {
+    if ( $("#branches option:selected").length < 1 ) {
+        $("#branches option:first").attr("selected", "selected");
+    }
+} );
 
 function DoCancel(f) {
   f.op.value='';
@@ -44,11 +49,11 @@ function CheckAttributeTypeForm(f) {
 //]]>
 </script>
 </head>
-<body>
+<body id="admin_patron-attr-types" class="admin">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'cat-search.inc' %]
 
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; [% IF ( display_list ) %]Patron Attribute Types[% ELSE %]<a href="/cgi-bin/koha/admin/patron-attr-types.pl">Patron Attribute Types</a>[% END %]
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; [% IF ( display_list ) %]Patron attribute types[% ELSE %]<a href="/cgi-bin/koha/admin/patron-attr-types.pl">Patron attribute types</a>[% END %]
 [% IF ( attribute_type_form ) %]
   [% IF ( edit_attribute_type ) %]
     &rsaquo; Modify patron attribute type
@@ -186,6 +191,48 @@ function CheckAttributeTypeForm(f) {
                   to be chosen from the authorized value list.  However, an authorized value list is not 
                   enforced during batch patron import.</span>
         </li>
+        <li><label for="branches">Branches limitation: </label>
+            <select id="branches" name="branches" multiple size="10">
+                <option value="">All branches</option>
+                [% FOREACH branch IN branches_loop %]
+                  [% IF ( branch.selected ) %]
+                    <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
+                  [% ELSE %]
+                    <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
+                  [% END %]
+                [% END %]
+            </select>
+            <span>Select All if this attribute type must to be displayed all the time. Otherwise select librairies you want to associate with this value.
+            </span>
+        </li>
+        <li>
+            <label for="category">Category: </label>
+            <select name="category_code" id="category">
+                <option value=""></option>
+                [% FOREACH cat IN categories %]
+                    [% IF ( cat.categorycode == category_code ) %]<option value="[% cat.categorycode %]" selected="selected">[% cat.description %]</option>[% ELSE %]<option value="[% cat.categorycode %]">[% cat.description %]</option>[% END %]
+                [% END %]
+            </select>
+            <span>Choose one to limit this attribute to one patron type. Please leave blank if you want these attributes to be available for all types of patrons.</span>
+        </li>
+        <li>
+            <label for="class">Class: </label>
+            <select name="class">
+                <option value="" />
+                [% FOREACH class IN classes_val_loop %]
+                    [% IF ( class.selected ) %]
+                        <option value="[% class.authorised_value %]" selected="selected">
+                            [% class.lib %]
+                        </option>
+                    [% ELSE %]
+                        <option value="[% class.authorised_value %]" >
+                            [% class.lib %]
+                        </option>
+                    [% END %]
+                [% END %]
+            </select>
+            <span>Group attributes types with a block title (based on authorized values category 'PA_CLASS')</span>
+        </li>
     </ol>
   </fieldset>
   <fieldset class="action">
@@ -214,23 +261,11 @@ function CheckAttributeTypeForm(f) {
 
 [% IF ( display_list ) %]
 
-<div id="toolbar">
-       <script type="text/javascript">
-       //<![CDATA[
-       // prepare DOM for YUI Toolbar
-        $(document).ready(function() {
-           yuiToolbar();
-        });
-       // YUI Toolbar Functions
-       function yuiToolbar() {
-           new YAHOO.widget.Button("newrule");
-       }       //]]>
-       </script>
-       <ul class="toolbar">
-       <li><a id="newrule" href="[% script_name %]?op=add_attribute_type">New Patron Attribute Type</a></li>
-</ul></div>
+<div id="toolbar" class="btn-toolbar">
+    <a class="btn btn-small" id="newrule" href="[% script_name %]?op=add_attribute_type"><i class="icon-plus"></i> New patron attribute type</a>
+</div>
 
-<h2>Patron Attribute Types</h2>
+<h2>Patron attribute types</h2>
 [% IF ( added_attribute_type ) %]
 <div class="dialog message">Added patron attribute type &quot;[% added_attribute_type %]&quot;</div>
 [% END %]
@@ -248,23 +283,54 @@ function CheckAttributeTypeForm(f) {
 <div class="dialog message">Could not delete patron attribute type &quot;[% ERROR_delete_not_found %]&quot; 
     &mdash; it was already absent from the database.</div>
 [% END %]
-[% IF ( available_attribute_types ) %]<table>
-  <tr>
-    <th>Code</th>
-    <th>Description</th>
-    <th>Actions</th>
-  </tr>
-  [% FOREACH available_attribute_type IN available_attribute_types %]
-  <tr>
-    <td>[% available_attribute_type.code |html %]</td>
-    <td>[% available_attribute_type.description %]</td>
-    <td>
-      <a href="[% available_attribute_type.script_name %]?op=edit_attribute_type&amp;code=[% available_attribute_type.code |html %]">Edit</a>
-      <a href="[% available_attribute_type.script_name %]?op=delete_attribute_type&amp;code=[% available_attribute_type.code |html %]">Delete</a>
-    </td>
-  </tr>
+[% IF ( available_attribute_types ) %]
+  [% FOREACH attribute IN available_attribute_types %]
+    [% IF attribute.class %]
+        <h4>[% attribute.lib %]</h4>
+    [% END %]
+    <table class="patron_attributes_types">
+      <thead>
+        <tr>
+          <th>Code</th>
+          <th>Description</th>
+          <th>Branches limitation</th>
+          <th>Actions</th>
+        </tr>
+      </thead>
+      <tbody>
+        [% FOREACH item IN attribute.items %]
+          <tr>
+            <td>[% item.code |html %]</td>
+            <td>[% item.description %]</td>
+            <td>
+                [% IF item.branches.size > 0 %]
+                    [% branches_str = "" %]
+                    [% FOREACH branch IN item.branches %]
+                        [% branches_str = branches_str _ " " _ branch.branchname _ "(" _ branch.branchcode _ ")" %]
+                    [% END %]
+                    <span title="[% branches_str %]">
+                        [% IF item.branches.size > 1 %]
+                            [% item.branches.size %] branches limitations
+                        [% ELSE %]
+                            [% item.branches.size %] branch limitation
+                        [% END %]
+                    </span>
+                [% ELSE %]
+                    No limitation
+                [% END %]
+            </td>
+            <td>
+              <a href="[% item.script_name %]?op=edit_attribute_type&amp;code=[% item.code |html %]">Edit</a>
+              <a href="[% item.script_name %]?op=delete_attribute_type&amp;code=[% item.code |html %]">Delete</a>
+            </td>
+          </tr>
+        [% END %]
+      </tbody>
+    </table>
   [% END %]
-</table>[% ELSE %]<p>There are no saved patron attribute types.</p>[% END %]
+[% ELSE %]
+  <p>There are no saved patron attribute types.</p>
+[% END %]
 
 <div class="pages">[% pagination_bar %]</div>