Jump to content

Edit History

JavierP

JavierP

hace 22 horas, 4you.software dijo:

and you know you didn't display the most important part of the code?
It is necessary to show the whole code of the hook, especially the return part.

You can't hide important information for advice.

If you put an image instead of a text code, no one here will write the entire code and copy the code from the image.
Your mistake.
Sorry, unfortunately you won't get an answer from me.

I am also not a free private counseling center and do not write me any private messages anymore.

Answer ?
I can write the same as yours. You have to write if ....
....
return ....
...
;

Fill in the code according to your code image.

Sorry.

 

JavierP

JavierP

hace 8 minutos, 4you.software dijo:

and you know you didn't display the most important part of the code?
It is necessary to show the whole code of the hook, especially the return part.

You can't hide important information for advice.

If you put an image instead of a text code, no one here will write the entire code and copy the code from the image.
Your mistake.
Sorry, unfortunately you won't get an answer from me.

I am also not a free private counseling center and do not write me any private messages anymore.

Answer ?
I can write the same as yours. You have to write if ....
....
return ....
...
;

Fill in the code according to your code image.

Sorry.

<?php
/**
* DISCLAIMER
*
*  @author    Sakosys

*  @copyright 2014-2017 SolverCircle
*  @license   http://opensource.org/licenses/LGPL-2.1
*  International Registered Trademark & Property of Sakosys
*/

if (!defined('_PS_VERSION_'))
	exit;

class PartsFilter extends Module
{
	public function __construct()
	{
	    $this->name = 'partsfilter';
		$this->tab = 'front_office_features';
		$this->version = '3.0.0';
		$this->author = 'SakoSys';
		$this->need_instance = 0;

		$this->bootstrap = true;
		parent::__construct();

		$this->displayName = $this->l('Vehicle Parts Finder');
		$this->description = $this->l('Find Your Auto Parts Based On Make Model Year');
		$this->ps_versions_compliancy = array('min' => '1.5.6.1', 'max' => _PS_VERSION_);
		
		$this->tabParentClassName = 'AdminCarMakeNoNeed';
        $this->parentTabName = 'Vehicle Parts Finder';
        $this->tabFirstChildName = 'Manage Make';
        $this->tabChildFirstClassName = 'AdminCarMake';
        $this->tabSecoendChildName = 'Manage Model';
        $this->tabChildSecoendClassName = 'AdminCarModel';

        $this->tabNuevoChildName = 'Manage Nuevo';
        $this->tabChildNuevoClassName = 'AdminCarNuevo';

		$this->tabChildThirdName = 'Manage Year';
        $this->tabChildThirdClassName = 'AdminCarYear';
		$this->tabChildFourthName = 'CSV Import';
        $this->tabChildFourthClassName = 'AdminMMYCSV';
		$this->tabChildFifthName = 'Product Map With Filter';
        $this->tabChildFifthClassName = 'AdminFilterAssign';
	}

	public function install()
	{
		if (!parent::install()) {
            return false;
        }
        //here add admin tab
        $tab = new Tab();
        $tab->class_name = $this->tabParentClassName;
        $tab->module = $this->name;
        $languages = Language::getLanguages();
        foreach ($languages as $language) {
            $tab->name[$language['id_lang']] = $this->parentTabName;
        }
        $tab->add();
        //here we create first child TAB
        $tab_first_child = new Tab();
        foreach ($languages as $language) {
            $tab_first_child->name[$language['id_lang']] = $this->tabFirstChildName;
        }
        $tab_first_child->class_name = $this->tabChildFirstClassName;
        $tab_first_child->id_parent = $tab->id;
        $tab_first_child->module = $this->name;
        $tab_first_child->add();
        //here we create secoend child TAB
        $tab_secoend_child = new Tab();
        foreach ($languages as $language) {
            $tab_secoend_child->name[$language['id_lang']] = $this->tabSecoendChildName;
        }
        $tab_secoend_child->class_name = $this->tabChildSecoendClassName;
        $tab_secoend_child->id_parent = $tab->id;
        $tab_secoend_child->module = $this->name;
        $tab_secoend_child->add();


        $tab_nuevo_child = new Tab();
        foreach ($languages as $language) {
            $tab_nuevo_child->name[$language['id_lang']] = $this->tabNuevoChildName;
        }
        $tab_nuevo_child->class_name = $this->tabChildNuevoClassName;
        $tab_nuevo_child->id_parent = $tab->id;
        $tab_nuevo_child->module = $this->name;
        $tab_nuevo_child->add();


		//here we create third child TAB
        $tab_third_child = new Tab();
        foreach ($languages as $language) {
            $tab_third_child->name[$language['id_lang']] = $this->tabChildThirdName;
        }
        $tab_third_child->class_name = $this->tabChildThirdClassName;
        $tab_third_child->id_parent = $tab->id;
        $tab_third_child->module = $this->name;
        $tab_third_child->add();
		//here we create fifth child TAB
        $tab_fifth_child = new Tab();
        foreach ($languages as $language) {
            $tab_fifth_child->name[$language['id_lang']] = $this->tabChildFifthName;
        }
        $tab_fifth_child->class_name = $this->tabChildFifthClassName;
        $tab_fifth_child->id_parent = $tab->id;
        $tab_fifth_child->module = $this->name;
        $tab_fifth_child->add();
		//here we create fourth child TAB
        $tab_fourth_child = new Tab();
        foreach ($languages as $language) {
            $tab_fourth_child->name[$language['id_lang']] = $this->tabChildFourthName;
        }
        $tab_fourth_child->class_name = $this->tabChildFourthClassName;
        $tab_fourth_child->id_parent = $tab->id;
        $tab_fourth_child->module = $this->name;
        $tab_fourth_child->add();
		//copy override controller
		copy(__DIR__.'/override/controllers/front/SearchController.php', _PS_ROOT_DIR_.'/override/controllers/front/SearchController.php');
		return $this->alterTable('add') && $this->registerHook('backOfficeHeader') && $this->registerHook('displayLeftColumn') && $this->registerHook('displayTop') && $this->registerHook('header') && $this->registerHook('footer') && $this->registerHook('displayFooter') && Configuration::updateValue('SSMAKEMODELYEAR', 'Find Your Parts By Make Model and Year');
	}

