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