<?php
// ajout des recherche par mot clé etc.
foreach($itemdescr->content as $cle=>$value){
    if($itemdescr->getParam($cle,"searchable",false)){
        switch($value['type']){
            case "radio":
                display_options($value,$value['type'],$cle, $itemdescr);
                break;
            case "checkbox":
                display_options($value,$value['type'],$cle, $itemdescr);
                break;
            case "select":
                display_options($value, "checkbox",$cle, $itemdescr);
                break;
        }
    }
}

function display_options($value,$type,$cle, $itemdescr){
    echo "<div class='my-3 fs-small' data-filtre='".$cle."' data-type='".$type."'><span class='ff-bold-secondary'>".$value['label']."&nbsp;:</span>&nbsp;";

    if($type=="radio"){
        echo "<span class='pr-1'>";
        echo "<input type='radio' name='".$cle."' value='' id='na' checked><label class='btn-cartouche' for='na'>N/A</label>";
        echo "</span>";
    }

    $options=$itemdescr->getOptionarray($cle);
    if(count($options)> 10){
        
        // multiple sélection?
        $addmult="";
        if($type=="checkbox" || ($type="select" && $itemdescr->isTagmultiple($cle))){
            $addmult=" multiple";
        }
        
        echo "<select class='btn-select' name='".$cle."' onchange='yc_filtre_items()'".$addmult.">";
        foreach($options as $option => $titre){
            echo "<option value='".$option."'>".$titre."</option>";
        }
        echo "</select>";
    } else {
        foreach($options as $option => $titre){
            echo "<span class='pr-1'>";
            echo "<input type='".$type."' name='".$cle."' value='".$titre."' ";
            if($type!="radio"){ echo "checked"; }
            echo " id='".makeid($titre)."'><label class='btn-cartouche' for='".makeid($titre)."'>".$titre."</label>";
            echo "</span>";
        }
    }
    echo "</div>";
}
?>
<div class="btn btn-ok btn-small" onclick="empty_filtre(true)">Réinitialiser</div> <div class="btn btn-ok btn-small" onclick="empty_filtre(false)">Tout déselectionner</div>