<?php
class ControllerextensionModulernumber 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['opacity'] = $setting['opacity'];
		$data['describe'] = $setting['describe'];
		$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['miconbj'] = $setting['miconbj'];
		$data['miconcolor'] = $setting['miconcolor'];
		$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['ncolor'] = $setting['ncolor'];
		$data['tcolor'] = $setting['tcolor'];	
        $data['rnlinew'] = $setting['rnlinew'];	
        $data['rnlineh'] = $setting['rnlineh'];	
        $data['rnlinec'] = $setting['rnlinec'];	
        $data['main'] = $setting['main'];	
        $data['sectionptop'] = $setting['sectionptop'];	
        $data['sectionpbuttom'] = $setting['sectionpbuttom'];	
        $data['maxfontsize'] = $setting['maxfontsize'];	
        $data['miconjbbj'] = $setting['miconjbbj'];		
        $data['depictcolor'] = $setting['depictcolor'];	
        $data['imagefull'] = $setting['imagefull'];	
        $data['sectionid'] = $setting['sectionid'];
        $data['sectiontab'] = $setting['sectiontab'];		
		$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'];		
		
		static $module = 0;

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

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

		$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['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['depict'][$this->config->get('config_language_id')])) {
					$service_info['depict'] = trim($service['depict'][$this->config->get('config_language_id')]);
				} else {
					$service_info['depict'] = '';
				}
				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['image']) && is_file(DIR_IMAGE . $service['image'])) {
					$service_info['image'] = $this->model_tool_image->resize($service['image'], 50, 50);
				} else {
					$service_info['image'] = $this->model_tool_image->resize('placeholder.png', 50, 50);
				}

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

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

	}
}