custom_field_form.tpl
17.4 KB
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
<?php echo $header; ?><?php echo $column_left; ?>
<div id="content">
<div class="page-header">
<div class="container-fluid">
<div class="pull-right">
<button type="submit" form="form-custom-field" data-toggle="tooltip" title="<?php echo $button_save; ?>" class="btn btn-primary"><i class="fa fa-save"></i></button>
<a href="<?php echo $cancel; ?>" data-toggle="tooltip" title="<?php echo $button_cancel; ?>" class="btn btn-default"><i class="fa fa-reply"></i></a></div>
<h1><?php echo $heading_title; ?></h1>
<ul class="breadcrumb">
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
<?php } ?>
</ul>
</div>
</div>
<div class="container-fluid">
<?php if ($error_warning) { ?>
<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?>
<button type="button" class="close" data-dismiss="alert">×</button>
</div>
<?php } ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-pencil"></i> <?php echo $text_form; ?></h3>
</div>
<div class="panel-body">
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-custom-field" class="form-horizontal">
<div class="form-group required">
<label class="col-sm-2 control-label"><?php echo $entry_name; ?></label>
<div class="col-sm-10">
<?php foreach ($languages as $language) { ?>
<div class="input-group"><span class="input-group-addon"><img src="language/<?php echo $language['code']; ?>/<?php echo $language['code']; ?>.png" title="<?php echo $language['name']; ?>" /></span>
<input type="text" name="custom_field_description[<?php echo $language['language_id']; ?>][name]" value="<?php echo isset($custom_field_description[$language['language_id']]) ? $custom_field_description[$language['language_id']]['name'] : ''; ?>" placeholder="<?php echo $entry_name; ?>" class="form-control" />
</div>
<?php if (isset($error_name[$language['language_id']])) { ?>
<div class="text-danger"><?php echo $error_name[$language['language_id']]; ?></div>
<?php } ?>
<?php } ?>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="input-location"><?php echo $entry_location; ?></label>
<div class="col-sm-10">
<select name="location" id="input-location" class="form-control">
<?php if ($location == 'account') { ?>
<option value="account" selected="selected"><?php echo $text_account; ?></option>
<?php } else { ?>
<option value="account"><?php echo $text_account; ?></option>
<?php } ?>
<?php if ($location == 'address') { ?>
<option value="address" selected="selected"><?php echo $text_address; ?></option>
<?php } else { ?>
<option value="address"><?php echo $text_address; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="input-type"><?php echo $entry_type; ?></label>
<div class="col-sm-10">
<select name="type" id="input-type" class="form-control">
<optgroup label="<?php echo $text_choose; ?>">
<?php if ($type == 'select') { ?>
<option value="select" selected="selected"><?php echo $text_select; ?></option>
<?php } else { ?>
<option value="select"><?php echo $text_select; ?></option>
<?php } ?>
<?php if ($type == 'radio') { ?>
<option value="radio" selected="selected"><?php echo $text_radio; ?></option>
<?php } else { ?>
<option value="radio"><?php echo $text_radio; ?></option>
<?php } ?>
<?php if ($type == 'checkbox') { ?>
<option value="checkbox" selected="selected"><?php echo $text_checkbox; ?></option>
<?php } else { ?>
<option value="checkbox"><?php echo $text_checkbox; ?></option>
<?php } ?>
</optgroup>
<optgroup label="<?php echo $text_input; ?>">
<?php if ($type == 'text') { ?>
<option value="text" selected="selected"><?php echo $text_text; ?></option>
<?php } else { ?>
<option value="text"><?php echo $text_text; ?></option>
<?php } ?>
<?php if ($type == 'textarea') { ?>
<option value="textarea" selected="selected"><?php echo $text_textarea; ?></option>
<?php } else { ?>
<option value="textarea"><?php echo $text_textarea; ?></option>
<?php } ?>
</optgroup>
<optgroup label="<?php echo $text_file; ?>">
<?php if ($type == 'file') { ?>
<option value="file" selected="selected"><?php echo $text_file; ?></option>
<?php } else { ?>
<option value="file"><?php echo $text_file; ?></option>
<?php } ?>
</optgroup>
<optgroup label="<?php echo $text_date; ?>">
<?php if ($type == 'date') { ?>
<option value="date" selected="selected"><?php echo $text_date; ?></option>
<?php } else { ?>
<option value="date"><?php echo $text_date; ?></option>
<?php } ?>
<?php if ($type == 'time') { ?>
<option value="time" selected="selected"><?php echo $text_time; ?></option>
<?php } else { ?>
<option value="time"><?php echo $text_time; ?></option>
<?php } ?>
<?php if ($type == 'datetime') { ?>
<option value="datetime" selected="selected"><?php echo $text_datetime; ?></option>
<?php } else { ?>
<option value="datetime"><?php echo $text_datetime; ?></option>
<?php } ?>
</optgroup>
</select>
</div>
</div>
<div class="form-group" id="display-value">
<label class="col-sm-2 control-label" for="input-value"><?php echo $entry_value; ?></label>
<div class="col-sm-10">
<input type="text" name="value" value="<?php echo $value; ?>" placeholder="<?php echo $entry_value; ?>" id="input-value" class="form-control" />
</div>
</div>
<div class="form-group" id="display-validation">
<label class="col-sm-2 control-label" for="input-validation"><span data-toggle="tooltip" title="<?php echo $help_regex ?>"><?php echo $entry_validation ?></span></label>
<div class="col-sm-10">
<input type="text" name="validation" id="input-validation" value="<?php echo $validation ?>" placeholder="<?php echo $text_regex ?>" class="form-control"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><?php echo $entry_customer_group; ?></label>
<div class="col-sm-10">
<?php $customer_group_row = 0; ?>
<?php foreach ($customer_groups as $customer_group) { ?>
<div class="checkbox">
<label>
<?php if (in_array($customer_group['customer_group_id'], $custom_field_customer_group)) { ?>
<input type="checkbox" name="custom_field_customer_group[<?php echo $customer_group_row; ?>][customer_group_id]" value="<?php echo $customer_group['customer_group_id']; ?>" checked="checked" />
<?php echo $customer_group['name']; ?>
<?php } else { ?>
<input type="checkbox" name="custom_field_customer_group[<?php echo $customer_group_row; ?>][customer_group_id]" value="<?php echo $customer_group['customer_group_id']; ?>" />
<?php echo $customer_group['name']; ?>
<?php } ?>
</label>
</div>
<?php $customer_group_row++; ?>
<?php } ?>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><?php echo $entry_required; ?></label>
<div class="col-sm-10">
<?php $customer_group_row = 0; ?>
<?php foreach ($customer_groups as $customer_group) { ?>
<div class="checkbox">
<label>
<?php if (in_array($customer_group['customer_group_id'], $custom_field_required)) { ?>
<input type="checkbox" name="custom_field_customer_group[<?php echo $customer_group_row; ?>][required]" value="<?php echo $customer_group['customer_group_id']; ?>" checked="checked" />
<?php echo $customer_group['name']; ?>
<?php } else { ?>
<input type="checkbox" name="custom_field_customer_group[<?php echo $customer_group_row; ?>][required]" value="<?php echo $customer_group['customer_group_id']; ?>" />
<?php echo $customer_group['name']; ?>
<?php } ?>
</label>
</div>
<?php $customer_group_row++; ?>
<?php } ?>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="input-status"><?php echo $entry_status; ?></label>
<div class="col-sm-10">
<select name="status" id="input-status" class="form-control">
<?php if ($status) { ?>
<option value="1" selected="selected"><?php echo $text_enabled; ?></option>
<option value="0"><?php echo $text_disabled; ?></option>
<?php } else { ?>
<option value="1"><?php echo $text_enabled; ?></option>
<option value="0" selected="selected"><?php echo $text_disabled; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="input-sort-order"><span data-toggle="tooltip" title="<?php echo $help_sort_order; ?>"><?php echo $entry_sort_order; ?></span></label>
<div class="col-sm-10">
<input type="text" name="sort_order" value="<?php echo $sort_order; ?>" placeholder="<?php echo $entry_sort_order; ?>" id="input-sort-order" class="form-control" />
</div>
</div>
<table id="custom-field-value" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<td class="text-left required"><?php echo $entry_custom_value; ?></td>
<td class="text-right"><?php echo $entry_sort_order; ?></td>
<td></td>
</tr>
</thead>
<tbody>
<?php $custom_field_value_row = 0; ?>
<?php foreach ($custom_field_values as $custom_field_value) { ?>
<tr id="custom-field-value-row<?php echo $custom_field_value_row; ?>">
<td class="text-left" style="width: 70%;"><input type="hidden" name="custom_field_value[<?php echo $custom_field_value_row; ?>][custom_field_value_id]" value="<?php echo $custom_field_value['custom_field_value_id']; ?>" />
<?php foreach ($languages as $language) { ?>
<div class="input-group"> <span class="input-group-addon"><img src="language/<?php echo $language['code']; ?>/<?php echo $language['code']; ?>.png" title="<?php echo $language['name']; ?>" /></span>
<input type="text" name="custom_field_value[<?php echo $custom_field_value_row; ?>][custom_field_value_description][<?php echo $language['language_id']; ?>][name]" value="<?php echo isset($custom_field_value['custom_field_value_description'][$language['language_id']]) ? $custom_field_value['custom_field_value_description'][$language['language_id']]['name'] : ''; ?>" placeholder="<?php echo $entry_custom_value; ?>" class="form-control" />
</div>
<?php if (isset($error_custom_field_value[$custom_field_value_row][$language['language_id']])) { ?>
<div class="text-danger"><?php echo $error_custom_field_value[$custom_field_value_row][$language['language_id']]; ?></div>
<?php } ?>
<?php } ?></td>
<td class="text-right"><input type="text" name="custom_field_value[<?php echo $custom_field_value_row; ?>][sort_order]" value="<?php echo $custom_field_value['sort_order']; ?>" placeholder="<?php echo $entry_sort_order; ?>" class="form-control" /></td>
<td class="text-left"><button onclick="$('#custom-field-value-row<?php echo $custom_field_value_row; ?>').remove();" data-toggle="tooltip" title="<?php echo $button_remove; ?>" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>
</tr>
<?php $custom_field_value_row++; ?>
<?php } ?>
</tbody>
<tfoot>
<tr>
<td colspan="2"></td>
<td class="text-left"><button type="button" onclick="addCustomFieldValue();" data-toggle="tooltip" title="<?php echo $button_custom_field_value_add; ?>" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></td>
</tr>
</tfoot>
</table>
</form>
</div>
</div>
</div>
<script type="text/javascript"><!--
$('select[name=\'type\']').on('change', function() {
if (this.value == 'select' || this.value == 'radio' || this.value == 'checkbox') {
$('#custom-field-value').show();
$('#display-value, #display-validation').hide();
} else {
$('#custom-field-value').hide();
$('#display-value, #display-validation').show();
}
if (this.value == 'date') {
$('#display-value > div').html('<div class="input-group date"><input type="text" name="value" value="' + $('#input-value').val() + '" placeholder="<?php echo $entry_value; ?>" data-date-format="YYYY-MM-DD" id="input-value" class="form-control" /><span class="input-group-btn"><button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button></span></div>');
} else if (this.value == 'time') {
$('#display-value > div').html('<div class="input-group time"><input type="text" name="value" value="' + $('#input-value').val() + '" placeholder="<?php echo $entry_value; ?>" data-date-format="HH:mm" id="input-value" class="form-control" /><span class="input-group-btn"><button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button></span></div>');
} else if (this.value == 'datetime') {
$('#display-value > div').html('<div class="input-group datetime"><input type="text" name="value" value="' + $('#input-value').val() + '" placeholder="<?php echo $entry_value; ?>" data-date-format="YYYY-MM-DD HH:mm" id="input-value" class="form-control" /><span class="input-group-btn"><button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button></span></div>');
} else if (this.value == 'textarea') {
$('#display-value > div').html('<textarea name="value" placeholder="<?php echo $entry_value; ?>" id="input-value" class="form-control">' + $('#input-value').val() + '</textarea>');
} else {
$('#display-value > div').html('<input type="text" name="value" value="' + $('#input-value').val() + '" placeholder="<?php echo $entry_value; ?>" id="input-value" class="form-control" />');
}
$('.date').datetimepicker({
pickTime: false
});
$('.time').datetimepicker({
pickDate: false
});
$('.datetime').datetimepicker({
pickDate: true,
pickTime: true
});
});
$('select[name=\'type\']').trigger('change');
var custom_field_value_row = <?php echo $custom_field_value_row; ?>;
function addCustomFieldValue() {
html = '<tr id="custom-field-value-row' + custom_field_value_row + '">';
html += ' <td class="text-left" style="width: 70%;"><input type="hidden" name="custom_field_value[' + custom_field_value_row + '][custom_field_value_id]" value="" />';
<?php foreach ($languages as $language) { ?>
html += ' <div class="input-group">';
html += ' <span class="input-group-addon"><img src="language/<?php echo $language['code']; ?>/<?php echo $language['code']; ?>.png" title="<?php echo $language['name']; ?>" /></span><input type="text" name="custom_field_value[' + custom_field_value_row + '][custom_field_value_description][<?php echo $language['language_id']; ?>][name]" value="" placeholder="<?php echo $entry_custom_value; ?>" class="form-control" />';
html += ' </div>';
<?php } ?>
html += ' </td>';
html += ' <td class="text-right"><input type="text" name="custom_field_value[' + custom_field_value_row + '][sort_order]" value="" placeholder="<?php echo $entry_sort_order; ?>" class="form-control" /></td>';
html += ' <td class="text-left"><button type="button" onclick="$(\'#custom-field-value-row' + custom_field_value_row + '\').remove();" data-toggle="tooltip" title="<?php echo $button_remove; ?>" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>';
html += '</tr>';
$('#custom-field-value tbody').append(html);
custom_field_value_row++;
}
//--></script></div>
<?php echo $footer; ?>