shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

ec_ship.php (10010B)


      1 <?php
      2 class ControllerExtensionShippingECShip extends Controller {
      3 	private $error = array();
      4 
      5 	public function index() {
      6 		$this->load->language('extension/shipping/ec_ship');
      7 
      8 		$this->document->setTitle($this->language->get('heading_title'));
      9 
     10 		$this->load->model('setting/setting');
     11 
     12 		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
     13 			$this->model_setting_setting->editSetting('shipping_ec_ship', $this->request->post);
     14 
     15 			$this->session->data['success'] = $this->language->get('text_success');
     16 
     17 			$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=shipping', true));
     18 		}
     19 
     20 		if (isset($this->error['warning'])) {
     21 			$data['error_warning'] = $this->error['warning'];
     22 		} else {
     23 			$data['error_warning'] = '';
     24 		}
     25 
     26 		if (isset($this->error['username'])) {
     27 			$data['error_username'] = $this->error['username'];
     28 		} else {
     29 			$data['error_username'] = '';
     30 		}
     31 
     32 		if (isset($this->error['api_username'])) {
     33 			$data['error_api_username'] = $this->error['entry_api_username'];
     34 		} else {
     35 			$data['error_api_username'] = '';
     36 		}
     37 
     38 		if (isset($this->error['api_key'])) {
     39 			$data['error_api_key'] = $this->error['api_key'];
     40 		} else {
     41 			$data['error_api_key'] = '';
     42 		}
     43 
     44 		$data['breadcrumbs'] = array();
     45 
     46 		$data['breadcrumbs'][] = array(
     47 			'text' => $this->language->get('text_home'),
     48 			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
     49 		);
     50 
     51 		$data['breadcrumbs'][] = array(
     52 			'text' => $this->language->get('text_extension'),
     53 			'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=shipping', true)
     54 		);
     55 
     56 		$data['breadcrumbs'][] = array(
     57 			'text' => $this->language->get('heading_title'),
     58 			'href' => $this->url->link('extension/shipping/ec_ship', 'user_token=' . $this->session->data['user_token'], true)
     59 		);
     60 
     61 		$data['action'] = $this->url->link('extension/shipping/ec_ship', 'user_token=' . $this->session->data['user_token'], true);
     62 
     63 		$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=shipping', true);
     64 
     65 		if (isset($this->request->post['shipping_ec_ship_api_key'])) {
     66 			$data['shipping_ec_ship_api_key'] = $this->request->post['shipping_ec_ship_api_key'];
     67 		} else {
     68 			$data['shipping_ec_ship_api_key'] = $this->config->get('shipping_ec_ship_api_key');
     69 		}
     70 
     71 		if (isset($this->request->post['shipping_ec_ship_username'])) {
     72 			$data['shipping_ec_ship_username'] = $this->request->post['shipping_ec_ship_username'];
     73 		} else {
     74 			$data['shipping_ec_ship_username'] = $this->config->get('shipping_ec_ship_username');
     75 		}
     76 
     77 		if (isset($this->request->post['shipping_ec_ship_api_username'])) {
     78 			$data['shipping_ec_ship_api_username'] = $this->request->post['shipping_ec_ship_api_username'];
     79 		} else {
     80 			$data['shipping_ec_ship_api_username'] = $this->config->get('shipping_ec_ship_api_username');
     81 		}
     82 
     83 		if (isset($this->request->post['shipping_ec_ship_test'])) {
     84 			$data['shipping_ec_ship_test'] = $this->request->post['shipping_ec_ship_test'];
     85 		} else {
     86 			$data['shipping_ec_ship_test'] = $this->config->get('shipping_ec_ship_test');
     87 		}
     88 
     89 		if (isset($this->request->post['shipping_ec_ship_air_registered_mail'])) {
     90 			$data['shipping_ec_ship_air_registered_mail'] = $this->request->post['shipping_ec_ship_air_registered_mail'];
     91 		} else {
     92 			$data['shipping_ec_ship_air_registered_mail'] = $this->config->get('shipping_ec_ship_air_registered_mail');
     93 		}
     94 
     95 		if (isset($this->request->post['shipping_ec_ship_air_parcel'])) {
     96 			$data['shipping_ec_ship_air_parcel'] = $this->request->post['shipping_ec_ship_air_parcel'];
     97 		} else {
     98 			$data['shipping_ec_ship_air_parcel'] = $this->config->get('shipping_ec_ship_air_parcel');
     99 		}
    100 
    101 		if (isset($this->request->post['shipping_ec_ship_e_express_service_to_us'])) {
    102 			$data['shipping_ec_ship_e_express_service_to_us'] = $this->request->post['shipping_ec_ship_e_express_service_to_us'];
    103 		} else {
    104 			$data['shipping_ec_ship_e_express_service_to_us'] = $this->config->get('shipping_ec_ship_e_express_service_to_us');
    105 		}
    106 
    107 		if (isset($this->request->post['shipping_ec_ship_e_express_service_to_canada'])) {
    108 			$data['shipping_ec_ship_e_express_service_to_canada'] = $this->request->post['shipping_ec_ship_e_express_service_to_canada'];
    109 		} else {
    110 			$data['shipping_ec_ship_e_express_service_to_canada'] = $this->config->get('shipping_ec_ship_e_express_service_to_canada');
    111 		}
    112 
    113 		if (isset($this->request->post['shipping_ec_ship_e_express_service_to_united_kingdom'])) {
    114 			$data['shipping_ec_ship_e_express_service_to_united_kingdom'] = $this->request->post['shipping_ec_ship_e_express_service_to_united_kingdom'];
    115 		} else {
    116 			$data['shipping_ec_ship_e_express_service_to_united_kingdom'] = $this->config->get('shipping_ec_ship_e_express_service_to_united_kingdom');
    117 		}
    118 
    119 		if (isset($this->request->post['shipping_ec_ship_e_express_service_to_russia'])) {
    120 			$data['shipping_ec_ship_e_express_service_to_russia'] = $this->request->post['shipping_ec_ship_e_express_service_to_russia'];
    121 		} else {
    122 			$data['shipping_ec_ship_e_express_service_to_russia'] = $this->config->get('shipping_ec_ship_e_express_service_to_russia');
    123 		}
    124 
    125 		if (isset($this->request->post['shipping_ec_ship_e_express_service_one'])) {
    126 			$data['shipping_ec_ship_e_express_service_one'] = $this->request->post['shipping_ec_ship_e_express_service_one'];
    127 		} else {
    128 			$data['shipping_ec_ship_e_express_service_one'] = $this->config->get('shipping_ec_ship_e_express_service_one');
    129 		}
    130 
    131 		if (isset($this->request->post['shipping_ec_ship_e_express_service_two'])) {
    132 			$data['shipping_ec_ship_e_express_service_two'] = $this->request->post['shipping_ec_ship_e_express_service_two'];
    133 		} else {
    134 			$data['shipping_ec_ship_e_express_service_two'] = $this->config->get('shipping_ec_ship_e_express_service_two');
    135 		}
    136 
    137 		if (isset($this->request->post['shipping_ec_ship_speed_post'])) {
    138 			$data['shipping_ec_ship_speed_post'] = $this->request->post['shipping_ec_ship_speed_post'];
    139 		} else {
    140 			$data['shipping_ec_ship_speed_post'] = $this->config->get('shipping_ec_ship_speed_post');
    141 		}
    142 
    143 		if (isset($this->request->post['shipping_ec_ship_smart_post'])) {
    144 			$data['shipping_ec_ship_smart_post'] = $this->request->post['shipping_ec_ship_smart_post'];
    145 		} else {
    146 			$data['shipping_ec_ship_smart_post'] = $this->config->get('shipping_ec_ship_smart_post');
    147 		}
    148 
    149 		if (isset($this->request->post['shipping_ec_ship_local_courier_post'])) {
    150 			$data['shipping_ec_ship_local_courier_post'] = $this->request->post['shipping_ec_ship_local_courier_post'];
    151 		} else {
    152 			$data['shipping_ec_ship_local_courier_post'] = $this->config->get('shipping_ec_ship_local_courier_post');
    153 		}
    154 
    155 		if (isset($this->request->post['shipping_ec_ship_local_parcel'])) {
    156 			$data['shipping_ec_ship_local_parcel'] = $this->request->post['shipping_ec_ship_local_parcel'];
    157 		} else {
    158 			$data['shipping_ec_ship_local_parcel'] = $this->config->get('shipping_ec_ship_local_parcel');
    159 		}
    160 
    161 		if (isset($this->request->post['shipping_ec_ship_weight_class_id'])) {
    162 			$data['shipping_ec_ship_weight_class_id'] = $this->request->post['shipping_ec_ship_weight_class_id'];
    163 		} else {
    164 			$data['shipping_ec_ship_weight_class_id'] = $this->config->get('shipping_ec_ship_weight_class_id');
    165 		}
    166 
    167 		$this->load->model('localisation/weight_class');
    168 
    169 		$data['weight_classes'] = $this->model_localisation_weight_class->getWeightClasses();
    170 
    171 		if (isset($this->request->post['shipping_ec_ship_tax_class_id'])) {
    172 			$data['shipping_ec_ship_tax_class_id'] = $this->request->post['shipping_ec_ship_tax_class_id'];
    173 		} else {
    174 			$data['shipping_ec_ship_tax_class_id'] = $this->config->get('shipping_ec_ship_tax_class_id');
    175 		}
    176 
    177 		$this->load->model('localisation/tax_class');
    178 
    179 		$data['tax_classes'] = $this->model_localisation_tax_class->getTaxClasses();
    180 
    181 		if (isset($this->request->post['shipping_ec_ship_geo_zone_id'])) {
    182 			$data['shipping_ec_ship_geo_zone_id'] = $this->request->post['shipping_ec_ship_geo_zone_id'];
    183 		} else {
    184 			$data['shipping_ec_ship_geo_zone_id'] = $this->config->get('shipping_ec_ship_geo_zone_id');
    185 		}
    186 
    187 		$this->load->model('localisation/geo_zone');
    188 
    189 		$data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();
    190 
    191 		if (isset($this->request->post['shipping_ec_ship_status'])) {
    192 			$data['shipping_ec_ship_status'] = $this->request->post['shipping_ec_ship_status'];
    193 		} else {
    194 			$data['shipping_ec_ship_status'] = $this->config->get('shipping_ec_ship_status');
    195 		}
    196 
    197 		if (isset($this->request->post['shipping_ec_ship_sort_order'])) {
    198 			$data['shipping_ec_ship_sort_order'] = $this->request->post['shipping_ec_ship_sort_order'];
    199 		} else {
    200 			$data['shipping_ec_ship_sort_order'] = $this->config->get('shipping_ec_ship_sort_order');
    201 		}
    202 
    203 		$data['header'] = $this->load->controller('common/header');
    204 		$data['column_left'] = $this->load->controller('common/column_left');
    205 		$data['footer'] = $this->load->controller('common/footer');
    206 
    207 		$this->response->setOutput($this->load->view('extension/shipping/ec_ship', $data));
    208 	}
    209 
    210 	protected function validate() {
    211 		if (!$this->user->hasPermission('modify', 'extension/shipping/ec_ship')) {
    212 			$this->error['warning'] = $this->language->get('error_permission');
    213 		}
    214 
    215 		if (!$this->request->post['shipping_ec_ship_api_key']) {
    216 			$this->error['api_key'] = $this->language->get('error_api_key');
    217 		}
    218 
    219 		if (!$this->request->post['shipping_ec_ship_username']) {
    220 			$this->error['username'] = $this->language->get('error_username');
    221 		}
    222 
    223 		if (!$this->request->post['shipping_ec_ship_api_username']) {
    224 			$this->error['api_username'] = $this->language->get('error_api_username');
    225 		}
    226 
    227 		return !$this->error;
    228 	}
    229 }