<?php
class ControllerextensionModulereasonright extends Controller {
	public function index($setting) {
		$data['titlename'] = $setting['titlename'];
		$data['bgcolor'] = $setting['bgcolor'];
		$data['bgcolorcss'] = $setting['bgcolorcss'];
		$data['titlecss'] = $setting['titlecss'];
		$data['titlesmcss'] = $setting['titlesmcss'];
		$data['namebig'] = $setting['namebig'];
		$data['namebigtwo'] = $setting['namebigtwo'];
		$data['namebigthree'] = $setting['namebigthree'];
		$data['namebigfour'] = $setting['namebigfour'];
		$data['section1'] = $setting['section1'];
		$data['section2'] = $setting['section2'];
		$data['section3'] = $setting['section3'];
		$data['section4'] = $setting['section4'];
		$data['describe'] = $setting['describe'];
		$data['wgdlg1'] = $setting['wgdlg1'];
		$data['wgdlg2'] = $setting['wgdlg2'];
		$data['column'] = $setting['column'];
		$data['miconbj'] = $setting['miconbj'];
		$data['miconjbbj'] = $setting['miconjbbj'];
		$data['miconcolor'] = $setting['miconcolor'];
		$data['miconround'] = $setting['miconround'];
		$data['miconsize'] = $setting['miconsize'];
		$data['miconborder'] = $setting['miconborder'];
		$data['miconbc'] = $setting['miconbc'];	
		$data['tccolor'] = $setting['tccolor'];
		$data['titlezwzc'] = $setting['titlezwzc'];
		$data['pricecolor'] = $setting['pricecolor'];
		$data['pricetitleicolor'] = $setting['pricetitleicolor'];	
		$data['miconwidth'] = $setting['miconwidth'];
		$data['miconheight'] = $setting['miconheight'];	
		$data['imagepicstyle'] = $setting['imagepicstyle'];
        $data['rrp'] = $setting['rrp'];	
        $data['rrb'] = $setting['rrb'];	
		$data['rfourlw'] = $setting['rfourlw'];
		$data['rfourlh'] = $setting['rfourlh'];
		$data['rfourlc'] = $setting['rfourlc'];		
		$data['autoplay'] = $setting['autoplay'];
		$data['main'] = $setting['main'];
		$data['speed'] = $setting['speed'];
		$data['scroll'] = $setting['scroll'];
		$data['rrsrow'] = $setting['rrsrow'];
		$data['rrmtp'] = $setting['rrmtp'];
		$data['rmaxwidth'] = $setting['rmaxwidth'];
		$data['rfontsize'] = $setting['rfontsize'];
		$data['rrbigt'] = $setting['rrbigt'];	
        $data['rrsmt'] = $setting['rrsmt'];
		$data['buttonname1'] = $setting['buttonname1'];
		$data['link1'] = $setting['link1'];
		$data['buttonname2'] = $setting['buttonname2'];
		$data['link2'] = $setting['link2'];
		$data['icons1'] = $setting['icons1'];
		$data['icons2'] = $setting['icons2'];
		$data['buttoncolor1'] = $setting['buttoncolor1'];
		$data['buttoncolor2'] = $setting['buttoncolor2'];
		$data['rrption'] = $setting['rrption'];
		$data['layoutpx'] = $setting['layoutpx'];	
		$data['layoutpy'] = $setting['layoutpy'];	
        $data['fade'] = $setting['fade'];	
		$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['paddingbottom'] = $setting['paddingbottom'];	
        $data['hoverbj'] = $setting['hoverbj'];
        $data['hovertit'] = $setting['hovertit'];	
		$data['qq1'] = $setting['qq1'];
		$data['alww1'] = $setting['alww1'];
		$data['qq2'] = $setting['qq2'];
		$data['alww2'] = $setting['alww2'];		
		$data['imganimation'] = $setting['imganimation'];
        $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['video'] = $setting['video'];			
		
		static $module = 0;

		$this->load->model('tool/image');

		if (is_file(DIR_IMAGE . $setting['image'])) {
			$image = $setting['image'];
		} else {
			$image = '';
		}

		$data['image'] = $this->model_tool_image->resize($image, $setting['width'], $setting['height']);
		$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['title1'][$this->config->get('config_language_id')])) {
					$service_info['title1'] = trim($service['title1'][$this->config->get('config_language_id')]);
				} else {
					$service_info['title1'] = '';
				}				
				if (isset($service['text1'][$this->config->get('config_language_id')])) {
					$service_info['text1'] = trim($service['text1'][$this->config->get('config_language_id')]);
				} else {
					$service_info['text1'] = '';
				}					
				if (isset($service['icon1'][$this->config->get('config_language_id')])) {
					$service_info['icon1'] = trim($service['icon1']);
				} else {
					$service_info['icon1'] = '';
				}																		
				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/reasonright.tpl')) {
				return $this->load->view($this->config->get('config_template') . 'extension/module/reasonright.tpl', $data);
			} else {
				return $this->load->view('extension/module/reasonright.tpl', $data);
			}
		}

	}
}