PageRenderTime 50ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 1ms

/upload/admin/controller/sale/order.php

https://github.com/opencartlite/opencart
PHP | 2261 lines | 1759 code | 498 blank | 4 comment | 456 complexity | 11f71a6f85ab1802aae402b4b89fa913 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, GPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. class ControllerSaleOrder extends Controller {
  3. private $error = array();
  4. public function index() {
  5. $this->data += $this->language->load('sale/order');
  6. $this->document->setTitle($this->language->get('heading_title'));
  7. $this->load->model('sale/order');
  8. $this->getList();
  9. }
  10. public function insert() {
  11. $this->data += $this->language->load('sale/order');
  12. $this->document->setTitle($this->language->get('heading_title'));
  13. $this->load->model('sale/order');
  14. if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
  15. $this->model_sale_order->addOrder($this->request->post);
  16. $this->session->data['success'] = $this->language->get('text_success');
  17. $url = '';
  18. if (isset($this->request->get['filter_order_id'])) {
  19. $url .= '&filter_order_id=' . $this->request->get['filter_order_id'];
  20. }
  21. if (isset($this->request->get['filter_customer'])) {
  22. $url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8'));
  23. }
  24. if (isset($this->request->get['filter_order_status_id'])) {
  25. $url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
  26. }
  27. if (isset($this->request->get['filter_total'])) {
  28. $url .= '&filter_total=' . $this->request->get['filter_total'];
  29. }
  30. if (isset($this->request->get['filter_date_added'])) {
  31. $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
  32. }
  33. if (isset($this->request->get['filter_date_modified'])) {
  34. $url .= '&filter_date_modified=' . $this->request->get['filter_date_modified'];
  35. }
  36. if (isset($this->request->get['sort'])) {
  37. $url .= '&sort=' . $this->request->get['sort'];
  38. }
  39. if (isset($this->request->get['order'])) {
  40. $url .= '&order=' . $this->request->get['order'];
  41. }
  42. if (isset($this->request->get['page'])) {
  43. $url .= '&page=' . $this->request->get['page'];
  44. }
  45. $this->redirect($this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, 'SSL'));
  46. }
  47. $this->getForm();
  48. }
  49. public function update() {
  50. $this->data += $this->language->load('sale/order');
  51. $this->document->setTitle($this->language->get('heading_title'));
  52. $this->load->model('sale/order');
  53. if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
  54. $this->model_sale_order->editOrder($this->request->get['order_id'], $this->request->post);
  55. $this->session->data['success'] = $this->language->get('text_success');
  56. $url = '';
  57. if (isset($this->request->get['filter_order_id'])) {
  58. $url .= '&filter_order_id=' . $this->request->get['filter_order_id'];
  59. }
  60. if (isset($this->request->get['filter_customer'])) {
  61. $url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8'));
  62. }
  63. if (isset($this->request->get['filter_order_status_id'])) {
  64. $url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
  65. }
  66. if (isset($this->request->get['filter_total'])) {
  67. $url .= '&filter_total=' . $this->request->get['filter_total'];
  68. }
  69. if (isset($this->request->get['filter_date_added'])) {
  70. $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
  71. }
  72. if (isset($this->request->get['filter_date_modified'])) {
  73. $url .= '&filter_date_modified=' . $this->request->get['filter_date_modified'];
  74. }
  75. if (isset($this->request->get['sort'])) {
  76. $url .= '&sort=' . $this->request->get['sort'];
  77. }
  78. if (isset($this->request->get['order'])) {
  79. $url .= '&order=' . $this->request->get['order'];
  80. }
  81. if (isset($this->request->get['page'])) {
  82. $url .= '&page=' . $this->request->get['page'];
  83. }
  84. $this->redirect($this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, 'SSL'));
  85. }
  86. $this->getForm();
  87. }
  88. public function delete() {
  89. $this->data += $this->language->load('sale/order');
  90. $this->document->setTitle($this->language->get('heading_title'));
  91. $this->load->model('sale/order');
  92. if (isset($this->request->post['selected']) && ($this->validateDelete())) {
  93. foreach ($this->request->post['selected'] as $order_id) {
  94. $this->model_sale_order->deleteOrder($order_id);
  95. }
  96. $this->session->data['success'] = $this->language->get('text_success');
  97. $url = '';
  98. if (isset($this->request->get['filter_order_id'])) {
  99. $url .= '&filter_order_id=' . $this->request->get['filter_order_id'];
  100. }
  101. if (isset($this->request->get['filter_customer'])) {
  102. $url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8'));
  103. }
  104. if (isset($this->request->get['filter_order_status_id'])) {
  105. $url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
  106. }
  107. if (isset($this->request->get['filter_total'])) {
  108. $url .= '&filter_total=' . $this->request->get['filter_total'];
  109. }
  110. if (isset($this->request->get['filter_date_added'])) {
  111. $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
  112. }
  113. if (isset($this->request->get['filter_date_modified'])) {
  114. $url .= '&filter_date_modified=' . $this->request->get['filter_date_modified'];
  115. }
  116. if (isset($this->request->get['sort'])) {
  117. $url .= '&sort=' . $this->request->get['sort'];
  118. }
  119. if (isset($this->request->get['order'])) {
  120. $url .= '&order=' . $this->request->get['order'];
  121. }
  122. if (isset($this->request->get['page'])) {
  123. $url .= '&page=' . $this->request->get['page'];
  124. }
  125. $this->redirect($this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, 'SSL'));
  126. }
  127. $this->getList();
  128. }
  129. protected function getList() {
  130. if (isset($this->request->get['filter_order_id'])) {
  131. $filter_order_id = $this->request->get['filter_order_id'];
  132. } else {
  133. $filter_order_id = null;
  134. }
  135. if (isset($this->request->get['filter_customer'])) {
  136. $filter_customer = $this->request->get['filter_customer'];
  137. } else {
  138. $filter_customer = null;
  139. }
  140. if (isset($this->request->get['filter_order_status_id'])) {
  141. $filter_order_status_id = $this->request->get['filter_order_status_id'];
  142. } else {
  143. $filter_order_status_id = null;
  144. }
  145. if (isset($this->request->get['filter_total'])) {
  146. $filter_total = $this->request->get['filter_total'];
  147. } else {
  148. $filter_total = null;
  149. }
  150. if (isset($this->request->get['filter_date_added'])) {
  151. $filter_date_added = $this->request->get['filter_date_added'];
  152. } else {
  153. $filter_date_added = null;
  154. }
  155. if (isset($this->request->get['filter_date_modified'])) {
  156. $filter_date_modified = $this->request->get['filter_date_modified'];
  157. } else {
  158. $filter_date_modified = null;
  159. }
  160. if (isset($this->request->get['sort'])) {
  161. $sort = $this->request->get['sort'];
  162. } else {
  163. $sort = 'o.order_id';
  164. }
  165. if (isset($this->request->get['order'])) {
  166. $order = $this->request->get['order'];
  167. } else {
  168. $order = 'DESC';
  169. }
  170. if (isset($this->request->get['page'])) {
  171. $page = $this->request->get['page'];
  172. } else {
  173. $page = 1;
  174. }
  175. $url = '';
  176. if (isset($this->request->get['filter_order_id'])) {
  177. $url .= '&filter_order_id=' . $this->request->get['filter_order_id'];
  178. }
  179. if (isset($this->request->get['filter_customer'])) {
  180. $url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8'));
  181. }
  182. if (isset($this->request->get['filter_order_status_id'])) {
  183. $url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
  184. }
  185. if (isset($this->request->get['filter_total'])) {
  186. $url .= '&filter_total=' . $this->request->get['filter_total'];
  187. }
  188. if (isset($this->request->get['filter_date_added'])) {
  189. $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
  190. }
  191. if (isset($this->request->get['filter_date_modified'])) {
  192. $url .= '&filter_date_modified=' . $this->request->get['filter_date_modified'];
  193. }
  194. if (isset($this->request->get['sort'])) {
  195. $url .= '&sort=' . $this->request->get['sort'];
  196. }
  197. if (isset($this->request->get['order'])) {
  198. $url .= '&order=' . $this->request->get['order'];
  199. }
  200. if (isset($this->request->get['page'])) {
  201. $url .= '&page=' . $this->request->get['page'];
  202. }
  203. $this->data['breadcrumbs'] = array();
  204. $this->data['breadcrumbs'][] = array(
  205. 'text' => $this->language->get('text_home'),
  206. 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL')
  207. );
  208. $this->data['breadcrumbs'][] = array(
  209. 'text' => $this->language->get('heading_title'),
  210. 'href' => $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, 'SSL')
  211. );
  212. $this->data['invoice'] = $this->url->link('sale/order/invoice', 'token=' . $this->session->data['token'], 'SSL');
  213. $this->data['insert'] = $this->url->link('sale/order/insert', 'token=' . $this->session->data['token'], 'SSL');
  214. $this->data['delete'] = $this->url->link('sale/order/delete', 'token=' . $this->session->data['token'] . $url, 'SSL');
  215. $this->data['orders'] = array();
  216. $data = array(
  217. 'filter_order_id' => $filter_order_id,
  218. 'filter_customer' => $filter_customer,
  219. 'filter_order_status_id' => $filter_order_status_id,
  220. 'filter_total' => $filter_total,
  221. 'filter_date_added' => $filter_date_added,
  222. 'filter_date_modified' => $filter_date_modified,
  223. 'sort' => $sort,
  224. 'order' => $order,
  225. 'start' => ($page - 1) * $this->config->get('config_admin_limit'),
  226. 'limit' => $this->config->get('config_admin_limit')
  227. );
  228. $order_total = $this->model_sale_order->getTotalOrders($data);
  229. $results = $this->model_sale_order->getOrders($data);
  230. foreach ($results as $result) {
  231. $action = array();
  232. $action[] = array(
  233. 'text' => $this->language->get('text_view'),
  234. 'href' => $this->url->link('sale/order/info', 'token=' . $this->session->data['token'] . '&order_id=' . $result['order_id'] . $url, 'SSL')
  235. );
  236. if (strtotime($result['date_added']) > strtotime('-' . (int)$this->config->get('config_order_edit') . ' day')) {
  237. $action[] = array(
  238. 'text' => $this->language->get('text_edit'),
  239. 'href' => $this->url->link('sale/order/update', 'token=' . $this->session->data['token'] . '&order_id=' . $result['order_id'] . $url, 'SSL')
  240. );
  241. }
  242. $this->data['orders'][] = array(
  243. 'order_id' => $result['order_id'],
  244. 'customer' => $result['customer'],
  245. 'status' => $result['status'],
  246. 'total' => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value']),
  247. 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
  248. 'date_modified' => date($this->language->get('date_format_short'), strtotime($result['date_modified'])),
  249. 'selected' => isset($this->request->post['selected']) && in_array($result['order_id'], $this->request->post['selected']),
  250. 'action' => $action
  251. );
  252. }
  253. $this->data['token'] = $this->session->data['token'];
  254. if (isset($this->error['warning'])) {
  255. $this->data['error_warning'] = $this->error['warning'];
  256. } else {
  257. $this->data['error_warning'] = '';
  258. }
  259. if (isset($this->session->data['success'])) {
  260. $this->data['success'] = $this->session->data['success'];
  261. unset($this->session->data['success']);
  262. } else {
  263. $this->data['success'] = '';
  264. }
  265. $url = '';
  266. if (isset($this->request->get['filter_order_id'])) {
  267. $url .= '&filter_order_id=' . $this->request->get['filter_order_id'];
  268. }
  269. if (isset($this->request->get['filter_customer'])) {
  270. $url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8'));
  271. }
  272. if (isset($this->request->get['filter_order_status_id'])) {
  273. $url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
  274. }
  275. if (isset($this->request->get['filter_total'])) {
  276. $url .= '&filter_total=' . $this->request->get['filter_total'];
  277. }
  278. if (isset($this->request->get['filter_date_added'])) {
  279. $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
  280. }
  281. if (isset($this->request->get['filter_date_modified'])) {
  282. $url .= '&filter_date_modified=' . $this->request->get['filter_date_modified'];
  283. }
  284. if ($order == 'ASC') {
  285. $url .= '&order=DESC';
  286. } else {
  287. $url .= '&order=ASC';
  288. }
  289. if (isset($this->request->get['page'])) {
  290. $url .= '&page=' . $this->request->get['page'];
  291. }
  292. $this->data['sort_order'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . '&sort=o.order_id' . $url, 'SSL');
  293. $this->data['sort_customer'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . '&sort=customer' . $url, 'SSL');
  294. $this->data['sort_status'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . '&sort=status' . $url, 'SSL');
  295. $this->data['sort_total'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . '&sort=o.total' . $url, 'SSL');
  296. $this->data['sort_date_added'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . '&sort=o.date_added' . $url, 'SSL');
  297. $this->data['sort_date_modified'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . '&sort=o.date_modified' . $url, 'SSL');
  298. $url = '';
  299. if (isset($this->request->get['filter_order_id'])) {
  300. $url .= '&filter_order_id=' . $this->request->get['filter_order_id'];
  301. }
  302. if (isset($this->request->get['filter_customer'])) {
  303. $url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8'));
  304. }
  305. if (isset($this->request->get['filter_order_status_id'])) {
  306. $url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
  307. }
  308. if (isset($this->request->get['filter_total'])) {
  309. $url .= '&filter_total=' . $this->request->get['filter_total'];
  310. }
  311. if (isset($this->request->get['filter_date_added'])) {
  312. $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
  313. }
  314. if (isset($this->request->get['filter_date_modified'])) {
  315. $url .= '&filter_date_modified=' . $this->request->get['filter_date_modified'];
  316. }
  317. if (isset($this->request->get['sort'])) {
  318. $url .= '&sort=' . $this->request->get['sort'];
  319. }
  320. if (isset($this->request->get['order'])) {
  321. $url .= '&order=' . $this->request->get['order'];
  322. }
  323. $pagination = new Pagination();
  324. $pagination->total = $order_total;
  325. $pagination->page = $page;
  326. $pagination->limit = $this->config->get('config_admin_limit');
  327. $pagination->text = $this->language->get('text_pagination');
  328. $pagination->url = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url . '&page={page}', 'SSL');
  329. $this->data['pagination'] = $pagination->render();
  330. $this->data['filter_order_id'] = $filter_order_id;
  331. $this->data['filter_customer'] = $filter_customer;
  332. $this->data['filter_order_status_id'] = $filter_order_status_id;
  333. $this->data['filter_total'] = $filter_total;
  334. $this->data['filter_date_added'] = $filter_date_added;
  335. $this->data['filter_date_modified'] = $filter_date_modified;
  336. $this->load->model('localisation/order_status');
  337. $this->data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
  338. $this->data['sort'] = $sort;
  339. $this->data['order'] = $order;
  340. $this->template = 'sale/order_list.tpl';
  341. $this->children = array(
  342. 'common/header',
  343. 'common/footer'
  344. );
  345. $this->response->setOutput($this->render());
  346. }
  347. public function getForm() {
  348. $this->load->model('sale/customer');
  349. if (isset($this->error['warning'])) {
  350. $this->data['error_warning'] = $this->error['warning'];
  351. } else {
  352. $this->data['error_warning'] = '';
  353. }
  354. if (isset($this->error['firstname'])) {
  355. $this->data['error_firstname'] = $this->error['firstname'];
  356. } else {
  357. $this->data['error_firstname'] = '';
  358. }
  359. if (isset($this->error['lastname'])) {
  360. $this->data['error_lastname'] = $this->error['lastname'];
  361. } else {
  362. $this->data['error_lastname'] = '';
  363. }
  364. if (isset($this->error['email'])) {
  365. $this->data['error_email'] = $this->error['email'];
  366. } else {
  367. $this->data['error_email'] = '';
  368. }
  369. if (isset($this->error['telephone'])) {
  370. $this->data['error_telephone'] = $this->error['telephone'];
  371. } else {
  372. $this->data['error_telephone'] = '';
  373. }
  374. if (isset($this->error['payment_firstname'])) {
  375. $this->data['error_payment_firstname'] = $this->error['payment_firstname'];
  376. } else {
  377. $this->data['error_payment_firstname'] = '';
  378. }
  379. if (isset($this->error['payment_lastname'])) {
  380. $this->data['error_payment_lastname'] = $this->error['payment_lastname'];
  381. } else {
  382. $this->data['error_payment_lastname'] = '';
  383. }
  384. if (isset($this->error['payment_address_1'])) {
  385. $this->data['error_payment_address_1'] = $this->error['payment_address_1'];
  386. } else {
  387. $this->data['error_payment_address_1'] = '';
  388. }
  389. if (isset($this->error['payment_city'])) {
  390. $this->data['error_payment_city'] = $this->error['payment_city'];
  391. } else {
  392. $this->data['error_payment_city'] = '';
  393. }
  394. if (isset($this->error['payment_postcode'])) {
  395. $this->data['error_payment_postcode'] = $this->error['payment_postcode'];
  396. } else {
  397. $this->data['error_payment_postcode'] = '';
  398. }
  399. if (isset($this->error['payment_country'])) {
  400. $this->data['error_payment_country'] = $this->error['payment_country'];
  401. } else {
  402. $this->data['error_payment_country'] = '';
  403. }
  404. if (isset($this->error['payment_zone'])) {
  405. $this->data['error_payment_zone'] = $this->error['payment_zone'];
  406. } else {
  407. $this->data['error_payment_zone'] = '';
  408. }
  409. if (isset($this->error['payment_method'])) {
  410. $this->data['error_payment_method'] = $this->error['payment_method'];
  411. } else {
  412. $this->data['error_payment_method'] = '';
  413. }
  414. if (isset($this->error['shipping_firstname'])) {
  415. $this->data['error_shipping_firstname'] = $this->error['shipping_firstname'];
  416. } else {
  417. $this->data['error_shipping_firstname'] = '';
  418. }
  419. if (isset($this->error['shipping_lastname'])) {
  420. $this->data['error_shipping_lastname'] = $this->error['shipping_lastname'];
  421. } else {
  422. $this->data['error_shipping_lastname'] = '';
  423. }
  424. if (isset($this->error['shipping_address_1'])) {
  425. $this->data['error_shipping_address_1'] = $this->error['shipping_address_1'];
  426. } else {
  427. $this->data['error_shipping_address_1'] = '';
  428. }
  429. if (isset($this->error['shipping_city'])) {
  430. $this->data['error_shipping_city'] = $this->error['shipping_city'];
  431. } else {
  432. $this->data['error_shipping_city'] = '';
  433. }
  434. if (isset($this->error['shipping_postcode'])) {
  435. $this->data['error_shipping_postcode'] = $this->error['shipping_postcode'];
  436. } else {
  437. $this->data['error_shipping_postcode'] = '';
  438. }
  439. if (isset($this->error['shipping_country'])) {
  440. $this->data['error_shipping_country'] = $this->error['shipping_country'];
  441. } else {
  442. $this->data['error_shipping_country'] = '';
  443. }
  444. if (isset($this->error['shipping_zone'])) {
  445. $this->data['error_shipping_zone'] = $this->error['shipping_zone'];
  446. } else {
  447. $this->data['error_shipping_zone'] = '';
  448. }
  449. if (isset($this->error['shipping_method'])) {
  450. $this->data['error_shipping_method'] = $this->error['shipping_method'];
  451. } else {
  452. $this->data['error_shipping_method'] = '';
  453. }
  454. $url = '';
  455. if (isset($this->request->get['filter_order_id'])) {
  456. $url .= '&filter_order_id=' . $this->request->get['filter_order_id'];
  457. }
  458. if (isset($this->request->get['filter_customer'])) {
  459. $url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8'));
  460. }
  461. if (isset($this->request->get['filter_order_status_id'])) {
  462. $url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
  463. }
  464. if (isset($this->request->get['filter_total'])) {
  465. $url .= '&filter_total=' . $this->request->get['filter_total'];
  466. }
  467. if (isset($this->request->get['filter_date_added'])) {
  468. $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
  469. }
  470. if (isset($this->request->get['filter_date_modified'])) {
  471. $url .= '&filter_date_modified=' . $this->request->get['filter_date_modified'];
  472. }
  473. if (isset($this->request->get['sort'])) {
  474. $url .= '&sort=' . $this->request->get['sort'];
  475. }
  476. if (isset($this->request->get['order'])) {
  477. $url .= '&order=' . $this->request->get['order'];
  478. }
  479. if (isset($this->request->get['page'])) {
  480. $url .= '&page=' . $this->request->get['page'];
  481. }
  482. $this->data['breadcrumbs'] = array();
  483. $this->data['breadcrumbs'][] = array(
  484. 'text' => $this->language->get('text_home'),
  485. 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL')
  486. );
  487. $this->data['breadcrumbs'][] = array(
  488. 'text' => $this->language->get('heading_title'),
  489. 'href' => $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, 'SSL')
  490. );
  491. if (!isset($this->request->get['order_id'])) {
  492. $this->data['action'] = $this->url->link('sale/order/insert', 'token=' . $this->session->data['token'] . $url, 'SSL');
  493. } else {
  494. $this->data['action'] = $this->url->link('sale/order/update', 'token=' . $this->session->data['token'] . '&order_id=' . $this->request->get['order_id'] . $url, 'SSL');
  495. }
  496. $this->data['cancel'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, 'SSL');
  497. if (isset($this->request->get['order_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
  498. $order_info = $this->model_sale_order->getOrder($this->request->get['order_id']);
  499. }
  500. $this->data['token'] = $this->session->data['token'];
  501. if (isset($this->request->get['order_id'])) {
  502. $this->data['order_id'] = $this->request->get['order_id'];
  503. } else {
  504. $this->data['order_id'] = 0;
  505. }
  506. if (isset($this->request->post['store_id'])) {
  507. $this->data['store_id'] = $this->request->post['store_id'];
  508. } elseif (!empty($order_info)) {
  509. $this->data['store_id'] = $order_info['store_id'];
  510. } else {
  511. $this->data['store_id'] = '';
  512. }
  513. $this->load->model('setting/store');
  514. $this->data['stores'] = $this->model_setting_store->getStores();
  515. if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
  516. $this->data['store_url'] = HTTPS_CATALOG;
  517. } else {
  518. $this->data['store_url'] = HTTP_CATALOG;
  519. }
  520. if (isset($this->request->post['customer'])) {
  521. $this->data['customer'] = $this->request->post['customer'];
  522. } elseif (!empty($order_info)) {
  523. $this->data['customer'] = $order_info['customer'];
  524. } else {
  525. $this->data['customer'] = '';
  526. }
  527. if (isset($this->request->post['customer_id'])) {
  528. $this->data['customer_id'] = $this->request->post['customer_id'];
  529. } elseif (!empty($order_info)) {
  530. $this->data['customer_id'] = $order_info['customer_id'];
  531. } else {
  532. $this->data['customer_id'] = '';
  533. }
  534. if (isset($this->request->post['customer_group_id'])) {
  535. $this->data['customer_group_id'] = $this->request->post['customer_group_id'];
  536. } elseif (!empty($order_info)) {
  537. $this->data['customer_group_id'] = $order_info['customer_group_id'];
  538. } else {
  539. $this->data['customer_group_id'] = '';
  540. }
  541. $this->load->model('sale/customer_group');
  542. $this->data['customer_groups'] = $this->model_sale_customer_group->getCustomerGroups();
  543. if (isset($this->request->post['firstname'])) {
  544. $this->data['firstname'] = $this->request->post['firstname'];
  545. } elseif (!empty($order_info)) {
  546. $this->data['firstname'] = $order_info['firstname'];
  547. } else {
  548. $this->data['firstname'] = '';
  549. }
  550. if (isset($this->request->post['lastname'])) {
  551. $this->data['lastname'] = $this->request->post['lastname'];
  552. } elseif (!empty($order_info)) {
  553. $this->data['lastname'] = $order_info['lastname'];
  554. } else {
  555. $this->data['lastname'] = '';
  556. }
  557. if (isset($this->request->post['email'])) {
  558. $this->data['email'] = $this->request->post['email'];
  559. } elseif (!empty($order_info)) {
  560. $this->data['email'] = $order_info['email'];
  561. } else {
  562. $this->data['email'] = '';
  563. }
  564. if (isset($this->request->post['telephone'])) {
  565. $this->data['telephone'] = $this->request->post['telephone'];
  566. } elseif (!empty($order_info)) {
  567. $this->data['telephone'] = $order_info['telephone'];
  568. } else {
  569. $this->data['telephone'] = '';
  570. }
  571. if (isset($this->request->post['fax'])) {
  572. $this->data['fax'] = $this->request->post['fax'];
  573. } elseif (!empty($order_info)) {
  574. $this->data['fax'] = $order_info['fax'];
  575. } else {
  576. $this->data['fax'] = '';
  577. }
  578. if (isset($this->request->post['affiliate_id'])) {
  579. $this->data['affiliate_id'] = $this->request->post['affiliate_id'];
  580. } elseif (!empty($order_info)) {
  581. $this->data['affiliate_id'] = $order_info['affiliate_id'];
  582. } else {
  583. $this->data['affiliate_id'] = '';
  584. }
  585. if (isset($this->request->post['affiliate'])) {
  586. $this->data['affiliate'] = $this->request->post['affiliate'];
  587. } elseif (!empty($order_info)) {
  588. $this->data['affiliate'] = ($order_info['affiliate_id'] ? $order_info['affiliate_firstname'] . ' ' . $order_info['affiliate_lastname'] : '');
  589. } else {
  590. $this->data['affiliate'] = '';
  591. }
  592. if (isset($this->request->post['order_status_id'])) {
  593. $this->data['order_status_id'] = $this->request->post['order_status_id'];
  594. } elseif (!empty($order_info)) {
  595. $this->data['order_status_id'] = $order_info['order_status_id'];
  596. } else {
  597. $this->data['order_status_id'] = '';
  598. }
  599. $this->load->model('localisation/order_status');
  600. $this->data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
  601. if (isset($this->request->post['comment'])) {
  602. $this->data['comment'] = $this->request->post['comment'];
  603. } elseif (!empty($order_info)) {
  604. $this->data['comment'] = $order_info['comment'];
  605. } else {
  606. $this->data['comment'] = '';
  607. }
  608. $this->load->model('sale/customer');
  609. if (isset($this->request->post['customer_id'])) {
  610. $this->data['addresses'] = $this->model_sale_customer->getAddresses($this->request->post['customer_id']);
  611. } elseif (!empty($order_info)) {
  612. $this->data['addresses'] = $this->model_sale_customer->getAddresses($order_info['customer_id']);
  613. } else {
  614. $this->data['addresses'] = array();
  615. }
  616. if (isset($this->request->post['payment_firstname'])) {
  617. $this->data['payment_firstname'] = $this->request->post['payment_firstname'];
  618. } elseif (!empty($order_info)) {
  619. $this->data['payment_firstname'] = $order_info['payment_firstname'];
  620. } else {
  621. $this->data['payment_firstname'] = '';
  622. }
  623. if (isset($this->request->post['payment_lastname'])) {
  624. $this->data['payment_lastname'] = $this->request->post['payment_lastname'];
  625. } elseif (!empty($order_info)) {
  626. $this->data['payment_lastname'] = $order_info['payment_lastname'];
  627. } else {
  628. $this->data['payment_lastname'] = '';
  629. }
  630. if (isset($this->request->post['payment_company'])) {
  631. $this->data['payment_company'] = $this->request->post['payment_company'];
  632. } elseif (!empty($order_info)) {
  633. $this->data['payment_company'] = $order_info['payment_company'];
  634. } else {
  635. $this->data['payment_company'] = '';
  636. }
  637. if (isset($this->request->post['payment_address_1'])) {
  638. $this->data['payment_address_1'] = $this->request->post['payment_address_1'];
  639. } elseif (!empty($order_info)) {
  640. $this->data['payment_address_1'] = $order_info['payment_address_1'];
  641. } else {
  642. $this->data['payment_address_1'] = '';
  643. }
  644. if (isset($this->request->post['payment_address_2'])) {
  645. $this->data['payment_address_2'] = $this->request->post['payment_address_2'];
  646. } elseif (!empty($order_info)) {
  647. $this->data['payment_address_2'] = $order_info['payment_address_2'];
  648. } else {
  649. $this->data['payment_address_2'] = '';
  650. }
  651. if (isset($this->request->post['payment_city'])) {
  652. $this->data['payment_city'] = $this->request->post['payment_city'];
  653. } elseif (!empty($order_info)) {
  654. $this->data['payment_city'] = $order_info['payment_city'];
  655. } else {
  656. $this->data['payment_city'] = '';
  657. }
  658. if (isset($this->request->post['payment_postcode'])) {
  659. $this->data['payment_postcode'] = $this->request->post['payment_postcode'];
  660. } elseif (!empty($order_info)) {
  661. $this->data['payment_postcode'] = $order_info['payment_postcode'];
  662. } else {
  663. $this->data['payment_postcode'] = '';
  664. }
  665. if (isset($this->request->post['payment_country_id'])) {
  666. $this->data['payment_country_id'] = $this->request->post['payment_country_id'];
  667. } elseif (!empty($order_info)) {
  668. $this->data['payment_country_id'] = $order_info['payment_country_id'];
  669. } else {
  670. $this->data['payment_country_id'] = '';
  671. }
  672. if (isset($this->request->post['payment_zone_id'])) {
  673. $this->data['payment_zone_id'] = $this->request->post['payment_zone_id'];
  674. } elseif (!empty($order_info)) {
  675. $this->data['payment_zone_id'] = $order_info['payment_zone_id'];
  676. } else {
  677. $this->data['payment_zone_id'] = '';
  678. }
  679. if (isset($this->request->post['payment_method'])) {
  680. $this->data['payment_method'] = $this->request->post['payment_method'];
  681. } elseif (!empty($order_info)) {
  682. $this->data['payment_method'] = $order_info['payment_method'];
  683. } else {
  684. $this->data['payment_method'] = '';
  685. }
  686. if (isset($this->request->post['payment_code'])) {
  687. $this->data['payment_code'] = $this->request->post['payment_code'];
  688. } elseif (!empty($order_info)) {
  689. $this->data['payment_code'] = $order_info['payment_code'];
  690. } else {
  691. $this->data['payment_code'] = '';
  692. }
  693. if (isset($this->request->post['shipping_firstname'])) {
  694. $this->data['shipping_firstname'] = $this->request->post['shipping_firstname'];
  695. } elseif (!empty($order_info)) {
  696. $this->data['shipping_firstname'] = $order_info['shipping_firstname'];
  697. } else {
  698. $this->data['shipping_firstname'] = '';
  699. }
  700. if (isset($this->request->post['shipping_lastname'])) {
  701. $this->data['shipping_lastname'] = $this->request->post['shipping_lastname'];
  702. } elseif (!empty($order_info)) {
  703. $this->data['shipping_lastname'] = $order_info['shipping_lastname'];
  704. } else {
  705. $this->data['shipping_lastname'] = '';
  706. }
  707. if (isset($this->request->post['shipping_company'])) {
  708. $this->data['shipping_company'] = $this->request->post['shipping_company'];
  709. } elseif (!empty($order_info)) {
  710. $this->data['shipping_company'] = $order_info['shipping_company'];
  711. } else {
  712. $this->data['shipping_company'] = '';
  713. }
  714. if (isset($this->request->post['shipping_address_1'])) {
  715. $this->data['shipping_address_1'] = $this->request->post['shipping_address_1'];
  716. } elseif (!empty($order_info)) {
  717. $this->data['shipping_address_1'] = $order_info['shipping_address_1'];
  718. } else {
  719. $this->data['shipping_address_1'] = '';
  720. }
  721. if (isset($this->request->post['shipping_address_2'])) {
  722. $this->data['shipping_address_2'] = $this->request->post['shipping_address_2'];
  723. } elseif (!empty($order_info)) {
  724. $this->data['shipping_address_2'] = $order_info['shipping_address_2'];
  725. } else {
  726. $this->data['shipping_address_2'] = '';
  727. }
  728. if (isset($this->request->post['shipping_city'])) {
  729. $this->data['shipping_city'] = $this->request->post['shipping_city'];
  730. } elseif (!empty($order_info)) {
  731. $this->data['shipping_city'] = $order_info['shipping_city'];
  732. } else {
  733. $this->data['shipping_city'] = '';
  734. }
  735. if (isset($this->request->post['shipping_postcode'])) {
  736. $this->data['shipping_postcode'] = $this->request->post['shipping_postcode'];
  737. } elseif (!empty($order_info)) {
  738. $this->data['shipping_postcode'] = $order_info['shipping_postcode'];
  739. } else {
  740. $this->data['shipping_postcode'] = '';
  741. }
  742. if (isset($this->request->post['shipping_country_id'])) {
  743. $this->data['shipping_country_id'] = $this->request->post['shipping_country_id'];
  744. } elseif (!empty($order_info)) {
  745. $this->data['shipping_country_id'] = $order_info['shipping_country_id'];
  746. } else {
  747. $this->data['shipping_country_id'] = '';
  748. }
  749. if (isset($this->request->post['shipping_zone_id'])) {
  750. $this->data['shipping_zone_id'] = $this->request->post['shipping_zone_id'];
  751. } elseif (!empty($order_info)) {
  752. $this->data['shipping_zone_id'] = $order_info['shipping_zone_id'];
  753. } else {
  754. $this->data['shipping_zone_id'] = '';
  755. }
  756. $this->load->model('localisation/country');
  757. $this->data['countries'] = $this->model_localisation_country->getCountries();
  758. if (isset($this->request->post['shipping_method'])) {
  759. $this->data['shipping_method'] = $this->request->post['shipping_method'];
  760. } elseif (!empty($order_info)) {
  761. $this->data['shipping_method'] = $order_info['shipping_method'];
  762. } else {
  763. $this->data['shipping_method'] = '';
  764. }
  765. if (isset($this->request->post['shipping_code'])) {
  766. $this->data['shipping_code'] = $this->request->post['shipping_code'];
  767. } elseif (!empty($order_info)) {
  768. $this->data['shipping_code'] = $order_info['shipping_code'];
  769. } else {
  770. $this->data['shipping_code'] = '';
  771. }
  772. if (isset($this->request->post['order_product'])) {
  773. $order_products = $this->request->post['order_product'];
  774. } elseif (isset($this->request->get['order_id'])) {
  775. $order_products = $this->model_sale_order->getOrderProducts($this->request->get['order_id']);
  776. } else {
  777. $order_products = array();
  778. }
  779. $this->load->model('catalog/product');
  780. $this->data['order_products'] = array();
  781. foreach ($order_products as $order_product) {
  782. if (isset($order_product['order_option'])) {
  783. $order_option = $order_product['order_option'];
  784. } elseif (isset($this->request->get['order_id'])) {
  785. $order_option = $this->model_sale_order->getOrderOptions($this->request->get['order_id'], $order_product['order_product_id']);
  786. } else {
  787. $order_option = array();
  788. }
  789. if (isset($order_product['order_download'])) {
  790. $order_download = $order_product['order_download'];
  791. } elseif (isset($this->request->get['order_id'])) {
  792. $order_download = $this->model_sale_order->getOrderDownloads($this->request->get['order_id'], $order_product['order_product_id']);
  793. } else {
  794. $order_download = array();
  795. }
  796. $this->data['order_products'][] = array(
  797. 'order_product_id' => $order_product['order_product_id'],
  798. 'product_id' => $order_product['product_id'],
  799. 'name' => $order_product['name'],
  800. 'model' => $order_product['model'],
  801. 'option' => $order_option,
  802. 'download' => $order_download,
  803. 'quantity' => $order_product['quantity'],
  804. 'price' => $order_product['price'],
  805. 'total' => $order_product['total'],
  806. 'tax' => $order_product['tax'],
  807. 'reward' => $order_product['reward']
  808. );
  809. }
  810. if (isset($this->request->post['order_voucher'])) {
  811. $this->data['order_vouchers'] = $this->request->post['order_voucher'];
  812. } elseif (isset($this->request->get['order_id'])) {
  813. $this->data['order_vouchers'] = $this->model_sale_order->getOrderVouchers($this->request->get['order_id']);
  814. } else {
  815. $this->data['order_vouchers'] = array();
  816. }
  817. $this->load->model('sale/voucher_theme');
  818. $this->data['voucher_themes'] = $this->model_sale_voucher_theme->getVoucherThemes();
  819. if (isset($this->request->post['order_total'])) {
  820. $this->data['order_totals'] = $this->request->post['order_total'];
  821. } elseif (isset($this->request->get['order_id'])) {
  822. $this->data['order_totals'] = $this->model_sale_order->getOrderTotals($this->request->get['order_id']);
  823. } else {
  824. $this->data['order_totals'] = array();
  825. }
  826. $this->template = 'sale/order_form.tpl';
  827. $this->children = array(
  828. 'common/header',
  829. 'common/footer'
  830. );
  831. $this->response->setOutput($this->render());
  832. }
  833. protected function validateForm() {
  834. if (!$this->user->hasPermission('modify', 'sale/order')) {
  835. $this->error['warning'] = $this->language->get('error_permission');
  836. }
  837. if ((utf8_strlen($this->request->post['firstname']) < 1) || (utf8_strlen($this->request->post['firstname']) > 32)) {
  838. $this->error['firstname'] = $this->language->get('error_firstname');
  839. }
  840. if ((utf8_strlen($this->request->post['lastname']) < 1) || (utf8_strlen($this->request->post['lastname']) > 32)) {
  841. $this->error['lastname'] = $this->language->get('error_lastname');
  842. }
  843. if ((utf8_strlen($this->request->post['email']) > 96) || (!preg_match('/^[^\@]+@.*\.[a-z]{2,6}$/i', $this->request->post['email']))) {
  844. $this->error['email'] = $this->language->get('error_email');
  845. }
  846. if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 32)) {
  847. $this->error['telephone'] = $this->language->get('error_telephone');
  848. }
  849. if ((utf8_strlen($this->request->post['payment_firstname']) < 1) || (utf8_strlen($this->request->post['payment_firstname']) > 32)) {
  850. $this->error['payment_firstname'] = $this->language->get('error_firstname');
  851. }
  852. if ((utf8_strlen($this->request->post['payment_lastname']) < 1) || (utf8_strlen($this->request->post['payment_lastname']) > 32)) {
  853. $this->error['payment_lastname'] = $this->language->get('error_lastname');
  854. }
  855. if ((utf8_strlen($this->request->post['payment_address_1']) < 3) || (utf8_strlen($this->request->post['payment_address_1']) > 128)) {
  856. $this->error['payment_address_1'] = $this->language->get('error_address_1');
  857. }
  858. if ((utf8_strlen($this->request->post['payment_city']) < 3) || (utf8_strlen($this->request->post['payment_city']) > 128)) {
  859. $this->error['payment_city'] = $this->language->get('error_city');
  860. }
  861. $this->load->model('localisation/country');
  862. $country_info = $this->model_localisation_country->getCountry($this->request->post['payment_country_id']);
  863. if ($country_info && $country_info['postcode_required'] && (utf8_strlen($this->request->post['payment_postcode']) < 2) || (utf8_strlen($this->request->post['payment_postcode']) > 10)) {
  864. $this->error['payment_postcode'] = $this->language->get('error_postcode');
  865. }
  866. if ($this->request->post['payment_country_id'] == '') {
  867. $this->error['payment_country'] = $this->language->get('error_country');
  868. }
  869. if (!isset($this->request->post['payment_zone_id']) || $this->request->post['payment_zone_id'] == '') {
  870. $this->error['payment_zone'] = $this->language->get('error_zone');
  871. }
  872. if ($this->request->post['payment_method'] == '') {
  873. $this->error['payment_zone'] = $this->language->get('error_zone');
  874. }
  875. if (!$this->request->post['payment_method']) {
  876. $this->error['payment_method'] = $this->language->get('error_payment');
  877. }
  878. // Check if any products require shipping
  879. $shipping = false;
  880. if (isset($this->request->post['order_product'])) {
  881. $this->load->model('catalog/product');
  882. foreach ($this->request->post['order_product'] as $order_product) {
  883. $product_info = $this->model_catalog_product->getProduct($order_product['product_id']);
  884. if ($product_info && $product_info['shipping']) {
  885. $shipping = true;
  886. }
  887. }
  888. }
  889. if ($shipping) {
  890. if ((utf8_strlen($this->request->post['shipping_firstname']) < 1) || (utf8_strlen($this->request->post['shipping_firstname']) > 32)) {
  891. $this->error['shipping_firstname'] = $this->language->get('error_firstname');
  892. }
  893. if ((utf8_strlen($this->request->post['shipping_lastname']) < 1) || (utf8_strlen($this->request->post['shipping_lastname']) > 32)) {
  894. $this->error['shipping_lastname'] = $this->language->get('error_lastname');
  895. }
  896. if ((utf8_strlen($this->request->post['shipping_address_1']) < 3) || (utf8_strlen($this->request->post['shipping_address_1']) > 128)) {
  897. $this->error['shipping_address_1'] = $this->language->get('error_address_1');
  898. }
  899. if ((utf8_strlen($this->request->post['shipping_city']) < 3) || (utf8_strlen($this->request->post['shipping_city']) > 128)) {
  900. $this->error['shipping_city'] = $this->language->get('error_city');
  901. }
  902. $this->load->model('localisation/country');
  903. $country_info = $this->model_localisation_country->getCountry($this->request->post['shipping_country_id']);
  904. if ($country_info && $country_info['postcode_required'] && (utf8_strlen($this->request->post['shipping_postcode']) < 2) || (utf8_strlen($this->request->post['shipping_postcode']) > 10)) {
  905. $this->error['shipping_postcode'] = $this->language->get('error_postcode');
  906. }
  907. if ($this->request->post['shipping_country_id'] == '') {
  908. $this->error['shipping_country'] = $this->language->get('error_country');
  909. }
  910. if (!isset($this->request->post['shipping_zone_id']) || $this->request->post['shipping_zone_id'] == '') {
  911. $this->error['shipping_zone'] = $this->language->get('error_zone');
  912. }
  913. if (!$this->request->post['shipping_method']) {
  914. $this->error['shipping_method'] = $this->language->get('error_shipping');
  915. }
  916. }
  917. if ($this->error && !isset($this->error['warning'])) {
  918. $this->error['warning'] = $this->language->get('error_warning');
  919. }
  920. if (!$this->error) {
  921. return true;
  922. } else {
  923. return false;
  924. }
  925. }
  926. protected function validateDelete() {
  927. if (!$this->user->hasPermission('modify', 'sale/order')) {
  928. $this->error['warning'] = $this->language->get('error_permission');
  929. }
  930. if (!$this->error) {
  931. return true;
  932. } else {
  933. return false;
  934. }
  935. }
  936. public function country() {
  937. $json = array();
  938. $this->load->model('localisation/country');
  939. $country_info = $this->model_localisation_country->getCountry($this->request->get['country_id']);
  940. if ($country_info) {
  941. $this->load->model('localisation/zone');
  942. $json = array(
  943. 'country_id' => $country_info['country_id'],
  944. 'name' => $country_info['name'],
  945. 'iso_code_2' => $country_info['iso_code_2'],
  946. 'iso_code_3' => $country_info['iso_code_3'],
  947. 'address_format' => $country_info['address_format'],
  948. 'postcode_required' => $country_info['postcode_required'],
  949. 'zone' => $this->model_localisation_zone->getZonesByCountryId($this->request->get['country_id']),
  950. 'status' => $country_info['status']
  951. );
  952. }
  953. $this->response->setOutput(json_encode($json));
  954. }
  955. public function info() {
  956. $this->load->model('sale/order');
  957. if (isset($this->request->get['order_id'])) {
  958. $order_id = $this->request->get['order_id'];
  959. } else {
  960. $order_id = 0;
  961. }
  962. $order_info = $this->model_sale_order->getOrder($order_id);
  963. if ($order_info) {
  964. $this->data += $this->language->load('sale/order');
  965. $this->document->setTitle($this->language->get('heading_title'));
  966. $this->data['token'] = $this->session->data['token'];
  967. $url = '';
  968. if (isset($this->request->get['filter_order_id'])) {
  969. $url .= '&filter_order_id=' . $this->request->get['filter_order_id'];
  970. }
  971. if (isset($this->request->get['filter_customer'])) {
  972. $url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8'));
  973. }
  974. if (isset($this->request->get['filter_order_status_id'])) {
  975. $url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
  976. }
  977. if (isset($this->request->get['filter_total'])) {
  978. $url .= '&filter_total=' . $this->request->get['filter_total'];
  979. }
  980. if (isset($this->request->get['filter_date_added'])) {
  981. $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
  982. }
  983. if (isset($this->request->get['filter_date_modified'])) {
  984. $url .= '&filter_date_modified=' . $this->request->get['filter_date_modified'];
  985. }
  986. if (isset($this->request->get['sort'])) {
  987. $url .= '&sort=' . $this->request->get['sort'];
  988. }
  989. if (isset($this->request->get['order'])) {
  990. $url .= '&order=' . $this->request->get['order'];
  991. }
  992. if (isset($this->request->get['page'])) {
  993. $url .= '&page=' . $this->request->get['page'];
  994. }
  995. $this->data['breadcrumbs'] = array();
  996. $this->data['breadcrumbs'][] = array(
  997. 'text' => $this->language->get('text_home'),
  998. 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL')
  999. );
  1000. $this->data['breadcrumbs'][] = array(
  1001. 'text' => $this->language->get('heading_title'),
  1002. 'href' => $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, 'SSL')
  1003. );
  1004. $this->data['invoice'] = $this->url->link('sale/order/invoice', 'token=' . $this->session->data['token'] . '&order_id=' . (int)$this->request->get['order_id'], 'SSL');
  1005. $this->data['cancel'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, 'SSL');
  1006. $this->data['order_id'] = $this->request->get['order_id'];
  1007. if ($order_info['invoice_no']) {
  1008. $this->data['invoice_no'] = $order_info['invoice_prefix'] . $order_info['invoice_no'];
  1009. } else {
  1010. $this->data['invoice_no'] = '';
  1011. }
  1012. $this->data['store_name'] = $order_info['store_name'];
  1013. $this->data['store_url'] = $order_info['store_url'];
  1014. $this->data['firstname'] = $order_info['firstname'];
  1015. $this->data['lastname'] = $order_info['lastname'];
  1016. if ($order_info['customer_id']) {
  1017. $this->data['customer'] = $this->url->link('sale/customer/update', 'token=' . $this->session->data['token'] . '&customer_id=' . $order_info['customer_id'], 'SSL');
  1018. } else {
  1019. $this->data['customer'] = '';
  1020. }
  1021. $this->load->model('sale/customer_group');
  1022. $customer_group_info = $this->model_sale_customer_group->getCustomerGroup($order_info['customer_group_id']);
  1023. if ($customer_group_info) {
  1024. $this->data['customer_group'] = $customer_group_info['name'];
  1025. } else {
  1026. $this->data['customer_group'] = '';
  1027. }
  1028. $this->data['email'] = $order_info['email'];
  1029. $this->data['telephone'] = $order_info['telephone'];
  1030. $this->data['fax'] = $order_info['fax'];
  1031. $this->data['comment'] = nl2br($order_info['comment']);
  1032. $this->data['shipping_method'] = $order_info['shipping_method'];
  1033. $this->data['payment_method'] = $order_info['payment_method'];
  1034. $this->data['total'] = $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value']);
  1035. if ($order_info['total'] < 0) {
  1036. $this->data['credit'] = $order_info['total'];
  1037. } else {
  1038. $this->data['credit'] = 0;
  1039. }
  1040. $this->load->model('sale/customer');
  1041. $this->data['credit_total'] = $this->model_sale_customer->getTotalTransactionsByOrderId($this->request->get['order_id']);
  1042. $this->data['reward'] = $order_info['reward'];
  1043. $this->data['reward_total'] = $this->model_sale_customer->getTotalCustomerRewardsByOrderId($this->request->get['order_id']);
  1044. $this->data['affiliate_firstname'] = $order_info['affiliate_firstname'];
  1045. $this->data['affiliate_lastname'] = $order_info['affiliate_lastname'];
  1046. if ($order_info['affiliate_id']) {
  1047. $this->data['affiliate'] = $this->url->link('sale/affiliate/update', 'token=' . $this->session->data['token'] . '&affiliate_id=' . $order_info['affiliate_id'], 'SSL');
  1048. } else {
  1049. $this->data['affiliate'] = '';
  1050. }
  1051. $this->data['commission'] = $this->currency->format($order_info['commission'], $order_info['currency_code'], $order_info['currency_value']);
  1052. $this->load->model('sale/affiliate');
  1053. $this->data['commission_total'] = $this->model_sale_affiliate->getTotalTransactionsByOrderId($this->request->get['order_id']);
  1054. $this->load->model('localisation/order_status');
  1055. $order_status_info = $this->model_localisation_order_status->getOrderStatus($order_info['order_status_id']);
  1056. if ($order_status_info) {
  1057. $this->data['order_status'] = $order_status_info['name'];
  1058. } else {
  1059. $this->data['order_status'] = '';
  1060. }
  1061. $this->data['ip'] = $order_info['ip'];
  1062. $this->data['forwarded_ip'] = $order_info['forwarded_ip'];
  1063. $this->data['user_agent'] = $order_info['user_agent'];
  1064. $this->data['accept_language'] = $order_info['accept_language'];
  1065. $this->data['date_added'] = date($this->language->get('date_format_short'), strtotime($orde

Large files files are truncated, but you can click here to view the full file