Lines 69-203
Link Here
|
69 |
<div class="row"> |
69 |
<div class="row"> |
70 |
<div class="col-sm-10 col-sm-push-2"> |
70 |
<div class="col-sm-10 col-sm-push-2"> |
71 |
<main> |
71 |
<main> |
72 |
|
72 |
<div id="cities"></div> |
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> |
73 |
</main> |
202 |
</div> <!-- /.col-sm-10.col-sm-push-2 --> |
74 |
</div> <!-- /.col-sm-10.col-sm-push-2 --> |
203 |
|
75 |
|
Lines 213-221
Link Here
|
213 |
[% INCLUDE 'datatables.inc' %] |
85 |
[% INCLUDE 'datatables.inc' %] |
214 |
[% INCLUDE 'columns_settings.inc' %] |
86 |
[% INCLUDE 'columns_settings.inc' %] |
215 |
<script> |
87 |
<script> |
216 |
|
|
|
217 |
var columns_settings = [% TablesSettings.GetColumns( 'admin', 'cities', 'table_cities', 'json' ) | $raw %]; |
88 |
var columns_settings = [% TablesSettings.GetColumns( 'admin', 'cities', 'table_cities', 'json' ) | $raw %]; |
218 |
$(document).ready(function() { |
|
|
219 |
var cities_table_url = '/api/v1/cities?'; |
89 |
var cities_table_url = '/api/v1/cities?'; |
220 |
|
90 |
|
221 |
[% IF city_name_filter %] |
91 |
[% IF city_name_filter %] |
Lines 226-287
Link Here
|
226 |
}; |
96 |
}; |
227 |
cities_table_url += 'q='+ encodeURIComponent(JSON.stringify(city_name_filter)); |
97 |
cities_table_url += 'q='+ encodeURIComponent(JSON.stringify(city_name_filter)); |
228 |
[% END %] |
98 |
[% END %] |
229 |
|
|
|
230 |
var cities_table = $("#table_cities").kohaTable({ |
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&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&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> |
99 |
</script> |
|
|
100 |
[% Asset.js("js/vue/dist/main.js") %] |
101 |
[% Asset.js("js/vue/dist/runtime.js") %] |
102 |
|
286 |
[% END %] |
103 |
[% END %] |
287 |
[% INCLUDE 'intranet-bottom.inc' %] |
104 |
[% INCLUDE 'intranet-bottom.inc' %] |