Quick Search:

View

Revision:

Diff

Diff from 1186 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/branches/frank/osc-tickets/admin/includes/content/orders.php

Annotated File View

hpdl
1016
1 <?php
2 /*
3   $Id: $
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
8   Copyright (c) 2006 osCommerce
9
10   Released under the GNU General Public License
11 */
12
13   class osC_Content_Orders extends osC_Template {
14
15 /* Private variables */
16
17     var $_module = 'orders',
hpdl
1078
18         $_page_title = HEADING_TITLE,
hpdl
1016
19         $_page_contents = 'orders.php';
20
21 /* Class constructor */
22
23     function osC_Content_Orders() {
24       global $osC_Database, $osC_Language, $osC_Currencies, $orders_statuses, $orders_status_array;
25
26       if (!isset($_GET['action'])) {
27         $_GET['action'] = '';
28       }
29
30       if (!isset($_GET['section'])) {
31         $_GET['section'] = '';
32       }
33
34       if (!isset($_GET['page']) || (isset($_GET['page']) && !is_numeric($_GET['page']))) {
35         $_GET['page'] = 1;
36       }
37
38       include('includes/classes/order.php');
39
40       include('../includes/classes/currencies.php');
41       $osC_Currencies = new osC_Currencies();
42
43       $orders_statuses = array();
44       $orders_status_array = array();
45
46       $Qstatuses = $osC_Database->query('select orders_status_id, orders_status_name from :table_orders_status where language_id = :language_id');
47       $Qstatuses->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
48       $Qstatuses->bindInt(':language_id', $osC_Language->getID());
49       $Qstatuses->execute();
50
51       while ($Qstatuses->next()) {
52         $orders_statuses[] = array('id' => $Qstatuses->valueInt('orders_status_id'),
53                                    'text' => $Qstatuses->value('orders_status_name'));
54
55         $orders_status_array[$Qstatuses->valueInt('orders_status_id')] = $Qstatuses->value('orders_status_name');
56       }
57
58       if (!empty($_GET['action'])) {
59         switch ($_GET['action']) {
60           case 'oEdit':
61             $this->_page_contents = 'orders_edit.php';
62             break;
63
64           case 'update_transaction':
65             $this->_updateTransaction();
66             break;
67
68           case 'update_order':
69             $this->_update();
70             break;
71
72           case 'deleteconfirm':
73             $this->_delete();
74             break;
75         }
76       }
77     }
78
79 /* Private methods */
80
81     function _updateTransaction() {
82       global $osC_Database, $osC_MessageStack;
83
84       if (isset($_GET['oID']) && is_numeric($_GET['oID'])) {
85         if (isset($_POST['transaction'])) {
86           $Qorder = $osC_Database->query('select payment_module from :table_orders where orders_id = :orders_id limit 1');
87           $Qorder->bindTable(':table_orders', TABLE_ORDERS);
88           $Qorder->bindInt(':orders_id', $_GET['oID']);
89           $Qorder->execute();
90
91           if ( ($Qorder->numberOfRows() === 1) && !osc_empty($Qorder->value('payment_module'))) {
92             if (file_exists('includes/modules/payment/' . $Qorder->value('payment_module') . '.php')) {
93               include('includes/classes/payment.php');
94               include('includes/modules/payment/' . $Qorder->value('payment_module') . '.php');
95
96               if (is_callable(array('osC_Payment_' . $Qorder->value('payment_module'), $_POST['transaction']))) {
97                 $payment_module = 'osC_Payment_' . $Qorder->value('payment_module');
98                 $payment_module = new $payment_module();
99                 $payment_module->$_POST['transaction']($_GET['oID']);
100 // HPDL - the following static call won't work due to using $this->_gateway_url in the class method
101 //                call_user_func(array('osC_Payment_' . $Qorder->value('payment_module'), $_POST['transaction']), $_GET['oID']);
102               }
103             }
104           }
105         }
106       }
107
108       osc_redirect(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&' . (isset($_GET['search']) ? 'search=' . $_GET['search'] . '&' : '') . (isset($_GET['status']) ? 'status=' . $_GET['status'] . '&' : '') . (isset($_GET['cID']) ? 'cID=' . $_GET['cID'] . '&' : '') . 'page=' . $_GET['page'] . '&oID=' . $_GET['oID'] . '&action=oEdit&section=transactionHistory'));
109     }
110
111     function _update() {
112       global $osC_Database, $osC_MessageStack;
113
114       if (isset($_GET['oID']) && is_numeric($_GET['oID'])) {
115         $Qorder = $osC_Database->query('select customers_name, customers_email_address, orders_status, date_purchased from :table_orders where orders_id = :orders_id');
116         $Qorder->bindTable(':table_orders', TABLE_ORDERS);
117         $Qorder->bindInt(':orders_id', $_GET['oID']);
118         $Qorder->execute();
119
120         if ($Qorder->numberOfRows() === 1) {
121           if (($_POST['status'] != $Qorder->valueInt('orders_status')) || !empty($_POST['comment'])) {
122             $Qupdate = $osC_Database->query('update :table_orders set orders_status = :orders_status, last_modified = now() where orders_id = :orders_id');
123             $Qupdate->bindTable(':table_orders', TABLE_ORDERS);
124             $Qupdate->bindInt(':orders_status', $_POST['status']);
125             $Qupdate->bindInt(':orders_id', $_GET['oID']);
126             $Qupdate->execute();
127
128             if ($Qupdate->affectedRows()) {
129               if (isset($_POST['notify_customer']) && ($_POST['notify_customer'] == 'on')) {
frank
1186
130                 $email_body = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $_GET['oID'] . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . osc_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $_GET['oID'], 'SSL', false, false, true) . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . osC_DateTime::getLong($Qorder->value('date_purchased')) . "\n\n";
hpdl
1016
131
132                 if (isset($_POST['append_comment']) && ($_POST['append_comment'] == 'on')) {
133                   $email_body .= sprintf(EMAIL_TEXT_COMMENTS_UPDATE, $_POST['comment']) . "\n\n";
134                 }
135
136                 $email_body .= sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$_POST['status']]);
137
138                 osc_email($Qorder->value('customers_name'), $Qorder->value('customers_email_address'), EMAIL_TEXT_SUBJECT, $email_body, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
139               }
140
141               $Qupdate = $osC_Database->query('insert into :table_orders_status_history (orders_id, orders_status_id, date_added, customer_notified, comments) values (:orders_id, :orders_status_id, now(), :customer_notified, :comments)');
142               $Qupdate->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY);
143               $Qupdate->bindInt(':orders_id', $_GET['oID']);
144               $Qupdate->bindInt(':orders_status_id', $_POST['status']);
145               $Qupdate->bindInt(':customer_notified', (isset($_POST['notify_customer']) && ($_POST['notify_customer'] == 'on') ? '1' : '0'));
146               $Qupdate->bindValue(':comments', $_POST['comment']);
147               $Qupdate->execute();
148
149               $osC_MessageStack->add_session($this->_module, SUCCESS_DB_ROWS_UPDATED, 'success');
150             } else {
151               $osC_MessageStack->add_session($this->_module, ERROR_DB_ROWS_NOT_UPDATED, 'error');
152             }
153           } else {
154             $osC_MessageStack->add_session($this->_module, WARNING_DB_ROWS_NOT_UPDATED, 'warning');
155           }
156         }
157       }
158
159       osc_redirect(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&' . (isset($_GET['search']) ? 'search=' . $_GET['search'] . '&' : '') . (isset($_GET['status']) ? 'status=' . $_GET['status'] . '&' : '') . (isset($_GET['cID']) ? 'cID=' . $_GET['cID'] . '&' : '') . 'page=' . $_GET['page'] . '&oID=' . $_GET['oID'] . '&action=oEdit&section=statusHistory'));
160     }
161
162     function _delete() {
163       osC_Order::delete($_GET['oID'], (isset($_POST['restock']) && ($_POST['restock'] == 'on') ? true : false));
164
165       osc_redirect(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&' . (isset($_GET['search']) ? 'search=' . $_GET['search'] . '&' : '') . (isset($_GET['status']) ? 'status=' . $_GET['status'] . '&' : '') . (isset($_GET['cID']) ? 'cID=' . $_GET['cID'] . '&' : '') . 'page=' . $_GET['page']));
166     }
167   }
168 ?>