<?php
    global $RUNE_STAT;
    global $QUALITY;
?>
<form action='/<?=$UID?>/report/runecraft/' method='get' id='filter_runecraft' class='filter'>
    <table>
        <tr>
            <td class='filter filter_title' rowspan='2'>
                <span>
                    Monster
                </span>
            </td>
            <td class='filter' colspan='3'>
                <span>Name:</span>
                <input type='text' name='monster_name' id='filter_name' value='<?=$filters["monster_name"]?>'/>
            </td>
            <td class='filter'>
                <span>Stars:</span>
                <input type='number' name='monster_min_stars' id='filter_stars_min' min='1' max='6' value='<?=$filters["monster_min_stars"]?>'/>
                -
                <input type='number' name='monster_max_stars' id='filter_stars_max' min='1' max='6' value='<?=$filters["monster_max_stars"]?>'/>
            </td>
        </tr>
            <td class='filter' colspan='4'>
<?php
                $checked = "";
                if ($filters["monster_in_storage"]){
                    $checked = "checked";
                }
?>
                <input type='checkbox' name='monster_in_storage' id='filter_monster_in_storage' <?=$checked?>/>
                <label for='filter_monster_in_storage'>Show monsters in storage</label>
            </td>
        </tr>
        <tr>
            <td class='filter filter_title filter_separator' rowspan='5'>
                <span>
                    Runes
                </span>
            </td>
            <td class='filter filter_stars filter_separator' colspan='2'>
                <span>Stars:</span>
                <input type='number' name='rune_min_stars' id='filter_stars_min' min='1' max='6' value='<?=$filters["rune_min_stars"]?>'/>
                -
                <input type='number' name='rune_max_stars' id='filter_stars_max' min='1' max='6' value='<?=$filters["rune_max_stars"]?>'/>
            </td>
            <td class='filter filter_separator' colspan='2'>
                <span>Level:</span>
                <input type='number' name='rune_min_level' id='filter_level_min' min='0' max='15' value='<?=$filters["rune_min_level"]?>'/>
                -
                <input type='number' name='rune_max_level' id='filter_level_max' min='0' max='15' value='<?=$filters["rune_max_level"]?>'/>
            </td>
        </tr>
        <tr>
            <td class='filter' rowspan='4'>
                <span>Slot:</span>
                <select multiple name='rune_slot[]' id='filter_slot'>
<?php
                    for ($i = 1; $i <= 6; $i ++){
                        if (in_array($i, $filters["rune_slot"])){
                            $selected = "selected='selected'";
                        }
                        else{
                            $selected = "";
                        }
?>
                        <option value='<?=$i?>' <?=$selected?>><?=$i?></option>
<?php
                    }
?>
                </select>
            </td>
            <td class='filter' colspan='3'>
                <span>Quality:</span>
<?php

                $selected = Array("", "", "", "", "");
                $selected[$filters["rune_min_quality"] - 1] = "selected";
?>
                <select name='rune_min_quality' id='filter_quality_min'>
                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
                </select>
                -
<?php
                $selected = Array("", "", "", "", "");
                $selected[$filters["rune_max_quality"] - 1] = "selected";
?>
                <select name='rune_max_quality' id='filter_quality_max'>
                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
                </select>
            </td>
        </tr>
        <tr>
            <td class='filter' colspan='3'>
                <span>Original quality:</span>
<?php
                $selected = Array("", "", "", "", "");
                $selected[$filters["rune_min_original_quality"] - 1] = "selected";
?>
                <select name='rune_min_original_quality' id='filter_original_quality_min'>
                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
                </select>
                -
<?php
                $selected = Array("", "", "", "", "");
                $selected[$filters["rune_max_original_quality"] - 1] = "selected";
