Bug 27846: (follow-up) Add id back to breadcrumbs container
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / cities.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <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>
6 [% INCLUDE 'doc-head-close.inc' %]
7 </head>
8
9 <body id="admin_cities" class="admin">
10 [% INCLUDE 'header.inc' %]
11 [% INCLUDE 'cities-admin-search.inc' %]
12
13 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
14     <ol>
15         <li>
16             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
17         </li>
18         <li>
19             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
20         </li>
21
22         [% IF op == 'add_form' %]
23             <li>
24                 <a href="/cgi-bin/koha/admin/cities.pl">Cities</a>
25             </li>
26             <li>
27                 <a href="#" aria-current="page">
28                     [% IF city.cityid %]
29                         Modify
30                     [% ELSE %]
31                         New
32                     [% END %] City
33                 </a>
34             </li>
35
36         [% ELSIF op == 'delete_confirm' %]
37             <li>
38                 <a href="/cgi-bin/koha/admin/cities.pl">Cities</a>
39             </li>
40             <li>
41                 <a href="#" aria-current="page">
42                     Confirm deletion of city
43                 </a>
44             </li>
45
46         [% ELSE %]
47             <li>
48                 <a href="#" aria-current="page">
49                     Cities
50                 </a>
51             </li>
52         [% END %]
53     </ol>
54 </nav>
55
56 <div class="main container-fluid">
57     <div class="row">
58         <div class="col-sm-10 col-sm-push-2">
59             <main>
60
61 [% FOR m IN messages %]
62     <div class="dialog [% m.type | html %]">
63         [% SWITCH m.code %]
64         [% CASE 'error_on_update' %]
65             An error occurred when updating this city. Perhaps it already exists.
66         [% CASE 'error_on_insert' %]
67             An error occurred when adding this city. The city id might already exist.
68         [% CASE 'error_on_delete' %]
69             An error occurred when deleting this city. Check the logs.
70         [% CASE 'success_on_update' %]
71             City updated successfully.
72         [% CASE 'success_on_insert' %]
73             City added successfully.
74         [% CASE 'success_on_delete' %]
75             City deleted successfully.
76         [% CASE 'already_exists' %]
77             This city already exists.
78         [% CASE %]
79             [% m.code | html %]
80         [% END %]
81     </div>
82 [% END %]
83
84 [% IF op == 'add_form' %]
85     [% IF city %]
86         <h1>Modify a city</h1>
87     [% ELSE %]
88         <h1>New city</h1>
89     [% END %]
90
91     <form action="/cgi-bin/koha/admin/cities.pl" name="Aform" method="post" class="validated">
92         <input type="hidden" name="op" value="add_validate" />
93         <input type="hidden" name="cityid" value="[% city.cityid | html %]" />
94
95         <fieldset class="rows">
96             <ol>
97                 [% IF city %]
98                     <li><span class="label">City ID: </span>[% city.cityid | html %]</li>
99                 [% END %]
100                 <li>
101                     <label for="city_name" class="required">City: </label>
102                     <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>
103                 </li>
104                 <li>
105                     <label for="city_state">State: </label>
106                     <input type="text" name="city_state" id="city_state" size="80" maxlength="100" value="[% city.city_state | html %]" />
107                 </li>
108                 <li>
109                     <label for="city_zipcode" class="required">ZIP/Postal code: </label>
110                     <input type="text" name="city_zipcode" id="city_zipcode" size="20" maxlength="20" value="[% city.city_zipcode | html %]" required="required" class="required" /> <span class="required">Required</span>
111                 </li>
112                 <li>
113                     <label for="city_country">Country: </label>
114                     <input type="text" name="city_country" id="city_country" size="80" maxlength="100" value="[% city.city_country | html %]" />
115                 </li>
116             </ol>
117         </fieldset>
118
119         <fieldset class="action">
120             <input type="submit" value="Submit" />
121             <a class="cancel" href="/cgi-bin/koha/admin/cities.pl">Cancel</a>
122         </fieldset>
123     </form>
124 [% END %]
125
126 [% IF op == 'delete_confirm' %]
127     <div class="dialog alert">
128         <h3>Delete city "[% city.city_name | html %]?"</h3>
129         <table>
130             <tr><th>City id</th>
131                 <td>[% city.cityid | html %]</td>
132             </tr>
133             <tr><th>City</th>
134                 <td>[% city.city_name | html %]</td>
135             </tr>
136             <tr><th>State</th>
137                 <td>[% city.city_state | html %]</td>
138             </tr>
139             <tr><th>ZIP/Postal code</th>
140                 <td>[% city.city_zipcode | html %]</td>
141             </tr>
142             <tr><th>Country</th>
143                 <td>[% city.city_country | html %]</td>
144             </tr>
145         </table>
146         <form action="/cgi-bin/koha/admin/cities.pl" method="post">
147             <input type="hidden" name="op" value="delete_confirmed" />
148             <input type="hidden" name="cityid" value="[% city.cityid | html %]" />
149             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
150         </form>
151         <form action="/cgi-bin/koha/admin/cities.pl" method="get">
152             <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
153         </form>
154     </div>
155 [% END %]
156
157 [% IF op == 'list' %]
158
159     <div id="toolbar" class="btn-toolbar">
160         <a class="btn btn-default" id="newcity" href="/cgi-bin/koha/admin/cities.pl?op=add_form"><i class="fa fa-plus"></i> New city</a>
161     </div>
162
163     <h2>Cities</h2>
164     [% IF city_name_filter %]
165         Searching: [% city_name_filter | html %]
166     [% END %]
167
168     [% IF cities_count > 0 %]
169         <div class="table_cities_table_controls"></div>
170         <table id="table_cities">
171             <thead>
172                 <tr>
173                     <th>City ID</th>
174                     <th>City</th>
175                     <th>State</th>
176                     <th>ZIP/Postal code</th>
177                     <th>Country</th>
178                     <th data-class-name="actions noExport">Actions</th>
179                 </tr>
180             </thead>
181         </table>
182     [% ELSE %]
183         <div class="dialog message">
184             There are no cities defined. <a href="/cgi-bin/koha/admin/cities.pl?op=add_form">Create a new city</a>.
185         </div>
186     [% END %]
187 [% END %]
188
189             </main>
190         </div> <!-- /.col-sm-10.col-sm-push-2 -->
191
192         <div class="col-sm-2 col-sm-pull-10">
193             <aside>
194                 [% INCLUDE 'admin-menu.inc' %]
195             </aside>
196         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
197      </div> <!-- /.row -->
198
199 [% MACRO jsinclude BLOCK %]
200     [% Asset.js("js/admin-menu.js") | $raw %]
201     [% INCLUDE 'datatables.inc' %]
202     <script>
203
204         $(document).ready(function() {
205             var cities_table_url = '/api/v1/cities?';
206
207         [% IF city_name_filter %]
208             var city_name_filter = {
209                 'name': {
210                     "like": '%[%- city_name_filter | html -%]%'
211                 }
212             };
213             cities_table_url += 'q='+ encodeURIComponent(JSON.stringify(city_name_filter));
214         [% END %]
215
216             var cities_table = $("#table_cities").api({
217                 "ajax": {
218                     "url": cities_table_url
219                 },
220                 "order": [[ 1, "asc" ]],
221                 "columnDefs": [ {
222                     "targets": [0,1,2,3,4],
223                     "render": function (data, type, row, meta) {
224                         if ( type == 'display' ) {
225                             return data.escapeHtml();
226                         }
227                         return data;
228                     }
229                 } ],
230                 "columns": [
231                     {
232                         "data": "city_id",
233                         "searchable": true,
234                         "orderable": true
235                     },
236                     {
237                         "data": "name",
238                         "searchable": true,
239                         "orderable": true
240                     },
241                     {
242                         "data": "state",
243                         "searchable": true,
244                         "orderable": true
245                     },
246                     {
247                         "data": "postal_code",
248                         "searchable": true,
249                         "orderable": true
250                     },
251                     {
252                         "data": "country",
253                         "searchable": true,
254                         "orderable": true
255                     },
256                     {
257                         "data": function( row, type, val, meta ) {
258
259                             var result = '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/cities.pl?op=add_form&amp;cityid='+ encodeURIComponent(row.city_id) +'"><i class="fa fa-pencil" aria-hidden="true"></i> '+_("Edit")+'</a>'+"\n";
260                             result += '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/cities.pl?op=delete_confirm&amp;cityid='+ encodeURIComponent(row.city_id) +'"><i class="fa fa-trash" aria-hidden="true"></i> '+_("Delete")+'</a>';
261                             return result;
262
263                         },
264                         "searchable": false,
265                         "orderable": false
266                     }
267                 ]
268             }, [], 1);
269
270         });
271     </script>
272 [% END %]
273 [% INCLUDE 'intranet-bottom.inc' %]