shop.balmet.com

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

weight.php (4309B)


      1 <?php
      2 class ControllerExtensionShippingWeight extends Controller {
      3 	private $error = array();
      4 
      5 	public function index() {
      6 		$this->load->language('extension/shipping/weight');
      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_weight', $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 		$data['breadcrumbs'] = array();
     27 
     28 		$data['breadcrumbs'][] = array(
     29 			'text' => $this->language->get('text_home'),
     30 			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
     31 		);
     32 
     33 		$data['breadcrumbs'][] = array(
     34 			'text' => $this->language->get('text_extension'),
     35 			'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=shipping', true)
     36 		);
     37 
     38 		$data['breadcrumbs'][] = array(
     39 			'text' => $this->language->get('heading_title'),
     40 			'href' => $this->url->link('extension/shipping/weight', 'user_token=' . $this->session->data['user_token'], true)
     41 		);
     42 
     43 		$data['action'] = $this->url->link('extension/shipping/weight', 'user_token=' . $this->session->data['user_token'], true);
     44 
     45 		$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=shipping', true);
     46 
     47 		$this->load->model('localisation/geo_zone');
     48 
     49 		$geo_zones = $this->model_localisation_geo_zone->getGeoZones();
     50 
     51 		foreach ($geo_zones as $geo_zone) {
     52 			if (isset($this->request->post['shipping_weight_' . $geo_zone['geo_zone_id'] . '_rate'])) {
     53 				$data['shipping_weight_geo_zone_rate'][$geo_zone['geo_zone_id']] = $this->request->post['shipping_weight_' . $geo_zone['geo_zone_id'] . '_rate'];
     54 			} else {
     55 				$data['shipping_weight_geo_zone_rate'][$geo_zone['geo_zone_id']] = $this->config->get('shipping_weight_' . $geo_zone['geo_zone_id'] . '_rate');
     56 			}
     57 
     58 			if (isset($this->request->post['shipping_weight_' . $geo_zone['geo_zone_id'] . '_status'])) {
     59 				$data['shipping_weight_geo_zone_status'][$geo_zone['geo_zone_id']] = $this->request->post['shipping_weight_' . $geo_zone['geo_zone_id'] . '_status'];
     60 			} else {
     61 				$data['shipping_weight_geo_zone_status'][$geo_zone['geo_zone_id']] = $this->config->get('shipping_weight_' . $geo_zone['geo_zone_id'] . '_status');
     62 			}
     63 		}
     64 
     65 		$data['geo_zones'] = $geo_zones;
     66 
     67 		if (isset($this->request->post['shipping_weight_tax_class_id'])) {
     68 			$data['shipping_weight_tax_class_id'] = $this->request->post['shipping_weight_tax_class_id'];
     69 		} else {
     70 			$data['shipping_weight_tax_class_id'] = $this->config->get('shipping_weight_tax_class_id');
     71 		}
     72 
     73 		$this->load->model('localisation/tax_class');
     74 
     75 		$data['tax_classes'] = $this->model_localisation_tax_class->getTaxClasses();
     76 
     77 		if (isset($this->request->post['shipping_weight_status'])) {
     78 			$data['shipping_weight_status'] = $this->request->post['shipping_weight_status'];
     79 		} else {
     80 			$data['shipping_weight_status'] = $this->config->get('shipping_weight_status');
     81 		}
     82 
     83 		if (isset($this->request->post['shipping_weight_sort_order'])) {
     84 			$data['shipping_weight_sort_order'] = $this->request->post['shipping_weight_sort_order'];
     85 		} else {
     86 			$data['shipping_weight_sort_order'] = $this->config->get('shipping_weight_sort_order');
     87 		}
     88 
     89 		$data['header'] = $this->load->controller('common/header');
     90 		$data['column_left'] = $this->load->controller('common/column_left');
     91 		$data['footer'] = $this->load->controller('common/footer');
     92 
     93 		$this->response->setOutput($this->load->view('extension/shipping/weight', $data));
     94 	}
     95 
     96 	protected function validate() {
     97 		if (!$this->user->hasPermission('modify', 'extension/shipping/weight')) {
     98 			$this->error['warning'] = $this->language->get('error_permission');
     99 		}
    100 
    101 		return !$this->error;
    102 	}
    103 }