-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcountries.html
300 lines (235 loc) · 14.9 KB
/
countries.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
{extends file="admin-layout.tpl"}
{block name="no-return-functions"}
{$admin_current_location = 'configuration'}
{/block}
{block name="page-title"}{intl l='Countries'}{/block}
{block name="check-resource"}admin.configuration.country{/block}
{block name="check-access"}view{/block}
{block name="main-content"}
<div class="countries">
<div id="wrapper" class="container">
<ul class="breadcrumb">
<li><a href="{url path='/admin/home'}">{intl l="Home"}</a></li>
<li><a href="{url path='/admin/configuration'}">{intl l="Configuration"}</a></li>
<li><a href="{url path='/admin/configuration/countries'}">{intl l="Countries"}</a></li>
</ul>
{hook name="countries.top" location="countries_top" }
<div class="row">
<div class="col-md-12">
<form action="" method="post">
<div class="general-block-decorator">
{ifloop rel="country-not-in-any-zone"}
<div class="row">
<div class="col-md-12">
<div class="alert alert-warning">
{intl l='<strong>Warning</strong>, some of your countries are not included in any shipping zone:'}
{loop name="country-not-in-any-zone" type="country" with_area=false}
{$TITLE}{if $LOOP_COUNT < $LOOP_TOTAL},{else}.{/if}
{/loop}
</div>
</div>
</div>
{/ifloop}
<div class="table-responsive">
<table class="table table-striped table-condensed">
<caption class="clearfix">
{intl l='Countries'}
{loop type="auth" name="can_create" role="ADMIN" resource="admin.configuration.country" access="CREATE"}
<a class="btn btn-primary action-btn" title="{intl l='Add a new country'}" href="#add_country_dialog" data-toggle="modal">
<span class="glyphicon glyphicon-plus-sign"></span>
</a>
{/loop}
</caption>
<thead>
<tr>
<th>{intl l="ID"}</th>
<th>{intl l="Name"}</th>
<th>{intl l="Default"}</th>
<th>{intl l="N° ISO"}</th>
<th>{intl l="ISO Code"}</th>
<th>{intl l="Shipping zone"}</th>
<th>{intl l="Visible"}</th>
{hook name="countries.table-header" location="countries_table_header" }
<th class="actions">{intl l='Actions'}</th>
</tr>
</thead>
<tbody>
{loop name="countries" type="country" backend_context="1" lang=$lang_id order=$order visible="*"}
<tr>
<td>{$ID}</td>
<td><a href="{url path="/admin/configuration/country/update/%id" id=$ID}">{$TITLE}</a></td>
<td>
<div class="make-switch switch-small switch-radio change-default-toggle" data-id="{$ID}" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input class="change-default-toggle" type="radio" name="by_default" value="{$ID}" {if $IS_DEFAULT}checked="checked"{/if}/>
</div>
</td>
<td>{$ISOCODE}</td>
<td>{$ISOALPHA3}</td>
<td>
{loop type="area" name="country-area" country={$ID}}
<a href="{url path="/admin/configuration/shipping_configuration/update/%id" id=$ID}">{$NAME}</a>{if $LOOP_COUNT < $LOOP_TOTAL},{/if}
{/loop}
{elseloop rel="country-area"}
<span class="text-warning"><i class="glyphicon glyphicon-warning-sign"></i> {intl l='None'}</span>
{/elseloop}
</td>
<td class="text-center">
{loop type="auth" name="can_change" role="ADMIN" resource="admin.country" access="UPDATE"}
<div class="make-switch switch-small visibleToggle" data-id="{$ID}" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input type="checkbox" class="visibleToggle" {if $VISIBLE == 1}checked="checked"{/if}>
</div>
{/loop}
{elseloop rel="can_change"}
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input type="checkbox" class="disabled" disabled="disabled" {if $VISIBLE == 1}checked="checked"{/if}>
</div>
{/elseloop}
</td>
{hook name="countries.table-row" location="countries_table_row" country_id={$ID} }
<td class="actions">
<div class="btn-toolbar btn toolbar-primary">
<span class="glyphicon glyphicon-cog"></span>
</div>
<div class="toolbar-options hidden">
{loop type="auth" name="can_change" role="ADMIN" resource="admin.configuration.country" access="UPDATE"}
<a class="country-change" title="{intl l='Change this country'}" href="{url path="/admin/configuration/country/update/%id" id=$ID}">
<span class="glyphicon glyphicon-edit"></span>
</a>
{/loop}
{loop type="auth" name="can_delete" role="ADMIN" resource="admin.configuration.country" access="DELETE"}
<a class="country-delete" title="{intl l='Delete this country'}" href="#delete_dialog" data-id="{$ID}" data-toggle="modal">
<span class="glyphicon glyphicon-trash"></span>
</a>
{/loop}
</div>
</td>
</tr>
{/loop}
{elseloop rel="countries"}
<tr>
<td colspan="8">
<div class="alert alert-info">
{intl l="No country has been created yet. Click the + button to create one."}
</div>
</td>
</tr>
{/elseloop}
</tbody>
</table>
</div>
</div>
</form>
</div>
</div>
{hook name="countries.bottom" location="countries_bottom" }
</div>
</div>
{* Adding a new Country *}
{form name="thelia.admin.country.creation"}
{* Capture the dialog body, to pass it to the generic dialog *}
{capture "country_creation_dialog"}
{form_hidden_fields exclude="locale"}
{* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *}
{render_form_field field='success_url' value="{url path='/admin/configuration/country/update/_ID_'}"}
{custom_render_form_field field="title"}
{loop type="lang" name="default-lang" default_only="1"}
{* Switch edition to the current locale *}
<input type="hidden" name="edit_language_id" value="{$ID}" />
{render_form_field field="locale" value=$LOCALE}
<div class="input-group">
<input type="text" {form_field_attributes field="title"}>
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$CODE}.png"}" alt="{$TITLE}" /></span>
</div>
{/loop}
{/custom_render_form_field}
{render_form_field field="isocode"}
{render_form_field field="isoalpha2"}
{render_form_field field="isoalpha3"}
{custom_render_form_field field="visible"}
<input type="checkbox" checked {form_field_attributes field="visible"}> {$label}
{/custom_render_form_field}
{custom_render_form_field field="has_states"}
<input type="checkbox" {form_field_attributes field="has_states"}> {$label}
{/custom_render_form_field}
{hook name="country.create-form" location="country_create_form" }
{/capture}
{include
file = "includes/generic-create-dialog.html"
dialog_id = "add_country_dialog"
dialog_title = {intl l="Create a new country"}
dialog_body = {$smarty.capture.country_creation_dialog nofilter}
dialog_ok_label = {intl l="Create this country"}
dialog_cancel_label = {intl l="Cancel"}
form_action = {url path='/admin/configuration/countries/create'}
form_enctype = {form_enctype}
form_error_message = $form_error_message
}
{/form}
{* Delete confirmation dialog *}
{capture "delete_dialog"}
<input type="hidden" name="country_id" id="country_delete_id" value="" />
{hook name="country.delete-form" location="country_delete_form" }
{/capture}
{include
file = "includes/generic-confirm-dialog.html"
dialog_id = "delete_dialog"
dialog_title = {intl l="Delete country"}
dialog_message = {intl l="Do you really want to delete this country ?"}
form_action = {token_url path='/admin/configuration/countries/delete'}
form_content = {$smarty.capture.delete_dialog nofilter}
}
<div class="modal fade" id="toggle-default-failed" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content alert alert-block alert-danger ">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h2>{intl l="Error"}</h2>
</div>
<div class="modal-body">
<strong>{intl l="Impossible to change default country. Please contact your administrator or try later"}</strong>
</div>
</div>
</div>
</div>
{/block}
{block name="javascript-initialization"}
{javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'}
<script src="{$asset_url}"></script>
<script>
$(document).ready(function(){
// Toogle switch on input radio
$('.switch-radio').on('switch-change', function () {
$('.switch-radio').bootstrapSwitch('toggleRadioState');
});
$('.country-delete').click(function(ev){
$('#country_delete_id').val($(this).data('id'));
});
$('.change-default-toggle').on('switch-change', function(e, data){
if(data.value) {
$.ajax({
url : "{url path='/admin/configuration/country/toggleDefault'}",
data : {
country_id: $(this).data('id')
}
}).fail(function(){
$('#toggle-default-failed').modal('show');
});
}
});
{* Visibility toggle *}
$(".visibleToggle").on('switch-change', function(event, data) {
$.ajax({
url : "{url path='admin/configuration/country/toggle-online'}",
data : {
country_id : $(this).data('id'),
action : 'visibilityToggle'
}
});
});
});
</script>
{/javascripts}
{/block}
{block name="javascript-last-call"}
{hook name="countries.js" location="countries-js" }
{/block}