first commit
This commit is contained in:
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
class ControllerMarketingContact extends Controller {
|
||||
private $error = array();
|
||||
|
||||
public function index() {
|
||||
$this->load->language('marketing/contact');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['breadcrumbs'] = array();
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
|
||||
);
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('marketing/contact', 'user_token=' . $this->session->data['user_token'], true)
|
||||
);
|
||||
|
||||
$data['cancel'] = $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true);
|
||||
|
||||
$this->load->model('setting/store');
|
||||
|
||||
$data['stores'] = $this->model_setting_store->getStores();
|
||||
|
||||
$this->load->model('customer/customer_group');
|
||||
|
||||
$data['customer_groups'] = $this->model_customer_customer_group->getCustomerGroups();
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('marketing/contact', $data));
|
||||
}
|
||||
|
||||
public function send() {
|
||||
$this->load->language('marketing/contact');
|
||||
|
||||
$json = array();
|
||||
|
||||
if ($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
if (!$this->user->hasPermission('modify', 'marketing/contact')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$this->request->post['subject']) {
|
||||
$json['error']['subject'] = $this->language->get('error_subject');
|
||||
}
|
||||
|
||||
if (!$this->request->post['message']) {
|
||||
$json['error']['message'] = $this->language->get('error_message');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/store');
|
||||
$this->load->model('setting/setting');
|
||||
$this->load->model('customer/customer');
|
||||
$this->load->model('sale/order');
|
||||
|
||||
$store_info = $this->model_setting_store->getStore($this->request->post['store_id']);
|
||||
|
||||
if ($store_info) {
|
||||
$store_name = $store_info['name'];
|
||||
} else {
|
||||
$store_name = $this->config->get('config_name');
|
||||
}
|
||||
|
||||
$setting = $this->model_setting_setting->getSetting('config', $this->request->post['store_id']);
|
||||
|
||||
$store_email = isset($setting['config_email']) ? $setting['config_email'] : $this->config->get('config_email');
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$email_total = 0;
|
||||
|
||||
$emails = array();
|
||||
|
||||
switch ($this->request->post['to']) {
|
||||
case 'newsletter':
|
||||
$customer_data = array(
|
||||
'filter_newsletter' => 1,
|
||||
'start' => ($page - 1) * 10,
|
||||
'limit' => 10
|
||||
);
|
||||
|
||||
$email_total = $this->model_customer_customer->getTotalCustomers($customer_data);
|
||||
|
||||
$results = $this->model_customer_customer->getCustomers($customer_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$emails[] = $result['email'];
|
||||
}
|
||||
break;
|
||||
case 'customer_all':
|
||||
$customer_data = array(
|
||||
'start' => ($page - 1) * 10,
|
||||
'limit' => 10
|
||||
);
|
||||
|
||||
$email_total = $this->model_customer_customer->getTotalCustomers($customer_data);
|
||||
|
||||
$results = $this->model_customer_customer->getCustomers($customer_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$emails[] = $result['email'];
|
||||
}
|
||||
break;
|
||||
case 'customer_group':
|
||||
$customer_data = array(
|
||||
'filter_customer_group_id' => $this->request->post['customer_group_id'],
|
||||
'start' => ($page - 1) * 10,
|
||||
'limit' => 10
|
||||
);
|
||||
|
||||
$email_total = $this->model_customer_customer->getTotalCustomers($customer_data);
|
||||
|
||||
$results = $this->model_customer_customer->getCustomers($customer_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$emails[$result['customer_id']] = $result['email'];
|
||||
}
|
||||
break;
|
||||
case 'customer':
|
||||
if (!empty($this->request->post['customer'])) {
|
||||
$customers = array_slice($this->request->post['customer'], ($page - 1) * 10, 10);
|
||||
|
||||
foreach ($customers as $customer_id) {
|
||||
$customer_info = $this->model_customer_customer->getCustomer($customer_id);
|
||||
|
||||
if ($customer_info) {
|
||||
$emails[] = $customer_info['email'];
|
||||
}
|
||||
}
|
||||
|
||||
$email_total = count($emails);
|
||||
}
|
||||
break;
|
||||
case 'affiliate_all':
|
||||
$affiliate_data = array(
|
||||
'filter_affiliate' => 1,
|
||||
'start' => ($page - 1) * 10,
|
||||
'limit' => 10
|
||||
);
|
||||
|
||||
$email_total = $this->model_customer_customer->getTotalCustomers($affiliate_data);
|
||||
|
||||
$results = $this->model_customer_customer->getCustomers($affiliate_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$emails[] = $result['email'];
|
||||
}
|
||||
break;
|
||||
case 'affiliate':
|
||||
if (!empty($this->request->post['affiliate'])) {
|
||||
$affiliates = array_slice($this->request->post['affiliate'], ($page - 1) * 10, 10);
|
||||
|
||||
foreach ($affiliates as $affiliate_id) {
|
||||
$affiliate_info = $this->model_customer_customer->getCustomer($affiliate_id);
|
||||
|
||||
if ($affiliate_info) {
|
||||
$emails[] = $affiliate_info['email'];
|
||||
}
|
||||
}
|
||||
|
||||
$email_total = count($this->request->post['affiliate']);
|
||||
}
|
||||
break;
|
||||
case 'product':
|
||||
if (isset($this->request->post['product'])) {
|
||||
$email_total = $this->model_sale_order->getTotalEmailsByProductsOrdered($this->request->post['product']);
|
||||
|
||||
$results = $this->model_sale_order->getEmailsByProductsOrdered($this->request->post['product'], ($page - 1) * 10, 10);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$emails[] = $result['email'];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ($emails) {
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
|
||||
$start = ($page - 1) * 10;
|
||||
$end = $start + 10;
|
||||
|
||||
if($page == 1 && $email_total < 10) {
|
||||
$json['success'] = sprintf($this->language->get('text_sent'), $email_total, $email_total);
|
||||
} else if($page == 1 && $email_total > 10) {
|
||||
$json['success'] = sprintf($this->language->get('text_sent'), 10, $email_total);
|
||||
} else if($page > 1 && $email_total < ($page * 10)) {
|
||||
$json['success'] = sprintf($this->language->get('text_sent'), $email_total, $email_total);
|
||||
} else {
|
||||
$json['success'] = sprintf($this->language->get('text_sent'), ($start * $page), $email_total);
|
||||
}
|
||||
|
||||
if ($end < $email_total) {
|
||||
$json['next'] = str_replace('&', '&', $this->url->link('marketing/contact/send', 'user_token=' . $this->session->data['user_token'] . '&page=' . ($page + 1), true));
|
||||
} else {
|
||||
$json['next'] = '';
|
||||
}
|
||||
|
||||
$message = '<html dir="ltr" lang="' . $this->language->get('code') . '">' . "\n";
|
||||
$message .= ' <head>' . "\n";
|
||||
$message .= ' <title>' . $this->request->post['subject'] . '</title>' . "\n";
|
||||
$message .= ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . "\n";
|
||||
$message .= ' </head>' . "\n";
|
||||
$message .= ' <body>' . html_entity_decode($this->request->post['message'], ENT_QUOTES, 'UTF-8') . '</body>' . "\n";
|
||||
$message .= '</html>' . "\n";
|
||||
|
||||
foreach ($emails as $email) {
|
||||
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$mail = new Mail($this->config->get('config_mail_engine'));
|
||||
$mail->parameter = $this->config->get('config_mail_parameter');
|
||||
$mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
|
||||
$mail->smtp_username = $this->config->get('config_mail_smtp_username');
|
||||
$mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
|
||||
$mail->smtp_port = $this->config->get('config_mail_smtp_port');
|
||||
$mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');
|
||||
|
||||
$mail->setTo($email);
|
||||
$mail->setFrom($store_email);
|
||||
$mail->setSender(html_entity_decode($store_name, ENT_QUOTES, 'UTF-8'));
|
||||
$mail->setSubject(html_entity_decode($this->request->post['subject'], ENT_QUOTES, 'UTF-8'));
|
||||
$mail->setHtml($message);
|
||||
$mail->send();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$json['error']['email'] = $this->language->get('error_email');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,556 @@
|
||||
<?php
|
||||
class ControllerMarketingCoupon extends Controller {
|
||||
private $error = array();
|
||||
|
||||
public function index() {
|
||||
$this->load->language('marketing/coupon');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$this->load->model('marketing/coupon');
|
||||
|
||||
$this->getList();
|
||||
}
|
||||
|
||||
public function add() {
|
||||
$this->load->language('marketing/coupon');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$this->load->model('marketing/coupon');
|
||||
|
||||
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
|
||||
$this->model_marketing_coupon->addCoupon($this->request->post);
|
||||
|
||||
$this->session->data['success'] = $this->language->get('text_success');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$this->response->redirect($this->url->link('marketing/coupon', 'user_token=' . $this->session->data['user_token'] . $url, true));
|
||||
}
|
||||
|
||||
$this->getForm();
|
||||
}
|
||||
|
||||
public function edit() {
|
||||
$this->load->language('marketing/coupon');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$this->load->model('marketing/coupon');
|
||||
|
||||
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
|
||||
$this->model_marketing_coupon->editCoupon($this->request->get['coupon_id'], $this->request->post);
|
||||
|
||||
$this->session->data['success'] = $this->language->get('text_success');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$this->response->redirect($this->url->link('marketing/coupon', 'user_token=' . $this->session->data['user_token'] . $url, true));
|
||||
}
|
||||
|
||||
$this->getForm();
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
$this->load->language('marketing/coupon');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$this->load->model('marketing/coupon');
|
||||
|
||||
if (isset($this->request->post['selected']) && $this->validateDelete()) {
|
||||
foreach ($this->request->post['selected'] as $coupon_id) {
|
||||
$this->model_marketing_coupon->deleteCoupon($coupon_id);
|
||||
}
|
||||
|
||||
$this->session->data['success'] = $this->language->get('text_success');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$this->response->redirect($this->url->link('marketing/coupon', 'user_token=' . $this->session->data['user_token'] . $url, true));
|
||||
}
|
||||
|
||||
$this->getList();
|
||||
}
|
||||
|
||||
protected function getList() {
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = $this->request->get['sort'];
|
||||
} else {
|
||||
$sort = 'name';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = $this->request->get['order'];
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = array();
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
|
||||
);
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('marketing/coupon', 'user_token=' . $this->session->data['user_token'] . $url, true)
|
||||
);
|
||||
|
||||
$data['add'] = $this->url->link('marketing/coupon/add', 'user_token=' . $this->session->data['user_token'] . $url, true);
|
||||
$data['delete'] = $this->url->link('marketing/coupon/delete', 'user_token=' . $this->session->data['user_token'] . $url, true);
|
||||
|
||||
$data['coupons'] = array();
|
||||
|
||||
$filter_data = array(
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $this->config->get('config_limit_admin'),
|
||||
'limit' => $this->config->get('config_limit_admin')
|
||||
);
|
||||
|
||||
$coupon_total = $this->model_marketing_coupon->getTotalCoupons();
|
||||
|
||||
$results = $this->model_marketing_coupon->getCoupons($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['coupons'][] = array(
|
||||
'coupon_id' => $result['coupon_id'],
|
||||
'name' => $result['name'],
|
||||
'code' => $result['code'],
|
||||
'discount' => $result['discount'],
|
||||
'date_start' => date($this->language->get('date_format_short'), strtotime($result['date_start'])),
|
||||
'date_end' => date($this->language->get('date_format_short'), strtotime($result['date_end'])),
|
||||
'status' => ($result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled')),
|
||||
'edit' => $this->url->link('marketing/coupon/edit', 'user_token=' . $this->session->data['user_token'] . '&coupon_id=' . $result['coupon_id'] . $url, true)
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($this->error['warning'])) {
|
||||
$data['error_warning'] = $this->error['warning'];
|
||||
} else {
|
||||
$data['error_warning'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->session->data['success'])) {
|
||||
$data['success'] = $this->session->data['success'];
|
||||
|
||||
unset($this->session->data['success']);
|
||||
} else {
|
||||
$data['success'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['selected'])) {
|
||||
$data['selected'] = (array)$this->request->post['selected'];
|
||||
} else {
|
||||
$data['selected'] = array();
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if ($order == 'ASC') {
|
||||
$url .= '&order=DESC';
|
||||
} else {
|
||||
$url .= '&order=ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['sort_name'] = $this->url->link('marketing/coupon', 'user_token=' . $this->session->data['user_token'] . '&sort=name' . $url, true);
|
||||
$data['sort_code'] = $this->url->link('marketing/coupon', 'user_token=' . $this->session->data['user_token'] . '&sort=code' . $url, true);
|
||||
$data['sort_discount'] = $this->url->link('marketing/coupon', 'user_token=' . $this->session->data['user_token'] . '&sort=discount' . $url, true);
|
||||
$data['sort_date_start'] = $this->url->link('marketing/coupon', 'user_token=' . $this->session->data['user_token'] . '&sort=date_start' . $url, true);
|
||||
$data['sort_date_end'] = $this->url->link('marketing/coupon', 'user_token=' . $this->session->data['user_token'] . '&sort=date_end' . $url, true);
|
||||
$data['sort_status'] = $this->url->link('marketing/coupon', 'user_token=' . $this->session->data['user_token'] . '&sort=status' . $url, true);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$pagination = new Pagination();
|
||||
$pagination->total = $coupon_total;
|
||||
$pagination->page = $page;
|
||||
$pagination->limit = $this->config->get('config_limit_admin');
|
||||
$pagination->url = $this->url->link('marketing/coupon', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}', true);
|
||||
|
||||
$data['pagination'] = $pagination->render();
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($coupon_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($coupon_total - $this->config->get('config_limit_admin'))) ? $coupon_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $coupon_total, ceil($coupon_total / $this->config->get('config_limit_admin')));
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('marketing/coupon_list', $data));
|
||||
}
|
||||
|
||||
protected function getForm() {
|
||||
$data['text_form'] = !isset($this->request->get['coupon_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
if (isset($this->request->get['coupon_id'])) {
|
||||
$data['coupon_id'] = (int)$this->request->get['coupon_id'];
|
||||
} else {
|
||||
$data['coupon_id'] = 0;
|
||||
}
|
||||
|
||||
if (isset($this->error['warning'])) {
|
||||
$data['error_warning'] = $this->error['warning'];
|
||||
} else {
|
||||
$data['error_warning'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->error['name'])) {
|
||||
$data['error_name'] = $this->error['name'];
|
||||
} else {
|
||||
$data['error_name'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->error['code'])) {
|
||||
$data['error_code'] = $this->error['code'];
|
||||
} else {
|
||||
$data['error_code'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->error['date_start'])) {
|
||||
$data['error_date_start'] = $this->error['date_start'];
|
||||
} else {
|
||||
$data['error_date_start'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->error['date_end'])) {
|
||||
$data['error_date_end'] = $this->error['date_end'];
|
||||
} else {
|
||||
$data['error_date_end'] = '';
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = array();
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
|
||||
);
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('marketing/coupon', 'user_token=' . $this->session->data['user_token'] . $url, true)
|
||||
);
|
||||
|
||||
if (!isset($this->request->get['coupon_id'])) {
|
||||
$data['action'] = $this->url->link('marketing/coupon/add', 'user_token=' . $this->session->data['user_token'] . $url, true);
|
||||
} else {
|
||||
$data['action'] = $this->url->link('marketing/coupon/edit', 'user_token=' . $this->session->data['user_token'] . '&coupon_id=' . $this->request->get['coupon_id'] . $url, true);
|
||||
}
|
||||
|
||||
$data['cancel'] = $this->url->link('marketing/coupon', 'user_token=' . $this->session->data['user_token'] . $url, true);
|
||||
|
||||
if (isset($this->request->get['coupon_id']) && (!$this->request->server['REQUEST_METHOD'] != 'POST')) {
|
||||
$coupon_info = $this->model_marketing_coupon->getCoupon($this->request->get['coupon_id']);
|
||||
}
|
||||
|
||||
if (isset($this->request->post['name'])) {
|
||||
$data['name'] = $this->request->post['name'];
|
||||
} elseif (!empty($coupon_info)) {
|
||||
$data['name'] = $coupon_info['name'];
|
||||
} else {
|
||||
$data['name'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['code'])) {
|
||||
$data['code'] = $this->request->post['code'];
|
||||
} elseif (!empty($coupon_info)) {
|
||||
$data['code'] = $coupon_info['code'];
|
||||
} else {
|
||||
$data['code'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['type'])) {
|
||||
$data['type'] = $this->request->post['type'];
|
||||
} elseif (!empty($coupon_info)) {
|
||||
$data['type'] = $coupon_info['type'];
|
||||
} else {
|
||||
$data['type'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['discount'])) {
|
||||
$data['discount'] = $this->request->post['discount'];
|
||||
} elseif (!empty($coupon_info)) {
|
||||
$data['discount'] = $coupon_info['discount'];
|
||||
} else {
|
||||
$data['discount'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['logged'])) {
|
||||
$data['logged'] = $this->request->post['logged'];
|
||||
} elseif (!empty($coupon_info)) {
|
||||
$data['logged'] = $coupon_info['logged'];
|
||||
} else {
|
||||
$data['logged'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['shipping'])) {
|
||||
$data['shipping'] = $this->request->post['shipping'];
|
||||
} elseif (!empty($coupon_info)) {
|
||||
$data['shipping'] = $coupon_info['shipping'];
|
||||
} else {
|
||||
$data['shipping'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['total'])) {
|
||||
$data['total'] = $this->request->post['total'];
|
||||
} elseif (!empty($coupon_info)) {
|
||||
$data['total'] = $coupon_info['total'];
|
||||
} else {
|
||||
$data['total'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['coupon_product'])) {
|
||||
$products = $this->request->post['coupon_product'];
|
||||
} elseif (isset($this->request->get['coupon_id'])) {
|
||||
$products = $this->model_marketing_coupon->getCouponProducts($this->request->get['coupon_id']);
|
||||
} else {
|
||||
$products = array();
|
||||
}
|
||||
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
$data['coupon_product'] = array();
|
||||
|
||||
foreach ($products as $product_id) {
|
||||
$product_info = $this->model_catalog_product->getProduct($product_id);
|
||||
|
||||
if ($product_info) {
|
||||
$data['coupon_product'][] = array(
|
||||
'product_id' => $product_info['product_id'],
|
||||
'name' => $product_info['name']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->request->post['coupon_category'])) {
|
||||
$categories = $this->request->post['coupon_category'];
|
||||
} elseif (isset($this->request->get['coupon_id'])) {
|
||||
$categories = $this->model_marketing_coupon->getCouponCategories($this->request->get['coupon_id']);
|
||||
} else {
|
||||
$categories = array();
|
||||
}
|
||||
|
||||
$this->load->model('catalog/category');
|
||||
|
||||
$data['coupon_category'] = array();
|
||||
|
||||
foreach ($categories as $category_id) {
|
||||
$category_info = $this->model_catalog_category->getCategory($category_id);
|
||||
|
||||
if ($category_info) {
|
||||
$data['coupon_category'][] = array(
|
||||
'category_id' => $category_info['category_id'],
|
||||
'name' => ($category_info['path'] ? $category_info['path'] . ' > ' : '') . $category_info['name']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->request->post['date_start'])) {
|
||||
$data['date_start'] = $this->request->post['date_start'];
|
||||
} elseif (!empty($coupon_info)) {
|
||||
$data['date_start'] = ($coupon_info['date_start'] != '0000-00-00' ? $coupon_info['date_start'] : '');
|
||||
} else {
|
||||
$data['date_start'] = date('Y-m-d', time());
|
||||
}
|
||||
|
||||
if (isset($this->request->post['date_end'])) {
|
||||
$data['date_end'] = $this->request->post['date_end'];
|
||||
} elseif (!empty($coupon_info)) {
|
||||
$data['date_end'] = ($coupon_info['date_end'] != '0000-00-00' ? $coupon_info['date_end'] : '');
|
||||
} else {
|
||||
$data['date_end'] = date('Y-m-d', strtotime('+1 month'));
|
||||
}
|
||||
|
||||
if (isset($this->request->post['uses_total'])) {
|
||||
$data['uses_total'] = $this->request->post['uses_total'];
|
||||
} elseif (!empty($coupon_info)) {
|
||||
$data['uses_total'] = $coupon_info['uses_total'];
|
||||
} else {
|
||||
$data['uses_total'] = 1;
|
||||
}
|
||||
|
||||
if (isset($this->request->post['uses_customer'])) {
|
||||
$data['uses_customer'] = $this->request->post['uses_customer'];
|
||||
} elseif (!empty($coupon_info)) {
|
||||
$data['uses_customer'] = $coupon_info['uses_customer'];
|
||||
} else {
|
||||
$data['uses_customer'] = 1;
|
||||
}
|
||||
|
||||
if (isset($this->request->post['status'])) {
|
||||
$data['status'] = $this->request->post['status'];
|
||||
} elseif (!empty($coupon_info)) {
|
||||
$data['status'] = $coupon_info['status'];
|
||||
} else {
|
||||
$data['status'] = true;
|
||||
}
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('marketing/coupon_form', $data));
|
||||
}
|
||||
|
||||
protected function validateForm() {
|
||||
if (!$this->user->hasPermission('modify', 'marketing/coupon')) {
|
||||
$this->error['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 128)) {
|
||||
$this->error['name'] = $this->language->get('error_name');
|
||||
}
|
||||
|
||||
if ((utf8_strlen($this->request->post['code']) < 3) || (utf8_strlen($this->request->post['code']) > 20)) {
|
||||
$this->error['code'] = $this->language->get('error_code');
|
||||
}
|
||||
|
||||
$coupon_info = $this->model_marketing_coupon->getCouponByCode($this->request->post['code']);
|
||||
|
||||
if ($coupon_info) {
|
||||
if (!isset($this->request->get['coupon_id'])) {
|
||||
$this->error['warning'] = $this->language->get('error_exists');
|
||||
} elseif ($coupon_info['coupon_id'] != $this->request->get['coupon_id']) {
|
||||
$this->error['warning'] = $this->language->get('error_exists');
|
||||
}
|
||||
}
|
||||
|
||||
return !$this->error;
|
||||
}
|
||||
|
||||
protected function validateDelete() {
|
||||
if (!$this->user->hasPermission('modify', 'marketing/coupon')) {
|
||||
$this->error['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
return !$this->error;
|
||||
}
|
||||
|
||||
public function history() {
|
||||
$this->load->language('marketing/coupon');
|
||||
|
||||
$this->load->model('marketing/coupon');
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$data['histories'] = array();
|
||||
|
||||
$results = $this->model_marketing_coupon->getCouponHistories($this->request->get['coupon_id'], ($page - 1) * 10, 10);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['histories'][] = array(
|
||||
'order_id' => $result['order_id'],
|
||||
'customer' => $result['customer'],
|
||||
'amount' => $result['amount'],
|
||||
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added']))
|
||||
);
|
||||
}
|
||||
|
||||
$history_total = $this->model_marketing_coupon->getTotalCouponHistories($this->request->get['coupon_id']);
|
||||
|
||||
$pagination = new Pagination();
|
||||
$pagination->total = $history_total;
|
||||
$pagination->page = $page;
|
||||
$pagination->limit = 10;
|
||||
$pagination->url = $this->url->link('marketing/coupon/history', 'user_token=' . $this->session->data['user_token'] . '&coupon_id=' . $this->request->get['coupon_id'] . '&page={page}', true);
|
||||
|
||||
$data['pagination'] = $pagination->render();
|
||||
|
||||
$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));
|
||||
|
||||
$this->response->setOutput($this->load->view('marketing/coupon_history', $data));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,496 @@
|
||||
<?php
|
||||
class ControllerMarketingMarketing extends Controller {
|
||||
private $error = array();
|
||||
|
||||
public function index() {
|
||||
$this->load->language('marketing/marketing');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$this->load->model('marketing/marketing');
|
||||
|
||||
$this->getList();
|
||||
}
|
||||
|
||||
public function add() {
|
||||
$this->load->language('marketing/marketing');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$this->load->model('marketing/marketing');
|
||||
|
||||
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
|
||||
$this->model_marketing_marketing->addMarketing($this->request->post);
|
||||
|
||||
$this->session->data['success'] = $this->language->get('text_success');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_code'])) {
|
||||
$url .= '&filter_code=' . $this->request->get['filter_code'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_added'])) {
|
||||
$url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$this->response->redirect($this->url->link('marketing/marketing', 'user_token=' . $this->session->data['user_token'] . $url, true));
|
||||
}
|
||||
|
||||
$this->getForm();
|
||||
}
|
||||
|
||||
public function edit() {
|
||||
$this->load->language('marketing/marketing');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$this->load->model('marketing/marketing');
|
||||
|
||||
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
|
||||
$this->model_marketing_marketing->editMarketing($this->request->get['marketing_id'], $this->request->post);
|
||||
|
||||
$this->session->data['success'] = $this->language->get('text_success');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_code'])) {
|
||||
$url .= '&filter_code=' . $this->request->get['filter_code'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_added'])) {
|
||||
$url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$this->response->redirect($this->url->link('marketing/marketing', 'user_token=' . $this->session->data['user_token'] . $url, true));
|
||||
}
|
||||
|
||||
$this->getForm();
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
$this->load->language('marketing/marketing');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$this->load->model('marketing/marketing');
|
||||
|
||||
if (isset($this->request->post['selected']) && $this->validateDelete()) {
|
||||
foreach ($this->request->post['selected'] as $marketing_id) {
|
||||
$this->model_marketing_marketing->deleteMarketing($marketing_id);
|
||||
}
|
||||
|
||||
$this->session->data['success'] = $this->language->get('text_success');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_code'])) {
|
||||
$url .= '&filter_code=' . $this->request->get['filter_code'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_added'])) {
|
||||
$url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$this->response->redirect($this->url->link('marketing/marketing', 'user_token=' . $this->session->data['user_token'] . $url, true));
|
||||
}
|
||||
|
||||
$this->getList();
|
||||
}
|
||||
|
||||
protected function getList() {
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$filter_name = $this->request->get['filter_name'];
|
||||
} else {
|
||||
$filter_name = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_code'])) {
|
||||
$filter_code = $this->request->get['filter_code'];
|
||||
} else {
|
||||
$filter_code = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_added'])) {
|
||||
$filter_date_added = $this->request->get['filter_date_added'];
|
||||
} else {
|
||||
$filter_date_added = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = $this->request->get['sort'];
|
||||
} else {
|
||||
$sort = 'm.name';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = $this->request->get['order'];
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_code'])) {
|
||||
$url .= '&filter_code=' . $this->request->get['filter_code'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_added'])) {
|
||||
$url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = array();
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
|
||||
);
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('marketing/marketing', 'user_token=' . $this->session->data['user_token'] . $url, true)
|
||||
);
|
||||
|
||||
$data['add'] = $this->url->link('marketing/marketing/add', 'user_token=' . $this->session->data['user_token'] . $url, true);
|
||||
$data['delete'] = $this->url->link('marketing/marketing/delete', 'user_token=' . $this->session->data['user_token'] . $url, true);
|
||||
|
||||
$data['marketings'] = array();
|
||||
|
||||
$filter_data = array(
|
||||
'filter_name' => $filter_name,
|
||||
'filter_code' => $filter_code,
|
||||
'filter_date_added' => $filter_date_added,
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $this->config->get('config_limit_admin'),
|
||||
'limit' => $this->config->get('config_limit_admin')
|
||||
);
|
||||
|
||||
$marketing_total = $this->model_marketing_marketing->getTotalMarketings($filter_data);
|
||||
|
||||
$results = $this->model_marketing_marketing->getMarketings($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['marketings'][] = array(
|
||||
'marketing_id' => $result['marketing_id'],
|
||||
'name' => $result['name'],
|
||||
'code' => $result['code'],
|
||||
'clicks' => $result['clicks'],
|
||||
'orders' => $result['orders'],
|
||||
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
|
||||
'edit' => $this->url->link('marketing/marketing/edit', 'user_token=' . $this->session->data['user_token'] . '&marketing_id=' . $result['marketing_id'] . $url, true)
|
||||
);
|
||||
}
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
if (isset($this->error['warning'])) {
|
||||
$data['error_warning'] = $this->error['warning'];
|
||||
} else {
|
||||
$data['error_warning'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->session->data['success'])) {
|
||||
$data['success'] = $this->session->data['success'];
|
||||
|
||||
unset($this->session->data['success']);
|
||||
} else {
|
||||
$data['success'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['selected'])) {
|
||||
$data['selected'] = (array)$this->request->post['selected'];
|
||||
} else {
|
||||
$data['selected'] = array();
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_code'])) {
|
||||
$url .= '&filter_code=' . $this->request->get['filter_code'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_added'])) {
|
||||
$url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
|
||||
}
|
||||
|
||||
if ($order == 'ASC') {
|
||||
$url .= '&order=DESC';
|
||||
} else {
|
||||
$url .= '&order=ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['sort_name'] = $this->url->link('marketing/marketing', 'user_token=' . $this->session->data['user_token'] . '&sort=m.name' . $url, true);
|
||||
$data['sort_code'] = $this->url->link('marketing/marketing', 'user_token=' . $this->session->data['user_token'] . '&sort=m.code' . $url, true);
|
||||
$data['sort_date_added'] = $this->url->link('marketing/marketing', 'user_token=' . $this->session->data['user_token'] . '&sort=m.date_added' . $url, true);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_code'])) {
|
||||
$url .= '&filter_code=' . $this->request->get['filter_code'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_added'])) {
|
||||
$url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$pagination = new Pagination();
|
||||
$pagination->total = $marketing_total;
|
||||
$pagination->page = $page;
|
||||
$pagination->limit = $this->config->get('config_limit_admin');
|
||||
$pagination->url = $this->url->link('marketing/marketing', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}', true);
|
||||
|
||||
$data['pagination'] = $pagination->render();
|
||||
|
||||
$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')));
|
||||
|
||||
$data['filter_name'] = $filter_name;
|
||||
$data['filter_code'] = $filter_code;
|
||||
$data['filter_date_added'] = $filter_date_added;
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('marketing/marketing_list', $data));
|
||||
}
|
||||
|
||||
protected function getForm() {
|
||||
$data['text_form'] = !isset($this->request->get['marketing_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
||||
|
||||
if (isset($this->error['warning'])) {
|
||||
$data['error_warning'] = $this->error['warning'];
|
||||
} else {
|
||||
$data['error_warning'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->error['name'])) {
|
||||
$data['error_name'] = $this->error['name'];
|
||||
} else {
|
||||
$data['error_name'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->error['code'])) {
|
||||
$data['error_code'] = $this->error['code'];
|
||||
} else {
|
||||
$data['error_code'] = '';
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_code'])) {
|
||||
$url .= '&filter_code=' . $this->request->get['filter_code'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_added'])) {
|
||||
$url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = array();
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
|
||||
);
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('marketing/marketing', 'user_token=' . $this->session->data['user_token'] . $url, true)
|
||||
);
|
||||
|
||||
if (!isset($this->request->get['marketing_id'])) {
|
||||
$data['action'] = $this->url->link('marketing/marketing/add', 'user_token=' . $this->session->data['user_token'] . $url, true);
|
||||
} else {
|
||||
$data['action'] = $this->url->link('marketing/marketing/edit', 'user_token=' . $this->session->data['user_token'] . '&marketing_id=' . $this->request->get['marketing_id'] . $url, true);
|
||||
}
|
||||
|
||||
$data['cancel'] = $this->url->link('marketing/marketing', 'user_token=' . $this->session->data['user_token'] . $url, true);
|
||||
|
||||
if (isset($this->request->get['marketing_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
|
||||
$marketing_info = $this->model_marketing_marketing->getMarketing($this->request->get['marketing_id']);
|
||||
}
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['store'] = HTTP_CATALOG;
|
||||
|
||||
if (isset($this->request->post['name'])) {
|
||||
$data['name'] = $this->request->post['name'];
|
||||
} elseif (!empty($marketing_info)) {
|
||||
$data['name'] = $marketing_info['name'];
|
||||
} else {
|
||||
$data['name'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['description'])) {
|
||||
$data['description'] = $this->request->post['description'];
|
||||
} elseif (!empty($marketing_info)) {
|
||||
$data['description'] = $marketing_info['description'];
|
||||
} else {
|
||||
$data['description'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['code'])) {
|
||||
$data['code'] = $this->request->post['code'];
|
||||
} elseif (!empty($marketing_info)) {
|
||||
$data['code'] = $marketing_info['code'];
|
||||
} else {
|
||||
$data['code'] = uniqid();
|
||||
}
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('marketing/marketing_form', $data));
|
||||
}
|
||||
|
||||
protected function validateForm() {
|
||||
if (!$this->user->hasPermission('modify', 'marketing/marketing')) {
|
||||
$this->error['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if ((utf8_strlen($this->request->post['name']) < 1) || (utf8_strlen($this->request->post['name']) > 32)) {
|
||||
$this->error['name'] = $this->language->get('error_name');
|
||||
}
|
||||
|
||||
if (!$this->request->post['code']) {
|
||||
$this->error['code'] = $this->language->get('error_code');
|
||||
}
|
||||
|
||||
$marketing_info = $this->model_marketing_marketing->getMarketingByCode($this->request->post['code']);
|
||||
|
||||
if (!isset($this->request->get['marketing_id'])) {
|
||||
if ($marketing_info) {
|
||||
$this->error['code'] = $this->language->get('error_exists');
|
||||
}
|
||||
} else {
|
||||
if ($marketing_info && ($this->request->get['marketing_id'] != $marketing_info['marketing_id'])) {
|
||||
$this->error['code'] = $this->language->get('error_exists');
|
||||
}
|
||||
}
|
||||
|
||||
return !$this->error;
|
||||
}
|
||||
|
||||
protected function validateDelete() {
|
||||
if (!$this->user->hasPermission('modify', 'marketing/marketing')) {
|
||||
$this->error['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
return !$this->error;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user