-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.php
198 lines (193 loc) · 11.3 KB
/
settings.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
<?php
require 'includes/common.php';
if(!isset($_SESSION['email']))
{
header('location: index.php');
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Amazing Zone</title>
<meta charset="utf-8">
<meta name='viewport' content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Oxygen&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/index.css">
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</head>
<body>
<?php include 'includes/header.php'; ?>
<div class="container-fluid">
<div class="row">
<main class="col-md-9 ml-sm-auto col-lg-12 px-md-4 py-4">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="#">Home</a></li>
<li class="breadcrumb-item active" aria-current="page">New Form</li>
</ol>
</nav>
<h1 style="margin-top:50px;">User Profile Page</h1>
<section>
<div class="container">
<h4 style="line-height: 50px;"><strong>Details of User account</strong></h4>
<?php if(isset($_GET['update_msg'])) {
echo"<div class='panel panel-success'>
<div class='panel-heading'>
<p>".$_GET['update_msg']."</p>
</div></div>";
}?>
<?php
$user_id = $_SESSION['user_id'];
$select_user_query = "SELECT * FROM users WHERE user_id = $user_id";
$select_user_query_result = mysqli_query($con , $select_user_query) or die(mysqli_error($con));
$user_row = mysqli_fetch_array($select_user_query_result);
?>
<form style="margin-top: 20px;" method="post" action="settings-script.php">
<div class="form-row">
<div class="form-group col-md-4">
<label for="name">Full Name</label>
<input type="text" class="form-control" name="name" id="name" value="<?php echo $user_row['name'] ?>" disabled autocomplete="off">
</div>
<div class="form-group col-md-offset-2 col-md-4">
<label for="email">Email ID</label>
<input type="email" class="form-control" name="email" id="email" value="<?php echo $user_row['email'] ?>" disabled autocomplete="off">
</div>
</div>
<div class="form-row">
<?php if($_SESSION['role'] == 0) {
$customer_id = $_SESSION['specific_id'];
$select_customer_query = "SELECT * FROM customers WHERE customer_id = $customer_id";
$select_customer_query_result = mysqli_query($con , $select_customer_query) or die(mysqli_error($con));
$customer_row = mysqli_fetch_array($select_customer_query_result);
?>
<div class="form-group col-md-4">
<label for="contact">Contact Number</label>
<input type="text" class="form-control" name="contact" id="contact" pattern="[0-9]{10}" value="<?php echo $customer_row['contact_no']; ?>" disabled autocomplete="off">
</div>
<div class="form-group col-md-4">
<label for="city">City</label>
<input type="text" class="form-control" name="city" id="city" value="<?php echo $customer_row['city']; ?>" disabled autocomplete="off">
</div>
<div class="form-group col-md-4">
<label for="country">Country</label>
<input type="text" class="form-control" name="country" id="country" value="<?php echo $customer_row['country']; ?>" disabled autocomplete="off">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="address">Address</label>
<input type="text" class="form-control" name="address" id="address" value="<?php echo $customer_row['address']; ?>" disabled autocomplete="off">
</div>
</div>
<div class="push"></div>
<div class="form-row" id="edit-row">
<center>
<div class="form-group col-md-12" id="edit">
<div class="btn btn-primary" onclick="editCustomer()">Edit Details</div>
</div>
</center>
</div>
<?php } else if($_SESSION['role'] == 1) {
$supplier_id = $_SESSION['specific_id'];
$select_supplier_query = "SELECT * FROM suppliers WHERE supplier_id = $supplier_id";
$select_supplier_query_result = mysqli_query($con , $select_supplier_query) or die(mysqli_error($con));
$supplier_row = mysqli_fetch_array($select_supplier_query_result);
?>
<div class="form-group col-md-4">
<label for="contact">Contact Number</label>
<input type="text" class="form-control" name="contact" id="contact" pattern="[0-9]{10}" value="<?php echo $supplier_row['contact_no']; ?>" disabled autocomplete="off">
</div>
<div class="form-group col-md-offset-2 col-md-4">
<label for="license">License ID</label>
<input type="text" class="form-control" name="license" id="license" value="<?php echo $supplier_row['license']; ?>" disabled autocomplete="off">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="address">Address</label>
<input type="text" class="form-control" id="address" name="address" value="<?php echo $supplier_row['address']; ?>" disabled autocomplete="off">
</div>
</div>
<div class="push"></div>
<div class="form-row" id="edit-row">
<center>
<div class="form-group col-md-12" id="edit">
<div class="btn btn-primary" onclick="editSupplier()">Edit Details</div>
</div>
</center>
</div>
<?php } ?>
</form>
</div>
</section>
</main>
</div>
</div>
<div class = "navbar navbar-inverse navbar-fixed-bottom">
<?php include 'includes/footer.php'; ?>
</div>
<script>
function editCustomer() {
document.getElementById("address").disabled = false;
document.getElementById("contact").disabled = false;
document.getElementById("city").disabled = false;
document.getElementById("country").disabled = false;
document.getElementById("name").disabled = false;
document.getElementById("email").disabled = false;
$( "#edit" ).remove();
newRow =
'<div class="form-group col-md-offset-5 col-md-1" id="submit"><input type="submit" value="Update" class="btn btn-primary"></div><div class="form-group col-md-1" id="cancel"><div class="btn btn-danger" onclick="restoreCustomer()">Cancel</div></div>';
$('#edit-row').append(newRow);
}
function editSupplier() {
document.getElementById("address").disabled = false;
document.getElementById("contact").disabled = false;
document.getElementById("license").disabled = false;
document.getElementById("name").disabled = false;
document.getElementById("email").disabled = false;
$( "#edit" ).remove();
newRow =
'<div class="form-group col-md-offset-5 col-md-1" id="submit"><input type="submit" value="Update" class="btn btn-primary"></div><div class="form-group col-md-1" id="cancel"><div class="btn btn-danger" onclick="restoreSupplier()">Cancel</div></div>';
$('#edit-row').append(newRow);
}
function restoreCustomer() {
document.getElementById("address").disabled = true;
document.getElementById("address").value = "<?php echo $customer_row['address']; ?>";
document.getElementById("contact").disabled = true;
document.getElementById("contact").value = "<?php echo $customer_row['contact_no']; ?>";
document.getElementById("city").disabled = true;
document.getElementById("city").value = "<?php echo $customer_row['city']; ?>";
document.getElementById("country").disabled = true;
document.getElementById("country").value = "<?php echo $customer_row['country']; ?>";
document.getElementById("name").disabled = true;
document.getElementById("name").value = "<?php echo $user_row['name']; ?>";
document.getElementById("email").disabled = true;
document.getElementById("email").value = "<?php echo $user_row['email']; ?>";
$( "#submit" ).remove();
$( "#cancel" ).remove();
newRow = '<center><div class="form-group col-md-12" id="edit"><div class="btn btn-primary" onclick="editCustomer()">Edit Details</div></div></center>';
$('#edit-row').append(newRow);
}
function restoreSupplier() {
document.getElementById("address").disabled = true;
document.getElementById("address").value = "<?php echo $supplier_row['address']; ?>";
document.getElementById("contact").disabled = true;
document.getElementById("contact").value = "<?php echo $supplier_row['contact_no']; ?>";
document.getElementById("license").disabled = true;
document.getElementById("license").value = "<?php echo $supplier_row['license']; ?>";
document.getElementById("name").disabled = true;
document.getElementById("name").value = "<?php echo $user_row['name']; ?>";
document.getElementById("email").disabled = true;
document.getElementById("email").value = "<?php echo $user_row['email']; ?>";
$( "#submit" ).remove();
$( "#cancel" ).remove();
newRow = '<center><div class="form-group col-md-12" id="edit"><div class="btn btn-primary" onclick="editSupplier()">Edit Details</div></div></center>';
$('#edit-row').append(newRow);
}
</script>
</body>
</html>