-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_account.php
95 lines (94 loc) · 5.56 KB
/
edit_account.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
<section class="py-5">
<div class="container">
<div class="card rounded-0">
<div class="card-body">
<div class="w-100 justify-content-between d-flex">
<h4><b>Update Account Details</b></h4>
<a href="./?p=my_account" class="btn btn btn-default btn-flat bg-maroon"><div class="fa fa-angle-left"></div> Back to Order List</a>
</div>
<hr class="border-warning">
<div class="col-md-6">
<form action="" id="update_account">
<input type="hidden" name="id" value="<?php echo $_settings->userdata('id') ?>">
<div class="form-group">
<label for="firstname" class="control-label">Firstname</label>
<input type="text" name="firstname" class="form-control form" value="<?php echo $_settings->userdata('firstname') ?>" required>
</div>
<div class="form-group">
<label for="lastname" class="control-label">Lastname</label>
<input type="text" name="lastname" class="form-control form" value="<?php echo $_settings->userdata('lastname') ?>" required>
</div>
<div class="form-group">
<label for="" class="control-label">Contact</label>
<input type="text" class="form-control form-control-sm form" name="contact" value="<?php echo $_settings->userdata('contact') ?>" required>
</div>
<div class="form-group">
<label for="" class="control-label">Gender</label>
<select name="gender" id="" class="custom-select select" required>
<option <?php echo $_settings->userdata('gender') == "Male" ? "selected" : '' ?>>Male</option>
<option <?php echo $_settings->userdata('gender') == "Female" ? "selected" : '' ?>>Female</option>
</select>
</div>
<div class="form-group">
<label for="" class="control-label">Default Delivery Address</label>
<textarea class="form-control form" rows='3' name="default_delivery_address"><?php echo $_settings->userdata('default_delivery_address') ?></textarea>
</div>
<div class="form-group">
<label for="email" class="control-label">Email</label>
<input type="text" name="email" class="form-control form" value="<?php echo $_settings->userdata('email') ?>" required>
</div>
<div class="form-group">
<label for="password" class="control-label">New Password</label>
<input type="password" name="password" class="form-control form" value="" placeholder="(Enter value to change password)">
<small class="text-muted"><i>Leave this blank if you don't want to update your password.</i></small>
</div>
<div class="form-group">
<label for="cpassword" class="control-label">Current Password</label>
<input type="password" name="cpassword" class="form-control form" value="" required>
<small class="text-muted"><i>Enter tour current password to update your details.</i></small>
</div>
<div class="form-group d-flex justify-content-end">
<button class="btn btn-dark btn-flat">Update</button>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
<script>
$(function(){
$('#update_account').submit(function(e){
e.preventDefault();
start_loader()
if($('.err-msg').length > 0)
$('.err-msg').remove();
$.ajax({
url:_base_url_+"classes/Master.php?f=update_account",
method:"POST",
data:$(this).serialize(),
dataType:"json",
error:err=>{
console.log(err)
alert_toast("an error occured",'error')
end_loader()
},
success:function(resp){
if(typeof resp == 'object' && resp.status == 'success'){
location.reload()
}else if(resp.status == 'failed' && !!resp.msg){
var _err_el = $('<div>')
_err_el.addClass("alert alert-danger err-msg").text(resp.msg)
$('#update_account').prepend(_err_el)
$('body, html').animate({scrollTop:0},'fast')
end_loader()
}else{
console.log(resp)
alert_toast("an error occured",'error')
}
end_loader()
}
})
})
})
</script>