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 ControllerMarketingMarketing extends \Divine\Engine\Core\Controller |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
private $error = array(); |
26
|
|
|
|
27
|
|
|
public function index() |
|
|
|
|
28
|
|
|
{ |
29
|
|
|
$this->load->language('marketing/marketing'); |
30
|
|
|
|
31
|
|
|
$this->document->setTitle($this->language->get('heading_title')); |
32
|
|
|
|
33
|
|
|
$this->load->model('marketing/marketing'); |
34
|
|
|
|
35
|
|
|
$this->getList(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function add() |
39
|
|
|
{ |
40
|
|
|
$this->load->language('marketing/marketing'); |
41
|
|
|
|
42
|
|
|
$this->document->setTitle($this->language->get('heading_title')); |
43
|
|
|
|
44
|
|
|
$this->load->model('marketing/marketing'); |
45
|
|
|
|
46
|
|
|
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) { |
47
|
|
|
$this->model_marketing_marketing->addMarketing($this->request->post); |
48
|
|
|
|
49
|
|
|
$this->session->data['success'] = $this->language->get('text_success'); |
50
|
|
|
|
51
|
|
|
$url = ''; |
52
|
|
|
|
53
|
|
|
if (isset($this->request->get['filter_name'])) { |
54
|
|
|
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
if (isset($this->request->get['filter_code'])) { |
58
|
|
|
$url .= '&filter_code=' . $this->request->get['filter_code']; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
62
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
if (isset($this->request->get['sort'])) { |
66
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
if (isset($this->request->get['order'])) { |
70
|
|
|
$url .= '&order=' . $this->request->get['order']; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
if (isset($this->request->get['page'])) { |
74
|
|
|
$url .= '&page=' . $this->request->get['page']; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
$this->response->redirect($this->url->link('marketing/marketing', 'token=' . $this->session->data['token'] . $url, true)); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
$this->getForm(); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function edit() |
84
|
|
|
{ |
85
|
|
|
$this->load->language('marketing/marketing'); |
86
|
|
|
|
87
|
|
|
$this->document->setTitle($this->language->get('heading_title')); |
88
|
|
|
|
89
|
|
|
$this->load->model('marketing/marketing'); |
90
|
|
|
|
91
|
|
|
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) { |
92
|
|
|
$this->model_marketing_marketing->editMarketing($this->request->get['marketing_id'], $this->request->post); |
93
|
|
|
|
94
|
|
|
$this->session->data['success'] = $this->language->get('text_success'); |
95
|
|
|
|
96
|
|
|
$url = ''; |
97
|
|
|
|
98
|
|
|
if (isset($this->request->get['filter_name'])) { |
99
|
|
|
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
if (isset($this->request->get['filter_code'])) { |
103
|
|
|
$url .= '&filter_code=' . $this->request->get['filter_code']; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
107
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
if (isset($this->request->get['sort'])) { |
111
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
if (isset($this->request->get['order'])) { |
115
|
|
|
$url .= '&order=' . $this->request->get['order']; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
if (isset($this->request->get['page'])) { |
119
|
|
|
$url .= '&page=' . $this->request->get['page']; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
$this->response->redirect($this->url->link('marketing/marketing', 'token=' . $this->session->data['token'] . $url, true)); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
$this->getForm(); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
public function delete() |
129
|
|
|
{ |
130
|
|
|
$this->load->language('marketing/marketing'); |
131
|
|
|
|
132
|
|
|
$this->document->setTitle($this->language->get('heading_title')); |
133
|
|
|
|
134
|
|
|
$this->load->model('marketing/marketing'); |
135
|
|
|
|
136
|
|
|
if (isset($this->request->post['selected']) && $this->validateDelete()) { |
137
|
|
|
foreach ($this->request->post['selected'] as $marketing_id) { |
138
|
|
|
$this->model_marketing_marketing->deleteMarketing($marketing_id); |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
$this->session->data['success'] = $this->language->get('text_success'); |
142
|
|
|
|
143
|
|
|
$url = ''; |
144
|
|
|
|
145
|
|
|
if (isset($this->request->get['filter_name'])) { |
146
|
|
|
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
if (isset($this->request->get['filter_code'])) { |
150
|
|
|
$url .= '&filter_code=' . $this->request->get['filter_code']; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
154
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
if (isset($this->request->get['sort'])) { |
158
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
if (isset($this->request->get['order'])) { |
162
|
|
|
$url .= '&order=' . $this->request->get['order']; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
if (isset($this->request->get['page'])) { |
166
|
|
|
$url .= '&page=' . $this->request->get['page']; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
$this->response->redirect($this->url->link('marketing/marketing', 'token=' . $this->session->data['token'] . $url, true)); |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
$this->getList(); |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
protected function getList() |
176
|
|
|
{ |
177
|
|
|
if (isset($this->request->get['filter_name'])) { |
178
|
|
|
$filter_name = $this->request->get['filter_name']; |
179
|
|
|
} else { |
180
|
|
|
$filter_name = null; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
if (isset($this->request->get['filter_code'])) { |
184
|
|
|
$filter_code = $this->request->get['filter_code']; |
185
|
|
|
} else { |
186
|
|
|
$filter_code = null; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
190
|
|
|
$filter_date_added = $this->request->get['filter_date_added']; |
191
|
|
|
} else { |
192
|
|
|
$filter_date_added = null; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
if (isset($this->request->get['sort'])) { |
196
|
|
|
$sort = $this->request->get['sort']; |
197
|
|
|
} else { |
198
|
|
|
$sort = 'name'; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
if (isset($this->request->get['order'])) { |
202
|
|
|
$order = $this->request->get['order']; |
203
|
|
|
} else { |
204
|
|
|
$order = 'ASC'; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
if (isset($this->request->get['page'])) { |
208
|
|
|
$page = $this->request->get['page']; |
209
|
|
|
} else { |
210
|
|
|
$page = 1; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
$url = ''; |
214
|
|
|
|
215
|
|
|
if (isset($this->request->get['filter_name'])) { |
216
|
|
|
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
if (isset($this->request->get['filter_code'])) { |
220
|
|
|
$url .= '&filter_code=' . $this->request->get['filter_code']; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
224
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
if (isset($this->request->get['sort'])) { |
228
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
if (isset($this->request->get['sort'])) { |
232
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
if (isset($this->request->get['order'])) { |
236
|
|
|
$url .= '&order=' . $this->request->get['order']; |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
if (isset($this->request->get['page'])) { |
240
|
|
|
$url .= '&page=' . $this->request->get['page']; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
$data['breadcrumbs'] = array(); |
|
|
|
|
244
|
|
|
|
245
|
|
|
$data['breadcrumbs'][] = array( |
246
|
|
|
'text' => $this->language->get('text_home'), |
247
|
|
|
'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
248
|
|
|
); |
249
|
|
|
|
250
|
|
|
$data['breadcrumbs'][] = array( |
251
|
|
|
'text' => $this->language->get('heading_title'), |
252
|
|
|
'href' => $this->url->link('marketing/marketing', 'token=' . $this->session->data['token'] . $url, true) |
253
|
|
|
); |
254
|
|
|
|
255
|
|
|
$data['add'] = $this->url->link('marketing/marketing/add', 'token=' . $this->session->data['token'] . $url, true); |
256
|
|
|
$data['delete'] = $this->url->link('marketing/marketing/delete', 'token=' . $this->session->data['token'] . $url, true); |
257
|
|
|
|
258
|
|
|
$data['marketings'] = array(); |
259
|
|
|
|
260
|
|
|
$filter_data = array( |
261
|
|
|
'filter_name' => $filter_name, |
262
|
|
|
'filter_code' => $filter_code, |
263
|
|
|
'filter_date_added' => $filter_date_added, |
264
|
|
|
'sort' => $sort, |
265
|
|
|
'order' => $order, |
266
|
|
|
'start' => ($page - 1) * $this->config->get('config_limit_admin'), |
267
|
|
|
'limit' => $this->config->get('config_limit_admin') |
268
|
|
|
); |
269
|
|
|
|
270
|
|
|
$marketing_total = $this->model_marketing_marketing->getTotalMarketings($filter_data); |
271
|
|
|
|
272
|
|
|
$results = $this->model_marketing_marketing->getMarketings($filter_data); |
273
|
|
|
|
274
|
|
|
foreach ($results as $result) { |
275
|
|
|
$data['marketings'][] = array( |
276
|
|
|
'marketing_id' => $result['marketing_id'], |
277
|
|
|
'name' => $result['name'], |
278
|
|
|
'code' => $result['code'], |
279
|
|
|
'clicks' => $result['clicks'], |
280
|
|
|
'orders' => $result['orders'], |
281
|
|
|
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])), |
282
|
|
|
'edit' => $this->url->link('marketing/marketing/edit', 'token=' . $this->session->data['token'] . '&marketing_id=' . $result['marketing_id'] . $url, true) |
283
|
|
|
); |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
$data['heading_title'] = $this->language->get('heading_title'); |
287
|
|
|
|
288
|
|
|
$data['text_list'] = $this->language->get('text_list'); |
289
|
|
|
$data['text_no_results'] = $this->language->get('text_no_results'); |
290
|
|
|
$data['text_confirm'] = $this->language->get('text_confirm'); |
291
|
|
|
|
292
|
|
|
$data['column_name'] = $this->language->get('column_name'); |
293
|
|
|
$data['column_code'] = $this->language->get('column_code'); |
294
|
|
|
$data['column_clicks'] = $this->language->get('column_clicks'); |
295
|
|
|
$data['column_orders'] = $this->language->get('column_orders'); |
296
|
|
|
$data['column_date_added'] = $this->language->get('column_date_added'); |
297
|
|
|
$data['column_action'] = $this->language->get('column_action'); |
298
|
|
|
|
299
|
|
|
$data['entry_name'] = $this->language->get('entry_name'); |
300
|
|
|
$data['entry_code'] = $this->language->get('entry_code'); |
301
|
|
|
$data['entry_date_added'] = $this->language->get('entry_date_added'); |
302
|
|
|
|
303
|
|
|
$data['button_add'] = $this->language->get('button_add'); |
304
|
|
|
$data['button_edit'] = $this->language->get('button_edit'); |
305
|
|
|
$data['button_delete'] = $this->language->get('button_delete'); |
306
|
|
|
$data['button_filter'] = $this->language->get('button_filter'); |
307
|
|
|
|
308
|
|
|
$data['token'] = $this->session->data['token']; |
309
|
|
|
|
310
|
|
|
if (isset($this->error['warning'])) { |
311
|
|
|
$data['error_warning'] = $this->error['warning']; |
312
|
|
|
} else { |
313
|
|
|
$data['error_warning'] = ''; |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
if (isset($this->session->data['success'])) { |
317
|
|
|
$data['success'] = $this->session->data['success']; |
318
|
|
|
|
319
|
|
|
unset($this->session->data['success']); |
320
|
|
|
} else { |
321
|
|
|
$data['success'] = ''; |
322
|
|
|
} |
323
|
|
|
|
324
|
|
|
if (isset($this->request->post['selected'])) { |
325
|
|
|
$data['selected'] = (array)$this->request->post['selected']; |
326
|
|
|
} else { |
327
|
|
|
$data['selected'] = array(); |
328
|
|
|
} |
329
|
|
|
|
330
|
|
|
$url = ''; |
331
|
|
|
|
332
|
|
|
if (isset($this->request->get['filter_name'])) { |
333
|
|
|
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
if (isset($this->request->get['filter_code'])) { |
337
|
|
|
$url .= '&filter_code=' . $this->request->get['filter_code']; |
338
|
|
|
} |
339
|
|
|
|
340
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
341
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
342
|
|
|
} |
343
|
|
|
|
344
|
|
|
if ($order == 'ASC') { |
345
|
|
|
$url .= '&order=DESC'; |
346
|
|
|
} else { |
347
|
|
|
$url .= '&order=ASC'; |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
if (isset($this->request->get['page'])) { |
351
|
|
|
$url .= '&page=' . $this->request->get['page']; |
352
|
|
|
} |
353
|
|
|
|
354
|
|
|
$data['sort_name'] = $this->url->link('marketing/marketing', 'token=' . $this->session->data['token'] . '&sort=m.name' . $url, true); |
355
|
|
|
$data['sort_code'] = $this->url->link('marketing/marketing', 'token=' . $this->session->data['token'] . '&sort=m.code' . $url, true); |
356
|
|
|
$data['sort_date_added'] = $this->url->link('marketing/marketing', 'token=' . $this->session->data['token'] . '&sort=m.date_added' . $url, true); |
357
|
|
|
|
358
|
|
|
$url = ''; |
359
|
|
|
|
360
|
|
|
if (isset($this->request->get['filter_name'])) { |
361
|
|
|
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
if (isset($this->request->get['filter_code'])) { |
365
|
|
|
$url .= '&filter_code=' . $this->request->get['filter_code']; |
366
|
|
|
} |
367
|
|
|
|
368
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
369
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
if (isset($this->request->get['sort'])) { |
373
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
if (isset($this->request->get['order'])) { |
377
|
|
|
$url .= '&order=' . $this->request->get['order']; |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
$pagination = new \Divine\Engine\Library\Pagination(); |
381
|
|
|
$pagination->total = $marketing_total; |
382
|
|
|
$pagination->page = $page; |
383
|
|
|
$pagination->limit = $this->config->get('config_limit_admin'); |
384
|
|
|
$pagination->url = $this->url->link('marketing/marketing', 'token=' . $this->session->data['token'] . $url . '&page={page}', true); |
385
|
|
|
|
386
|
|
|
$data['pagination'] = $pagination->render(); |
387
|
|
|
|
388
|
|
|
$data['results'] = sprintf($this->language->get('text_pagination'), ($marketing_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($marketing_total - $this->config->get('config_limit_admin'))) ? $marketing_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $marketing_total, ceil($marketing_total / $this->config->get('config_limit_admin'))); |
389
|
|
|
|
390
|
|
|
$data['filter_name'] = $filter_name; |
391
|
|
|
$data['filter_code'] = $filter_code; |
392
|
|
|
$data['filter_date_added'] = $filter_date_added; |
393
|
|
|
|
394
|
|
|
$data['sort'] = $sort; |
395
|
|
|
$data['order'] = $order; |
396
|
|
|
|
397
|
|
|
$data['header'] = $this->load->controller('common/header'); |
398
|
|
|
$data['column'] = $this->load->controller('common/column_left'); |
399
|
|
|
$data['footer'] = $this->load->controller('common/footer'); |
400
|
|
|
|
401
|
|
|
$this->response->setOutput($this->load->view('marketing/marketing_list', $data)); |
402
|
|
|
} |
403
|
|
|
|
404
|
|
|
protected function getForm() |
405
|
|
|
{ |
406
|
|
|
$data['heading_title'] = $this->language->get('heading_title'); |
|
|
|
|
407
|
|
|
|
408
|
|
|
$data['text_form'] = !isset($this->request->get['marketing_id']) ? $this->language->get('text_add') : $this->language->get('text_edit'); |
409
|
|
|
|
410
|
|
|
$data['entry_name'] = $this->language->get('entry_name'); |
411
|
|
|
$data['entry_description'] = $this->language->get('entry_description'); |
412
|
|
|
$data['entry_code'] = $this->language->get('entry_code'); |
413
|
|
|
$data['entry_example'] = $this->language->get('entry_example'); |
414
|
|
|
|
415
|
|
|
$data['help_code'] = $this->language->get('help_code'); |
416
|
|
|
$data['help_example'] = $this->language->get('help_example'); |
417
|
|
|
|
418
|
|
|
$data['button_save'] = $this->language->get('button_save'); |
419
|
|
|
$data['button_cancel'] = $this->language->get('button_cancel'); |
420
|
|
|
|
421
|
|
|
if (isset($this->error['warning'])) { |
422
|
|
|
$data['error_warning'] = $this->error['warning']; |
423
|
|
|
} else { |
424
|
|
|
$data['error_warning'] = ''; |
425
|
|
|
} |
426
|
|
|
|
427
|
|
|
if (isset($this->error['name'])) { |
428
|
|
|
$data['error_name'] = $this->error['name']; |
429
|
|
|
} else { |
430
|
|
|
$data['error_name'] = ''; |
431
|
|
|
} |
432
|
|
|
|
433
|
|
|
if (isset($this->error['code'])) { |
434
|
|
|
$data['error_code'] = $this->error['code']; |
435
|
|
|
} else { |
436
|
|
|
$data['error_code'] = ''; |
437
|
|
|
} |
438
|
|
|
|
439
|
|
|
$url = ''; |
440
|
|
|
|
441
|
|
|
if (isset($this->request->get['filter_name'])) { |
442
|
|
|
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
443
|
|
|
} |
444
|
|
|
|
445
|
|
|
if (isset($this->request->get['filter_code'])) { |
446
|
|
|
$url .= '&filter_code=' . $this->request->get['filter_code']; |
447
|
|
|
} |
448
|
|
|
|
449
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
450
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
if (isset($this->request->get['sort'])) { |
454
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
455
|
|
|
} |
456
|
|
|
|
457
|
|
|
if (isset($this->request->get['order'])) { |
458
|
|
|
$url .= '&order=' . $this->request->get['order']; |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
if (isset($this->request->get['page'])) { |
462
|
|
|
$url .= '&page=' . $this->request->get['page']; |
463
|
|
|
} |
464
|
|
|
|
465
|
|
|
$data['breadcrumbs'] = array(); |
466
|
|
|
|
467
|
|
|
$data['breadcrumbs'][] = array( |
468
|
|
|
'text' => $this->language->get('text_home'), |
469
|
|
|
'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
470
|
|
|
); |
471
|
|
|
|
472
|
|
|
$data['breadcrumbs'][] = array( |
473
|
|
|
'text' => $this->language->get('heading_title'), |
474
|
|
|
'href' => $this->url->link('marketing/marketing', 'token=' . $this->session->data['token'] . $url, true) |
475
|
|
|
); |
476
|
|
|
|
477
|
|
|
if (!isset($this->request->get['marketing_id'])) { |
478
|
|
|
$data['action'] = $this->url->link('marketing/marketing/add', 'token=' . $this->session->data['token'] . $url, true); |
479
|
|
|
} else { |
480
|
|
|
$data['action'] = $this->url->link('marketing/marketing/edit', 'token=' . $this->session->data['token'] . '&marketing_id=' . $this->request->get['marketing_id'] . $url, true); |
481
|
|
|
} |
482
|
|
|
|
483
|
|
|
$data['cancel'] = $this->url->link('marketing/marketing', 'token=' . $this->session->data['token'] . $url, true); |
484
|
|
|
|
485
|
|
|
if (isset($this->request->get['marketing_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) { |
486
|
|
|
$marketing_info = $this->model_marketing_marketing->getMarketing($this->request->get['marketing_id']); |
487
|
|
|
} |
488
|
|
|
|
489
|
|
|
$data['token'] = $this->session->data['token']; |
490
|
|
|
|
491
|
|
|
$data['store'] = '/'; |
492
|
|
|
|
493
|
|
|
if (isset($this->request->post['name'])) { |
494
|
|
|
$data['name'] = $this->request->post['name']; |
495
|
|
|
} elseif (!empty($marketing_info)) { |
496
|
|
|
$data['name'] = $marketing_info['name']; |
497
|
|
|
} else { |
498
|
|
|
$data['name'] = ''; |
499
|
|
|
} |
500
|
|
|
|
501
|
|
|
if (isset($this->request->post['description'])) { |
502
|
|
|
$data['description'] = $this->request->post['description']; |
503
|
|
|
} elseif (!empty($marketing_info)) { |
504
|
|
|
$data['description'] = $marketing_info['description']; |
505
|
|
|
} else { |
506
|
|
|
$data['description'] = ''; |
507
|
|
|
} |
508
|
|
|
|
509
|
|
|
if (isset($this->request->post['code'])) { |
510
|
|
|
$data['code'] = $this->request->post['code']; |
511
|
|
|
} elseif (!empty($marketing_info)) { |
512
|
|
|
$data['code'] = $marketing_info['code']; |
513
|
|
|
} else { |
514
|
|
|
$data['code'] = uniqid(); |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
$data['header'] = $this->load->controller('common/header'); |
518
|
|
|
$data['column'] = $this->load->controller('common/column_left'); |
519
|
|
|
$data['footer'] = $this->load->controller('common/footer'); |
520
|
|
|
|
521
|
|
|
$this->response->setOutput($this->load->view('marketing/marketing_form', $data)); |
522
|
|
|
} |
523
|
|
|
|
524
|
|
|
protected function validateForm() |
525
|
|
|
{ |
526
|
|
|
if (!$this->user->hasPermission('modify', 'marketing/marketing')) { |
527
|
|
|
$this->error['warning'] = $this->language->get('error_permission'); |
528
|
|
|
} |
529
|
|
|
|
530
|
|
|
if ((\voku\helper\UTF8::strlen($this->request->post['name']) < 1) || (\voku\helper\UTF8::strlen($this->request->post['name']) > 32)) { |
531
|
|
|
$this->error['name'] = $this->language->get('error_name'); |
532
|
|
|
} |
533
|
|
|
|
534
|
|
|
if (!$this->request->post['code']) { |
535
|
|
|
$this->error['code'] = $this->language->get('error_code'); |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
$marketing_info = $this->model_marketing_marketing->getMarketingByCode($this->request->post['code']); |
539
|
|
|
|
540
|
|
|
if (!isset($this->request->get['marketing_id'])) { |
541
|
|
|
if ($marketing_info) { |
542
|
|
|
$this->error['code'] = $this->language->get('error_exists'); |
543
|
|
|
} |
544
|
|
|
} else { |
545
|
|
|
if ($marketing_info && ($this->request->get['marketing_id'] != $marketing_info['marketing_id'])) { |
546
|
|
|
$this->error['code'] = $this->language->get('error_exists'); |
547
|
|
|
} |
548
|
|
|
} |
549
|
|
|
|
550
|
|
|
return !$this->error; |
551
|
|
|
} |
552
|
|
|
|
553
|
|
|
protected function validateDelete() |
554
|
|
|
{ |
555
|
|
|
if (!$this->user->hasPermission('modify', 'marketing/marketing')) { |
556
|
|
|
$this->error['warning'] = $this->language->get('error_permission'); |
557
|
|
|
} |
558
|
|
|
|
559
|
|
|
return !$this->error; |
560
|
|
|
} |
561
|
|
|
} |
562
|
|
|
|
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.