	public function uninstall()
	{
		 $moduleTabs = Tab::getCollectionFromModule($this->name);
        if (!empty($moduleTabs)) {
            foreach ($moduleTabs as $moduleTab) {
                $moduleTab->delete();
            }
        }
		//remove override controller
		if(file_exists(_PS_ROOT_DIR_.'/override/controllers/front/SearchController.php')){
		  unlink(_PS_ROOT_DIR_.'/override/controllers/front/SearchController.php');
		}
		//remove override class
		if(file_exists(_PS_ROOT_DIR_.'/override/classes/Search.php')){
		  unlink(_PS_ROOT_DIR_.'/override/classes/Search.php');
		}
		return parent::uninstall() && $this->alterTable('remove') && Configuration::deleteByName('SSMAKEMODELYEAR');
	}
	public function hookBackOfficeHeader($params)
    {
        $this->context->controller->addCSS($this->getPathUri(). 'views/css/admin_menu_icon.css');
    }
	/*Admin Settings Page*/
	public function getContent()
	{
		$html = '';
		if (Tools::isSubmit('SubmitCarMMYFilterSettings'))
		{
			Configuration::updateValue('PS_MMY_TOP_TEXT', (string)Tools::getValue('PS_MMY_TOP_TEXT'));
			Configuration::updateValue('PS_MMY_BOX_HEADER', (string)Tools::getValue('PS_MMY_BOX_HEADER'));
			Configuration::updateValue('PS_MMY_MAKE_DEFAULT_TEXT', (string)Tools::getValue('PS_MMY_MAKE_DEFAULT_TEXT'));
			Configuration::updateValue('PS_MMY_MODEL_DEFAULT_TEXT', (string)Tools::getValue('PS_MMY_MODEL_DEFAULT_TEXT'));
            Configuration::updateValue('PS_MMY_NUEVO_DEFAULT_TEXT', (string)Tools::getValue('PS_MMY_NUEVO_DEFAULT_TEXT'));
			Configuration::updateValue('PS_MMY_YEAR_DEFAULT_TEXT', (string)Tools::getValue('PS_MMY_YEAR_DEFAULT_TEXT'));
			Configuration::updateValue('PS_MMY_MAKE_TEXT', (string)Tools::getValue('PS_MMY_MAKE_TEXT'));
			Configuration::updateValue('PS_MMY_MODEL_TEXT', (string)Tools::getValue('PS_MMY_MODEL_TEXT'));
			Configuration::updateValue('PS_MMY_YEAR_TEXT', (string)Tools::getValue('PS_MMY_YEAR_TEXT'));
			Configuration::updateValue('PS_MMY_MAKE_REQUIRED_TEXT', (string)Tools::getValue('PS_MMY_MAKE_REQUIRED_TEXT'));
			Configuration::updateValue('PS_MMY_MODEL_REQUIRED_TEXT', (string)Tools::getValue('PS_MMY_MODEL_REQUIRED_TEXT'));
            Configuration::updateValue('PS_MMY_NUEVO_REQUIRED_TEXT', (string)Tools::getValue('PS_MMY_NUEVO_REQUIRED_TEXT'));
			Configuration::updateValue('PS_MMY_YEAR_REQUIRED_TEXT', (string)Tools::getValue('PS_MMY_YEAR_REQUIRED_TEXT'));
			Configuration::updateValue('PS_MMY_FILTER_BUTTON_TEXT', (string)Tools::getValue('PS_MMY_FILTER_BUTTON_TEXT'));
			Configuration::updateValue('PS_MMY_FILTER_BOX_LABEL', (int)Tools::getValue('PS_MMY_FILTER_BOX_LABEL'));
			Configuration::updateValue('PS_MMY_FILTER_VALIDATE_REQURED', (int)Tools::getValue('PS_MMY_FILTER_VALIDATE_REQURED'));
			$html .= $this->displayConfirmation($this->l('Car Parts Filter Configaration Save Successfully'));
		}
		return $html.$this->renderForm();
	}
	public function renderForm()
	{
		$fields_form = array(
			'form' => array(
				'legend' => array(
					'title' => $this->l('Settings'),
					'icon' => 'icon-cogs'
				),
				'input' => array(
					array(
						'type' => 'text',
						'label' => $this->l('Search Page Top Text:'),
						'name' => 'PS_MMY_TOP_TEXT',
						'suffix' => $this->l('Filter Page Header Text')
					),
					array(
						'type' => 'text',
						'label' => $this->l('Filter Box Header Text:'),
						'name' => 'PS_MMY_BOX_HEADER',
						'suffix' => $this->l('Filter Box Header Text')
					),
					array(
						'type' => 'text',
						'label' => $this->l('Make Dropdown Default Text:'),
						'name' => 'PS_MMY_MAKE_DEFAULT_TEXT',
						'suffix' => $this->l('Make Dropdownlist Default Text')
					),
					array(
						'type' => 'text',
						'label' => $this->l('Model Dropdown Default Text:'),
						'name' => 'PS_MMY_MODEL_DEFAULT_TEXT',
						'suffix' => $this->l('Model Dropdownlist Default Text')
					),
                    array(
                        'type' => 'text',
                        'label' => $this->l('Nuevo Dropdown Default Text:'),
                        'name' => 'PS_MMY_NUEVO_DEFAULT_TEXT',
                        'suffix' => $this->l('Nuevo Dropdownlist Default Text')
                    ),
					array(
						'type' => 'text',
						'label' => $this->l('Year Dropdown Default Text:'),
						'name' => 'PS_MMY_YEAR_DEFAULT_TEXT',
						'suffix' => $this->l('Year Dropdownlist Default Text')
					),
					array(
						'type' => 'text',
						'label' => $this->l('Make Text:'),
						'name' => 'PS_MMY_MAKE_TEXT',
						'suffix' => $this->l('Make Text')
					),
					array(
						'type' => 'text',
						'label' => $this->l('Model Text:'),
						'name' => 'PS_MMY_MODEL_TEXT',
						'suffix' => $this->l('Model Text')
					),
                    array(
                        'type' => 'text',
                        'label' => $this->l('Nuevo Text:'),
                        'name' => 'PS_MMY_NUEVO_TEXT',
                        'suffix' => $this->l('Nuevo Text')
                    ),
					array(
						'type' => 'text',
						'label' => $this->l('Year Text:'),
						'name' => 'PS_MMY_YEAR_TEXT',
						'suffix' => $this->l('Year Text')
					),
					array(
						'type' => 'text',
						'label' => $this->l('Make Required Text:'),
						'name' => 'PS_MMY_MAKE_REQUIRED_TEXT',
						'suffix' => $this->l('Required Text')
					),
					array(
						'type' => 'text',
						'label' => $this->l('Model Required Text:'),
						'name' => 'PS_MMY_MODEL_REQUIRED_TEXT',
						'suffix' => $this->l('Required Text')
					),
                    array(
                        'type' => 'text',
                        'label' => $this->l('Nuevo Required Text:'),
                        'name' => 'PS_MMY_NUEVO_REQUIRED_TEXT',
                        'suffix' => $this->l('Required Text')
                    ),
					array(
						'type' => 'text',
						'label' => $this->l('Year Required Text:'),
						'name' => 'PS_MMY_YEAR_REQUIRED_TEXT',
						'suffix' => $this->l('Required Text')
					),
					array(
						'type' => 'text',
						'label' => $this->l('Filter Button Text:'),
						'name' => 'PS_MMY_FILTER_BUTTON_TEXT',
						'suffix' => $this->l('Filter Button Text')
					),
					array(
						'type' => 'switch',
						'label' => $this->l('Hide Filter Box Label ? '),
						'desc' => $this->l('If yes hide filter box label'),
						'name' => 'PS_MMY_FILTER_BOX_LABEL',
						'values' => array(
							array(
								'id' => 'active_on',
								'value' => 1,
								'label' => $this->l('Enabled')
							),
							array(
								'id' => 'active_off',
								'value' => 0,
								'label' => $this->l('Disabled')
							)
						),
					),
					array(
						'type' => 'switch',
						'label' => $this->l('Validate Required ? '),
						'desc' => $this->l('If yes customer need to select all'),
						'name' => 'PS_MMY_FILTER_VALIDATE_REQURED',
						'values' => array(
							array(
								'id' => 'active_on',
								'value' => 1,
								'label' => $this->l('Enabled')
							),
							array(
								'id' => 'active_off',
								'value' => 0,
								'label' => $this->l('Disabled')
							)
						),
					),
				),
				'submit' => array(
					'title' => $this->trans('Save', array(), 'Admin.Actions')
				)
			),
		);

		$helper = new HelperForm();
		$helper->show_toolbar = false;
		$helper->table = $this->table;
		$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
		$helper->default_form_language = $lang->id;
		$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
		$this->fields_form = array();

		$helper->identifier = $this->identifier;
		$helper->submit_action = 'SubmitCarMMYFilterSettings';
		$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
		$helper->token = Tools::getAdminTokenLite('AdminModules');
		$helper->tpl_vars = array(
			'fields_value' => $this->getConfigFieldsValues(),
			'languages' => $this->context->controller->getLanguages(),
			'id_language' => $this->context->language->id
		);

		return $helper->generateForm(array($fields_form));
	}
	
	
	public function getConfigFieldsValues()
	{
		$top_text = "Make Model Year Filter Result";
		$header_text = "Find Your Parts";
		$make_ddl_default_text = "--Select Make--";
		$model_ddl_default_text = "--Select Model--";
        $nuevo_ddl_default_text = "--Select Nuevo--";
		$year_ddl_default_text = "--Select Year--";
		$make_text = 'Make';
		$model_text = 'Model';
		$year_text = 'Year';
		$make_required = 'Make Required';
		$model_required = 'Model Required';
		$year_required = 'Year Required';
		$filter_button_text = 'Filter';
		$hide_filter_label = 0;
		$validate_required = 1;
		
		if(Configuration::get('PS_MMY_TOP_TEXT') != ''){
			$top_text = Configuration::get('PS_MMY_TOP_TEXT');
		}
		if(Configuration::get('PS_MMY_BOX_HEADER') != ''){
			$header_text = Configuration::get('PS_MMY_BOX_HEADER');
		}
		if(Configuration::get('PS_MMY_MAKE_DEFAULT_TEXT') != ''){
			$make_ddl_default_text = Configuration::get('PS_MMY_MAKE_DEFAULT_TEXT');
		}
		if(Configuration::get('PS_MMY_MODEL_DEFAULT_TEXT') != ''){
			$model_ddl_default_text = Configuration::get('PS_MMY_MODEL_DEFAULT_TEXT');
		}
        if(Configuration::get('PS_MMY_NUEVO_DEFAULT_TEXT') != ''){
            $nuevo_ddl_default_text = Configuration::get('PS_MMY_NUEVO_DEFAULT_TEXT');
        }
		if(Configuration::get('PS_MMY_YEAR_DEFAULT_TEXT') != ''){
			$year_ddl_default_text = Configuration::get('PS_MMY_YEAR_DEFAULT_TEXT');
		}
		if(Configuration::get('PS_MMY_MAKE_TEXT') != ''){
			$make_text = Configuration::get('PS_MMY_MAKE_TEXT');
		}
		if(Configuration::get('PS_MMY_MODEL_TEXT') != ''){
			$model_text = Configuration::get('PS_MMY_MODEL_TEXT');
		}
		if(Configuration::get('PS_MMY_YEAR_TEXT') != ''){
			$year_text = Configuration::get('PS_MMY_YEAR_TEXT');
		}
		if(Configuration::get('PS_MMY_MAKE_REQUIRED_TEXT') != ''){
			$make_required = Configuration::get('PS_MMY_MAKE_REQUIRED_TEXT');
		}
		if(Configuration::get('PS_MMY_MODEL_REQUIRED_TEXT') != ''){
			$model_required = Configuration::get('PS_MMY_MODEL_REQUIRED_TEXT');
		}
        if(Configuration::get('PS_MMY_NUEVO_REQUIRED_TEXT') != ''){
            $nuevo_required = Configuration::get('PS_MMY_NUEVO_REQUIRED_TEXT');
        }
		if(Configuration::get('PS_MMY_YEAR_REQUIRED_TEXT') != ''){
			$year_required = Configuration::get('PS_MMY_YEAR_REQUIRED_TEXT');
		}
		if(Configuration::get('PS_MMY_FILTER_BUTTON_TEXT') != ''){
			$filter_button_text = Configuration::get('PS_MMY_FILTER_BUTTON_TEXT');
		}
		if(Configuration::get('PS_MMY_FILTER_VALIDATE_REQURED') != ''){
			$validate_required = Configuration::get('PS_MMY_FILTER_VALIDATE_REQURED');
		}
		return array(
			'PS_MMY_TOP_TEXT' 					=> Tools::getValue('PS_MMY_TOP_TEXT', $top_text),
			'PS_MMY_BOX_HEADER' 				=> Tools::getValue('PS_MMY_BOX_HEADER', $header_text),
			'PS_MMY_MAKE_DEFAULT_TEXT' 			=> Tools::getValue('PS_MMY_MAKE_DEFAULT_TEXT', $make_ddl_default_text),
			'PS_MMY_MODEL_DEFAULT_TEXT' 		=> Tools::getValue('PS_MMY_MODEL_DEFAULT_TEXT', $model_ddl_default_text),
			'PS_MMY_NUEVO_DEFAULT_TEXT' 		=> Tools::getValue('PS_MMY_NUEVO_DEFAULT_TEXT', $nuevo_ddl_default_text),
			'PS_MMY_YEAR_DEFAULT_TEXT' 			=> Tools::getValue('PS_MMY_YEAR_DEFAULT_TEXT', $year_ddl_default_text),
			'PS_MMY_MAKE_TEXT'	 				=> Tools::getValue('PS_MMY_MAKE_TEXT', $make_text),
			'PS_MMY_MODEL_TEXT' 				=> Tools::getValue('PS_MMY_MODEL_TEXT', $model_text),
            'PS_MMY_NUEVO_TEXT' 				=> Tools::getValue('PS_MMY_NUEVO_TEXT', $model_text),
			'PS_MMY_YEAR_TEXT' 					=> Tools::getValue('PS_MMY_YEAR_TEXT', $year_text),
			'PS_MMY_MAKE_REQUIRED_TEXT' 		=> Tools::getValue('PS_MMY_MAKE_REQUIRED_TEXT', $make_required),
			'PS_MMY_MODEL_REQUIRED_TEXT' 		=> Tools::getValue('PS_MMY_MODEL_REQUIRED_TEXT', $model_required),
            'PS_MMY_NUEVO_REQUIRED_TEXT' 		=> Tools::getValue('PS_MMY_NUEVO_REQUIRED_TEXT', $model_required),
			'PS_MMY_YEAR_REQUIRED_TEXT' 		=> Tools::getValue('PS_MMY_YEAR_REQUIRED_TEXT', $year_required),
			'PS_MMY_FILTER_BUTTON_TEXT' 		=> Tools::getValue('PS_MMY_FILTER_BUTTON_TEXT', $filter_button_text),
			'PS_MMY_FILTER_BOX_LABEL' 			=> Tools::getValue('PS_MMY_FILTER_BOX_LABEL', $hide_filter_label),
			'PS_MMY_FILTER_VALIDATE_REQURED' 	=> Tools::getValue('PS_MMY_FILTER_VALIDATE_REQURED', $validate_required)
		);
	}
	public function alterTable($method)
	{
		switch ($method) {
			case 'add':
				$sql = 'CREATE TABLE IF NOT EXISTS ' . _DB_PREFIX_ . 'car_filter_data(`id_product` int(11),`make` VARCHAR(100) collate utf8_bin,`model` VARCHAR(100) collate utf8_bin, `nuevo` VARCHAR(100) collate utf8_bin,`year` VARCHAR(100) collate utf8_bin)';
				if(!Db::getInstance()->Execute($sql)){
					return false;
				}
				$sql_make = 'CREATE TABLE IF NOT EXISTS ' . _DB_PREFIX_ . 'carmake(`makeid` int(10) NOT NULL AUTO_INCREMENT,`makename` varchar(200) collate utf8_bin,PRIMARY KEY (`makeid`))';
				if(!Db::getInstance()->Execute($sql_make)){
					return false;
				}
				$sql_model = 'CREATE TABLE IF NOT EXISTS ' . _DB_PREFIX_ . 'carmodel(`modelid` int(10) NOT NULL AUTO_INCREMENT,`makeid` int(10) NOT NULL DEFAULT 0,`modelname` varchar(200) collate utf8_bin,PRIMARY KEY (`modelid`))';
				if(!Db::getInstance()->Execute($sql_model)){
					return false;
				}
                $sql_model = 'CREATE TABLE IF NOT EXISTS ' . _DB_PREFIX_ . 'carnuevo(`nuevoid` int(10) NOT NULL AUTO_INCREMENT,`makeid` int(10) NOT NULL DEFAULT 0,`modelid` int(10) NOT NULL DEFAULT 0,`nuevoname` varchar(200) collate utf8_bin,PRIMARY KEY (`nuevoid`))';
                if(!Db::getInstance()->Execute($sql_model)){
                    return false;
                }
                $sql_year = 'CREATE TABLE IF NOT EXISTS ' . _DB_PREFIX_ . 'caryear(`yearid` int(10) NOT NULL AUTO_INCREMENT,`makeid` int(10) NOT NULL DEFAULT 0,`modelid` int(10) NOT NULL DEFAULT 0,`nuevoid` int(10) NOT NULL DEFAULT 0 , `year` varchar(200) collate utf8_bin,PRIMARY KEY (`yearid`))';
				if(!Db::getInstance()->Execute($sql_year)){
					return false;
				}	
				break;
			
			case 'remove':
				Db::getInstance()->Execute("DROP TABLE IF EXISTS " . _DB_PREFIX_ . "car_filter_data");
				Db::getInstance()->Execute("DROP TABLE IF EXISTS " . _DB_PREFIX_ . "carmake");
				Db::getInstance()->Execute("DROP TABLE IF EXISTS " . _DB_PREFIX_ . "carmodel");
                Db::getInstance()->Execute("DROP TABLE IF EXISTS " . _DB_PREFIX_ . "carnuevo");
				Db::getInstance()->Execute("DROP TABLE IF EXISTS " . _DB_PREFIX_ . "caryear");
				break;
		}
		return true;
	}
	
