blob: f75a3c7a5bd9da98b0fcd7f45645bf25dc7326c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
<?php
class ModelCustomerCustomerApproval extends Model {
public function getCustomerApprovals($data = array()) {
$sql = "SELECT *, CONCAT(c.`firstname`, ' ', c.`lastname`) AS name, cgd.`name` AS customer_group, ca.`type` FROM `" . DB_PREFIX . "customer_approval` ca LEFT JOIN `" . DB_PREFIX . "customer` c ON (ca.`customer_id` = c.`customer_id`) LEFT JOIN `" . DB_PREFIX . "customer_group_description` cgd ON (c.`customer_group_id` = cgd.`customer_group_id`) WHERE cgd.`language_id` = '" . (int)$this->config->get('config_language_id') . "'";
if (!empty($data['filter_name'])) {
$sql .= " AND CONCAT(c.`firstname`, ' ', c.`lastname`) LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
}
if (!empty($data['filter_email'])) {
$sql .= " AND c.`email` LIKE '" . $this->db->escape($data['filter_email']) . "%'";
}
if (!empty($data['filter_customer_group_id'])) {
$sql .= " AND c.`customer_group_id` = '" . (int)$data['filter_customer_group_id'] . "'";
}
if (!empty($data['filter_type'])) {
$sql .= " AND ca.`type` = '" . $this->db->escape($data['filter_type']) . "'";
}
if (!empty($data['filter_date_added'])) {
$sql .= " AND DATE(c.`date_added`) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
}
$sql .= " ORDER BY c.`date_added` DESC";
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query($sql);
return $query->rows;
}
public function getCustomerApproval($customer_approval_id) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "customer_approval` WHERE `customer_approval_id` = '" . (int)$customer_approval_id . "'");
return $query->row;
}
public function getTotalCustomerApprovals($data = array()) {
$sql = "SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "customer_approval` ca LEFT JOIN `" . DB_PREFIX . "customer` c ON (ca.`customer_id` = c.`customer_id`)";
$implode = array();
if (!empty($data['filter_name'])) {
$implode[] = "CONCAT(c.`firstname`, ' ', c.`lastname`) LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
}
if (!empty($data['filter_email'])) {
$implode[] = "c.`email` LIKE '" . $this->db->escape($data['filter_email']) . "%'";
}
if (!empty($data['filter_customer_group_id'])) {
$implode[] = "c.`customer_group_id` = '" . (int)$data['filter_customer_group_id'] . "'";
}
if (!empty($data['filter_type'])) {
$implode[] = "ca.`type` = '" . $this->db->escape($data['filter_type']) . "'";
}
if (!empty($data['filter_date_added'])) {
$implode[] = "DATE(ca.`date_added`) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
}
if ($implode) {
$sql .= " WHERE " . implode(" AND ", $implode);
}
$query = $this->db->query($sql);
return $query->row['total'];
}
public function approveCustomer($customer_id) {
$this->db->query("UPDATE `" . DB_PREFIX . "customer` SET status = '1' WHERE customer_id = '" . (int)$customer_id . "'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "customer_approval` WHERE customer_id = '" . (int)$customer_id . "' AND `type` = 'customer'");
}
public function denyCustomer($customer_id) {
$this->db->query("DELETE FROM `" . DB_PREFIX . "customer_approval` WHERE customer_id = '" . (int)$customer_id . "' AND `type` = 'customer'");
}
public function approveAffiliate($customer_id) {
$this->db->query("UPDATE `" . DB_PREFIX . "customer_affiliate` SET status = '1' WHERE customer_id = '" . (int)$customer_id . "'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "customer_approval` WHERE customer_id = '" . (int)$customer_id . "' AND `type` = 'affiliate'");
}
public function denyAffiliate($customer_id) {
$this->db->query("DELETE FROM `" . DB_PREFIX . "customer_approval` WHERE customer_id = '" . (int)$customer_id . "' AND `type` = 'affiliate'");
}
}
|