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