hpdl
|
1
|
1
|
<?php
|
|
2
|
/*
|
hpdl
|
121
|
3
|
$Id: order.php 1862 2009-03-06 23:34:07Z hpdl $
|
hpdl
|
1
|
4
|
|
|
5
|
osCommerce, Open Source E-Commerce Solutions
|
|
6
|
http://www.oscommerce.com
|
|
7
|
|
hpdl
|
1374
|
8
|
Copyright (c) 2007 osCommerce
|
hpdl
|
1
|
9
|
|
hpdl
|
1498
|
10
|
This program is free software; you can redistribute it and/or modify
|
|
11
|
it under the terms of the GNU General Public License v2 (1991)
|
|
12
|
as published by the Free Software Foundation.
|
hpdl
|
1
|
13
|
*/
|
|
14
|
|
|
15
|
class osC_Order {
|
|
16
|
// private variables
|
|
17
|
var $_valid_order;
|
|
18
|
|
|
19
|
// class constructor
|
|
20
|
function osC_Order($order_id = '') {
|
|
21
|
$this->_valid_order = false;
|
|
22
|
|
|
23
|
if (is_numeric($order_id)) {
|
|
24
|
$this->_getSummary($order_id);
|
|
25
|
}
|
|
26
|
}
|
|
27
|
|
|
28
|
// private methods
|
|
29
|
function _getSummary($order_id) {
|
|
30
|
global $osC_Database;
|
|
31
|
|
hpdl
|
757
|
32
|
$Qorder = $osC_Database->query('select * from :table_orders where orders_id = :orders_id');
|
hpdl
|
1
|
33
|
$Qorder->bindTable(':table_orders', TABLE_ORDERS);
|
|
34
|
$Qorder->bindInt(':orders_id', $order_id);
|
|
35
|
$Qorder->execute();
|
|
36
|
|
|
37
|
if ($Qorder->numberOfRows() === 1) {
|
|
38
|
$this->_valid_order = true;
|
|
39
|
|
|
40
|
$this->_order_id = $Qorder->valueInt('orders_id');
|
|
41
|
|
|
42
|
$this->_customer = array('name' => $Qorder->valueProtected('customers_name'),
|
|
43
|
'company' => $Qorder->valueProtected('customers_company'),
|
|
44
|
'street_address' => $Qorder->valueProtected('customers_street_address'),
|
|
45
|
'suburb' => $Qorder->valueProtected('customers_suburb'),
|
|
46
|
'city' => $Qorder->valueProtected('customers_city'),
|
|
47
|
'postcode' => $Qorder->valueProtected('customers_postcode'),
|
|
48
|
'state' => $Qorder->valueProtected('customers_state'),
|
hpdl
|
869
|
49
|
'zone_code' => $Qorder->value('customers_state_code'),
|
|
50
|
'country_title' => $Qorder->value('customers_country'),
|
hpdl
|
757
|
51
|
'country_iso2' => $Qorder->value('customers_country_iso2'),
|
|
52
|
'country_iso3' => $Qorder->value('customers_country_iso3'),
|
|
53
|
'format' => $Qorder->value('customers_address_format'),
|
hpdl
|
1
|
54
|
'telephone' => $Qorder->valueProtected('customers_telephone'),
|
|
55
|
'email_address' => $Qorder->valueProtected('customers_email_address'));
|
|
56
|
|
|
57
|
$this->_delivery = array('name' => $Qorder->valueProtected('delivery_name'),
|
|
58
|
'company' => $Qorder->valueProtected('delivery_company'),
|
|
59
|
'street_address' => $Qorder->valueProtected('delivery_street_address'),
|
|
60
|
'suburb' => $Qorder->valueProtected('delivery_suburb'),
|
|
61
|
'city' => $Qorder->valueProtected('delivery_city'),
|
|
62
|
'postcode' => $Qorder->valueProtected('delivery_postcode'),
|
|
63
|
'state' => $Qorder->valueProtected('delivery_state'),
|
hpdl
|
869
|
64
|
'zone_code' => $Qorder->value('delivery_state_code'),
|
|
65
|
'country_title' => $Qorder->value('delivery_country'),
|
hpdl
|
757
|
66
|
'country_iso2' => $Qorder->value('delivery_country_iso2'),
|
|
67
|
'country_iso3' => $Qorder->value('delivery_country_iso3'),
|
|
68
|
'format' => $Qorder->value('delivery_address_format'));
|
hpdl
|
1
|
69
|
|
|
70
|
$this->_billing = array('name' => $Qorder->valueProtected('billing_name'),
|
|
71
|
'company' => $Qorder->valueProtected('billing_company'),
|
|
72
|
'street_address' => $Qorder->valueProtected('billing_street_address'),
|
|
73
|
'suburb' => $Qorder->valueProtected('billing_suburb'),
|
|
74
|
'city' => $Qorder->valueProtected('billing_city'),
|
|
75
|
'postcode' => $Qorder->valueProtected('billing_postcode'),
|
|
76
|
'state' => $Qorder->valueProtected('billing_state'),
|
hpdl
|
869
|
77
|
'zone_code' => $Qorder->value('billing_state_code'),
|
|
78
|
'country_title' => $Qorder->value('billing_country'),
|
hpdl
|
757
|
79
|
'country_iso2' => $Qorder->value('billing_country_iso2'),
|
|
80
|
'country_iso3' => $Qorder->value('billing_country_iso3'),
|
|
81
|
'format' => $Qorder->value('billing_address_format'));
|
hpdl
|
1
|
82
|
|
|
83
|
$this->_payment_method = $Qorder->value('payment_method');
|
hpdl
|
554
|
84
|
$this->_payment_module = $Qorder->value('payment_module');
|
hpdl
|
1
|
85
|
|
|
86
|
$this->_currency = array('code' => $Qorder->value('currency'),
|
|
87
|
'value' => $Qorder->value('currency_value'));
|
|
88
|
|
|
89
|
$this->_date_purchased = $Qorder->value('date_purchased');
|
|
90
|
$this->_last_modified = $Qorder->value('last_modified');
|
|
91
|
|
|
92
|
$this->_status_id = $Qorder->value('orders_status');
|
|
93
|
}
|
|
94
|
}
|
|
95
|
|
|
96
|
function _getStatus() {
|
hpdl
|
121
|
97
|
global $osC_Database, $osC_Language;
|
hpdl
|
1
|
98
|
|
|
99
|
$Qstatus = $osC_Database->query('select orders_status_name from :table_orders_status where orders_status_id = :orders_status_id and language_id = :language_id');
|
|
100
|
$Qstatus->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
|
|
101
|
$Qstatus->bindInt(':orders_status_id', $this->_status_id);
|
|
102
|
|
hpdl
|
121
|
103
|
/* HPDL - DEFAULT_LANGUAGE is the language code, not the language id */
|
hpdl
|
365
|
104
|
// $Qstatus->bindInt(':language_id', (isset($_SESSION['languages_id']) ? $_SESSION['languages_id'] : DEFAULT_LANGUAGE));
|
hpdl
|
121
|
105
|
$Qstatus->bindInt(':language_id', $osC_Language->getID());
|
hpdl
|
1
|
106
|
$Qstatus->execute();
|
|
107
|
|
|
108
|
if ($Qstatus->numberOfRows() === 1) {
|
|
109
|
$this->_status = $Qstatus->value('orders_status_name');
|
|
110
|
} else {
|
|
111
|
$this->_status = $this->_status_id;
|
|
112
|
}
|
|
113
|
}
|
|
114
|
|
|
115
|
function _getStatusHistory() {
|
hpdl
|
121
|
116
|
global $osC_Database, $osC_Language;
|
hpdl
|
1
|
117
|
|
|
118
|
$history_array = array();
|
|
119
|
|
|
120
|
$Qhistory = $osC_Database->query('select osh.orders_status_id, osh.date_added, osh.customer_notified, osh.comments, os.orders_status_name from :table_orders_status_history osh left join :table_orders_status os on (osh.orders_status_id = os.orders_status_id and os.language_id = :language_id) where osh.orders_id = :orders_id order by osh.date_added');
|
|
121
|
$Qhistory->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY);
|
|
122
|
$Qhistory->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
|
|
123
|
|
hpdl
|
121
|
124
|
/* HPDL - DEFAULT_LANGUAGE is the language code, not the language id */
|
hpdl
|
365
|
125
|
// $Qstatus->bindInt(':language_id', (isset($_SESSION['languages_id']) ? $_SESSION['languages_id'] : DEFAULT_LANGUAGE));
|
hpdl
|
121
|
126
|
$Qhistory->bindInt(':language_id', $osC_Language->getID());
|
hpdl
|
1
|
127
|
|
|
128
|
$Qhistory->bindInt(':orders_id', $this->_order_id);
|
|
129
|
$Qhistory->execute();
|
|
130
|
|
|
131
|
while ($Qhistory->next()) {
|
|
132
|
$history_array[] = array('status_id' => $Qhistory->valueInt('orders_status_id'),
|
|
133
|
'status' => $Qhistory->value('orders_status_name'),
|
|
134
|
'date_added' => $Qhistory->value('date_added'),
|
|
135
|
'customer_notified' => $Qhistory->valueInt('customer_notified'),
|
|
136
|
'comment' => $Qhistory->valueProtected('comments'));
|
|
137
|
}
|
|
138
|
|
|
139
|
$this->_status_history = $history_array;
|
|
140
|
}
|
|
141
|
|
hpdl
|
554
|
142
|
function _getTransactionHistory() {
|
|
143
|
global $osC_Database, $osC_Language;
|
|
144
|
|
|
145
|
$this->_transaction_history = array();
|
|
146
|
|
|
147
|
$Qhistory = $osC_Database->query('select oth.transaction_code, oth.transaction_return_value, oth.transaction_return_status, oth.date_added, ots.status_name from :table_orders_transactions_history oth left join :table_orders_transactions_status ots on (oth.transaction_code = ots.id and ots.language_id = :language_id) where oth.orders_id = :orders_id order by oth.date_added');
|
|
148
|
$Qhistory->bindTable(':table_orders_transactions_history', TABLE_ORDERS_TRANSACTIONS_HISTORY);
|
|
149
|
$Qhistory->bindTable(':table_orders_transactions_status', TABLE_ORDERS_TRANSACTIONS_STATUS);
|
|
150
|
$Qhistory->bindInt(':language_id', $osC_Language->getID());
|
|
151
|
$Qhistory->bindInt(':orders_id', $this->_order_id);
|
|
152
|
$Qhistory->execute();
|
|
153
|
|
|
154
|
while ($Qhistory->next()) {
|
|
155
|
$this->_transaction_history[] = array('status_id' => $Qhistory->valueInt('transaction_code'),
|
|
156
|
'status' => $Qhistory->value('status_name'),
|
|
157
|
'return_value' => $Qhistory->valueProtected('transaction_return_value'),
|
|
158
|
'return_status' => $Qhistory->valueInt('transaction_return_status'),
|
|
159
|
'date_added' => $Qhistory->value('date_added'));
|
|
160
|
}
|
|
161
|
}
|
|
162
|
|
|
163
|
function _getPostTransactionActions() {
|
|
164
|
global $osC_Database, $osC_Language;
|
|
165
|
|
|
166
|
$this->_post_transaction_actions = array();
|
|
167
|
|
|
168
|
if (file_exists('includes/modules/payment/' . $this->_payment_module . '.php')) {
|
|
169
|
include('includes/classes/payment.php');
|
|
170
|
include('includes/modules/payment/' . $this->_payment_module . '.php');
|
|
171
|
|
|
172
|
if (call_user_func(array('osC_Payment_' . $this->_payment_module, 'isInstalled')) === true) {
|
|
173
|
$trans_array = array();
|
|
174
|
|
|
175
|
foreach ($this->getTransactionHistory() as $history) {
|
|
176
|
if ($history['return_status'] === 1) {
|
|
177
|
$trans_array[] = $history['status_id'];
|
|
178
|
}
|
|
179
|
}
|
|
180
|
|
|
181
|
$transactions = call_user_func(array('osC_Payment_' . $this->_payment_module, 'getPostTransactionActions'), $trans_array);
|
|
182
|
|
|
183
|
if (is_array($transactions) && (empty($transactions) === false)) {
|
|
184
|
$Qactions = $osC_Database->query('select id, status_name from :table_orders_transactions_status where language_id = :language_id and id in :id order by status_name');
|
|
185
|
$Qactions->bindTable(':table_orders_transactions_status', TABLE_ORDERS_TRANSACTIONS_STATUS);
|
|
186
|
$Qactions->bindInt(':language_id', $osC_Language->getID());
|
|
187
|
$Qactions->bindRaw(':id', '(' . implode(', ', array_keys($transactions)) . ')');
|
|
188
|
$Qactions->execute();
|
|
189
|
|
|
190
|
$trans_code_array = array();
|
|
191
|
|
|
192
|
while ($Qactions->next()) {
|
|
193
|
$this->_post_transaction_actions[] = array('id' => $transactions[$Qactions->valueInt('id')],
|
|
194
|
'text' => $Qactions->value('status_name'));
|
|
195
|
}
|
|
196
|
}
|
|
197
|
}
|
|
198
|
}
|
|
199
|
}
|
|
200
|
|
hpdl
|
1
|
201
|
function _getProducts() {
|
|
202
|
global $osC_Database;
|
|
203
|
|
|
204
|
$products_array = array();
|
|
205
|
$key = 0;
|
|
206
|
|
hpdl
|
1862
|
207
|
$Qproducts = $osC_Database->query('select orders_products_id, products_name, products_model, products_price, products_tax, products_quantity from :table_orders_products where orders_id = :orders_id');
|
hpdl
|
1
|
208
|
$Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);
|
|
209
|
$Qproducts->bindInt(':orders_id', $this->_order_id);
|
|
210
|
$Qproducts->execute();
|
|
211
|
|
|
212
|
while ($Qproducts->next()) {
|
|
213
|
$products_array[$key] = array('quantity' => $Qproducts->valueInt('products_quantity'),
|
|
214
|
'name' => $Qproducts->value('products_name'),
|
|
215
|
'model' => $Qproducts->value('products_model'),
|
|
216
|
'tax' => $Qproducts->value('products_tax'),
|
hpdl
|
1862
|
217
|
'price' => $Qproducts->value('products_price'));
|
hpdl
|
1
|
218
|
|
hpdl
|
1862
|
219
|
$Qvariants = $osC_Database->query('select group_title, value_title from :table_orders_products_variants where orders_id = :orders_id and orders_products_id = :orders_products_id order by id');
|
|
220
|
$Qvariants->bindTable(':table_orders_products_variants', TABLE_ORDERS_PRODUCTS_VARIANTS);
|
|
221
|
$Qvariants->bindInt(':orders_id', $this->_order_id);
|
|
222
|
$Qvariants->bindInt(':orders_products_id', $Qproducts->valueInt('orders_products_id'));
|
|
223
|
$Qvariants->execute();
|
hpdl
|
1
|
224
|
|
hpdl
|
1862
|
225
|
if ( $Qvariants->numberOfRows() > 0 ) {
|
|
226
|
while ( $Qvariants->next() ) {
|
|
227
|
$products_array[$key]['attributes'][] = array('option' => $Qvariants->value('group_title'),
|
|
228
|
'value' => $Qvariants->value('value_title'));
|
hpdl
|
1
|
229
|
}
|
|
230
|
}
|
|
231
|
|
|
232
|
$key++;
|
|
233
|
}
|
|
234
|
|
|
235
|
$this->_products = $products_array;
|
|
236
|
}
|
|
237
|
|
|
238
|
function _getTotals() {
|
|
239
|
global $osC_Database;
|
|
240
|
|
|
241
|
$totals_array = array();
|
|
242
|
|
|
243
|
$Qtotals = $osC_Database->query('select title, text, value, class from :table_orders_total where orders_id = :orders_id order by sort_order');
|
|
244
|
$Qtotals->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL);
|
|
245
|
$Qtotals->bindInt(':orders_id', $this->_order_id);
|
|
246
|
$Qtotals->execute();
|
|
247
|
|
|
248
|
while ($Qtotals->next()) {
|
|
249
|
$totals_array[] = array('title' => $Qtotals->value('title'),
|
|
250
|
'text' => $Qtotals->value('text'),
|
|
251
|
'value' => $Qtotals->value('value'),
|
|
252
|
'class' => $Qtotals->value('class'));
|
|
253
|
}
|
|
254
|
|
|
255
|
$this->_totals = $totals_array;
|
|
256
|
}
|
|
257
|
|
|
258
|
// public methods
|
|
259
|
function isValid() {
|
|
260
|
if ($this->_valid_order === true) {
|
|
261
|
return true;
|
|
262
|
} else {
|
|
263
|
return false;
|
|
264
|
}
|
|
265
|
}
|
|
266
|
|
|
267
|
function getOrderID() {
|
|
268
|
return $this->_order_id;
|
|
269
|
}
|
|
270
|
|
|
271
|
function getCustomer($id = '') {
|
|
272
|
if (empty($id)) {
|
|
273
|
return $this->_customer;
|
|
274
|
} elseif (isset($this->_customer[$id])) {
|
|
275
|
return $this->_customer[$id];
|
|
276
|
}
|
|
277
|
|
|
278
|
return false;
|
|
279
|
}
|
|
280
|
|
|
281
|
function getDelivery($id = '') {
|
|
282
|
if (empty($id)) {
|
|
283
|
return $this->_delivery;
|
|
284
|
} elseif (isset($this->_delivery[$id])) {
|
|
285
|
return $this->_delivery[$id];
|
|
286
|
}
|
|
287
|
|
|
288
|
return false;
|
|
289
|
}
|
|
290
|
|
|
291
|
function getBilling($id = '') {
|
|
292
|
if (empty($id)) {
|
|
293
|
return $this->_billing;
|
|
294
|
} elseif (isset($this->_billing[$id])) {
|
|
295
|
return $this->_billing[$id];
|
|
296
|
}
|
|
297
|
|
|
298
|
return false;
|
|
299
|
}
|
|
300
|
|
|
301
|
function getPaymentMethod() {
|
|
302
|
return $this->_payment_method;
|
|
303
|
}
|
|
304
|
|
hpdl
|
554
|
305
|
function getPaymentModule() {
|
|
306
|
return $this->_payment_module;
|
|
307
|
}
|
|
308
|
|
hpdl
|
1
|
309
|
function getCreditCardDetails($id = '') {
|
|
310
|
if (empty($id)) {
|
|
311
|
return $this->_credit_card;
|
|
312
|
} elseif (isset($this->_credit_card[$id])) {
|
|
313
|
return $this->_credit_card[$id];
|
|
314
|
}
|
|
315
|
|
|
316
|
return false;
|
|
317
|
}
|
|
318
|
|
|
319
|
function isValidCreditCard() {
|
|
320
|
if (!empty($this->_credit_card['owner']) && !empty($this->_credit_card['number']) && !empty($this->_credit_card['expires'])) {
|
|
321
|
return true;
|
|
322
|
}
|
|
323
|
|
|
324
|
return false;
|
|
325
|
}
|
|
326
|
|
|
327
|
function getCurrency($id = 'code') {
|
|
328
|
if (isset($this->_currency[$id])) {
|
|
329
|
return $this->_currency[$id];
|
|
330
|
}
|
|
331
|
|
|
332
|
return false;
|
|
333
|
}
|
|
334
|
|
|
335
|
function getCurrencyValue() {
|
|
336
|
return $this->getCurrency('value');
|
|
337
|
}
|
|
338
|
|
|
339
|
function getDateCreated() {
|
|
340
|
return $this->_date_purchased;
|
|
341
|
}
|
|
342
|
|
|
343
|
function getDateLastModified() {
|
|
344
|
return $this->_last_modified;
|
|
345
|
}
|
|
346
|
|
|
347
|
function getStatusID() {
|
|
348
|
return $this->_status_id;
|
|
349
|
}
|
|
350
|
|
|
351
|
function getStatus() {
|
|
352
|
if (!isset($this->_status)) {
|
|
353
|
$this->_getStatus();
|
|
354
|
}
|
|
355
|
|
|
356
|
return $this->_status;
|
|
357
|
}
|
|
358
|
|
|
359
|
function getNumberOfComments() {
|
|
360
|
$number_of_comments = 0;
|
|
361
|
|
|
362
|
if (!isset($this->_status_history)) {
|
|
363
|
$this->_getStatusHistory();
|
|
364
|
}
|
|
365
|
|
|
366
|
foreach ($this->_status_history as $status_history) {
|
|
367
|
if (!empty($status_history['comment'])) {
|
|
368
|
$number_of_comments++;
|
|
369
|
}
|
|
370
|
}
|
|
371
|
|
|
372
|
return $number_of_comments;
|
|
373
|
}
|
|
374
|
|
|
375
|
function getProducts() {
|
|
376
|
if (!isset($this->_products)) {
|
|
377
|
$this->_getProducts();
|
|
378
|
}
|
|
379
|
|
|
380
|
return $this->_products;
|
|
381
|
}
|
|
382
|
|
|
383
|
function getNumberOfProducts() {
|
|
384
|
if (!isset($this->_products)) {
|
|
385
|
$this->_getProducts();
|
|
386
|
}
|
|
387
|
|
|
388
|
return sizeof($this->_products);
|
|
389
|
}
|
|
390
|
|
|
391
|
function getNumberOfItems() {
|
|
392
|
$number_of_items = 0;
|
|
393
|
|
|
394
|
if (!isset($this->_products)) {
|
|
395
|
$this->_getProducts();
|
|
396
|
}
|
|
397
|
|
|
398
|
foreach ($this->_products as $product) {
|
|
399
|
$number_of_items += $product['quantity'];
|
|
400
|
}
|
|
401
|
|
|
402
|
return $number_of_items;
|
|
403
|
}
|
|
404
|
|
hpdl
|
443
|
405
|
function getTotal($id = 'total') {
|
hpdl
|
1
|
406
|
if (!isset($this->_totals)) {
|
|
407
|
$this->_getTotals();
|
|
408
|
}
|
|
409
|
|
|
410
|
foreach ($this->_totals as $total) {
|
|
411
|
if ($total['class'] == $id) {
|
|
412
|
return strip_tags($total['text']);
|
|
413
|
}
|
|
414
|
}
|
|
415
|
|
|
416
|
return false;
|
|
417
|
}
|
|
418
|
|
|
419
|
function getTotals() {
|
|
420
|
if (!isset($this->_totals)) {
|
|
421
|
$this->_getTotals();
|
|
422
|
}
|
|
423
|
|
|
424
|
return $this->_totals;
|
|
425
|
}
|
|
426
|
|
|
427
|
function getStatusHistory() {
|
|
428
|
if (!isset($this->_status_history)) {
|
|
429
|
$this->_getStatusHistory();
|
|
430
|
}
|
|
431
|
|
|
432
|
return $this->_status_history;
|
|
433
|
}
|
hpdl
|
554
|
434
|
|
|
435
|
function getTransactionHistory() {
|
|
436
|
if (!isset($this->_transaction_history)) {
|
|
437
|
$this->_getTransactionHistory();
|
|
438
|
}
|
|
439
|
|
|
440
|
return $this->_transaction_history;
|
|
441
|
}
|
|
442
|
|
|
443
|
function getPostTransactionActions() {
|
|
444
|
if (!isset($this->_post_transaction_actions)) {
|
|
445
|
$this->_getPostTransactionActions();
|
|
446
|
}
|
|
447
|
|
|
448
|
return $this->_post_transaction_actions;
|
|
449
|
}
|
|
450
|
|
|
451
|
function hasPostTransactionActions() {
|
|
452
|
if (!isset($this->_post_transaction_actions)) {
|
|
453
|
$this->_getPostTransactionActions();
|
|
454
|
}
|
|
455
|
|
|
456
|
return !empty($this->_post_transaction_actions);
|
|
457
|
}
|
hpdl
|
758
|
458
|
|
|
459
|
function delete($id, $restock = false) {
|
|
460
|
global $osC_Database;
|
|
461
|
|
|
462
|
$error = false;
|
|
463
|
|
|
464
|
$osC_Database->startTransaction();
|
|
465
|
|
|
466
|
if ($restock === true) {
|
|
467
|
$Qproducts = $osC_Database->query('select products_id, products_quantity from :table_orders_products where orders_id = :orders_id');
|
|
468
|
$Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);
|
|
469
|
$Qproducts->bindInt(':orders_id', $id);
|
|
470
|
$Qproducts->execute();
|
|
471
|
|
|
472
|
while ($Qproducts->next()) {
|
|
473
|
$Qupdate = $osC_Database->query('update :table_products set products_quantity = products_quantity + :products_quantity, products_ordered = products_ordered - :products_ordered where products_id = :products_id');
|
|
474
|
$Qupdate->bindTable(':table_products', TABLE_PRODUCTS);
|
|
475
|
$Qupdate->bindInt(':products_quantity', $Qproducts->valueInt('products_quantity'));
|
|
476
|
$Qupdate->bindInt(':products_ordered', $Qproducts->valueInt('products_quantity'));
|
|
477
|
$Qupdate->bindInt(':products_id', $Qproducts->valueInt('products_id'));
|
hpdl
|
1374
|
478
|
$Qupdate->setLogging($_SESSION['module'], $id);
|
hpdl
|
758
|
479
|
$Qupdate->execute();
|
|
480
|
|
|
481
|
if ($osC_Database->isError() === true) {
|
|
482
|
$error = true;
|
|
483
|
break;
|
|
484
|
}
|
|
485
|
|
|
486
|
$Qcheck = $osC_Database->query('select products_quantity from :table_products where products_id = :products_id and products_Status = 0');
|
|
487
|
$Qcheck->bindTable(':table_products', TABLE_PRODUCTS);
|
|
488
|
$Qcheck->bindInt(':products_id', $Qproducts->valueInt('products_id'));
|
|
489
|
$Qcheck->execute();
|
|
490
|
|
|
491
|
if (($Qcheck->numberOfRows() === 1) && ($Qcheck->valueInt('products_quantity') > 0)) {
|
|
492
|
$Qstatus = $osC_Database->query('update :table_products set products_status = 1 where products_id = :products_id');
|
|
493
|
$Qstatus->bindTable(':table_products', TABLE_PRODUCTS);
|
|
494
|
$Qstatus->bindInt(':products_id', $Qproducts->valueInt('products_id'));
|
hpdl
|
1374
|
495
|
$Qstatus->setLogging($_SESSION['module'], $id);
|
hpdl
|
758
|
496
|
$Qstatus->execute();
|
|
497
|
|
|
498
|
if ($osC_Database->isError() === true) {
|
|
499
|
$error = true;
|
|
500
|
break;
|
|
501
|
}
|
|
502
|
}
|
|
503
|
}
|
|
504
|
}
|
|
505
|
|
|
506
|
if ($error === false) {
|
hpdl
|
1862
|
507
|
$Qvariants = $osC_Database->query('delete from :table_orders_products_variants where orders_id = :orders_id');
|
|
508
|
$Qvariants->bindTable(':table_orders_products_variants', TABLE_ORDERS_PRODUCTS_VARIANTS);
|
|
509
|
$Qvariants->bindInt(':orders_id', $id);
|
|
510
|
$Qvariants->setLogging($_SESSION['module'], $id);
|
|
511
|
$Qvariants->execute();
|
hpdl
|
758
|
512
|
|
|
513
|
if ($osC_Database->isError() === true) {
|
|
514
|
$error = true;
|
|
515
|
}
|
|
516
|
}
|
|
517
|
|
|
518
|
if ($error === false) {
|
|
519
|
$Qop = $osC_Database->query('delete from :table_orders_products where orders_id = :orders_id');
|
|
520
|
$Qop->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);
|
|
521
|
$Qop->bindInt(':orders_id', $id);
|
hpdl
|
1374
|
522
|
$Qop->setLogging($_SESSION['module'], $id);
|
hpdl
|
758
|
523
|
$Qop->execute();
|
|
524
|
|
|
525
|
if ($osC_Database->isError() === true) {
|
|
526
|
$error = true;
|
|
527
|
}
|
|
528
|
}
|
|
529
|
|
|
530
|
if ($error === false) {
|
|
531
|
$Qosh = $osC_Database->query('delete from :table_orders_transactions_history where orders_id = :orders_id');
|
|
532
|
$Qosh->bindTable(':table_orders_transactions_history', TABLE_ORDERS_TRANSACTIONS_HISTORY);
|
|
533
|
$Qosh->bindInt(':orders_id', $id);
|
hpdl
|
1374
|
534
|
$Qosh->setLogging($_SESSION['module'], $id);
|
hpdl
|
758
|
535
|
$Qosh->execute();
|
|
536
|
|
|
537
|
if ($osC_Database->isError() === true) {
|
|
538
|
$error = true;
|
|
539
|
}
|
|
540
|
}
|
|
541
|
|
|
542
|
if ($error === false) {
|
|
543
|
$Qosh = $osC_Database->query('delete from :table_orders_status_history where orders_id = :orders_id');
|
|
544
|
$Qosh->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY);
|
|
545
|
$Qosh->bindInt(':orders_id', $id);
|
hpdl
|
1374
|
546
|
$Qosh->setLogging($_SESSION['module'], $id);
|
hpdl
|
758
|
547
|
$Qosh->execute();
|
|
548
|
|
|
549
|
if ($osC_Database->isError() === true) {
|
|
550
|
$error = true;
|
|
551
|
}
|
|
552
|
}
|
|
553
|
|
|
554
|
if ($error === false) {
|
|
555
|
$Qot = $osC_Database->query('delete from :table_orders_total where orders_id = :orders_id');
|
|
556
|
$Qot->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL);
|
|
557
|
$Qot->bindInt(':orders_id', $id);
|
hpdl
|
1374
|
558
|
$Qot->setLogging($_SESSION['module'], $id);
|
hpdl
|
758
|
559
|
$Qot->execute();
|
|
560
|
|
|
561
|
if ($osC_Database->isError() === true) {
|
|
562
|
$error = true;
|
|
563
|
}
|
|
564
|
}
|
|
565
|
|
|
566
|
if ($error === false) {
|
|
567
|
$Qo = $osC_Database->query('delete from :table_orders where orders_id = :orders_id');
|
|
568
|
$Qo->bindTable(':table_orders', TABLE_ORDERS);
|
|
569
|
$Qo->bindInt(':orders_id', $id);
|
hpdl
|
1374
|
570
|
$Qo->setLogging($_SESSION['module'], $id);
|
hpdl
|
758
|
571
|
$Qo->execute();
|
|
572
|
|
|
573
|
if ($osC_Database->isError() === true) {
|
|
574
|
$error = true;
|
|
575
|
}
|
|
576
|
}
|
|
577
|
|
|
578
|
if ($error === false) {
|
|
579
|
$osC_Database->commitTransaction();
|
|
580
|
|
|
581
|
return true;
|
|
582
|
} else {
|
|
583
|
$osC_Database->rollbackTransaction();
|
|
584
|
|
|
585
|
return false;
|
|
586
|
}
|
|
587
|
}
|
hpdl
|
1
|
588
|
}
|
|
589
|
?>
|