	public function hookDisplayTop($params){
		$currentCategory = Tools::getValue ('id_category');
if ($currentCategory! = 2)
return;
		$top_text = "Make Model Year Filter Result";
		$header_text = "Find Your Parts";
		$make_ddl_default_text = "--Select Make--";
		$model_ddl_default_text = "--Select Model--";
        $nuevo_ddl_default_text = "--Select Nuevo--";
		$year_ddl_default_text = "--Select Year--";
		$make_text = 'Make';
		$model_text = 'Model';
        $nuevo_text = 'Nuevo';
		$year_text = 'Year';
		$make_required = 'Make Required';
		$model_required = 'Model Required';
        $nuevo_required = 'Nuevo Required';
		$year_required = 'Year Required';
		$filter_button_text = 'Filter';
		$hide_filter_label = 0;
		$validate_required = 1;
		
		if(Configuration::get('PS_MMY_TOP_TEXT') != ''){
			$top_text = Configuration::get('PS_MMY_TOP_TEXT');
		}
		if(Configuration::get('PS_MMY_BOX_HEADER') != ''){
			$header_text = Configuration::get('PS_MMY_BOX_HEADER');
		}
		if(Configuration::get('PS_MMY_MAKE_DEFAULT_TEXT') != ''){
			$make_ddl_default_text = Configuration::get('PS_MMY_MAKE_DEFAULT_TEXT');
		}
		if(Configuration::get('PS_MMY_MODEL_DEFAULT_TEXT') != ''){
			$model_ddl_default_text = Configuration::get('PS_MMY_MODEL_DEFAULT_TEXT');
		}
        if(Configuration::get('PS_MMY_NUEVO_DEFAULT_TEXT') != ''){
            $nuevo_ddl_default_text = Configuration::get('PS_MMY_NUEVO_DEFAULT_TEXT');
        }
		if(Configuration::get('PS_MMY_YEAR_DEFAULT_TEXT') != ''){
			$year_ddl_default_text = Configuration::get('PS_MMY_YEAR_DEFAULT_TEXT');
		}
		if(Configuration::get('PS_MMY_MAKE_TEXT') != ''){
			$make_text = Configuration::get('PS_MMY_MAKE_TEXT');
		}
		if(Configuration::get('PS_MMY_MODEL_TEXT') != ''){
			$model_text = Configuration::get('PS_MMY_MODEL_TEXT');
		}
        if(Configuration::get('PS_MMY_NUEVO_TEXT') != ''){
            $nuevo_text = Configuration::get('PS_MMY_NUEVO_TEXT');
        }
		if(Configuration::get('PS_MMY_YEAR_TEXT') != ''){
			$year_text = Configuration::get('PS_MMY_YEAR_TEXT');
		}
		if(Configuration::get('PS_MMY_MAKE_REQUIRED_TEXT') != ''){
			$make_required = Configuration::get('PS_MMY_MAKE_REQUIRED_TEXT');
		}
		if(Configuration::get('PS_MMY_MODEL_REQUIRED_TEXT') != ''){
			$model_required = Configuration::get('PS_MMY_MODEL_REQUIRED_TEXT');
		}
        if(Configuration::get('PS_MMY_NUEVO_REQUIRED_TEXT') != ''){
            $nuevo_required = Configuration::get('PS_MMY_NUEVO_REQUIRED_TEXT');
        }
		if(Configuration::get('PS_MMY_YEAR_REQUIRED_TEXT') != ''){
			$year_required = Configuration::get('PS_MMY_YEAR_REQUIRED_TEXT');
		}
		if(Configuration::get('PS_MMY_FILTER_BUTTON_TEXT') != ''){
			$filter_button_text = Configuration::get('PS_MMY_FILTER_BUTTON_TEXT');
		}
		if(Configuration::get('PS_MMY_FILTER_BOX_LABEL') != ''){
			$hide_filter_label = Configuration::get('PS_MMY_FILTER_BOX_LABEL');
		}
		if(Configuration::get('PS_MMY_FILTER_VALIDATE_REQURED') != ''){
			$validate_required = Configuration::get('PS_MMY_FILTER_VALIDATE_REQURED');
		}

		/*Filter values*/
		$make_id = 0;
		$model_id = 0;
        $nuevo_id = 0;
		$year_id = 0;
		$model_html = '';
        $nuevo_html = '';
		$year_html = '';


		/****    AQUI     ****/
		
		if(Tools::getValue('make') && Tools::getValue('make') != '') {
			$make_id = Tools::getValue('make');
		}
		if(Tools::getValue('model') && Tools::getValue('model') != '') {
			$model_id = Tools::getValue('model');
		}
        if(Tools::getValue('nuevo') && Tools::getValue('nuevo') != '') {
            $nuevo_id = Tools::getValue('nuevo');
        }
		if(Tools::getValue('year') && Tools::getValue('year') != '') {
			$year_id = Tools::getValue('year');
		}
		if(Tools::getValue('make') && Tools::getValue('make') != '' && Tools::getValue('model') && Tools::getValue('model') != '') {
			$model_html = $this->getFilterBoxModelHtml(Tools::getValue('make'), Tools::getValue('model'));
		}
        if(Tools::getValue('make') && Tools::getValue('make') != '' && Tools::getValue('model') && Tools::getValue('model') != '' && Tools::getValue('nuevo') && Tools::getValue('nuevo') != '') {
            $nuevo_html = $this->getFilterBoxNuevoHtml(Tools::getValue('make'), Tools::getValue('model') , Tools::getValue('nuevo'));
        }
		if(Tools::getValue('make') && Tools::getValue('make') != '' && Tools::getValue('model') && Tools::getValue('model') != '' && Tools::getValue('year') && Tools::getValue('year') != '' && Tools::getValue('nuevo') != '') {
			$year_html = $this->getFilterBoxYearHtml(Tools::getValue('make'), Tools::getValue('model'), Tools::getValue('nuevo'), Tools::getValue('year'));
		}
		
		$ps__base_url = Context::getContext()->shop->getBaseURL(true);
		$base_url_module = $ps__base_url . 'modules/partsfilter/';
		$filter_url = $this->context->link->getPagelink('search').'?controller=search&s=apf';
		$make_data = $this->getAllMakeData();
		$this->context->smarty->assign(array(
			'base_url_module'			=> $base_url_module,
			'header_text'				=> $header_text,
			'make_text'					=> $make_text,
			'model_text'				=> $model_text,
            'nuevo_text'				=> $nuevo_text,
			'year_text'					=> $year_text,
			'make_ddl_default_text'		=> $make_ddl_default_text,
			'model_ddl_default_text'	=> $model_ddl_default_text,
            'nuevo_ddl_default_text'	=> $nuevo_ddl_default_text,
			'year_ddl_default_text'		=> $year_ddl_default_text,
			'filter_button_text'		=> $filter_button_text,
			'hide_filter_label'			=> $hide_filter_label,
			'validate_required'			=> $validate_required,
			'make_data'					=> $make_data,
			'make_required'				=> $make_required,
			'model_required'			=> $model_required,
            'nuevo_required'			=> $nuevo_required,
			'year_required'				=> $year_required,
			'filter_url'				=> $filter_url,
			'make_id'					=> $make_id,
			'model_id'					=> $model_id,
			'year_id'					=> $year_id,
            'nuevo_id'					=> $nuevo_id,
			'model_xhtml'				=> $model_html,
            'nuevo_xhtml'				=> $nuevo_html,
			'year_html'					=> $year_html
		));
		return $this->display(__FILE__, 'views/templates/front/filterbox_top.tpl');
	}
	
