Bug 16167: Remove Authorised value images prefs
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / authtypes.tt
index c87434e..9c7d419 100644 (file)
@@ -1,53 +1,28 @@
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Administration &rsaquo; Authority types
-[% IF ( add_form ) %]
-&rsaquo; [% IF ( authtypecode ) %]Modify authority type[% ELSE %]New authority type[% END %]
-[% ELSIF ( delete_confirm ) %]
+[% IF op == 'add_form' %]
+&rsaquo; [% IF authority_type.authtypecode.defined %]Modify authority type[% ELSE %]New authority type[% END %]
+[% ELSIF op == 'delete_confirm' %]
 &rsaquo; Confirm deletion of authority type
 [% END %]
 </title>
 [% INCLUDE 'doc-head-close.inc' %]
+<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
+[% INCLUDE 'datatables.inc' %]
 <script type="text/javascript">
 //<![CDATA[
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-function isNotNull(f,noalert) {
-       if (f.value.length ==0) {
-               return false;
-       }
-       return true;
-}
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-function toUC(f) {
-       var x=f.value.toUpperCase();
-       f.value=x;
-       return true;
-}
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-function Check(f) {
-       var _alertString="";
-       var alertString2;
-       if (f.authtypecode.value.length==0) {
-               _alertString += "\n- " + _("Authority type : code missing");
-       }
-       if (!(isNotNull(window.document.Aform.authtypetext,1))) {
-               _alertString += "\n- " + _("Description missing");
-       }
-       if (_alertString.length==0) {
-               document.Aform.submit();
-       } else {
-               alertString2  = _("Form not submitted because of the following problem(s)");
-               alertString2 += "\n------------------------------------------------------------------------------------\n";
-               alertString2 += _alertString;
-               alert(alertString2);
-       }
-}
-
-$(document).ready(function() {
-    new YAHOO.widget.Button("authtype");
-});
+    $(document).ready(function() {
+        $("#authtypes").dataTable($.extend(true, {}, dataTablesDefaults, {
+            "aoColumnDefs": [
+                { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
+            ],
+            "sPaginationType": "four_button"
+        }));
+    });
 //]]>
 </script>
 </head>
+
 <body id="admin_authtypes" class="admin">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'cat-search.inc' %]
