<?php
/**
 * @package DJ-Catalog2-Yootheme
 * @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email contact@dj-extensions.com
 */
defined('_JEXEC') or die;
$select = $this->el('select', [

    'class' => [
        'nice-select-version',
    ]
]);

$app = \JFactory::getApplication();
$attributeValues = $app->input->getRaw($child->alias, array());
$textValues = array();

if ($attributeValues) {
    $attributeValues = explode(',', $attributeValues);

    foreach ($attributeValues as $attributeValue) {
        $valueIndex = array_search($attributeValue, $child->options);
        if (isset($child->optionValues[$valueIndex])) {
            $textValues[] = $child->optionValues[$valueIndex];
        }
    }

}

?>
<select style="display: none" class="lena-filter-select" data-label="<?php echo $child->name; ?>" multiple="true" name="<?php echo $child->alias; ?>" data-attribute="<?php echo $child->id ?>">
    <option value=""><?php echo $child->name ?></option>
    <?php foreach ($child->optionValues as $index => $optionValue) : ?>
        <option <?php echo((in_array($child->options[$index], $attributeValues)) ? 'selected="selected"' : '') ?>
                value="<?php echo $child->options[$index] ?>"><?php echo $optionValue ?></option>
    <?php endforeach; ?>
</select>
<div class="nice-select nice-select-version sd-select" >
    <div class="current">

        <?php if (count($textValues)) : ?>
            <?php echo  $child->name . ' - ' . implode(',', $textValues); ?>
        <?php else : ?>
            <?php echo $child->name; ?>
        <?php endif; ?>
    </div>
    <ul class="list">
            <?php foreach ($child->optionValues as $index => $optionValue) : ?>
            <li data-id="<?php echo $child->options[$index] ?>"
                class="option <?php echo((in_array($child->options[$index], $attributeValues)) ? 'selected' : '') ?>"><?php echo $optionValue ?></li>
        <?php endforeach; ?>
    </ul>
</div>