	private function getFilterBoxModelHtml($makeId, $modelId) {
		$model_html = '';
		if(!empty($makeId) && $makeId > 0){
			$sql = "select * from " ._DB_PREFIX_. "carmodel where makeid = '" . (int)$makeId . "'";
			if ($results = Db::getInstance()->ExecuteS($sql)){
				foreach($results as $row){
					if($row['modelid'] == $modelId){
						$model_html .= "<option selected='selected' value='".$row['modelid']."'>".$row['modelname']."</option>";
					}
					else{
						$model_html .= "<option value='".$row['modelid']."'>".$row['modelname']."</option>";
					}	
				}
			}
		}
		return $model_html;
	}
    private function getFilterBoxNuevoHtml($makeId, $modelId , $nuevoId) {
        $nuevo_html = '';
        if(!empty($makeId) && $makeId > 0){
            $sql = "select * from " ._DB_PREFIX_. "carnuevo where makeid = '" . (int)$makeId . "' and modelid = '" . (int)$modelId . "'";
            if ($results = Db::getInstance()->ExecuteS($sql)){
                foreach($results as $row){
                    if($row['nuevoid'] == $nuevoId){
                        $nuevo_html .= "<option selected='selected' value='".$row['nuevoid']."'>".$row['nuevoname']."</option>";
                    }
                    else{
                        $nuevo_html .= "<option value='".$row['nuevoid']."'>".$row['nuevoname']."</option>";
                    }
                }
            }
        }
        return $nuevo_html;
    }
	private function getFilterBoxYearHtml($makeId, $modelId, $nuevoId, $yearId) {
		$year_html = '';
		if(!empty($makeId) && $makeId > 0 && !empty($modelId) && $modelId > 0 && !empty($nuevoId) && $nuevoId > 0  && !empty($yearId) && $yearId > 0){
			$sql = "select * from " ._DB_PREFIX_. "caryear where makeid = '" . (int)$makeId . "' and modelid = '" . (int)$modelId . "'and nuevoid = '" . (int)$nuevoId . "'";
			if ($results = Db::getInstance()->ExecuteS($sql)){
				foreach($results as $row){
					if($row['yearid'] == $yearId){
						$year_html .= "<option selected='selected' value='".$row['yearid']."'>".$row['year']."</option>";
					}
					else{
						$year_html .= "<option value='".$row['yearid']."'>".$row['year']."</option>";
					}	
				}
			}
		}
		return $year_html;
	}
	
	public function hookDisplayLeftColumn($params){
		$top_text = "Make Model Year Filter Result";
		$header_text = "Find Your Parts";
		$make_ddl_default_text = "--Select Make--";
		$model_ddl_default_text = "--Select Model--";
		$year_ddl_default_text = "--Select Year--";
		$make_text = 'Make';
		$model_text = 'Model';
        $nuevo_text = 'Nuevo';
		$year_text = 'Year';
		$make_required = 'Make Required';
		$model_required = 'Model Required';
        $nuevo_required = 'Nuevo Required';
		$year_required = 'Year Required';
		$filter_button_text = 'Filter';
		$hide_filter_label = 0;
		$validate_required = 1;
		
		if(Configuration::get('PS_MMY_TOP_TEXT') != ''){
			$top_text = Configuration::get('PS_MMY_TOP_TEXT');
		}
		if(Configuration::get('PS_MMY_BOX_HEADER') != ''){
			$header_text = Configuration::get('PS_MMY_BOX_HEADER');
		}
		if(Configuration::get('PS_MMY_MAKE_DEFAULT_TEXT') != ''){
			$make_ddl_default_text = Configuration::get('PS_MMY_MAKE_DEFAULT_TEXT');
		}
		if(Configuration::get('PS_MMY_MODEL_DEFAULT_TEXT') != ''){
			$model_ddl_default_text = Configuration::get('PS_MMY_MODEL_DEFAULT_TEXT');
		}
        if(Configuration::get('PS_MMY_NUEVO_DEFAULT_TEXT') != ''){
            $nuevo_ddl_default_text = Configuration::get('PS_MMY_NUEVO_DEFAULT_TEXT');
        }
		if(Configuration::get('PS_MMY_YEAR_DEFAULT_TEXT') != ''){
			$year_ddl_default_text = Configuration::get('PS_MMY_YEAR_DEFAULT_TEXT');
		}
		if(Configuration::get('PS_MMY_MAKE_TEXT') != ''){
			$make_text = Configuration::get('PS_MMY_MAKE_TEXT');
		}
		if(Configuration::get('PS_MMY_MODEL_TEXT') != ''){
			$model_text = Configuration::get('PS_MMY_MODEL_TEXT');
		}
        if(Configuration::get('PS_MMY_NUEVO_TEXT') != ''){
            $nuevo_text = Configuration::get('PS_MMY_NUEVO_TEXT');
        }
		if(Configuration::get('PS_MMY_YEAR_TEXT') != ''){
			$year_text = Configuration::get('PS_MMY_YEAR_TEXT');
		}
		if(Configuration::get('PS_MMY_MAKE_REQUIRED_TEXT') != ''){
			$make_required = Configuration::get('PS_MMY_MAKE_REQUIRED_TEXT');
		}
		if(Configuration::get('PS_MMY_MODEL_REQUIRED_TEXT') != ''){
			$model_required = Configuration::get('PS_MMY_MODEL_REQUIRED_TEXT');
		}
        if(Configuration::get('PS_MMY_NUEVO_REQUIRED_TEXT') != ''){
            $nuevo_required = Configuration::get('PS_MMY_NUEVO_REQUIRED_TEXT');
        }
		if(Configuration::get('PS_MMY_YEAR_REQUIRED_TEXT') != ''){
			$year_required = Configuration::get('PS_MMY_YEAR_REQUIRED_TEXT');
		}
		if(Configuration::get('PS_MMY_FILTER_BUTTON_TEXT') != ''){
			$filter_button_text = Configuration::get('PS_MMY_FILTER_BUTTON_TEXT');
		}
		if(Configuration::get('PS_MMY_FILTER_BOX_LABEL') != ''){
			$hide_filter_label = Configuration::get('PS_MMY_FILTER_BOX_LABEL');
		}
		if(Configuration::get('PS_MMY_FILTER_VALIDATE_REQURED') != ''){
			$validate_required = Configuration::get('PS_MMY_FILTER_VALIDATE_REQURED');
		}
		
		/*Filter values*/
		$make_id = 0;
		$model_id = 0;
        $nuevo_id = 0;
		$year_id = 0;
        $model_html = '';
        $nuevo_html = '';
		$year_html = '';
		
		if(Tools::getValue('make') && Tools::getValue('make') != '') {
			$make_id = Tools::getValue('make');
		}
		if(Tools::getValue('model') && Tools::getValue('model') != '') {
			$model_id = Tools::getValue('model');
		}
        if(Tools::getValue('nuevo') && Tools::getValue('nuevo') != '') {
            $nuevo_id = Tools::getValue('nuevo');
        }
		if(Tools::getValue('year') && Tools::getValue('year') != '') {
			$year_id = Tools::getValue('year');
		}
		
		if(Tools::getValue('make') && Tools::getValue('make') != '' && Tools::getValue('model') && Tools::getValue('model') != '') {
			$model_html = $this->getFilterBoxModelHtml(Tools::getValue('make'), Tools::getValue('model'));
		}
        if(Tools::getValue('make') && Tools::getValue('make') != '' && Tools::getValue('model') && Tools::getValue('model') != ''  && Tools::getValue('nuevo') && Tools::getValue('nuevo') != '') {
            $nuevo_html = $this->getFilterBoxNuevoHtml(Tools::getValue('make'), Tools::getValue('model') , Tools::getValue('nuevo'));
        }
		if(Tools::getValue('make') && Tools::getValue('make') != '' && Tools::getValue('model') && Tools::getValue('model') != ''  && Tools::getValue('nuevo') && Tools::getValue('nuevo') != '' && Tools::getValue('year') && Tools::getValue('year') != '') {
			$year_html = $this->getFilterBoxYearHtml(Tools::getValue('make'), Tools::getValue('model'), Tools::getValue('nuevo'), Tools::getValue('year'));
		}
		
		$ps__base_url = Context::getContext()->shop->getBaseURL(true);
		$base_url_module = $ps__base_url.'modules/partsfilter/';
		$filter_url = $this->context->link->getPagelink('search').'?controller=search&s=apf';
		$make_data = $this->getAllMakeData();
		$this->context->smarty->assign(array(
			'base_url_module'			=> $base_url_module,
			'header_text'				=> $header_text,
			'make_text'					=> $make_text,
			'model_text'				=> $model_text,
            'nuevo_text'				=> $nuevo_text,
			'year_text'					=> $year_text,
			'make_ddl_default_text'		=> $make_ddl_default_text,
			'model_ddl_default_text'	=> $model_ddl_default_text,
            'nuevo_ddl_default_text'	=> $nuevo_ddl_default_text,
			'year_ddl_default_text'		=> $year_ddl_default_text,
			'filter_button_text'		=> $filter_button_text,
			'hide_filter_label'			=> $hide_filter_label,
			'validate_required'			=> $validate_required,
			'make_data'					=> $make_data,
			'make_required'				=> $make_required,
			'model_required'			=> $model_required,
            'nuevo_required'			=> $nuevo_required,
			'year_required'				=> $year_required,
			'filter_url'				=> $filter_url,
			'make_id'					=> $make_id,
			'model_id'					=> $model_id,
            'nuevo_id'					=> $nuevo_id,
			'year_id'					=> $year_id,
			'model_xhtml'				=> $model_html,
            'nuevo_xhtml'				=> $nuevo_html,
			'year_html'					=> $year_html
		));
		return $this->display(__FILE__, 'views/templates/front/filterbox.tpl');
	}
	
