PageRenderTime 61ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 1ms

/admin/controller/sale/order.php

https://github.com/zahidiub/yahya
PHP | 2571 lines | 2033 code | 532 blank | 6 comment | 468 complexity | 1b952441772512d6ca81fe723f6a74fa MD5 | raw file
Possible License(s): LGPL-2.1

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

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