<?php
/**
 * Maho
 *
 * @category    design
 * @package     rwd_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2021-2024 The OpenMage Contributors (https://openmage.org)
 * @copyright   Copyright (c) 2024 Maho (https://mahocommerce.com)
 * @license     https://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php
/**
 * Catalog advanced search form
 *
 * @see Mage_CatalogSearch_Block_Advanced_Form
 * @var Mage_CatalogSearch_Block_Advanced_Form $this 
 */
?>
<?php $maxQueryLength= $this->helper('catalogsearch')->getMaxQueryLength();?>
<div class="page-title">
    <h1><?= $this->__('Catalog Advanced Search') ?></h1>
</div>
<?= $this->getMessagesBlock()->toHtml() ?>
<form action="<?= $this->getSearchPostUrl() ?>" method="get" id="form-validate">
    <div class="fieldset advanced-search">
        <h2 class="legend"><?= $this->__('Search Settings') ?></h2>
        <ul class="form-list" id="advanced-search-list">
            <?php foreach ($this->getSearchableAttributes() as $_attribute): ?>
            <?php $_code = $_attribute->getAttributeCode() ?>
            <li>
                <label for="<?= $_code ?>"><?= $this->getAttributeLabel($_attribute) ?></label>
                <?php switch($this->getAttributeInputType($_attribute)):
                    case 'number': ?>
                    <div class="input-range">
                        <input type="text" pattern="\d*" name="<?= $_code ?>[from]" value="<?= $this->escapeHtml($this->getAttributeValue($_attribute, 'from')) ?>" id="<?= $_code ?>" title="<?= $this->escapeHtml($this->getAttributeLabel($_attribute)) ?>" class="input-text validate-number" maxlength="<?= $maxQueryLength ?>" />
                        <span class="separator">-</span>
                        <input type="text" pattern="\d*" name="<?= $_code ?>[to]" value="<?= $this->escapeHtml($this->getAttributeValue($_attribute, 'to')) ?>" id="<?= $_code ?>_to" title="<?= $this->escapeHtml($this->getAttributeLabel($_attribute)) ?>" class="input-text validate-number" maxlength="<?= $maxQueryLength ?>" />
                    </div>
                    <?php break;
                    case 'price': ?>
                    <div class="input-range">
                        <input name="<?= $_code ?>[from]" value="<?= $this->escapeHtml($this->getAttributeValue($_attribute, 'from')) ?>" id="<?= $_code ?>" title="<?= $this->escapeHtml($this->getAttributeLabel($_attribute)) ?>"  class="input-text validate-number" type="text" pattern="\d*" maxlength="<?= $maxQueryLength ?>" />
                        <span class="separator">-</span>
                        <input name="<?= $_code ?>[to]" value="<?= $this->escapeHtml($this->getAttributeValue($_attribute, 'to')) ?>" id="<?= $_code ?>_to" title="<?= $this->escapeHtml($this->getAttributeLabel($_attribute)) ?>"  class="input-text validate-number" type="text" pattern="\d*" maxlength="<?= $maxQueryLength ?>" />
                        <small>(<?= $this->getCurrency($_attribute) ?>)</small>
                    </div>
                    <?php break;
                    case 'select': ?>
                        <div class="input-box">
                            <?= $this->getAttributeSelectElement($_attribute) ?>
                        </div>
                    <?php break;
                    case 'yesno': ?>
                        <?= $this->getAttributeYesNoElement($_attribute) ?>
                    <?php break;
                    case 'date': ?>
                    <div class="input-range">
                        <?= $this->getDateInput($_attribute, 'from') ?>
                        <span class="separator">-</span>
                        <?= $this->getDateInput($_attribute, 'to') ?>
                    </div>
                    <?php break;
                    default: ?>
                    <div class="input-box">
                        <input type="text" name="<?= $_code ?>" id="<?= $_code ?>" value="<?= $this->escapeHtml($this->getAttributeValue($_attribute)) ?>" title="<?= $this->escapeHtml($this->getAttributeLabel($_attribute)) ?>"  class="input-text <?= $this->getAttributeValidationClass($_attribute) ?>" maxlength="<?= $maxQueryLength ?>" />
                    </div>
                <?php endswitch; ?>
            </li>
            <?php endforeach ?>
        </ul>
    </div>
    <div class="buttons-set">
        <button type="submit" title="<?= Mage::helper('core')->quoteEscape($this->__('Search')) ?>" class="button"><?= $this->__('Search') ?></button>
    </div>
</form>
<script type="text/javascript">
    var dataForm = new VarienForm('form-validate', true);
</script>
