$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_choose'] = $this->language->get('text_choose');
$this->data['text_select'] = $this->language->get('text_select');
$this->data['text_radio'] = $this->language->get('text_radio');
$this->data['text_checkbox'] = $this->language->get('text_checkbox');
$this->data['text_input'] = $this->language->get('text_input');
$this->data['text_text'] = $this->language->get('text_text');
$this->data['text_textarea'] = $this->language->get('text_textarea');
$this->data['text_file'] = $this->language->get('text_file');
$this->data['text_date'] = $this->language->get('text_date');
$this->data['text_datetime'] = $this->language->get('text_datetime');
$this->data['text_time'] = $this->language->get('text_time');
$this->data['text_customer'] = $this->language->get('text_customer');
$this->data['text_address'] = $this->language->get('text_address');
$this->data['text_payment_address'] = $this->language->get('text_payment_address');
$this->data['text_shipping_address'] = $this->language->get('text_shipping_address');
$this->data['text_yes'] = $this->language->get('text_yes');
$this->data['text_no'] = $this->language->get('text_no');
$this->data['entry_name'] = $this->language->get('entry_name');
$this->data['entry_type'] = $this->language->get('entry_type');
$this->data['entry_value'] = $this->language->get('entry_value');
$this->data['entry_custom_value'] = $this->language->get('entry_custom_value');
$this->data['entry_required'] = $this->language->get('entry_required');
$this->data['entry_location'] = $this->language->get('entry_location');
$this->data['entry_position'] = $this->language->get('entry_position');
$this->data['entry_sort_order'] = $this->language->get('entry_sort_order');
$this->data['button_save'] = $this->language->get('button_save');
$this->data['button_cancel'] = $this->language->get('button_cancel');
$this->data['button_add_custom_field_value'] = $this->language->get('button_add_custom_field_value');
$this->data['button_remove'] = $this->language->get('button_remove');
if (isset($this->error['warning'])) {
$this->data['error_warning'] = $this->error['warning'];
} else {
$this->data['error_warning'] = '';
}
if (isset($this->error['name'])) {
$this->data['error_name'] = $this->error['name'];
} else {
$this->data['error_name'] = array();
}
if (isset($this->error['custom_field_value'])) {
$this->data['error_custom_field_value'] = $this->error['custom_field_value'];
} else {
$this->data['error_custom_field_value'] = array();
}
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('design/custom_field', 'token=' . $this->session->data['token'] . $url, 'SSL'),
'separator' => ' :: '
);
if (!isset($this->request->get['custom_field_id'])) {
$this->data['action'] = $this->url->link('design/custom_field/insert', 'token=' . $this->session->data['token'] . $url, 'SSL');
} else {
$this->data['action'] = $this->url->link('design/custom_field/update', 'token=' . $this->session->data['token'] . '&custom_field_id=' . $this->request->get['custom_field_id'] . $url, 'SSL');
}
$this->data['cancel'] = $this->url->link('design/custom_field', 'token=' . $this->session->data['token'] . $url, 'SSL');
if (isset($this->request->get['custom_field_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
$custom_field_info = $this->model_design_custom_field->getCustomField($this->request->get['custom_field_id']);
}
$this->data['token'] = $this->session->data['token'];
$this->load->model('localisation/language');
$this->data['languages'] = $this->model_localisation_language->getLanguages();
if (isset($this->request->post['custom_field_description'])) {
$this->data['custom_field_description'] = $this->request->post['custom_field_description'];
} elseif (isset($this->request->get['custom_field_id'])) {
$this->data['custom_field_description'] = $this->model_design_custom_field->getCustomFieldDescriptions($this->request->get['custom_field_id']);
} else {
$this->data['custom_field_description'] = array();
}
if (isset($this->request->post['type'])) {
$this->data['type'] = $this->request->post['type'];
} elseif (!empty($custom_field_info)) {
$this->data['type'] = $custom_field_info['type'];
} else {
$this->data['type'] = '';
}
if (isset($this->request->post['value'])) {
$this->data['value'] = $this->request->post['value'];
} elseif (!empty($custom_field_info)) {
$this->data['value'] = $custom_field_info['value'];
} else {
$this->data['value'] = '';
}
if (isset($this->request->post['required'])) {
$this->data['required'] = $this->request->post['required'];
} elseif (!empty($custom_field_info)) {
$this->data['required'] = $custom_field_info['required'];
} else {
$this->data['required'] = '';
}
if (isset($this->request->post['location'])) {
$this->data['location'] = $this->request->post['location'];
} elseif (!empty($custom_field_info)) {
$this->data['location'] = $custom_field_info['location'];
} else {
$this->data['location'] = '';
}
if (isset($this->request->post['position'])) {
$this->data['position'] = $this->request->post['position'];
} elseif (!empty($custom_field_info)) {
$this->data['position'] = $custom_field_info['position'];
} else {
$this->data['position'] = '';
}
if (isset($this->request->post['sort_order'])) {
$this->data['sort_order'] = $this->request->post['sort_order'];
} elseif (!empty($custom_field_info)) {
$this->data['sort_order'] = $custom_field_info['sort_order'];
} else {
$this->data['sort_order'] = '';
}
if (isset($this->request->post['custom_field_value'])) {
$custom_field_values = $this->request->post['custom_field_value'];
} elseif (isset($this->request->get['custom_field_id'])) {
$custom_field_values = $this->model_design_custom_field->getCustomFieldValueDescriptions($this->request->get['custom_field_id']);
} else {
$custom_field_values = array();
}
$this->data['custom_field_values'] = array();
foreach ($custom_field_values as $custom_field_value) {
$this->data['custom_field_values'][] = array(
'custom_field_value_id' => $custom_field_value['custom_field_value_id'],
'custom_field_value_description' => $custom_field_value['custom_field_value_description'],
'sort_order' => $custom_field_value['sort_order']
);
}
$this->template = 'design/custom_field_form.tpl';
$this->children = array(
'common/header',
'common/footer'
);
$this->response->setOutput($this->render());