Bug 16308 - Remove the use of "onclick" from Z39.50/SRU servers template
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / cities.tt
index bd45d57..f6a85ea 100644 (file)
@@ -1,26 +1,19 @@
 [% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; Administration &rsaquo; [% IF ( add_form ) %]Cities &rsaquo; [% IF ( cityid ) %] Modify City[% ELSE %] New City[% END %][% ELSE %][% IF ( delete_confirm ) %]Cities &rsaquo; Confirm Deletion of City[% ELSE %] Cities[% END %][% END %]</title>
+<title>Koha &rsaquo; Administration &rsaquo; [% IF op =='add_form' %]Cities &rsaquo; [% IF city.cityid %] Modify city[% ELSE %] New city[% END %][% ELSE %][% IF op == 'delete_confirm' %]Cities &rsaquo; Confirm deletion of city[% ELSE %] Cities[% END %][% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.pager.js"></script>
-<script type="text/javascript" id="js">$(document).ready(function() {
-       $.tablesorter.defaults.widgets = ['zebra'];
-       $("#table_cities").tablesorter({
-               sortList: [[1,0]],
-               headers: { 5: { sorter: false},6: { sorter: false}}
-       }).tablesorterPager({container: $("#pagertable_cities"),positionFixed: false,size: 20});
-}); </script>
+<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
+[% INCLUDE 'datatables.inc' %]
 <script type="text/javascript">
 //<![CDATA[
-    function Check(f) {
-        if (f.city_zipcode.value.length == 0 && f.city_name.value.length == 0 ) {
-            alert(_("City name & zipcode missing"));
-        } else{
-            document.Aform.submit();
-        }
-    }
     $(document).ready(function() {
-        new YAHOO.widget.Button("newcity");
+        $("#table_cities").dataTable($.extend(true, {}, dataTablesDefaults, {
+            "aoColumnDefs": [
+                { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
+            ],
+            "aaSorting": [[ 1, "asc" ]],
+            "iDisplayLength": 10,
+            "sPaginationType": "full_numbers"
+        }));
     });
 //]]>
 </script>
     <a href="/cgi-bin/koha/mainpage.pl">Home</a>
     &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
     &rsaquo; <a href="/cgi-bin/koha/admin/cities.pl">Cities</a>
-    [% IF ( add_form ) %]
-    &rsaquo; [% IF ( cityid ) %]Modify[% ELSE %]New[% END %] City
-    [% ELSIF ( delete_confirm ) %]
-    &rsaquo; Confirm Deletion of City
+    [% IF op == 'add_form' %]
+    &rsaquo; [% IF city.cityid %]Modify[% ELSE %]New[% END %] City
+    [% ELSIF op == 'delete_confirm' %]
+    &rsaquo; Confirm deletion of city
     [% END %]
 </div>
 
 <div id="doc3" class="yui-t2">
-   
+
    <div id="bd">
-       <div id="yui-main">
-       <div class="yui-b">
+    <div id="yui-main">
+    <div class="yui-b">
+
+[% FOR m IN messages %]
+    <div class="dialog [% m.type %]">
+        [% SWITCH m.code %]
+        [% CASE 'error_on_update' %]
+            An error occurred when updating this city. Perhaps it already exists.
+        [% CASE 'error_on_insert' %]
+            An error occurred when adding this city. The city id might already exist.
+        [% CASE 'error_on_delete' %]
+            An error occurred when deleting this city. Check the logs.
+        [% CASE 'success_on_update' %]
+            City updated successfully.
+        [% CASE 'success_on_insert' %]
+            City added successfully.
+        [% CASE 'success_on_delete' %]
+            City deleted successfully.
+        [% CASE 'already_exists' %]
+            This city already exists.
+        [% CASE %]
+            [% m.code %]
+        [% END %]
+    </div>
+[% END %]
 
-[% IF ( add_form ) %]
-       [% IF ( cityid ) %]
-               <h1>Modify a city</h1>
-       [% ELSE %]
-               <h1>New city</h1>
-       [% END %]
+[% IF op == 'add_form' %]
+    [% IF city %]
+        <h1>Modify a city</h1>
+    [% ELSE %]
+        <h1>New city</h1>
+    [% END %]
 
-       <form action="[% script_name %]" name="Aform" method="post">
-       <input type="hidden" name="op" value="add_validate" />
-       <input type="hidden" name="checked" value="0" />
-       <input type="hidden" name="cityid" value="[% cityid %]" />
+    <form action="/cgi-bin/koha/admin/cities.pl" name="Aform" method="post" class="validated">
+        <input type="hidden" name="op" value="add_validate" />
+        <input type="hidden" name="cityid" value="[% city.cityid %]" />
 
-<fieldset class="rows"><ol>    [% IF ( cityid ) %]
-               <li>
-               <span class="label">City ID: </span>[% cityid %]</li>
-       [% END %]
-       <li>
-       <label for="city_name" class="required" title="required">City: </label>
-       <input type="text" name="city_name" id="city_name" size="80" maxlength="100" value="[% city_name |html %]" />
-       </li>
-       <li>
-       <label for="city_state">State: </label>
-       <input type="text" name="city_state" id="city_state" size="80" maxlength="100" value="[% city_state |html %]" />
-       </li>
-       <li>                            
-       <label for="city_zipcode" class="required" title="required">Zip/Postal code: </label>
-       <input type="text" name="city_zipcode" id="city_zipcode" size="20" maxlength="20" value="[% city_zipcode %]" />
-       </li>
-       <li>
-       <label for="city_country">Country: </label>
-       <input type="text" name="city_country" id="city_country" size="80" maxlength="100" value="[% city_country |html %]" />
-       </li></ol></fieldset>
-       
-       <fieldset class="action">
-               <input class="button" type="button" onclick="Check(this.form)" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/admin/cities.pl">Cancel</a>
-       </fieldset>
-       </form>
+        <fieldset class="rows">
+            <ol>
+                [% IF city %]
+                    <li><span class="label">City ID: </span>[% city.cityid %]</li>
+                [% END %]
+                <li>
+                    <label for="city_name" class="required">City: </label>
+                    <input type="text" name="city_name" id="city_name" size="80" maxlength="100" value="[% city.city_name |html %]" required="required" class="required" /> <span class="required">Required</span>
+                </li>
+                <li>
+                    <label for="city_state">State: </label>
+                    <input type="text" name="city_state" id="city_state" size="80" maxlength="100" value="[% city.city_state |html %]" />
+                </li>
+                <li>
+                    <label for="city_zipcode" class="required">ZIP/Postal code: </label>
+                    <input type="text" name="city_zipcode" id="city_zipcode" size="20" maxlength="20" value="[% city.city_zipcode %]" required="required" class="required" /> <span class="required">Required</span>
+                </li>
+                <li>
+                    <label for="city_country">Country: </label>
+                    <input type="text" name="city_country" id="city_country" size="80" maxlength="100" value="[% city.city_country |html %]" />
+                </li>
+            </ol>
+        </fieldset>
 
+        <fieldset class="action">
+            <input type="submit" value="Submit" />
+            <a class="cancel" href="/cgi-bin/koha/admin/cities.pl">Cancel</a>
+        </fieldset>
+    </form>
 [% END %]
-[% IF ( delete_confirm ) %]
+
+[% IF op == 'delete_confirm' %]
     <div class="dialog alert">
-    <h3>Delete City "[% city_name %]?"</h3>
-    <table>
-        <tr><th>City id</th>
-            <td>[% cityid %]</td>
-        </tr>
-        <tr><th>City</th>
-            <td>[% city_name %]</td>
-        </tr>
-        <tr><th>State</th>
-            <td>[% city_state %]</td>
-        </tr>
-        <tr><th>Zip/Postal code</th>
-            <td>[% city_zipcode %]</td>
-        </tr>
-        <tr><th>Country</th>
-            <td>[% city_country %]</td>
-        </tr>
-    </table>
-    <form action="[% script_name %]" method="post">
-        <input type="hidden" name="op" value="delete_confirmed" />
-        <input type="hidden" name="cityid" value="[% cityid %]" />
-        <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>
+        <h3>Delete city "[% city.city_name %]?"</h3>
+        <table>
+            <tr><th>City id</th>
+                <td>[% city.cityid %]</td>
+            </tr>
+            <tr><th>City</th>
+                <td>[% city.city_name %]</td>
+            </tr>
+            <tr><th>State</th>
+                <td>[% city.city_state %]</td>
+            </tr>
+            <tr><th>ZIP/Postal code</th>
+                <td>[% city.city_zipcode %]</td>
+            </tr>
+            <tr><th>Country</th>
+                <td>[% city.city_country %]</td>
+            </tr>
+        </table>
+        <form action="/cgi-bin/koha/admin/cities.pl" method="post">
+            <input type="hidden" name="op" value="delete_confirmed" />
+            <input type="hidden" name="cityid" value="[% city.cityid %]" />
+            <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
+        </form>
+        <form action="/cgi-bin/koha/admin/cities.pl" method="get">
+            <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
+        </form>
+    </div>
 [% END %]
 
-[% IF ( else ) %]
+[% IF op == 'list' %]
 
-<div id="toolbar">
-       <ul class="toolbar">
-       <li><a id="newcity" href="[% script_name %]?op=add_form">New City</a></li>
-</ul></div>
+    <div id="toolbar" class="btn-toolbar">
+        <a class="btn btn-small" id="newcity" href="/cgi-bin/koha/admin/cities.pl?op=add_form"><i class="fa fa-plus"></i> New city</a>
+    </div>
 
-       <h2>Cities</h2>
-       [% IF ( searchfield ) %]
-               Searching: [% searchfield %]
-       [% END %]
+    <h2>Cities</h2>
+    [% IF searchfield %]
+        Searching: [% searchfield %]
+    [% END %]
 
-[% IF ( loop ) %]
-<div id="pagertable_cities">
-[% INCLUDE 'table-pager.inc' perpage='20' %]
-</div>
-<table id="table_cities">
-               <thead>
-                       <th>City ID</th>
-                       <th>City</th>
-                       <th>State</th>
-                       <th>Zip/Postal code</th>
-                       <th>Country</th>
-                       <th>&nbsp;</th>
-                       <th>&nbsp;</th>
-               </thead>
-               [% FOREACH loo IN loop %]
-               [% UNLESS ( loop.odd ) %]
-               <tr class="highlight">
-               [% ELSE %]
-               <tr>
-               [% END %]
-                       <td>[% loo.cityid %]</td>
-                       <td>[% loo.city_name %]</td>
-                       <td>[% loo.city_state %]</td>
-                       <td>[% loo.city_zipcode %]</td>
-                       <td>[% loo.city_country %]</td>
-                       <td><a href="[% loo.script_name %]?op=add_form&amp;cityid=[% loo.cityid %]">Edit</a></td>
-                       <td><a href="[% loo.script_name %]?op=delete_confirm&amp;cityid=[% loo.cityid %]">Delete</a></td>
-               </tr>
-               [% END %]
-       </table>[% END %]
+    [% IF cities %]
+        <table id="table_cities">
+            <thead>
+                <th>City ID</th>
+                <th>City</th>
+                <th>State</th>
+                <th>ZIP/Postal code</th>
+                <th>Country</th>
+                <th>&nbsp;</th>
+                <th>&nbsp;</th>
+            </thead>
+            <tbody>
+                [% FOREACH city IN cities %]
+                <tr>
+                    <td>[% city.cityid %]</td>
+                    <td>[% city.city_name %]</td>
+                    <td>[% city.city_state %]</td>
+                    <td>[% city.city_zipcode %]</td>
+                    <td>[% city.city_country %]</td>
+                    <td><a href="/cgi-bin/koha/admin/cities.pl?op=add_form&amp;cityid=[% city.cityid %]">Edit</a></td>
+                    <td><a href="/cgi-bin/koha/admin/cities.pl?op=delete_confirm&amp;cityid=[% city.cityid %]">Delete</a></td>
+                </tr>
+                [% END %]
+            </tbody>
+        </table>
+    [% ELSE %]
+        There is no city defined. <a href="/cgi-bin/koha/admin/cities.pl?op=add_form">Create a new city</a>.
+    [% END %]
 [% END %]
 
 </div>