[go: up one dir, main page]

Menu

[r19]: / admin / c_orders.php  Maximize  Restore  History

Download this file

1683 lines (1492 with data), 82.6 kB

   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
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
<?php
/*
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
Written by Jonathan Hilgeman of SiteCreative.com (osc@sitecreative.com)
Version History
*/
require('includes/application_top.php');
require(DIR_WS_FUNCTIONS . 'c_orders.php');
require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();
include(DIR_WS_CLASSES . 'order.php');
// New "Status History" table has different format.
$OldNewStatusValues = (tep_field_exists(TABLE_ORDERS_STATUS_HISTORY, "old_value") && tep_field_exists(TABLE_ORDERS_STATUS_HISTORY, "new_value"));
$CommentsWithStatus = tep_field_exists(TABLE_ORDERS_STATUS_HISTORY, "comments");
$SeparateBillingFields = tep_field_exists(TABLE_ORDERS, "billing_name");
$order_updated = false;
// Optional Tax Rate/Percent
$AddShippingTax = "0.0"; // e.g. shipping tax of 17.5% is "17.5"
$orders_statuses = array();
$orders_status_array = array();
$orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "'");
while ($orders_status = tep_db_fetch_array($orders_status_query)) {
$orders_statuses[] = array('id' => $orders_status['orders_status_id'],
'text' => $orders_status['orders_status_name']);
$orders_status_array[$orders_status['orders_status_id']] = $orders_status['orders_status_name'];
}
//get shipping method
$orders_ship_method = array();
$orders_ship_method_array = array();
$orders_ship_method_query = tep_db_query("select ship_method from orders_ship_methods where ship_method_language = '" . (int)$languages_id . "'");
while ($orders_ship_methods = tep_db_fetch_array($orders_ship_method_query)) {
$orders_ship_method[] = array('id' => $orders_ship_methods['ship_method'],
'text' => $orders_ship_methods['ship_method']);
$orders_ship_method_array[$orders_ship_methods['ship_method']] = $orders_ship_methods['ship_method'];
}
//get pay method
$orders_pay_method = array();
$orders_pay_method_array = array();
$orders_pay_method_query = tep_db_query("select pay_method from orders_pay_methods where pay_method_language = '" . (int)$languages_id . "'");
while ($orders_pay_methods = tep_db_fetch_array($orders_pay_method_query)) {
$orders_pay_method[] = array('id' => $orders_pay_methods['pay_method'],
'text' => $orders_pay_methods['pay_method']);
$orders_pay_method_array[$orders_pay_methods['pay_method']] = $orders_pay_methods['pay_method'];
}
// begin action
$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : 'edit');
if (tep_not_null($action)) {
switch ($action) {
// Update Order
case 'update_order':
$oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
$order = new order($oID);
$status = tep_db_prepare_input($HTTP_POST_VARS['status']);
$comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
// Update Order Info
$UpdateOrders = "update " . TABLE_ORDERS . " set
customers_name = '" . tep_db_input(stripslashes($update_customer_name)) . "',
customers_company = '" . tep_db_input(stripslashes($update_customer_company)) . "',
customers_street_address = '" . tep_db_input(stripslashes($update_customer_street_address)) . "',
customers_suburb = '" . tep_db_input(stripslashes($update_customer_suburb)) . "',
customers_city = '" . tep_db_input(stripslashes($update_customer_city)) . "',
customers_state = '" . tep_db_input(stripslashes($update_customer_state)) . "',
customers_postcode = '" . tep_db_input($update_customer_postcode) . "',
customers_country = '" . tep_db_input(stripslashes($update_customer_country)) . "',
customers_telephone = '" . tep_db_input($update_customer_telephone) . "',
customers_email_address = '" . tep_db_input($update_customer_email_address) . "',";
if($SeparateBillingFields)
{
$UpdateOrders .= "billing_name = '" . tep_db_input(stripslashes($update_billing_name)) . "',
billing_company = '" . tep_db_input(stripslashes($update_billing_company)) . "',
billing_street_address = '" . tep_db_input(stripslashes($update_billing_street_address)) . "',
billing_suburb = '" . tep_db_input(stripslashes($update_billing_suburb)) . "',
billing_city = '" . tep_db_input(stripslashes($update_billing_city)) . "',
billing_state = '" . tep_db_input(stripslashes($update_billing_state)) . "',
billing_postcode = '" . tep_db_input($update_billing_postcode) . "',
billing_country = '" . tep_db_input(stripslashes($update_billing_country)) . "',";
}
$UpdateOrders .= "delivery_name = '" . tep_db_input(stripslashes($update_delivery_name)) . "',
delivery_company = '" . tep_db_input(stripslashes($update_delivery_company)) . "',
delivery_street_address = '" . tep_db_input(stripslashes($update_delivery_street_address)) . "',
delivery_suburb = '" . tep_db_input(stripslashes($update_delivery_suburb)) . "',
delivery_city = '" . tep_db_input(stripslashes($update_delivery_city)) . "',
delivery_state = '" . tep_db_input(stripslashes($update_delivery_state)) . "',
delivery_postcode = '" . tep_db_input($update_delivery_postcode) . "',
delivery_country = '" . tep_db_input(stripslashes($update_delivery_country)) . "',
payment_method = '" . tep_db_input($update_info_payment_method) . "',
account_name = '" . tep_db_input($account_name) . "',
account_number = '" . tep_db_input($account_number) . "',
po_number = '" . tep_db_input($po_number) . "',
cc_type = '" . tep_db_input($update_info_cc_type) . "',
cc_owner = '" . tep_db_input($update_info_cc_owner) . "',
cc_start = '" . tep_db_input($update_info_cc_start) . "',
cc_issue = '" . tep_db_input($update_info_cc_issue) . "',
last_modified = now(),";
// encrypt cc number begin
if ( (PAYMENT_CC_CRYPT == 'True') || (@ereg ("([0-9]{1})", $order->info['cc_number'])) ) {
$cc_number5 = $order->info['cc_number'];
}else if ( (PAYMENT_CC_CRYPT == 'True') && !(@ereg ("([0-9]{1})", $order->info['cc_number'])) ){
$cc_number5 = cc_decrypt($order->info['cc_number']);
}else{
$cc_number5 =$order->info['cc_number'];
}
if ($update_info_cc_number != $cc_number5){
if ( (PAYMENT_CC_CRYPT == 'True') && (@ereg ("([0-9]{1})", $update_info_cc_number)) ) {
$cc_number10 = cc_encrypt($update_info_cc_number);
}else if ( (PAYMENT_CC_CRYPT == 'True') && !(@ereg ("([0-9]{1})", $update_info_cc_number)) ){
$cc_number10 = $update_info_cc_number;
}else{
$cc_number10 =$update_info_cc_number;
}
$UpdateOrders .= " cc_number = '$cc_number10',";
}
//encrypt cc number end ;
// encrypt cc expire begin ;
if ( (PAYMENT_CC_CRYPT == 'True') || (@ereg ("([0-9]{1})", $order->info['cc_expires'])) ) {
$cc_expires5 = $order->info['cc_expires'];
}else if ( (PAYMENT_CC_CRYPT == 'True') && !(@ereg ("([0-9]{1})", $order->info['cc_expires'])) ){
$cc_expires5 = cc_decrypt($order->info['cc_expires']);
}else{
$cc_expires5 =$order->info['cc_expires'];
}
if ($update_info_cc_number != $cc_expires5){
if ( (PAYMENT_CC_CRYPT == 'True') && (@ereg ("([0-9]{1})", $update_info_cc_expires)) ) {
$cc_expires10 = cc_encrypt($update_info_cc_expires);
}else if ( (PAYMENT_CC_CRYPT == 'True') && !(@ereg ("([0-9]{1})", $update_info_cc_expires)) ){
$cc_expires10 = $update_info_cc_expires;
}else{
$cc_expires10 =$update_info_cc_expires;
}
$UpdateOrders .= " cc_expires = '$cc_expires10',";
}
//encrypt cc expire end
//ccv begin
if ( (PAYMENT_CC_CRYPT == 'True') || (@ereg ("([0-9]{1})", $order->info['cc_ccv'])) ) {
$cc_ccv5 = $order->info['cc_ccv'];
}else if ( (PAYMENT_CC_CRYPT == 'True') && !(@ereg ("([0-9]{1})", $order->info['cc_ccv'])) ){
$cc_ccv5 = cc_decrypt($order->info['cc_ccv']);
}else{
$cc_ccv5 =$order->info['cc_ccv'];
}
if ($update_info_cc_ccv != $cc_ccv5){
if ( (PAYMENT_CC_CRYPT == 'True') && (@ereg ("([0-9]{1})", $update_info_cc_ccv)) ) {
$cc_ccv10 = cc_encrypt($update_info_cc_ccv);
}else if ( (PAYMENT_CC_CRYPT == 'True') && !(@ereg ("([0-9]{1})", $update_info_cc_ccv)) ){
$cc_ccv10 = $update_info_cc_ccv;
}else{
$cc_ccv10 = $update_info_cc_ccv;
}
}
$UpdateOrders .= " cc_ccv = '$cc_ccv10' ";
//ccv end
$UpdateOrders .= " where orders_id = '" . tep_db_input($oID) . "' ";
tep_db_query($UpdateOrders);
$Query1 = "update orders set last_modified = now() where orders_id = '" . tep_db_input($oID) . "';";
tep_db_query($Query1);
$order_updated = true;
// status and comments
$status = tep_db_prepare_input($HTTP_POST_VARS['status']);
$comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
$check_status_query = tep_db_query("select customers_name, customers_email_address, orders_status, date_purchased from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
$check_status = tep_db_fetch_array($check_status_query);
// NOTE: you must post the order status to both the order, and order status history
if($CommentsWithStatus)
// always update date and time on order_status
//check to see if can download status change
if ( ($check_status['orders_status'] != $status) || $comments != '' || ($status ==DOWNLOADS_ORDERS_STATUS_UPDATED_VALUE) ) {
tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . tep_db_input($status) . "', last_modified = now() where orders_id = '" . (int)$oID . "'");
$check_status_query2 = tep_db_query("select customers_name, customers_email_address, orders_status, date_purchased from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
$check_status2 = tep_db_fetch_array($check_status_query2);
if ( $check_status2['orders_status']==DOWNLOADS_ORDERS_STATUS_UPDATED_VALUE ) {
tep_db_query("update " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " set download_maxdays = '" . tep_get_configuration_key_value('DOWNLOAD_MAX_DAYS') . "', download_count = '" . tep_get_configuration_key_value('DOWNLOAD_MAX_COUNT') . "' where orders_id = '" . (int)$oID . "'");
}
$customer_notified = '0';
//if notify = true then send email update
if (isset($HTTP_POST_VARS['notify']) && ($HTTP_POST_VARS['notify'] == 'on')) {
$notify_comments = '';
if (isset($HTTP_POST_VARS['notify_comments']) && ($HTTP_POST_VARS['notify_comments'] == 'on')) {
$notify_comments = sprintf(EMAIL_TEXT_COMMENTS_UPDATE, $comments) . "\n\n";
}
$email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' .
tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') . "\n" . EMAIL_TEXT_DATE_ORDERED .
' ' . tep_date_long($check_status['date_purchased']) . "\n\n" . $notify_comments .
sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]);
tep_mail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT, $email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
$customer_notified = '1';
}
tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) values ('" . (int)$oID . "', '" . tep_db_input($status) . "', now(), '" . tep_db_input($customer_notified) . "', '" . tep_db_input($comments) . "')");
$order_updated = true;
}
// check to see if there are products to update
if (count($update_products) > 0)
{
// Update Products
$RunningSubTotal = 0;
$RunningTax = 0;
// CWS EDIT (start) -- Check for existence of subtotals...
// Do pre-check for subtotal field existence
$ot_subtotal_found = false;
foreach($update_totals as $total_details)
{
extract($total_details,EXTR_PREFIX_ALL,"ot");
if($ot_class == "ot_subtotal")
{
$ot_subtotal_found = true;
break;
}
}
// CWS EDIT (end) -- Check for existence of subtotals...
foreach($update_products as $orders_products_id => $products_details)
{
// Update orders_products Table
//UPDATE_INVENTORY_QUANTITY_START##############################################################################################################
$order_query = tep_db_query("select products_id, products_quantity from " . TABLE_ORDERS_PRODUCTS . " where orders_products_id = '" . (int)$orders_products_id . "'");
if (tep_db_num_rows($order_query) > 0) {
$order_array = tep_db_fetch_array($order_query);
} else {
$order_array['products_quantity'] = 0;
}
if ($products_details["qty"] != $order_array['products_quantity']) {
$quantity_difference = (int)($products_details["qty"]) - (int)($order_array['products_quantity']);
$products_quantity = tep_db_fetch_array(tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$order_array['products_id'] . "'"));
$products_new_quantity = (int)$products_quantity['products_quantity'] - $quantity_difference;
$products_ordered = 0;
if ($order_array['products_quantity'] == 0) {
$products_ordered = 1;
}
tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = " . $products_new_quantity . ", products_ordered = products_ordered + " . (int)$products_ordered . " where products_id = '" . (int)$order_array['products_id'] . "'");
}
//UPDATE_INVENTORY_QUANTITY_END##############################################################################################################
if($products_details["qty"] > 0)
{
$Query = "update " . TABLE_ORDERS_PRODUCTS . " set
products_model = '" . $products_details["model"] . "',
products_name = '" . str_replace("'", "&#39;", $products_details["name"]) . "',
final_price = '" . $products_details["final_price"] . "',
products_tax = '" . $products_details["tax"] . "',
products_quantity = '" . $products_details["qty"] . "'
where orders_products_id = '$orders_products_id';";
tep_db_query($Query);
// Update Tax and Subtotals
$RunningSubTotal += $products_details["qty"] * $products_details["final_price"];
$RunningTax += (($products_details["tax"]/100) * ($products_details["qty"] * $products_details["final_price"]));
// Update Any Attributes
if(IsSet($products_details[attributes]))
{
foreach($products_details["attributes"] as $orders_products_attributes_id => $attributes_details)
{
$Query = "update " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " set
products_options = '" . $attributes_details["option"] . "',
products_options_values = '" . $attributes_details["value"] . "',
options_values_price = '" . $attributes_details["att_price"] . "',
price_prefix = '" . $attributes_details["att_prefix"] . "',
products_options_id = '" . $attributes_details["option_names"] . "',
products_options_values_id = '" . $attributes_details["value"] . "'
where orders_products_attributes_id = '$orders_products_attributes_id';";
tep_db_query($Query);
}
}
}
else
{
// 0 Quantity = Delete
$Query = "delete from " . TABLE_ORDERS_PRODUCTS . " where orders_products_id = '$orders_products_id';";
tep_db_query($Query);
$Query = "delete from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_products_id = '$orders_products_id';";
tep_db_query($Query);
}
}
// Shipping Tax
foreach($update_totals as $total_index => $total_details)
{
extract($total_details,EXTR_PREFIX_ALL,"ot");
if($ot_class == "ot_shipping")
{
$RunningTax += (($AddShippingTax / 100) * $ot_value);
}
}
// Update Totals
$RunningTotal = 0;
$sort_order = 0;
// Do pre-check for Tax field existence
$ot_tax_found = 0;
foreach($update_totals as $total_details)
{
extract($total_details,EXTR_PREFIX_ALL,"ot");
if($ot_class == "ot_tax")
{
$ot_tax_found = 1;
break;
}
}
foreach($update_totals as $total_index => $total_details)
{
extract($total_details,EXTR_PREFIX_ALL,"ot");
if( trim(strtolower($ot_title)) == "tax" || trim(strtolower($ot_title)) == "tax:" )
{
if($ot_class != "ot_tax" && $ot_tax_found == 0)
{
// Inserting Tax
$ot_class = "ot_tax";
$ot_value = "x"; // This gets updated in the next step
$ot_tax_found = 1;
}
}
if( trim($ot_title) && trim($ot_value) )
{
$sort_order++;
// Update ot_subtotal, ot_tax, and ot_total classes
if($ot_class == "ot_subtotal")
$ot_value = $RunningSubTotal;
if($ot_class == "ot_tax")
{
$ot_value = $RunningTax;
// print "ot_value = $ot_value<br>\n";
}
// CWS EDIT (start) -- Check for existence of subtotals...
if($ot_class == "ot_total")
{
$ot_value = $RunningTotal ;
if ( !$ot_subtotal_found )
{
// There was no subtotal on this order, lets add the running subtotal in.
$ot_value = $ot_value + $RunningSubTotal;
}
}
// CWS EDIT (end) -- Check for existence of subtotals...
// Set $ot_text (display-formatted value)
// $ot_text = "\$" . number_format($ot_value, 2, '.', ',');
$order = new order($oID);
$ot_text = $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']);
if($ot_class == "ot_total")
$ot_text = "<b>" . $ot_text . "</b>";
if($ot_total_id > 0)
{
// In Database Already - Update
$Query = "update " . TABLE_ORDERS_TOTAL . " set
title = '$ot_title',
text = '$ot_text',
value = '$ot_value',
sort_order = '$sort_order'
where orders_total_id = '$ot_total_id'";
tep_db_query($Query);
}
else
{
// New Insert
$Query = "insert into " . TABLE_ORDERS_TOTAL . " set
orders_id = '$oID',
title = '$ot_title',
text = '$ot_text',
value = '$ot_value',
class = '$ot_class',
sort_order = '$sort_order'";
tep_db_query($Query);
}
if ($ot_class == "ot_shipping" || $ot_class == "ot_lev_discount" || $ot_class == "ot_custom" || $ot_class == "ot_cod_fee") {
// Again, because products are calculated in terms of default currency, we need to align shipping, custom etc. values with default currency
$RunningTotal += $ot_value / $order->info['currency_value'];
} else if($ot_class == "ot_coupon" ||$ot_class == "ot_customer_discount" || $ot_class == "ot_discount" || $ot_class == "ot_gv"){
//subtract discounts
$RunningTotal -= $ot_value / $order->info['currency_value'];
}else{
if($ot_class != "ot_tax") {
$RunningTotal += $ot_value;
}else if ( DISPLAY_PRICE_WITH_TAX == 'false') {
$RunningTotal += $ot_value;
}
}
}
elseif (($ot_total_id > 0) && ($ot_class != "ot_shipping")) { // Delete Total Piece
// Delete Total Piece
$Query = "delete from " . TABLE_ORDERS_TOTAL . " where orders_total_id = '$ot_total_id'";
tep_db_query($Query);
}
}
}
if ($order_updated == true) {
$messageStack->add_session('search', SUCCESS_ORDER_UPDATED, 'success');
} else {
$messageStack->add_session('search', WARNING_ORDER_NOT_UPDATED, 'warning');
}
tep_redirect(tep_href_link(FILENAME_C_ORDERS, tep_get_all_get_params(array('action')) . 'oID=' . $HTTP_GET_VARS['oID'] . '&action=edit', 'SSL'));
break;
// Add a Product
case 'add_product':
if($step == 5) {
// Get Order Info
$oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
$order = new order($oID);
$AddedOptionsPrice = 0;
// Get Product Info
$InfoQuery = "select p.products_model,p.products_price,pd.products_name,p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id='$add_product_products_id' and p.products_id=pd.products_id";
$result = tep_db_query($InfoQuery);
$row = tep_db_fetch_array($result);
extract($row, EXTR_PREFIX_ALL, "p");
// risolviamo il bug delle specials
$rs_special = tep_db_query("select * from specials where products_id ='". $add_product_products_id."' and status = 1 " );
$special = tep_db_fetch_array($rs_special);
if ($special)
{
$p_products_price = $special['specials_new_products_price'];
}
// Following functions are defined at the bottom of this file
$CountryID = tep_get_country_id($order->delivery["country"]);
$ZoneID = tep_get_zone_id($CountryID, $order->delivery["state"]);
$ProductsTax = tep_get_tax_rate($p_products_tax_class_id, $CountryID, $ZoneID);
$Query = "insert into " . TABLE_ORDERS_PRODUCTS . " set
orders_id = $oID,
products_id = $add_product_products_id,
products_model = '$p_products_model',
products_name = '" . str_replace("'", "&#39;", $p_products_name) . "',
products_price = '$p_products_price',
final_price = '" . ($p_products_price + $AddedOptionsPrice) . "',
products_tax = '$ProductsTax',
products_quantity = $add_product_quantity;";
tep_db_query($Query);
$new_product_id = tep_db_insert_id();
//UPDATE_INVENTORY_QUANTITY_START##############################################################################################################
tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity - " . (int)$add_product_quantity . ", products_ordered = products_ordered + 1 where products_id = '" . (int)$add_product_products_id . "'");
//UPDATE_INVENTORY_QUANTITY_END##############################################################################################################
// Get Product Attribute Info
if(isset($add_product_options)){
//split $add_product_options
foreach($add_product_options as $option_id => $option_value_id){
// check to see if there is a downloadable file
if (DOWNLOAD_ENABLED == 'true') {
$attributes_query_check = tep_db_query("select pa.products_attributes_id, poval.products_options_values_id, pa.products_id, pa.options_id, pa.options_values_id, pa.options_values_price, pa.price_prefix, poptt.products_options_name, poval.products_options_values_name, pad.products_attributes_filename, pad.products_attributes_maxdays, pad.products_attributes_maxcount FROM
" . TABLE_PRODUCTS_OPTIONS . " popt,
" . TABLE_PRODUCTS_OPTIONS_TEXT . " poptt,
" . TABLE_PRODUCTS_OPTIONS_VALUES . " poval,
" . TABLE_PRODUCTS_ATTRIBUTES . " pa,
" . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
WHERE
pa.products_id = '" . $add_product_products_id . "'
and pa.options_id = '" . $option_id. "'
and pa.options_values_id = '" . $option_value_id. "'
and poptt.products_options_text_id = pa.options_id
and poval.products_options_values_id = pa.options_values_id
and poptt.language_id = '" . (int)$languages_id . "'
and poval.language_id = '" . (int)$languages_id . "'
and pad.products_attributes_id = pa.products_attributes_id
order by pa.products_options_sort_order
limit 1");
if (tep_db_num_rows($attributes_query_check)) {
$item_has_down = '1';
} // end if tep_db_num_rows
}// end if DOWNLOAD_ENABLED
// get attibutes data
if ($item_has_down == '1') {
$attributes_query = tep_db_query("select pa.products_attributes_id, poval.products_options_values_id, pa.products_id, pa.options_id, pa.options_values_id, pa.options_values_price, pa.price_prefix, poptt.products_options_name, poval.products_options_values_name, pad.products_attributes_filename, pad.products_attributes_maxdays, pad.products_attributes_maxcount FROM
" . TABLE_PRODUCTS_OPTIONS . " popt,
" . TABLE_PRODUCTS_OPTIONS_TEXT . " poptt,
" . TABLE_PRODUCTS_OPTIONS_VALUES . " poval,
" . TABLE_PRODUCTS_ATTRIBUTES . " pa,
" . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
WHERE
pa.products_id = '" . $add_product_products_id . "'
and pa.options_id = '" . $option_id. "'
and pa.options_values_id = '" . $option_value_id. "'
and poptt.products_options_text_id = pa.options_id
and poval.products_options_values_id = pa.options_values_id
and poptt.language_id = '" . (int)$languages_id . "'
and poval.language_id = '" . (int)$languages_id . "'
and pad.products_attributes_id = pa.products_attributes_id
order by pa.products_options_sort_order
limit 1");
} else {
$attributes_query = tep_db_query("select pa.products_attributes_id, poval.products_options_values_id, pa.products_id, pa.options_id, pa.options_values_id, pa.options_values_price, pa.price_prefix, poptt.products_options_name, poval.products_options_values_name from
" . TABLE_PRODUCTS_OPTIONS . " popt,
" . TABLE_PRODUCTS_OPTIONS_TEXT . " poptt,
" . TABLE_PRODUCTS_OPTIONS_VALUES . " poval,
" . TABLE_PRODUCTS_ATTRIBUTES . " pa
where
pa.products_id = '" . $add_product_products_id . "'
and pa.options_id = '" . $option_id. "'
and pa.options_values_id = '" . $option_value_id. "'
and poptt.products_options_text_id = pa.options_id
and poval.products_options_values_id = pa.options_values_id
and poptt.language_id = '" . (int)$languages_id . "'
and poval.language_id = '" . (int)$languages_id . "'
order by pa.products_options_sort_order
limit 1
");
}
while ($attributes = tep_db_fetch_array($attributes_query)){
$orders_products_id = $new_product_id;
$products_options = $attributes['products_options_name'];
$products_options_values = $attributes['products_options_values_name'];
$options_values_price = $attributes['options_values_price'];
$price_prefix = $attributes['price_prefix'];
$products_options_id = $attributes['options_id'];
$products_options_values_id = $attributes['options_values_id'];
//downloads
if ($item_has_down == '1') {
$orders_products_filename = $attributes['products_attributes_filename'];
$download_maxdays = $attributes['products_attributes_maxdays'];
$download_count = $attributes['products_attributes_maxcount'];
}
//add attibute price to product price
if ($price_prefix == '+'){
$AddedOptionsPrice += $options_values_price;
}else{
$AddedOptionsPrice -= $options_values_price;
}
// $att_options_values_price = $att_price;
// update final price
$product_price_update = tep_db_query("select final_price from
" . TABLE_ORDERS_PRODUCTS . "
where
orders_id = $oID and
orders_products_id = $orders_products_id ");
while ($product_price_array_1 = tep_db_fetch_array($product_price_update)){
$Query_final_price = "update " . TABLE_ORDERS_PRODUCTS . " set
final_price = '" . ($p_products_price + $AddedOptionsPrice) . "'
where orders_id = $oID and orders_products_id = $orders_products_id ";
tep_db_query($Query_final_price);
}
//insert attrbutes
if(isset($add_product_options)){
$Query = "insert into " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " set
orders_id = $oID,
orders_products_id = $orders_products_id,
products_options = '". $products_options . "',
products_options_values = '" . $products_options_values. "',
options_values_price = $options_values_price,
price_prefix = '" . $price_prefix . "',
products_options_id = $products_options_id,
products_options_values_id = $products_options_values_id;";
tep_db_query($Query);
}
// add download insert
if ((DOWNLOAD_ENABLED == 'true') && isset($orders_products_filename) && tep_not_null($orders_products_filename)) {
$sql_data_array = array('orders_id' => $oID,
'orders_products_id' => $new_product_id,
'orders_products_filename' => $orders_products_filename,
'download_maxdays' => $download_maxdays,
'download_count' => $download_count);
tep_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);
}
} // end while get option
}
}
//add product info
// recalculate totals
//UPDATE_INVENTORY_QUANTITY_START##############################################################################################################
tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity - " . $add_product_quantity . ", products_ordered = products_ordered + " . $add_product_quantity . " where products_id = '" . $add_product_products_id . "'");
//UPDATE_INVENTORY_QUANTITY_END##############################################################################################################
//end add product info
//get total of product using order class
$order = new order($oID);
$RunningSubTotal = 0;
$RunningTax = 0;
//$this->totals
for ($i=0; $i<sizeof($order->products); $i++)
{
$RunningSubTotal += ($order->products[$i]['qty'] * $order->products[$i]['final_price']);
//tax caculated on a per product bases
$RunningTax += (($order->products[$i]['tax'] / 100) * ($order->products[$i]['qty'] * $order->products[$i]['final_price']));
}
//subtotal to total
$RunningTotal = $RunningSubTotal;
//add tax
$RunningTotal += $RunningTax;
// Calculate Tax and Sub-Totals
// get exsisting order details so we can update them
$totals_query_5 = tep_db_query("select title as ot_title, text as ot_text, value as ot_value, class as ot_class from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . $oID . "' order by sort_order");
while ($totals_1 = tep_db_fetch_array($totals_query_5)) {
$totals_array[] = array('ot_title' => $totals_1['ot_title'],
'ot_text' => $totals_1['ot_text'],
'ot_value' => $totals_1['ot_value'],
'ot_class' => $totals_1['ot_class']);
}
//echo 'print_r' . $totals;
//print_r($totals);
//parse array
for ($i=0, $n=sizeof($totals_array); $i<$n; $i++) {
$totals = $totals_array[$i];
//add other order totals
if ($totals['ot_class'] == "ot_shipping" || $totals['ot_class'] == "ot_custom" || $totals['ot_class'] == "ot_cod_fee") {
// add ot_ items not already added
$RunningTotal += $totals['ot_value'] / $order->info['currency_value'];
//deduct discounts
} else if($totals['ot_class'] == "ot_coupon" ||$totals['ot_class'] == "ot_customer_discount" || $totals['ot_class'] == "ot_discount" || $totals['ot_class'] == "ot_gv" || $totals['ot_class'] == "ot_lev_discount" ){
//subtract discounts
$RunningTotal -= $totals['ot_value'] / $order->info['currency_value'];
}
// Tax
$Query = "update " . TABLE_ORDERS_TOTAL . " set
text = '\$" . number_format($RunningTax, 2, '.', ',') . "',
value = '" . $RunningTax . "'
where class='ot_tax' and orders_id=$oID";
tep_db_query($Query);
// Sub-Total
$Query = "update " . TABLE_ORDERS_TOTAL . " set
text = '\$" . number_format($RunningSubTotal, 2, '.', ',') . "',
value = '" . $RunningSubTotal . "'
where class='ot_subtotal' and orders_id=$oID";
tep_db_query($Query);
$Query = "update " . TABLE_ORDERS_TOTAL . " set
text = '<b>\$" . number_format($RunningTotal, 2, '.', ',') . "</b>',
value = '" . $RunningTotal . "'
where class='ot_total' and orders_id=$oID";
tep_db_query($Query);
} //end of for
tep_redirect(tep_href_link(FILENAME_C_ORDERS, tep_get_all_get_params(array('action')) . 'oID=' . $HTTP_GET_VARS['oID'] . '&action=edit', 'SSL'));
}
break;
} //end action
}// end action NUll
if (($action == 'edit') && isset($HTTP_GET_VARS['oID'])) {
$oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
$orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
$order_exists = true;
if (!tep_db_num_rows($orders_query)) {
$order_exists = false;
$messageStack->add('search', sprintf(ERROR_ORDER_DOES_NOT_EXIST, $oID), 'error');
}
}
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/menu.js"></script>
<script language="javascript" src="includes/general.js"></script>
<script language="javascript"><!--
function popupWindow(url) {
window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=650,height=500,screenX=150,screenY=150,top=150,left=150')
}
//--></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php
require(DIR_WS_INCLUDES . 'header.php');
?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
if (($action == 'edit') && ($order_exists == true)) {
$order = new order($oID);
?>
<tr>
<td width="100%">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<tr><td class=main><font color='#000000'><b><?php echo HEADING_STEP2 . $oID; ?></b></td></tr>
<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
<td class="pageHeading" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('action')), 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
</tr>
</table></td>
</tr>
<!-- Begin Addresses Block -->
<tr><?php echo tep_draw_form('edit_order', FILENAME_C_ORDERS, tep_get_all_get_params(array('action','paycc')) . 'action=update_order', 'post', '', 'SSL'); ?>
<td><table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td valign="top">
<!-- Customer Info Block -->
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td colspan='2' class="main" valign="top"><b><?php echo ENTRY_CUSTOMER; ?></b></td>
<td colspan='2' class="main" valign="top"><b><?php echo ENTRY_BILLING_ADDRESS; ?></b></td>
</tr>
<tr>
<td colspan='2' class="main">
<table border="0" cellspacing="0" cellpadding="2" class="infoBox">
<tr>
<td class="editOrder"><b><?php echo ENTRY_NAME ?></b></font></td>
<td><input name='update_customer_name' size='37' value='<?php echo tep_html_quotes($order->customer['name']); ?>'></td>
</tr>
<tr>
<td class="editOrder"><b><?php echo ENTRY_COMPANY ?></b></font></td>
<td><input name='update_customer_company' size='37' value='<?php echo tep_html_quotes($order->customer['company']); ?>'></td>
</tr>
<tr>
<td class="editOrder"><b><?php echo CATEGORY_ADDRESS ?></b></font></td>
<td><input name='update_customer_street_address' size='37' value='<?php echo tep_html_quotes($order->customer['street_address']); ?>'></td>
</tr>
<tr>
<td class="editOrder"><b><?php echo ENTRY_SUBURB ?></b></font></td>
<td><input name='update_customer_suburb' size='37' value='<?php echo tep_html_quotes($order->customer['suburb']); ?>'></td>
</tr>
<tr>
<td class="editOrder"><b><?php echo ENTRY_CITY ?></b></font></td>
<td><input name='update_customer_city' size='15' value='<?php echo tep_html_quotes($order->customer['city']); ?>'> </td>
</tr>
<tr>
<td class="editOrder"><b><?php echo ENTRY_STATE ?></b></font></td>
<td><input name='update_customer_state' size='15' value='<?php echo tep_html_quotes($order->customer['state']); ?>'> </td>
</tr>
<tr>
<td class="editOrder"><b><?php echo ENTRY_POST_CODE ?></b></font></td>
<td><input name='update_customer_postcode' size='5' value='<?php echo $order->customer['postcode']; ?>'></td>
</tr>
<tr>
<td class="editOrder"><b><?php echo ENTRY_COUNTRY ?></b></font></td>
<td><input name='update_customer_country' size='37' value='<?php echo tep_html_quotes($order->customer['country']); ?>'></td>
</tr>
</table>
</td>
<?php if($SeparateBillingFields) { ?>
<td>
<!-- Billing Address Block -->
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td colspan='2' class="main">
<table border="0" cellspacing="0" cellpadding="2" class="infoBox">
<tr>
<td class="editOrder"><b><?php echo ENTRY_NAME ?></b></font></td>
<td><input name='update_billing_name' size='37' value='<?php echo tep_html_quotes($order->billing['name']); ?>'></td>
</tr>
<tr>
<td class="editOrder"><b><?php echo ENTRY_COMPANY ?></b></font></td>
<td><input name='update_billing_company' size='37' value='<?php echo tep_html_quotes($order->billing['company']); ?>'></td>
</tr>
<tr>
<td class="editOrder"><b><?php echo CATEGORY_ADDRESS ?></b></font></td>
<td><input name='update_billing_street_address' size='37' value='<?php echo tep_html_quotes($order->billing['street_address']); ?>'></td>
</tr>
<tr>
<td class="editOrder"><b><?php echo ENTRY_SUBURB ?></b></font></td>
<td><input name='update_billing_suburb' size='37' value='<?php echo tep_html_quotes($order->billing['suburb']); ?>'></td>
</tr>
<tr>
<td class="editOrder"><b><?php echo ENTRY_CITY ?></b></font></td>
<td><input name='update_billing_city' size='15' value='<?php echo tep_html_quotes($order->billing['city']); ?>'> </td>
</tr>
<tr>
<td class="editOrder"><b><?php echo ENTRY_STATE ?></b></font></td>
<td><input name='update_billing_state' size='15' value='<?php echo tep_html_quotes($order->billing['state']); ?>'> </td>
</tr>
<tr>
<td class="editOrder"><b><?php echo ENTRY_POST_CODE ?></b></font></td>
<td><input name='update_billing_postcode' size='5' value='<?php echo $order->billing['postcode']; ?>'></td>
</tr>
<tr>
<td class="editOrder"><b><?php echo ENTRY_COUNTRY ?></b></font></td>
<td><input name='update_billing_country' size='37' value='<?php echo tep_html_quotes($order->billing['country']); ?>'></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<?php } ?>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top">
<!-- Shipping Address Block -->
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="main" valign="top"><b><?php echo ENTRY_SHIPPING_ADDRESS; ?></b></td>
</tr>
<tr>
<td colspan='1' class="main">
<table border="0" cellspacing="0" cellpadding="2" class="infoBox">
<tr>
<td class="editOrder"><b><?php echo ENTRY_NAME ?></b></font></td>
<td><input name='update_delivery_name' size='37' value='<?php echo tep_html_quotes($order->delivery['name']); ?>'></td>
</tr>
<tr>
<td class="editOrder"><b><?php echo ENTRY_COMPANY ?></b></font></td>
<td><input name='update_delivery_company' size='37' value='<?php echo tep_html_quotes($order->delivery['company']); ?>'></td>
</tr>
<tr>
<td class="editOrder"><b><?php echo CATEGORY_ADDRESS ?></b></font></td>
<td><input name='update_delivery_street_address' size='37' value='<?php echo tep_html_quotes($order->delivery['street_address']); ?>'></td>
</tr>
<tr>
<td class="editOrder"><b><?php echo ENTRY_SUBURB ?></b></font></td>
<td><input name='update_delivery_suburb' size='37' value='<?php echo tep_html_quotes($order->delivery['suburb']); ?>'></td>
</tr>
<tr>
<td class="editOrder"><b><?php echo ENTRY_CITY ?></b></font></td>
<td><input name='update_delivery_city' size='15' value='<?php echo tep_html_quotes($order->delivery['city']); ?>'> </td>
</tr>
<tr>
<td class="editOrder"><b><?php echo ENTRY_STATE ?></b></font></td>
<td><input name='update_delivery_state' size='15' value='<?php echo tep_html_quotes($order->delivery['state']); ?>'> </td>
</tr>
<tr>
<td class="editOrder"><b><?php echo ENTRY_POST_CODE ?></b></font></td>
<td><input name='update_delivery_postcode' size='5' value='<?php echo $order->delivery['postcode']; ?>'></td>
</tr>
<tr>
<td class="editOrder"><b><?php echo ENTRY_COUNTRY ?></b></font></td>
<td><input name='update_delivery_country' size='37' value='<?php echo tep_html_quotes($order->delivery['country']); ?>'></td>
</tr>
</table>
</td>
<td class="main" align="center" valign="middle">
<font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" color="red"><b><?php echo HEADING_INSTRUCT1 ?></b></font><br><br>
<?php echo HEADING_INSTRUCT2 ?>
</td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
<!-- End Addresses Block -->
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<!-- Begin Phone/Email Block -->
<tr>
<td><table border="0" cellspacing="0" cellpadding="2" class="infoBox">
<tr>
<td class="main"><b><?php echo ENTRY_TELEPHONE_NUMBER; ?></b></td>
<td class="main"><input name='update_customer_telephone' size='15' value='<?php echo $order->customer['telephone']; ?>'></td>
</tr>
<tr>
<td class="main"><b><?php echo ENTRY_EMAIL_ADDRESS; ?></b></td>
<td class="main"><input name='update_customer_email_address' size='35' value='<?php echo $order->customer['email_address']; ?>'></td>
</tr>
<tr>
<td class="main"><b><?php echo ENTRY_IPADDRESS; ?></b></td>
<td class="main"><?php echo $order->customer['ipaddy']; ?></td>
</tr>
<tr>
<td class="main"><b><?php echo ENTRY_IPISP; ?></b></td>
<td class="main"><?php echo $order->customer['ipisp']; ?></td>
</tr>
</table></td>
</tr>
<!-- End Phone/Email Block -->
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<!-- Begin Payment Block -->
<tr>
<td><table border="0" cellspacing="0" cellpadding="2" class="infoBox">
<tr valine="middle">
<td class="main"><b><?php echo ENTRY_PAYMENT_METHOD; ?></b></td>
<td class="main"><?php echo tep_draw_pull_down_menu('update_info_payment_method', $orders_pay_method, $order->info['payment_method']); ?>
<?php
echo tep_image_submit('button_update.gif', IMAGE_UPDATE);
if($order->info['payment_method'] != "Credit Card") {
echo TEXT_VIEW_CC;
}
if($order->info['payment_method'] != "Purchase Order") {
echo TEXT_VIEW_PO;
}
?>
</td>
</tr>
<?php if ($order->info['cc_type'] || $order->info['cc_owner'] || $order->info['payment_method'] == "Credit Card" || $order->info['cc_number']) { ?>
<!-- Begin Credit Card Info Block -->
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td class="main"><?php echo ENTRY_CREDIT_CARD_TYPE; ?></td>
<td class="main"><input name='update_info_cc_type' size='10' value='<?php echo $order->info['cc_type']; ?>'></td>
</tr>
<tr>
<td class="main"><?php echo ENTRY_CREDIT_CARD_OWNER; ?></td>
<td class="main"><input name='update_info_cc_owner' size='20' value='<?php echo $order->info['cc_owner']; ?>'></td>
</tr>
<tr>
<?php
unset ($cc_number7) ;
if ( ($order->info['cc_number'] == '' ) || ((PAYMENT_CC_CRYPT == 'True') && (@ereg ("([0-9]{6})", $order->info['cc_number'])) && !($order->info['cc_number'] == '0000000000000000') )) {
$cc_number7 = $order->info['cc_number'];
$text_encypt3 = TEXT_CARD_NOT_ENCRPYT ;
}else if ( (PAYMENT_CC_CRYPT == 'True') && !(@ereg ("([0-9]{6})", $order->info['cc_number']) ) ) {
$cc_number7 = cc_decrypt($order->info['cc_number']);
$text_encypt3= TEXT_CARD_ENCRPYT;
}else if($order->info['cc_number'] == '0000000000000000') {
$cc_number7 = $order->info['cc_number'];
$text_encypt3= TEXT_CCV_REMOVED;
}else{
$cc_number7 = $order->info['cc_number'];
$text_encypt3 = TEXT_CARD_NOT_ENCRPYT ;
}
?>
<td class="main"><?php echo ENTRY_CREDIT_CARD_NUMBER; ?></td>
<td class="main"><input name='update_info_cc_number' size='20' value='<?php echo $cc_number7; ?>'></td>
<td class="main"><?php echo $text_encypt3 ; ?></td>
</tr>
<tr>
<?php
if ( ($order->info['cc_expires'] == '' ) || ( (PAYMENT_CC_CRYPT == 'True') && (@ereg ("([0-9]{4})", $order->info['cc_expires'])) ) ){
$cc_expires7 = $order->info['cc_expires'];
$text_encypt4 = TEXT_EXPIRES_NOT_ENCRPYT ;
}else if ( (PAYMENT_CC_CRYPT == 'True') && !(@ereg ("([0-9]{4})", $order->info['cc_expires'])) && !($order->info['cc_expires'] == '') ) {
$cc_expires7 = cc_decrypt($order->info['cc_expires']);
$text_encypt4= TEXT_EXPIRES_ENCRPYT;
}else if($order->info['cc_expires'] == '') {
$cc_expires7 = $order->info['cc_expires'];
$text_encypt4 = TEXT_EXPIRES_REMOVED ;
}else{
$cc_expires7 =$order->info['cc_expires'];
$text_encypt4 = TEXT_EXPIRES_NOT_ENCRPYT ;
}
?>
<td class="main"><?php echo ENTRY_CREDIT_CARD_EXPIRES; ?></td>
<td class="main"><input name='update_info_cc_expires' size='4' value='<?php echo $cc_expires7; ?>'></td>
<td class="main"><?php echo $text_encypt4; ?></td>
</tr>
<tr>
<?php
if ( ($order->info['cc_ccv'] == '' ) || ((PAYMENT_CC_CRYPT == 'True') && (@ereg ("([0-9]{3})", $order->info['cc_ccv'])) ) ){
$cc_ccv7 = $order->info['cc_ccv'];
$text_encypt5 = TEXT_CCV_NOT_ENCRPYT ;
}else if ( (PAYMENT_CC_CRYPT == 'True') && !(@ereg ("([0-9]{3})", $order->info['cc_ccv'])) && !($order->info['cc_ccv'] == '') ) {
$cc_ccv7 = cc_decrypt($order->info['cc_ccv']);
$text_encypt5= TEXT_CCV_ENCRPYT;
}else if($order->info['cc_ccv'] == '') {
$cc_ccv7 = $order->info['cc_ccv'];
$text_encypt5= TEXT_CCV_REMOVED;
}else {
$cc_ccv7 =$order->info['cc_ccv'];
$text_encypt5= TEXT_CCV_NOT_ENCRPYT;
}
?>
<td class="main"><?php echo ENTRY_CREDIT_CARD_CCV; ?></td>
<td class="main"><input name='update_info_cc_ccv' size='4' value='<?php echo $cc_ccv7; ?>'></td>
<td class="main"><?php echo $text_encypt5; ?></td>
</tr>
<td class="main"><?php echo ENTRY_CREDIT_CARD_START_DATE; ?></td>
<td class="main"><input name='update_info_cc_start' size='4' value='<?php echo $order->info['cc_start']; ?>'></td>
</tr>
<tr>
<td class="main"><?php echo ENTRY_CREDIT_CARD_ISSUE; ?></td>
<td class="main"><input name='update_info_cc_issue' size='4' value='<?php echo $order->info['cc_issue']; ?>'></td>
</tr>
<!-- End Credit Card Info Block -->
<?php
// purchaseorder start
} else if( (($order->info['account_name']) || ($order->info['account_number']) || $order->info['payment_method'] == "Purchase Order"|| ($order->info['po_number'])) ) {
?>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td class="main" valign="top" align="left"><b><?php echo TEXT_INFO_PO ?></b></td>
<td>
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td width="10"><img src="images/pixel_trans.gif" border="0" alt="" width="10" height="1"></td>
<td class="main"><?php echo TEXT_INFO_NAME ?></td>
<td><img src="images/pixel_trans.gif" border="0" alt="" width="10" height="1"></td>
<td class="main"><input type="text" name="account_name" value='<?php echo $order->info['account_name']; ?>'></td></td>
<td width="10"><img src="images/pixel_trans.gif" border="0" alt="" width="10" height="1"></td>
</tr>
<tr>
<td width="10"><img src="images/pixel_trans.gif" border="0" alt="" width="10" height="1"></td>
<td class="main"><?php echo TEXT_INFO_AC_NR ?></td>
<td><img src="images/pixel_trans.gif" border="0" alt="" width="10" height="1"></td>
<td class="main"><input type="text" name="account_number" value='<?php echo $order->info['account_number']; ?>'></td>
<td width="10"><img src="images/pixel_trans.gif" border="0" alt="" width="10" height="1"></td>
</tr>
<tr>
<td width="10"><img src="images/pixel_trans.gif" border="0" alt="" width="10" height="1"></td>
<td class="main"><?php echo TEXT_INFO_PO_NR ?></td>
<td><img src="images/pixel_trans.gif" border="0" alt="" width="10" height="1"></td>
<td class="main"><input type="text" name="po_number" value='<?php echo $order->info['po_number']; ?>'></td>
<td width="10"><img src="images/pixel_trans.gif" border="0" alt="" width="10" height="1"></td>
</tr>
</table></td>
</tr>
<?php } ?>
</table></td>
</tr>
<!-- End Payment Block -->
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<!-- Begin Products Listing Block -->
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr class="dataTableHeadingRow">
<td class="dataTableHeadingContent" colspan="2"><?php echo TABLE_HEADING_PRODUCTS; ?></td>
<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_MODEL; ?></td>
<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_TAX; ?></td>
<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_BASE_PRICE; ?></td>
<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_UNIT_PRICE; ?></td>
<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TOTAL_PRICE; ?></td>
<?php
if ( DISPLAY_PRICE_WITH_TAX == 'true'){
echo '<td class="dataTableHeadingContent" align="right">' . TABLE_HEADING_TOTAL_PRICE_TAXED . '</td>';
}
;?>
</tr>
<!-- Begin Products Listings Block -->
<?php
// Override order.php Class's Field Limitations
$index = 0;
$order->products = array();
$orders_products_query = tep_db_query("select * from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$oID . "'");
while ($orders_products = tep_db_fetch_array($orders_products_query)) {
$order->products[$index] = array('qty' => $orders_products['products_quantity'],
'name' => str_replace("'", "&#39;", $orders_products['products_name']),
'model' => $orders_products['products_model'],
'tax' => $orders_products['products_tax'],
'price' => $orders_products['products_price'],
'final_price' => $orders_products['final_price'],
'orders_products_id' => $orders_products['orders_products_id']);
$subindex = 0;
$attributes_query_string = "select * from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$oID . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'";
$attributes_query = tep_db_query($attributes_query_string);
if (tep_db_num_rows($attributes_query)) {
while ($attributes = tep_db_fetch_array($attributes_query)) {
$order->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'],
'value' => $attributes['products_options_values'],
'prefix' => $attributes['price_prefix'],
'price' => $attributes['options_values_price'],
'orders_products_attributes_id' => $attributes['orders_products_attributes_id']);
$subindex++;
}
}
$index++;
}
for ($i=0; $i<sizeof($order->products); $i++) {
$orders_products_id = $order->products[$i]['orders_products_id'];
$RowStyle = "dataTableContent";
echo ' <tr class="dataTableRow">' . "\n" .
' <td class="' . $RowStyle . '" valign="top" align="right">' . "<input name='update_products[$orders_products_id][qty]' size='2' value='" . $order->products[$i]['qty'] . "'>&nbsp;x</td>\n" .
' <td class="' . $RowStyle . '" valign="top">' . $order->products[$i]['name'] . "<input name='update_products[$orders_products_id][name]' type='hidden' size='25' value='" . $order->products[$i]['name'] . "'>";
// Has Attributes?
if (sizeof($order->products[$i]['attributes']) > 0) {
for ($j=0; $j<sizeof($order->products[$i]['attributes']); $j++) {
$orders_products_attributes_id = $order->products[$i]['attributes'][$j]['orders_products_attributes_id'];
echo '<br><nobr><small>&nbsp;<i> - ' . $order->products[$i]['attributes'][$j]['option'] . ' : ' . $order->products[$i]['attributes'][$j]['value'] . ' ' . $order->products[$i]['attributes'][$j]['prefix'] . ' ' . $currencies->format($order->products[$i]['attributes'][$j]['price']) ;
echo '</i></small></nobr>';
}
}
echo ' </td>' . "\n" .
' <td class="' . $RowStyle . '" valign="top">' . $order->products[$i]['model'] . "<input name='update_products[$orders_products_id][model]' type='hidden' size='12' value='" . $order->products[$i]['model'] . "'>" . '</td>' . "\n" .
' <td class="' . $RowStyle . '" align="center" valign="top">' . "<input name='update_products[$orders_products_id][tax]' size='3' value='" . tep_display_tax_value($order->products[$i]['tax']) . "'>" . '%</td>' . "\n" .
' <td class="' . $RowStyle . '" align="right" valign="top">' . $currencies->format($order->products[$i]['price'], true, $order->info['currency'], $order->info['currency_value']). "<input name='update_products[$orders_products_id][price]' type='hidden' size='5' value='" . number_format($order->products[$i]['price'], 2, '.', '') . "'>" . '</td>' . "\n" .
' <td class="' . $RowStyle . '" align="right" valign="top">' . $currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']) . "<input name='update_products[$orders_products_id][final_price]' type='hidden' size='5' value='" . number_format($order->products[$i]['final_price'], 2, '.', '') . "'>" . '</td>' . "\n" .
' <td class="' . $RowStyle . '" align="right" valign="top">' . $currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</td>' . "\n" ;
if ( DISPLAY_PRICE_WITH_TAX == 'true'){
echo ' <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n";
}
echo ' </tr>' . "\n";
}
?>
<!-- End Products Listings Block -->
<!-- Begin Order Total Block -->
<tr>
<td align="right" colspan="8">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr>
<td align='center' valign='top'><br><?php echo '<a href="' . tep_href_link(FILENAME_C_ORDERS, 'oID=' . $HTTP_GET_VARS['oID'] . '&action=add_product&step=1') . '">'. tep_image_button('button_add_product.gif', 'Add a product') . '&nbsp;</a></td>' ;?>
<td align='right'>
<table border="0" cellspacing="0" cellpadding="2">
<?php
// Override order.php Class's Field Limitations
$totals_query = tep_db_query("select * from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$oID . "' order by sort_order");
$order->totals = array();
while ($totals = tep_db_fetch_array($totals_query)) { $order->totals[] = array('title' => $totals['title'], 'text' => $totals['text'], 'class' => $totals['class'], 'value' => $totals['value'], 'orders_total_id' => $totals['orders_total_id']); }
$TotalsArray = array();
for ($i=0; $i<sizeof($order->totals); $i++) {
$TotalsArray[] = array("Name" => $order->totals[$i]['title'], "Price" => number_format($order->totals[$i]['value'], 2, '.', ''), "Class" => $order->totals[$i]['class'], "TotalID" => $order->totals[$i]['orders_total_id']);
$TotalsArray[] = array("Name" => " ", "Price" => "", "Class" => "ot_custom", "TotalID" => "0");
}
array_pop($TotalsArray);
foreach($TotalsArray as $TotalIndex => $TotalDetails)
{
$TotalStyle = "smallText";
if(($TotalDetails["Class"] == "ot_subtotal") || ($TotalDetails["Class"] == "ot_total"))
{
echo ' <tr>' . "\n" .
' <td class="main" align="right"><b>' . $TotalDetails["Name"] . '</b></td>' .
' <td class="main" align="right"><b>' . $TotalDetails["Price"] .
"<input name='update_totals[$TotalIndex][title]' type='hidden' value='" . trim($TotalDetails["Name"]) . "' >" .
"<input name='update_totals[$TotalIndex][value]' type='hidden' value='" . $TotalDetails["Price"] . "' size='6' >" .
"<input name='update_totals[$TotalIndex][class]' type='hidden' value='" . $TotalDetails["Class"] . "'>\n" .
"<input type='hidden' name='update_totals[$TotalIndex][total_id]' value='" . $TotalDetails["TotalID"] . "'>" . '</b></td>' .
' </tr>' . "\n";
}
elseif($TotalDetails["Class"] == "ot_customer_discount")
{
echo ' <tr>' . "\n" .
' <td class="main" align="right"><font color="#FF0000">' . ENTRY_CUSTOMER_DISCOUNT . '<b>' . $TotalDetails["Name"] . '</b></font></td>' .
' <td align="right" SPAN class="' . $TotalStyle . '">' . "<input name='update_totals[$TotalIndex][value]' size='6' value=' " . $TotalDetails["Price"] . "'></SPAN>" .
"<input name='update_totals[$TotalIndex][title]' type='hidden' value='" . trim($TotalDetails["Name"]) . "' >" .
"<input name='update_totals[$TotalIndex][class]' type='hidden' value='" . $TotalDetails["Class"] . "'>\n" .
"<input type='hidden' name='update_totals[$TotalIndex][total_id]' value='" . $TotalDetails["TotalID"] . "'>" . '</b></td>' .
' </tr>' . "\n";
}
elseif(($TotalDetails["Class"] == "ot_gv") || ($TotalDetails["Class"] == "ot_coupon"))
{
echo ' <tr>' . "\n" .
' <td class="main" align="right">' . ENTRY_CUSTOMER_GV . '<b>' . $TotalDetails["Name"] . '</b></td>' .
' <td align="right" class="' . $TotalStyle . '">' . "<input name='update_totals[$TotalIndex][value]' size='6' value=' " . $TotalDetails["Price"] . "'>" .
"<input name='update_totals[$TotalIndex][title]' type='hidden' value='" . trim($TotalDetails["Name"]) . "' >" .
"<input name='update_totals[$TotalIndex][class]' type='hidden' value='" . $TotalDetails["Class"] . "'>\n" .
"<input type='hidden' name='update_totals[$TotalIndex][total_id]' value='" . $TotalDetails["TotalID"] . "'>" . '</b></td>' .
' </tr>' . "\n";
}
elseif($TotalDetails["Class"] == "ot_tax")
//taxes
{
echo ' <tr>' . "\n" .
' <td class="main" align="right"><b>' . $TotalDetails["Name"] . '</b></td>' .
' <td class="main" align="right"><b>' . $TotalDetails["Price"] .
"<input name='update_totals[$TotalIndex][title]' type='hidden' value='" . trim($TotalDetails["Name"]) . "' >" .
"<input name='update_totals[$TotalIndex][value]' type='hidden' value='" . $TotalDetails["Price"] . "' size='6' >" .
"<input name='update_totals[$TotalIndex][class]' type='hidden' value='" . $TotalDetails["Class"] . "'>\n" .
"<input type='hidden' name='update_totals[$TotalIndex][total_id]' value='" . $TotalDetails["TotalID"] . "'>" . '</b></td>' .
' </tr>' . "\n";
}
// Shipping
elseif($TotalDetails["Class"] == "ot_shipping")
{
//list exsisting shipping if not in current order_ship_meahtods table
$orders_ship_methodA[] = array('id' => $TotalDetails["Name"],
'text' => $TotalDetails["Name"]);
// $orders_ship_method1 = array_merge($orders_ship_method, $orders_ship_methodA) ;
// check to see if meathod in totals is in same as in order_ship_meahtods table
// if false merge if true dont merge
$orders_ship_method1 = array_merge($orders_ship_methodA, $orders_ship_method) ;
echo ' <tr>' . "\n" .
' <td align="right" class="' . $TotalStyle . '"><b><?php echo HEADING_SHIPPING ?></b>' . tep_draw_pull_down_menu('update_totals[$TotalIndex][title]', $orders_ship_method1, $TotalDetails["Name"]) . '</td>' . "\n";
echo ' <td align="right" class="' . $TotalStyle . '">' . "<input name='update_totals[$TotalIndex][value]' size='6' value='" . $TotalDetails["Price"] . "'>" .
"<input type='hidden' name='update_totals[$TotalIndex][class]' value='" . $TotalDetails["Class"] . "'>" .
"<input type='hidden' name='update_totals[$TotalIndex][total_id]' value='" . $TotalDetails["TotalID"] . "'>" . '</td>' .
' </tr>' . "\n";
}
// End Shipping
else
{
echo ' <tr>' . "\n" .
' <td class="main" align="right"><b>' . $TotalDetails["Name"] . '</b></td>' .
' <td align="right" class="' . $TotalStyle . '">' . "<input type='hidden' name='update_totals[$TotalIndex][value]' size='6' value='" . $TotalDetails["Price"] . "'>" .
"<input type='hidden' name='update_totals[$TotalIndex][title]' value='" . trim($TotalDetails["Name"]) . "' >" .
"<input type='hidden' name='update_totals[$TotalIndex][class]' value='" . $TotalDetails["Class"] . "'>" .
"<input type='hidden' name='update_totals[$TotalIndex][total_id]' value='" . $TotalDetails["TotalID"] . "'>" .
'</td>' . "\n" .
' </tr>' . "\n";
}
}
?>
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- End Order Total Block -->
</table></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td class="main"><table border="1" cellspacing="0" cellpadding="5">
<tr>
<td class="smallText" align="center"><b><?php echo TABLE_HEADING_DATE_ADDED; ?></b></td>
<td class="smallText" align="center"><b><?php echo TABLE_HEADING_CUSTOMER_NOTIFIED; ?></b></td>
<td class="smallText" align="center"><b><?php echo TABLE_HEADING_STATUS; ?></b></td>
<td class="smallText" align="center"><b><?php echo TABLE_HEADING_COMMENTS; ?></b></td>
</tr>
<?php
$orders_status_query = tep_db_query("select orders_status from " . TABLE_ORDERS . " where orders_id = '" . tep_db_input($oID) . "'");
while ($orders_status_1 = tep_db_fetch_array($orders_status_query)) {
$orders_status_test = $orders_status_1['orders_status'];
}
$orders_history_query = tep_db_query("select * from " . TABLE_ORDERS_STATUS_HISTORY . " where orders_id = '" . tep_db_input($oID) . "' order by date_added");
if (tep_db_num_rows($orders_history_query)) {
while ($orders_history = tep_db_fetch_array($orders_history_query)) {
echo ' <tr>' . "\n" .
' <td class="smallText" align="center">' . tep_datetime_short($orders_history['date_added']) . '</td>' . "\n" .
' <td class="smallText" align="center">';
if ($orders_history['customer_notified'] == '1') {
echo tep_image(DIR_WS_ICONS . 'tick.gif', ICON_TICK) . "</td>\n";
} else {
echo tep_image(DIR_WS_ICONS . 'cross.gif', ICON_CROSS) . "</td>\n";
}
echo ' <td class="smallText">' . $orders_status_array[$orders_history['orders_status_id']] . '</td>' . "\n";
echo ' <td class="smallText">' . nl2br(tep_db_output($orders_history['comments'])) . '&nbsp;</td>' . "\n";
echo ' </tr>' . "\n";
}
} else {
echo ' <tr>' . "\n" .
' <td class="smallText" colspan="5">' . TEXT_NO_ORDER_HISTORY . '</td>' . "\n" .
' </tr>' . "\n";
}
?>
</table></td>
</tr>
<tr>
<td class="main"><br><b><?php echo TABLE_HEADING_COMMENTS; ?></b></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
</tr>
<tr>
<td class="main">
<?php
echo tep_draw_textarea_field('comments', 'soft', '60', '5');
?>
</td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="main"><b><?php echo ENTRY_STATUS; ?></b> <?php echo tep_draw_pull_down_menu('status', $orders_statuses, $order->info['orders_status_number']); ?></td>
</tr>
<tr>
<td class="main"><b><?php echo ENTRY_NOTIFY_CUSTOMER; ?></b> <?php echo tep_draw_checkbox_field('notify', '', false); ?></td>
<td class="main"><b><?php echo ENTRY_NOTIFY_COMMENTS; ?></b> <?php echo tep_draw_checkbox_field('notify_comments', '', false); ?></td>
</tr>
</table></td>
</tr>
</tr>
</table></td>
</tr>
<tr>
<td align='center' valign="top"><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?></td>
</tr>
<tr>
<td colspan="2" align="right"><?php
if (isset($HTTP_GET_VARS[tep_session_name()])) {
$oscid = '&' . tep_session_name() . '=' . $HTTP_GET_VARS[tep_session_name()];
} else {
$oscid = '';
}
echo ' </a> <a href="javascript:popupWindow(\'' . (HTTP_SERVER . DIR_WS_ADMIN . FILENAME_ORDERS_INVOICE) . '?' . (tep_get_all_get_params(array('oID')) . 'oID=' . $HTTP_GET_VARS['oID']) . $oscid . '\')">' . tep_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . '</a><a href="javascript:popupWindow(\'' . (HTTP_SERVER . DIR_WS_ADMIN . FILENAME_ORDERS_PACKINGSLIP) . '?' . (tep_get_all_get_params(array('oID')) . 'oID=' . $HTTP_GET_VARS['oID']) . $oscid . '\')">' . tep_image_button('button_packingslip.gif', IMAGE_ORDERS_PACKINGSLIP) . '</a>'; ?></td>
</tr>
</form>
<?php
}
if($action == "add_product")
{
?>
<tr>
<td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="pageHeading"><?php echo ADDING_TITLE; ?> #<?php echo $oID; ?></td>
<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
<td class="pageHeading" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_C_ORDERS, tep_get_all_get_params(array('action')), 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
</tr>
</table></td>
</tr>
<?php
// ############################################################################
// Get List of All Products
// ############################################################################
$parent_ids = array();
$parent_query = tep_db_query("SELECT DISTINCT products_parent_id
FROM " . TABLE_PRODUCTS . "
WHERE products_parent_id <> 0");
while($parent = tep_db_fetch_array($parent_query)) {
$parent_ids[$parent['products_parent_id']] = 1;
}
ksort($parent_ids);
$result = tep_db_query("SELECT
products_name,
p.products_id,
cd.categories_name,
ptc.categories_id
FROM " . TABLE_PRODUCTS . " p,
" . TABLE_PRODUCTS_DESCRIPTION . " pd,
" . TABLE_PRODUCTS_TO_CATEGORIES . " ptc,
" . TABLE_CATEGORIES_DESCRIPTION . " cd
where cd.categories_id=ptc.categories_id
and ptc.products_id=p.products_id
and (p.products_status = '1'
or (p.products_status <> '1' and p.products_parent_id <> 0))
and p.products_id=pd.products_id
and pd.language_id = '" . (int)$languages_id . "'
ORDER BY cd.categories_name");
while($row = tep_db_fetch_array($result))
{
// if (tep_db_num_rows($result_new) > 0) {
if (isset($parent_ids[$row['products_id']])) {
continue;
}
extract($row,EXTR_PREFIX_ALL,"db");
$ProductList[$db_categories_id][$db_products_id] = $db_products_name;
$CategoryList[$db_categories_id] = $db_categories_name;
$LastCategory = $db_categories_name;
}
// ksort($ProductList);
$LastOptionTag = "";
$ProductSelectOptions = "<option value='0'>".DONT_ADD_NEW_PRODUCT . $LastOptionTag . "\n";
$ProductSelectOptions .= "<option value='0'>&nbsp;" . $LastOptionTag . "\n";
foreach($ProductList as $Category => $Products)
{
$ProductSelectOptions .= "<option value='0'>$Category" . $LastOptionTag . "\n";
$ProductSelectOptions .= "<option value='0'>---------------------------" . $LastOptionTag . "\n";
asort($Products);
foreach($Products as $Product_ID => $Product_Name)
{
$ProductSelectOptions .= "<option value='$Product_ID'> &nbsp; $Product_Name" . $LastOptionTag . "\n";
}
if($Category != $LastCategory)
{
$ProductSelectOptions .= "<option value='0'>&nbsp;" . $LastOptionTag . "\n";
$ProductSelectOptions .= "<option value='0'>&nbsp;" . $LastOptionTag . "\n";
}
}
// ############################################################################
// Add Products Steps
// ############################################################################
echo '<tr><td><table border=\'0\'>' . "\n";
// Set Defaults
if(!IsSet($add_product_categories_id))
$add_product_categories_id = 0;
if(!IsSet($add_product_products_id))
$add_product_products_id = 0;
// Step 1: Choose Category
print "<tr class=\"dataTableRow\"><form action='" . tep_href_link(FILENAME_C_ORDERS, 'oID='.$oID.'&action=add_product') . "' method='POST'>\n";
echo "<td class=\"dataTableContent\" align=\"right\"><b>" . TEXT_ADD_PROD_STEP1 . "</b></td><td class=\"dataTableContent\" valign=\"top\">";
$tree = tep_get_category_tree();
$dropdown= tep_draw_pull_down_menu('add_product_categories_id', $tree, '', ''); //single
echo $dropdown;
// print "<select name='add_product_categories_id'>\n";
// $CategoryOptions = "<option value='0'> TEXT_ADD_CAT_CHOOSE ";
// foreach($CategoryList as $CategoryID => $CategoryName)
// {
// $CategoryOptions .= "<option value='$CategoryID'> $CategoryName\n";
// }
$CategoryOptions = str_replace("value='$add_product_categories_id'","value='$add_product_categories_id' selected", $CategoryOptions);
print $CategoryOptions;
print "</td>\n";
print "<td class='dataTableContent' align='center'><input type='submit' value='" . TEXT_SELECT_CAT . "'>";
print "<input type='hidden' name='step' value='2'>";
print "</td>\n";
print "</form></tr>\n";
print "<tr><td colspan='3'>&nbsp;</td></tr>\n";
// Step 2: Choose Product
if(($step > 1) && ($add_product_categories_id > 0))
{
print "<tr class=\"dataTableRow\"><form action='" . tep_href_link(FILENAME_C_ORDERS, 'oID='.$oID.'&action='.$action) . "' method='POST'>\n";
print "<td class='dataTableContent' align='right'><b>" . TEXT_ADD_STEP2 . "</b></td><td class='dataTableContent' valign='top'><select name='add_product_products_id'>";
$ProductOptions = "<option value='0'> " . TEXT_ADD_PROD_CHOOSE;
asort($ProductList[$add_product_categories_id]);
foreach($ProductList[$add_product_categories_id] as $ProductID => $ProductName)
{
$ProductOptions .= "<option value='$ProductID'> $ProductName\n";
}
$ProductOptions = str_replace("value='$add_product_products_id'","value='$add_product_products_id' selected", $ProductOptions);
print $ProductOptions;
print "</select></td>\n";
print "<td class='dataTableContent' align='center'><input type='submit' value='" . TEXT_SELECT_PROD . "'>";
print "<input type='hidden' name='add_product_categories_id' value='$add_product_categories_id'>";
print "<input type='hidden' name='step' value='3'>";
print "</td>\n";
print "</form></tr>\n";
print "<tr><td colspan='3'>&nbsp;</td></tr>\n";
}
// Step 3: Choose Options
// Eversun mod for show product price
if ($add_product_products_id > 0) {
$rs_special = tep_db_query("select * from specials where products_id ='". $add_product_products_id."' and status = 1 " );
$special = tep_db_fetch_array($rs_special);
if ($special) {
$p_products_price = $currencies->format($special['specials_new_products_price']);
} else {
$rs_price = tep_db_fetch_array(tep_db_query("select products_price from " . TABLE_PRODUCTS . " where products_id = '" . $add_product_products_id . "'"));
$p_products_price = $currencies->format($rs_price['products_price']);
}
} else {
$p_products_price = '';
}
// Eversun mod end for show product price
echo TEXT_ADD_PROD . $add_product_products_id . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Price: ' . $p_products_price;
if(($step > 2) && ($add_product_products_id > 0))
{
// Get Options for Products
$result = tep_db_query("SELECT * FROM
" . TABLE_PRODUCTS_ATTRIBUTES . " pa,
" . TABLE_PRODUCTS_OPTIONS . " po,
" . TABLE_PRODUCTS_OPTIONS_TEXT . " pot,
" . TABLE_PRODUCTS_OPTIONS_VALUES . " pov
WHERE
pa.options_id = po.products_options_id and
pa.options_id = pot.products_options_text_id and
pa.options_values_id =pov.products_options_values_id and
products_id ='$add_product_products_id' ");
// Skip to Step 4 if no Options
if(tep_db_num_rows($result) == 0)
{
echo "<tr class=\"dataTableRow\">\n";
echo "<td class='dataTableContent' align='right'><b>" . TEXT_ADD_STEP3 . "</b></td><td class='dataTableContent' valign='top' colspan='2'><i>" . TEXT_SELECT_OPT_SKIP . "</i></td>";
echo "</tr>\n";
$step = 4;
}
else
{
while($row = tep_db_fetch_array($result))
{
extract($row,EXTR_PREFIX_ALL,"db");
$Options[$db_products_options_id] = $db_products_options_name;
$ProductOptionValues[$db_products_options_id][$db_products_options_values_id] = $db_products_options_values_name;
}
echo '<tr class=\"dataTableRow\">' . tep_draw_form('select_product', FILENAME_C_ORDERS, 'oID='.$oID . '&action=add_product', 'post', '', 'SSL') . "\n";
print "<td class='dataTableContent' align='right'><b>" . TEXT_ADD_STEP3 . "</b></td>
<td class='dataTableContent' valign='top'>";
foreach($ProductOptionValues as $OptionID => $OptionValues)
{
$OptionOption = "<b>" . $Options[$OptionID] . "</b> - <select name='add_product_options[$OptionID]'>";
foreach($OptionValues as $OptionValueID => $OptionValueName)
{
//get price
$price_query = tep_db_query("SELECT * FROM
" . TABLE_PRODUCTS_ATTRIBUTES . " pa
WHERE
pa.options_id = $OptionID and
pa.options_values_id = $OptionValueID
");
while($price_array = tep_db_fetch_array($price_query))
{
$option_price = $price_array['options_values_price'];
$option_price1 = ' ' . $price_array['price_prefix'] . ' ' . $currencies->format($option_price);
}
$OptionOption .= "<option value='$OptionValueID'> $OptionValueName $option_price1 \n";
}
$OptionOption .= "</select><br>\n";
if(IsSet($add_product_options))
$OptionOption = str_replace("value='" . $add_product_options[$OptionID] . "'","value='" . $add_product_options[$OptionID] . "' selected",$OptionOption);
print $OptionOption;
}
print "</td>";
print "<td class='dataTableContent' align='center'><input type='submit' value='".SELECT_THESE_OPTIONS."'>";
print "<input type='hidden' name='add_product_categories_id' value='$add_product_categories_id'>";
print "<input type='hidden' name='add_product_products_id' value='$add_product_products_id'>";
print "<input type='hidden' name='step' value='4'>";
print "</td>\n";
print "</form></tr>\n";
}
print "<tr><td colspan='3'>&nbsp;</td></tr>\n";
}
// Step 4: Confirm
if($step > 3)
{
echo '<tr class=\"dataTableRow\">' . tep_draw_form('select_product', FILENAME_C_ORDERS, 'oID='.$oID . '&action=add_product', 'post', '', 'SSL') . "\n";
// echo "<tr class=\"dataTableRow\"><form action='$PHP_SELF?oID=$oID&action=$action' method='POST'>\n";
print "<td class='dataTableContent' align='right'><b>" . TEXT_ADD_STEP4 . "</b></td>";
print "<td class='dataTableContent' valign='top'><input name='add_product_quantity' size='2' value='1'>" . TEXT_ADD_QUANTITY . "</td>";
print "<td class='dataTableContent' align='center'><input type='submit' value='" . TEXT_ADD_NOW . "'>";
if(IsSet($add_product_options))
{
foreach($add_product_options as $option_id => $option_value_id)
{
echo "<input type='hidden' name='add_product_options[$option_id]' value='$option_value_id'>";
}
}
print "<input type='hidden' name='add_product_categories_id' value='$add_product_categories_id'>";
print "<input type='hidden' name='add_product_products_id' value='$add_product_products_id'>";
print "<input type='hidden' name='step' value='5'>";
print "</td>\n";
print "</form></tr>\n";
}
echo "</table></td></tr>\n";
}
?>
</table></td>
<!-- body_text_eof //-->
</tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php
require(DIR_WS_INCLUDES . 'application_bottom.php');
?>