3b33747ff3efc5d73ca9fe009bea33ea13cde7dd
[koha-equinox.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>Koha &rsaquo; Administration &rsaquo; [% IF op =='add_form' %]Cities &rsaquo; [% IF city.cityid %] Modify city[% ELSE %] New city[% END %][% ELSE %][% IF op == 'delete_confirm' %]Cities &rsaquo; Confirm deletion of city[% ELSE %] Cities[% END %][% END %]</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 </head>
8
9 <body id="admin_cities" class="admin">
10 [% INCLUDE 'header.inc' %]
11 [% INCLUDE 'cities-admin-search.inc' %]
12
13 <div id="breadcrumbs">
14     <a href="/cgi-bin/koha/mainpage.pl">Home</a>
15     &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
16     &rsaquo; <a href="/cgi-bin/koha/admin/cities.pl">Cities</a>
17     [% IF op == 'add_form' %]
18     &rsaquo; [% IF city.cityid %]Modify[% ELSE %]New[% END %] City
19     [% ELSIF op == 'delete_confirm' %]
20     &rsaquo; Confirm deletion of city
21     [% END %]
22 </div>
23
24 <div class="main container-fluid">
25     <div class="row">
26         <div class="col-sm-10 col-sm-push-2">
27             <main>
28
29 [% FOR m IN messages %]
30     <div class="dialog [% m.type | html %]">
31         [% SWITCH m.code %]
32         [% CASE 'error_on_update' %]
33             An error occurred when updating this city. Perhaps it already exists.
34         [% CASE 'error_on_insert' %]
35             An error occurred when adding this city. The city id might already exist.
36         [% CASE 'error_on_delete' %]
37             An error occurred when deleting this city. Check the logs.
38         [% CASE 'success_on_update' %]
39             City updated successfully.
40         [% CASE 'success_on_insert' %]
41             City added successfully.
42         [% CASE 'success_on_delete' %]
43             City deleted successfully.
44         [% CASE 'already_exists' %]
45             This city already exists.
46         [% CASE %]
47             [% m.code | html %]
48         [% END %]
49     </div>
50 [% END %]
51
52 [% IF op == 'add_form' %]
53     [% IF city %]
54         <h1>Modify a city</h1>
55     [% ELSE %]
56         <h1>New city</h1>
57     [% END %]
58
59     <form action="/cgi-bin/koha/admin/cities.pl" name="Aform" method="post" class="validated">
60         <input type="hidden" name="op" value="add_validate" />
61         <input type="hidden" name="cityid" value="[% city.cityid | html %]" />
62
63         <fieldset class="rows">
64             <ol>
65                 [% IF city %]
66                     <li><span class="label">City ID: </span>[% city.cityid | html %]</li>
67                 [% END %]
68                 <li>
69                     <label for="city_name" class="required">City: </label>
70                     <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>
71                 </li>
72                 <li>
73                     <label for="city_state">State: </label>
74                     <input type="text" name="city_state" id="city_state" size="80" maxlength="100" value="[% city.city_state | html %]" />
75                 </li>
76                 <li>
77                     <label for="city_zipcode" class="required">ZIP/Postal code: </label>
78                     <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>
79                 </li>
80                 <li>
81                     <label for="city_country">Country: </label>
82                     <input type="text" name="city_country" id="city_country" size="80" maxlength="100" value="[% city.city_country | html %]" />
83                 </li>
84             </ol>
85         </fieldset>
86
87         <fieldset class="action">
88             <input type="submit" value="Submit" />
89             <a class="cancel" href="/cgi-bin/koha/admin/cities.pl">Cancel</a>
90         </fieldset>
91     </form>
92 [% END %]
93
94 [% IF op == 'delete_confirm' %]
95     <div class="dialog alert">
96         <h3>Delete city "[% city.city_name | html %]?"</h3>
97         <table>
98             <tr><th>City id</th>
99                 <td>[% city.cityid | html %]</td>
100             </tr>
101             <tr><th>City</th>
102                 <td>[% city.city_name | html %]</td>
103             </tr>
104             <tr><th>State</th>
105                 <td>[% city.city_state | html %]</td>
106             </tr>
107             <tr><th>ZIP/Postal code</th>
108                 <td>[% city.city_zipcode | html %]</td>
109             </tr>
110             <tr><th>Country</th>
111                 <td>[% city.city_country | html %]</td>
112             </tr>
113         </table>
114         <form action="/cgi-bin/koha/admin/cities.pl" method="post">
115             <input type="hidden" name="op" value="delete_confirmed" />
116             <input type="hidden" name="cityid" value="[% city.cityid | html %]" />
117             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
118         </form>
119         <form action="/cgi-bin/koha/admin/cities.pl" method="get">
120             <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
121         </form>
122     </div>
123 [% END %]
124
125 [% IF op == 'list' %]
126
127     <div id="toolbar" class="btn-toolbar">
128         <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>
129     </div>
130
131     <h2>Cities</h2>
132     [% IF searchfield %]
133         Searching: [% searchfield | html %]
134     [% END %]
135
136     <table id="table_cities">
137         <thead>
138             <tr>
139                 <th>City ID</th>
140                 <th>City</th>
141                 <th>State</th>
142                 <th>ZIP/Postal code</th>
143                 <th>Country</th>
144                 <th>Actions</th>
145             </tr>
146         </thead>
147     </table>
148 [% END %]
149
150             </main>
151         </div> <!-- /.col-sm-10.col-sm-push-2 -->
152
153         <div class="col-sm-2 col-sm-pull-10">
154             <aside>
155                 [% INCLUDE 'admin-menu.inc' %]
156             </aside>
157         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
158      </div> <!-- /.row -->
159
160 [% MACRO jsinclude BLOCK %]
161     [% Asset.js("js/admin-menu.js") | $raw %]
162     [% INCLUDE 'datatables.inc' %]
163     <script>
164         $(document).ready(function() {
165             var cities_table_url = '/api/v1/cities';
166             var cities_table = $("#table_cities").api({
167                 "ajax": {
168                     "url": cities_table_url
169                 },
170                 'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
171                 "columns": [
172                     {
173                         "data": "city_id",
174                         "searchable": true,
175                         "orderable": true
176                     },
177                     {
178                         "data": "name",
179                         "searchable": true,
180                         "orderable": true
181                     },
182                     {
183                         "data": "state",
184                         "searchable": true,
185                         "orderable": true
186                     },
187                     {
188                         "data": "postal_code",
189                         "searchable": true,
190                         "orderable": true
191                     },
192                     {
193                         "data": "country",
194                         "searchable": true,
195                         "orderable": true
196                     },
197                     {
198                         "data": function( row, type, val, meta ) {
199
200                             var result = '<a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/cities.pl?op=add_form&amp;cityid='+ row.id +'"><i class="fa fa-pencil"></i> Edit</a>';
201                             result += '<a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/cities.pl?op=delete_confirm&amp;cityid='+ row.id +'"><i class="fa fa-trash"></i> Delete</a>';
202                             return result;
203
204                         },
205                         "searchable": false,
206                         "orderable": false
207                     }
208                 ]
209             });
210         });
211     </script>
212 [% END %]
213 [% INCLUDE 'intranet-bottom.inc' %]