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