forked from WWBN/AVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
userPersonalInfo.php
251 lines (224 loc) · 10.5 KB
/
userPersonalInfo.php
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
<form class="form-compact well form-horizontal" id="updateUserFormPersonal" onsubmit="">
<?php
if (!empty($advancedCustomUser->disablePersonalInfo)) {
return false;
}
require_once $global['systemRootPath'] . 'plugin/User_Location/Objects/IP2Location.php';
$text = "-- " . __('Select one Option') . " --";
$myCountry = $user->getCountry();
$myRegion = $user->getRegion();
$myCity = $user->getCity();
?>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo __("First Name"); ?></label>
<div class="col-md-8 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
<input name="first_name" id="first_name" placeholder="<?php echo __("Last Name"); ?>" class="form-control" type="text" value="<?php echo $user->getFirst_name(); ?>" >
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo __("Last Name"); ?></label>
<div class="col-md-8 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
<input name="last_name" id="last_name" placeholder="<?php echo __("Last Name"); ?>" class="form-control" type="text" value="<?php echo $user->getLast_name(); ?>" >
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo __("Address"); ?></label>
<div class="col-md-8 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
<input name="address" id="address" placeholder="<?php echo __("Address"); ?>" class="form-control" type="text" value="<?php echo $user->getAddress(); ?>" >
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo __("Zip Code"); ?></label>
<div class="col-md-8 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
<input name="zip_code" id="zip_code" placeholder="<?php echo __("Zip Code"); ?>" class="form-control" type="text" value="<?php echo $user->getZip_code(); ?>" >
</div>
</div>
</div>
<?php
$countries = IP2Location::getCountries();
?>
<div class="form-group">
<label for="status" class="col-md-4 control-label"><?php echo __("Country"); ?>:</label>
<div class="col-md-8 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
<select class="form-control input-sm" name="country" id="country">
<option><?php echo $text; ?></option>
<?php
foreach ($countries as $key => $value) {
$selected = "";
if ($myCountry === $value) {
$selected = 'selected';
}
echo '<option ' . $selected . '>' . $value . '</option>';
}
?>
</select>
</div>
</div>
</div>
<div class="form-group">
<label for="status" class="col-md-4 control-label"><?php echo __("Region"); ?>:</label>
<div class="col-md-8 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
<select class="form-control input-sm" name="region" id="region">
<option><?php echo $text; ?></option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label for="status" class="col-md-4 control-label"><?php echo __("City"); ?>:</label>
<div class="col-md-8 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
<select class="form-control input-sm" name="city" id="city">
<option><?php echo $text; ?></option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-12 ">
<div id="documentImage"></div>
<center>
<a id="upload-btnDocument" class="btn btn-success"><i class="fa fa-upload"></i> <?php echo __("Upload a Document Image"); ?></a>
</center>
</div>
<input type="file" name="uploadDocument" id="uploadDocument" value="Choose a file" accept="image/*" style="display: none;" />
</div>
<!-- Button -->
<div class="form-group">
<hr>
<div class="col-md-12">
<center>
<button type="submit" class="btn btn-primary btn-block btn-lg">
<span class="fa fa-save"></span> <?php echo __("Save"); ?>
</button>
</center>
</div>
</div>
<script>
var uploadCropDocument;
function savePersonalInfo() {
$('#aPersonalInfo').tab('show');
modal.showPleaseWait();
setTimeout(function () {
savePersonalInfoAjax();
}, 1000);
}
function savePersonalInfoAjax() {
uploadCropDocument.croppie('result', {
type: 'canvas',
size: 'viewport'
}).then(function (resp) {
$.ajax({
type: "POST",
url: "<?php echo $global['webSiteRootURL']; ?>objects/userUpdatePersonal.json.php",
data: {
imgBase64: resp,
first_name: $('#first_name').val(),
last_name: $('#last_name').val(),
address: $('#address').val(),
zip_code: $('#zip_code').val(),
country: $('#country').val(),
region: $('#region').val(),
city: $('#city').val()
}
}).done(function (o) {
modal.hidePleaseWait();
});
});
}
$(document).ready(function () {
$('#uploadDocument').on('change', function () {
readFile(this, uploadCropDocument);
});
$('#upload-btnDocument').on('click', function (ev) {
$('#uploadDocument').trigger("click");
});
$('#updateUserFormPersonal').submit(function (evt) {
evt.preventDefault();
savePersonalInfo();
});
uploadCropDocument = $('#documentImage').croppie({
url: '<?php echo $global['webSiteRootURL']; ?>objects/userDocument.png.php?users_id=<?php echo User::getId(); ?>',
enableExif: true,
enforceBoundary: false,
mouseWheelZoom: false,
viewport: {
width: 640,
height: 450
},
boundary: {
width: 640,
height: 450
}
});
$("#country").on("change", function (e) {
//modal.showPleaseWait();
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>plugin/User_Location/regions.json.php?country=' + $('#country').val(),
success: function (response) {
$('#region').empty();
$('#region').append($("<option></option>").text('<?php echo $text; ?>'));
$('#city').empty();
$('#city').append($("<option></option>").text('<?php echo $text; ?>'));
var found = false;
$.each(response, function (key, value) {
var selected = '';
if (value === '<?php echo $myRegion; ?>') {
selected = 'selected';
found = true;
}
$('#region').append($("<option " + selected + "></option>").attr("value", value).text(value));
});
//modal.hidePleaseWait();
if (found) {
$("#region").trigger('change');
}
}
});
});
$("#region").on("change", function (e) {
//modal.showPleaseWait();
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>plugin/User_Location/cities.json.php?country=' + $('#country').val() + '®ion=' + $('#region').val(),
success: function (response) {
$('#city').empty();
$('#city').append($("<option></option>").text('<?php echo $text; ?>'));
$.each(response, function (key, value) {
var selected = '';
if (value === '<?php echo $myCity; ?>') {
selected = 'selected';
}
$('#city').append($("<option " + selected + "></option>").attr("value", value).text(value));
});
//modal.hidePleaseWait();
}
});
});
<?php
if (!empty($myCountry)) {
?>
setTimeout(function () {
$("#country").trigger('change');
}, 1000);
<?php
}
?>
});
</script>
</form>