hpdl
|
1
|
1
|
<?php
|
|
2
|
/*
|
mattice
|
151
|
3
|
$Id: customers.php 847 2006-08-29 20:03:36Z hpdl $
|
hpdl
|
1
|
4
|
|
|
5
|
osCommerce, Open Source E-Commerce Solutions
|
|
6
|
http://www.oscommerce.com
|
|
7
|
|
hpdl
|
410
|
8
|
Copyright (c) 2006 osCommerce
|
hpdl
|
1
|
9
|
|
|
10
|
Released under the GNU General Public License
|
|
11
|
*/
|
|
12
|
|
|
13
|
require('includes/application_top.php');
|
|
14
|
|
|
15
|
require('external/adodb/adodb-time.inc.php');
|
|
16
|
|
|
17
|
$action = (isset($_GET['action']) ? $_GET['action'] : '');
|
|
18
|
|
|
19
|
if (!isset($_GET['page']) || (isset($_GET['page']) && !is_numeric($_GET['page']))) {
|
|
20
|
$_GET['page'] = 1;
|
|
21
|
}
|
|
22
|
|
|
23
|
if (!empty($action)) {
|
|
24
|
switch ($action) {
|
|
25
|
case 'save':
|
|
26
|
$error = false;
|
|
27
|
|
|
28
|
if (ACCOUNT_GENDER > 0) {
|
|
29
|
if (!isset($_POST['gender']) || (($_POST['gender'] != 'm') && ($_POST['gender'] != 'f'))) {
|
|
30
|
$osC_MessageStack->add('header', ENTRY_GENDER_ERROR, 'error');
|
|
31
|
$error = true;
|
|
32
|
}
|
|
33
|
}
|
|
34
|
|
|
35
|
if (!isset($_POST['firstname']) || (strlen(trim($_POST['firstname'])) < ACCOUNT_FIRST_NAME)) {
|
|
36
|
$osC_MessageStack->add('header', ENTRY_FIRST_NAME_ERROR, 'error');
|
|
37
|
$error = true;
|
|
38
|
}
|
|
39
|
|
|
40
|
if (!isset($_POST['lastname']) || (strlen(trim($_POST['lastname'])) < ACCOUNT_LAST_NAME)) {
|
|
41
|
$osC_MessageStack->add('header', ENTRY_LAST_NAME_ERROR, 'error');
|
|
42
|
$error = true;
|
|
43
|
}
|
|
44
|
|
hpdl
|
554
|
45
|
if (ACCOUNT_DATE_OF_BIRTH == '1') {
|
hpdl
|
1
|
46
|
if (isset($_POST['dob_days']) && isset($_POST['dob_months']) && isset($_POST['dob_years']) && checkdate($_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years'])) {
|
|
47
|
$dob = adodb_mktime(0, 0, 0, $_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years']);
|
|
48
|
} else {
|
|
49
|
$osC_MessageStack->add('header', ENTRY_DATE_OF_BIRTH_ERROR, 'error');
|
|
50
|
$error = true;
|
|
51
|
}
|
|
52
|
}
|
|
53
|
|
|
54
|
if (!isset($_POST['email_address']) || (strlen(trim($_POST['email_address'])) < ACCOUNT_EMAIL_ADDRESS)) {
|
|
55
|
$osC_MessageStack->add('header', ENTRY_EMAIL_ADDRESS_ERROR, 'error');
|
|
56
|
$error = true;
|
hpdl
|
758
|
57
|
} elseif (osc_validate_email_address($_POST['email_address']) == false) {
|
hpdl
|
1
|
58
|
$osC_MessageStack->add('header', ENTRY_EMAIL_ADDRESS_CHECK_ERROR, 'error');
|
|
59
|
$error = true;
|
|
60
|
} else {
|
|
61
|
$Qcheck = $osC_Database->query('select customers_id from :table_customers where customers_email_address = :customers_email_address');
|
|
62
|
if (isset($_GET['cID']) && is_numeric($_GET['cID'])) {
|
|
63
|
$Qcheck->appendQuery('and customers_id != :customers_id');
|
|
64
|
$Qcheck->bindInt(':customers_id', $_GET['cID']);
|
|
65
|
}
|
|
66
|
$Qcheck->appendQuery('limit 1');
|
|
67
|
$Qcheck->bindTable(':table_customers', TABLE_CUSTOMERS);
|
|
68
|
$Qcheck->bindValue(':customers_email_address', $_POST['email_address']);
|
|
69
|
$Qcheck->execute();
|
|
70
|
|
|
71
|
if ($Qcheck->numberOfRows() > 0) {
|
|
72
|
$osC_MessageStack->add('header', ENTRY_EMAIL_ADDRESS_ERROR_EXISTS, 'error');
|
|
73
|
$error = true;
|
|
74
|
}
|
|
75
|
|
|
76
|
$Qcheck->freeResult();
|
|
77
|
}
|
|
78
|
|
|
79
|
if ( (!isset($_GET['cID']) || (isset($_POST['password']) && !empty($_POST['password']))) && (strlen(trim($_POST['password'])) < ACCOUNT_PASSWORD)) {
|
|
80
|
$osC_MessageStack->add('header', ENTRY_PASSWORD_ERROR, 'error');
|
|
81
|
$error = true;
|
|
82
|
} elseif (isset($_POST['confirmation']) && !empty($_POST['confirmation']) && (trim($_POST['password']) != trim($_POST['confirmation']))) {
|
|
83
|
$osC_MessageStack->add('header', ENTRY_PASSWORD_ERROR_NOT_MATCHING, 'error');
|
|
84
|
$error = true;
|
|
85
|
}
|
|
86
|
|
|
87
|
if (!isset($_GET['cID']) || (strlen(trim($_POST['ab_street_address'])) > 0)) {
|
|
88
|
if (ACCOUNT_GENDER > 0) {
|
|
89
|
if (!isset($_POST['ab_gender']) || (($_POST['ab_gender'] != 'm') && ($_POST['ab_gender'] != 'f'))) {
|
|
90
|
$osC_MessageStack->add('header', ENTRY_GENDER_ERROR, 'error');
|
|
91
|
$error = true;
|
|
92
|
}
|
|
93
|
}
|
|
94
|
|
|
95
|
if (!isset($_POST['ab_firstname']) || (strlen(trim($_POST['ab_firstname'])) < ACCOUNT_FIRST_NAME)) {
|
|
96
|
$osC_MessageStack->add('header', ENTRY_FIRST_NAME_ERROR, 'error');
|
|
97
|
$error = true;
|
|
98
|
}
|
|
99
|
|
|
100
|
if (!isset($_POST['ab_lastname']) || (strlen(trim($_POST['ab_lastname'])) < ACCOUNT_LAST_NAME)) {
|
|
101
|
$osC_MessageStack->add('header', ENTRY_LAST_NAME_ERROR, 'error');
|
|
102
|
$error = true;
|
|
103
|
}
|
|
104
|
|
|
105
|
if (ACCOUNT_COMPANY > 0) {
|
|
106
|
if (!isset($_POST['ab_company']) || (strlen(trim($_POST['ab_company'])) < ACCOUNT_COMPANY)) {
|
|
107
|
$osC_MessageStack->add('header', ENTRY_COMPANY_ERROR, 'error');
|
|
108
|
$error = true;
|
|
109
|
}
|
|
110
|
}
|
|
111
|
|
|
112
|
if (!isset($_POST['ab_street_address']) || (strlen(trim($_POST['ab_street_address'])) < ACCOUNT_STREET_ADDRESS)) {
|
|
113
|
$osC_MessageStack->add('header', ENTRY_STREET_ADDRESS_ERROR, 'error');
|
|
114
|
$error = true;
|
|
115
|
}
|
|
116
|
|
|
117
|
if (ACCOUNT_SUBURB > 0) {
|
|
118
|
if (!isset($_POST['ab_suburb']) || (strlen(trim($_POST['ab_suburb'])) < ACCOUNT_SUBURB)) {
|
|
119
|
$osC_MessageStack->add('header', ENTRY_SUBURB_ERROR, 'error');
|
|
120
|
$error = true;
|
|
121
|
}
|
|
122
|
}
|
|
123
|
|
hpdl
|
779
|
124
|
if (ACCOUNT_POST_CODE > 0) {
|
|
125
|
if (!isset($_POST['ab_postcode']) || (strlen(trim($_POST['ab_postcode'])) < ACCOUNT_POST_CODE)) {
|
|
126
|
$osC_MessageStack->add('header', ENTRY_POST_CODE_ERROR, 'error');
|
|
127
|
$error = true;
|
|
128
|
}
|
hpdl
|
1
|
129
|
}
|
|
130
|
|
|
131
|
if (!isset($_POST['ab_city']) || (strlen(trim($_POST['ab_city'])) < ACCOUNT_CITY)) {
|
|
132
|
$osC_MessageStack->add('header', ENTRY_CITY_ERROR, 'error');
|
|
133
|
$error = true;
|
|
134
|
}
|
|
135
|
|
|
136
|
if (ACCOUNT_STATE > 0) {
|
|
137
|
$zone_id = 0;
|
|
138
|
|
|
139
|
$Qcheck = $osC_Database->query('select zone_id from :table_zones where zone_country_id = :zone_country_id limit 1');
|
|
140
|
$Qcheck->bindTable(':table_zones', TABLE_ZONES);
|
|
141
|
$Qcheck->bindInt(':zone_country_id', $_POST['ab_country']);
|
|
142
|
$Qcheck->execute();
|
|
143
|
|
|
144
|
$entry_state_has_zones = ($Qcheck->numberOfRows() > 0);
|
|
145
|
|
|
146
|
$Qcheck->freeResult();
|
|
147
|
|
|
148
|
if ($entry_state_has_zones === true) {
|
|
149
|
$Qzone = $osC_Database->query('select zone_id from :table_zones where zone_country_id = :zone_country_id and zone_code like :zone_code');
|
|
150
|
$Qzone->bindTable(':table_zones', TABLE_ZONES);
|
|
151
|
$Qzone->bindInt(':zone_country_id', $_POST['ab_country']);
|
|
152
|
$Qzone->bindValue(':zone_code', $_POST['ab_state']);
|
|
153
|
$Qzone->execute();
|
|
154
|
|
|
155
|
if ($Qzone->numberOfRows() === 1) {
|
|
156
|
$zone_id = $Qzone->valueInt('zone_id');
|
|
157
|
} else {
|
|
158
|
$Qzone = $osC_Database->query('select zone_id from :table_zones where zone_country_id = :zone_country_id and zone_name like :zone_name');
|
|
159
|
$Qzone->bindTable(':table_zones', TABLE_ZONES);
|
|
160
|
$Qzone->bindInt(':zone_country_id', $_POST['ab_country']);
|
|
161
|
$Qzone->bindValue(':zone_name', $_POST['ab_state'] . '%');
|
|
162
|
$Qzone->execute();
|
|
163
|
|
|
164
|
if ($Qzone->numberOfRows() === 1) {
|
|
165
|
$zone_id = $Qzone->valueInt('zone_id');
|
|
166
|
} else {
|
|
167
|
$osC_MessageStack->add('header', ENTRY_STATE_ERROR_SELECT, 'error');
|
|
168
|
$error = true;
|
|
169
|
}
|
|
170
|
}
|
|
171
|
|
|
172
|
$Qzone->freeResult();
|
|
173
|
} else {
|
|
174
|
if (strlen(trim($_POST['ab_state'])) < ACCOUNT_STATE) {
|
|
175
|
$osC_MessageStack->add('header', ENTRY_STATE_ERROR, 'error');
|
|
176
|
$error = true;
|
|
177
|
}
|
|
178
|
}
|
|
179
|
}
|
|
180
|
|
|
181
|
if ( (is_numeric($_POST['ab_country']) === false) || ($_POST['ab_country'] < 1) ) {
|
|
182
|
$osC_MessageStack->add('header', ENTRY_COUNTRY_ERROR, 'error');
|
|
183
|
$error = true;
|
|
184
|
}
|
|
185
|
|
|
186
|
if (ACCOUNT_TELEPHONE > 0) {
|
|
187
|
if (!isset($_POST['ab_telephone']) || (strlen(trim($_POST['ab_telephone'])) < ACCOUNT_TELEPHONE)) {
|
|
188
|
$osC_MessageStack->add('header', ENTRY_TELEPHONE_NUMBER_ERROR, 'error');
|
|
189
|
$error = true;
|
|
190
|
}
|
|
191
|
}
|
|
192
|
|
|
193
|
if (ACCOUNT_FAX > 0) {
|
|
194
|
if (!isset($_POST['ab_fax']) || (strlen(trim($_POST['ab_fax'])) < ACCOUNT_FAX)) {
|
|
195
|
$osC_MessageStack->add('header', ENTRY_FAX_NUMBER_ERROR, 'error');
|
|
196
|
$error = true;
|
|
197
|
}
|
|
198
|
}
|
|
199
|
}
|
|
200
|
|
|
201
|
if ($error === false) {
|
|
202
|
$modified = false;
|
|
203
|
|
|
204
|
$osC_Database->startTransaction();
|
|
205
|
|
|
206
|
if (isset($_GET['cID']) && is_numeric($_GET['cID'])) {
|
|
207
|
$Qcustomer = $osC_Database->query('update :table_customers set customers_gender = :customers_gender, customers_firstname = :customers_firstname, customers_lastname = :customers_lastname, customers_email_address = :customers_email_address, customers_dob = :customers_dob, customers_newsletter = :customers_newsletter, customers_status = :customers_status where customers_id = :customers_id');
|
hpdl
|
847
|
208
|
$Qcustomer->bindInt(':customers_id', $_GET['cID']);
|
hpdl
|
1
|
209
|
} else {
|
hpdl
|
814
|
210
|
$Qcustomer = $osC_Database->query('insert into :table_customers (customers_gender, customers_firstname, customers_lastname, customers_email_address, customers_dob, customers_newsletter, customers_status, number_of_logons, date_account_created) values (:customers_gender, :customers_firstname, :customers_lastname, :customers_email_address, :customers_dob, :customers_newsletter, :customers_status, :number_of_logons, :date_account_created)');
|
|
211
|
$Qcustomer->bindInt(':number_of_logons', 0);
|
|
212
|
$Qcustomer->bindRaw(':date_account_created', 'now()');
|
hpdl
|
1
|
213
|
}
|
|
214
|
$Qcustomer->bindTable(':table_customers', TABLE_CUSTOMERS);
|
|
215
|
$Qcustomer->bindValue(':customers_gender', (((ACCOUNT_GENDER > -1) && isset($_POST['gender']) && (($_POST['gender'] == 'm') || ($_POST['gender'] == 'f'))) ? $_POST['gender'] : ''));
|
|
216
|
$Qcustomer->bindValue(':customers_firstname', $_POST['firstname']);
|
|
217
|
$Qcustomer->bindValue(':customers_lastname', $_POST['lastname']);
|
|
218
|
$Qcustomer->bindValue(':customers_email_address', $_POST['email_address']);
|
hpdl
|
554
|
219
|
$Qcustomer->bindValue(':customers_dob', ((ACCOUNT_DATE_OF_BIRTH == '1') ? adodb_date('Ymd', $dob) : ''));
|
hpdl
|
1
|
220
|
$Qcustomer->bindInt(':customers_newsletter', (isset($_POST['newsletter']) && ($_POST['newsletter'] == 'on') ? '1' : '0'));
|
|
221
|
$Qcustomer->bindInt(':customers_status', (isset($_POST['status']) && ($_POST['status'] == 'on') ? '1' : '0'));
|
|
222
|
$Qcustomer->execute();
|
|
223
|
|
|
224
|
if ($osC_Database->isError() === false) {
|
|
225
|
if ($Qcustomer->affectedRows()) {
|
|
226
|
$modified = true;
|
|
227
|
|
|
228
|
if (isset($_GET['cID']) && is_numeric($_GET['cID'])) {
|
hpdl
|
847
|
229
|
$customer_id = $_GET['cID'];
|
|
230
|
|
hpdl
|
814
|
231
|
$Qupdate = $osC_Database->query('update :table_customers set date_account_last_modified = :date_account_last_modified where customers_id = :customers_id');
|
|
232
|
$Qupdate->bindTable(':table_customers', TABLE_CUSTOMERS);
|
|
233
|
$Qupdate->bindRaw(':date_account_last_modified', 'now()');
|
|
234
|
$Qupdate->bindInt(':customers_id', $customer_id);
|
hpdl
|
1
|
235
|
$Qupdate->execute();
|
|
236
|
|
|
237
|
if ($osC_Database->isError()) {
|
|
238
|
$error = true;
|
|
239
|
}
|
hpdl
|
847
|
240
|
} else {
|
|
241
|
$customer_id = $osC_Database->nextID();
|
hpdl
|
1
|
242
|
}
|
|
243
|
}
|
|
244
|
} else {
|
|
245
|
$error = true;
|
|
246
|
}
|
|
247
|
|
|
248
|
if ($error === false) {
|
|
249
|
if (isset($_POST['confirmation']) && !empty($_POST['confirmation']) && (trim($_POST['password']) == trim($_POST['confirmation']))) {
|
|
250
|
$Qpassword = $osC_Database->query('update :table_customers set customers_password = :customers_password where customers_id = :customers_id');
|
|
251
|
$Qpassword->bindTable(':table_customers', TABLE_CUSTOMERS);
|
hpdl
|
758
|
252
|
$Qpassword->bindValue(':customers_password', osc_encrypt_string(trim($_POST['password'])));
|
hpdl
|
1
|
253
|
$Qpassword->bindInt(':customers_id', $customer_id);
|
|
254
|
$Qpassword->execute();
|
|
255
|
|
|
256
|
if ($osC_Database->isError() === false) {
|
|
257
|
if ($Qpassword->affectedRows()) {
|
|
258
|
$modified = true;
|
|
259
|
}
|
|
260
|
} else {
|
|
261
|
$error = true;
|
|
262
|
}
|
|
263
|
}
|
|
264
|
}
|
|
265
|
|
|
266
|
if ($error === false) {
|
|
267
|
if (strlen(trim($_POST['ab_street_address'])) > 0) {
|
|
268
|
$Qcustomer = $osC_Database->query('select customers_gender, customers_firstname, customers_lastname, customers_email_address, customers_default_address_id from :table_customers where customers_id = :customers_id');
|
|
269
|
$Qcustomer->bindTable(':table_customers', TABLE_CUSTOMERS);
|
|
270
|
$Qcustomer->bindInt(':customers_id', $customer_id);
|
|
271
|
$Qcustomer->execute();
|
|
272
|
|
|
273
|
if ($Qcustomer->valueInt('customers_default_address_id') > 0) {
|
|
274
|
$Qab = $osC_Database->query('update :table_address_book set customers_id = :customers_id, entry_gender = :entry_gender, entry_company = :entry_company, entry_firstname = :entry_firstname, entry_lastname = :entry_lastname, entry_street_address = :entry_street_address, entry_suburb = :entry_suburb, entry_postcode = :entry_postcode, entry_city = :entry_city, entry_state = :entry_state, entry_country_id = :entry_country_id, entry_zone_id = :entry_zone_id, entry_telephone = :entry_telephone, entry_fax = :entry_fax where address_book_id = :address_book_id and customers_id = :customers_id');
|
|
275
|
$Qab->bindInt(':address_book_id', $Qcustomer->valueInt('customers_default_address_id'));
|
|
276
|
$Qab->bindInt(':customers_id', $customer_id);
|
|
277
|
} else {
|
|
278
|
$Qab = $osC_Database->query('insert into :table_address_book (customers_id, entry_gender, entry_company, entry_firstname, entry_lastname, entry_street_address, entry_suburb, entry_postcode, entry_city, entry_state, entry_country_id, entry_zone_id, entry_telephone, entry_fax) values (:customers_id, :entry_gender, :entry_company, :entry_firstname, :entry_lastname, :entry_street_address, :entry_suburb, :entry_postcode, :entry_city, :entry_state, :entry_country_id, :entry_zone_id, :entry_telephone, :entry_fax)');
|
|
279
|
}
|
|
280
|
$Qab->bindInt(':customers_id', $customer_id);
|
|
281
|
$Qab->bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
|
|
282
|
$Qab->bindValue(':entry_gender', (((ACCOUNT_GENDER > -1) && isset($_POST['ab_gender']) && (($_POST['ab_gender'] == 'm') || ($_POST['ab_gender'] == 'f'))) ? $_POST['ab_gender'] : ''));
|
|
283
|
$Qab->bindValue(':entry_company', ((ACCOUNT_COMPANY > -1) ? $_POST['ab_company'] : ''));
|
|
284
|
$Qab->bindValue(':entry_firstname', $_POST['ab_firstname']);
|
|
285
|
$Qab->bindValue(':entry_lastname', $_POST['ab_lastname']);
|
|
286
|
$Qab->bindValue(':entry_street_address', $_POST['ab_street_address']);
|
|
287
|
$Qab->bindValue(':entry_suburb', ((ACCOUNT_SUBURB > -1) ? $_POST['ab_suburb'] : ''));
|
hpdl
|
779
|
288
|
$Qab->bindValue(':entry_postcode', ((ACCOUNT_POST_CODE > -1) ? $_POST['ab_postcode'] : ''));
|
hpdl
|
1
|
289
|
$Qab->bindValue(':entry_city', $_POST['ab_city']);
|
|
290
|
$Qab->bindValue(':entry_state', ((ACCOUNT_STATE > -1) ? (($zone_id > 0) ? '' : $_POST['ab_state']) : ''));
|
|
291
|
$Qab->bindInt(':entry_country_id', $_POST['ab_country']);
|
|
292
|
$Qab->bindInt(':entry_zone_id', ((ACCOUNT_STATE > -1) ? (($zone_id > 0) ? $zone_id : 0) : ''));
|
|
293
|
$Qab->bindValue(':entry_telephone', ((ACCOUNT_TELEPHONE > -1) ? $_POST['ab_telephone'] : ''));
|
|
294
|
$Qab->bindValue(':entry_fax', ((ACCOUNT_FAX > -1) ? $_POST['ab_fax'] : ''));
|
|
295
|
$Qab->execute();
|
|
296
|
|
|
297
|
if ($osC_Database->isError() === false) {
|
|
298
|
if ($Qab->affectedRows()) {
|
|
299
|
$modified = true;
|
|
300
|
|
|
301
|
if ($Qcustomer->valueInt('customers_default_address_id') < 1) {
|
|
302
|
$address_book_id = $osC_Database->nextID();
|
|
303
|
|
|
304
|
$Qupdate = $osC_Database->query('update :table_customers set customers_default_address_id = :customers_default_address_id where customers_id = :customers_id');
|
|
305
|
$Qupdate->bindTable(':table_customers', TABLE_CUSTOMERS);
|
|
306
|
$Qupdate->bindInt(':customers_default_address_id', $address_book_id);
|
|
307
|
$Qupdate->bindInt(':customers_id', $customer_id);
|
|
308
|
$Qupdate->execute();
|
|
309
|
|
|
310
|
if ($osC_Database->isError()) {
|
|
311
|
$error = true;
|
|
312
|
}
|
|
313
|
}
|
|
314
|
}
|
|
315
|
} else {
|
|
316
|
$error = true;
|
|
317
|
}
|
|
318
|
}
|
|
319
|
}
|
|
320
|
|
|
321
|
if ($error === false) {
|
|
322
|
if ($modified === true) {
|
|
323
|
$osC_Database->commitTransaction();
|
|
324
|
|
|
325
|
if (!isset($_GET['cID'])) {
|
|
326
|
$full_name = $Qcustomer->value('customers_firstname') . ' ' . $Qcustomer->value('customers_lastname');
|
|
327
|
|
|
328
|
if (ACCOUNT_GENDER > -1) {
|
|
329
|
if ($Qcustomer->value('customers_gender') == 'm') {
|
|
330
|
$email_text = sprintf(EMAIL_GREET_MR, $Qcustomer->value('customers_lastname'));
|
|
331
|
} else {
|
|
332
|
$email_text = sprintf(EMAIL_GREET_MS, $Qcustomer->value('customers_lastname'));
|
|
333
|
}
|
|
334
|
} else {
|
|
335
|
$email_text = sprintf(EMAIL_GREET_NONE, $full_name);
|
|
336
|
}
|
|
337
|
|
|
338
|
$email_text .= EMAIL_WELCOME . EMAIL_TEXT . EMAIL_CONTACT; // . sprintf(EMAIL_PASSWORD, $customers_password);
|
hpdl
|
813
|
339
|
osc_email($full_name, $Qcustomer->value('customers_email_address'), EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
|
hpdl
|
1
|
340
|
}
|
|
341
|
|
|
342
|
$osC_MessageStack->add_session('header', SUCCESS_DB_ROWS_UPDATED, 'success');
|
|
343
|
} else {
|
|
344
|
$osC_MessageStack->add_session('header', WARNING_DB_ROWS_NOT_UPDATED, 'warning');
|
|
345
|
}
|
|
346
|
} else {
|
|
347
|
$osC_Database->rollbackTransaction();
|
|
348
|
|
|
349
|
$osC_MessageStack->add_session('header', ERROR_DB_ROWS_NOT_UPDATED, 'error');
|
|
350
|
}
|
|
351
|
|
hpdl
|
758
|
352
|
osc_redirect(osc_href_link_admin(FILENAME_CUSTOMERS, (isset($_GET['search']) ? 'search=' . $_GET['search'] . '&' : '') . 'page=' . $_GET['page'] . '&cID=' . $customer_id));
|
hpdl
|
1
|
353
|
}
|
|
354
|
|
|
355
|
break;
|
|
356
|
case 'deleteconfirm':
|
|
357
|
if (isset($_GET['cID']) && is_numeric($_GET['cID'])) {
|
|
358
|
$error = false;
|
|
359
|
|
|
360
|
$osC_Database->startTransaction();
|
|
361
|
|
|
362
|
if (isset($_POST['delete_reviews']) && ($_POST['delete_reviews'] == 'on')) {
|
|
363
|
$Qreviews = $osC_Database->query('delete from :table_reviews where customers_id = :customers_id');
|
|
364
|
$Qreviews->bindTable(':table_reviews', TABLE_REVIEWS);
|
|
365
|
$Qreviews->bindInt(':customers_id', $_GET['cID']);
|
|
366
|
$Qreviews->execute();
|
|
367
|
|
|
368
|
if ($osC_Database->isError()) {
|
|
369
|
$error = true;
|
|
370
|
}
|
|
371
|
} else {
|
|
372
|
$Qcheck = $osC_Database->query('select reviews_id from :table_reviews where customers_id = :customers_id limit 1');
|
|
373
|
$Qcheck->bindTable(':table_reviews', TABLE_REVIEWS);
|
|
374
|
$Qcheck->bindInt(':customers_id', $_GET['cID']);
|
|
375
|
$Qcheck->execute();
|
|
376
|
|
|
377
|
if ($Qcheck->numberOfRows() > 0) {
|
|
378
|
$Qreviews = $osC_Database->query('update :table_reviews set customers_id = null where customers_id = :customers_id');
|
|
379
|
$Qreviews->bindTable(':table_reviews', TABLE_REVIEWS);
|
|
380
|
$Qreviews->bindInt(':customers_id', $_GET['cID']);
|
|
381
|
$Qreviews->execute();
|
|
382
|
|
|
383
|
if ($osC_Database->isError()) {
|
|
384
|
$error = true;
|
|
385
|
}
|
|
386
|
}
|
|
387
|
}
|
|
388
|
|
|
389
|
if ($error === false) {
|
|
390
|
$Qab = $osC_Database->query('delete from :table_address_book where customers_id = :customers_id');
|
|
391
|
$Qab->bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
|
|
392
|
$Qab->bindInt(':customers_id', $_GET['cID']);
|
|
393
|
$Qab->execute();
|
|
394
|
|
|
395
|
if ($osC_Database->isError()) {
|
|
396
|
$error = true;
|
|
397
|
}
|
|
398
|
}
|
|
399
|
|
|
400
|
if ($error === false) {
|
|
401
|
$Qcustomers = $osC_Database->query('delete from :table_customers where customers_id = :customers_id');
|
|
402
|
$Qcustomers->bindTable(':table_customers', TABLE_CUSTOMERS);
|
|
403
|
$Qcustomers->bindInt(':customers_id', $_GET['cID']);
|
|
404
|
$Qcustomers->execute();
|
|
405
|
|
|
406
|
if ($osC_Database->isError()) {
|
|
407
|
$error = true;
|
|
408
|
}
|
|
409
|
}
|
|
410
|
|
|
411
|
if ($error === false) {
|
|
412
|
$Qcb = $osC_Database->query('delete from :table_customers_basket where customers_id = :customers_id');
|
|
413
|
$Qcb->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET);
|
|
414
|
$Qcb->bindInt(':customers_id', $_GET['cID']);
|
|
415
|
$Qcb->execute();
|
|
416
|
|
|
417
|
if ($osC_Database->isError()) {
|
|
418
|
$error = true;
|
|
419
|
}
|
|
420
|
}
|
|
421
|
|
|
422
|
if ($error === false) {
|
|
423
|
$Qpn = $osC_Database->query('delete from :table_products_notifications where customers_id = :customers_id');
|
|
424
|
$Qpn->bindTable(':table_products_notifications', TABLE_PRODUCTS_NOTIFICATIONS);
|
|
425
|
$Qpn->bindInt(':customers_id', $_GET['cID']);
|
|
426
|
$Qpn->execute();
|
|
427
|
|
|
428
|
if ($osC_Database->isError()) {
|
|
429
|
$error = true;
|
|
430
|
}
|
|
431
|
}
|
|
432
|
|
|
433
|
if ($error === false) {
|
|
434
|
$Qwho = $osC_Database->query('delete from :table_whos_online where customer_id = :customer_id');
|
|
435
|
$Qwho->bindTable(':table_whos_online', TABLE_WHOS_ONLINE);
|
|
436
|
$Qwho->bindInt(':customer_id', $_GET['cID']);
|
|
437
|
$Qwho->execute();
|
|
438
|
|
|
439
|
if ($osC_Database->isError()) {
|
|
440
|
$error = true;
|
|
441
|
}
|
|
442
|
}
|
|
443
|
|
|
444
|
if ($error === false) {
|
|
445
|
$osC_Database->commitTransaction();
|
|
446
|
|
|
447
|
$osC_MessageStack->add_session('header', SUCCESS_DB_ROWS_UPDATED, 'success');
|
|
448
|
} else {
|
|
449
|
$osC_Database->rollbackTransaction();
|
|
450
|
|
|
451
|
$osC_MessageStack->add_session('header', ERROR_DB_ROWS_NOT_UPDATED, 'error');
|
|
452
|
}
|
|
453
|
}
|
|
454
|
|
hpdl
|
758
|
455
|
osc_redirect(osc_href_link_admin(FILENAME_CUSTOMERS, (isset($_GET['search']) ? 'search=' . $_GET['search'] . '&' : '') . 'page=' . $_GET['page']));
|
hpdl
|
1
|
456
|
break;
|
|
457
|
}
|
|
458
|
}
|
|
459
|
|
|
460
|
switch ($action) {
|
|
461
|
case 'cEdit':
|
|
462
|
case 'cNew':
|
|
463
|
case 'save': $page_contents = 'customers_edit.php'; break;
|
|
464
|
default: $page_contents = 'customers.php';
|
|
465
|
}
|
|
466
|
|
|
467
|
require('templates/default.php');
|
|
468
|
|
|
469
|
require('includes/application_bottom.php');
|
|
470
|
?>
|