	public function getAllMakeData(){
		$make_list = array();
		$sql = 'SELECT * FROM '._DB_PREFIX_.'carmake ORDER BY makename ASC';
		if ($results = Db::getInstance()->ExecuteS($sql)){
			foreach($results as $row){
				$make_list[] = array(
					'mid'			=> $row['makeid'],
					'name'			=> $row['makename']
				);
			}
		}
		return $make_list;
	}
}

 

JavierP

JavierP

hace 6 minutos, 4you.software dijo:

and you know you didn't display the most important part of the code?
It is necessary to show the whole code of the hook, especially the return part.

You can't hide important information for advice.

If you put an image instead of a text code, no one here will write the entire code and copy the code from the image.
Your mistake.
Sorry, unfortunately you won't get an answer from me.

I am also not a free private counseling center and do not write me any private messages anymore.

Answer ?
I can write the same as yours. You have to write if ....
....
return ....
...
;

Fill in the code according to your code image.

Sorry.

<?php
/**
* DISCLAIMER
*
*  @author    Sakosys

*  @copyright 2014-2017 SolverCircle
*  @license   http://opensource.org/licenses/LGPL-2.1
*  International Registered Trademark & Property of Sakosys
*/

if (!defined('_PS_VERSION_'))
	exit;

class PartsFilter extends Module
{
	public function __construct()
	{
	    $this->name = 'partsfilter';
		$this->tab = 'front_office_features';
		$this->version = '3.0.0';
		$this->author = 'SakoSys';
		$this->need_instance = 0;

		$this->bootstrap = true;
		parent::__construct();

		$this->displayName = $this->l('Vehicle Parts Finder');
		$this->description = $this->l('Find Your Auto Parts Based On Make Model Year');
		$this->ps_versions_compliancy = array('min' => '1.5.6.1', 'max' => _PS_VERSION_);
		
		$this->tabParentClassName = 'AdminCarMakeNoNeed';
        $this->parentTabName = 'Vehicle Parts Finder';
        $this->tabFirstChildName = 'Manage Make';
        $this->tabChildFirstClassName = 'AdminCarMake';
        $this->tabSecoendChildName = 'Manage Model';
        $this->tabChildSecoendClassName = 'AdminCarModel';

        $this->tabNuevoChildName = 'Manage Nuevo';
        $this->tabChildNuevoClassName = 'AdminCarNuevo';

		$this->tabChildThirdName = 'Manage Year';
        $this->tabChildThirdClassName = 'AdminCarYear';
		$this->tabChildFourthName = 'CSV Import';
        $this->tabChildFourthClassName = 'AdminMMYCSV';
		$this->tabChildFifthName = 'Product Map With Filter';
        $this->tabChildFifthClassName = 'AdminFilterAssign';
	}

	public function install()
	{
		if (!parent::install()) {
            return false;
        }
        //here add admin tab
        $tab = new Tab();
        $tab->class_name = $this->tabParentClassName;
        $tab->module = $this->name;
        $languages = Language::getLanguages();
        foreach ($languages as $language) {
            $tab->name[$language['id_lang']] = $this->parentTabName;
        }
        $tab->add();
        //here we create first child TAB
        $tab_first_child = new Tab();
        foreach ($languages as $language) {
            $tab_first_child->name[$language['id_lang']] = $this->tabFirstChildName;
        }
        $tab_first_child->class_name = $this->tabChildFirstClassName;
        $tab_first_child->id_parent = $tab->id;
        $tab_first_child->module = $this->name;
        $tab_first_child->add();
        //here we create secoend child TAB
        $tab_secoend_child = new Tab();
        foreach ($languages as $language) {
            $tab_secoend_child->name[$language['id_lang']] = $this->tabSecoendChildName;
        }
        $tab_secoend_child->class_name = $this->tabChildSecoendClassName;
        $tab_secoend_child->id_parent = $tab->id;
        $tab_secoend_child->module = $this->name;
        $tab_secoend_child->add();


        $tab_nuevo_child = new Tab();
        foreach ($languages as $language) {
            $tab_nuevo_child->name[$language['id_lang']] = $this->tabNuevoChildName;
        }
        $tab_nuevo_child->class_name = $this->tabChildNuevoClassName;
        $tab_nuevo_child->id_parent = $tab->id;
        $tab_nuevo_child->module = $this->name;
        $tab_nuevo_child->add();


		//here we create third child TAB
        $tab_third_child = new Tab();
        foreach ($languages as $language) {
            $tab_third_child->name[$language['id_lang']] = $this->tabChildThirdName;
        }
        $tab_third_child->class_name = $this->tabChildThirdClassName;
        $tab_third_child->id_parent = $tab->id;
        $tab_third_child->module = $this->name;
        $tab_third_child->add();
		//here we create fifth child TAB
        $tab_fifth_child = new Tab();
        foreach ($languages as $language) {
            $tab_fifth_child->name[$language['id_lang']] = $this->tabChildFifthName;
        }
        $tab_fifth_child->class_name = $this->tabChildFifthClassName;
        $tab_fifth_child->id_parent = $tab->id;
        $tab_fifth_child->module = $this->name;
        $tab_fifth_child->add();
		//here we create fourth child TAB
        $tab_fourth_child = new Tab();
        foreach ($languages as $language) {
            $tab_fourth_child->name[$language['id_lang']] = $this->tabChildFourthName;
        }
        $tab_fourth_child->class_name = $this->tabChildFourthClassName;
        $tab_fourth_child->id_parent = $tab->id;
        $tab_fourth_child->module = $this->name;
        $tab_fourth_child->add();
		//copy override controller
		copy(__DIR__.'/override/controllers/front/SearchController.php', _PS_ROOT_DIR_.'/override/controllers/front/SearchController.php');
		return $this->alterTable('add') && $this->registerHook('backOfficeHeader') && $this->registerHook('displayLeftColumn') && $this->registerHook('displayTop') && $this->registerHook('header') && $this->registerHook('footer') && $this->registerHook('displayFooter') && Configuration::updateValue('SSMAKEMODELYEAR', 'Find Your Parts By Make Model and Year');
	}

