<?php
class ControllerExtensionModuleocarouselbanner extends Controller {
	public function index($setting) {
		$data['bgcolorcss'] = $setting['bgcolorcss'];
		$data['titleposition'] = $setting['titleposition'];
		$data['titlefontsize'] = $setting['titlefontsize'];
		$data['titlecss'] = $setting['titlecss'];
		$data['describebjc'] = $setting['describebjc'];
		$data['ocrgba'] = $setting['ocrgba'];
		$data['buttoncss'] = $setting['buttoncss'];
		$data['buttonbjcss'] = $setting['buttonbjcss'];
		$data['buttontitcss'] = $setting['buttontitcss'];
		$data['buttontithover'] = $setting['buttontithover'];
		$data['buttonradius'] = $setting['buttonradius'];
		$data['buttonname1'] = $setting['buttonname1'];
		$data['buttonname2'] = $setting['buttonname2'];
		$data['qq1'] = $setting['qq1'];
		$data['qq2'] = $setting['qq2'];
		$data['alww1'] = $setting['alww1'];
		$data['alww2'] = $setting['alww2'];	
		$data['link1'] = $setting['link1'];
		$data['link2'] = $setting['link2'];
		$data['icons1'] = $setting['icons1'];
		$data['icons2'] = $setting['icons2'];
		$data['buttoncolor1'] = $setting['buttoncolor1'];
		$data['buttoncolor2'] = $setting['buttoncolor2'];
		$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['buttonposition'] = $setting['buttonposition'];
		$data['slidewidth'] = $setting['slidewidth'];	       
        $data['slideheight'] = $setting['slideheight'];
        $data['slideradius'] = $setting['slideradius'];	
        $data['slidebjcolor'] = $setting['slidebjcolor'];
        $data['bjcolorafter'] = $setting['bjcolorafter'];
        $data['sliderborder'] = $setting['sliderborder'];
        $data['sliderborderw'] = $setting['sliderborderw'];	
        $data['sliderborderrd'] = $setting['sliderborderrd'];			
        $data['sliderhkc'] = $setting['sliderhkc'];
        $data['sliderpadding'] = $setting['sliderpadding'];
        $data['sectiontab'] = $setting['sectiontab'];	
		$data['slidewidthtwo'] = $setting['slidewidthtwo'];	       
        $data['slideheighttwo'] = $setting['slideheighttwo'];
        $data['slideradiustwo'] = $setting['slideradiustwo'];	
		$data['slidefsizetwo'] = $setting['slidefsizetwo'];	
        $data['slidebackgroundtwo'] = $setting['slidebackgroundtwo'];
        $data['slidecolortwo'] = $setting['slidecolortwo'];
        $data['sliderbordertwo'] = $setting['sliderbordertwo'];	
        $data['sliderhkctwo'] = $setting['sliderhkctwo'];
        $data['slideformtwo'] = $setting['slideformtwo'];
		
		$data['ocbr'] = $setting['ocbr'];
		$data['ocbpa'] = $setting['ocbpa'];
		$data['ocbw'] = $setting['ocbw'];
		$data['ocbwposition'] = $setting['ocbwposition'];
		$data['bannerbgc'] = $setting['bannerbgc'];
		$data['bannerbgcjb'] = $setting['bannerbgcjb'];
		$data['ocbpo'] = $setting['ocbpo'];
		$data['ocbpowidth'] = $setting['ocbpowidth'];
		$data['ocbvh'] = $setting['ocbvh'];
		$data['ocbmh'] = $setting['ocbmh'];
		$data['autoplay'] = $setting['autoplay'];
		$data['speed'] = $setting['speed'];
		$data['fade'] = $setting['fade'];
		$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['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['image']) && is_file(DIR_IMAGE . $service['image'])) {
					$service_info['image'] = $this->model_tool_image->resize($service['image'], 1600, 750);
				} else {
					$service_info['image'] = $this->model_tool_image->resize('placeholder.png', 1600, 750);
				}

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

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

	}
}