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