<?php
class ControllerExtensionModuleprice 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['boxbjhover'] = $setting['boxbjhover'];
        $data['boxcolorhover'] = $setting['boxcolorhover'];		
		$data['mouseafter'] = $setting['mouseafter'];
        $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['boxprice'] = $setting['boxprice'];
		$data['boxpriceyj'] = $setting['boxpriceyj'];
		$data['boxterm'] = $setting['boxterm'];	
		$data['boxlinewidth'] = $setting['boxlinewidth'];
		$data['boxline'] = $setting['boxline'];	
		$data['boxbs'] = $setting['boxbs'];	
		$data['boxmagin'] = $setting['boxmagin'];
		$data['boxpadding'] = $setting['boxpadding'];
		$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['buttonsize'] = $setting['buttonsize'];
		$data['buttoninset'] = $setting['buttoninset'];	       
        $data['buttonborder'] = $setting['buttonborder'];
        $data['buttonround'] = $setting['buttonround'];	
        $data['buttonhover'] = $setting['buttonhover'];
        $data['buttond'] = $setting['buttond'];	
		$data['qq1'] = $setting['qq1'];
		$data['alww1'] = $setting['alww1'];
		$data['qq2'] = $setting['qq2'];
		$data['alww2'] = $setting['alww2'];
		$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['titlems'][$this->config->get('config_language_id')])) {
					$service_info['titlems'] = trim($service['titlems'][$this->config->get('config_language_id')]);
				} else {
					$service_info['titlems'] = '';
				}
				if (isset($service['price'][$this->config->get('config_language_id')])) {
					$service_info['price'] = trim($service['price'][$this->config->get('config_language_id')]);
				} else {
					$service_info['price'] = '';
				}
				if (isset($service['price1'][$this->config->get('config_language_id')])) {
					$service_info['price1'] = trim($service['price1'][$this->config->get('config_language_id')]);
				} else {
					$service_info['price1'] = '';
				}			
				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['text2'][$this->config->get('config_language_id')])) {
					$service_info['text2'] = trim($service['text2'][$this->config->get('config_language_id')]);
				} else {
					$service_info['text2'] = '';
				}
				if (isset($service['text3'][$this->config->get('config_language_id')])) {
					$service_info['text3'] = trim($service['text3'][$this->config->get('config_language_id')]);
				} else {
					$service_info['text3'] = '';
				}
				if (isset($service['text4'][$this->config->get('config_language_id')])) {
					$service_info['text4'] = trim($service['text4'][$this->config->get('config_language_id')]);
				} else {
					$service_info['text4'] = '';
				}
				if (isset($service['text5'][$this->config->get('config_language_id')])) {
					$service_info['text5'] = trim($service['text5'][$this->config->get('config_language_id')]);
				} else {
					$service_info['text5'] = '';
				}
				if (isset($service['text6'][$this->config->get('config_language_id')])) {
					$service_info['text6'] = trim($service['text6'][$this->config->get('config_language_id')]);
				} else {
					$service_info['text6'] = '';
				}
				if (isset($service['text7'][$this->config->get('config_language_id')])) {
					$service_info['text7'] = trim($service['text7'][$this->config->get('config_language_id')]);
				} else {
					$service_info['text7'] = '';
				}	
				if (isset($service['text8'][$this->config->get('config_language_id')])) {
					$service_info['text8'] = trim($service['text8'][$this->config->get('config_language_id')]);
				} else {
					$service_info['text8'] = '';
				}																											

				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/price.tpl')) {
				return $this->load->view($this->config->get('config_template') . 'extension/module/price.tpl', $data);
			} else {
				return $this->load->view('extension/module/price.tpl', $data);
			}
		}

	}
}