<?php
    global $QUALITY;
?>
<form action='/<?=$UID?>/report/runeupgrade/' method='get' id='filter_runeupgrade' 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 = 0; $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' rowspan='3'>
                <span>
                    Alternatives
                </span>
            </td>
            <td class='filter filter_stars filter_separator'>
                <span>Min. stars:</span>
                <input type='number' name='alternative_min_stars' id='filter_stars_min' min='1' max='6' value='<?=$filters["alternative_min_stars"]?>'/>
            </td>
            <td class='filter filter_separator' colspan='2'>
                <span>Min. O. quality:</span>
<?php
                $selected = Array("", "", "", "", "");
                $selected[$filters["alternative_min_original_quality"]] = "selected";
?>
                <select name='alternative_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>
            </td>
            <td class='filter filter_separator'>
                <span>Min. Level:</span>
                <input type='number' name='alternative_min_level' id='filter_level_min' min='0' max='15' value='<?=$filters["alternative_min_level"]?>'/>
            </td>
        </tr>
        <tr>
            <td class='filter' colspan='4'>
                <span>Condition:</span>
<?php
                $selected = Array("", "", "", "", "", "");
                $selected[$filters["alternative_condition"]] = "selected";

?>
                <select name='alternative_condition'>
                    <option value='0' <?=$selected[0]?>>Higher grade, any quality
                    <option value='1' <?=$selected[1]?>>Higher grade or higher quality
                    <option value='2' <?=$selected[2]?>>Equal or higher grade and equal or higher quality</option>
                    <option value='3' <?=$selected[3]?>>Equal or higher grade and higher quality</option>
                    <option value='4' <?=$selected[4]?>>Equal grade and equal or higher quality</option>
                    <option value='5' <?=$selected[5]?>>Higher grade and higher quality</option>
                </select>
            </td>
        </tr>
        <tr>
            <td class='filter' colspan='4'>
                <span>Source:</span>
<?php
                $selected = Array("", "", "", "");
                $selected[$filters["alternative_source"]] = "selected";
?>
                <select name='alternative_source'>
                    <option value='0' <?=$selected[0]?>>Inventory only</option>
                    <option value='1' <?=$selected[1]?>>Inventory or assigned to a lower grade monster</option>
                    <option value='2' <?=$selected[2]?>>Any</option>
                </select>
            </td>
        </tr>
    </table>
    <div id='filter_apply'>
        <input type='submit' value='Apply'/>
    </div>
</form>
