1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* Divine CMS - Open source CMS for widespread use. |
4
|
|
|
Copyright (c) 2019 Mykola Burakov ([email protected]) |
5
|
|
|
|
6
|
|
|
See SOURCE.txt for other and additional information. |
7
|
|
|
|
8
|
|
|
This file is part of Divine CMS. |
9
|
|
|
|
10
|
|
|
This program is free software: you can redistribute it and/or modify |
11
|
|
|
it under the terms of the GNU General Public License as published by |
12
|
|
|
the Free Software Foundation, either version 3 of the License, or |
13
|
|
|
(at your option) any later version. |
14
|
|
|
|
15
|
|
|
This program is distributed in the hope that it will be useful, |
16
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
17
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18
|
|
|
GNU General Public License for more details. |
19
|
|
|
|
20
|
|
|
You should have received a copy of the GNU General Public License |
21
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
22
|
|
|
|
23
|
|
|
class ControllerSaleOrder extends \Divine\Engine\Core\Controller |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
private $error = array(); |
26
|
|
|
|
27
|
|
|
public function index() |
|
|
|
|
28
|
|
|
{ |
29
|
|
|
$this->load->language('sale/order'); |
30
|
|
|
|
31
|
|
|
$this->document->setTitle($this->language->get('heading_title')); |
32
|
|
|
|
33
|
|
|
$this->load->model('sale/order'); |
34
|
|
|
|
35
|
|
|
$this->getList(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function add() |
39
|
|
|
{ |
40
|
|
|
$this->load->language('sale/order'); |
41
|
|
|
|
42
|
|
|
$this->document->setTitle($this->language->get('heading_title')); |
43
|
|
|
|
44
|
|
|
$this->load->model('sale/order'); |
45
|
|
|
|
46
|
|
|
$this->getForm(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function edit() |
50
|
|
|
{ |
51
|
|
|
$this->load->language('sale/order'); |
52
|
|
|
|
53
|
|
|
$this->document->setTitle($this->language->get('heading_title')); |
54
|
|
|
|
55
|
|
|
$this->load->model('sale/order'); |
56
|
|
|
|
57
|
|
|
$this->getForm(); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function delete() |
61
|
|
|
{ |
62
|
|
|
$this->load->language('sale/order'); |
63
|
|
|
|
64
|
|
|
$this->document->setTitle($this->language->get('heading_title')); |
65
|
|
|
|
66
|
|
|
$this->load->model('sale/order'); |
67
|
|
|
|
68
|
|
|
if (isset($this->request->post['selected']) && $this->validate()) { |
69
|
|
|
foreach ($this->request->post['selected'] as $order_id) { |
70
|
|
|
$this->model_sale_order->deleteOrder($order_id); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
$this->session->data['success'] = $this->language->get('text_success'); |
74
|
|
|
|
75
|
|
|
$url = ''; |
76
|
|
|
|
77
|
|
|
if (isset($this->request->get['filter_order_id'])) { |
78
|
|
|
$url .= '&filter_order_id=' . $this->request->get['filter_order_id']; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
if (isset($this->request->get['filter_customer'])) { |
82
|
|
|
$url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8')); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
if (isset($this->request->get['filter_order_status'])) { |
86
|
|
|
$url .= '&filter_order_status=' . $this->request->get['filter_order_status']; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
if (isset($this->request->get['filter_total'])) { |
90
|
|
|
$url .= '&filter_total=' . $this->request->get['filter_total']; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
94
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
if (isset($this->request->get['filter_date_modified'])) { |
98
|
|
|
$url .= '&filter_date_modified=' . $this->request->get['filter_date_modified']; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
$this->response->redirect($this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, true)); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
$this->getList(); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
protected function getList() |
108
|
|
|
{ |
109
|
|
|
if (isset($this->request->get['filter_order_id'])) { |
110
|
|
|
$filter_order_id = $this->request->get['filter_order_id']; |
111
|
|
|
} else { |
112
|
|
|
$filter_order_id = null; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
if (isset($this->request->get['filter_customer'])) { |
116
|
|
|
$filter_customer = $this->request->get['filter_customer']; |
117
|
|
|
} else { |
118
|
|
|
$filter_customer = null; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
if (isset($this->request->get['filter_order_status'])) { |
122
|
|
|
$filter_order_status = $this->request->get['filter_order_status']; |
123
|
|
|
} else { |
124
|
|
|
$filter_order_status = null; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
if (isset($this->request->get['filter_total'])) { |
128
|
|
|
$filter_total = $this->request->get['filter_total']; |
129
|
|
|
} else { |
130
|
|
|
$filter_total = null; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
134
|
|
|
$filter_date_added = $this->request->get['filter_date_added']; |
135
|
|
|
} else { |
136
|
|
|
$filter_date_added = null; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
if (isset($this->request->get['filter_date_modified'])) { |
140
|
|
|
$filter_date_modified = $this->request->get['filter_date_modified']; |
141
|
|
|
} else { |
142
|
|
|
$filter_date_modified = null; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
if (isset($this->request->get['sort'])) { |
146
|
|
|
$sort = $this->request->get['sort']; |
147
|
|
|
} else { |
148
|
|
|
$sort = 'o.order_id'; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
if (isset($this->request->get['order'])) { |
152
|
|
|
$order = $this->request->get['order']; |
153
|
|
|
} else { |
154
|
|
|
$order = 'DESC'; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
if (isset($this->request->get['page'])) { |
158
|
|
|
$page = $this->request->get['page']; |
159
|
|
|
} else { |
160
|
|
|
$page = 1; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
$url = ''; |
164
|
|
|
|
165
|
|
|
if (isset($this->request->get['filter_order_id'])) { |
166
|
|
|
$url .= '&filter_order_id=' . $this->request->get['filter_order_id']; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
if (isset($this->request->get['filter_customer'])) { |
170
|
|
|
$url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8')); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
if (isset($this->request->get['filter_order_status'])) { |
174
|
|
|
$url .= '&filter_order_status=' . $this->request->get['filter_order_status']; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
if (isset($this->request->get['filter_total'])) { |
178
|
|
|
$url .= '&filter_total=' . $this->request->get['filter_total']; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
182
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
if (isset($this->request->get['filter_date_modified'])) { |
186
|
|
|
$url .= '&filter_date_modified=' . $this->request->get['filter_date_modified']; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
if (isset($this->request->get['sort'])) { |
190
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
if (isset($this->request->get['order'])) { |
194
|
|
|
$url .= '&order=' . $this->request->get['order']; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
if (isset($this->request->get['page'])) { |
198
|
|
|
$url .= '&page=' . $this->request->get['page']; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
$data['breadcrumbs'] = array(); |
|
|
|
|
202
|
|
|
|
203
|
|
|
$data['breadcrumbs'][] = array( |
204
|
|
|
'text' => $this->language->get('text_home'), |
205
|
|
|
'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
206
|
|
|
); |
207
|
|
|
|
208
|
|
|
$data['breadcrumbs'][] = array( |
209
|
|
|
'text' => $this->language->get('heading_title'), |
210
|
|
|
'href' => $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, true) |
211
|
|
|
); |
212
|
|
|
|
213
|
|
|
$data['invoice'] = $this->url->link('sale/order/invoice', 'token=' . $this->session->data['token'], true); |
214
|
|
|
$data['shipping'] = $this->url->link('sale/order/shipping', 'token=' . $this->session->data['token'], true); |
215
|
|
|
$data['add'] = $this->url->link('sale/order/add', 'token=' . $this->session->data['token'], true); |
216
|
|
|
$data['delete'] = $this->url->link('sale/order/delete', 'token=' . $this->session->data['token'], true); |
217
|
|
|
|
218
|
|
|
$data['orders'] = array(); |
219
|
|
|
|
220
|
|
|
$filter_data = array( |
221
|
|
|
'filter_order_id' => $filter_order_id, |
222
|
|
|
'filter_customer' => $filter_customer, |
223
|
|
|
'filter_order_status' => $filter_order_status, |
224
|
|
|
'filter_total' => $filter_total, |
225
|
|
|
'filter_date_added' => $filter_date_added, |
226
|
|
|
'filter_date_modified' => $filter_date_modified, |
227
|
|
|
'sort' => $sort, |
228
|
|
|
'order' => $order, |
229
|
|
|
'start' => ($page - 1) * $this->config->get('config_limit_admin'), |
230
|
|
|
'limit' => $this->config->get('config_limit_admin') |
231
|
|
|
); |
232
|
|
|
|
233
|
|
|
$order_total = $this->model_sale_order->getTotalOrders($filter_data); |
234
|
|
|
|
235
|
|
|
$results = $this->model_sale_order->getOrders($filter_data); |
236
|
|
|
|
237
|
|
|
foreach ($results as $result) { |
238
|
|
|
$data['orders'][] = array( |
239
|
|
|
'order_id' => $result['order_id'], |
240
|
|
|
'customer' => $result['customer'], |
241
|
|
|
'order_status' => $result['order_status'] ? $result['order_status'] : $this->language->get('text_missing'), |
242
|
|
|
'total' => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value']), |
243
|
|
|
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])), |
244
|
|
|
'date_modified' => date($this->language->get('date_format_short'), strtotime($result['date_modified'])), |
245
|
|
|
'shipping_code' => $result['shipping_code'], |
246
|
|
|
'view' => $this->url->link('sale/order/info', 'token=' . $this->session->data['token'] . '&order_id=' . $result['order_id'] . $url, true), |
247
|
|
|
'edit' => $this->url->link('sale/order/edit', 'token=' . $this->session->data['token'] . '&order_id=' . $result['order_id'] . $url, true) |
248
|
|
|
); |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
$data['heading_title'] = $this->language->get('heading_title'); |
252
|
|
|
|
253
|
|
|
$data['text_list'] = $this->language->get('text_list'); |
254
|
|
|
$data['text_no_results'] = $this->language->get('text_no_results'); |
255
|
|
|
$data['text_confirm'] = $this->language->get('text_confirm'); |
256
|
|
|
$data['text_missing'] = $this->language->get('text_missing'); |
257
|
|
|
$data['text_loading'] = $this->language->get('text_loading'); |
258
|
|
|
|
259
|
|
|
$data['column_order_id'] = $this->language->get('column_order_id'); |
260
|
|
|
$data['column_customer'] = $this->language->get('column_customer'); |
261
|
|
|
$data['column_status'] = $this->language->get('column_status'); |
262
|
|
|
$data['column_total'] = $this->language->get('column_total'); |
263
|
|
|
$data['column_date_added'] = $this->language->get('column_date_added'); |
264
|
|
|
$data['column_date_modified'] = $this->language->get('column_date_modified'); |
265
|
|
|
$data['column_action'] = $this->language->get('column_action'); |
266
|
|
|
|
267
|
|
|
$data['entry_order_id'] = $this->language->get('entry_order_id'); |
268
|
|
|
$data['entry_customer'] = $this->language->get('entry_customer'); |
269
|
|
|
$data['entry_order_status'] = $this->language->get('entry_order_status'); |
270
|
|
|
$data['entry_total'] = $this->language->get('entry_total'); |
271
|
|
|
$data['entry_date_added'] = $this->language->get('entry_date_added'); |
272
|
|
|
$data['entry_date_modified'] = $this->language->get('entry_date_modified'); |
273
|
|
|
|
274
|
|
|
$data['button_invoice_print'] = $this->language->get('button_invoice_print'); |
275
|
|
|
$data['button_shipping_print'] = $this->language->get('button_shipping_print'); |
276
|
|
|
$data['button_add'] = $this->language->get('button_add'); |
277
|
|
|
$data['button_edit'] = $this->language->get('button_edit'); |
278
|
|
|
$data['button_delete'] = $this->language->get('button_delete'); |
279
|
|
|
$data['button_filter'] = $this->language->get('button_filter'); |
280
|
|
|
$data['button_view'] = $this->language->get('button_view'); |
281
|
|
|
$data['button_ip_add'] = $this->language->get('button_ip_add'); |
282
|
|
|
|
283
|
|
|
$data['token'] = $this->session->data['token']; |
284
|
|
|
|
285
|
|
|
if (isset($this->error['warning'])) { |
286
|
|
|
$data['error_warning'] = $this->error['warning']; |
287
|
|
|
} else { |
288
|
|
|
$data['error_warning'] = ''; |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
if (isset($this->session->data['success'])) { |
292
|
|
|
$data['success'] = $this->session->data['success']; |
293
|
|
|
|
294
|
|
|
unset($this->session->data['success']); |
295
|
|
|
} else { |
296
|
|
|
$data['success'] = ''; |
297
|
|
|
} |
298
|
|
|
|
299
|
|
|
if (isset($this->request->post['selected'])) { |
300
|
|
|
$data['selected'] = (array)$this->request->post['selected']; |
301
|
|
|
} else { |
302
|
|
|
$data['selected'] = array(); |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
$url = ''; |
306
|
|
|
|
307
|
|
|
if (isset($this->request->get['filter_order_id'])) { |
308
|
|
|
$url .= '&filter_order_id=' . $this->request->get['filter_order_id']; |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
if (isset($this->request->get['filter_customer'])) { |
312
|
|
|
$url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8')); |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
if (isset($this->request->get['filter_order_status'])) { |
316
|
|
|
$url .= '&filter_order_status=' . $this->request->get['filter_order_status']; |
317
|
|
|
} |
318
|
|
|
|
319
|
|
|
if (isset($this->request->get['filter_total'])) { |
320
|
|
|
$url .= '&filter_total=' . $this->request->get['filter_total']; |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
324
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
if (isset($this->request->get['filter_date_modified'])) { |
328
|
|
|
$url .= '&filter_date_modified=' . $this->request->get['filter_date_modified']; |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
if ($order == 'ASC') { |
332
|
|
|
$url .= '&order=DESC'; |
333
|
|
|
} else { |
334
|
|
|
$url .= '&order=ASC'; |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
if (isset($this->request->get['page'])) { |
338
|
|
|
$url .= '&page=' . $this->request->get['page']; |
339
|
|
|
} |
340
|
|
|
|
341
|
|
|
$data['sort_order'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . '&sort=o.order_id' . $url, true); |
342
|
|
|
$data['sort_customer'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . '&sort=customer' . $url, true); |
343
|
|
|
$data['sort_status'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . '&sort=order_status' . $url, true); |
344
|
|
|
$data['sort_total'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . '&sort=o.total' . $url, true); |
345
|
|
|
$data['sort_date_added'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . '&sort=o.date_added' . $url, true); |
346
|
|
|
$data['sort_date_modified'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . '&sort=o.date_modified' . $url, true); |
347
|
|
|
|
348
|
|
|
$url = ''; |
349
|
|
|
|
350
|
|
|
if (isset($this->request->get['filter_order_id'])) { |
351
|
|
|
$url .= '&filter_order_id=' . $this->request->get['filter_order_id']; |
352
|
|
|
} |
353
|
|
|
|
354
|
|
|
if (isset($this->request->get['filter_customer'])) { |
355
|
|
|
$url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8')); |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
if (isset($this->request->get['filter_order_status'])) { |
359
|
|
|
$url .= '&filter_order_status=' . $this->request->get['filter_order_status']; |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
if (isset($this->request->get['filter_total'])) { |
363
|
|
|
$url .= '&filter_total=' . $this->request->get['filter_total']; |
364
|
|
|
} |
365
|
|
|
|
366
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
367
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
368
|
|
|
} |
369
|
|
|
|
370
|
|
|
if (isset($this->request->get['filter_date_modified'])) { |
371
|
|
|
$url .= '&filter_date_modified=' . $this->request->get['filter_date_modified']; |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
if (isset($this->request->get['sort'])) { |
375
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
if (isset($this->request->get['order'])) { |
379
|
|
|
$url .= '&order=' . $this->request->get['order']; |
380
|
|
|
} |
381
|
|
|
|
382
|
|
|
$pagination = new \Divine\Engine\Library\Pagination(); |
383
|
|
|
$pagination->total = $order_total; |
384
|
|
|
$pagination->page = $page; |
385
|
|
|
$pagination->limit = $this->config->get('config_limit_admin'); |
386
|
|
|
$pagination->url = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url . '&page={page}', true); |
387
|
|
|
|
388
|
|
|
$data['pagination'] = $pagination->render(); |
389
|
|
|
|
390
|
|
|
$data['results'] = sprintf( |
391
|
|
|
$this->language->get('text_pagination'), |
392
|
|
|
($order_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, |
393
|
|
|
((($page - 1) * $this->config->get('config_limit_admin')) > ($order_total - $this->config->get('config_limit_admin'))) ? $order_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), |
394
|
|
|
$order_total, |
395
|
|
|
ceil($order_total / $this->config->get('config_limit_admin')) |
396
|
|
|
); |
397
|
|
|
|
398
|
|
|
$data['filter_order_id'] = $filter_order_id; |
399
|
|
|
$data['filter_customer'] = $filter_customer; |
400
|
|
|
$data['filter_order_status'] = $filter_order_status; |
401
|
|
|
$data['filter_total'] = $filter_total; |
402
|
|
|
$data['filter_date_added'] = $filter_date_added; |
403
|
|
|
$data['filter_date_modified'] = $filter_date_modified; |
404
|
|
|
|
405
|
|
|
$data['sort'] = $sort; |
406
|
|
|
$data['order'] = $order; |
407
|
|
|
|
408
|
|
|
$this->load->model('localisation/order_status'); |
409
|
|
|
|
410
|
|
|
$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); |
411
|
|
|
|
412
|
|
|
$data['header'] = $this->load->controller('common/header'); |
413
|
|
|
$data['column'] = $this->load->controller('common/column_left'); |
414
|
|
|
$data['footer'] = $this->load->controller('common/footer'); |
415
|
|
|
|
416
|
|
|
$this->response->setOutput($this->load->view('sale/order_list', $data)); |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
public function getForm() |
420
|
|
|
{ |
421
|
|
|
$data['heading_title'] = $this->language->get('heading_title'); |
|
|
|
|
422
|
|
|
|
423
|
|
|
$data['text_form'] = !isset($this->request->get['order_id']) ? $this->language->get('text_add') : $this->language->get('text_edit'); |
424
|
|
|
$data['text_no_results'] = $this->language->get('text_no_results'); |
425
|
|
|
$data['text_default'] = $this->language->get('text_default'); |
426
|
|
|
$data['text_select'] = $this->language->get('text_select'); |
427
|
|
|
$data['text_none'] = $this->language->get('text_none'); |
428
|
|
|
$data['text_loading'] = $this->language->get('text_loading'); |
429
|
|
|
$data['text_ip_add'] = sprintf($this->language->get('text_ip_add'), $this->request->server['REMOTE_ADDR']); |
430
|
|
|
$data['text_product'] = $this->language->get('text_product'); |
431
|
|
|
$data['text_order_detail'] = $this->language->get('text_order_detail'); |
432
|
|
|
|
433
|
|
|
$data['entry_customer'] = $this->language->get('entry_customer'); |
434
|
|
|
$data['entry_customer_group'] = $this->language->get('entry_customer_group'); |
435
|
|
|
$data['entry_firstname'] = $this->language->get('entry_firstname'); |
436
|
|
|
$data['entry_lastname'] = $this->language->get('entry_lastname'); |
437
|
|
|
$data['entry_email'] = $this->language->get('entry_email'); |
438
|
|
|
$data['entry_telephone'] = $this->language->get('entry_telephone'); |
439
|
|
|
$data['entry_fax'] = $this->language->get('entry_fax'); |
440
|
|
|
$data['entry_comment'] = $this->language->get('entry_comment'); |
441
|
|
|
$data['entry_address'] = $this->language->get('entry_address'); |
442
|
|
|
$data['entry_company'] = $this->language->get('entry_company'); |
443
|
|
|
$data['entry_address_1'] = $this->language->get('entry_address_1'); |
444
|
|
|
$data['entry_address_2'] = $this->language->get('entry_address_2'); |
445
|
|
|
$data['entry_city'] = $this->language->get('entry_city'); |
446
|
|
|
$data['entry_postcode'] = $this->language->get('entry_postcode'); |
447
|
|
|
$data['entry_zone'] = $this->language->get('entry_zone'); |
448
|
|
|
$data['entry_zone_code'] = $this->language->get('entry_zone_code'); |
449
|
|
|
$data['entry_country'] = $this->language->get('entry_country'); |
450
|
|
|
$data['entry_product'] = $this->language->get('entry_product'); |
451
|
|
|
$data['entry_option'] = $this->language->get('entry_option'); |
452
|
|
|
$data['entry_quantity'] = $this->language->get('entry_quantity'); |
453
|
|
|
$data['entry_to_name'] = $this->language->get('entry_to_name'); |
454
|
|
|
$data['entry_to_email'] = $this->language->get('entry_to_email'); |
455
|
|
|
$data['entry_from_name'] = $this->language->get('entry_from_name'); |
456
|
|
|
$data['entry_from_email'] = $this->language->get('entry_from_email'); |
457
|
|
|
$data['entry_theme'] = $this->language->get('entry_theme'); |
458
|
|
|
$data['entry_message'] = $this->language->get('entry_message'); |
459
|
|
|
$data['entry_amount'] = $this->language->get('entry_amount'); |
460
|
|
|
$data['entry_currency'] = $this->language->get('entry_currency'); |
461
|
|
|
$data['entry_shipping_method'] = $this->language->get('entry_shipping_method'); |
462
|
|
|
$data['entry_payment_method'] = $this->language->get('entry_payment_method'); |
463
|
|
|
$data['entry_reward'] = $this->language->get('entry_reward'); |
464
|
|
|
$data['entry_order_status'] = $this->language->get('entry_order_status'); |
465
|
|
|
|
466
|
|
|
$data['column_product'] = $this->language->get('column_product'); |
467
|
|
|
$data['column_model'] = $this->language->get('column_model'); |
468
|
|
|
$data['column_quantity'] = $this->language->get('column_quantity'); |
469
|
|
|
$data['column_price'] = $this->language->get('column_price'); |
470
|
|
|
$data['column_total'] = $this->language->get('column_total'); |
471
|
|
|
$data['column_action'] = $this->language->get('column_action'); |
472
|
|
|
|
473
|
|
|
$data['button_save'] = $this->language->get('button_save'); |
474
|
|
|
$data['button_cancel'] = $this->language->get('button_cancel'); |
475
|
|
|
$data['button_continue'] = $this->language->get('button_continue'); |
476
|
|
|
$data['button_back'] = $this->language->get('button_back'); |
477
|
|
|
$data['button_refresh'] = $this->language->get('button_refresh'); |
478
|
|
|
$data['button_product_add'] = $this->language->get('button_product_add'); |
479
|
|
|
$data['button_apply'] = $this->language->get('button_apply'); |
480
|
|
|
$data['button_upload'] = $this->language->get('button_upload'); |
481
|
|
|
$data['button_remove'] = $this->language->get('button_remove'); |
482
|
|
|
$data['button_ip_add'] = $this->language->get('button_ip_add'); |
483
|
|
|
|
484
|
|
|
$data['tab_order'] = $this->language->get('tab_order'); |
485
|
|
|
$data['tab_customer'] = $this->language->get('tab_customer'); |
486
|
|
|
$data['tab_payment'] = $this->language->get('tab_payment'); |
487
|
|
|
$data['tab_shipping'] = $this->language->get('tab_shipping'); |
488
|
|
|
$data['tab_product'] = $this->language->get('tab_product'); |
489
|
|
|
$data['tab_total'] = $this->language->get('tab_total'); |
490
|
|
|
|
491
|
|
|
$url = ''; |
492
|
|
|
|
493
|
|
|
if (isset($this->request->get['filter_order_id'])) { |
494
|
|
|
$url .= '&filter_order_id=' . $this->request->get['filter_order_id']; |
495
|
|
|
} |
496
|
|
|
|
497
|
|
|
if (isset($this->request->get['filter_customer'])) { |
498
|
|
|
$url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8')); |
499
|
|
|
} |
500
|
|
|
|
501
|
|
|
if (isset($this->request->get['filter_order_status'])) { |
502
|
|
|
$url .= '&filter_order_status=' . $this->request->get['filter_order_status']; |
503
|
|
|
} |
504
|
|
|
|
505
|
|
|
if (isset($this->request->get['filter_total'])) { |
506
|
|
|
$url .= '&filter_total=' . $this->request->get['filter_total']; |
507
|
|
|
} |
508
|
|
|
|
509
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
510
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
511
|
|
|
} |
512
|
|
|
|
513
|
|
|
if (isset($this->request->get['filter_date_modified'])) { |
514
|
|
|
$url .= '&filter_date_modified=' . $this->request->get['filter_date_modified']; |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
if (isset($this->request->get['sort'])) { |
518
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
519
|
|
|
} |
520
|
|
|
|
521
|
|
|
if (isset($this->request->get['order'])) { |
522
|
|
|
$url .= '&order=' . $this->request->get['order']; |
523
|
|
|
} |
524
|
|
|
|
525
|
|
|
if (isset($this->request->get['page'])) { |
526
|
|
|
$url .= '&page=' . $this->request->get['page']; |
527
|
|
|
} |
528
|
|
|
|
529
|
|
|
$data['breadcrumbs'] = array(); |
530
|
|
|
|
531
|
|
|
$data['breadcrumbs'][] = array( |
532
|
|
|
'text' => $this->language->get('text_home'), |
533
|
|
|
'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
534
|
|
|
); |
535
|
|
|
|
536
|
|
|
$data['breadcrumbs'][] = array( |
537
|
|
|
'text' => $this->language->get('heading_title'), |
538
|
|
|
'href' => $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, true) |
539
|
|
|
); |
540
|
|
|
|
541
|
|
|
$data['cancel'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, true); |
542
|
|
|
|
543
|
|
|
$data['token'] = $this->session->data['token']; |
544
|
|
|
|
545
|
|
|
if (isset($this->request->get['order_id'])) { |
546
|
|
|
$order_info = $this->model_sale_order->getOrder($this->request->get['order_id']); |
547
|
|
|
} |
548
|
|
|
|
549
|
|
|
if (!empty($order_info)) { |
550
|
|
|
$data['order_id'] = $this->request->get['order_id']; |
551
|
|
|
$data['store_url'] = '/'; |
552
|
|
|
|
553
|
|
|
$data['customer'] = $order_info['customer']; |
554
|
|
|
$data['customer_id'] = $order_info['customer_id']; |
555
|
|
|
$data['customer_group_id'] = $order_info['customer_group_id']; |
556
|
|
|
$data['firstname'] = $order_info['firstname']; |
557
|
|
|
$data['lastname'] = $order_info['lastname']; |
558
|
|
|
$data['email'] = $order_info['email']; |
559
|
|
|
$data['telephone'] = $order_info['telephone']; |
560
|
|
|
$data['fax'] = $order_info['fax']; |
561
|
|
|
$data['account_custom_field'] = $order_info['custom_field']; |
562
|
|
|
|
563
|
|
|
$this->load->model('customer/customer'); |
564
|
|
|
|
565
|
|
|
$data['addresses'] = $this->model_customer_customer->getAddresses($order_info['customer_id']); |
566
|
|
|
|
567
|
|
|
$data['payment_firstname'] = $order_info['payment_firstname']; |
568
|
|
|
$data['payment_lastname'] = $order_info['payment_lastname']; |
569
|
|
|
$data['payment_company'] = $order_info['payment_company']; |
570
|
|
|
$data['payment_address_1'] = $order_info['payment_address_1']; |
571
|
|
|
$data['payment_address_2'] = $order_info['payment_address_2']; |
572
|
|
|
$data['payment_city'] = $order_info['payment_city']; |
573
|
|
|
$data['payment_postcode'] = $order_info['payment_postcode']; |
574
|
|
|
$data['payment_country_id'] = $order_info['payment_country_id']; |
575
|
|
|
$data['payment_zone_id'] = $order_info['payment_zone_id']; |
576
|
|
|
$data['payment_custom_field'] = $order_info['payment_custom_field']; |
577
|
|
|
$data['payment_method'] = $order_info['payment_method']; |
578
|
|
|
$data['payment_code'] = $order_info['payment_code']; |
579
|
|
|
|
580
|
|
|
$data['shipping_firstname'] = $order_info['shipping_firstname']; |
581
|
|
|
$data['shipping_lastname'] = $order_info['shipping_lastname']; |
582
|
|
|
$data['shipping_company'] = $order_info['shipping_company']; |
583
|
|
|
$data['shipping_address_1'] = $order_info['shipping_address_1']; |
584
|
|
|
$data['shipping_address_2'] = $order_info['shipping_address_2']; |
585
|
|
|
$data['shipping_city'] = $order_info['shipping_city']; |
586
|
|
|
$data['shipping_postcode'] = $order_info['shipping_postcode']; |
587
|
|
|
$data['shipping_country_id'] = $order_info['shipping_country_id']; |
588
|
|
|
$data['shipping_zone_id'] = $order_info['shipping_zone_id']; |
589
|
|
|
$data['shipping_custom_field'] = $order_info['shipping_custom_field']; |
590
|
|
|
$data['shipping_method'] = $order_info['shipping_method']; |
591
|
|
|
$data['shipping_code'] = $order_info['shipping_code']; |
592
|
|
|
|
593
|
|
|
// Products |
594
|
|
|
$data['order_products'] = array(); |
595
|
|
|
|
596
|
|
|
$products = $this->model_sale_order->getOrderProducts($this->request->get['order_id']); |
597
|
|
|
|
598
|
|
|
foreach ($products as $product) { |
599
|
|
|
$data['order_products'][] = array( |
600
|
|
|
'product_id' => $product['product_id'], |
601
|
|
|
'name' => $product['name'], |
602
|
|
|
'model' => $product['model'], |
603
|
|
|
'option' => $this->model_sale_order->getOrderOptions($this->request->get['order_id'], $product['order_product_id']), |
604
|
|
|
'quantity' => $product['quantity'], |
605
|
|
|
'price' => $product['price'], |
606
|
|
|
'total' => $product['total'], |
607
|
|
|
'reward' => $product['reward'] |
608
|
|
|
); |
609
|
|
|
} |
610
|
|
|
|
611
|
|
|
$data['reward'] = ''; |
612
|
|
|
|
613
|
|
|
$data['order_totals'] = array(); |
614
|
|
|
|
615
|
|
|
$order_totals = $this->model_sale_order->getOrderTotals($this->request->get['order_id']); |
616
|
|
|
|
617
|
|
|
foreach ($order_totals as $order_total) { |
618
|
|
|
// If reward points |
619
|
|
|
$start = strpos($order_total['title'], '(') + 1; |
620
|
|
|
$end = strrpos($order_total['title'], ')'); |
621
|
|
|
|
622
|
|
|
if ($start && $end) { |
623
|
|
|
$data[$order_total['code']] = substr($order_total['title'], $start, $end - $start); |
624
|
|
|
} |
625
|
|
|
} |
626
|
|
|
|
627
|
|
|
$data['order_status_id'] = $order_info['order_status_id']; |
628
|
|
|
$data['comment'] = $order_info['comment']; |
629
|
|
|
$data['currency_code'] = $order_info['currency_code']; |
630
|
|
|
} else { |
631
|
|
|
$data['order_id'] = 0; |
632
|
|
|
$data['store_url'] = '/'; |
633
|
|
|
|
634
|
|
|
$data['customer'] = ''; |
635
|
|
|
$data['customer_id'] = ''; |
636
|
|
|
$data['customer_group_id'] = $this->config->get('config_customer_group_id'); |
637
|
|
|
$data['firstname'] = ''; |
638
|
|
|
$data['lastname'] = ''; |
639
|
|
|
$data['email'] = ''; |
640
|
|
|
$data['telephone'] = ''; |
641
|
|
|
$data['fax'] = ''; |
642
|
|
|
$data['customer_custom_field'] = array(); |
643
|
|
|
|
644
|
|
|
$data['addresses'] = array(); |
645
|
|
|
|
646
|
|
|
$data['payment_firstname'] = ''; |
647
|
|
|
$data['payment_lastname'] = ''; |
648
|
|
|
$data['payment_company'] = ''; |
649
|
|
|
$data['payment_address_1'] = ''; |
650
|
|
|
$data['payment_address_2'] = ''; |
651
|
|
|
$data['payment_city'] = ''; |
652
|
|
|
$data['payment_postcode'] = ''; |
653
|
|
|
$data['payment_country_id'] = ''; |
654
|
|
|
$data['payment_zone_id'] = ''; |
655
|
|
|
$data['payment_custom_field'] = array(); |
656
|
|
|
$data['payment_method'] = ''; |
657
|
|
|
$data['payment_code'] = ''; |
658
|
|
|
|
659
|
|
|
$data['shipping_firstname'] = ''; |
660
|
|
|
$data['shipping_lastname'] = ''; |
661
|
|
|
$data['shipping_company'] = ''; |
662
|
|
|
$data['shipping_address_1'] = ''; |
663
|
|
|
$data['shipping_address_2'] = ''; |
664
|
|
|
$data['shipping_city'] = ''; |
665
|
|
|
$data['shipping_postcode'] = ''; |
666
|
|
|
$data['shipping_country_id'] = ''; |
667
|
|
|
$data['shipping_zone_id'] = ''; |
668
|
|
|
$data['shipping_custom_field'] = array(); |
669
|
|
|
$data['shipping_method'] = ''; |
670
|
|
|
$data['shipping_code'] = ''; |
671
|
|
|
|
672
|
|
|
$data['order_products'] = array(); |
673
|
|
|
$data['order_totals'] = array(); |
674
|
|
|
|
675
|
|
|
$data['order_status_id'] = $this->config->get('config_order_status_id'); |
676
|
|
|
$data['comment'] = ''; |
677
|
|
|
$data['currency_code'] = $this->config->get('config_currency'); |
678
|
|
|
|
679
|
|
|
$data['reward'] = ''; |
680
|
|
|
} |
681
|
|
|
|
682
|
|
|
// Customer Groups |
683
|
|
|
$this->load->model('customer/customer_group'); |
684
|
|
|
|
685
|
|
|
$data['customer_groups'] = $this->model_customer_customer_group->getCustomerGroups(); |
686
|
|
|
|
687
|
|
|
// Custom Fields |
688
|
|
|
$this->load->model('customer/custom_field'); |
689
|
|
|
|
690
|
|
|
$data['custom_fields'] = array(); |
691
|
|
|
|
692
|
|
|
$filter_data = array( |
693
|
|
|
'sort' => 'cf.sort_order', |
694
|
|
|
'order' => 'ASC' |
695
|
|
|
); |
696
|
|
|
|
697
|
|
|
$custom_fields = $this->model_customer_custom_field->getCustomFields($filter_data); |
698
|
|
|
|
699
|
|
|
foreach ($custom_fields as $custom_field) { |
700
|
|
|
$data['custom_fields'][] = array( |
701
|
|
|
'custom_field_id' => $custom_field['custom_field_id'], |
702
|
|
|
'custom_field_value' => $this->model_customer_custom_field->getCustomFieldValues($custom_field['custom_field_id']), |
703
|
|
|
'name' => $custom_field['name'], |
704
|
|
|
'value' => $custom_field['value'], |
705
|
|
|
'type' => $custom_field['type'], |
706
|
|
|
'location' => $custom_field['location'], |
707
|
|
|
'sort_order' => $custom_field['sort_order'] |
708
|
|
|
); |
709
|
|
|
} |
710
|
|
|
|
711
|
|
|
$this->load->model('localisation/order_status'); |
712
|
|
|
|
713
|
|
|
$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); |
714
|
|
|
|
715
|
|
|
$this->load->model('localisation/country'); |
716
|
|
|
|
717
|
|
|
$data['countries'] = $this->model_localisation_country->getCountries(); |
718
|
|
|
|
719
|
|
|
$this->load->model('localisation/currency'); |
720
|
|
|
|
721
|
|
|
$data['currencies'] = $this->model_localisation_currency->getCurrencies(); |
722
|
|
|
|
723
|
|
|
$data['header'] = $this->load->controller('common/header'); |
724
|
|
|
$data['column'] = $this->load->controller('common/column_left'); |
725
|
|
|
$data['footer'] = $this->load->controller('common/footer'); |
726
|
|
|
|
727
|
|
|
$this->response->setOutput($this->load->view('sale/order_form', $data)); |
728
|
|
|
} |
729
|
|
|
|
730
|
|
|
public function info() |
731
|
|
|
{ |
732
|
|
|
$this->load->model('sale/order'); |
733
|
|
|
|
734
|
|
|
if (isset($this->request->get['order_id'])) { |
735
|
|
|
$order_id = $this->request->get['order_id']; |
736
|
|
|
} else { |
737
|
|
|
$order_id = 0; |
738
|
|
|
} |
739
|
|
|
|
740
|
|
|
$order_info = $this->model_sale_order->getOrder($order_id); |
741
|
|
|
|
742
|
|
|
if ($order_info) { |
743
|
|
|
$this->load->language('sale/order'); |
744
|
|
|
|
745
|
|
|
$this->document->setTitle($this->language->get('heading_title')); |
746
|
|
|
|
747
|
|
|
$data['heading_title'] = $this->language->get('heading_title'); |
|
|
|
|
748
|
|
|
|
749
|
|
|
$data['text_ip_add'] = sprintf($this->language->get('text_ip_add'), $this->request->server['REMOTE_ADDR']); |
750
|
|
|
$data['text_order_detail'] = $this->language->get('text_order_detail'); |
751
|
|
|
$data['text_customer_detail'] = $this->language->get('text_customer_detail'); |
752
|
|
|
$data['text_option'] = $this->language->get('text_option'); |
753
|
|
|
$data['text_store'] = $this->language->get('text_store'); |
754
|
|
|
$data['text_date_added'] = $this->language->get('text_date_added'); |
755
|
|
|
$data['text_payment_method'] = $this->language->get('text_payment_method'); |
756
|
|
|
$data['text_shipping_method'] = $this->language->get('text_shipping_method'); |
757
|
|
|
$data['text_customer'] = $this->language->get('text_customer'); |
758
|
|
|
$data['text_customer_group'] = $this->language->get('text_customer_group'); |
759
|
|
|
$data['text_email'] = $this->language->get('text_email'); |
760
|
|
|
$data['text_telephone'] = $this->language->get('text_telephone'); |
761
|
|
|
$data['text_invoice'] = $this->language->get('text_invoice'); |
762
|
|
|
$data['text_reward'] = $this->language->get('text_reward'); |
763
|
|
|
$data['text_order'] = sprintf($this->language->get('text_order'), $this->request->get['order_id']); |
764
|
|
|
$data['text_payment_address'] = $this->language->get('text_payment_address'); |
765
|
|
|
$data['text_shipping_address'] = $this->language->get('text_shipping_address'); |
766
|
|
|
$data['text_comment'] = $this->language->get('text_comment'); |
767
|
|
|
$data['text_account_custom_field'] = $this->language->get('text_account_custom_field'); |
768
|
|
|
$data['text_payment_custom_field'] = $this->language->get('text_payment_custom_field'); |
769
|
|
|
$data['text_shipping_custom_field'] = $this->language->get('text_shipping_custom_field'); |
770
|
|
|
$data['text_browser'] = $this->language->get('text_browser'); |
771
|
|
|
$data['text_ip'] = $this->language->get('text_ip'); |
772
|
|
|
$data['text_forwarded_ip'] = $this->language->get('text_forwarded_ip'); |
773
|
|
|
$data['text_user_agent'] = $this->language->get('text_user_agent'); |
774
|
|
|
$data['text_accept_language'] = $this->language->get('text_accept_language'); |
775
|
|
|
$data['text_history'] = $this->language->get('text_history'); |
776
|
|
|
$data['text_history_add'] = $this->language->get('text_history_add'); |
777
|
|
|
$data['text_loading'] = $this->language->get('text_loading'); |
778
|
|
|
|
779
|
|
|
$data['column_product'] = $this->language->get('column_product'); |
780
|
|
|
$data['column_model'] = $this->language->get('column_model'); |
781
|
|
|
$data['column_quantity'] = $this->language->get('column_quantity'); |
782
|
|
|
$data['column_price'] = $this->language->get('column_price'); |
783
|
|
|
$data['column_total'] = $this->language->get('column_total'); |
784
|
|
|
|
785
|
|
|
$data['entry_order_status'] = $this->language->get('entry_order_status'); |
786
|
|
|
$data['entry_notify'] = $this->language->get('entry_notify'); |
787
|
|
|
$data['entry_override'] = $this->language->get('entry_override'); |
788
|
|
|
$data['entry_comment'] = $this->language->get('entry_comment'); |
789
|
|
|
|
790
|
|
|
$data['help_override'] = $this->language->get('help_override'); |
791
|
|
|
|
792
|
|
|
$data['button_invoice_print'] = $this->language->get('button_invoice_print'); |
793
|
|
|
$data['button_shipping_print'] = $this->language->get('button_shipping_print'); |
794
|
|
|
$data['button_edit'] = $this->language->get('button_edit'); |
795
|
|
|
$data['button_cancel'] = $this->language->get('button_cancel'); |
796
|
|
|
$data['button_generate'] = $this->language->get('button_generate'); |
797
|
|
|
$data['button_reward_add'] = $this->language->get('button_reward_add'); |
798
|
|
|
$data['button_reward_remove'] = $this->language->get('button_reward_remove'); |
799
|
|
|
$data['button_commission_add'] = $this->language->get('button_commission_add'); |
800
|
|
|
$data['button_commission_remove'] = $this->language->get('button_commission_remove'); |
801
|
|
|
$data['button_history_add'] = $this->language->get('button_history_add'); |
802
|
|
|
$data['button_ip_add'] = $this->language->get('button_ip_add'); |
803
|
|
|
|
804
|
|
|
$data['tab_history'] = $this->language->get('tab_history'); |
805
|
|
|
$data['tab_additional'] = $this->language->get('tab_additional'); |
806
|
|
|
|
807
|
|
|
$url = ''; |
808
|
|
|
|
809
|
|
|
if (isset($this->request->get['filter_order_id'])) { |
810
|
|
|
$url .= '&filter_order_id=' . $this->request->get['filter_order_id']; |
811
|
|
|
} |
812
|
|
|
|
813
|
|
|
if (isset($this->request->get['filter_customer'])) { |
814
|
|
|
$url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8')); |
815
|
|
|
} |
816
|
|
|
|
817
|
|
|
if (isset($this->request->get['filter_order_status'])) { |
818
|
|
|
$url .= '&filter_order_status=' . $this->request->get['filter_order_status']; |
819
|
|
|
} |
820
|
|
|
|
821
|
|
|
if (isset($this->request->get['filter_total'])) { |
822
|
|
|
$url .= '&filter_total=' . $this->request->get['filter_total']; |
823
|
|
|
} |
824
|
|
|
|
825
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
826
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
827
|
|
|
} |
828
|
|
|
|
829
|
|
|
if (isset($this->request->get['filter_date_modified'])) { |
830
|
|
|
$url .= '&filter_date_modified=' . $this->request->get['filter_date_modified']; |
831
|
|
|
} |
832
|
|
|
|
833
|
|
|
if (isset($this->request->get['sort'])) { |
834
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
835
|
|
|
} |
836
|
|
|
|
837
|
|
|
if (isset($this->request->get['order'])) { |
838
|
|
|
$url .= '&order=' . $this->request->get['order']; |
839
|
|
|
} |
840
|
|
|
|
841
|
|
|
if (isset($this->request->get['page'])) { |
842
|
|
|
$url .= '&page=' . $this->request->get['page']; |
843
|
|
|
} |
844
|
|
|
|
845
|
|
|
$data['breadcrumbs'] = array(); |
846
|
|
|
|
847
|
|
|
$data['breadcrumbs'][] = array( |
848
|
|
|
'text' => $this->language->get('text_home'), |
849
|
|
|
'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
850
|
|
|
); |
851
|
|
|
|
852
|
|
|
$data['breadcrumbs'][] = array( |
853
|
|
|
'text' => $this->language->get('heading_title'), |
854
|
|
|
'href' => $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, true) |
855
|
|
|
); |
856
|
|
|
|
857
|
|
|
$data['shipping'] = $this->url->link('sale/order/shipping', 'token=' . $this->session->data['token'] . '&order_id=' . (int)$this->request->get['order_id'], true); |
858
|
|
|
$data['invoice'] = $this->url->link('sale/order/invoice', 'token=' . $this->session->data['token'] . '&order_id=' . (int)$this->request->get['order_id'], true); |
859
|
|
|
$data['edit'] = $this->url->link('sale/order/edit', 'token=' . $this->session->data['token'] . '&order_id=' . (int)$this->request->get['order_id'], true); |
860
|
|
|
$data['cancel'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, true); |
861
|
|
|
|
862
|
|
|
$data['token'] = $this->session->data['token']; |
863
|
|
|
|
864
|
|
|
$data['order_id'] = $this->request->get['order_id']; |
865
|
|
|
|
866
|
|
|
$data['store_name'] = $order_info['store_name']; |
867
|
|
|
$data['store_url'] = '/'; |
868
|
|
|
|
869
|
|
|
if ($order_info['invoice_no']) { |
870
|
|
|
$data['invoice_no'] = $order_info['invoice_prefix'] . $order_info['invoice_no']; |
871
|
|
|
} else { |
872
|
|
|
$data['invoice_no'] = ''; |
873
|
|
|
} |
874
|
|
|
|
875
|
|
|
$data['date_added'] = date($this->language->get('date_format_short'), strtotime($order_info['date_added'])); |
876
|
|
|
|
877
|
|
|
$data['firstname'] = $order_info['firstname']; |
878
|
|
|
$data['lastname'] = $order_info['lastname']; |
879
|
|
|
|
880
|
|
|
if ($order_info['customer_id']) { |
881
|
|
|
$data['customer'] = $this->url->link('customer/customer/edit', 'token=' . $this->session->data['token'] . '&customer_id=' . $order_info['customer_id'], true); |
882
|
|
|
} else { |
883
|
|
|
$data['customer'] = ''; |
884
|
|
|
} |
885
|
|
|
|
886
|
|
|
$this->load->model('customer/customer_group'); |
887
|
|
|
|
888
|
|
|
$customer_group_info = $this->model_customer_customer_group->getCustomerGroup($order_info['customer_group_id']); |
889
|
|
|
|
890
|
|
|
if ($customer_group_info) { |
891
|
|
|
$data['customer_group'] = $customer_group_info['name']; |
892
|
|
|
} else { |
893
|
|
|
$data['customer_group'] = ''; |
894
|
|
|
} |
895
|
|
|
|
896
|
|
|
$data['email'] = $order_info['email']; |
897
|
|
|
$data['telephone'] = $order_info['telephone']; |
898
|
|
|
|
899
|
|
|
$data['shipping_method'] = $order_info['shipping_method']; |
900
|
|
|
$data['payment_method'] = $order_info['payment_method']; |
901
|
|
|
|
902
|
|
|
// Payment Address |
903
|
|
|
if ($order_info['payment_address_format']) { |
904
|
|
|
$format = $order_info['payment_address_format']; |
905
|
|
|
} else { |
906
|
|
|
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}'; |
907
|
|
|
} |
908
|
|
|
|
909
|
|
|
$find = array( |
910
|
|
|
'{firstname}', |
911
|
|
|
'{lastname}', |
912
|
|
|
'{company}', |
913
|
|
|
'{address_1}', |
914
|
|
|
'{address_2}', |
915
|
|
|
'{city}', |
916
|
|
|
'{postcode}', |
917
|
|
|
'{zone}', |
918
|
|
|
'{zone_code}', |
919
|
|
|
'{country}' |
920
|
|
|
); |
921
|
|
|
|
922
|
|
|
$replace = array( |
923
|
|
|
'firstname' => $order_info['payment_firstname'], |
924
|
|
|
'lastname' => $order_info['payment_lastname'], |
925
|
|
|
'company' => $order_info['payment_company'], |
926
|
|
|
'address_1' => $order_info['payment_address_1'], |
927
|
|
|
'address_2' => $order_info['payment_address_2'], |
928
|
|
|
'city' => $order_info['payment_city'], |
929
|
|
|
'postcode' => $order_info['payment_postcode'], |
930
|
|
|
'zone' => $order_info['payment_zone'], |
931
|
|
|
'zone_code' => $order_info['payment_zone_code'], |
932
|
|
|
'country' => $order_info['payment_country'] |
933
|
|
|
); |
934
|
|
|
|
935
|
|
|
$data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format)))); |
|
|
|
|
936
|
|
|
|
937
|
|
|
// Shipping Address |
938
|
|
|
if ($order_info['shipping_address_format']) { |
939
|
|
|
$format = $order_info['shipping_address_format']; |
940
|
|
|
} else { |
941
|
|
|
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}'; |
942
|
|
|
} |
943
|
|
|
|
944
|
|
|
$find = array( |
945
|
|
|
'{firstname}', |
946
|
|
|
'{lastname}', |
947
|
|
|
'{company}', |
948
|
|
|
'{address_1}', |
949
|
|
|
'{address_2}', |
950
|
|
|
'{city}', |
951
|
|
|
'{postcode}', |
952
|
|
|
'{zone}', |
953
|
|
|
'{zone_code}', |
954
|
|
|
'{country}' |
955
|
|
|
); |
956
|
|
|
|
957
|
|
|
$replace = array( |
958
|
|
|
'firstname' => $order_info['shipping_firstname'], |
959
|
|
|
'lastname' => $order_info['shipping_lastname'], |
960
|
|
|
'company' => $order_info['shipping_company'], |
961
|
|
|
'address_1' => $order_info['shipping_address_1'], |
962
|
|
|
'address_2' => $order_info['shipping_address_2'], |
963
|
|
|
'city' => $order_info['shipping_city'], |
964
|
|
|
'postcode' => $order_info['shipping_postcode'], |
965
|
|
|
'zone' => $order_info['shipping_zone'], |
966
|
|
|
'zone_code' => $order_info['shipping_zone_code'], |
967
|
|
|
'country' => $order_info['shipping_country'] |
968
|
|
|
); |
969
|
|
|
|
970
|
|
|
$data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format)))); |
|
|
|
|
971
|
|
|
|
972
|
|
|
// Uploaded files |
973
|
|
|
$this->load->model('tool/upload'); |
974
|
|
|
|
975
|
|
|
$data['products'] = array(); |
976
|
|
|
|
977
|
|
|
$products = $this->model_sale_order->getOrderProducts($this->request->get['order_id']); |
978
|
|
|
|
979
|
|
|
foreach ($products as $product) { |
980
|
|
|
$option_data = array(); |
981
|
|
|
|
982
|
|
|
$options = $this->model_sale_order->getOrderOptions($this->request->get['order_id'], $product['order_product_id']); |
983
|
|
|
|
984
|
|
|
foreach ($options as $option) { |
985
|
|
|
if ($option['type'] != 'file') { |
986
|
|
|
$option_data[] = array( |
987
|
|
|
'name' => $option['name'], |
988
|
|
|
'value' => $option['value'], |
989
|
|
|
'type' => $option['type'] |
990
|
|
|
); |
991
|
|
|
} else { |
992
|
|
|
$upload_info = $this->model_tool_upload->getUploadByCode($option['value']); |
993
|
|
|
|
994
|
|
|
if ($upload_info) { |
995
|
|
|
$option_data[] = array( |
996
|
|
|
'name' => $option['name'], |
997
|
|
|
'value' => $upload_info['name'], |
998
|
|
|
'type' => $option['type'], |
999
|
|
|
'href' => $this->url->link('tool/upload/download', 'token=' . $this->session->data['token'] . '&code=' . $upload_info['code'], true) |
1000
|
|
|
); |
1001
|
|
|
} |
1002
|
|
|
} |
1003
|
|
|
} |
1004
|
|
|
|
1005
|
|
|
$data['products'][] = array( |
1006
|
|
|
'order_product_id' => $product['order_product_id'], |
1007
|
|
|
'product_id' => $product['product_id'], |
1008
|
|
|
'name' => $product['name'], |
1009
|
|
|
'model' => $product['model'], |
1010
|
|
|
'option' => $option_data, |
1011
|
|
|
'quantity' => $product['quantity'], |
1012
|
|
|
'price' => $this->currency->format($product['price'], $order_info['currency_code'], $order_info['currency_value']), |
1013
|
|
|
'total' => $this->currency->format($product['total'], $order_info['currency_code'], $order_info['currency_value']), |
1014
|
|
|
'href' => $this->url->link('catalog/product/edit', 'token=' . $this->session->data['token'] . '&product_id=' . $product['product_id'], true) |
1015
|
|
|
); |
1016
|
|
|
} |
1017
|
|
|
|
1018
|
|
|
$data['totals'] = array(); |
1019
|
|
|
|
1020
|
|
|
$totals = $this->model_sale_order->getOrderTotals($this->request->get['order_id']); |
1021
|
|
|
|
1022
|
|
|
foreach ($totals as $total) { |
1023
|
|
|
$data['totals'][] = array( |
1024
|
|
|
'title' => $total['title'], |
1025
|
|
|
'text' => $this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']) |
1026
|
|
|
); |
1027
|
|
|
} |
1028
|
|
|
|
1029
|
|
|
$data['comment'] = nl2br($order_info['comment']); |
1030
|
|
|
|
1031
|
|
|
$this->load->model('customer/customer'); |
1032
|
|
|
|
1033
|
|
|
$data['reward'] = $order_info['reward']; |
1034
|
|
|
|
1035
|
|
|
$data['reward_total'] = $this->model_customer_customer->getTotalCustomerRewardsByOrderId($this->request->get['order_id']); |
1036
|
|
|
|
1037
|
|
|
$data['commission'] = $this->currency->format($order_info['commission'], $order_info['currency_code'], $order_info['currency_value']); |
1038
|
|
|
|
1039
|
|
|
$this->load->model('localisation/order_status'); |
1040
|
|
|
|
1041
|
|
|
$order_status_info = $this->model_localisation_order_status->getOrderStatus($order_info['order_status_id']); |
1042
|
|
|
|
1043
|
|
|
if ($order_status_info) { |
1044
|
|
|
$data['order_status'] = $order_status_info['name']; |
1045
|
|
|
} else { |
1046
|
|
|
$data['order_status'] = ''; |
1047
|
|
|
} |
1048
|
|
|
|
1049
|
|
|
$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); |
1050
|
|
|
|
1051
|
|
|
$data['order_status_id'] = $order_info['order_status_id']; |
1052
|
|
|
|
1053
|
|
|
$data['account_custom_field'] = $order_info['custom_field']; |
1054
|
|
|
|
1055
|
|
|
// Custom Fields |
1056
|
|
|
$this->load->model('customer/custom_field'); |
1057
|
|
|
|
1058
|
|
|
$data['account_custom_fields'] = array(); |
1059
|
|
|
|
1060
|
|
|
$filter_data = array( |
1061
|
|
|
'sort' => 'cf.sort_order', |
1062
|
|
|
'order' => 'ASC' |
1063
|
|
|
); |
1064
|
|
|
|
1065
|
|
|
$custom_fields = $this->model_customer_custom_field->getCustomFields($filter_data); |
1066
|
|
|
|
1067
|
|
|
foreach ($custom_fields as $custom_field) { |
1068
|
|
|
if ($custom_field['location'] == 'account' && isset($order_info['custom_field'][$custom_field['custom_field_id']])) { |
1069
|
|
|
if ($custom_field['type'] == 'select' || $custom_field['type'] == 'radio') { |
1070
|
|
|
$custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($order_info['custom_field'][$custom_field['custom_field_id']]); |
1071
|
|
|
|
1072
|
|
|
if ($custom_field_value_info) { |
1073
|
|
|
$data['account_custom_fields'][] = array( |
1074
|
|
|
'name' => $custom_field['name'], |
1075
|
|
|
'value' => $custom_field_value_info['name'] |
1076
|
|
|
); |
1077
|
|
|
} |
1078
|
|
|
} |
1079
|
|
|
|
1080
|
|
|
if ($custom_field['type'] == 'checkbox' && is_array($order_info['custom_field'][$custom_field['custom_field_id']])) { |
1081
|
|
|
foreach ($order_info['custom_field'][$custom_field['custom_field_id']] as $custom_field_value_id) { |
1082
|
|
|
$custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($custom_field_value_id); |
1083
|
|
|
|
1084
|
|
|
if ($custom_field_value_info) { |
1085
|
|
|
$data['account_custom_fields'][] = array( |
1086
|
|
|
'name' => $custom_field['name'], |
1087
|
|
|
'value' => $custom_field_value_info['name'] |
1088
|
|
|
); |
1089
|
|
|
} |
1090
|
|
|
} |
1091
|
|
|
} |
1092
|
|
|
|
1093
|
|
|
if ($custom_field['type'] == 'text' || $custom_field['type'] == 'textarea' || $custom_field['type'] == 'file' || $custom_field['type'] == 'date' || $custom_field['type'] == 'datetime' || $custom_field['type'] == 'time') { |
1094
|
|
|
$data['account_custom_fields'][] = array( |
1095
|
|
|
'name' => $custom_field['name'], |
1096
|
|
|
'value' => $order_info['custom_field'][$custom_field['custom_field_id']] |
1097
|
|
|
); |
1098
|
|
|
} |
1099
|
|
|
|
1100
|
|
|
if ($custom_field['type'] == 'file') { |
1101
|
|
|
$upload_info = $this->model_tool_upload->getUploadByCode($order_info['custom_field'][$custom_field['custom_field_id']]); |
1102
|
|
|
|
1103
|
|
|
if ($upload_info) { |
1104
|
|
|
$data['account_custom_fields'][] = array( |
1105
|
|
|
'name' => $custom_field['name'], |
1106
|
|
|
'value' => $upload_info['name'] |
1107
|
|
|
); |
1108
|
|
|
} |
1109
|
|
|
} |
1110
|
|
|
} |
1111
|
|
|
} |
1112
|
|
|
|
1113
|
|
|
// Custom fields |
1114
|
|
|
$data['payment_custom_fields'] = array(); |
1115
|
|
|
|
1116
|
|
|
foreach ($custom_fields as $custom_field) { |
1117
|
|
|
if ($custom_field['location'] == 'address' && isset($order_info['payment_custom_field'][$custom_field['custom_field_id']])) { |
1118
|
|
|
if ($custom_field['type'] == 'select' || $custom_field['type'] == 'radio') { |
1119
|
|
|
$custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($order_info['payment_custom_field'][$custom_field['custom_field_id']]); |
1120
|
|
|
|
1121
|
|
|
if ($custom_field_value_info) { |
1122
|
|
|
$data['payment_custom_fields'][] = array( |
1123
|
|
|
'name' => $custom_field['name'], |
1124
|
|
|
'value' => $custom_field_value_info['name'], |
1125
|
|
|
'sort_order' => $custom_field['sort_order'] |
1126
|
|
|
); |
1127
|
|
|
} |
1128
|
|
|
} |
1129
|
|
|
|
1130
|
|
|
if ($custom_field['type'] == 'checkbox' && is_array($order_info['payment_custom_field'][$custom_field['custom_field_id']])) { |
1131
|
|
|
foreach ($order_info['payment_custom_field'][$custom_field['custom_field_id']] as $custom_field_value_id) { |
1132
|
|
|
$custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($custom_field_value_id); |
1133
|
|
|
|
1134
|
|
|
if ($custom_field_value_info) { |
1135
|
|
|
$data['payment_custom_fields'][] = array( |
1136
|
|
|
'name' => $custom_field['name'], |
1137
|
|
|
'value' => $custom_field_value_info['name'], |
1138
|
|
|
'sort_order' => $custom_field['sort_order'] |
1139
|
|
|
); |
1140
|
|
|
} |
1141
|
|
|
} |
1142
|
|
|
} |
1143
|
|
|
|
1144
|
|
|
if ($custom_field['type'] == 'text' || $custom_field['type'] == 'textarea' || $custom_field['type'] == 'file' || $custom_field['type'] == 'date' || $custom_field['type'] == 'datetime' || $custom_field['type'] == 'time') { |
1145
|
|
|
$data['payment_custom_fields'][] = array( |
1146
|
|
|
'name' => $custom_field['name'], |
1147
|
|
|
'value' => $order_info['payment_custom_field'][$custom_field['custom_field_id']], |
1148
|
|
|
'sort_order' => $custom_field['sort_order'] |
1149
|
|
|
); |
1150
|
|
|
} |
1151
|
|
|
|
1152
|
|
|
if ($custom_field['type'] == 'file') { |
1153
|
|
|
$upload_info = $this->model_tool_upload->getUploadByCode($order_info['payment_custom_field'][$custom_field['custom_field_id']]); |
1154
|
|
|
|
1155
|
|
|
if ($upload_info) { |
1156
|
|
|
$data['payment_custom_fields'][] = array( |
1157
|
|
|
'name' => $custom_field['name'], |
1158
|
|
|
'value' => $upload_info['name'], |
1159
|
|
|
'sort_order' => $custom_field['sort_order'] |
1160
|
|
|
); |
1161
|
|
|
} |
1162
|
|
|
} |
1163
|
|
|
} |
1164
|
|
|
} |
1165
|
|
|
|
1166
|
|
|
// Shipping |
1167
|
|
|
$data['shipping_custom_fields'] = array(); |
1168
|
|
|
|
1169
|
|
|
foreach ($custom_fields as $custom_field) { |
1170
|
|
|
if ($custom_field['location'] == 'address' && isset($order_info['shipping_custom_field'][$custom_field['custom_field_id']])) { |
1171
|
|
|
if ($custom_field['type'] == 'select' || $custom_field['type'] == 'radio') { |
1172
|
|
|
$custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($order_info['shipping_custom_field'][$custom_field['custom_field_id']]); |
1173
|
|
|
|
1174
|
|
|
if ($custom_field_value_info) { |
1175
|
|
|
$data['shipping_custom_fields'][] = array( |
1176
|
|
|
'name' => $custom_field['name'], |
1177
|
|
|
'value' => $custom_field_value_info['name'], |
1178
|
|
|
'sort_order' => $custom_field['sort_order'] |
1179
|
|
|
); |
1180
|
|
|
} |
1181
|
|
|
} |
1182
|
|
|
|
1183
|
|
|
if ($custom_field['type'] == 'checkbox' && is_array($order_info['shipping_custom_field'][$custom_field['custom_field_id']])) { |
1184
|
|
|
foreach ($order_info['shipping_custom_field'][$custom_field['custom_field_id']] as $custom_field_value_id) { |
1185
|
|
|
$custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($custom_field_value_id); |
1186
|
|
|
|
1187
|
|
|
if ($custom_field_value_info) { |
1188
|
|
|
$data['shipping_custom_fields'][] = array( |
1189
|
|
|
'name' => $custom_field['name'], |
1190
|
|
|
'value' => $custom_field_value_info['name'], |
1191
|
|
|
'sort_order' => $custom_field['sort_order'] |
1192
|
|
|
); |
1193
|
|
|
} |
1194
|
|
|
} |
1195
|
|
|
} |
1196
|
|
|
|
1197
|
|
|
if ($custom_field['type'] == 'text' || $custom_field['type'] == 'textarea' || $custom_field['type'] == 'file' || $custom_field['type'] == 'date' || $custom_field['type'] == 'datetime' || $custom_field['type'] == 'time') { |
1198
|
|
|
$data['shipping_custom_fields'][] = array( |
1199
|
|
|
'name' => $custom_field['name'], |
1200
|
|
|
'value' => $order_info['shipping_custom_field'][$custom_field['custom_field_id']], |
1201
|
|
|
'sort_order' => $custom_field['sort_order'] |
1202
|
|
|
); |
1203
|
|
|
} |
1204
|
|
|
|
1205
|
|
|
if ($custom_field['type'] == 'file') { |
1206
|
|
|
$upload_info = $this->model_tool_upload->getUploadByCode($order_info['shipping_custom_field'][$custom_field['custom_field_id']]); |
1207
|
|
|
|
1208
|
|
|
if ($upload_info) { |
1209
|
|
|
$data['shipping_custom_fields'][] = array( |
1210
|
|
|
'name' => $custom_field['name'], |
1211
|
|
|
'value' => $upload_info['name'], |
1212
|
|
|
'sort_order' => $custom_field['sort_order'] |
1213
|
|
|
); |
1214
|
|
|
} |
1215
|
|
|
} |
1216
|
|
|
} |
1217
|
|
|
} |
1218
|
|
|
|
1219
|
|
|
$data['ip'] = $order_info['ip']; |
1220
|
|
|
$data['forwarded_ip'] = $order_info['forwarded_ip']; |
1221
|
|
|
$data['user_agent'] = $order_info['user_agent']; |
1222
|
|
|
$data['accept_language'] = $order_info['accept_language']; |
1223
|
|
|
|
1224
|
|
|
// Additional Tabs |
1225
|
|
|
$data['tabs'] = array(); |
1226
|
|
|
|
1227
|
|
|
if ($this->user->hasPermission('access', 'extension/payment/' . $order_info['payment_code'])) { |
1228
|
|
|
if (is_file(DIR_CATALOG . 'controller/extension/payment/' . $order_info['payment_code'] . '.php')) { |
|
|
|
|
1229
|
|
|
$content = $this->load->controller('extension/payment/' . $order_info['payment_code'] . '/order'); |
1230
|
|
|
} else { |
1231
|
|
|
$content = null; |
1232
|
|
|
} |
1233
|
|
|
|
1234
|
|
|
if ($content) { |
1235
|
|
|
$this->load->language('extension/payment/' . $order_info['payment_code']); |
1236
|
|
|
|
1237
|
|
|
$data['tabs'][] = array( |
1238
|
|
|
'code' => $order_info['payment_code'], |
1239
|
|
|
'title' => $this->language->get('heading_title'), |
1240
|
|
|
'content' => $content |
1241
|
|
|
); |
1242
|
|
|
} |
1243
|
|
|
} |
1244
|
|
|
|
1245
|
|
|
$data['header'] = $this->load->controller('common/header'); |
1246
|
|
|
$data['column'] = $this->load->controller('common/column_left'); |
1247
|
|
|
$data['footer'] = $this->load->controller('common/footer'); |
1248
|
|
|
|
1249
|
|
|
$this->response->setOutput($this->load->view('sale/order_info', $data)); |
1250
|
|
|
} else { |
1251
|
|
|
return new \Divine\Engine\Core\Action('error/not_found'); |
1252
|
|
|
} |
1253
|
|
|
} |
1254
|
|
|
|
1255
|
|
|
protected function validate() |
1256
|
|
|
{ |
1257
|
|
|
if (!$this->user->hasPermission('modify', 'sale/order')) { |
1258
|
|
|
$this->error['warning'] = $this->language->get('error_permission'); |
1259
|
|
|
} |
1260
|
|
|
|
1261
|
|
|
return !$this->error; |
1262
|
|
|
} |
1263
|
|
|
|
1264
|
|
|
public function createInvoiceNo() |
1265
|
|
|
{ |
1266
|
|
|
$this->load->language('sale/order'); |
1267
|
|
|
|
1268
|
|
|
$json = array(); |
1269
|
|
|
|
1270
|
|
|
if (!$this->user->hasPermission('modify', 'sale/order')) { |
1271
|
|
|
$json['error'] = $this->language->get('error_permission'); |
1272
|
|
|
} elseif (isset($this->request->get['order_id'])) { |
1273
|
|
|
if (isset($this->request->get['order_id'])) { |
1274
|
|
|
$order_id = $this->request->get['order_id']; |
1275
|
|
|
} else { |
1276
|
|
|
$order_id = 0; |
1277
|
|
|
} |
1278
|
|
|
|
1279
|
|
|
$this->load->model('sale/order'); |
1280
|
|
|
|
1281
|
|
|
$invoice_no = $this->model_sale_order->createInvoiceNo($order_id); |
1282
|
|
|
|
1283
|
|
|
if ($invoice_no) { |
1284
|
|
|
$json['invoice_no'] = $invoice_no; |
1285
|
|
|
} else { |
1286
|
|
|
$json['error'] = $this->language->get('error_action'); |
1287
|
|
|
} |
1288
|
|
|
} |
1289
|
|
|
|
1290
|
|
|
$this->response->addHeader('Content-Type: application/json'); |
1291
|
|
|
$this->response->setOutput(json_encode($json)); |
1292
|
|
|
} |
1293
|
|
|
|
1294
|
|
|
public function addReward() |
1295
|
|
|
{ |
1296
|
|
|
$this->load->language('sale/order'); |
1297
|
|
|
|
1298
|
|
|
$json = array(); |
1299
|
|
|
|
1300
|
|
|
if (!$this->user->hasPermission('modify', 'sale/order')) { |
1301
|
|
|
$json['error'] = $this->language->get('error_permission'); |
1302
|
|
|
} else { |
1303
|
|
|
if (isset($this->request->get['order_id'])) { |
1304
|
|
|
$order_id = $this->request->get['order_id']; |
1305
|
|
|
} else { |
1306
|
|
|
$order_id = 0; |
1307
|
|
|
} |
1308
|
|
|
|
1309
|
|
|
$this->load->model('sale/order'); |
1310
|
|
|
|
1311
|
|
|
$order_info = $this->model_sale_order->getOrder($order_id); |
1312
|
|
|
|
1313
|
|
|
if ($order_info && $order_info['customer_id'] && ($order_info['reward'] > 0)) { |
1314
|
|
|
$this->load->model('customer/customer'); |
1315
|
|
|
|
1316
|
|
|
$reward_total = $this->model_customer_customer->getTotalCustomerRewardsByOrderId($order_id); |
1317
|
|
|
|
1318
|
|
|
if (!$reward_total) { |
1319
|
|
|
$this->model_customer_customer->addReward($order_info['customer_id'], $this->language->get('text_order_id') . ' #' . $order_id, $order_info['reward'], $order_id); |
1320
|
|
|
} |
1321
|
|
|
} |
1322
|
|
|
|
1323
|
|
|
$json['success'] = $this->language->get('text_reward_added'); |
1324
|
|
|
} |
1325
|
|
|
|
1326
|
|
|
$this->response->addHeader('Content-Type: application/json'); |
1327
|
|
|
$this->response->setOutput(json_encode($json)); |
1328
|
|
|
} |
1329
|
|
|
|
1330
|
|
|
public function removeReward() |
1331
|
|
|
{ |
1332
|
|
|
$this->load->language('sale/order'); |
1333
|
|
|
|
1334
|
|
|
$json = array(); |
1335
|
|
|
|
1336
|
|
|
if (!$this->user->hasPermission('modify', 'sale/order')) { |
1337
|
|
|
$json['error'] = $this->language->get('error_permission'); |
1338
|
|
|
} else { |
1339
|
|
|
if (isset($this->request->get['order_id'])) { |
1340
|
|
|
$order_id = $this->request->get['order_id']; |
1341
|
|
|
} else { |
1342
|
|
|
$order_id = 0; |
1343
|
|
|
} |
1344
|
|
|
|
1345
|
|
|
$this->load->model('sale/order'); |
1346
|
|
|
|
1347
|
|
|
$order_info = $this->model_sale_order->getOrder($order_id); |
1348
|
|
|
|
1349
|
|
|
if ($order_info) { |
1350
|
|
|
$this->load->model('customer/customer'); |
1351
|
|
|
|
1352
|
|
|
$this->model_customer_customer->deleteReward($order_id); |
1353
|
|
|
} |
1354
|
|
|
|
1355
|
|
|
$json['success'] = $this->language->get('text_reward_removed'); |
1356
|
|
|
} |
1357
|
|
|
|
1358
|
|
|
$this->response->addHeader('Content-Type: application/json'); |
1359
|
|
|
$this->response->setOutput(json_encode($json)); |
1360
|
|
|
} |
1361
|
|
|
|
1362
|
|
|
public function addCommission() |
1363
|
|
|
{ |
1364
|
|
|
$this->load->language('sale/order'); |
1365
|
|
|
|
1366
|
|
|
$json = array(); |
1367
|
|
|
|
1368
|
|
|
if (!$this->user->hasPermission('modify', 'sale/order')) { |
1369
|
|
|
$json['error'] = $this->language->get('error_permission'); |
1370
|
|
|
} else { |
1371
|
|
|
if (isset($this->request->get['order_id'])) { |
1372
|
|
|
$order_id = $this->request->get['order_id']; |
1373
|
|
|
} else { |
1374
|
|
|
$order_id = 0; |
1375
|
|
|
} |
1376
|
|
|
|
1377
|
|
|
$this->load->model('sale/order'); |
1378
|
|
|
|
1379
|
|
|
$order_info = $this->model_sale_order->getOrder($order_id); |
|
|
|
|
1380
|
|
|
|
1381
|
|
|
$json['success'] = $this->language->get('text_commission_added'); |
1382
|
|
|
} |
1383
|
|
|
|
1384
|
|
|
$this->response->addHeader('Content-Type: application/json'); |
1385
|
|
|
$this->response->setOutput(json_encode($json)); |
1386
|
|
|
} |
1387
|
|
|
|
1388
|
|
|
public function removeCommission() |
1389
|
|
|
{ |
1390
|
|
|
$this->load->language('sale/order'); |
1391
|
|
|
|
1392
|
|
|
$json = array(); |
1393
|
|
|
|
1394
|
|
|
if (!$this->user->hasPermission('modify', 'sale/order')) { |
1395
|
|
|
$json['error'] = $this->language->get('error_permission'); |
1396
|
|
|
} else { |
1397
|
|
|
if (isset($this->request->get['order_id'])) { |
1398
|
|
|
$order_id = $this->request->get['order_id']; |
1399
|
|
|
} else { |
1400
|
|
|
$order_id = 0; |
1401
|
|
|
} |
1402
|
|
|
|
1403
|
|
|
$this->load->model('sale/order'); |
1404
|
|
|
|
1405
|
|
|
$order_info = $this->model_sale_order->getOrder($order_id); |
|
|
|
|
1406
|
|
|
|
1407
|
|
|
$json['success'] = $this->language->get('text_commission_removed'); |
1408
|
|
|
} |
1409
|
|
|
|
1410
|
|
|
$this->response->addHeader('Content-Type: application/json'); |
1411
|
|
|
$this->response->setOutput(json_encode($json)); |
1412
|
|
|
} |
1413
|
|
|
|
1414
|
|
|
public function history() |
1415
|
|
|
{ |
1416
|
|
|
$this->load->language('sale/order'); |
1417
|
|
|
|
1418
|
|
|
$data['text_no_results'] = $this->language->get('text_no_results'); |
|
|
|
|
1419
|
|
|
|
1420
|
|
|
$data['column_date_added'] = $this->language->get('column_date_added'); |
1421
|
|
|
$data['column_status'] = $this->language->get('column_status'); |
1422
|
|
|
$data['column_notify'] = $this->language->get('column_notify'); |
1423
|
|
|
$data['column_comment'] = $this->language->get('column_comment'); |
1424
|
|
|
|
1425
|
|
|
if (isset($this->request->get['page'])) { |
1426
|
|
|
$page = $this->request->get['page']; |
1427
|
|
|
} else { |
1428
|
|
|
$page = 1; |
1429
|
|
|
} |
1430
|
|
|
|
1431
|
|
|
$data['histories'] = array(); |
1432
|
|
|
|
1433
|
|
|
$this->load->model('sale/order'); |
1434
|
|
|
|
1435
|
|
|
$results = $this->model_sale_order->getOrderHistories($this->request->get['order_id'], ($page - 1) * 10, 10); |
1436
|
|
|
|
1437
|
|
|
foreach ($results as $result) { |
1438
|
|
|
$data['histories'][] = array( |
1439
|
|
|
'notify' => $result['notify'] ? $this->language->get('text_yes') : $this->language->get('text_no'), |
1440
|
|
|
'status' => $result['status'], |
1441
|
|
|
'comment' => nl2br($result['comment']), |
1442
|
|
|
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])) |
1443
|
|
|
); |
1444
|
|
|
} |
1445
|
|
|
|
1446
|
|
|
$history_total = $this->model_sale_order->getTotalOrderHistories($this->request->get['order_id']); |
1447
|
|
|
|
1448
|
|
|
$pagination = new \Divine\Engine\Library\Pagination(); |
1449
|
|
|
$pagination->total = $history_total; |
1450
|
|
|
$pagination->page = $page; |
1451
|
|
|
$pagination->limit = 10; |
1452
|
|
|
$pagination->url = $this->url->link('sale/order/history', 'token=' . $this->session->data['token'] . '&order_id=' . $this->request->get['order_id'] . '&page={page}', true); |
1453
|
|
|
|
1454
|
|
|
$data['pagination'] = $pagination->render(); |
1455
|
|
|
|
1456
|
|
|
$data['results'] = sprintf($this->language->get('text_pagination'), ($history_total) ? (($page - 1) * 10) + 1 : 0, ((($page - 1) * 10) > ($history_total - 10)) ? $history_total : ((($page - 1) * 10) + 10), $history_total, ceil($history_total / 10)); |
1457
|
|
|
|
1458
|
|
|
$this->response->setOutput($this->load->view('sale/order_history', $data)); |
1459
|
|
|
} |
1460
|
|
|
|
1461
|
|
|
public function invoice() |
1462
|
|
|
{ |
1463
|
|
|
$this->load->language('sale/order'); |
1464
|
|
|
|
1465
|
|
|
$data['title'] = $this->language->get('text_invoice'); |
|
|
|
|
1466
|
|
|
|
1467
|
|
|
$data['direction'] = $this->language->get('direction'); |
1468
|
|
|
$data['lang'] = $this->language->get('code'); |
1469
|
|
|
|
1470
|
|
|
$data['text_invoice'] = $this->language->get('text_invoice'); |
1471
|
|
|
$data['text_order_detail'] = $this->language->get('text_order_detail'); |
1472
|
|
|
$data['text_order_id'] = $this->language->get('text_order_id'); |
1473
|
|
|
$data['text_invoice_no'] = $this->language->get('text_invoice_no'); |
1474
|
|
|
$data['text_invoice_date'] = $this->language->get('text_invoice_date'); |
1475
|
|
|
$data['text_date_added'] = $this->language->get('text_date_added'); |
1476
|
|
|
$data['text_telephone'] = $this->language->get('text_telephone'); |
1477
|
|
|
$data['text_fax'] = $this->language->get('text_fax'); |
1478
|
|
|
$data['text_email'] = $this->language->get('text_email'); |
1479
|
|
|
$data['text_website'] = $this->language->get('text_website'); |
1480
|
|
|
$data['text_payment_address'] = $this->language->get('text_payment_address'); |
1481
|
|
|
$data['text_shipping_address'] = $this->language->get('text_shipping_address'); |
1482
|
|
|
$data['text_payment_method'] = $this->language->get('text_payment_method'); |
1483
|
|
|
$data['text_shipping_method'] = $this->language->get('text_shipping_method'); |
1484
|
|
|
$data['text_comment'] = $this->language->get('text_comment'); |
1485
|
|
|
|
1486
|
|
|
$data['column_product'] = $this->language->get('column_product'); |
1487
|
|
|
$data['column_model'] = $this->language->get('column_model'); |
1488
|
|
|
$data['column_quantity'] = $this->language->get('column_quantity'); |
1489
|
|
|
$data['column_price'] = $this->language->get('column_price'); |
1490
|
|
|
$data['column_total'] = $this->language->get('column_total'); |
1491
|
|
|
|
1492
|
|
|
$this->load->model('sale/order'); |
1493
|
|
|
|
1494
|
|
|
$this->load->model('setting/setting'); |
1495
|
|
|
|
1496
|
|
|
$data['orders'] = array(); |
1497
|
|
|
|
1498
|
|
|
$orders = array(); |
1499
|
|
|
|
1500
|
|
|
if (isset($this->request->post['selected'])) { |
1501
|
|
|
$orders = $this->request->post['selected']; |
1502
|
|
|
} elseif (isset($this->request->get['order_id'])) { |
1503
|
|
|
$orders[] = $this->request->get['order_id']; |
1504
|
|
|
} |
1505
|
|
|
|
1506
|
|
|
foreach ($orders as $order_id) { |
1507
|
|
|
$order_info = $this->model_sale_order->getOrder($order_id); |
1508
|
|
|
|
1509
|
|
|
if ($order_info) { |
1510
|
|
|
$store_address = $this->config->get('config_address'); |
1511
|
|
|
$store_email = $this->config->get('config_email'); |
1512
|
|
|
$store_telephone = $this->config->get('config_telephone'); |
1513
|
|
|
$store_fax = $this->config->get('config_fax'); |
1514
|
|
|
|
1515
|
|
|
if ($order_info['invoice_no']) { |
1516
|
|
|
$invoice_no = $order_info['invoice_prefix'] . $order_info['invoice_no']; |
1517
|
|
|
} else { |
1518
|
|
|
$invoice_no = ''; |
1519
|
|
|
} |
1520
|
|
|
|
1521
|
|
|
if ($order_info['payment_address_format']) { |
1522
|
|
|
$format = $order_info['payment_address_format']; |
1523
|
|
|
} else { |
1524
|
|
|
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}'; |
1525
|
|
|
} |
1526
|
|
|
|
1527
|
|
|
$find = array( |
1528
|
|
|
'{firstname}', |
1529
|
|
|
'{lastname}', |
1530
|
|
|
'{company}', |
1531
|
|
|
'{address_1}', |
1532
|
|
|
'{address_2}', |
1533
|
|
|
'{city}', |
1534
|
|
|
'{postcode}', |
1535
|
|
|
'{zone}', |
1536
|
|
|
'{zone_code}', |
1537
|
|
|
'{country}' |
1538
|
|
|
); |
1539
|
|
|
|
1540
|
|
|
$replace = array( |
1541
|
|
|
'firstname' => $order_info['payment_firstname'], |
1542
|
|
|
'lastname' => $order_info['payment_lastname'], |
1543
|
|
|
'company' => $order_info['payment_company'], |
1544
|
|
|
'address_1' => $order_info['payment_address_1'], |
1545
|
|
|
'address_2' => $order_info['payment_address_2'], |
1546
|
|
|
'city' => $order_info['payment_city'], |
1547
|
|
|
'postcode' => $order_info['payment_postcode'], |
1548
|
|
|
'zone' => $order_info['payment_zone'], |
1549
|
|
|
'zone_code' => $order_info['payment_zone_code'], |
1550
|
|
|
'country' => $order_info['payment_country'] |
1551
|
|
|
); |
1552
|
|
|
|
1553
|
|
|
$payment_address = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format)))); |
|
|
|
|
1554
|
|
|
|
1555
|
|
|
if ($order_info['shipping_address_format']) { |
1556
|
|
|
$format = $order_info['shipping_address_format']; |
1557
|
|
|
} else { |
1558
|
|
|
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}'; |
1559
|
|
|
} |
1560
|
|
|
|
1561
|
|
|
$find = array( |
1562
|
|
|
'{firstname}', |
1563
|
|
|
'{lastname}', |
1564
|
|
|
'{company}', |
1565
|
|
|
'{address_1}', |
1566
|
|
|
'{address_2}', |
1567
|
|
|
'{city}', |
1568
|
|
|
'{postcode}', |
1569
|
|
|
'{zone}', |
1570
|
|
|
'{zone_code}', |
1571
|
|
|
'{country}' |
1572
|
|
|
); |
1573
|
|
|
|
1574
|
|
|
$replace = array( |
1575
|
|
|
'firstname' => $order_info['shipping_firstname'], |
1576
|
|
|
'lastname' => $order_info['shipping_lastname'], |
1577
|
|
|
'company' => $order_info['shipping_company'], |
1578
|
|
|
'address_1' => $order_info['shipping_address_1'], |
1579
|
|
|
'address_2' => $order_info['shipping_address_2'], |
1580
|
|
|
'city' => $order_info['shipping_city'], |
1581
|
|
|
'postcode' => $order_info['shipping_postcode'], |
1582
|
|
|
'zone' => $order_info['shipping_zone'], |
1583
|
|
|
'zone_code' => $order_info['shipping_zone_code'], |
1584
|
|
|
'country' => $order_info['shipping_country'] |
1585
|
|
|
); |
1586
|
|
|
|
1587
|
|
|
$shipping_address = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format)))); |
|
|
|
|
1588
|
|
|
|
1589
|
|
|
$this->load->model('tool/upload'); |
1590
|
|
|
|
1591
|
|
|
$product_data = array(); |
1592
|
|
|
|
1593
|
|
|
$products = $this->model_sale_order->getOrderProducts($order_id); |
1594
|
|
|
|
1595
|
|
|
foreach ($products as $product) { |
1596
|
|
|
$option_data = array(); |
1597
|
|
|
|
1598
|
|
|
$options = $this->model_sale_order->getOrderOptions($order_id, $product['order_product_id']); |
1599
|
|
|
|
1600
|
|
|
foreach ($options as $option) { |
1601
|
|
|
if ($option['type'] != 'file') { |
1602
|
|
|
$value = $option['value']; |
1603
|
|
|
} else { |
1604
|
|
|
$upload_info = $this->model_tool_upload->getUploadByCode($option['value']); |
1605
|
|
|
|
1606
|
|
|
if ($upload_info) { |
1607
|
|
|
$value = $upload_info['name']; |
1608
|
|
|
} else { |
1609
|
|
|
$value = ''; |
1610
|
|
|
} |
1611
|
|
|
} |
1612
|
|
|
|
1613
|
|
|
$option_data[] = array( |
1614
|
|
|
'name' => $option['name'], |
1615
|
|
|
'value' => $value |
1616
|
|
|
); |
1617
|
|
|
} |
1618
|
|
|
|
1619
|
|
|
$product_data[] = array( |
1620
|
|
|
'name' => $product['name'], |
1621
|
|
|
'model' => $product['model'], |
1622
|
|
|
'option' => $option_data, |
1623
|
|
|
'quantity' => $product['quantity'], |
1624
|
|
|
'price' => $this->currency->format($product['price'], $order_info['currency_code'], $order_info['currency_value']), |
1625
|
|
|
'total' => $this->currency->format($product['total'], $order_info['currency_code'], $order_info['currency_value']) |
1626
|
|
|
); |
1627
|
|
|
} |
1628
|
|
|
|
1629
|
|
|
$total_data = array(); |
1630
|
|
|
|
1631
|
|
|
$totals = $this->model_sale_order->getOrderTotals($order_id); |
1632
|
|
|
|
1633
|
|
|
foreach ($totals as $total) { |
1634
|
|
|
$total_data[] = array( |
1635
|
|
|
'title' => $total['title'], |
1636
|
|
|
'text' => $this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']) |
1637
|
|
|
); |
1638
|
|
|
} |
1639
|
|
|
|
1640
|
|
|
$data['orders'][] = array( |
1641
|
|
|
'order_id' => $order_id, |
1642
|
|
|
'invoice_no' => $invoice_no, |
1643
|
|
|
'date_added' => date($this->language->get('date_format_short'), strtotime($order_info['date_added'])), |
1644
|
|
|
'store_name' => $order_info['store_name'], |
1645
|
|
|
'store_url' => rtrim($order_info['store_url'], '/'), |
1646
|
|
|
'store_address' => nl2br($store_address), |
1647
|
|
|
'store_email' => $store_email, |
1648
|
|
|
'store_telephone' => $store_telephone, |
1649
|
|
|
'store_fax' => $store_fax, |
1650
|
|
|
'email' => $order_info['email'], |
1651
|
|
|
'telephone' => $order_info['telephone'], |
1652
|
|
|
'shipping_address' => $shipping_address, |
1653
|
|
|
'shipping_method' => $order_info['shipping_method'], |
1654
|
|
|
'payment_address' => $payment_address, |
1655
|
|
|
'payment_method' => $order_info['payment_method'], |
1656
|
|
|
'product' => $product_data, |
1657
|
|
|
'total' => $total_data, |
1658
|
|
|
'comment' => nl2br($order_info['comment']) |
1659
|
|
|
); |
1660
|
|
|
} |
1661
|
|
|
} |
1662
|
|
|
|
1663
|
|
|
$this->response->setOutput($this->load->view('sale/order_invoice', $data)); |
1664
|
|
|
} |
1665
|
|
|
|
1666
|
|
|
public function shipping() |
1667
|
|
|
{ |
1668
|
|
|
$this->load->language('sale/order'); |
1669
|
|
|
|
1670
|
|
|
$data['title'] = $this->language->get('text_shipping'); |
|
|
|
|
1671
|
|
|
|
1672
|
|
|
$data['direction'] = $this->language->get('direction'); |
1673
|
|
|
$data['lang'] = $this->language->get('code'); |
1674
|
|
|
|
1675
|
|
|
$data['text_shipping'] = $this->language->get('text_shipping'); |
1676
|
|
|
$data['text_picklist'] = $this->language->get('text_picklist'); |
1677
|
|
|
$data['text_order_detail'] = $this->language->get('text_order_detail'); |
1678
|
|
|
$data['text_order_id'] = $this->language->get('text_order_id'); |
1679
|
|
|
$data['text_invoice_no'] = $this->language->get('text_invoice_no'); |
1680
|
|
|
$data['text_invoice_date'] = $this->language->get('text_invoice_date'); |
1681
|
|
|
$data['text_date_added'] = $this->language->get('text_date_added'); |
1682
|
|
|
$data['text_telephone'] = $this->language->get('text_telephone'); |
1683
|
|
|
$data['text_fax'] = $this->language->get('text_fax'); |
1684
|
|
|
$data['text_email'] = $this->language->get('text_email'); |
1685
|
|
|
$data['text_website'] = $this->language->get('text_website'); |
1686
|
|
|
$data['text_contact'] = $this->language->get('text_contact'); |
1687
|
|
|
$data['text_shipping_address'] = $this->language->get('text_shipping_address'); |
1688
|
|
|
$data['text_shipping_method'] = $this->language->get('text_shipping_method'); |
1689
|
|
|
$data['text_sku'] = $this->language->get('text_sku'); |
1690
|
|
|
$data['text_upc'] = $this->language->get('text_upc'); |
1691
|
|
|
$data['text_ean'] = $this->language->get('text_ean'); |
1692
|
|
|
$data['text_jan'] = $this->language->get('text_jan'); |
1693
|
|
|
$data['text_isbn'] = $this->language->get('text_isbn'); |
1694
|
|
|
$data['text_mpn'] = $this->language->get('text_mpn'); |
1695
|
|
|
$data['text_comment'] = $this->language->get('text_comment'); |
1696
|
|
|
|
1697
|
|
|
$data['column_location'] = $this->language->get('column_location'); |
1698
|
|
|
$data['column_reference'] = $this->language->get('column_reference'); |
1699
|
|
|
$data['column_product'] = $this->language->get('column_product'); |
1700
|
|
|
$data['column_model'] = $this->language->get('column_model'); |
1701
|
|
|
$data['column_quantity'] = $this->language->get('column_quantity'); |
1702
|
|
|
|
1703
|
|
|
$this->load->model('sale/order'); |
1704
|
|
|
|
1705
|
|
|
$this->load->model('catalog/product'); |
1706
|
|
|
|
1707
|
|
|
$this->load->model('setting/setting'); |
1708
|
|
|
|
1709
|
|
|
$data['orders'] = array(); |
1710
|
|
|
|
1711
|
|
|
$orders = array(); |
1712
|
|
|
|
1713
|
|
|
if (isset($this->request->post['selected'])) { |
1714
|
|
|
$orders = $this->request->post['selected']; |
1715
|
|
|
} elseif (isset($this->request->get['order_id'])) { |
1716
|
|
|
$orders[] = $this->request->get['order_id']; |
1717
|
|
|
} |
1718
|
|
|
|
1719
|
|
|
foreach ($orders as $order_id) { |
1720
|
|
|
$order_info = $this->model_sale_order->getOrder($order_id); |
1721
|
|
|
|
1722
|
|
|
// Make sure there is a shipping method |
1723
|
|
|
if ($order_info && $order_info['shipping_code']) { |
1724
|
|
|
$store_address = $this->config->get('config_address'); |
1725
|
|
|
$store_email = $this->config->get('config_email'); |
1726
|
|
|
$store_telephone = $this->config->get('config_telephone'); |
1727
|
|
|
$store_fax = $this->config->get('config_fax'); |
1728
|
|
|
|
1729
|
|
|
if ($order_info['invoice_no']) { |
1730
|
|
|
$invoice_no = $order_info['invoice_prefix'] . $order_info['invoice_no']; |
1731
|
|
|
} else { |
1732
|
|
|
$invoice_no = ''; |
1733
|
|
|
} |
1734
|
|
|
|
1735
|
|
|
if ($order_info['shipping_address_format']) { |
1736
|
|
|
$format = $order_info['shipping_address_format']; |
1737
|
|
|
} else { |
1738
|
|
|
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}'; |
1739
|
|
|
} |
1740
|
|
|
|
1741
|
|
|
$find = array( |
1742
|
|
|
'{firstname}', |
1743
|
|
|
'{lastname}', |
1744
|
|
|
'{company}', |
1745
|
|
|
'{address_1}', |
1746
|
|
|
'{address_2}', |
1747
|
|
|
'{city}', |
1748
|
|
|
'{postcode}', |
1749
|
|
|
'{zone}', |
1750
|
|
|
'{zone_code}', |
1751
|
|
|
'{country}' |
1752
|
|
|
); |
1753
|
|
|
|
1754
|
|
|
$replace = array( |
1755
|
|
|
'firstname' => $order_info['shipping_firstname'], |
1756
|
|
|
'lastname' => $order_info['shipping_lastname'], |
1757
|
|
|
'company' => $order_info['shipping_company'], |
1758
|
|
|
'address_1' => $order_info['shipping_address_1'], |
1759
|
|
|
'address_2' => $order_info['shipping_address_2'], |
1760
|
|
|
'city' => $order_info['shipping_city'], |
1761
|
|
|
'postcode' => $order_info['shipping_postcode'], |
1762
|
|
|
'zone' => $order_info['shipping_zone'], |
1763
|
|
|
'zone_code' => $order_info['shipping_zone_code'], |
1764
|
|
|
'country' => $order_info['shipping_country'] |
1765
|
|
|
); |
1766
|
|
|
|
1767
|
|
|
$shipping_address = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format)))); |
|
|
|
|
1768
|
|
|
|
1769
|
|
|
$this->load->model('tool/upload'); |
1770
|
|
|
|
1771
|
|
|
$product_data = array(); |
1772
|
|
|
|
1773
|
|
|
$products = $this->model_sale_order->getOrderProducts($order_id); |
1774
|
|
|
|
1775
|
|
|
foreach ($products as $product) { |
1776
|
|
|
$product_info = $this->model_catalog_product->getProduct($product['product_id']); |
1777
|
|
|
|
1778
|
|
|
if ($product_info) { |
1779
|
|
|
$option_data = array(); |
1780
|
|
|
|
1781
|
|
|
$options = $this->model_sale_order->getOrderOptions($order_id, $product['order_product_id']); |
1782
|
|
|
|
1783
|
|
|
foreach ($options as $option) { |
1784
|
|
|
if ($option['type'] != 'file') { |
1785
|
|
|
$value = $option['value']; |
1786
|
|
|
} else { |
1787
|
|
|
$upload_info = $this->model_tool_upload->getUploadByCode($option['value']); |
1788
|
|
|
|
1789
|
|
|
if ($upload_info) { |
1790
|
|
|
$value = $upload_info['name']; |
1791
|
|
|
} else { |
1792
|
|
|
$value = ''; |
1793
|
|
|
} |
1794
|
|
|
} |
1795
|
|
|
|
1796
|
|
|
$option_data[] = array( |
1797
|
|
|
'name' => $option['name'], |
1798
|
|
|
'value' => $value |
1799
|
|
|
); |
1800
|
|
|
|
1801
|
|
|
$product_option_value_info = $this->model_catalog_product->getProductOptionValue($product['product_id'], $option['product_option_value_id']); |
|
|
|
|
1802
|
|
|
} |
1803
|
|
|
|
1804
|
|
|
$product_data[] = array( |
1805
|
|
|
'name' => $product_info['name'], |
1806
|
|
|
'model' => $product_info['model'], |
1807
|
|
|
'option' => $option_data, |
1808
|
|
|
'quantity' => $product['quantity'], |
1809
|
|
|
'location' => $product_info['location'], |
1810
|
|
|
'sku' => $product_info['sku'], |
1811
|
|
|
'upc' => $product_info['upc'], |
1812
|
|
|
'ean' => $product_info['ean'], |
1813
|
|
|
'jan' => $product_info['jan'], |
1814
|
|
|
'isbn' => $product_info['isbn'], |
1815
|
|
|
'mpn' => $product_info['mpn'] |
1816
|
|
|
); |
1817
|
|
|
} |
1818
|
|
|
} |
1819
|
|
|
|
1820
|
|
|
$data['orders'][] = array( |
1821
|
|
|
'order_id' => $order_id, |
1822
|
|
|
'invoice_no' => $invoice_no, |
1823
|
|
|
'date_added' => date($this->language->get('date_format_short'), strtotime($order_info['date_added'])), |
1824
|
|
|
'store_name' => $order_info['store_name'], |
1825
|
|
|
'store_url' => rtrim($order_info['store_url'], '/'), |
1826
|
|
|
'store_address' => nl2br($store_address), |
1827
|
|
|
'store_email' => $store_email, |
1828
|
|
|
'store_telephone' => $store_telephone, |
1829
|
|
|
'store_fax' => $store_fax, |
1830
|
|
|
'email' => $order_info['email'], |
1831
|
|
|
'telephone' => $order_info['telephone'], |
1832
|
|
|
'shipping_address' => $shipping_address, |
1833
|
|
|
'shipping_method' => $order_info['shipping_method'], |
1834
|
|
|
'product' => $product_data, |
1835
|
|
|
'comment' => nl2br($order_info['comment']) |
1836
|
|
|
); |
1837
|
|
|
} |
1838
|
|
|
} |
1839
|
|
|
|
1840
|
|
|
$this->response->setOutput($this->load->view('sale/order_shipping', $data)); |
1841
|
|
|
} |
1842
|
|
|
} |
1843
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.