shop.balmet.com

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

klarna_fee.php (3623B)


      1 <?php
      2 class ControllerExtensionTotalKlarnaFee extends Controller {
      3 	private $error = array();
      4 
      5 	public function index() {
      6 		$this->load->language('extension/total/klarna_fee');
      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 			$status = false;
     14 
     15 			foreach ($this->request->post['klarna_fee'] as $klarna_account) {
     16 				if ($klarna_account['status']) {
     17 					$status = true;
     18 
     19 					break;
     20 				}
     21 			}
     22 
     23 			$this->model_setting_setting->editSetting('total_klarna_fee', array_merge($this->request->post, array('klarna_fee_status' => $status)));
     24 
     25 			$this->session->data['success'] = $this->language->get('text_success');
     26 
     27 			$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=total', true));
     28 		}
     29 
     30 		if (isset($this->error['warning'])) {
     31 			$data['error_warning'] = $this->error['warning'];
     32 		} else {
     33 			$data['error_warning'] = '';
     34 		}
     35 
     36 		$data['breadcrumbs'] = array();
     37 
     38 		$data['breadcrumbs'][] = array(
     39 			'text' => $this->language->get('text_home'),
     40 			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
     41 		);
     42 
     43 		$data['breadcrumbs'][] = array(
     44 			'text' => $this->language->get('text_extension'),
     45 			'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=total', true)
     46 		);
     47 
     48 		$data['breadcrumbs'][] = array(
     49 			'text' => $this->language->get('heading_title'),
     50 			'href' => $this->url->link('extension/total/klarna_fee', 'user_token=' . $this->session->data['user_token'], true)
     51 		);
     52 
     53 		$data['action'] = $this->url->link('extension/total/klarna_fee', 'user_token=' . $this->session->data['user_token'], true);
     54 
     55 		$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=total', true);
     56 
     57 		$data['countries'] = array();
     58 
     59 		$data['countries'][] = array(
     60 			'name' => $this->language->get('text_germany'),
     61 			'code' => 'DEU'
     62 		);
     63 
     64 		$data['countries'][] = array(
     65 			'name' => $this->language->get('text_netherlands'),
     66 			'code' => 'NLD'
     67 		);
     68 
     69 		$data['countries'][] = array(
     70 			'name' => $this->language->get('text_denmark'),
     71 			'code' => 'DNK'
     72 		);
     73 
     74 		$data['countries'][] = array(
     75 			'name' => $this->language->get('text_sweden'),
     76 			'code' => 'SWE'
     77 		);
     78 
     79 		$data['countries'][] = array(
     80 			'name' => $this->language->get('text_norway'),
     81 			'code' => 'NOR'
     82 		);
     83 
     84 		$data['countries'][] = array(
     85 			'name' => $this->language->get('text_finland'),
     86 			'code' => 'FIN'
     87 		);
     88 
     89 		if (isset($this->request->post['total_klarna_fee'])) {
     90 			$data['total_klarna_fee'] = $this->request->post['total_klarna_fee'];
     91 		} else {
     92 			$data['total_klarna_fee'] = $this->config->get('total_klarna_fee');
     93 		}
     94 
     95 		$this->load->model('localisation/tax_class');
     96 
     97 		$data['tax_classes'] = $this->model_localisation_tax_class->getTaxClasses();
     98 
     99 		$data['header'] = $this->load->controller('common/header');
    100 		$data['column_left'] = $this->load->controller('common/column_left');
    101 		$data['footer'] = $this->load->controller('common/footer');
    102 
    103 		$this->response->setOutput($this->load->view('extension/total/klarna_fee', $data));
    104 	}
    105 
    106 	private function validate() {
    107 		if (!$this->user->hasPermission('modify', 'extension/total/klarna_fee')) {
    108 			$this->error['warning'] = $this->language->get('error_permission');
    109 		}
    110 
    111 		return !$this->error;
    112 	}
    113 }