	public function uninstall()
	{
		 $moduleTabs = Tab::getCollectionFromModule($this->name);
        if (!empty($moduleTabs)) {
            foreach ($moduleTabs as $moduleTab) {
                $moduleTab->delete();
            }
        }
		//remove override controller
		if(file_exists(_PS_ROOT_DIR_.'/override/controllers/front/SearchController.php')){
		  unlink(_PS_ROOT_DIR_.'/override/controllers/front/SearchController.php');
		}
		//remove override class
		if(file_exists(_PS_ROOT_DIR_.'/override/classes/Search.php')){
		  unlink(_PS_ROOT_DIR_.'/override/classes/Search.php');
		}
		return parent::uninstall() && $this->alterTable('remove') && Configuration::deleteByName('SSMAKEMODELYEAR');
	}
	public function hookBackOfficeHeader($params)
    {
        $this->context->controller->addCSS($this->getPathUri(). 'views/css/admin_menu_icon.css');
    }
	/*Admin Settings Page*/
	public function getContent()
	{
		$html = '';
		if (Tools::isSubmit('SubmitCarMMYFilterSettings'))
		{
			Configuration::updateValue('PS_MMY_TOP_TEXT', (string)Tools::getValue('PS_MMY_TOP_TEXT'));
			Configuration::updateValue('PS_MMY_BOX_HEADER', (string)Tools::getValue('PS_MMY_BOX_HEADER'));
			Configuration::updateValue('PS_MMY_MAKE_DEFAULT_TEXT', (string)Tools::getValue('PS_MMY_MAKE_DEFAULT_TEXT'));
			Configuration::updateValue('PS_MMY_MODEL_DEFAULT_TEXT', (string)Tools::getValue('PS_MMY_MODEL_DEFAULT_TEXT'));
            Configuration::updateValue('PS_MMY_NUEVO_DEFAULT_TEXT', (string)Tools::getValue('PS_MMY_NUEVO_DEFAULT_TEXT'));
			Configuration::updateValue('PS_MMY_YEAR_DEFAULT_TEXT', (string)Tools::getValue('PS_MMY_YEAR_DEFAULT_TEXT'));
			Configuration::updateValue('PS_MMY_MAKE_TEXT', (string)Tools::getValue('PS_MMY_MAKE_TEXT'));
			Configuration::updateValue('PS_MMY_MODEL_TEXT', (string)Tools::getValue('PS_MMY_MODEL_TEXT'));
			Configuration::updateValue('PS_MMY_YEAR_TEXT', (string)Tools::getValue('PS_MMY_YEAR_TEXT'));
			Configuration::updateValue('PS_MMY_MAKE_REQUIRED_TEXT', (string)Tools::getValue('PS_MMY_MAKE_REQUIRED_TEXT'));
			Configuration::updateValue('PS_MMY_MODEL_REQUIRED_TEXT', (string)Tools::getValue('PS_MMY_MODEL_REQUIRED_TEXT'));
            Configuration::updateValue('PS_MMY_NUEVO_REQUIRED_TEXT', (string)Tools::getValue('PS_MMY_NUEVO_REQUIRED_TEXT'));
			Configuration::updateValue('PS_MMY_YEAR_REQUIRED_TEXT', (string)Tools::getValue('PS_MMY_YEAR_REQUIRED_TEXT'));
			Configuration::updateValue('PS_MMY_FILTER_BUTTON_TEXT', (string)Tools::getValue('PS_MMY_FILTER_BUTTON_TEXT'));
			Configuration::updateValue('PS_MMY_FILTER_BOX_LABEL', (int)Tools::getValue('PS_MMY_FILTER_BOX_LABEL'));
			Configuration::updateValue('PS_MMY_FILTER_VALIDATE_REQURED', (int)Tools::getValue('PS_MMY_FILTER_VALIDATE_REQURED'));
			$html .= $this->displayConfirmation($this->l('Car Parts Filter Configaration Save Successfully'));
		}
		return $html.$this->renderForm();
	}
	public function renderForm()
	{
		$fields_form = array(
			'form' => array(
				'legend' => array(
					'title' => $this->l('Settings'),
					'icon' => 'icon-cogs'
				),
				'input' => array(
					array(
						'type' => 'text',
						'label' => $this->l('Search Page Top Text:'),
						'name' => 'PS_MMY_TOP_TEXT',
						'suffix' => $this->l('Filter Page Header Text')
					),
					array(
						'type' => 'text',
						'label' => $this->l('Filter Box Header Text:'),
						'name' => 'PS_MMY_BOX_HEADER',
						'suffix' => $this->l('Filter Box Header Text')
					),
					array(
						'type' => 'text',
						'label' => $this->l('Make Dropdown Default Text:'),
						'name' => 'PS_MMY_MAKE_DEFAULT_TEXT',
						'suffix' => $this->l('Make Dropdownlist Default Text')
					),
					array(
						'type' => 'text',
						'label' => $this->l('Model Dropdown Default Text:'),
						'name' => 'PS_MMY_MODEL_DEFAULT_TEXT',
						'suffix' => $this->l('Model Dropdownlist Default Text')
					),
                    array(
                        'type' => 'text',
                        'label' => $this->l('Nuevo Dropdown Default Text:'),
                        'name' => 'PS_MMY_NUEVO_DEFAULT_TEXT',
                        'suffix' => $this->l('Nuevo Dropdownlist Default Text')
                    ),
					array(
						'type' => 'text',
						'label' => $this->l('Year Dropdown Default Text:'),
						'name' => 'PS_MMY_YEAR_DEFAULT_TEXT',
						'suffix' => $this->l('Year Dropdownlist Default Text')
					),
					array(
						'type' => 'text',
						'label' => $this->l('Make Text:'),
						'name' => 'PS_MMY_MAKE_TEXT',
						'suffix' => $this->l('Make Text')
					),
					array(
						'type' => 'text',
						'label' => $this->l('Model Text:'),
						'name' => 'PS_MMY_MODEL_TEXT',
						'suffix' => $this->l('Model Text')
					),
                    array(
                        'type' => 'text',
                        'label' => $this->l('Nuevo Text:'),
                        'name' => 'PS_MMY_NUEVO_TEXT',
                        'suffix' => $this->l('Nuevo Text')
                    ),
					array(
						'type' => 'text',
						'label' => $this->l('Year Text:'),
						'name' => 'PS_MMY_YEAR_TEXT',
						'suffix' => $this->l('Year Text')
					),
					array(
						'type' => 'text',
						'label' => $this->l('Make Required Text:'),
						'name' => 'PS_MMY_MAKE_REQUIRED_TEXT',
						'suffix' => $this->l('Required Text')
					),
					array(
						'type' => 'text',
						'label' => $this->l('Model Required Text:'),
						'name' => 'PS_MMY_MODEL_REQUIRED_TEXT',
						'suffix' => $this->l('Required Text')
					),
                    array(
                        'type' => 'text',
                        'label' => $this->l('Nuevo Required Text:'),
                        'name' => 'PS_MMY_NUEVO_REQUIRED_TEXT',
                        'suffix' => $this->l('Required Text')
                    ),
					array(
						'type' => 'text',
						'label' => $this->l('Year Required Text:'),
						'name' => 'PS_MMY_YEAR_REQUIRED_TEXT',
						'suffix' => $this->l('Required Text')
					),
					array(
						'type' => 'text',
						'label' => $this->l('Filter Button Text:'),
						'name' => 'PS_MMY_FILTER_BUTTON_TEXT',
						'suffix' => $this->l('Filter Button Text')
					),
					array(
						'type' => 'switch',
						'label' => $this->l('Hide Filter Box Label ? '),
						'desc' => $this->l('If yes hide filter box label'),
						'name' => 'PS_MMY_FILTER_BOX_LABEL',
						'values' => array(
							array(
								'id' => 'active_on',
								'value' => 1,
								'label' => $this->l('Enabled')
							),
							array(
								'id' => 'active_off',
								'value' => 0,
								'label' => $this->l('Disabled')
							)
						),
					),
					array(
						'type' => 'switch',
						'label' => $this->l('Validate Required ? '),
						'desc' => $this->l('If yes customer need to select all'),
						'name' => 'PS_MMY_FILTER_VALIDATE_REQURED',
						'values' => array(
							array(
								'id' => 'active_on',
								'value' => 1,
								'label' => $this->l('Enabled')
							),
							array(
								'id' => 'active_off',
								'value' => 0,
								'label' => $this->l('Disabled')
							)
						),
					),
				),
				'submit' => array(
					'title' => $this->trans('Save', array(), 'Admin.Actions')
				)
			),
		);

		$helper = new HelperForm();
		$helper->show_toolbar = false;
		$helper->table = $this->table;
		$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
		$helper->default_form_language = $lang->id;
		$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
		$this->fields_form = array();

		$helper->identifier = $this->identifier;
		$helper->submit_action = 'SubmitCarMMYFilterSettings';
		$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
		$helper->token = Tools::getAdminTokenLite('AdminModules');
		$helper->tpl_vars = array(
			'fields_value' => $this->getConfigFieldsValues(),
			'languages' => $this->context->controller->getLanguages(),
			'id_language' => $this->context->language->id
		);

		return $helper->generateForm(array($fields_form));
	}
	
	
	public function getConfigFieldsValues()
	{
		$top_text = "Make Model Year Filter Result";
		$header_text = "Find Your Parts";
		$make_ddl_default_text = "--Select Make--";
		$model_ddl_default_text = "--Select Model--";
        $nuevo_ddl_default_text = "--Select Nuevo--";
		$year_ddl_default_text = "--Select Year--";
		$make_text = 'Make';
		$model_text = 'Model';
		$year_text = 'Year';
		$make_required = 'Make Required';
		$model_required = 'Model Required';
		$year_required = 'Year Required';
		$filter_button_text = 'Filter';
		$hide_filter_label = 0;
		$validate_required = 1;
		
		if(Configuration::get('PS_MMY_TOP_TEXT') != ''){
			$top_text = Configuration::get('PS_MMY_TOP_TEXT');
		}
		if(Configuration::get('PS_MMY_BOX_HEADER') != ''){
			$header_text = Configuration::get('PS_MMY_BOX_HEADER');
		}
		if(Configuration::get('PS_MMY_MAKE_DEFAULT_TEXT') != ''){
			$make_ddl_default_text = Configuration::get('PS_MMY_MAKE_DEFAULT_TEXT');
		}
		if(Configuration::get('PS_MMY_MODEL_DEFAULT_TEXT') != ''){
			$model_ddl_default_text = Configuration::get('PS_MMY_MODEL_DEFAULT_TEXT');
		}
        if(Configuration::get('PS_MMY_NUEVO_DEFAULT_TEXT') != ''){
            $nuevo_ddl_default_text = Configuration::get('PS_MMY_NUEVO_DEFAULT_TEXT');
        }
		if(Configuration::get('PS_MMY_YEAR_DEFAULT_TEXT') != ''){
			$year_ddl_default_text = Configuration::get('PS_MMY_YEAR_DEFAULT_TEXT');
		}
		if(Configuration::get('PS_MMY_MAKE_TEXT') != ''){
			$make_text = Configuration::get('PS_MMY_MAKE_TEXT');
		}
		if(Configuration::get('PS_MMY_MODEL_TEXT') != ''){
			$model_text = Configuration::get('PS_MMY_MODEL_TEXT');
		}
		if(Configuration::get('PS_MMY_YEAR_TEXT') != ''){
			$year_text = Configuration::get('PS_MMY_YEAR_TEXT');
		}
		if(Configuration::get('PS_MMY_MAKE_REQUIRED_TEXT') != ''){
			$make_required = Configuration::get('PS_MMY_MAKE_REQUIRED_TEXT');
		}
		if(Configuration::get('PS_MMY_MODEL_REQUIRED_TEXT') != ''){
			$model_required = Configuration::get('PS_MMY_MODEL_REQUIRED_TEXT');
		}
        if(Configuration::get('PS_MMY_NUEVO_REQUIRED_TEXT') != ''){
            $nuevo_required = Configuration::get('PS_MMY_NUEVO_REQUIRED_TEXT');
        }
		if(Configuration::get('PS_MMY_YEAR_REQUIRED_TEXT') != ''){
			$year_required = Configuration::get('PS_MMY_YEAR_REQUIRED_TEXT');
		}
		if(Configuration::get('PS_MMY_FILTER_BUTTON_TEXT') != ''){
			$filter_button_text = Configuration::get('PS_MMY_FILTER_BUTTON_TEXT');
		}
		if(Configuration::get('PS_MMY_FILTER_VALIDATE_REQURED') != ''){
			$validate_required = Configuration::get('PS_MMY_FILTER_VALIDATE_REQURED');
		}
		return array(
			'PS_MMY_TOP_TEXT' 					=> Tools::getValue('PS_MMY_TOP_TEXT', $top_text),
			'PS_MMY_BOX_HEADER' 				=> Tools::getValue('PS_MMY_BOX_HEADER', $header_text),
			'PS_MMY_MAKE_DEFAULT_TEXT' 			=> Tools::getValue('PS_MMY_MAKE_DEFAULT_TEXT', $make_ddl_default_text),
			'PS_MMY_MODEL_DEFAULT_TEXT' 		=> Tools::getValue('PS_MMY_MODEL_DEFAULT_TEXT', $model_ddl_default_text),
			'PS_MMY_NUEVO_DEFAULT_TEXT' 		=> Tools::getValue('PS_MMY_NUEVO_DEFAULT_TEXT', $nuevo_ddl_default_text),
			'PS_MMY_YEAR_DEFAULT_TEXT' 			=> Tools::getValue('PS_MMY_YEAR_DEFAULT_TEXT', $year_ddl_default_text),
			'PS_MMY_MAKE_TEXT'	 				=> Tools::getValue('PS_MMY_MAKE_TEXT', $make_text),
			'PS_MMY_MODEL_TEXT' 				=> Tools::getValue('PS_MMY_MODEL_TEXT', $model_text),
            'PS_MMY_NUEVO_TEXT' 				=> Tools::getValue('PS_MMY_NUEVO_TEXT', $model_text),
			'PS_MMY_YEAR_TEXT' 					=> Tools::getValue('PS_MMY_YEAR_TEXT', $year_text),
			'PS_MMY_MAKE_REQUIRED_TEXT' 		=> Tools::getValue('PS_MMY_MAKE_REQUIRED_TEXT', $make_required),
			'PS_MMY_MODEL_REQUIRED_TEXT' 		=> Tools::getValue('PS_MMY_MODEL_REQUIRED_TEXT', $model_required),
            'PS_MMY_NUEVO_REQUIRED_TEXT' 		=> Tools::getValue('PS_MMY_NUEVO_REQUIRED_TEXT', $model_required),
			'PS_MMY_YEAR_REQUIRED_TEXT' 		=> Tools::getValue('PS_MMY_YEAR_REQUIRED_TEXT', $year_required),
			'PS_MMY_FILTER_BUTTON_TEXT' 		=> Tools::getValue('PS_MMY_FILTER_BUTTON_TEXT', $filter_button_text),
			'PS_MMY_FILTER_BOX_LABEL' 			=> Tools::getValue('PS_MMY_FILTER_BOX_LABEL', $hide_filter_label),
			'PS_MMY_FILTER_VALIDATE_REQURED' 	=> Tools::getValue('PS_MMY_FILTER_VALIDATE_REQURED', $validate_required)
		);
	}
	public function alterTable($method)
	{
		switch ($method) {
			case 'add':
				$sql = 'CREATE TABLE IF NOT EXISTS ' . _DB_PREFIX_ . 'car_filter_data(`id_product` int(11),`make` VARCHAR(100) collate utf8_bin,`model` VARCHAR(100) collate utf8_bin, `nuevo` VARCHAR(100) collate utf8_bin,`year` VARCHAR(100) collate utf8_bin)';
				if(!Db::getInstance()->Execute($sql)){
					return false;
				}
				$sql_make = 'CREATE TABLE IF NOT EXISTS ' . _DB_PREFIX_ . 'carmake(`makeid` int(10) NOT NULL AUTO_INCREMENT,`makename` varchar(200) collate utf8_bin,PRIMARY KEY (`makeid`))';
				if(!Db::getInstance()->Execute($sql_make)){
					return false;
				}
				$sql_model = 'CREATE TABLE IF NOT EXISTS ' . _DB_PREFIX_ . 'carmodel(`modelid` int(10) NOT NULL AUTO_INCREMENT,`makeid` int(10) NOT NULL DEFAULT 0,`modelname` varchar(200) collate utf8_bin,PRIMARY KEY (`modelid`))';
				if(!Db::getInstance()->Execute($sql_model)){
					return false;
				}
                $sql_model = 'CREATE TABLE IF NOT EXISTS ' . _DB_PREFIX_ . 'carnuevo(`nuevoid` int(10) NOT NULL AUTO_INCREMENT,`makeid` int(10) NOT NULL DEFAULT 0,`modelid` int(10) NOT NULL DEFAULT 0,`nuevoname` varchar(200) collate utf8_bin,PRIMARY KEY (`nuevoid`))';
                if(!Db::getInstance()->Execute($sql_model)){
                    return false;
                }
                $sql_year = 'CREATE TABLE IF NOT EXISTS ' . _DB_PREFIX_ . 'caryear(`yearid` int(10) NOT NULL AUTO_INCREMENT,`makeid` int(10) NOT NULL DEFAULT 0,`modelid` int(10) NOT NULL DEFAULT 0,`nuevoid` int(10) NOT NULL DEFAULT 0 , `year` varchar(200) collate utf8_bin,PRIMARY KEY (`yearid`))';
				if(!Db::getInstance()->Execute($sql_year)){
					return false;
				}	
				break;
			
			case 'remove':
				Db::getInstance()->Execute("DROP TABLE IF EXISTS " . _DB_PREFIX_ . "car_filter_data");
				Db::getInstance()->Execute("DROP TABLE IF EXISTS " . _DB_PREFIX_ . "carmake");
				Db::getInstance()->Execute("DROP TABLE IF EXISTS " . _DB_PREFIX_ . "carmodel");
                Db::getInstance()->Execute("DROP TABLE IF EXISTS " . _DB_PREFIX_ . "carnuevo");
				Db::getInstance()->Execute("DROP TABLE IF EXISTS " . _DB_PREFIX_ . "caryear");
				break;
		}
		return true;
	}
	