?>
                <select name='rune_max_original_quality' id='filter_original_quality_max'>
                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
                </select>
            </td>
        </tr>
        <tr>
            <td class='filter' colspan='3'>
                <span>Efficiency:</span>
                <input type='number' name='rune_min_efficiency' id='filter_efficiency_min' min='0' max='100' value='<?=$filters["rune_min_efficiency"]?>'/>%
                -
                <input type='number' name='rune_max_efficiency' id='filter_efficiency_max' min='0' max='100' value='<?=$filters["rune_max_efficiency"]?>'/>%
            </td>
        </tr>
        <tr>
            <td class='filter' colspan='3'>
                <span>Maximum efficiency:</span>
                <input type='number' name='rune_min_max_efficiency' id='filter_max_efficiency_min' min='0' max='100' value='<?=$filters["rune_min_max_efficiency"]?>'/>%
                -
                <input type='number' name='rune_max_max_efficiency' id='filter_max_efficiency_max' min='0' max='100' value='<?=$filters["rune_max_max_efficiency"]?>'/>%
            </td>
        </tr>
        <tr>
            <td class='filter filter_title filter_separator'>
                <span>
                    Grindstones
                </span>
            </td>
            <td class='filter filter_stars filter_separator'>
<?php
                $checked = "";
                if ($filters["grind"]){
                    $checked = "checked";
                }
?>
                <input type='checkbox' name='grind' id='filter_grind' <?=$checked?>/>
                <label for='filter_grind'>Grindstones</label>
            </td>
            <td class='filter filter_separator'>
                <span>Min. quality:</span>
<?php
                $selected = Array("", "", "", "", "");
                $selected[$filters["grind_min_quality"] - 1] = "selected";
?>
                <select name='grind_min_quality'>
                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
                </select>
            </td>
            <td class='filter filter_separator' colspan='2'>
                <span>Stats:</span>
                <select multiple name='grind_stat[]' id='filter_grind_stat'>
<?php
                    foreach($RUNE_STAT as $k=>$n){
                        $selected = "";
                        if (in_array($n, $filters["grind_stat"])){
                            $selected = "selected='selected'";
                        }
                        $name = ucwords($k);
?>
                        <option value='<?=$n?>' <?=$selected?>><?=$name?></option>
<?php
                    }
?>
                </select>
            </td>
        </tr>
        <tr>
            <td class='filter filter_title filter_separator'>
                <span>
                    Gems
                </span>
            </td>
            <td class='filter filter_stars filter_separator'>
<?php
                $checked = "";
                if ($filters["gem"]){
                    $checked = "checked";
                }
?>
                <input type='checkbox' name='gem' id='filter_gem' <?=$checked?>/>
                <label for='filter_gem'>Gems</label>
            </td>
            <td class='filter filter_separator'>
                <span>Min. quality:</span>
<?php
                $selected = Array("", "", "", "", "");
                $selected[$filters["gem_min_quality"] - 1] = "selected";
?>
                <select name='gem_min_quality'>
                    <option value='<?=$QUALITY["NORMAL"]?>' <?=$selected[0]?>>Normal</option>
                    <option value='<?=$QUALITY["MAGIC"]?>' <?=$selected[1]?>>Magic</option>
                    <option value='<?=$QUALITY["RARE"]?>' <?=$selected[2]?>>Rare</option>
                    <option value='<?=$QUALITY["HERO"]?>' <?=$selected[3]?>>Hero</option>
                    <option value='<?=$QUALITY["LEGEND"]?>' <?=$selected[4]?>>Legend</option>
                </select>
            </td>
            <td class='filter filter_separator'>
                <span>Replace...</span>
                <select multiple name='gem_stat_from[]' id='filter_gem_stat_from'>
<?php
                    foreach($RUNE_STAT as $k=>$n){
                        $selected = "";
                        if (in_array($n, $filters["gem_stat_from"])){
                            $selected = "selected='selected'";
                        }
                        $name = ucwords($k);
?>
                        <option value='<?=$n?>' <?=$selected?>><?=$name?></option>
<?php
                    }
?>
                </select>
            </td>
            <td class='filter filter_separator'>
                <span>...with...</span>
                <select multiple name='gem_stat_from[]' id='filter_gem_stat_to'>
<?php
                    foreach($RUNE_STAT as $k=>$n){
                        $selected = "";
                        if (in_array($n, $filters["gem_stat_to"])){
                            $selected = "selected='selected'";
                        }
                        $name = ucwords($k);
?>
                        <option value='<?=$n?>' <?=$selected?>><?=$name?></option>
<?php
                    }
?>
                </select>
            </td>
        </tr>
    </table>
    <div id='filter_apply'>
        <input type='submit' value='Apply'/>
    </div>
</form>
