<?php
class ControllerextensionModulereasonone extends Controller {
	public function index($setting) {
		$data['titlename'] = $setting['titlename'];
		$data['linew'] = $setting['linew'];
		$data['lineh'] = $setting['lineh'];
		$data['linec'] = $setting['linec'];
		$data['describe'] = $setting['describe'];
		$data['buttonname1'] = $setting['buttonname1'];
		$data['link1'] = $setting['link1'];
		$data['buttonname2'] = $setting['buttonname2'];
		$data['link2'] = $setting['link2'];
		$data['buttoncolor1'] = $setting['buttoncolor1'];
		$data['buttoncolor2'] = $setting['buttoncolor2'];
		$data['main'] = $setting['main'];
		$data['autoplay'] = $setting['autoplay'];
		$data['fade'] = $setting['fade'];
		$data['speed'] = $setting['speed'];
		$data['column'] = $setting['column'];
		$data['rows'] = $setting['rows'];
		$data['scroll'] = $setting['scroll'];		
		$data['sectionbj'] = $setting['sectionbj'];		
		$data['sectionjbbj'] = $setting['sectionjbbj'];
		$data['sectiontitle'] = $setting['sectiontitle'];
		$data['sectiondescribe'] = $setting['sectiondescribe'];
		$data['sectionptop'] = $setting['sectionptop'];
		$data['sectionpbuttom'] = $setting['sectionpbuttom'];
        $data['sectionid'] = $setting['sectionid'];
        $data['sectiontab'] = $setting['sectiontab'];
		$data['imground'] = $setting['imground'];
        $data['imgthumb'] = $setting['imgthumb'];	
        $data['imgshadow'] = $setting['imgshadow'];	
		$data['imgpadding'] = $setting['imgpadding'];
        $data['imgborder'] = $setting['imgborder'];	
        $data['imgcolor'] = $setting['imgcolor'];	
		
		$data['boxbg'] = $setting['boxbg'];
		$data['boxjbbj'] = $setting['boxjbbj'];
		$data['boxtitle'] = $setting['boxtitle'];
		$data['boxdescribe'] = $setting['boxdescribe'];	
		$data['boxmagin'] = $setting['boxmagin'];
		$data['boxpadding'] = $setting['boxpadding'];
		$data['boxtbpadding'] = $setting['boxtbpadding'];
		$data['boxborder'] = $setting['boxborder'];
		$data['boxcolor'] = $setting['boxcolor'];	       
        $data['boxround'] = $setting['boxround'];
        $data['boxposition'] = $setting['boxposition'];	
        $data['boxshadow'] = $setting['boxshadow'];
        $data['boxshadowhover'] = $setting['boxshadowhover'];			
        $data['boxbjhover'] = $setting['boxbjhover'];
        $data['boxcolorhover'] = $setting['boxcolorhover'];		
		
		$data['buttonsize'] = $setting['buttonsize'];
		$data['buttoninset'] = $setting['buttoninset'];	       
        $data['buttonborder'] = $setting['buttonborder'];
        $data['buttonround'] = $setting['buttonround'];	
        $data['buttonhover'] = $setting['buttonhover'];
        $data['buttond'] = $setting['buttond'];	

        $data['miconbj'] = $setting['miconbj'];		
        $data['miconcolorc'] = $setting['miconcolorc'];
		$data['miconcolor'] = $setting['miconcolor'];
        $data['hoverbj'] = $setting['hoverbj'];
        $data['hovertit'] = $setting['hovertit'];	
		$data['miconround'] = $setting['miconround'];
		$data['miconsize'] = $setting['miconsize'];
		$data['miconborder'] = $setting['miconborder'];
		$data['miconbc'] = $setting['miconbc'];
		$data['miconwidth'] = $setting['miconwidth'];
		$data['miconheight'] = $setting['miconheight'];	
		$data['qq1'] = $setting['qq1'];
		$data['alww1'] = $setting['alww1'];
		$data['qq2'] = $setting['qq2'];
		$data['alww2'] = $setting['alww2'];	
        $data['imagepicstyle'] = $setting['imagepicstyle'];		
		
		$data['services'] = array();

		if (isset($setting['service']) && $setting['service']) {
			$this->load->model('tool/image');

			$services = $setting['service'];

			$sort_order = array();

			foreach ($services as $key => $value) {
				$sort_order[$key] = $value['sort_order'];
			}

			array_multisort($sort_order, SORT_ASC, $services);

			foreach ($services as $service) {
				$service_info = array();
				if (isset($service['title'][$this->config->get('config_language_id')])) {
					$service_info['title'] = trim($service['title'][$this->config->get('config_language_id')]);
				} else {
					$service_info['title'] = '';
				}

				if (isset($service['text'][$this->config->get('config_language_id')])) {
					$service_info['text'] = trim($service['text'][$this->config->get('config_language_id')]);
				} else {
					$service_info['text'] = '';
				}
				if (isset($service['icon'][$this->config->get('config_language_id')])) {
					$service_info['icon'] = trim($service['icon']);
				} else {
					$service_info['icon'] = '';
				}
				if (isset($service['rboxcolor'][$this->config->get('config_language_id')])) {
					$service_info['rboxcolor'] = trim($service['rboxcolor']);
				} else {
					$service_info['rboxcolor'] = '';
				}
				if (isset($service['buttonname'][$this->config->get('config_language_id')])) {
					$service_info['buttonname'] = trim($service['buttonname'][$this->config->get('config_language_id')]);
				} else {
					$service_info['buttonname'] = '';
				}
				if (isset($service['link'])) {
					$service_info['link'] = trim($service['link']);
				} else {
					$service_info['link'] = '';
				}

				if (isset($service['image']) && is_file(DIR_IMAGE . $service['image'])) {
					$service_info['image'] = $this->model_tool_image->resize($service['image'], $setting['imagewidth'], $setting['imageheight']);
				} else {
					$service_info['image'] = $this->model_tool_image->resize('', $setting['imagewidth'], $setting['imageheight']);
				}

				$data['services'][] = $service_info;
			}
		}

		if ($data['services']) {
			if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . 'extension/module/reasonone.tpl')) {
				return $this->load->view($this->config->get('config_template') . 'extension/module/reasonone.tpl', $data);
			} else {
				return $this->load->view('extension/module/reasonone.tpl', $data);
			}
		}

	}
}