	public function hookDisplayTop($params){
		
		$top_text = "Make Model Year Filter Result";
		$header_text = "Find Your Parts";
		$make_ddl_default_text = "--Select Make--";
		$model_ddl_default_text = "--Select Model--";
        $nuevo_ddl_default_text = "--Select Nuevo--";
		$year_ddl_default_text = "--Select Year--";
		$make_text = 'Make';
		$model_text = 'Model';
        $nuevo_text = 'Nuevo';
		$year_text = 'Year';
		$make_required = 'Make Required';
		$model_required = 'Model Required';
        $nuevo_required = 'Nuevo Required';
		$year_required = 'Year Required';
		$filter_button_text = 'Filter';
		$hide_filter_label = 0;
		$validate_required = 1;
		
		if(Configuration::get('PS_MMY_TOP_TEXT') != ''){
			$top_text = Configuration::get('PS_MMY_TOP_TEXT');
		}
		if(Configuration::get('PS_MMY_BOX_HEADER') != ''){
			$header_text = Configuration::get('PS_MMY_BOX_HEADER');
		}
		if(Configuration::get('PS_MMY_MAKE_DEFAULT_TEXT') != ''){
			$make_ddl_default_text = Configuration::get('PS_MMY_MAKE_DEFAULT_TEXT');
		}
		if(Configuration::get('PS_MMY_MODEL_DEFAULT_TEXT') != ''){
			$model_ddl_default_text = Configuration::get('PS_MMY_MODEL_DEFAULT_TEXT');
		}
        if(Configuration::get('PS_MMY_NUEVO_DEFAULT_TEXT') != ''){
            $nuevo_ddl_default_text = Configuration::get('PS_MMY_NUEVO_DEFAULT_TEXT');
        }
		if(Configuration::get('PS_MMY_YEAR_DEFAULT_TEXT') != ''){
			$year_ddl_default_text = Configuration::get('PS_MMY_YEAR_DEFAULT_TEXT');
		}
		if(Configuration::get('PS_MMY_MAKE_TEXT') != ''){
			$make_text = Configuration::get('PS_MMY_MAKE_TEXT');
		}
		if(Configuration::get('PS_MMY_MODEL_TEXT') != ''){
			$model_text = Configuration::get('PS_MMY_MODEL_TEXT');
		}
        if(Configuration::get('PS_MMY_NUEVO_TEXT') != ''){
            $nuevo_text = Configuration::get('PS_MMY_NUEVO_TEXT');
        }
		if(Configuration::get('PS_MMY_YEAR_TEXT') != ''){
			$year_text = Configuration::get('PS_MMY_YEAR_TEXT');
		}
		if(Configuration::get('PS_MMY_MAKE_REQUIRED_TEXT') != ''){
			$make_required = Configuration::get('PS_MMY_MAKE_REQUIRED_TEXT');
		}
		if(Configuration::get('PS_MMY_MODEL_REQUIRED_TEXT') != ''){
			$model_required = Configuration::get('PS_MMY_MODEL_REQUIRED_TEXT');
		}
        if(Configuration::get('PS_MMY_NUEVO_REQUIRED_TEXT') != ''){
            $nuevo_required = Configuration::get('PS_MMY_NUEVO_REQUIRED_TEXT');
        }
		if(Configuration::get('PS_MMY_YEAR_REQUIRED_TEXT') != ''){
			$year_required = Configuration::get('PS_MMY_YEAR_REQUIRED_TEXT');
		}
		if(Configuration::get('PS_MMY_FILTER_BUTTON_TEXT') != ''){
			$filter_button_text = Configuration::get('PS_MMY_FILTER_BUTTON_TEXT');
		}
		if(Configuration::get('PS_MMY_FILTER_BOX_LABEL') != ''){
			$hide_filter_label = Configuration::get('PS_MMY_FILTER_BOX_LABEL');
		}
		if(Configuration::get('PS_MMY_FILTER_VALIDATE_REQURED') != ''){
			$validate_required = Configuration::get('PS_MMY_FILTER_VALIDATE_REQURED');
		}

		/*Filter values*/
		$make_id = 0;
		$model_id = 0;
        $nuevo_id = 0;
		$year_id = 0;
		$model_html = '';
        $nuevo_html = '';
		$year_html = '';


		/****    AQUI     ****/
		
		if(Tools::getValue('make') && Tools::getValue('make') != '') {
			$make_id = Tools::getValue('make');
		}
		if(Tools::getValue('model') && Tools::getValue('model') != '') {
			$model_id = Tools::getValue('model');
		}
        if(Tools::getValue('nuevo') && Tools::getValue('nuevo') != '') {
            $nuevo_id = Tools::getValue('nuevo');
        }
		if(Tools::getValue('year') && Tools::getValue('year') != '') {
			$year_id = Tools::getValue('year');
		}
		if(Tools::getValue('make') && Tools::getValue('make') != '' && Tools::getValue('model') && Tools::getValue('model') != '') {
			$model_html = $this->getFilterBoxModelHtml(Tools::getValue('make'), Tools::getValue('model'));
		}
        if(Tools::getValue('make') && Tools::getValue('make') != '' && Tools::getValue('model') && Tools::getValue('model') != '' && Tools::getValue('nuevo') && Tools::getValue('nuevo') != '') {
            $nuevo_html = $this->getFilterBoxNuevoHtml(Tools::getValue('make'), Tools::getValue('model') , Tools::getValue('nuevo'));
        }
		if(Tools::getValue('make') && Tools::getValue('make') != '' && Tools::getValue('model') && Tools::getValue('model') != '' && Tools::getValue('year') && Tools::getValue('year') != '' && Tools::getValue('nuevo') != '') {
			$year_html = $this->getFilterBoxYearHtml(Tools::getValue('make'), Tools::getValue('model'), Tools::getValue('nuevo'), Tools::getValue('year'));
		}
		
		$ps__base_url = Context::getContext()->shop->getBaseURL(true);
		$base_url_module = $ps__base_url . 'modules/partsfilter/';
		$filter_url = $this->context->link->getPagelink('search').'?controller=search&s=apf';
		$make_data = $this->getAllMakeData();
		$this->context->smarty->assign(array(
			'base_url_module'			=> $base_url_module,
			'header_text'				=> $header_text,
			'make_text'					=> $make_text,
			'model_text'				=> $model_text,
            'nuevo_text'				=> $nuevo_text,
			'year_text'					=> $year_text,
			'make_ddl_default_text'		=> $make_ddl_default_text,
			'model_ddl_default_text'	=> $model_ddl_default_text,
            'nuevo_ddl_default_text'	=> $nuevo_ddl_default_text,
			'year_ddl_default_text'		=> $year_ddl_default_text,
			'filter_button_text'		=> $filter_button_text,
			'hide_filter_label'			=> $hide_filter_label,
			'validate_required'			=> $validate_required,
			'make_data'					=> $make_data,
			'make_required'				=> $make_required,
			'model_required'			=> $model_required,
            'nuevo_required'			=> $nuevo_required,
			'year_required'				=> $year_required,
			'filter_url'				=> $filter_url,
			'make_id'					=> $make_id,
			'model_id'					=> $model_id,
			'year_id'					=> $year_id,
            'nuevo_id'					=> $nuevo_id,
			'model_xhtml'				=> $model_html,
            'nuevo_xhtml'				=> $nuevo_html,
			'year_html'					=> $year_html
		));
		return $this->display(__FILE__, 'views/templates/front/filterbox_top.tpl');
	}
	
