customer_approval.php (9583B)
1 <?php 2 class ControllerCustomerCustomerApproval extends Controller { 3 public function index() { 4 $this->load->language('customer/customer_approval'); 5 6 $this->document->setTitle($this->language->get('heading_title')); 7 8 if (isset($this->request->get['filter_name'])) { 9 $filter_name = $this->request->get['filter_name']; 10 } else { 11 $filter_name = ''; 12 } 13 14 if (isset($this->request->get['filter_email'])) { 15 $filter_email = $this->request->get['filter_email']; 16 } else { 17 $filter_email = ''; 18 } 19 20 if (isset($this->request->get['filter_customer_group_id'])) { 21 $filter_customer_group_id = $this->request->get['filter_customer_group_id']; 22 } else { 23 $filter_customer_group_id = ''; 24 } 25 26 if (isset($this->request->get['filter_type'])) { 27 $filter_type = $this->request->get['filter_type']; 28 } else { 29 $filter_type = ''; 30 } 31 32 if (isset($this->request->get['filter_date_added'])) { 33 $filter_date_added = $this->request->get['filter_date_added']; 34 } else { 35 $filter_date_added = ''; 36 } 37 38 $url = ''; 39 40 if (isset($this->request->get['filter_name'])) { 41 $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); 42 } 43 44 if (isset($this->request->get['filter_email'])) { 45 $url .= '&filter_email=' . urlencode(html_entity_decode($this->request->get['filter_email'], ENT_QUOTES, 'UTF-8')); 46 } 47 48 if (isset($this->request->get['filter_customer_group_id'])) { 49 $url .= '&filter_customer_group_id=' . $this->request->get['filter_customer_group_id']; 50 } 51 52 if (isset($this->request->get['filter_type'])) { 53 $url .= '&filter_type=' . $this->request->get['filter_type']; 54 } 55 56 if (isset($this->request->get['filter_date_added'])) { 57 $url .= '&filter_date_added=' . $this->request->get['filter_date_added']; 58 } 59 60 if (isset($this->request->get['page'])) { 61 $url .= '&page=' . $this->request->get['page']; 62 } 63 64 $data['breadcrumbs'] = array(); 65 66 $data['breadcrumbs'][] = array( 67 'text' => $this->language->get('text_home'), 68 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) 69 ); 70 71 $data['breadcrumbs'][] = array( 72 'text' => $this->language->get('heading_title'), 73 'href' => $this->url->link('customer/customer_approval', 'user_token=' . $this->session->data['user_token'], true) 74 ); 75 76 $data['filter_name'] = $filter_name; 77 $data['filter_email'] = $filter_email; 78 $data['filter_customer_group_id'] = $filter_customer_group_id; 79 $data['filter_type'] = $filter_type; 80 $data['filter_date_added'] = $filter_date_added; 81 82 $data['user_token'] = $this->session->data['user_token']; 83 84 $this->load->model('customer/customer_group'); 85 86 $data['customer_groups'] = $this->model_customer_customer_group->getCustomerGroups(); 87 88 $data['header'] = $this->load->controller('common/header'); 89 $data['column_left'] = $this->load->controller('common/column_left'); 90 $data['footer'] = $this->load->controller('common/footer'); 91 92 $this->response->setOutput($this->load->view('customer/customer_approval', $data)); 93 } 94 95 public function customer_approval() { 96 $this->load->language('customer/customer_approval'); 97 98 if (isset($this->request->get['filter_name'])) { 99 $filter_name = $this->request->get['filter_name']; 100 } else { 101 $filter_name = ''; 102 } 103 104 if (isset($this->request->get['filter_email'])) { 105 $filter_email = $this->request->get['filter_email']; 106 } else { 107 $filter_email = ''; 108 } 109 110 if (isset($this->request->get['filter_customer_group_id'])) { 111 $filter_customer_group_id = $this->request->get['filter_customer_group_id']; 112 } else { 113 $filter_customer_group_id = ''; 114 } 115 116 if (isset($this->request->get['filter_type'])) { 117 $filter_type = $this->request->get['filter_type']; 118 } else { 119 $filter_type = ''; 120 } 121 122 if (isset($this->request->get['filter_date_added'])) { 123 $filter_date_added = $this->request->get['filter_date_added']; 124 } else { 125 $filter_date_added = ''; 126 } 127 128 if (isset($this->request->get['page'])) { 129 $page = $this->request->get['page']; 130 } else { 131 $page = 1; 132 } 133 134 $data['customer_approvals'] = array(); 135 136 $filter_data = array( 137 'filter_name' => $filter_name, 138 'filter_email' => $filter_email, 139 'filter_customer_group_id' => $filter_customer_group_id, 140 'filter_type' => $filter_type, 141 'filter_date_added' => $filter_date_added, 142 'start' => ($page - 1) * $this->config->get('config_limit_admin'), 143 'limit' => $this->config->get('config_limit_admin') 144 ); 145 146 $this->load->model('customer/customer_approval'); 147 148 $customer_approval_total = $this->model_customer_customer_approval->getTotalCustomerApprovals($filter_data); 149 150 $results = $this->model_customer_customer_approval->getCustomerApprovals($filter_data); 151 152 foreach ($results as $result) { 153 $data['customer_approvals'][] = array( 154 'customer_id' => $result['customer_id'], 155 'name' => $result['name'], 156 'email' => $result['email'], 157 'customer_group' => $result['customer_group'], 158 'type' => $this->language->get('text_' . $result['type']), 159 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])), 160 'approve' => $this->url->link('customer/customer_approval/approve', 'user_token=' . $this->session->data['user_token'] . '&customer_id=' . $result['customer_id'] . '&type=' . $result['type'], true), 161 'deny' => $this->url->link('customer/customer_approval/deny', 'user_token=' . $this->session->data['user_token'] . '&customer_id=' . $result['customer_id'] . '&type=' . $result['type'], true), 162 'edit' => $this->url->link('customer/customer/edit', 'user_token=' . $this->session->data['user_token'] . '&customer_id=' . $result['customer_id'], true) 163 ); 164 } 165 166 $url = ''; 167 168 if (isset($this->request->get['filter_name'])) { 169 $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); 170 } 171 172 if (isset($this->request->get['filter_email'])) { 173 $url .= '&filter_email=' . urlencode(html_entity_decode($this->request->get['filter_email'], ENT_QUOTES, 'UTF-8')); 174 } 175 176 if (isset($this->request->get['filter_customer_group_id'])) { 177 $url .= '&filter_customer_group_id=' . $this->request->get['filter_customer_group_id']; 178 } 179 180 if (isset($this->request->get['filter_type'])) { 181 $url .= '&filter_type=' . $this->request->get['filter_type']; 182 } 183 184 if (isset($this->request->get['filter_date_added'])) { 185 $url .= '&filter_date_added=' . $this->request->get['filter_date_added']; 186 } 187 188 $pagination = new Pagination(); 189 $pagination->total = $customer_approval_total; 190 $pagination->page = $page; 191 $pagination->limit = $this->config->get('config_limit_admin'); 192 $pagination->url = $this->url->link('customer/customer_approval/customer_approval', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}', true); 193 194 $data['pagination'] = $pagination->render(); 195 196 $data['results'] = sprintf($this->language->get('text_pagination'), ($customer_approval_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($customer_approval_total - $this->config->get('config_limit_admin'))) ? $customer_approval_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $customer_approval_total, ceil($customer_approval_total / $this->config->get('config_limit_admin'))); 197 198 $this->response->setOutput($this->load->view('customer/customer_approval_list', $data)); 199 } 200 201 public function approve() { 202 $this->load->language('customer/customer_approval'); 203 204 $json = array(); 205 206 if (!$this->user->hasPermission('modify', 'customer/customer_approval')) { 207 $json['error'] = $this->language->get('error_permission'); 208 } else { 209 $this->load->model('customer/customer_approval'); 210 211 if ($this->request->get['type'] == 'customer') { 212 $this->model_customer_customer_approval->approveCustomer($this->request->get['customer_id']); 213 } elseif ($this->request->get['type'] == 'affiliate') { 214 $this->model_customer_customer_approval->approveAffiliate($this->request->get['customer_id']); 215 } 216 217 $json['success'] = $this->language->get('text_success'); 218 } 219 220 $this->response->addHeader('Content-Type: application/json'); 221 $this->response->setOutput(json_encode($json)); 222 } 223 224 public function deny() { 225 $this->load->language('customer/customer_approval'); 226 227 $json = array(); 228 229 if (!$this->user->hasPermission('modify', 'customer/customer_approval')) { 230 $json['error'] = $this->language->get('error_permission'); 231 } else { 232 $this->load->model('customer/customer_approval'); 233 234 if ($this->request->get['type'] == 'customer') { 235 $this->model_customer_customer_approval->denyCustomer($this->request->get['customer_id']); 236 } elseif ($this->request->get['type'] == 'affiliate') { 237 $this->model_customer_customer_approval->denyAffiliate($this->request->get['customer_id']); 238 } 239 240 $json['success'] = $this->language->get('text_success'); 241 } 242 243 $this->response->addHeader('Content-Type: application/json'); 244 $this->response->setOutput(json_encode($json)); 245 } 246 }