<?php

$loader = $this->registry->get('load');
$loader->controller('module/filter');

class ControllerModuleFuturaFiltroValor extends ControllerModuleFilter {

	protected function index($setting) {

		if(!$this->config->get('futurafiltrovalor_status')){
			return false;
		}

		$this->app();

		$this->data['futurafiltrovalor_status'] = $this->config->get('futurafiltrovalor_status');

		$this->load->helper('ftr_geral');
		$this->language->load('module/futurafiltrovalor');

		$this->data['heading_title_price']        = $this->language->get('heading_title_price');
		$this->data['text_price_inicial']         = $this->language->get('text_price_inicial');
		$this->data['text_price_final']           = $this->language->get('text_price_final');
		$this->data['text_clear']                 = $this->language->get('text_clear');
		$this->data['error_price']                = $this->language->get('error_price');
		$this->data['button_search']              = $this->language->get('button_search');

		$btncolor 		 = '' ;
		$btncolorhover = '' ;

		if( (ftr_geral::isIsset($this->config->get('color_btn_price')) && $this->config->get('color_btn_price')!='')
		&& (ftr_geral::isIsset($this->config->get('color_btn_price_houver')) && $this->config->get('color_btn_price_houver')!="") ){
			$btncolor			 = $this->config->get('color_btn_price') ;
			$btncolorhover = $this->config->get('color_btn_price_houver') ;
		}

		$this->data['btncolor']  			= $btncolor 		 ;
		$this->data['btncolorhover']  = $btncolorhover ;

        $data = parent::getFilters();
        if(($data['price_initial']!='') || ($data['price_laste']!='')){
          $this->data['clearprice'] = true;
        }else{
          $this->data['clearprice'] = false;
        }

        $this->data['price_initial'] = $data['price_initial'];
        $this->data['price_laste']   = $data['price_laste'];

		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/futurafiltrovalor.twig')) {
			$this->template = $this->config->get('config_template') . '/template/module/futurafiltrovalor.twig';
		} else {
			$this->template = 'default/template/module/futurafiltrovalor.twig';
		}

		$this->render('module/futurafiltrovalor');
	}

	public function app(){
		if($this->ftrgeralregistry->isApp()){
			$this->document->addScriptApp(array(
				'catalog/view/theme/appmobile/public/js/jquery.mask.js'
			));
		}
	}

}
