first commit

This commit is contained in:
Konstantin
2026-05-30 09:27:58 +03:00
commit de0344d218
2371 changed files with 661486 additions and 0 deletions
+125
View File
@@ -0,0 +1,125 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountAccount extends Controller {
public function index() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/account', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->language('account/account');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
if (isset($this->session->data['success'])) {
$data['success'] = $this->session->data['success'];
unset($this->session->data['success']);
} else {
$data['success'] = '';
}
$data['edit'] = $this->url->link('account/edit', '', true);
$data['password'] = $this->url->link('account/password', '', true);
$data['address'] = $this->url->link('account/address', '', true);
$data['credit_cards'] = array();
$files = glob(DIR_APPLICATION . 'controller/extension/credit_card/*.php');
foreach ($files as $file) {
$code = basename($file, '.php');
if ($this->config->get('payment_' . $code . '_status') && $this->config->get('payment_' . $code . '_card')) {
$this->load->language('extension/credit_card/' . $code, 'extension');
$data['credit_cards'][] = array(
'name' => $this->language->get('extension')->get('heading_title'),
'href' => $this->url->link('extension/credit_card/' . $code, '', true)
);
}
}
$data['wishlist'] = $this->url->link('account/wishlist');
$data['order'] = $this->url->link('account/order', '', true);
$data['download'] = $this->url->link('account/download', '', true);
if ($this->config->get('total_reward_status')) {
$data['reward'] = $this->url->link('account/reward', '', true);
} else {
$data['reward'] = '';
}
$data['return'] = $this->url->link('account/return', '', true);
$data['transaction'] = $this->url->link('account/transaction', '', true);
$data['newsletter'] = $this->url->link('account/newsletter', '', true);
$data['recurring'] = $this->url->link('account/recurring', '', true);
$this->load->model('account/customer');
$affiliate_info = $this->model_account_customer->getAffiliate($this->customer->getId());
if (!$affiliate_info) {
$data['affiliate'] = $this->url->link('account/affiliate/add', '', true);
} else {
$data['affiliate'] = $this->url->link('account/affiliate/edit', '', true);
}
if ($affiliate_info) {
$data['tracking'] = $this->url->link('account/tracking', '', true);
} else {
$data['tracking'] = '';
}
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/account', $data));
}
public function country() {
$json = array();
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($this->request->get['country_id']);
if ($country_info) {
$this->load->model('localisation/zone');
$json = array(
'country_id' => $country_info['country_id'],
'name' => $country_info['name'],
'iso_code_2' => $country_info['iso_code_2'],
'iso_code_3' => $country_info['iso_code_3'],
'address_format' => $country_info['address_format'],
'postcode_required' => $country_info['postcode_required'],
'zone' => $this->model_localisation_zone->getZonesByCountryId($this->request->get['country_id']),
'status' => $country_info['status']
);
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}
+497
View File
@@ -0,0 +1,497 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountAddress extends Controller {
private $error = array();
public function index() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/address', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->language('account/address');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$this->load->model('account/address');
$this->getList();
}
public function add() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/address', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->language('account/address');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$this->document->addScript('store/view/javascript/jquery/datetimepicker/moment/moment.min.js');
$this->document->addScript('store/view/javascript/jquery/datetimepicker/moment/moment-with-locales.min.js');
$this->document->addScript('store/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js');
$this->document->addStyle('store/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css');
$this->load->model('account/address');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
$this->model_account_address->addAddress($this->customer->getId(), $this->request->post);
$this->session->data['success'] = $this->language->get('text_add');
$this->response->redirect($this->url->link('account/address', '', true));
}
$this->getForm();
}
public function edit() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/address', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->language('account/address');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$this->document->addScript('store/view/javascript/jquery/datetimepicker/moment/moment.min.js');
$this->document->addScript('store/view/javascript/jquery/datetimepicker/moment/moment-with-locales.min.js');
$this->document->addScript('store/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js');
$this->document->addStyle('store/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css');
$this->load->model('account/address');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
$this->model_account_address->editAddress($this->request->get['address_id'], $this->request->post);
// Default Shipping Address
if (isset($this->session->data['shipping_address']['address_id']) && ($this->request->get['address_id'] == $this->session->data['shipping_address']['address_id'])) {
$this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->request->get['address_id']);
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
}
// Default Payment Address
if (isset($this->session->data['payment_address']['address_id']) && ($this->request->get['address_id'] == $this->session->data['payment_address']['address_id'])) {
$this->session->data['payment_address'] = $this->model_account_address->getAddress($this->request->get['address_id']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
}
$this->session->data['success'] = $this->language->get('text_edit');
$this->response->redirect($this->url->link('account/address', '', true));
}
$this->getForm();
}
public function delete() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/address', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->language('account/address');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$this->load->model('account/address');
if (isset($this->request->get['address_id']) && $this->validateDelete()) {
$this->model_account_address->deleteAddress($this->request->get['address_id']);
// Default Shipping Address
if (isset($this->session->data['shipping_address']['address_id']) && ($this->request->get['address_id'] == $this->session->data['shipping_address']['address_id'])) {
unset($this->session->data['shipping_address']);
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
}
// Default Payment Address
if (isset($this->session->data['payment_address']['address_id']) && ($this->request->get['address_id'] == $this->session->data['payment_address']['address_id'])) {
unset($this->session->data['payment_address']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
}
$this->session->data['success'] = $this->language->get('text_delete');
$this->response->redirect($this->url->link('account/address', '', true));
}
$this->getList();
}
protected function getList() {
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('account/address', '', 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'] = '';
}
$data['addresses'] = array();
$results = $this->model_account_address->getAddresses();
foreach ($results as $result) {
if ($result['address_format']) {
$format = $result['address_format'];
} else {
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
}
$find = array(
'{firstname}',
'{lastname}',
'{company}',
'{address_1}',
'{address_2}',
'{city}',
'{postcode}',
'{zone}',
'{zone_code}',
'{country}'
);
$replace = array(
'firstname' => $result['firstname'],
'lastname' => $result['lastname'],
'company' => $result['company'],
'address_1' => $result['address_1'],
'address_2' => $result['address_2'],
'city' => $result['city'],
'postcode' => $result['postcode'],
'zone' => $result['zone'],
'zone_code' => $result['zone_code'],
'country' => $result['country']
);
$data['addresses'][] = array(
'address_id' => $result['address_id'],
'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)))),
'update' => $this->url->link('account/address/edit', 'address_id=' . $result['address_id'], true),
'delete' => $this->url->link('account/address/delete', 'address_id=' . $result['address_id'], true)
);
}
$data['add'] = $this->url->link('account/address/add', '', true);
$data['back'] = $this->url->link('account/account', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/address_list', $data));
}
protected function getForm() {
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('account/address', '', true)
);
if (!isset($this->request->get['address_id'])) {
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_address_add'),
'href' => $this->url->link('account/address/add', '', true)
);
} else {
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_address_edit'),
'href' => $this->url->link('account/address/edit', 'address_id=' . $this->request->get['address_id'], true)
);
}
$data['text_address'] = !isset($this->request->get['address_id']) ? $this->language->get('text_address_add') : $this->language->get('text_address_edit');
if (isset($this->error['firstname'])) {
$data['error_firstname'] = $this->error['firstname'];
} else {
$data['error_firstname'] = '';
}
if (isset($this->error['lastname'])) {
$data['error_lastname'] = $this->error['lastname'];
} else {
$data['error_lastname'] = '';
}
if (isset($this->error['address_1'])) {
$data['error_address_1'] = $this->error['address_1'];
} else {
$data['error_address_1'] = '';
}
if (isset($this->error['city'])) {
$data['error_city'] = $this->error['city'];
} else {
$data['error_city'] = '';
}
if (isset($this->error['postcode'])) {
$data['error_postcode'] = $this->error['postcode'];
} else {
$data['error_postcode'] = '';
}
if (isset($this->error['country'])) {
$data['error_country'] = $this->error['country'];
} else {
$data['error_country'] = '';
}
if (isset($this->error['zone'])) {
$data['error_zone'] = $this->error['zone'];
} else {
$data['error_zone'] = '';
}
if (isset($this->error['custom_field'])) {
$data['error_custom_field'] = $this->error['custom_field'];
} else {
$data['error_custom_field'] = array();
}
if (!isset($this->request->get['address_id'])) {
$data['action'] = $this->url->link('account/address/add', '', true);
} else {
$data['action'] = $this->url->link('account/address/edit', 'address_id=' . $this->request->get['address_id'], true);
}
if (isset($this->request->get['address_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
$address_info = $this->model_account_address->getAddress($this->request->get['address_id']);
}
if (isset($this->request->post['firstname'])) {
$data['firstname'] = $this->request->post['firstname'];
} elseif (!empty($address_info)) {
$data['firstname'] = $address_info['firstname'];
} else {
$data['firstname'] = '';
}
if (isset($this->request->post['lastname'])) {
$data['lastname'] = $this->request->post['lastname'];
} elseif (!empty($address_info)) {
$data['lastname'] = $address_info['lastname'];
} else {
$data['lastname'] = '';
}
if (isset($this->request->post['company'])) {
$data['company'] = $this->request->post['company'];
} elseif (!empty($address_info)) {
$data['company'] = $address_info['company'];
} else {
$data['company'] = '';
}
if (isset($this->request->post['address_1'])) {
$data['address_1'] = $this->request->post['address_1'];
} elseif (!empty($address_info)) {
$data['address_1'] = $address_info['address_1'];
} else {
$data['address_1'] = '';
}
if (isset($this->request->post['address_2'])) {
$data['address_2'] = $this->request->post['address_2'];
} elseif (!empty($address_info)) {
$data['address_2'] = $address_info['address_2'];
} else {
$data['address_2'] = '';
}
if (isset($this->request->post['postcode'])) {
$data['postcode'] = $this->request->post['postcode'];
} elseif (!empty($address_info)) {
$data['postcode'] = $address_info['postcode'];
} else {
$data['postcode'] = '';
}
if (isset($this->request->post['city'])) {
$data['city'] = $this->request->post['city'];
} elseif (!empty($address_info)) {
$data['city'] = $address_info['city'];
} else {
$data['city'] = '';
}
if (isset($this->request->post['country_id'])) {
$data['country_id'] = (int)$this->request->post['country_id'];
} elseif (!empty($address_info)) {
$data['country_id'] = $address_info['country_id'];
} else {
$data['country_id'] = $this->config->get('config_country_id');
}
if (isset($this->request->post['zone_id'])) {
$data['zone_id'] = (int)$this->request->post['zone_id'];
} elseif (!empty($address_info)) {
$data['zone_id'] = $address_info['zone_id'];
} else {
$data['zone_id'] = '';
}
$this->load->model('localisation/country');
$data['countries'] = $this->model_localisation_country->getCountries();
// Custom fields
$data['custom_fields'] = array();
$this->load->model('account/custom_field');
$custom_fields = $this->model_account_custom_field->getCustomFields($this->config->get('config_customer_group_id'));
foreach ($custom_fields as $custom_field) {
if ($custom_field['location'] == 'address') {
$data['custom_fields'][] = $custom_field;
}
}
if (isset($this->request->post['custom_field']['address'])) {
$data['address_custom_field'] = $this->request->post['custom_field']['address'];
} elseif (isset($address_info['custom_field'])) {
$data['address_custom_field'] = $address_info['custom_field'];
} else {
$data['address_custom_field'] = array();
}
if (isset($this->request->post['default'])) {
$data['default'] = $this->request->post['default'];
} elseif (isset($this->request->get['address_id'])) {
$data['default'] = $this->customer->getAddressId() == $this->request->get['address_id'];
} else {
$data['default'] = false;
}
$data['back'] = $this->url->link('account/address', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/address_form', $data));
}
protected function validateForm() {
if ((utf8_strlen(trim($this->request->post['firstname'])) < 1) || (utf8_strlen(trim($this->request->post['firstname'])) > 32)) {
$this->error['firstname'] = $this->language->get('error_firstname');
}
if ((utf8_strlen(trim($this->request->post['lastname'])) < 1) || (utf8_strlen(trim($this->request->post['lastname'])) > 32)) {
$this->error['lastname'] = $this->language->get('error_lastname');
}
if ((utf8_strlen(trim($this->request->post['address_1'])) < 3) || (utf8_strlen(trim($this->request->post['address_1'])) > 128)) {
$this->error['address_1'] = $this->language->get('error_address_1');
}
if ((utf8_strlen(trim($this->request->post['city'])) < 2) || (utf8_strlen(trim($this->request->post['city'])) > 128)) {
$this->error['city'] = $this->language->get('error_city');
}
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']);
if ($country_info && $country_info['postcode_required'] && (utf8_strlen(trim($this->request->post['postcode'])) < 2 || utf8_strlen(trim($this->request->post['postcode'])) > 10)) {
$this->error['postcode'] = $this->language->get('error_postcode');
}
if ($this->request->post['country_id'] == '' || !is_numeric($this->request->post['country_id'])) {
$this->error['country'] = $this->language->get('error_country');
}
if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '' || !is_numeric($this->request->post['zone_id'])) {
$this->error['zone'] = $this->language->get('error_zone');
}
// Custom field validation
$this->load->model('account/custom_field');
$custom_fields = $this->model_account_custom_field->getCustomFields($this->config->get('config_customer_group_id'));
foreach ($custom_fields as $custom_field) {
if ($custom_field['location'] == 'address') {
if ($custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']])) {
$this->error['custom_field'][$custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']);
} elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) {
$this->error['custom_field'][$custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']);
}
}
}
return !$this->error;
}
protected function validateDelete() {
if ($this->model_account_address->getTotalAddresses() == 1) {
$this->error['warning'] = $this->language->get('error_delete');
}
if ($this->customer->getAddressId() == $this->request->get['address_id']) {
$this->error['warning'] = $this->language->get('error_default');
}
return !$this->error;
}
}
@@ -0,0 +1,305 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountAffiliate extends Controller {
private $error = array();
public function add() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/affiliate', '', true);
$this->response->redirect($this->url->link('affiliate/login', '', true));
}
$this->load->language('account/affiliate');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$this->load->model('account/customer');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->model_account_customer->addAffiliate($this->customer->getId(), $this->request->post);
$this->session->data['success'] = $this->language->get('text_success');
$this->response->redirect($this->url->link('account/account', '', true));
}
$this->getForm();
}
public function edit() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/affiliate', '', true);
$this->response->redirect($this->url->link('affiliate/login', '', true));
}
$this->load->language('account/affiliate');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$this->load->model('account/customer');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->model_account_customer->editAffiliate($this->customer->getId(), $this->request->post);
$this->session->data['success'] = $this->language->get('text_success');
$this->response->redirect($this->url->link('account/account', '', true));
}
$this->getForm();
}
public function getForm() {
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
if ($this->request->get['route'] == 'account/affiliate/add') {
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_affiliate'),
'href' => $this->url->link('account/affiliate/add', '', true)
);
} else {
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_affiliate'),
'href' => $this->url->link('account/affiliate/edit', '', true)
);
}
if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
if (isset($this->error['cheque'])) {
$data['error_cheque'] = $this->error['cheque'];
} else {
$data['error_cheque'] = '';
}
if (isset($this->error['paypal'])) {
$data['error_paypal'] = $this->error['paypal'];
} else {
$data['error_paypal'] = '';
}
if (isset($this->error['bank_account_name'])) {
$data['error_bank_account_name'] = $this->error['bank_account_name'];
} else {
$data['error_bank_account_name'] = '';
}
if (isset($this->error['bank_account_number'])) {
$data['error_bank_account_number'] = $this->error['bank_account_number'];
} else {
$data['error_bank_account_number'] = '';
}
if (isset($this->error['custom_field'])) {
$data['error_custom_field'] = $this->error['custom_field'];
} else {
$data['error_custom_field'] = array();
}
$data['action'] = $this->url->link($this->request->get['route'], '', true);
if ($this->request->get['route'] == 'account/affiliate/edit' && $this->request->server['REQUEST_METHOD'] != 'POST') {
$affiliate_info = $this->model_account_customer->getAffiliate($this->customer->getId());
}
if (isset($this->request->post['company'])) {
$data['company'] = $this->request->post['company'];
} elseif (!empty($affiliate_info)) {
$data['company'] = $affiliate_info['company'];
} else {
$data['company'] = '';
}
if (isset($this->request->post['website'])) {
$data['website'] = $this->request->post['website'];
} elseif (!empty($affiliate_info)) {
$data['website'] = $affiliate_info['website'];
} else {
$data['website'] = '';
}
if (isset($this->request->post['tax'])) {
$data['tax'] = $this->request->post['tax'];
} elseif (!empty($affiliate_info)) {
$data['tax'] = $affiliate_info['tax'];
} else {
$data['tax'] = '';
}
if (isset($this->request->post['payment'])) {
$data['payment'] = $this->request->post['payment'];
} elseif (!empty($affiliate_info)) {
$data['payment'] = $affiliate_info['payment'];
} else {
$data['payment'] = 'cheque';
}
if (isset($this->request->post['cheque'])) {
$data['cheque'] = $this->request->post['cheque'];
} elseif (!empty($affiliate_info)) {
$data['cheque'] = $affiliate_info['cheque'];
} else {
$data['cheque'] = '';
}
if (isset($this->request->post['paypal'])) {
$data['paypal'] = $this->request->post['paypal'];
} elseif (!empty($affiliate_info)) {
$data['paypal'] = $affiliate_info['paypal'];
} else {
$data['paypal'] = '';
}
if (isset($this->request->post['bank_name'])) {
$data['bank_name'] = $this->request->post['bank_name'];
} elseif (!empty($affiliate_info)) {
$data['bank_name'] = $affiliate_info['bank_name'];
} else {
$data['bank_name'] = '';
}
if (isset($this->request->post['bank_branch_number'])) {
$data['bank_branch_number'] = $this->request->post['bank_branch_number'];
} elseif (!empty($affiliate_info)) {
$data['bank_branch_number'] = $affiliate_info['bank_branch_number'];
} else {
$data['bank_branch_number'] = '';
}
if (isset($this->request->post['bank_swift_code'])) {
$data['bank_swift_code'] = $this->request->post['bank_swift_code'];
} elseif (!empty($affiliate_info)) {
$data['bank_swift_code'] = $affiliate_info['bank_swift_code'];
} else {
$data['bank_swift_code'] = '';
}
if (isset($this->request->post['bank_account_name'])) {
$data['bank_account_name'] = $this->request->post['bank_account_name'];
} elseif (!empty($affiliate_info)) {
$data['bank_account_name'] = $affiliate_info['bank_account_name'];
} else {
$data['bank_account_name'] = '';
}
if (isset($this->request->post['bank_account_number'])) {
$data['bank_account_number'] = $this->request->post['bank_account_number'];
} elseif (!empty($affiliate_info)) {
$data['bank_account_number'] = $affiliate_info['bank_account_number'];
} else {
$data['bank_account_number'] = '';
}
// Custom Fields
$this->load->model('account/custom_field');
$data['custom_fields'] = $this->model_account_custom_field->getCustomFields($this->config->get('config_customer_group_id'));
if (isset($this->request->post['custom_field'])) {
$data['affiliate_custom_field'] = $this->request->post['custom_field'];
} elseif (isset($affiliate_info)) {
$data['affiliate_custom_field'] = json_decode($affiliate_info['custom_field'], true);
} else {
$data['affiliate_custom_field'] = array();
}
$affiliate_info = $this->model_account_customer->getAffiliate($this->customer->getId());
if (!$affiliate_info && $this->config->get('config_affiliate_id')) {
$this->load->model('catalog/information');
$information_info = $this->model_catalog_information->getInformation($this->config->get('config_affiliate_id'));
if ($information_info) {
$data['text_agree'] = sprintf($this->language->get('text_agree'), $this->url->link('information/information/agree', 'information_id=' . $this->config->get('config_affiliate_id'), true), $information_info['title']);
} else {
$data['text_agree'] = '';
}
} else {
$data['text_agree'] = '';
}
if (isset($this->request->post['agree'])) {
$data['agree'] = $this->request->post['agree'];
} else {
$data['agree'] = false;
}
$data['back'] = $this->url->link('account/account', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/affiliate', $data));
}
protected function validate() {
if ($this->request->post['payment'] == 'cheque' && !$this->request->post['cheque']) {
$this->error['cheque'] = $this->language->get('error_cheque');
} elseif (($this->request->post['payment'] == 'paypal') && ((utf8_strlen($this->request->post['paypal']) > 96) || !filter_var($this->request->post['paypal'], FILTER_VALIDATE_EMAIL))) {
$this->error['paypal'] = $this->language->get('error_paypal');
} elseif ($this->request->post['payment'] == 'bank') {
if ($this->request->post['bank_account_name'] == '') {
$this->error['bank_account_name'] = $this->language->get('error_bank_account_name');
}
if ($this->request->post['bank_account_number'] == '') {
$this->error['bank_account_number'] = $this->language->get('error_bank_account_number');
}
}
// Custom field validation
$this->load->model('account/custom_field');
$custom_fields = $this->model_account_custom_field->getCustomFields($this->config->get('config_customer_group_id'));
foreach ($custom_fields as $custom_field) {
if ($custom_field['location'] == 'affiliate') {
if ($custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']])) {
$this->error['custom_field'][$custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']);
} elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) {
$this->error['custom_field'][$custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']);
}
}
}
// Validate agree only if customer not already an affiliate
$affiliate_info = $this->model_account_customer->getAffiliate($this->customer->getId());
if (!$affiliate_info && $this->config->get('config_affiliate_id')) {
$this->load->model('catalog/information');
$information_info = $this->model_catalog_information->getInformation($this->config->get('config_affiliate_id'));
if ($information_info && !isset($this->request->post['agree'])) {
$this->error['warning'] = sprintf($this->language->get('error_agree'), $information_info['title']);
}
}
return !$this->error;
}
}
@@ -0,0 +1,151 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountDownload extends Controller {
public function index() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/download', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->language('account/download');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_downloads'),
'href' => $this->url->link('account/download', '', true)
);
$this->load->model('account/download');
if (isset($this->request->get['page'])) {
$page = (int)$this->request->get['page'];
} else {
$page = 1;
}
$data['downloads'] = array();
$download_total = $this->model_account_download->getTotalDownloads();
$results = $this->model_account_download->getDownloads(($page - 1) * $this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit'), $this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit'));
foreach ($results as $result) {
if (file_exists(DIR_DOWNLOAD . $result['filename'])) {
$size = filesize(DIR_DOWNLOAD . $result['filename']);
$i = 0;
$suffix = array(
'B',
'KB',
'MB',
'GB',
'TB',
'PB',
'EB',
'ZB',
'YB'
);
while (($size / 1024) > 1) {
$size = $size / 1024;
$i++;
}
$data['downloads'][] = array(
'order_id' => $result['order_id'],
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'name' => $result['name'],
'size' => round(substr($size, 0, strpos($size, '.') + 4), 2) . $suffix[$i],
'href' => $this->url->link('account/download/download', 'download_id=' . $result['download_id'], true)
);
}
}
$pagination = new Pagination();
$pagination->total = $download_total;
$pagination->page = $page;
$pagination->limit = $this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit');
$pagination->url = $this->url->link('account/download', 'page={page}', true);
$data['pagination'] = $pagination->render();
$data['results'] = sprintf($this->language->get('text_pagination'), ($download_total) ? (($page - 1) * 10) + 1 : 0, ((($page - 1) * 10) > ($download_total - 10)) ? $download_total : ((($page - 1) * 10) + 10), $download_total, ceil($download_total / 10));
$data['continue'] = $this->url->link('account/account', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/download', $data));
}
public function download() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/download', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->model('account/download');
if (isset($this->request->get['download_id'])) {
$download_id = $this->request->get['download_id'];
} else {
$download_id = 0;
}
$download_info = $this->model_account_download->getDownload($download_id);
if ($download_info) {
$file = DIR_DOWNLOAD . $download_info['filename'];
$mask = basename($download_info['mask']);
if (!headers_sent()) {
if (file_exists($file)) {
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . ($mask ? $mask : basename($file)) . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
if (ob_get_level()) {
ob_end_clean();
}
readfile($file, 'rb');
exit();
} else {
exit('Error: Could not find file ' . $file . '!');
}
} else {
exit('Error: Headers already sent out!');
}
} else {
$this->response->redirect($this->url->link('account/download', '', true));
}
}
}
+197
View File
@@ -0,0 +1,197 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountEdit extends Controller {
private $error = array();
public function index() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/edit', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->language('account/edit');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$this->document->addScript('store/view/javascript/jquery/datetimepicker/moment/moment.min.js');
$this->document->addScript('store/view/javascript/jquery/datetimepicker/moment/moment-with-locales.min.js');
$this->document->addScript('store/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js');
$this->document->addStyle('store/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css');
$this->load->model('account/customer');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->model_account_customer->editCustomer($this->customer->getId(), $this->request->post);
$this->session->data['success'] = $this->language->get('text_success');
$this->response->redirect($this->url->link('account/account', '', true));
}
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_edit'),
'href' => $this->url->link('account/edit', '', true)
);
if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
if (isset($this->error['firstname'])) {
$data['error_firstname'] = $this->error['firstname'];
} else {
$data['error_firstname'] = '';
}
if (isset($this->error['lastname'])) {
$data['error_lastname'] = $this->error['lastname'];
} else {
$data['error_lastname'] = '';
}
if (isset($this->error['email'])) {
$data['error_email'] = $this->error['email'];
} else {
$data['error_email'] = '';
}
if (isset($this->error['telephone'])) {
$data['error_telephone'] = $this->error['telephone'];
} else {
$data['error_telephone'] = '';
}
if (isset($this->error['custom_field'])) {
$data['error_custom_field'] = $this->error['custom_field'];
} else {
$data['error_custom_field'] = array();
}
$data['action'] = $this->url->link('account/edit', '', true);
if ($this->request->server['REQUEST_METHOD'] != 'POST') {
$customer_info = $this->model_account_customer->getCustomer($this->customer->getId());
}
if (isset($this->request->post['firstname'])) {
$data['firstname'] = $this->request->post['firstname'];
} elseif (!empty($customer_info)) {
$data['firstname'] = $customer_info['firstname'];
} else {
$data['firstname'] = '';
}
if (isset($this->request->post['lastname'])) {
$data['lastname'] = $this->request->post['lastname'];
} elseif (!empty($customer_info)) {
$data['lastname'] = $customer_info['lastname'];
} else {
$data['lastname'] = '';
}
if (isset($this->request->post['email'])) {
$data['email'] = $this->request->post['email'];
} elseif (!empty($customer_info)) {
$data['email'] = $customer_info['email'];
} else {
$data['email'] = '';
}
if (isset($this->request->post['telephone'])) {
$data['telephone'] = $this->request->post['telephone'];
} elseif (!empty($customer_info)) {
$data['telephone'] = $customer_info['telephone'];
} else {
$data['telephone'] = '';
}
// Custom Fields
$data['custom_fields'] = array();
$this->load->model('account/custom_field');
$custom_fields = $this->model_account_custom_field->getCustomFields($this->config->get('config_customer_group_id'));
foreach ($custom_fields as $custom_field) {
if ($custom_field['location'] == 'account') {
$data['custom_fields'][] = $custom_field;
}
}
if (isset($this->request->post['custom_field']['account'])) {
$data['account_custom_field'] = $this->request->post['custom_field']['account'];
} elseif (isset($customer_info)) {
$data['account_custom_field'] = json_decode($customer_info['custom_field'], true);
} else {
$data['account_custom_field'] = array();
}
$data['back'] = $this->url->link('account/account', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/edit', $data));
}
protected function validate() {
if ((utf8_strlen(trim($this->request->post['firstname'])) < 1) || (utf8_strlen(trim($this->request->post['firstname'])) > 32)) {
$this->error['firstname'] = $this->language->get('error_firstname');
}
if ((utf8_strlen(trim($this->request->post['lastname'])) < 1) || (utf8_strlen(trim($this->request->post['lastname'])) > 32)) {
$this->error['lastname'] = $this->language->get('error_lastname');
}
if ((utf8_strlen($this->request->post['email']) > 96) || !filter_var($this->request->post['email'], FILTER_VALIDATE_EMAIL)) {
$this->error['email'] = $this->language->get('error_email');
}
if (($this->customer->getEmail() != $this->request->post['email']) && $this->model_account_customer->getTotalCustomersByEmail($this->request->post['email'])) {
$this->error['warning'] = $this->language->get('error_exists');
}
if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 32)) {
$this->error['telephone'] = $this->language->get('error_telephone');
}
// Custom field validation
$this->load->model('account/custom_field');
$custom_fields = $this->model_account_custom_field->getCustomFields('account', $this->config->get('config_customer_group_id'));
foreach ($custom_fields as $custom_field) {
if ($custom_field['location'] == 'account') {
if ($custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']])) {
$this->error['custom_field'][$custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']);
} elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) {
$this->error['custom_field'][$custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']);
}
}
}
return !$this->error;
}
}
@@ -0,0 +1,87 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountForgotten extends Controller {
private $error = array();
public function index() {
if ($this->customer->isLogged()) {
$this->response->redirect($this->url->link('account/account', '', true));
}
$this->load->language('account/forgotten');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$this->load->model('account/customer');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->model_account_customer->editCode($this->request->post['email'], token(40));
$this->session->data['success'] = $this->language->get('text_success');
$this->response->redirect($this->url->link('account/login', '', true));
}
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_forgotten'),
'href' => $this->url->link('account/forgotten', '', true)
);
if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
$data['action'] = $this->url->link('account/forgotten', '', true);
$data['back'] = $this->url->link('account/login', '', true);
if (isset($this->request->post['email'])) {
$data['email'] = $this->request->post['email'];
} else {
$data['email'] = '';
}
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/forgotten', $data));
}
protected function validate() {
if (!isset($this->request->post['email'])) {
$this->error['warning'] = $this->language->get('error_email');
} elseif (!$this->model_account_customer->getTotalCustomersByEmail($this->request->post['email'])) {
$this->error['warning'] = $this->language->get('error_email');
}
// Check if customer has been approved.
$customer_info = $this->model_account_customer->getCustomerByEmail($this->request->post['email']);
if ($customer_info && !$customer_info['status']) {
$this->error['warning'] = $this->language->get('error_approved');
}
return !$this->error;
}
}
+189
View File
@@ -0,0 +1,189 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountLogin extends Controller {
private $error = array();
public function index() {
$this->load->model('account/customer');
// Login override for admin users
if (!empty($this->request->get['token'])) {
$this->customer->logout();
$this->cart->clear();
unset($this->session->data['order_id']);
unset($this->session->data['payment_address']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
unset($this->session->data['shipping_address']);
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['comment']);
unset($this->session->data['coupon']);
unset($this->session->data['reward']);
unset($this->session->data['voucher']);
unset($this->session->data['vouchers']);
$customer_info = $this->model_account_customer->getCustomerByToken($this->request->get['token']);
if ($customer_info && $this->customer->login($customer_info['email'], '', true)) {
// Default Addresses
$this->load->model('account/address');
if ($this->config->get('config_tax_customer') == 'payment') {
$this->session->data['payment_address'] = $this->model_account_address->getAddress($this->customer->getAddressId());
}
if ($this->config->get('config_tax_customer') == 'shipping') {
$this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->customer->getAddressId());
}
$this->response->redirect($this->url->link('account/account', '', true));
}
}
if ($this->customer->isLogged()) {
$this->response->redirect($this->url->link('account/account', '', true));
}
$this->load->language('account/login');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
// Unset guest
unset($this->session->data['guest']);
// Default Shipping Address
$this->load->model('account/address');
if ($this->config->get('config_tax_customer') == 'payment') {
$this->session->data['payment_address'] = $this->model_account_address->getAddress($this->customer->getAddressId());
}
if ($this->config->get('config_tax_customer') == 'shipping') {
$this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->customer->getAddressId());
}
// Wishlist
if (isset($this->session->data['wishlist']) && is_array($this->session->data['wishlist'])) {
$this->load->model('account/wishlist');
foreach ($this->session->data['wishlist'] as $key => $product_id) {
$this->model_account_wishlist->addWishlist($product_id);
unset($this->session->data['wishlist'][$key]);
}
}
// Added strpos check to pass McAfee PCI compliance test (http://forum.opencart.com/viewtopic.php?f=10&t=12043&p=151494#p151295)
if (isset($this->request->post['redirect']) && $this->request->post['redirect'] != $this->url->link('account/logout', '', true) && (strpos($this->request->post['redirect'], $this->config->get('config_url')) !== false || strpos($this->request->post['redirect'], $this->config->get('config_ssl')) !== false)) {
$this->response->redirect(str_replace('&amp;', '&', $this->request->post['redirect']));
} else {
$this->response->redirect($this->url->link('account/account', '', true));
}
}
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_login'),
'href' => $this->url->link('account/login', '', true)
);
if (isset($this->session->data['error'])) {
$data['error_warning'] = $this->session->data['error'];
unset($this->session->data['error']);
} elseif (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
$data['action'] = $this->url->link('account/login', '', true);
$data['register'] = $this->url->link('account/register', '', true);
$data['forgotten'] = $this->url->link('account/forgotten', '', true);
// Added strpos check to pass McAfee PCI compliance test (http://forum.opencart.com/viewtopic.php?f=10&t=12043&p=151494#p151295)
if (isset($this->request->post['redirect']) && (strpos($this->request->post['redirect'], $this->config->get('config_url')) !== false || strpos($this->request->post['redirect'], $this->config->get('config_ssl')) !== false)) {
$data['redirect'] = $this->request->post['redirect'];
} elseif (isset($this->session->data['redirect'])) {
$data['redirect'] = $this->session->data['redirect'];
unset($this->session->data['redirect']);
} else {
$data['redirect'] = '';
}
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['email'])) {
$data['email'] = $this->request->post['email'];
} else {
$data['email'] = '';
}
if (isset($this->request->post['password'])) {
$data['password'] = $this->request->post['password'];
} else {
$data['password'] = '';
}
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/login', $data));
}
protected function validate() {
// Check how many login attempts have been made.
$login_info = $this->model_account_customer->getLoginAttempts($this->request->post['email']);
if ($login_info && ($login_info['total'] >= $this->config->get('config_login_attempts')) && strtotime('-1 hour') < strtotime($login_info['date_modified'])) {
$this->error['warning'] = $this->language->get('error_attempts');
}
// Check if customer has been approved.
$customer_info = $this->model_account_customer->getCustomerByEmail($this->request->post['email']);
if ($customer_info && !$customer_info['status']) {
$this->error['warning'] = $this->language->get('error_approved');
}
if (!$this->error) {
if (!$this->customer->login($this->request->post['email'], $this->request->post['password'])) {
$this->error['warning'] = $this->language->get('error_login');
$this->model_account_customer->addLoginAttempt($this->request->post['email']);
} else {
$this->model_account_customer->deleteLoginAttempts($this->request->post['email']);
}
}
return !$this->error;
}
}
@@ -0,0 +1,59 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountLogout extends Controller {
public function index() {
if ($this->customer->isLogged()) {
$this->customer->logout();
unset($this->session->data['shipping_address']);
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_address']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
unset($this->session->data['comment']);
unset($this->session->data['order_id']);
unset($this->session->data['coupon']);
unset($this->session->data['reward']);
unset($this->session->data['voucher']);
unset($this->session->data['vouchers']);
$this->response->redirect($this->url->link('account/logout', '', true));
}
$this->load->language('account/logout');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_logout'),
'href' => $this->url->link('account/logout', '', true)
);
$data['continue'] = $this->url->link('common/home');
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('common/success', $data));
}
}
@@ -0,0 +1,60 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountNewsletter extends Controller {
public function index() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/newsletter', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->language('account/newsletter');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
if ($this->request->server['REQUEST_METHOD'] == 'POST') {
$this->load->model('account/customer');
$this->model_account_customer->editNewsletter($this->request->post['newsletter']);
$this->session->data['success'] = $this->language->get('text_success');
$this->response->redirect($this->url->link('account/account', '', true));
}
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_newsletter'),
'href' => $this->url->link('account/newsletter', '', true)
);
$data['action'] = $this->url->link('account/newsletter', '', true);
$data['newsletter'] = $this->customer->getNewsletter();
$data['back'] = $this->url->link('account/account', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/newsletter', $data));
}
}
+405
View File
@@ -0,0 +1,405 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountOrder extends Controller {
public function index() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/order', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->language('account/order');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$url = '';
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/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('account/order', $url, true)
);
if (isset($this->request->get['page'])) {
$page = (int)$this->request->get['page'];
} else {
$page = 1;
}
$data['orders'] = array();
$this->load->model('account/order');
$order_total = $this->model_account_order->getTotalOrders();
$results = $this->model_account_order->getOrders(($page - 1) * 10, 10);
foreach ($results as $result) {
$product_total = $this->model_account_order->getTotalOrderProductsByOrderId($result['order_id']);
$voucher_total = $this->model_account_order->getTotalOrderVouchersByOrderId($result['order_id']);
$data['orders'][] = array(
'order_id' => $result['order_id'],
'name' => $result['firstname'] . ' ' . $result['lastname'],
'status' => $result['status'],
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'products' => ($product_total + $voucher_total),
'total' => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value']),
'view' => $this->url->link('account/order/info', 'order_id=' . $result['order_id'], true),
);
}
$pagination = new Pagination();
$pagination->total = $order_total;
$pagination->page = $page;
$pagination->limit = 10;
$pagination->url = $this->url->link('account/order', 'page={page}', true);
$data['pagination'] = $pagination->render();
$data['results'] = sprintf($this->language->get('text_pagination'), ($order_total) ? (($page - 1) * 10) + 1 : 0, ((($page - 1) * 10) > ($order_total - 10)) ? $order_total : ((($page - 1) * 10) + 10), $order_total, ceil($order_total / 10));
$data['continue'] = $this->url->link('account/account', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/order_list', $data));
}
public function info() {
$this->load->language('account/order');
if (isset($this->request->get['order_id'])) {
$order_id = $this->request->get['order_id'];
} else {
$order_id = 0;
}
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/order/info', 'order_id=' . $order_id, true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->model('account/order');
$order_info = $this->model_account_order->getOrder($order_id);
if ($order_info) {
$this->document->setTitle($this->language->get('text_order'));
$url = '';
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/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('account/order', $url, true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_order'),
'href' => $this->url->link('account/order/info', 'order_id=' . $this->request->get['order_id'] . $url, true)
);
if (isset($this->session->data['error'])) {
$data['error_warning'] = $this->session->data['error'];
unset($this->session->data['error']);
} 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 ($order_info['invoice_no']) {
$data['invoice_no'] = $order_info['invoice_prefix'] . $order_info['invoice_no'];
} else {
$data['invoice_no'] = '';
}
$data['order_id'] = (int)$this->request->get['order_id'];
$data['date_added'] = date($this->language->get('date_format_short'), strtotime($order_info['date_added']));
if ($order_info['payment_address_format']) {
$format = $order_info['payment_address_format'];
} else {
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
}
$find = array(
'{firstname}',
'{lastname}',
'{company}',
'{address_1}',
'{address_2}',
'{city}',
'{postcode}',
'{zone}',
'{zone_code}',
'{country}'
);
$replace = array(
'firstname' => $order_info['payment_firstname'],
'lastname' => $order_info['payment_lastname'],
'company' => $order_info['payment_company'],
'address_1' => $order_info['payment_address_1'],
'address_2' => $order_info['payment_address_2'],
'city' => $order_info['payment_city'],
'postcode' => $order_info['payment_postcode'],
'zone' => $order_info['payment_zone'],
'zone_code' => $order_info['payment_zone_code'],
'country' => $order_info['payment_country']
);
$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))));
$data['payment_method'] = $order_info['payment_method'];
if ($order_info['shipping_address_format']) {
$format = $order_info['shipping_address_format'];
} else {
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
}
$find = array(
'{firstname}',
'{lastname}',
'{company}',
'{address_1}',
'{address_2}',
'{city}',
'{postcode}',
'{zone}',
'{zone_code}',
'{country}'
);
$replace = array(
'firstname' => $order_info['shipping_firstname'],
'lastname' => $order_info['shipping_lastname'],
'company' => $order_info['shipping_company'],
'address_1' => $order_info['shipping_address_1'],
'address_2' => $order_info['shipping_address_2'],
'city' => $order_info['shipping_city'],
'postcode' => $order_info['shipping_postcode'],
'zone' => $order_info['shipping_zone'],
'zone_code' => $order_info['shipping_zone_code'],
'country' => $order_info['shipping_country']
);
$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))));
$data['shipping_method'] = $order_info['shipping_method'];
$this->load->model('catalog/product');
$this->load->model('tool/upload');
// Products
$data['products'] = array();
$products = $this->model_account_order->getOrderProducts($this->request->get['order_id']);
foreach ($products as $product) {
$option_data = array();
$options = $this->model_account_order->getOrderOptions($this->request->get['order_id'], $product['order_product_id']);
foreach ($options as $option) {
if ($option['type'] != 'file') {
$value = $option['value'];
} else {
$upload_info = $this->model_tool_upload->getUploadByCode($option['value']);
if ($upload_info) {
$value = $upload_info['name'];
} else {
$value = '';
}
}
$option_data[] = array(
'name' => $option['name'],
'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value)
);
}
$product_info = $this->model_catalog_product->getProduct($product['product_id']);
if ($product_info) {
$reorder = $this->url->link('account/order/reorder', 'order_id=' . $order_id . '&order_product_id=' . $product['order_product_id'], true);
} else {
$reorder = '';
}
$data['products'][] = array(
'name' => $product['name'],
'model' => $product['model'],
'option' => $option_data,
'quantity' => $product['quantity'],
'price' => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']),
'total' => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? ($product['tax'] * $product['quantity']) : 0), $order_info['currency_code'], $order_info['currency_value']),
'reorder' => $reorder,
'return' => $this->url->link('account/return/add', 'order_id=' . $order_info['order_id'] . '&product_id=' . $product['product_id'], true)
);
}
// Voucher
$data['vouchers'] = array();
$vouchers = $this->model_account_order->getOrderVouchers($this->request->get['order_id']);
foreach ($vouchers as $voucher) {
$data['vouchers'][] = array(
'description' => $voucher['description'],
'amount' => $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value'])
);
}
// Totals
$data['totals'] = array();
$totals = $this->model_account_order->getOrderTotals($this->request->get['order_id']);
foreach ($totals as $total) {
$data['totals'][] = array(
'title' => $total['title'],
'text' => $this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']),
);
}
$data['comment'] = nl2br($order_info['comment']);
// History
$data['histories'] = array();
$results = $this->model_account_order->getOrderHistories($this->request->get['order_id']);
foreach ($results as $result) {
$data['histories'][] = array(
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'status' => $result['status'],
'comment' => $result['notify'] ? nl2br($result['comment']) : ''
);
}
$data['continue'] = $this->url->link('account/order', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/order_info', $data));
} else {
return new Action('error/not_found');
}
}
public function reorder() {
$this->load->language('account/order');
if (isset($this->request->get['order_id'])) {
$order_id = $this->request->get['order_id'];
} else {
$order_id = 0;
}
$this->load->model('account/order');
$order_info = $this->model_account_order->getOrder($order_id);
if ($order_info) {
if (isset($this->request->get['order_product_id'])) {
$order_product_id = $this->request->get['order_product_id'];
} else {
$order_product_id = 0;
}
$order_product_info = $this->model_account_order->getOrderProduct($order_id, $order_product_id);
if ($order_product_info) {
$this->load->model('catalog/product');
$product_info = $this->model_catalog_product->getProduct($order_product_info['product_id']);
if ($product_info) {
$option_data = array();
$order_options = $this->model_account_order->getOrderOptions($order_product_info['order_id'], $order_product_id);
foreach ($order_options as $order_option) {
if ($order_option['type'] == 'select' || $order_option['type'] == 'radio' || $order_option['type'] == 'image') {
$option_data[$order_option['product_option_id']] = $order_option['product_option_value_id'];
} elseif ($order_option['type'] == 'checkbox') {
$option_data[$order_option['product_option_id']][] = $order_option['product_option_value_id'];
} elseif ($order_option['type'] == 'text' || $order_option['type'] == 'textarea' || $order_option['type'] == 'date' || $order_option['type'] == 'datetime' || $order_option['type'] == 'time') {
$option_data[$order_option['product_option_id']] = $order_option['value'];
} elseif ($order_option['type'] == 'file') {
$option_data[$order_option['product_option_id']] = $this->encryption->encrypt($this->config->get('config_encryption'), $order_option['value']);
}
}
$this->cart->add($order_product_info['product_id'], $order_product_info['quantity'], $option_data);
$this->session->data['success'] = sprintf($this->language->get('text_success'), $this->url->link('product/product', 'product_id=' . $product_info['product_id']), $product_info['name'], $this->url->link('checkout/cart'));
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
} else {
$this->session->data['error'] = sprintf($this->language->get('error_reorder'), $order_product_info['name']);
}
}
}
$this->response->redirect($this->url->link('account/order/info', 'order_id=' . $order_id));
}
}
@@ -0,0 +1,96 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountPassword extends Controller {
private $error = array();
public function index() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/password', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->language('account/password');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->load->model('account/customer');
$this->model_account_customer->editPassword($this->customer->getEmail(), $this->request->post['password']);
$this->session->data['success'] = $this->language->get('text_success');
$this->response->redirect($this->url->link('account/account', '', true));
}
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('account/password', '', true)
);
if (isset($this->error['password'])) {
$data['error_password'] = $this->error['password'];
} else {
$data['error_password'] = '';
}
if (isset($this->error['confirm'])) {
$data['error_confirm'] = $this->error['confirm'];
} else {
$data['error_confirm'] = '';
}
$data['action'] = $this->url->link('account/password', '', true);
if (isset($this->request->post['password'])) {
$data['password'] = $this->request->post['password'];
} else {
$data['password'] = '';
}
if (isset($this->request->post['confirm'])) {
$data['confirm'] = $this->request->post['confirm'];
} else {
$data['confirm'] = '';
}
$data['back'] = $this->url->link('account/account', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/password', $data));
}
protected function validate() {
if ((utf8_strlen(html_entity_decode($this->request->post['password'], ENT_QUOTES, 'UTF-8')) < 4) || (utf8_strlen(html_entity_decode($this->request->post['password'], ENT_QUOTES, 'UTF-8')) > 40)) {
$this->error['password'] = $this->language->get('error_password');
}
if ($this->request->post['confirm'] != $this->request->post['password']) {
$this->error['confirm'] = $this->language->get('error_confirm');
}
return !$this->error;
}
}
@@ -0,0 +1,222 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountRecurring extends Controller {
public function index() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/recurring', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->language('account/recurring');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$url = '';
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/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('account/recurring', $url, true)
);
if (isset($this->request->get['page'])) {
$page = (int)$this->request->get['page'];
} else {
$page = 1;
}
$data['recurrings'] = array();
$this->load->model('account/recurring');
$recurring_total = $this->model_account_recurring->getTotalOrderRecurrings();
$results = $this->model_account_recurring->getOrderRecurrings(($page - 1) * 10, 10);
foreach ($results as $result) {
if ($result['status']) {
$status = $this->language->get('text_status_' . $result['status']);
} else {
$status = '';
}
$data['recurrings'][] = array(
'order_recurring_id' => $result['order_recurring_id'],
'product' => $result['product_name'],
'status' => $status,
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'view' => $this->url->link('account/recurring/info', 'order_recurring_id=' . $result['order_recurring_id'], true),
);
}
$pagination = new Pagination();
$pagination->total = $recurring_total;
$pagination->page = $page;
$pagination->limit = 10;
$pagination->text = $this->language->get('text_pagination');
$pagination->url = $this->url->link('account/recurring', 'page={page}', true);
$data['pagination'] = $pagination->render();
$data['continue'] = $this->url->link('account/account', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/recurring_list', $data));
}
public function info() {
$this->load->language('account/recurring');
if (isset($this->request->get['order_recurring_id'])) {
$order_recurring_id = $this->request->get['order_recurring_id'];
} else {
$order_recurring_id = 0;
}
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/recurring/info', 'order_recurring_id=' . $order_recurring_id, true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->model('account/recurring');
$recurring_info = $this->model_account_recurring->getOrderRecurring($order_recurring_id);
if ($recurring_info) {
$this->document->setTitle($this->language->get('text_recurring'));
$url = '';
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/home'),
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true),
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('account/recurring', $url, true),
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_recurring'),
'href' => $this->url->link('account/recurring/info', 'order_recurring_id=' . $this->request->get['order_recurring_id'] . $url, true),
);
$data['order_recurring_id'] = (int)$this->request->get['order_recurring_id'];
$data['date_added'] = date($this->language->get('date_format_short'), strtotime($recurring_info['date_added']));
if ($recurring_info['status']) {
$data['status'] = $this->language->get('text_status_' . $recurring_info['status']);
} else {
$data['status'] = '';
}
$data['payment_method'] = $recurring_info['payment_method'];
$data['order_id'] = $recurring_info['order_id'];
$data['product_name'] = $recurring_info['product_name'];
$data['product_quantity'] = $recurring_info['product_quantity'];
$data['recurring_description'] = $recurring_info['recurring_description'];
$data['reference'] = $recurring_info['reference'];
// Transactions
$data['transactions'] = array();
$results = $this->model_account_recurring->getOrderRecurringTransactions($this->request->get['order_recurring_id']);
foreach ($results as $result) {
$data['transactions'][] = array(
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'type' => $result['type'],
'amount' => $this->currency->format($result['amount'], $recurring_info['currency_code'])
);
}
$data['order'] = $this->url->link('account/order/info', 'order_id=' . $recurring_info['order_id'], true);
$data['product'] = $this->url->link('product/product', 'product_id=' . $recurring_info['product_id'], true);
$data['recurring'] = $this->load->controller('extension/recurring/' . $recurring_info['payment_code']);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/recurring_info', $data));
} else {
$this->document->setTitle($this->language->get('text_recurring'));
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('account/recurring', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_recurring'),
'href' => $this->url->link('account/recurring/info', 'order_recurring_id=' . $order_recurring_id, true)
);
$data['continue'] = $this->url->link('account/recurring', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('error/not_found', $data));
}
}
}
@@ -0,0 +1,322 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountRegister extends Controller {
private $error = array();
public function index() {
if ($this->customer->isLogged()) {
$this->response->redirect($this->url->link('account/account', '', true));
}
$this->load->language('account/register');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$this->document->addScript('store/view/javascript/jquery/datetimepicker/moment/moment.min.js');
$this->document->addScript('store/view/javascript/jquery/datetimepicker/moment/moment-with-locales.min.js');
$this->document->addScript('store/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js');
$this->document->addStyle('store/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css');
$this->load->model('account/customer');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$customer_id = $this->model_account_customer->addCustomer($this->request->post);
// Clear any previous login attempts for unregistered accounts.
$this->model_account_customer->deleteLoginAttempts($this->request->post['email']);
$this->customer->login($this->request->post['email'], $this->request->post['password']);
unset($this->session->data['guest']);
$this->response->redirect($this->url->link('account/success'));
}
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_register'),
'href' => $this->url->link('account/register', '', true)
);
$data['text_account_already'] = sprintf($this->language->get('text_account_already'), $this->url->link('account/login', '', true));
if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
if (isset($this->error['firstname'])) {
$data['error_firstname'] = $this->error['firstname'];
} else {
$data['error_firstname'] = '';
}
if (isset($this->error['lastname'])) {
$data['error_lastname'] = $this->error['lastname'];
} else {
$data['error_lastname'] = '';
}
if (isset($this->error['email'])) {
$data['error_email'] = $this->error['email'];
} else {
$data['error_email'] = '';
}
if (isset($this->error['telephone'])) {
$data['error_telephone'] = $this->error['telephone'];
} else {
$data['error_telephone'] = '';
}
if (isset($this->error['custom_field'])) {
$data['error_custom_field'] = $this->error['custom_field'];
} else {
$data['error_custom_field'] = array();
}
if (isset($this->error['password'])) {
$data['error_password'] = $this->error['password'];
} else {
$data['error_password'] = '';
}
if (isset($this->error['confirm'])) {
$data['error_confirm'] = $this->error['confirm'];
} else {
$data['error_confirm'] = '';
}
$data['action'] = $this->url->link('account/register', '', true);
$data['customer_groups'] = array();
if (is_array($this->config->get('config_customer_group_display'))) {
$this->load->model('account/customer_group');
$customer_groups = $this->model_account_customer_group->getCustomerGroups();
foreach ($customer_groups as $customer_group) {
if (in_array($customer_group['customer_group_id'], $this->config->get('config_customer_group_display'))) {
$data['customer_groups'][] = $customer_group;
}
}
}
if (isset($this->request->post['customer_group_id'])) {
$data['customer_group_id'] = $this->request->post['customer_group_id'];
} else {
$data['customer_group_id'] = $this->config->get('config_customer_group_id');
}
if (isset($this->request->post['firstname'])) {
$data['firstname'] = $this->request->post['firstname'];
} else {
$data['firstname'] = '';
}
if (isset($this->request->post['lastname'])) {
$data['lastname'] = $this->request->post['lastname'];
} else {
$data['lastname'] = '';
}
if (isset($this->request->post['email'])) {
$data['email'] = $this->request->post['email'];
} else {
$data['email'] = '';
}
if (isset($this->request->post['telephone'])) {
$data['telephone'] = $this->request->post['telephone'];
} else {
$data['telephone'] = '';
}
// Custom Fields
$data['custom_fields'] = array();
$this->load->model('account/custom_field');
$custom_fields = $this->model_account_custom_field->getCustomFields();
foreach ($custom_fields as $custom_field) {
if ($custom_field['location'] == 'account') {
$data['custom_fields'][] = $custom_field;
}
}
if (isset($this->request->post['custom_field']['account'])) {
$data['register_custom_field'] = $this->request->post['custom_field']['account'];
} else {
$data['register_custom_field'] = array();
}
if (isset($this->request->post['password'])) {
$data['password'] = $this->request->post['password'];
} else {
$data['password'] = '';
}
if (isset($this->request->post['confirm'])) {
$data['confirm'] = $this->request->post['confirm'];
} else {
$data['confirm'] = '';
}
if (isset($this->request->post['newsletter'])) {
$data['newsletter'] = $this->request->post['newsletter'];
} else {
$data['newsletter'] = '';
}
// Captcha
if ($this->config->get('captcha_' . $this->config->get('config_captcha') . '_status') && in_array('register', (array)$this->config->get('config_captcha_page'))) {
$data['captcha'] = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha'), $this->error);
} else {
$data['captcha'] = '';
}
if ($this->config->get('config_account_id')) {
$this->load->model('catalog/information');
$information_info = $this->model_catalog_information->getInformation($this->config->get('config_account_id'));
if ($information_info) {
$data['text_agree'] = sprintf($this->language->get('text_agree'), $this->url->link('information/information/agree', 'information_id=' . $this->config->get('config_account_id'), true), $information_info['title']);
} else {
$data['text_agree'] = '';
}
} else {
$data['text_agree'] = '';
}
if (isset($this->request->post['agree'])) {
$data['agree'] = $this->request->post['agree'];
} else {
$data['agree'] = false;
}
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/register', $data));
}
private function validate() {
if ((utf8_strlen(trim($this->request->post['firstname'])) < 1) || (utf8_strlen(trim($this->request->post['firstname'])) > 32)) {
$this->error['firstname'] = $this->language->get('error_firstname');
}
if ((utf8_strlen(trim($this->request->post['lastname'])) < 1) || (utf8_strlen(trim($this->request->post['lastname'])) > 32)) {
$this->error['lastname'] = $this->language->get('error_lastname');
}
if ((utf8_strlen($this->request->post['email']) > 96) || !filter_var($this->request->post['email'], FILTER_VALIDATE_EMAIL)) {
$this->error['email'] = $this->language->get('error_email');
}
if ($this->model_account_customer->getTotalCustomersByEmail($this->request->post['email'])) {
$this->error['warning'] = $this->language->get('error_exists');
}
if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 32)) {
$this->error['telephone'] = $this->language->get('error_telephone');
}
// Customer Group
if (isset($this->request->post['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display'))) {
$customer_group_id = $this->request->post['customer_group_id'];
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
// Custom field validation
$this->load->model('account/custom_field');
$custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id);
foreach ($custom_fields as $custom_field) {
if ($custom_field['location'] == 'account') {
if ($custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']])) {
$this->error['custom_field'][$custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']);
} elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) {
$this->error['custom_field'][$custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']);
}
}
}
if ((utf8_strlen(html_entity_decode($this->request->post['password'], ENT_QUOTES, 'UTF-8')) < 4) || (utf8_strlen(html_entity_decode($this->request->post['password'], ENT_QUOTES, 'UTF-8')) > 40)) {
$this->error['password'] = $this->language->get('error_password');
}
if ($this->request->post['confirm'] != $this->request->post['password']) {
$this->error['confirm'] = $this->language->get('error_confirm');
}
// Captcha
if ($this->config->get('captcha_' . $this->config->get('config_captcha') . '_status') && in_array('register', (array)$this->config->get('config_captcha_page'))) {
$captcha = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha') . '/validate');
if ($captcha) {
$this->error['captcha'] = $captcha;
}
}
// Agree to terms
if ($this->config->get('config_account_id')) {
$this->load->model('catalog/information');
$information_info = $this->model_catalog_information->getInformation($this->config->get('config_account_id'));
if ($information_info && !isset($this->request->post['agree'])) {
$this->error['warning'] = sprintf($this->language->get('error_agree'), $information_info['title']);
}
}
return !$this->error;
}
public function customfield() {
$json = array();
$this->load->model('account/custom_field');
// Customer Group
if (isset($this->request->get['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->get['customer_group_id'], $this->config->get('config_customer_group_display'))) {
$customer_group_id = $this->request->get['customer_group_id'];
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id);
foreach ($custom_fields as $custom_field) {
$json[] = array(
'custom_field_id' => $custom_field['custom_field_id'],
'required' => $custom_field['required']
);
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}
+113
View File
@@ -0,0 +1,113 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountReset extends Controller {
private $error = array();
public function index() {
if ($this->customer->isLogged()) {
$this->response->redirect($this->url->link('account/account', '', true));
}
if (isset($this->request->get['code'])) {
$code = $this->request->get['code'];
} else {
$code = '';
}
$this->load->model('account/customer');
$customer_info = $this->model_account_customer->getCustomerByCode($code);
if ($customer_info) {
$this->load->language('account/reset');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->model_account_customer->editPassword($customer_info['email'], $this->request->post['password']);
// Clear any previous login attempts
$this->model_account_customer->deleteLoginAttempts($customer_info['email']);
$this->session->data['success'] = $this->language->get('text_success');
$this->response->redirect($this->url->link('account/login', '', true));
}
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('account/reset', '', true)
);
if (isset($this->error['password'])) {
$data['error_password'] = $this->error['password'];
} else {
$data['error_password'] = '';
}
if (isset($this->error['confirm'])) {
$data['error_confirm'] = $this->error['confirm'];
} else {
$data['error_confirm'] = '';
}
$data['action'] = $this->url->link('account/reset', 'code=' . $code, true);
$data['back'] = $this->url->link('account/login', '', true);
if (isset($this->request->post['password'])) {
$data['password'] = $this->request->post['password'];
} else {
$data['password'] = '';
}
if (isset($this->request->post['confirm'])) {
$data['confirm'] = $this->request->post['confirm'];
} else {
$data['confirm'] = '';
}
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/reset', $data));
} else {
$this->load->language('account/reset');
$this->session->data['error'] = $this->language->get('error_code');
return new Action('account/login');
}
}
protected function validate() {
if ((utf8_strlen(html_entity_decode($this->request->post['password'], ENT_QUOTES, 'UTF-8')) < 4) || (utf8_strlen(html_entity_decode($this->request->post['password'], ENT_QUOTES, 'UTF-8')) > 40)) {
$this->error['password'] = $this->language->get('error_password');
}
if ($this->request->post['confirm'] != $this->request->post['password']) {
$this->error['confirm'] = $this->language->get('error_confirm');
}
return !$this->error;
}
}
+547
View File
@@ -0,0 +1,547 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountReturn extends Controller {
private $error = array();
public function index() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/return', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->language('account/return');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$url = '';
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('account/return', $url, true)
);
$this->load->model('account/return');
if (isset($this->request->get['page'])) {
$page = (int)$this->request->get['page'];
} else {
$page = 1;
}
$data['returns'] = array();
$return_total = $this->model_account_return->getTotalReturns();
$results = $this->model_account_return->getReturns(($page - 1) * 10, 10);
foreach ($results as $result) {
$data['returns'][] = array(
'return_id' => $result['return_id'],
'order_id' => $result['order_id'],
'name' => $result['firstname'] . ' ' . $result['lastname'],
'status' => $result['status'],
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'href' => $this->url->link('account/return/info', 'return_id=' . $result['return_id'] . $url, true)
);
}
$pagination = new Pagination();
$pagination->total = $return_total;
$pagination->page = $page;
$pagination->limit = $this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit');
$pagination->url = $this->url->link('account/return', 'page={page}', true);
$data['pagination'] = $pagination->render();
$data['results'] = sprintf($this->language->get('text_pagination'), ($return_total) ? (($page - 1) * $this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit')) + 1 : 0, ((($page - 1) * $this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit')) > ($return_total - $this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit'))) ? $return_total : ((($page - 1) * $this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit')) + $this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit')), $return_total, ceil($return_total / $this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit')));
$data['continue'] = $this->url->link('account/account', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/return_list', $data));
}
public function info() {
$this->load->language('account/return');
if (isset($this->request->get['return_id'])) {
$return_id = $this->request->get['return_id'];
} else {
$return_id = 0;
}
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/return/info', 'return_id=' . $return_id, true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->model('account/return');
$return_info = $this->model_account_return->getReturn($return_id);
if ($return_info) {
$this->document->setTitle($this->language->get('text_return'));
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$url = '';
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('account/return', $url, true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_return'),
'href' => $this->url->link('account/return/info', 'return_id=' . $this->request->get['return_id'] . $url, true)
);
$data['return_id'] = $return_info['return_id'];
$data['order_id'] = $return_info['order_id'];
$data['date_ordered'] = date($this->language->get('date_format_short'), strtotime($return_info['date_ordered']));
$data['date_added'] = date($this->language->get('date_format_short'), strtotime($return_info['date_added']));
$data['firstname'] = $return_info['firstname'];
$data['lastname'] = $return_info['lastname'];
$data['email'] = $return_info['email'];
$data['telephone'] = $return_info['telephone'];
$data['product'] = $return_info['product'];
$data['model'] = $return_info['model'];
$data['quantity'] = $return_info['quantity'];
$data['reason'] = $return_info['reason'];
$data['opened'] = $return_info['opened'] ? $this->language->get('text_yes') : $this->language->get('text_no');
$data['comment'] = nl2br($return_info['comment']);
$data['action'] = $return_info['action'];
$data['histories'] = array();
$results = $this->model_account_return->getReturnHistories($this->request->get['return_id']);
foreach ($results as $result) {
$data['histories'][] = array(
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'status' => $result['status'],
'comment' => nl2br($result['comment'])
);
}
$data['continue'] = $this->url->link('account/return', $url, true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/return_info', $data));
} else {
$this->document->setTitle($this->language->get('text_return'));
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('account/return', '', true)
);
$url = '';
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_return'),
'href' => $this->url->link('account/return/info', 'return_id=' . $return_id . $url, true)
);
$data['continue'] = $this->url->link('account/return', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('error/not_found', $data));
}
}
public function add() {
$this->load->language('account/return');
$this->load->model('account/return');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->model_account_return->addReturn($this->request->post);
$this->response->redirect($this->url->link('account/return/success', '', true));
}
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$this->document->addScript('store/view/javascript/jquery/datetimepicker/moment/moment.min.js');
$this->document->addScript('store/view/javascript/jquery/datetimepicker/moment/moment-with-locales.min.js');
$this->document->addScript('store/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js');
$this->document->addStyle('store/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('account/return/add', '', true)
);
if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
if (isset($this->error['order_id'])) {
$data['error_order_id'] = $this->error['order_id'];
} else {
$data['error_order_id'] = '';
}
if (isset($this->error['firstname'])) {
$data['error_firstname'] = $this->error['firstname'];
} else {
$data['error_firstname'] = '';
}
if (isset($this->error['lastname'])) {
$data['error_lastname'] = $this->error['lastname'];
} else {
$data['error_lastname'] = '';
}
if (isset($this->error['email'])) {
$data['error_email'] = $this->error['email'];
} else {
$data['error_email'] = '';
}
if (isset($this->error['telephone'])) {
$data['error_telephone'] = $this->error['telephone'];
} else {
$data['error_telephone'] = '';
}
if (isset($this->error['product'])) {
$data['error_product'] = $this->error['product'];
} else {
$data['error_product'] = '';
}
if (isset($this->error['model'])) {
$data['error_model'] = $this->error['model'];
} else {
$data['error_model'] = '';
}
if (isset($this->error['reason'])) {
$data['error_reason'] = $this->error['reason'];
} else {
$data['error_reason'] = '';
}
$data['action'] = $this->url->link('account/return/add', '', true);
$this->load->model('account/order');
if (isset($this->request->get['order_id'])) {
$order_info = $this->model_account_order->getOrder($this->request->get['order_id']);
}
$this->load->model('catalog/product');
if (isset($this->request->get['product_id'])) {
$product_info = $this->model_catalog_product->getProduct($this->request->get['product_id']);
}
if (isset($this->request->post['order_id'])) {
$data['order_id'] = $this->request->post['order_id'];
} elseif (!empty($order_info)) {
$data['order_id'] = $order_info['order_id'];
} else {
$data['order_id'] = '';
}
if (isset($this->request->post['product_id'])) {
$data['product_id'] = $this->request->post['product_id'];
} elseif (!empty($product_info)) {
$data['product_id'] = $product_info['product_id'];
} else {
$data['product_id'] = '';
}
if (isset($this->request->post['date_ordered'])) {
$data['date_ordered'] = $this->request->post['date_ordered'];
} elseif (!empty($order_info)) {
$data['date_ordered'] = date('Y-m-d', strtotime($order_info['date_added']));
} else {
$data['date_ordered'] = '';
}
if (isset($this->request->post['firstname'])) {
$data['firstname'] = $this->request->post['firstname'];
} elseif (!empty($order_info)) {
$data['firstname'] = $order_info['firstname'];
} else {
$data['firstname'] = $this->customer->getFirstName();
}
if (isset($this->request->post['lastname'])) {
$data['lastname'] = $this->request->post['lastname'];
} elseif (!empty($order_info)) {
$data['lastname'] = $order_info['lastname'];
} else {
$data['lastname'] = $this->customer->getLastName();
}
if (isset($this->request->post['email'])) {
$data['email'] = $this->request->post['email'];
} elseif (!empty($order_info)) {
$data['email'] = $order_info['email'];
} else {
$data['email'] = $this->customer->getEmail();
}
if (isset($this->request->post['telephone'])) {
$data['telephone'] = $this->request->post['telephone'];
} elseif (!empty($order_info)) {
$data['telephone'] = $order_info['telephone'];
} else {
$data['telephone'] = $this->customer->getTelephone();
}
if (isset($this->request->post['product'])) {
$data['product'] = $this->request->post['product'];
} elseif (!empty($product_info)) {
$data['product'] = $product_info['name'];
} else {
$data['product'] = '';
}
if (isset($this->request->post['model'])) {
$data['model'] = $this->request->post['model'];
} elseif (!empty($product_info)) {
$data['model'] = $product_info['model'];
} else {
$data['model'] = '';
}
if (isset($this->request->post['quantity'])) {
$data['quantity'] = $this->request->post['quantity'];
} else {
$data['quantity'] = 1;
}
if (isset($this->request->post['opened'])) {
$data['opened'] = $this->request->post['opened'];
} else {
$data['opened'] = false;
}
if (isset($this->request->post['return_reason_id'])) {
$data['return_reason_id'] = $this->request->post['return_reason_id'];
} else {
$data['return_reason_id'] = '';
}
$this->load->model('localisation/return_reason');
$data['return_reasons'] = $this->model_localisation_return_reason->getReturnReasons();
if (isset($this->request->post['comment'])) {
$data['comment'] = $this->request->post['comment'];
} else {
$data['comment'] = '';
}
// Captcha
if ($this->config->get('captcha_' . $this->config->get('config_captcha') . '_status') && in_array('return', (array)$this->config->get('config_captcha_page'))) {
$data['captcha'] = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha'), $this->error);
} else {
$data['captcha'] = '';
}
if ($this->config->get('config_return_id')) {
$this->load->model('catalog/information');
$information_info = $this->model_catalog_information->getInformation($this->config->get('config_return_id'));
if ($information_info) {
$data['text_agree'] = sprintf($this->language->get('text_agree'), $this->url->link('information/information/agree', 'information_id=' . $this->config->get('config_return_id'), true), $information_info['title']);
} else {
$data['text_agree'] = '';
}
} else {
$data['text_agree'] = '';
}
if (isset($this->request->post['agree'])) {
$data['agree'] = $this->request->post['agree'];
} else {
$data['agree'] = false;
}
$data['back'] = $this->url->link('account/account', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/return_form', $data));
}
protected function validate() {
if (!$this->request->post['order_id']) {
$this->error['order_id'] = $this->language->get('error_order_id');
}
if ((utf8_strlen(trim($this->request->post['firstname'])) < 1) || (utf8_strlen(trim($this->request->post['firstname'])) > 32)) {
$this->error['firstname'] = $this->language->get('error_firstname');
}
if ((utf8_strlen(trim($this->request->post['lastname'])) < 1) || (utf8_strlen(trim($this->request->post['lastname'])) > 32)) {
$this->error['lastname'] = $this->language->get('error_lastname');
}
if ((utf8_strlen($this->request->post['email']) > 96) || !filter_var($this->request->post['email'], FILTER_VALIDATE_EMAIL)) {
$this->error['email'] = $this->language->get('error_email');
}
if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 32)) {
$this->error['telephone'] = $this->language->get('error_telephone');
}
if ((utf8_strlen($this->request->post['product']) < 1) || (utf8_strlen($this->request->post['product']) > 255)) {
$this->error['product'] = $this->language->get('error_product');
}
if ((utf8_strlen($this->request->post['model']) < 1) || (utf8_strlen($this->request->post['model']) > 64)) {
$this->error['model'] = $this->language->get('error_model');
}
if (empty($this->request->post['return_reason_id'])) {
$this->error['reason'] = $this->language->get('error_reason');
}
if ($this->config->get('captcha_' . $this->config->get('config_captcha') . '_status') && in_array('return', (array)$this->config->get('config_captcha_page'))) {
$captcha = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha') . '/validate');
if ($captcha) {
$this->error['captcha'] = $captcha;
}
}
if ($this->config->get('config_return_id')) {
$this->load->model('catalog/information');
$information_info = $this->model_catalog_information->getInformation($this->config->get('config_return_id'));
if ($information_info && !isset($this->request->post['agree'])) {
$this->error['warning'] = sprintf($this->language->get('error_agree'), $information_info['title']);
}
}
return !$this->error;
}
public function success() {
$this->load->language('account/return');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('account/return', '', true)
);
$data['continue'] = $this->url->link('common/home');
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('common/success', $data));
}
}
@@ -0,0 +1,89 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountReward extends Controller {
public function index() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/reward', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->language('account/reward');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_reward'),
'href' => $this->url->link('account/reward', '', true)
);
$this->load->model('account/reward');
if (isset($this->request->get['page'])) {
$page = (int)$this->request->get['page'];
} else {
$page = 1;
}
$data['rewards'] = array();
$filter_data = array(
'sort' => 'date_added',
'order' => 'DESC',
'start' => ($page - 1) * 10,
'limit' => 10
);
$reward_total = $this->model_account_reward->getTotalRewards();
$results = $this->model_account_reward->getRewards($filter_data);
foreach ($results as $result) {
$data['rewards'][] = array(
'order_id' => $result['order_id'],
'points' => $result['points'],
'description' => $result['description'],
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'href' => $this->url->link('account/order/info', 'order_id=' . $result['order_id'], true)
);
}
$pagination = new Pagination();
$pagination->total = $reward_total;
$pagination->page = $page;
$pagination->limit = 10;
$pagination->url = $this->url->link('account/reward', 'page={page}', true);
$data['pagination'] = $pagination->render();
$data['results'] = sprintf($this->language->get('text_pagination'), ($reward_total) ? (($page - 1) * 10) + 1 : 0, ((($page - 1) * 10) > ($reward_total - 10)) ? $reward_total : ((($page - 1) * 10) + 10), $reward_total, ceil($reward_total / 10));
$data['total'] = (int)$this->customer->getRewardPoints();
$data['continue'] = $this->url->link('account/account', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/reward', $data));
}
}
@@ -0,0 +1,50 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountSuccess extends Controller {
public function index() {
$this->load->language('account/success');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_success'),
'href' => $this->url->link('account/success')
);
if ($this->customer->isLogged()) {
$data['text_message'] = sprintf($this->language->get('text_message'), $this->url->link('information/contact'));
} else {
$data['text_message'] = sprintf($this->language->get('text_approval'), $this->config->get('config_name'), $this->url->link('information/contact'));
}
if ($this->cart->hasProducts()) {
$data['continue'] = $this->url->link('checkout/cart');
} else {
$data['continue'] = $this->url->link('account/account', '', true);
}
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('common/success', $data));
}
}
@@ -0,0 +1,90 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountTracking extends Controller {
public function index() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/tracking', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->model('account/customer');
$affiliate_info = $this->model_account_customer->getAffiliate($this->customer->getId());
if ($affiliate_info) {
$this->load->language('account/tracking');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('account/tracking', '', true)
);
$data['text_description'] = sprintf($this->language->get('text_description'), $this->config->get('config_name'));
$data['code'] = $affiliate_info['tracking'];
$data['continue'] = $this->url->link('account/account', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/tracking', $data));
} else {
return new Action('error/not_found');
}
}
public function autocomplete() {
$json = array();
if (isset($this->request->get['filter_name'])) {
if (isset($this->request->get['tracking'])) {
$tracking = $this->request->get['tracking'];
} else {
$tracking = '';
}
$this->load->model('catalog/product');
$filter_data = array(
'filter_name' => $this->request->get['filter_name'],
'start' => 0,
'limit' => 5
);
$results = $this->model_catalog_product->getProducts($filter_data);
foreach ($results as $result) {
$json[] = array(
'name' => strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8')),
'link' => str_replace('&amp;', '&', $this->url->link('product/product', 'product_id=' . $result['product_id'] . '&tracking=' . $tracking))
);
}
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}
@@ -0,0 +1,89 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountTransaction extends Controller {
public function index() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/transaction', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->language('account/transaction');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_transaction'),
'href' => $this->url->link('account/transaction', '', true)
);
$this->load->model('account/transaction');
$data['column_amount'] = sprintf($this->language->get('column_amount'), $this->config->get('config_currency'));
if (isset($this->request->get['page'])) {
$page = (int)$this->request->get['page'];
} else {
$page = 1;
}
$data['transactions'] = array();
$filter_data = array(
'sort' => 'date_added',
'order' => 'DESC',
'start' => ($page - 1) * 10,
'limit' => 10
);
$transaction_total = $this->model_account_transaction->getTotalTransactions();
$results = $this->model_account_transaction->getTransactions($filter_data);
foreach ($results as $result) {
$data['transactions'][] = array(
'amount' => $this->currency->format($result['amount'], $this->config->get('config_currency')),
'description' => $result['description'],
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added']))
);
}
$pagination = new Pagination();
$pagination->total = $transaction_total;
$pagination->page = $page;
$pagination->limit = 10;
$pagination->url = $this->url->link('account/transaction', 'page={page}', true);
$data['pagination'] = $pagination->render();
$data['results'] = sprintf($this->language->get('text_pagination'), ($transaction_total) ? (($page - 1) * 10) + 1 : 0, ((($page - 1) * 10) > ($transaction_total - 10)) ? $transaction_total : ((($page - 1) * 10) + 10), $transaction_total, ceil($transaction_total / 10));
$data['total'] = $this->currency->format($this->customer->getBalance(), $this->session->data['currency']);
$data['continue'] = $this->url->link('account/account', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/transaction', $data));
}
}
+223
View File
@@ -0,0 +1,223 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountVoucher extends Controller {
private $error = array();
public function index() {
$this->load->language('account/voucher');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
if (!isset($this->session->data['vouchers'])) {
$this->session->data['vouchers'] = array();
}
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->session->data['vouchers'][mt_rand()] = array(
'description' => sprintf($this->language->get('text_for'), $this->currency->format($this->request->post['amount'], $this->session->data['currency'], 1.0), $this->request->post['to_name']),
'to_name' => $this->request->post['to_name'],
'to_email' => $this->request->post['to_email'],
'from_name' => $this->request->post['from_name'],
'from_email' => $this->request->post['from_email'],
'voucher_theme_id' => $this->request->post['voucher_theme_id'],
'message' => $this->request->post['message'],
'amount' => $this->currency->convert($this->request->post['amount'], $this->session->data['currency'], $this->config->get('config_currency'))
);
$this->response->redirect($this->url->link('account/voucher/success'));
}
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_voucher'),
'href' => $this->url->link('account/voucher', '', true)
);
$data['help_amount'] = sprintf($this->language->get('help_amount'), $this->currency->format($this->config->get('config_voucher_min'), $this->session->data['currency']), $this->currency->format($this->config->get('config_voucher_max'), $this->session->data['currency']));
if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
if (isset($this->error['to_name'])) {
$data['error_to_name'] = $this->error['to_name'];
} else {
$data['error_to_name'] = '';
}
if (isset($this->error['to_email'])) {
$data['error_to_email'] = $this->error['to_email'];
} else {
$data['error_to_email'] = '';
}
if (isset($this->error['from_name'])) {
$data['error_from_name'] = $this->error['from_name'];
} else {
$data['error_from_name'] = '';
}
if (isset($this->error['from_email'])) {
$data['error_from_email'] = $this->error['from_email'];
} else {
$data['error_from_email'] = '';
}
if (isset($this->error['theme'])) {
$data['error_theme'] = $this->error['theme'];
} else {
$data['error_theme'] = '';
}
if (isset($this->error['amount'])) {
$data['error_amount'] = $this->error['amount'];
} else {
$data['error_amount'] = '';
}
$data['action'] = $this->url->link('account/voucher', '', true);
if (isset($this->request->post['to_name'])) {
$data['to_name'] = $this->request->post['to_name'];
} else {
$data['to_name'] = '';
}
if (isset($this->request->post['to_email'])) {
$data['to_email'] = $this->request->post['to_email'];
} else {
$data['to_email'] = '';
}
if (isset($this->request->post['from_name'])) {
$data['from_name'] = $this->request->post['from_name'];
} elseif ($this->customer->isLogged()) {
$data['from_name'] = $this->customer->getFirstName() . ' ' . $this->customer->getLastName();
} else {
$data['from_name'] = '';
}
if (isset($this->request->post['from_email'])) {
$data['from_email'] = $this->request->post['from_email'];
} elseif ($this->customer->isLogged()) {
$data['from_email'] = $this->customer->getEmail();
} else {
$data['from_email'] = '';
}
$this->load->model('extension/total/voucher_theme');
$data['voucher_themes'] = $this->model_extension_total_voucher_theme->getVoucherThemes();
if (isset($this->request->post['voucher_theme_id'])) {
$data['voucher_theme_id'] = $this->request->post['voucher_theme_id'];
} else {
$data['voucher_theme_id'] = '';
}
if (isset($this->request->post['message'])) {
$data['message'] = $this->request->post['message'];
} else {
$data['message'] = '';
}
if (isset($this->request->post['amount'])) {
$data['amount'] = $this->request->post['amount'];
} else {
$data['amount'] = $this->currency->format($this->config->get('config_voucher_min'), $this->config->get('config_currency'), false, false);
}
if (isset($this->request->post['agree'])) {
$data['agree'] = $this->request->post['agree'];
} else {
$data['agree'] = false;
}
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/voucher', $data));
}
public function success() {
$this->load->language('account/voucher');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('account/voucher')
);
$data['continue'] = $this->url->link('checkout/cart');
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('common/success', $data));
}
protected function validate() {
if ((utf8_strlen($this->request->post['to_name']) < 1) || (utf8_strlen($this->request->post['to_name']) > 64)) {
$this->error['to_name'] = $this->language->get('error_to_name');
}
if ((utf8_strlen($this->request->post['to_email']) > 96) || !filter_var($this->request->post['to_email'], FILTER_VALIDATE_EMAIL)) {
$this->error['to_email'] = $this->language->get('error_email');
}
if ((utf8_strlen($this->request->post['from_name']) < 1) || (utf8_strlen($this->request->post['from_name']) > 64)) {
$this->error['from_name'] = $this->language->get('error_from_name');
}
if ((utf8_strlen($this->request->post['from_email']) > 96) || !filter_var($this->request->post['from_email'], FILTER_VALIDATE_EMAIL)) {
$this->error['from_email'] = $this->language->get('error_email');
}
if (!isset($this->request->post['voucher_theme_id'])) {
$this->error['theme'] = $this->language->get('error_theme');
}
if ((!isset($this->request->post['amount'])) || (!is_numeric($this->request->post['amount'])) || ($this->currency->convert($this->request->post['amount'], $this->session->data['currency'], $this->config->get('config_currency')) < $this->config->get('config_voucher_min')) || ($this->currency->convert($this->request->post['amount'], $this->session->data['currency'], $this->config->get('config_currency')) > $this->config->get('config_voucher_max'))) {
$this->error['amount'] = sprintf($this->language->get('error_amount'), $this->currency->format($this->config->get('config_voucher_min'), $this->session->data['currency']), $this->currency->format($this->config->get('config_voucher_max'), $this->session->data['currency']));
}
if (!isset($this->request->post['agree'])) {
$this->error['warning'] = $this->language->get('error_agree');
}
return !$this->error;
}
}
@@ -0,0 +1,195 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerAccountWishList extends Controller {
public function index() {
if (1 == 2) {
$this->session->data['redirect'] = $this->url->link('account/wishlist', '', true);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->load->language('account/wishlist');
$this->load->model('account/wishlist');
$this->load->model('catalog/product');
$this->load->model('tool/image');
if (isset($this->request->get['remove'])) {
// Remove Wishlist
$this->model_account_wishlist->deleteWishlist($this->request->get['remove']);
$this->session->data['success'] = $this->language->get('text_remove');
$this->response->redirect($this->url->link('account/wishlist'));
}
$this->document->setTitle($this->language->get('heading_title'));
$this->document->setRobots('noindex,follow');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
/*
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', true)
);
*/
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('account/wishlist')
);
if (isset($this->session->data['success'])) {
$data['success'] = $this->session->data['success'];
unset($this->session->data['success']);
} else {
$data['success'] = '';
}
$data['products'] = array();
$results = $this->session->data['wishlist'] ? $this->session->data['wishlist'] : [];
foreach ($results as $result) {
$product_info = $this->model_catalog_product->getProduct($result);
if ($product_info) {
if ($product_info['image']) {
$image = $this->model_tool_image->resize($product_info['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_wishlist_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_wishlist_height'));
} else {
$image = false;
}
if ($product_info['quantity'] <= 0) {
$stock = $product_info['stock_status'];
} elseif ($this->config->get('config_stock_display')) {
$stock = $product_info['quantity'];
} else {
$stock = $this->language->get('text_instock');
}
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$price = false;
}
if ((float)$product_info['special']) {
$special = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$special = false;
}
$data['products'][] = array(
'product_id' => $product_info['product_id'],
'thumb' => $image,
'name' => $product_info['name'],
'model' => $product_info['model'],
'stock' => $stock,
'price' => $price,
'special' => $special,
'href' => $this->url->link('product/product', 'product_id=' . $product_info['product_id']),
'remove' => $this->url->link('account/wishlist', 'remove=' . $product_info['product_id'])
);
} else {
$this->model_account_wishlist->deleteWishlist($result);
}
}
$data['continue'] = $this->url->link('account/account', '', true);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('account/wishlist', $data));
}
public function add() {
$this->load->language('account/wishlist');
$json = array();
if (isset($this->request->post['product_id'])) {
$product_id = $this->request->post['product_id'];
} else {
$product_id = 0;
}
$this->load->model('catalog/product');
$product_info = $this->model_catalog_product->getProduct($product_id);
if ($product_info) {
if (!isset($this->session->data['wishlist'])) {
$this->session->data['wishlist'] = array();
}
$this->session->data['wishlist'][] = $this->request->post['product_id'];
$this->session->data['wishlist'] = array_unique($this->session->data['wishlist']);
$json['success'] = sprintf($this->language->get('text_success'), $this->url->link('product/product', 'product_id=' . (int)$this->request->post['product_id']), $product_info['name'], $this->url->link('account/wishlist'));
$json['total'] = sprintf($this->language->get('text_wishlist'), (isset($this->session->data['wishlist']) ? count($this->session->data['wishlist']) : 0));
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
public function old_add() {
$this->load->language('account/wishlist');
$json = array();
if (isset($this->request->post['product_id'])) {
$product_id = $this->request->post['product_id'];
} else {
$product_id = 0;
}
$this->load->model('catalog/product');
$product_info = $this->model_catalog_product->getProduct($product_id);
if ($product_info) {
if ($this->customer->isLogged()) {
// Edit customers cart
$this->load->model('account/wishlist');
$this->model_account_wishlist->addWishlist($this->request->post['product_id']);
$json['success'] = sprintf($this->language->get('text_success'), $this->url->link('product/product', 'product_id=' . (int)$this->request->post['product_id']), $product_info['name'], $this->url->link('account/wishlist'));
$json['total'] = sprintf($this->language->get('text_wishlist'), $this->model_account_wishlist->getTotalWishlist());
} else {
if (!isset($this->session->data['wishlist'])) {
$this->session->data['wishlist'] = array();
}
$this->session->data['wishlist'][] = $this->request->post['product_id'];
$this->session->data['wishlist'] = array_unique($this->session->data['wishlist']);
$json['success'] = sprintf($this->language->get('text_login'), $this->url->link('account/login', '', true), $this->url->link('account/register', '', true), $this->url->link('product/product', 'product_id=' . (int)$this->request->post['product_id']), $product_info['name'], $this->url->link('account/wishlist'));
$json['total'] = sprintf($this->language->get('text_wishlist'), (isset($this->session->data['wishlist']) ? count($this->session->data['wishlist']) : 0));
}
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}