	private function getFilterBoxModelHtml($makeId, $modelId) {
		$model_html = '';
		if(!empty($makeId) && $makeId > 0){
			$sql = "select * from " ._DB_PREFIX_. "carmodel where makeid = '" . (int)$makeId . "'";
			if ($results = Db::getInstance()->ExecuteS($sql)){
				foreach($results as $row){
					if($row['modelid'] == $modelId){
						$model_html .= "<option selected='selected' value='".$row['modelid']."'>".$row['modelname']."</option>";
					}
					else{
						$model_html .= "<option value='".$row['modelid']."'>".$row['modelname']."</option>";
					}	
				}
			}
		}
		return $model_html;
	}
    private function getFilterBoxNuevoHtml($makeId, $modelId , $nuevoId) {
        $nuevo_html = '';
        if(!empty($makeId) && $makeId > 0){
            $sql = "select * from " ._DB_PREFIX_. "carnuevo where makeid = '" . (int)$makeId . "' and modelid = '" . (int)$modelId . "'";
            if ($results = Db::getInstance()->ExecuteS($sql)){
                foreach($results as $row){
                    if($row['nuevoid'] == $nuevoId){
                        $nuevo_html .= "<option selected='selected' value='".$row['nuevoid']."'>".$row['nuevoname']."</option>";
                    }
                    else{
                        $nuevo_html .= "<option value='".$row['nuevoid']."'>".$row['nuevoname']."</option>";
                    }
                }
            }
        }
        return $nuevo_html;
    }
	private function getFilterBoxYearHtml($makeId, $modelId, $nuevoId, $yearId) {
		$year_html = '';
		if(!empty($makeId) && $makeId > 0 && !empty($modelId) && $modelId > 0 && !empty($nuevoId) && $nuevoId > 0  && !empty($yearId) && $yearId > 0){
			$sql = "select * from " ._DB_PREFIX_. "caryear where makeid = '" . (int)$makeId . "' and modelid = '" . (int)$modelId . "'and nuevoid = '" . (int)$nuevoId . "'";
			if ($results = Db::getInstance()->ExecuteS($sql)){
				foreach($results as $row){
					if($row['yearid'] == $yearId){
						$year_html .= "<option selected='selected' value='".$row['yearid']."'>".$row['year']."</option>";
					}
					else{
						$year_html .= "<option value='".$row['yearid']."'>".$row['year']."</option>";
					}	
				}
			}
		}
		return $year_html;
	}
	
	public function hookDisplayLeftColumn($params){
		$top_text = "Make Model Year Filter Result";
		$header_text = "Find Your Parts";
		$make_ddl_default_text = "--Select Make--";
		$model_ddl_default_text = "--Select Model--";
		$year_ddl_default_text = "--Select Year--";
		$make_text = 'Make';
		$model_text = 'Model';
        $nuevo_text = 'Nuevo';
		$year_text = 'Year';
		$make_required = 'Make Required';
		$model_required = 'Model Required';
        $nuevo_required = 'Nuevo Required';
		$year_required = 'Year Required';
		$filter_button_text = 'Filter';
		$hide_filter_label = 0;
		$validate_required = 1;
		
		if(Configuration::get('PS_MMY_TOP_TEXT') != ''){
			$top_text = Configuration::get('PS_MMY_TOP_TEXT');
		}
		if(Configuration::get('PS_MMY_BOX_HEADER') != ''){
			$header_text = Configuration::get('PS_MMY_BOX_HEADER');
		}
		if(Configuration::get('PS_MMY_MAKE_DEFAULT_TEXT') != ''){
			$make_ddl_default_text = Configuration::get('PS_MMY_MAKE_DEFAULT_TEXT');
		}
		if(Configuration::get('PS_MMY_MODEL_DEFAULT_TEXT') != ''){
			$model_ddl_default_text = Configuration::get('PS_MMY_MODEL_DEFAULT_TEXT');
		}
        if(Configuration::get('PS_MMY_NUEVO_DEFAULT_TEXT') != ''){
            $nuevo_ddl_default_text = Configuration::get('PS_MMY_NUEVO_DEFAULT_TEXT');
        }
		if(Configuration::get('PS_MMY_YEAR_DEFAULT_TEXT') != ''){
			$year_ddl_default_text = Configuration::get('PS_MMY_YEAR_DEFAULT_TEXT');
		}
		if(Configuration::get('PS_MMY_MAKE_TEXT') != ''){
			$make_text = Configuration::get('PS_MMY_MAKE_TEXT');
		}
		if(Configuration::get('PS_MMY_MODEL_TEXT') != ''){
			$model_text = Configuration::get('PS_MMY_MODEL_TEXT');
		}
        if(Configuration::get('PS_MMY_NUEVO_TEXT') != ''){
            $nuevo_text = Configuration::get('PS_MMY_NUEVO_TEXT');
        }
		if(Configuration::get('PS_MMY_YEAR_TEXT') != ''){
			$year_text = Configuration::get('PS_MMY_YEAR_TEXT');
		}
		if(Configuration::get('PS_MMY_MAKE_REQUIRED_TEXT') != ''){
			$make_required = Configuration::get('PS_MMY_MAKE_REQUIRED_TEXT');
		}
		if(Configuration::get('PS_MMY_MODEL_REQUIRED_TEXT') != ''){
			$model_required = Configuration::get('PS_MMY_MODEL_REQUIRED_TEXT');
		}
        if(Configuration::get('PS_MMY_NUEVO_REQUIRED_TEXT') != ''){
            $nuevo_required = Configuration::get('PS_MMY_NUEVO_REQUIRED_TEXT');
        }
		if(Configuration::get('PS_MMY_YEAR_REQUIRED_TEXT') != ''){
			$year_required = Configuration::get('PS_MMY_YEAR_REQUIRED_TEXT');
		}
		if(Configuration::get('PS_MMY_FILTER_BUTTON_TEXT') != ''){
			$filter_button_text = Configuration::get('PS_MMY_FILTER_BUTTON_TEXT');
		}
		if(Configuration::get('PS_MMY_FILTER_BOX_LABEL') != ''){
			$hide_filter_label = Configuration::get('PS_MMY_FILTER_BOX_LABEL');
		}
		if(Configuration::get('PS_MMY_FILTER_VALIDATE_REQURED') != ''){
			$validate_required = Configuration::get('PS_MMY_FILTER_VALIDATE_REQURED');
		}
		
		/*Filter values*/
		$make_id = 0;
		$model_id = 0;
        $nuevo_id = 0;
		$year_id = 0;
        $model_html = '';
        $nuevo_html = '';
		$year_html = '';
		
		if(Tools::getValue('make') && Tools::getValue('make') != '') {
			$make_id = Tools::getValue('make');
		}
		if(Tools::getValue('model') && Tools::getValue('model') != '') {
			$model_id = Tools::getValue('model');
		}
        if(Tools::getValue('nuevo') && Tools::getValue('nuevo') != '') {
            $nuevo_id = Tools::getValue('nuevo');
        }
		if(Tools::getValue('year') && Tools::getValue('year') != '') {
			$year_id = Tools::getValue('year');
		}
		
		if(Tools::getValue('make') && Tools::getValue('make') != '' && Tools::getValue('model') && Tools::getValue('model') != '') {
			$model_html = $this->getFilterBoxModelHtml(Tools::getValue('make'), Tools::getValue('model'));
		}
        if(Tools::getValue('make') && Tools::getValue('make') != '' && Tools::getValue('model') && Tools::getValue('model') != ''  && Tools::getValue('nuevo') && Tools::getValue('nuevo') != '') {
            $nuevo_html = $this->getFilterBoxNuevoHtml(Tools::getValue('make'), Tools::getValue('model') , Tools::getValue('nuevo'));
        }
		if(Tools::getValue('make') && Tools::getValue('make') != '' && Tools::getValue('model') && Tools::getValue('model') != ''  && Tools::getValue('nuevo') && Tools::getValue('nuevo') != '' && Tools::getValue('year') && Tools::getValue('year') != '') {
			$year_html = $this->getFilterBoxYearHtml(Tools::getValue('make'), Tools::getValue('model'), Tools::getValue('nuevo'), Tools::getValue('year'));
		}
		
		$ps__base_url = Context::getContext()->shop->getBaseURL(true);
		$base_url_module = $ps__base_url.'modules/partsfilter/';
		$filter_url = $this->context->link->getPagelink('search').'?controller=search&s=apf';
		$make_data = $this->getAllMakeData();
		$this->context->smarty->assign(array(
			'base_url_module'			=> $base_url_module,
			'header_text'				=> $header_text,
			'make_text'					=> $make_text,
			'model_text'				=> $model_text,
            'nuevo_text'				=> $nuevo_text,
			'year_text'					=> $year_text,
			'make_ddl_default_text'		=> $make_ddl_default_text,
			'model_ddl_default_text'	=> $model_ddl_default_text,
            'nuevo_ddl_default_text'	=> $nuevo_ddl_default_text,
			'year_ddl_default_text'		=> $year_ddl_default_text,
			'filter_button_text'		=> $filter_button_text,
			'hide_filter_label'			=> $hide_filter_label,
			'validate_required'			=> $validate_required,
			'make_data'					=> $make_data,
			'make_required'				=> $make_required,
			'model_required'			=> $model_required,
            'nuevo_required'			=> $nuevo_required,
			'year_required'				=> $year_required,
			'filter_url'				=> $filter_url,
			'make_id'					=> $make_id,
			'model_id'					=> $model_id,
            'nuevo_id'					=> $nuevo_id,
			'year_id'					=> $year_id,
			'model_xhtml'				=> $model_html,
            'nuevo_xhtml'				=> $nuevo_html,
			'year_html'					=> $year_html
		));
		return $this->display(__FILE__, 'views/templates/front/filterbox.tpl');
	}
	
	public function getAllMakeData(){
		$make_list = array();
		$sql = 'SELECT * FROM '._DB_PREFIX_.'carmake ORDER BY makename ASC';
		if ($results = Db::getInstance()->ExecuteS($sql)){
			foreach($results as $row){
				$make_list[] = array(
					'mid'			=> $row['makeid'],
					'name'			=> $row['makename']
				);
			}
		}
		return $make_list;
	}
}

 

×
×
  • Create New...