контроллер
<?php
class ControllerShippingCourier extends Controller {
private $error = array();
public function index() {
$this->load->language('shipping/courier');
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('setting/setting');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->model_setting_setting->editSetting('courier', $this->request->post);
$this->session->data['success'] = $this->language->get('text_success');
$this->redirect($this->url->link('extension/shipping', 'token=' . $this->session->data['token'], 'SSL'));
}
// установка языковых переменных
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_enabled'] = $this->language->get('text_enabled');
$this->data['text_disabled'] = $this->language->get('text_disabled');
$this->data['text_all_zones'] = $this->language->get('text_all_zones');
$this->data['text_none'] = $this->language->get('text_none');
$this->data['entry_tax_class'] = $this->language->get('entry_tax_class');
$this->data['entry_geo_zone'] = $this->language->get('entry_geo_zone');
$this->data['entry_status'] = $this->language->get('entry_status');
$this->data['entry_sort_order'] = $this->language->get('entry_sort_order');
$this->data['entry_delivery_price_zone1_after'] = $this->language->get('entry_delivery_price_zone1_after');
$this->data['entry_delivery_price_zone2_after'] = $this->language->get('entry_delivery_price_zone2_after');
$this->data['entry_delivery_price_zone3_after'] = $this->language->get('entry_delivery_price_zone3_after');
$this->data['entry_delivery_price_zone4_after'] = $this->language->get('entry_delivery_price_zone4_after');
$this->data['entry_delivery_price_zone5_after'] = $this->language->get('entry_delivery_price_zone5_after');
$this->data['entry_delivery_price_zone6_after'] = $this->language->get('entry_delivery_price_zone6_after');
$this->data['entry_delivery_price_zone7_after'] = $this->language->get('entry_delivery_price_zone7_after');
$this->data['entry_delivery_price_zone1_before'] = $this->language->get('entry_delivery_price_zone1_before');
$this->data['entry_delivery_price_zone2_before'] = $this->language->get('entry_delivery_price_zone2_before');
$this->data['entry_delivery_price_zone3_before'] = $this->language->get('entry_delivery_price_zone3_before');
$this->data['entry_delivery_price_zone4_before'] = $this->language->get('entry_delivery_price_zone4_before');
$this->data['entry_delivery_price_zone5_before'] = $this->language->get('entry_delivery_price_zone5_before');
$this->data['entry_delivery_price_zone6_before'] = $this->language->get('entry_delivery_price_zone6_before');
$this->data['entry_delivery_price_zone7_before'] = $this->language->get('entry_delivery_price_zone7_before');
$this->data['entry_min_total_for_change_cost'] = $this->language->get('entry_min_total_for_change_cost');
$this->data['button_save'] = $this->language->get('button_save');
$this->data['button_cancel'] = $this->language->get('button_cancel');
$this->data['tab_general'] = $this->language->get('tab_general');
if (isset($this->error['warning'])) {
$this->data['error_warning'] = $this->error['warning'];
} else {
$this->data['error_warning'] = '';
}
// хлебные крошки
$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('text_shipping'),
'href' => $this->url->link('extension/shipping', 'token=' . $this->session->data['token'], 'SSL'),
'separator' => ' :: '
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('shipping/courier', 'token=' . $this->session->data['token'], 'SSL'),
'separator' => ' :: '
);
// ссылки для кнопок Сохранить и Отменить
$this->data['action'] = $this->url->link('shipping/courier', 'token=' . $this->session->data['token'], 'SSL');
$this->data['cancel'] = $this->url->link('extension/shipping', 'token=' . $this->session->data['token'], 'SSL');
if (isset($this->request->post['courier_min_total_for_change_cost'])) {
$this->data['courier_min_total_for_change_cost'] = $this->request->post['courier_min_total_for_change_cost'];
} else {
$this->data['courier_min_total_for_change_cost'] = $this->config->get('courier_min_total_for_change_cost');
}
if (isset($this->request->post['courier_delivery_price_zone1_before'])) {
$this->data['courier_delivery_price_zone1_before'] = $this->request->post['courier_delivery_price_zone1_before'];
} else {
$this->data['courier_delivery_price_zone1_before'] = $this->config->get('courier_delivery_price_zone1_before');
}
if (isset($this->request->post['courier_delivery_price_zone2_before'])) {
$this->data['courier_delivery_price_zone2_before'] = $this->request->post['courier_delivery_price_zone2_before'];
} else {
$this->data['courier_delivery_price_zone2_before'] = $this->config->get('courier_delivery_price_zone2_before');
}
if (isset($this->request->post['courier_delivery_price_zone3_before'])) {
$this->data['courier_delivery_price_zone3_before'] = $this->request->post['courier_delivery_price_zone3_before'];
} else {
$this->data['courier_delivery_price_zone3_before'] = $this->config->get('courier_delivery_price_zone3_before');
}
if (isset($this->request->post['courier_delivery_price_zone4_before'])) {
$this->data['courier_delivery_price_zone4_before'] = $this->request->post['courier_delivery_price_zone4_before'];
} else {
$this->data['courier_delivery_price_zone4_before'] = $this->config->get('courier_delivery_price_zone4_before');
}
if (isset($this->request->post['courier_delivery_price_zone5_before'])) {
$this->data['courier_delivery_price_zone5_before'] = $this->request->post['courier_delivery_price_zone5_before'];
} else {
$this->data['courier_delivery_price_zone5_before'] = $this->config->get('courier_delivery_price_zone5_before');
}
if (isset($this->request->post['courier_delivery_price_zone6_before'])) {
$this->data['courier_delivery_price_zone6_before'] = $this->request->post['courier_delivery_price_zone6_before'];
} else {
$this->data['courier_delivery_price_zone6_before'] = $this->config->get('courier_delivery_price_zone6_before');
}
if (isset($this->request->post['courier_delivery_price_zone7_before'])) {
$this->data['courier_delivery_price_zone7_before'] = $this->request->post['courier_delivery_price_zone7_before'];
} else {
$this->data['courier_delivery_price_zone7_before'] = $this->config->get('courier_delivery_price_zone7_before');
}
if (isset($this->request->post['courier_delivery_price_zone1_after'])) {
$this->data['courier_delivery_price_zone1_after'] = $this->request->post['courier_delivery_price_zone1_after'];
} else {
$this->data['courier_delivery_price_zone1_after'] = $this->config->get('courier_delivery_price_zone1_after');
}
if (isset($this->request->post['courier_delivery_price_zone2_after'])) {
$this->data['courier_delivery_price_zone2_after'] = $this->request->post['courier_delivery_price_zone2_after'];
} else {
$this->data['courier_delivery_price_zone2_after'] = $this->config->get('courier_delivery_price_zone2_after');
}
if (isset($this->request->post['courier_delivery_price_zone3_after'])) {
$this->data['courier_delivery_price_zone3_after'] = $this->request->post['courier_delivery_price_zone3_after'];
} else {
$this->data['courier_delivery_price_zone3_after'] = $this->config->get('courier_delivery_price_zone3_after');
}
if (isset($this->request->post['courier_delivery_price_zone4_after'])) {
$this->data['courier_delivery_price_zone4_after'] = $this->request->post['courier_delivery_price_zone4_after'];
} else {
$this->data['courier_delivery_price_zone4_after'] = $this->config->get('courier_delivery_price_zone4_after');
}
if (isset($this->request->post['courier_delivery_price_zone5_after'])) {
$this->data['courier_delivery_price_zone5_after'] = $this->request->post['courier_delivery_price_zone5_after'];
} else {
$this->data['courier_delivery_price_zone5_after'] = $this->config->get('courier_delivery_price_zone5_after');
}
if (isset($this->request->post['courier_delivery_price_zone6_after'])) {
$this->data['courier_delivery_price_zone6_after'] = $this->request->post['courier_delivery_price_zone6_after'];
} else {
$this->data['courier_delivery_price_zone6_after'] = $this->config->get('courier_delivery_price_zone6_after');
}
if (isset($this->request->post['courier_delivery_price_zone7_after'])) {
$this->data['courier_delivery_price_zone7_after'] = $this->request->post['courier_delivery_price_zone7_after'];
} else {
$this->data['courier_delivery_price_zone7_after'] = $this->config->get('courier_delivery_price_zone7_after');
}
if (isset($this->request->post['courier_geo_zone_id'])) {
$this->data['courier_geo_zone_id'] = $this->request->post['courier_geo_zone_id'];
} else {
$this->data['courier_geo_zone_id'] = $this->config->get('courier_geo_zone_id');
}
if (isset($this->request->post['courier_status'])) {
$this->data['courier_status'] = $this->request->post['courier_status'];
} else {
$this->data['courier_status'] = $this->config->get('courier_status');
}
if (isset($this->request->post['courier_sort_order'])) {
$this->data['courier_sort_order'] = $this->request->post['courier_sort_order'];
} else {
$this->data['courier_sort_order'] = $this->config->get('courier_sort_order');
}
$this->load->model('localisation/geo_zone');
$this->data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();
$this->template = 'shipping/courier.tpl';
$this->children = array(
'common/header',
'common/footer'
);
$this->response->setOutput($this->render());
}
private function validate() {
if (!$this->user->hasPermission('modify', 'shipping/courier')) {
$this->error['warning'] = $this->language->get('error_permission');
}
if (!$this->error) {
return true;
} else {
return false;
}
}
}
?>
тпл
<?php echo $header; ?>
<div id="content">
<div class="breadcrumb">
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
<?php } ?>
</div>
<?php if ($error_warning) { ?>
<div class="warning"><?php echo $error_warning; ?></div>
<?php } ?>
<div class="box">
<div class="heading">
<h1><img src="view/image/shipping.png" alt="" /> <?php echo $heading_title; ?></h1>
<div class="buttons"><a onclick="$('#form').submit();" class="button"><?php echo $button_save; ?></a><a onclick="location = '<?php echo $cancel; ?>';" class="button"><?php echo $button_cancel; ?></a></div>
</div>
<div class="content">
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
<table class="form">
<tr>
<td>
<?php echo $entry_min_total_for_change_cost; ?>
</td>
<td><input type="text" name="courier_min_total_for_change_cost" value="<?php echo $courier_min_total_for_change_cost; ?>" /></td>
</tr>
<tr>
<td> <?php echo $entry_delivery_price_zone1_before; ?></td>
<td><input type="text" name="courier_delivery_price_zone1_before" value="<?php echo $courier_delivery_price_zone1_before; ?>" /></td>
<td> <?php echo $entry_delivery_price_zone1_after; ?></td>
<td><input type="text" name="courier_delivery_price_zone1_after" value="<?php echo $courier_delivery_price_zone1_after; ?>" /></td>
</tr>
<tr>
<td> <?php echo $entry_delivery_price_zone2_before; ?></td>
<td><input type="text" name="courier_delivery_price_zone2_before" value="<?php echo $courier_delivery_price_zone2_before; ?>" /></td>
<td> <?php echo $entry_delivery_price_zone2_after; ?></td>
<td><input type="text" name="courier_delivery_price_zone2_after" value="<?php echo $courier_delivery_price_zone2_after; ?>" /></td>
</tr>
<tr>
<td> <?php echo $entry_delivery_price_zone3_before; ?></td>
<td><input type="text" name="courier_delivery_price_zone3_before" value="<?php echo $courier_delivery_price_zone3_before; ?>" /></td>
<td> <?php echo $entry_delivery_price_zone3_after; ?></td>
<td><input type="text" name="courier_delivery_price_zone3_after" value="<?php echo $courier_delivery_price_zone3_after; ?>" /></td>
</tr>
<tr>
<td> <?php echo $entry_delivery_price_zone4_before; ?></td>
<td><input type="text" name="courier_delivery_price_zone4_before" value="<?php echo $courier_delivery_price_zone4_before; ?>" /></td>
<td> <?php echo $entry_delivery_price_zone4_after; ?></td>
<td><input type="text" name="courier_delivery_price_zone4_after" value="<?php echo $courier_delivery_price_zone4_after; ?>" /></td>
</tr>
<tr>
<td> <?php echo $entry_delivery_price_zone5_before; ?></td>
<td><input type="text" name="courier_delivery_price_zone5_before" value="<?php echo $courier_delivery_price_zone5_before; ?>" /></td>
<td> <?php echo $entry_delivery_price_zone5_after; ?></td>
<td><input type="text" name="courier_delivery_price_zone5_after" value="<?php echo $courier_delivery_price_zone5_after; ?>" /></td>
</tr>
<tr>
<td> <?php echo $entry_delivery_price_zone6_before; ?></td>
<td><input type="text" name="courier_delivery_price_zone6_before" value="<?php echo $courier_delivery_price_zone6_before; ?>" /></td>
<td> <?php echo $entry_delivery_price_zone6_after; ?></td>
<td><input type="text" name="courier_delivery_price_zone6_after" value="<?php echo $courier_delivery_price_zone6_after; ?>" /></td>
</tr>
<tr>
<td> <?php echo $entry_delivery_price_zone7_before; ?></td>
<td><input type="text" name="courier_delivery_price_zone7_before" value="<?php echo $courier_delivery_price_zone7_before; ?>" /></td>
<td> <?php echo $entry_delivery_price_zone7_after; ?></td>
<td><input type="text" name="courier_delivery_price_zone7_after" value="<?php echo $courier_delivery_price_zone7_after; ?>" /></td>
</tr>
<tr>
<td><?php echo $entry_geo_zone; ?></td>
<td><select name="courier_geo_zone_id">
<option value="0"><?php echo $text_all_zones; ?></option>
<?php foreach ($geo_zones as $geo_zone) { ?>
<?php if ($geo_zone['geo_zone_id'] == $courier_geo_zone_id) { ?>
<option value="<?php echo $geo_zone['geo_zone_id']; ?>" selected="selected"><?php echo $geo_zone['name']; ?></option>
<?php } else { ?>
<option value="<?php echo $geo_zone['geo_zone_id']; ?>"><?php echo $geo_zone['name']; ?></option>
<?php } ?>
<?php } ?>
</select></td>
</tr>
<tr>
<td><?php echo $entry_status; ?></td>
<td><select name="courier_status">
<?php if ($courier_status) { ?>
<option value="1" selected="selected"><?php echo $text_enabled; ?></option>
<option value="0"><?php echo $text_disabled; ?></option>
<?php } else { ?>
<option value="1"><?php echo $text_enabled; ?></option>
<option value="0" selected="selected"><?php echo $text_disabled; ?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td><?php echo $entry_sort_order; ?></td>
<td><input type="text" name="courier_sort_order" value="<?php echo $courier_sort_order; ?>" size="1" /></td>
</tr>
</table>
</form>
</div>
</div>
<?php echo $footer; ?>
подправьте пожалуйста