-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.php
280 lines (276 loc) · 13 KB
/
profile.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
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
<?php
require __DIR__ . '/vendor/autoload.php';
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
use App\Auth;
use App\Database;
$db = new Database();
$jsonData = file_get_contents(config("app.root") . 'assets/data/bangladesh.json');
$data = json_decode($jsonData, true);
$divisions = $data['divisions'];
$userId = $_SESSION['user']['id'];
$data = Auth::getUserById($userId);
$profile = Auth::getProfile($userId);
$pageName = "Edit Profile < {$data['first_name']} {$data['last_name']}";
$pageGroup = "User Profile";
$currentPage = "Profile";
require __DIR__ . '/components/header.php';
?>
<body>
<?php require __DIR__ . "/components/sidebar/customer.php" ?>
<main id="content" class="bg-body-tertiary" >
<?php require __DIR__ . "/components/navbar/customer.php" ?>
<?php require __DIR__ . "/components/breadcrumb/customer/primary.php" ?>
<!-- YOUR CONTENT STARTS FROM HERE -->
<section class="container-fluid my-5">
<form action="<?= config("app.root") ?>src/actions/users/update.php" method="post" enctype="multipart/form-data">
<div class="row row-cols-3 row-cols-lg-5 g-3 g-lg-3">
<div class="col-12 col-sm-12 col-md-12 col-lg-5 col-xl-4 col-xxl-4">
<div class="card shadow">
<div class="card-header bg-success py-1">
<h5 class="card-title text-light py-0 my-0">Edit Profile</h5>
</div>
<div class="card-body pt-0">
<input type="hidden" name="user" value="<?= isset($data['id']) ? $data['id'] : " " ?>">
<div class="row g-3 pt-0 mt-0">
<div class="col-6">
<label for="imageInput" class="d-flex flex-column align-items-center justify-content-center bg-light h-100" style="border: 3px solid lightgray; border-style: dashed;">
<div class="d-flex flex-column align-items-center justify-content-center py-1">
<h1 class="mb-0"><i class="fas fa-cloud-arrow-up"></i></h1>
<h6 class="my-1 text-dark text-center"><strong>Click to upload</strong></h6>
<p class="mb-2 text-dark text-center" style="font-size: 0.75rem;">
<span>PNG, WEBP, JPG or JPEG</span><br />
<span>(MAX. UPLOAD 2MB)</span><br/>
<span>(MIN. RES. 300X300)</span>
</p>
</div>
<input type="file" name="avatar" class="d-none" id="imageInput" accept="image/*;capture=camera" />
</label>
</div>
<div class="col-6">
<img id="dummy" src="assets/images/dummy-square.jpg" class="w-100" alt="" />
</div>
<div class="col-12">
<hr class="py-0 my-0">
</div>
<div class="col-12">
<div class="input-group input-group-sm">
<input type="text" name="fname" class="form-control" id="fName" value="<?= isset($data['first_name']) ? $data['first_name'] : " " ?>" placeholder="First Name" />
<input type="text" name="lname" class="form-control" id="lName" value="<?= isset($data['last_name']) ? $data['last_name'] : " " ?>" placeholder="Last Name" />
</div>
</div>
<div class="col-6">
<input type="text" name="uname" class="form-control form-control-sm" id="uName" value="<?= isset($data['username']) ? $data['username'] : " " ?>" placeholder="Username" />
</div>
<div class="col-6">
<input type="date" name="dob" class="form-control form-control-sm" id="dob" placeholder="" />
</div>
<div class="col-12">
<hr class="py-0 my-0">
</div>
<div class="col-12">
<input type="email" name="email" class="form-control form-control-sm" id="email" value="<?= isset($data['email_address']) ? $data['email_address'] : " " ?>" placeholder="[email protected]" />
</div>
<div class="col-12">
<input type="email" name="alt_email" class="form-control form-control-sm" id="altEmail" placeholder="[email protected]" />
</div>
<div class="col-6">
<input type="tel" name="phone" class="form-control form-control-sm" id="phone" value="<?= isset($data['cell_phone']) ? $data['cell_phone'] : " " ?>" placeholder="+88 (01X) XX-XXXXXX" oninput="formatPhoneNumber(this)" maxlength="19" />
</div>
<div class="col-6">
<input type="tel" name="alt_phone" class="form-control form-control-sm" id="altPhone" placeholder="+88 (01X) XX-XXXXXX" oninput="formatPhoneNumber(this)" maxlength="19" />
</div>
<div class="col-12">
<hr class="py-0 my-0">
</div>
<div class="col-4 d-flex align-items-center">
<small class="py-0 m-0"><b>Created At :</b></small>
</div>
<div class="col-8">
<input type="datetime-local" name="" class="form-control form-control-sm" id="created" value="<?= isset($data['created_at']) ? $data['created_at'] : " " ?>" disabled />
</div>
<div class="col-4 d-flex align-items-center">
<small class="py-0 m-0"><b>Verified At :</b></small>
</div>
<div class="col-8">
<input type="<?= isset($data['email_verified_at']) && $data['email_verified_at'] != NULL ? 'datetime-local' : 'text' ?>" name="" class="form-control form-control-sm" id="verified" value="<?= isset($data['email_verified_at']) ? $data['email_verified_at'] : "Not Verified Yet" ?>" disabled />
</div>
<div class="col-4 d-flex align-items-center">
<small class="py-0 m-0"><b>Last Updated :</b></small>
</div>
<div class="col-8">
<input type="datetime-local" name="" class="form-control form-control-sm" id="updated" value="<?= isset($data['updated_at']) ? $data['updated_at'] : " " ?>" disabled />
</div>
</div>
</div>
<div class="card-footer">
<div class="row g-3">
<div class="col d-grid">
<a href="<?= config("app.root") ?>dashboard.php" class="btn btn-secondary btn-sm rounded-pill py-2">
<i class="fas fa-arrow-left"></i>
<span class="ps-1">Discard</span>
</a>
</div>
<div class="col d-grid">
<button type="submit" class="btn btn-success btn-sm rounded-pill py-2">
<i class="fas fa-check"></i>
<span class="ps-1">Update</span>
</button>
</div>
</div>
</div>
</div>
</div>
<div class="col-12 col-sm-12 col-md-12 col-lg-7 col-xl-8 col-xxl-8">
<div class="card shadow">
<div class="card-body pt-3">
<div class="row g-3">
<div class="col-12">
<div class="input-group input-group-sm">
<textarea name="biography" class="form-control" id="biography" cols="30" rows="21" placeholder="Type your details here"></textarea>
</div>
</div>
<div class="col-12">
<hr class="py-0 my-0">
</div>
<div class="col-12">
<div class="input-group input-group-sm">
<textarea name="address" class="form-control" id="" cols="30" rows="3" placeholder="Type your address here ..."></textarea>
</div>
</div>
<div class="col-4">
<select name="division" class="form-control form-control-sm" id="division" onchange="populateDistricts()" >
<option value="">-- Division --</option>
<?php foreach ($divisions as $division) { ?>
<option value="<?= $division['name']?>"><?= $division['name']?></option>;
<?php } ?>
</select>
</div>
<div class="col-4">
<select name="district" class="form-control form-control-sm" id="district">
<option value="">-- District --</option>
</select>
</div>
<div class="col-4">
<input type="text" name="postal" class="form-control form-control-sm" id="" placeholder="Postal Code" />
</div>
<div class="col-12">
<hr class="py-0 my-0">
</div>
<div class="col-4">
<select name="gender" class="form-control form-control-sm" id="">
<option value="">-- Gender --</option>
<option value="1">Male</option>
<option value="2">Female</option>
<option value="3">Others</option>
</select>
</div>
<div class="col-4">
<select name="religion" class="form-control form-control-sm" id="">
<option value="">-- Religion --</option>
<option value="1">Islam</option>
<option value="2">Hinduism</option>
<option value="3">Christians</option>
<option value="4">Buddhist</option>
<option value="5">Others</option>
</select>
</div>
<div class="col-4">
<select name="marital" class="form-control form-control-sm" id="">
<option value="">-- Marital Status --</option>
<option value="1">Single</option>
<option value="2">Married</option>
<option value="3">Unmarried</option>
<option value="4">Engaged</option>
<option value="5">Divorced</option>
<option value="6">Separeted</option>
<option value="7">Widowed</option>
</select>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</section>
</main>
<!-- <script>
$(document).ready(function() {
$('form').submit(function(e) {
e.preventDefault();
$.ajax({
url: '<?= config("app.root") ?>src/actions/users/update.php',
type: 'POST',
data: $(this).serialize(),
dataType: 'json',
success: function(response) {
if (response.success) {
Swal.fire({
icon: 'success',
title: 'Updated',
text: response.message,
timer: 2000,
showConfirmButton: false
}).then(function() {
location.reload();
});
} else {
Swal.fire({
icon: 'error',
title: 'Error',
text: response.message,
timer: 2000,
showConfirmButton: false
});
}
},
error: function(xhr, status, error) {
if (xhr.status === 400) {
// Bad request error
Swal.fire({
icon: 'error',
title: 'Error',
text: 'Bad request. Please check your form data.',
timer: 2000,
showConfirmButton: false
});
} else if (xhr.status === 500) {
// Internal server error
Swal.fire({
icon: 'error',
title: 'Error',
text: 'Internal server error. Please try again later.',
timer: 2000,
showConfirmButton: false
});
} else {
// Other errors
console.error(error);
Swal.fire({
icon: 'error',
title: 'Error',
text: 'An error occurred while processing the request.',
timer: 2000,
showConfirmButton: false
});
}
}
});
});
});
</script> -->
<script>
var imgInp = document.getElementById("imageInput");
var dummy = document.getElementById("dummy");
imgInp.onchange = evt => {
const [file] = imgInp.files
if (file) {
dummy.src = URL.createObjectURL(file)
}
}
var divisions = <?= json_encode($divisions); ?>;
</script>
</body>
</html>