-
Notifications
You must be signed in to change notification settings - Fork 1
/
customer-billing-shipping-update.php
207 lines (196 loc) · 12.3 KB
/
customer-billing-shipping-update.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
<?php require_once('header.php'); ?>
<?php
// Check if the customer is logged in or not
if(!isset($_SESSION['customer'])) {
header('location: '.BASE_URL.'logout.php');
exit;
} else {
// If customer is logged in, but admin make him inactive, then force logout this user.
$statement = $pdo->prepare("SELECT * FROM tbl_customer WHERE cust_id=? AND cust_status=?");
$statement->execute(array($_SESSION['customer']['cust_id'],0));
$total = $statement->rowCount();
if($total) {
header('location: '.BASE_URL.'logout.php');
exit;
}
}
?>
<?php
if (isset($_POST['form1'])) {
// update data into the database
$statement = $pdo->prepare("UPDATE tbl_customer SET
cust_b_name=?,
cust_b_cname=?,
cust_b_phone=?,
cust_b_country=?,
cust_b_address=?,
cust_b_city=?,
cust_b_state=?,
cust_b_zip=?,
cust_s_name=?,
cust_s_cname=?,
cust_s_phone=?,
cust_s_country=?,
cust_s_address=?,
cust_s_city=?,
cust_s_state=?,
cust_s_zip=?
WHERE cust_id=?");
$statement->execute(array(
strip_tags($_POST['cust_b_name']),
strip_tags($_POST['cust_b_cname']),
strip_tags($_POST['cust_b_phone']),
strip_tags($_POST['cust_b_country']),
strip_tags($_POST['cust_b_address']),
strip_tags($_POST['cust_b_city']),
strip_tags($_POST['cust_b_state']),
strip_tags($_POST['cust_b_zip']),
strip_tags($_POST['cust_s_name']),
strip_tags($_POST['cust_s_cname']),
strip_tags($_POST['cust_s_phone']),
strip_tags($_POST['cust_s_country']),
strip_tags($_POST['cust_s_address']),
strip_tags($_POST['cust_s_city']),
strip_tags($_POST['cust_s_state']),
strip_tags($_POST['cust_s_zip']),
$_SESSION['customer']['cust_id']
));
$success_message = LANG_VALUE_122;
$_SESSION['customer']['cust_b_name'] = strip_tags($_POST['cust_b_name']);
$_SESSION['customer']['cust_b_cname'] = strip_tags($_POST['cust_b_cname']);
$_SESSION['customer']['cust_b_phone'] = strip_tags($_POST['cust_b_phone']);
$_SESSION['customer']['cust_b_country'] = strip_tags($_POST['cust_b_country']);
$_SESSION['customer']['cust_b_address'] = strip_tags($_POST['cust_b_address']);
$_SESSION['customer']['cust_b_city'] = strip_tags($_POST['cust_b_city']);
$_SESSION['customer']['cust_b_state'] = strip_tags($_POST['cust_b_state']);
$_SESSION['customer']['cust_b_zip'] = strip_tags($_POST['cust_b_zip']);
$_SESSION['customer']['cust_s_name'] = strip_tags($_POST['cust_s_name']);
$_SESSION['customer']['cust_s_cname'] = strip_tags($_POST['cust_s_cname']);
$_SESSION['customer']['cust_s_phone'] = strip_tags($_POST['cust_s_phone']);
$_SESSION['customer']['cust_s_country'] = strip_tags($_POST['cust_s_country']);
$_SESSION['customer']['cust_s_address'] = strip_tags($_POST['cust_s_address']);
$_SESSION['customer']['cust_s_city'] = strip_tags($_POST['cust_s_city']);
$_SESSION['customer']['cust_s_state'] = strip_tags($_POST['cust_s_state']);
$_SESSION['customer']['cust_s_zip'] = strip_tags($_POST['cust_s_zip']);
}
?>
<div class="page">
<div class="container">
<div class="row">
<div class="col-md-12">
<?php require_once('customer-sidebar.php'); ?>
</div>
<div class="col-md-12">
<div class="user-content">
<?php
if($error_message != '') {
echo "<div class='error' style='padding: 10px;background:#f1f1f1;margin-bottom:20px;'>".$error_message."</div>";
}
if($success_message != '') {
echo "<div class='success' style='padding: 10px;background:#f1f1f1;margin-bottom:20px;'>".$success_message."</div>";
}
?>
<form action="" method="post">
<?php $csrf->echoInputField(); ?>
<div class="row">
<div class="col-md-6">
<h3><?php echo LANG_VALUE_86; ?></h3>
<div class="form-group">
<label for=""><?php echo LANG_VALUE_102; ?></label>
<input type="text" class="form-control" name="cust_b_name" value="<?php echo $_SESSION['customer']['cust_b_name']; ?>">
</div>
<div class="form-group">
<label for=""><?php echo LANG_VALUE_103; ?></label>
<input type="text" class="form-control" name="cust_b_cname" value="<?php echo $_SESSION['customer']['cust_b_cname']; ?>">
</div>
<div class="form-group">
<label for=""><?php echo LANG_VALUE_104; ?></label>
<input type="text" class="form-control" name="cust_b_phone" value="<?php echo $_SESSION['customer']['cust_b_phone']; ?>">
</div>
<div class="form-group">
<label for=""><?php echo LANG_VALUE_106; ?></label>
<select name="cust_b_country" class="form-control">
<?php
$statement = $pdo->prepare("SELECT * FROM tbl_country ORDER BY country_name ASC");
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
?>
<option value="<?php echo $row['country_id']; ?>" <?php if($row['country_id'] == $_SESSION['customer']['cust_b_country']) {echo 'selected';} ?>><?php echo $row['country_name']; ?></option>
<?php
}
?>
</select>
</div>
<div class="form-group">
<label for=""><?php echo LANG_VALUE_105; ?></label>
<textarea name="cust_b_address" class="form-control" cols="30" rows="10" style="height:100px;"><?php echo $_SESSION['customer']['cust_b_address']; ?></textarea>
</div>
<div class="form-group">
<label for=""><?php echo LANG_VALUE_107; ?></label>
<input type="text" class="form-control" name="cust_b_city" value="<?php echo $_SESSION['customer']['cust_b_city']; ?>">
</div>
<div class="form-group">
<label for=""><?php echo LANG_VALUE_108; ?></label>
<input type="text" class="form-control" name="cust_b_state" value="<?php echo $_SESSION['customer']['cust_b_state']; ?>">
</div>
<div class="form-group">
<label for=""><?php echo LANG_VALUE_109; ?></label>
<input type="text" class="form-control" name="cust_b_zip" value="<?php echo $_SESSION['customer']['cust_b_zip']; ?>">
</div>
</div>
<div class="col-md-6">
<h3><?php echo LANG_VALUE_87; ?></h3>
<div class="form-group">
<label for=""><?php echo LANG_VALUE_102; ?></label>
<input type="text" class="form-control" name="cust_s_name" value="<?php echo $_SESSION['customer']['cust_s_name']; ?>">
</div>
<div class="form-group">
<label for=""><?php echo LANG_VALUE_103; ?></label>
<input type="text" class="form-control" name="cust_s_cname" value="<?php echo $_SESSION['customer']['cust_s_cname']; ?>">
</div>
<div class="form-group">
<label for=""><?php echo LANG_VALUE_104; ?></label>
<input type="text" class="form-control" name="cust_s_phone" value="<?php echo $_SESSION['customer']['cust_s_phone']; ?>">
</div>
<div class="form-group">
<label for=""><?php echo LANG_VALUE_106; ?></label>
<select name="cust_s_country" class="form-control">
<?php
$statement = $pdo->prepare("SELECT * FROM tbl_country ORDER BY country_name ASC");
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
?>
<option value="<?php echo $row['country_id']; ?>" <?php if($row['country_id'] == $_SESSION['customer']['cust_s_country']) {echo 'selected';} ?>><?php echo $row['country_name']; ?></option>
<?php
}
?>
</select>
</div>
<div class="form-group">
<label for=""><?php echo LANG_VALUE_105; ?></label>
<textarea name="cust_s_address" class="form-control" cols="30" rows="10" style="height:100px;"><?php echo $_SESSION['customer']['cust_s_address']; ?></textarea>
</div>
<div class="form-group">
<label for=""><?php echo LANG_VALUE_107; ?></label>
<input type="text" class="form-control" name="cust_s_city" value="<?php echo $_SESSION['customer']['cust_s_city']; ?>">
</div>
<div class="form-group">
<label for=""><?php echo LANG_VALUE_108; ?></label>
<input type="text" class="form-control" name="cust_s_state" value="<?php echo $_SESSION['customer']['cust_s_state']; ?>">
</div>
<div class="form-group">
<label for=""><?php echo LANG_VALUE_109; ?></label>
<input type="text" class="form-control" name="cust_s_zip" value="<?php echo $_SESSION['customer']['cust_s_zip']; ?>">
</div>
</div>
</div>
<input type="submit" class="btn btn-primary" value="<?php echo LANG_VALUE_5; ?>" name="form1">
</form>
</div>
</div>
</div>
</div>
</div>
<?php require_once('footer.php'); ?>