$this->language->load('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->redirect($this->url->link('account/return/success', '', 'SSL'));
}
$this->document->setTitle($this->language->get('heading_title'));
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', 'SSL'),
'separator' => $this->language->get('text_separator')
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('account/return/insert', '', 'SSL'),
'separator' => $this->language->get('text_separator')
);
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_description'] = $this->language->get('text_description');
$this->data['text_order'] = $this->language->get('text_order');
$this->data['text_product'] = $this->language->get('text_product');
$this->data['text_yes'] = $this->language->get('text_yes');
$this->data['text_no'] = $this->language->get('text_no');
$this->data['entry_order_id'] = $this->language->get('entry_order_id');
$this->data['entry_date_ordered'] = $this->language->get('entry_date_ordered');
$this->data['entry_firstname'] = $this->language->get('entry_firstname');
$this->data['entry_lastname'] = $this->language->get('entry_lastname');
$this->data['entry_email'] = $this->language->get('entry_email');
$this->data['entry_telephone'] = $this->language->get('entry_telephone');
$this->data['entry_product'] = $this->language->get('entry_product');
$this->data['entry_model'] = $this->language->get('entry_model');
$this->data['entry_quantity'] = $this->language->get('entry_quantity');
$this->data['entry_reason'] = $this->language->get('entry_reason');
$this->data['entry_opened'] = $this->language->get('entry_opened');
$this->data['entry_fault_detail'] = $this->language->get('entry_fault_detail');
$this->data['entry_captcha'] = $this->language->get('entry_captcha');
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['button_back'] = $this->language->get('button_back');
if (isset($this->error['warning'])) {
$this->data['error_warning'] = $this->error['warning'];
} else {
$this->data['error_warning'] = '';
}
if (isset($this->error['order_id'])) {
$this->data['error_order_id'] = $this->error['order_id'];
} else {
$this->data['error_order_id'] = '';
}
if (isset($this->error['firstname'])) {
$this->data['error_firstname'] = $this->error['firstname'];
} else {
$this->data['error_firstname'] = '';
}
if (isset($this->error['lastname'])) {
$this->data['error_lastname'] = $this->error['lastname'];
} else {
$this->data['error_lastname'] = '';
}
if (isset($this->error['email'])) {
$this->data['error_email'] = $this->error['email'];
} else {
$this->data['error_email'] = '';
}
if (isset($this->error['telephone'])) {
$this->data['error_telephone'] = $this->error['telephone'];
} else {
$this->data['error_telephone'] = '';
}
if (isset($this->error['product'])) {
$this->data['error_product'] = $this->error['product'];
} else {
$this->data['error_product'] = '';
}
if (isset($this->error['model'])) {
$this->data['error_model'] = $this->error['model'];
} else {
$this->data['error_model'] = '';
}
if (isset($this->error['reason'])) {
$this->data['error_reason'] = $this->error['reason'];
} else {
$this->data['error_reason'] = '';
}
if (isset($this->error['captcha'])) {
$this->data['error_captcha'] = $this->error['captcha'];
} else {
$this->data['error_captcha'] = '';
}
$this->data['action'] = $this->url->link('account/return/insert', '', 'SSL');
$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'])) {
$this->data['order_id'] = $this->request->post['order_id'];
} elseif (!empty($order_info)) {
$this->data['order_id'] = $order_info['order_id'];
} else {
$this->data['order_id'] = '';
}
if (isset($this->request->post['date_ordered'])) {
$this->data['date_ordered'] = $this->request->post['date_ordered'];
} elseif (!empty($order_info)) {
$this->data['date_ordered'] = date('Y-m-d', strtotime($order_info['date_added']));
} else {
$this->data['date_ordered'] = '';
}
if (isset($this->request->post['firstname'])) {
$this->data['firstname'] = $this->request->post['firstname'];
} elseif (!empty($order_info)) {
$this->data['firstname'] = $order_info['firstname'];
} else {
$this->data['firstname'] = $this->customer->getFirstName();
}
if (isset($this->request->post['lastname'])) {
$this->data['lastname'] = $this->request->post['lastname'];
} elseif (!empty($order_info)) {
$this->data['lastname'] = $order_info['lastname'];
} else {
$this->data['lastname'] = $this->customer->getLastName();
}
if (isset($this->request->post['email'])) {
$this->data['email'] = $this->request->post['email'];
} elseif (!empty($order_info)) {
$this->data['email'] = $order_info['email'];
} else {
$this->data['email'] = $this->customer->getEmail();
}
if (isset($this->request->post['telephone'])) {
$this->data['telephone'] = $this->request->post['telephone'];
} elseif (!empty($order_info)) {
$this->data['telephone'] = $order_info['telephone'];
} else {
$this->data['telephone'] = $this->customer->getTelephone();
}
if (isset($this->request->post['product'])) {
$this->data['product'] = $this->request->post['product'];
} elseif (!empty($product_info)) {
$this->data['product'] = $product_info['name'];
} else {
$this->data['product'] = '';
}
if (isset($this->request->post['model'])) {
$this->data['model'] = $this->request->post['model'];
} elseif (!empty($product_info)) {
$this->data['model'] = $product_info['model'];
} else {
$this->data['model'] = '';
}
if (isset($this->request->post['quantity'])) {
$this->data['quantity'] = $this->request->post['quantity'];
} else {
$this->data['quantity'] = 1;
}
if (isset($this->request->post['opened'])) {
$this->data['opened'] = $this->request->post['opened'];
} else {
$this->data['opened'] = false;
}
if (isset($this->request->post['return_reason_id'])) {
$this->data['return_reason_id'] = $this->request->post['return_reason_id'];
} else {
$this->data['return_reason_id'] = '';
}
$this->load->model('localisation/return_reason');
$this->data['return_reasons'] = $this->model_localisation_return_reason->getReturnReasons();
if (isset($this->request->post['comment'])) {
$this->data['comment'] = $this->request->post['comment'];
} else {
$this->data['comment'] = '';
}
if (isset($this->request->post['captcha'])) {
$this->data['captcha'] = $this->request->post['captcha'];
} else {
$this->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) {
$this->data['text_agree'] = sprintf($this->language->get('text_agree'), $this->url->link('information/information/info', 'information_id=' . $this->config->get('config_return_id'), 'SSL'), $information_info['title'], $information_info['title']);
} else {
$this->data['text_agree'] = '';
}
} else {
$this->data['text_agree'] = '';
}
if (isset($this->request->post['agree'])) {
$this->data['agree'] = $this->request->post['agree'];
} else {
$this->data['agree'] = false;
}
$this->data['back'] = $this->url->link('account/account', '', 'SSL');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/return_form.tpl')) {
$this->template = $this->config->get('config_template') . '/template/account/return_form.tpl';
} else {
$this->template = 'default/template/account/return_form.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());