@@ -55,10 +30,10 @@ $(document).ready(function() {
 <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; <a href="[% script_name %]">Authority types</a>
-[% IF ( add_form ) %]
-&rsaquo; [% IF ( authtypecode ) %]Modify[% ELSE %]New[% END %] Authority type
-[% ELSIF ( delete_confirm ) %]
+&rsaquo; <a href="/cgi-bin/koha/admin/authtypes.pl">Authority types</a>
+[% IF op == 'add_form' %]
+&rsaquo; [% IF authority_type.authtypecode.defined %]Modify[% ELSE %]New[% END %] Authority type
+[% ELSIF op == 'delete_confirm' %]
 &rsaquo; Confirm deletion of authority type
 [% END %]
 </div>
@@ -68,101 +43,140 @@ $(document).ready(function() {
        <div id="yui-main">
          <div class="yui-b">
 
-[% IF ( add_form ) %]
-
-    <form action="[% script_name %]" name="Aform" method="post">
-    <fieldset class="rows">
-    <legend>
-    [% IF ( authtypecode ) %]
-        Modify authority type
-       [% ELSE %]
-        New authority type
-       [% END %]
-    </legend>
-    <ol>
-        <li>
-    [% IF ( authtypecode ) %]
-            <span class="label">Authority type</span>
-            <input type="hidden" name="op" value="add_validate" />
-            <input type="hidden" name="checked" value="0" />
-            <input type="hidden" name="authtypecode" value="[% authtypecode %]" />[% authtypecode %]
-    [% ELSE %]
-            <label for="authtypecode">Authority type: </label>
-            <input id="authtypecode" type="text" name="authtypecode" size="10" maxlength="10" onblur="toUC(this)" />
-    [% END %]
-        </li>
-               <li><label for="authtypetext">Description: </label><input type="text" id="authtypetext" name="authtypetext" size="40" maxlength="80" value="[% authtypetext |html %]" /></li>
-               <li><label for="summary">Summary: </label><textarea id="summary" name="summary" cols="55" rows="7">[% summary %]</textarea></li>
-               <li>
-               <p class="tip">Note: for 'Authority field to copy', enter the authority field that should be copied from the authority record to the bibliographic record. E.g., in MARC21, field 100 in the authority record should be copied to field 100 in the bibliographic record</p>
-               <label for="auth_tag_to_report">Authority field to copy: </label><input type="text" id="auth_tag_to_report" name="auth_tag_to_report" size="5" maxlength="3" value="[% auth_tag_to_report %]" />
-               <input type="hidden" name="op" value="add_validate" />
-        [% IF ( authtypecode ) %]
-        <input type="hidden" name="modif" value="1" />
+[% FOR m IN messages %]
+    <div class="dialog [% m.type %]">
+        [% SWITCH m.code %]
+        [% CASE 'error_on_update' %]
+            An error occurred when updating this authority type. Perhaps it already exists.
+        [% CASE 'error_on_insert' %]
+            An error occurred when adding this authority type. The authority type code might already exist.
+        [% CASE 'error_on_delete' %]
+            An error occurred when deleting this authority type. Check the logs.
+        [% CASE 'success_on_update' %]
+            Authority type updated successfully.
+        [% CASE 'success_on_insert' %]
+            Authority type added successfully.
+        [% CASE 'success_on_delete' %]
+            Authority type deleted successfully.
+        [% CASE %]
+            [% m.code %]
         [% END %]
-        </li>
-    </ol>
-       </fieldset>
-       <fieldset class="action"><input type="submit" value="Submit" onclick="Check(this.form); return false;" />
-        <a class="cancel" href="[% script_name %]">Cancel</a>
-    </fieldset>
-       </form>
+    </div>
 [% END %]
 
-[% IF ( delete_confirm ) %]
-        <div class="dialog alert"><h3>Confirm deletion of authority structure definition for <span class="ex">'[% authtypetext %]' ([% authtypecode %])</span></h3>
-       [% IF ( total ) %]
-               <p>This record is used <strong>[% total %]</strong> times</p>
-       [% END %]               
-                       <form action="[% script_name %]" method="post"><input type="hidden" name="op" value="delete_confirmed" />
-                       <input type="hidden" name="authtypecode" value="[% authtypecode %]" />
-                       <fieldset class="action"><input type="submit" class="approve" value="Yes, Delete" />
-               </form>
-               <form action="[% script_name %]" method="get"><input type="submit" class="deny" value="No, Do Not Delete" /></form>
-               </div>
-[% END %]
 
-[% IF ( else ) %]
 
-<div id="toolbar">
-       <ul class="toolbar">
-    <li><a id="authtype" href="[% script_name %]?op=add_form">New authority type</a></li>
-</ul></div>
+[% IF op == 'add_form' %]
+    <form action="/cgi-bin/koha/admin/authtypes.pl" name="Aform" method="post" class="validated">
+        <fieldset class="rows">
+            <legend>
+                [% IF authority_type.authtypecode.defined %]
+                    Modify authority type
+                [% ELSE %]
+                    New authority type
+                [% END %]
+            </legend>
+            <ol>
+                <li>
+                    [% IF authority_type.authtypecode.defined %]
+                            <span class="label">Authority type</span>
+                            <input type="hidden" name="op" value="add_validate" />
+                            <input type="hidden" name="checked" value="0" />
+                            <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode %]" />[% authority_type.authtypecode %]
+                    [% ELSE %]
+                            <label for="authtypecode" class="required">Authority type: </label>
+                            <input id="authtypecode" type="text" class="required" required="required" name="authtypecode" size="10" maxlength="10" onblur="toUC(this)" />
+                            <span class="required">Required</span>
+                    [% END %]
+                </li>
+                <li>
+                    <label for="authtypetext" class="required">Description: </label>
+                    <input type="text" id="authtypetext" name="authtypetext" size="40" maxlength="80" value="[% authority_type.authtypetext |html %]" class="required" required="required" />
+                    <span class="required">Required</span>
+                </li>
+                <li>
+                    <label for="summary">Summary: </label>
+                    <textarea id="summary" name="summary" cols="55" rows="7">[% authority_type.summary %]</textarea>
+                </li>
+                <li>
+                    <p class="tip">Note: for 'Authority field to copy', enter the authority field that should be copied from the authority record to the bibliographic record. E.g., in MARC21, field 100 in the authority record should be copied to field 100 in the bibliographic record</p>
+                    <label for="auth_tag_to_report">Authority field to copy: </label>
+                    <input type="text" id="auth_tag_to_report" name="auth_tag_to_report" size="5" maxlength="3" value="[% authority_type.auth_tag_to_report %]" />
+                    <input type="hidden" name="op" value="add_validate" />
+                    [% IF authority_type.authtypecode.defined %]
+                        <input type="hidden" name="is_a_modif" value="1" />
+                    [% END %]
+                </li>
+            </ol>
+        </fieldset>
+        <fieldset class="action">
+            <input type="submit" value="Submit" />
+            <a class="cancel" href="/cgi-bin/koha/admin/authtypes.pl">Cancel</a>
+        </fieldset>
+    </form>
+[% END %]
 
-<h1>Authority types</h1>
-<p>Define authority types, then authority MARC structure in the same way you define itemtypes and biblio MARC tag structure. Authority values are managed through plugins</p>
-<table>
-       <tr>
-               <th>Code</th>
-               <th>Description</th>
-               <th>Summary</th>
-               <th>Auth field copied</th>
-               <th>&nbsp;</th>
-               <th>Edit</th>
-               <th>Delete</th>
-       </tr>
-       
-       [% FOREACH loo IN loop %]
-        [% IF ( loop.odd ) %]
-               <tr>
+[% IF op == 'delete_confirm' %]
+    <div class="dialog alert">
+        [% IF authorities_using_it %]
+            <h3>This authority type cannot be deleted</h3>
+            <p>This record is used <strong>[% authorities_using_it %]</strong> times</p>
+            <a class="cancel" href="/cgi-bin/koha/admin/authtypes.pl">Back to the list</a>
         [% ELSE %]
-        <tr class="highlight">
+            <h3>Confirm deletion of authority structure definition for <span class="ex">'[% authority_type.authtypetext %]' ([% authority_type.authtypecode %])</span></h3>
+            <form action="/cgi-bin/koha/admin/authtypes.pl" method="post">
+                <input type="hidden" name="op" value="delete_confirmed" />
+                <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode %]" />
+                <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
+            </form>
+            <form action="/cgi-bin/koha/admin/authtypes.pl" method="get">
+                <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
+            </form>
         [% END %]
-                       <td>[% loo.authtypecode %]</td>
-                       <td>[% loo.authtypetext %]</td>
-                       <td>[% loo.summary %]</td>
-                       <td>[% loo.auth_tag_to_report %]</td>
-                       <td><a href="auth_tag_structure.pl?authtypecode=[% loo.authtypecode %]" class="button parameters" >MARC structure</a></td>
-                       <td><a href="[% loo.script_name %]?op=add_form&amp;authtypecode=[% loo.authtypecode |html %]">Edit</a></td>
-                       <td><a href="[% loo.script_name %]?op=delete_confirm&amp;authtypecode=[% loo.authtypecode |html %]">Delete</a></td>
-               </tr>
-       [% END %]
-</table>
+    </div>
+[% END %]
 
-       [% IF ( previous ) %]<p><a href="[% previous %]">&lt;&lt; Previous</a></p>[% END %]
-       [% IF ( next ) %]<p><a href="[% next %]">Next &gt;&gt;</a></p>[% END %]
+[% IF op == 'list' %]
+    <div id="toolbar" class="btn-toolbar">
+        <a id="authtype" class="btn btn-small" href="/cgi-bin/koha/admin/authtypes.pl?op=add_form"><i class="fa fa-plus"></i> New authority type</a>
+    </div>
 
+    <h1>Authority types</h1>
+    <p>Define authority types, then authority MARC structure in the same way you define itemtypes and biblio MARC tag structure. Authority values are managed through plugins</p>
+    <table id="authtypes">
+        <thead>
+        <tr>
+            <th>Code</th>
+            <th>Description</th>
+            <th>Summary</th>
+            <th>Auth field copied</th>
+            <th>&nbsp;</th>
+        </tr>
+        </thead>
+        <tbody>
+        [% FOREACH authority_type IN authority_types %]
+            <tr>
+                <td>[% authority_type.authtypecode %]</td>
+                <td>[% authority_type.authtypetext %]</td>
+                <td>[% authority_type.summary %]</td>
+                <td>[% authority_type.auth_tag_to_report %]</td>
+                <td>
+                  <div class="dropdown">
+                    <a class="btn btn-mini dropdown-toggle" id="authtypeactions[% authority_type.authtypecode %]" role="button" data-toggle="dropdown" href="#">
+                      Actions <b class="caret"></b></a>
+                    <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="authtypeactions[% authority_type.authtypecode %]">
+                      <li><a href="auth_tag_structure.pl?authtypecode=[% authority_type.authtypecode %]" class="button parameters"><i class="fa fa-eye"></i> MARC structure</a></li>
+                      <li><a href="/cgi-bin/koha/admin/authtypes.pl?op=add_form&amp;authtypecode=[% authority_type.authtypecode |html %]"><i class="fa fa-pencil"></i> Edit</a></li>
+                      [% IF authority_type.authtypecode %]<li><a href="/cgi-bin/koha/admin/authtypes.pl?op=delete_confirm&amp;authtypecode=[% authority_type.authtypecode |html %]"><i class="fa fa-trash"></i> Delete</a></li>[% END %]
+                    </ul>
+                  </div>
+                </td>
+            </tr>
+        [% END %]
+        <tbody>
+    </table>
 [% END %]
+
 </div>
 </div>
 <div class="yui-b">