<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.12/js/jquery.dataTables.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.12/css/jquery.dataTables.css">
<div>
    <h1>Shop</h1>
    <div class="shop-config">
        <form action="/admin/modules/shop" method="post">
            <table width="100%">
                <tr>
                    <td>Enable</td>
                    <td>
                        {if $Config.Enable}
                            <input name="Enable" id="Enable" type="checkbox" checked/>
                        {else}
                            <input name="Enable" id="Enable" type="checkbox"/>
                        {/if}
                    </td>
                </tr>
                <tr>
                    <td>Main Valute (Default: {$Valutes[0].Name})</td>
                    <td>
                        <select name="main_valute" id="main_valute">
                            {foreach $Valutes item=$val key=$i}
                                {if $val.Name != ''}
                                    {if $Config.MainValute == $i}
                                        <option value="{$i}" selected>{$val.Name}</option>
                                    {else}
                                        <option value="{$i}">{$val.Name}</option>
                                    {/if}
                                {/if}
                            {/foreach}
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>Return Procent</td>
                    <td><input name="return_proc" type="number" value="{$Config.ReturnProcent}"></td>
                </tr>
                <tr>
                    <th style="font-size: 14px" colspan="2">Price option</th>
                </tr>
                <tr>
                    <td>Luck</td>
                    <td><input name="opt_luck" type="number" value="{$Config.Price.Luck}"></td>
                </tr>
                <tr>
                    <td>Skill</td>
                    <td><input name="opt_skill" type="number" value="{$Config.Price.Skill}"></td>
                </tr>
                <tr>
                    <td>Level (+1)</td>
                    <td><input name="opt_level" type="number" value="{$Config.Price.Level}"></td>
                </tr>
                <tr>
                    <td>Addition option (+4/+1%)</td>
                    <td><input name="opt_addition" type="number" value="{$Config.Price.Option}"></td>
                </tr>
                <tr>
                    <td>Harmony</td>
                    <td><input name="opt_harmony" type="number" value="{$Config.Price.Harmony}"></td>
                </tr>
                <tr>
                    <td>Harmony level</td>
                    <td><input name="opt_harmony_level" type="number" value="{$Config.Price.HarmonyLevel}"></td>
                </tr>
                <tr>
                    <td>Excellent</td>
                    <td><input name="opt_excellent" type="number" value="{$Config.Price.Excellent}"></td>
                </tr>
                <tr>
                    <td>Ancient</td>
                    <td><input name="opt_ancient" type="number" value="{$Config.Price.Ancient}"></td>
                </tr>
                <tr>
                    <td colspan="2">Sockets are disabled</td>
                </tr>
                <tr>
                    <td>Socket 1</td>
                    <td><input name="opt_soc1" type="number" value="{$Config.Price.Socket1}"></td>
                </tr>
                <tr>
                    <td>Socket 2</td>
                    <td><input name="opt_soc2" type="number" value="{$Config.Price.Socket2}"></td>
                </tr>
                <tr>
                    <td>Socket 3</td>
                    <td><input name="opt_soc3" type="number" value="{$Config.Price.Socket3}"></td>
                </tr>
                <tr>
                    <td>Socket 4</td>
                    <td><input name="opt_soc4" type="number" value="{$Config.Price.Socket4}"></td>
                </tr>
                <tr>
                    <td>Socket 5</td>
                    <td><input name="opt_soc5" type="number" value="{$Config.Price.Socket5}"></td>
                </tr>
                <tr>
                    <td colspan="2"><button class="def_adm_btn" name="shop_save">Save</button></td>
                </tr>
            </table>
        </form>

        <form action="/admin/modules/shop" method="post">
            <table width="100%"><tr><td>
            <table id="list-shop-items" class="display">
                <thead>
                <tr>
                    <th>Item name</th>
                    <th>Char class</th>
                    <th>Item type</th>
                    <th>Item index</th>
                    <th>Skill</th>
                    <th>Luck</th>
                    <th>Harmony</th>
                    <th>Ancient</th>
                    <th>Max Addition</th>
                    <th>Max Level</th>
                    <th>Max Excellent</th>
                    <th>Max Socket</th>
                    <th>Start Price ({$Valutes[$Config.MainValute].Name})</th>
                    <th>Update</th>
                    <th>Delete</th>
                </tr>
                </thead>
                <tbody>
                {foreach $Config.Items item=item key=i}
                    <tr>
                        <td>{$item.Name}</td>
                        <td>
                            {if $item.CharClass == "0"}
                                Dark Wizard
                            {elseif $item.CharClass == "1"}
                                Dark Knight
                            {elseif $item.CharClass == "2"}
                                Fairy Elf
                            {elseif $item.CharClass == "3"}
                                Summoner
                            {elseif $item.CharClass == "4"}
                                Magic Gladiator
                            {elseif $item.CharClass == "5"}
                                Dark Lord
                            {elseif $item.CharClass == "6"}
                                Rage Fight
                            {elseif $item.CharClass == "7"}
                                Other Item
                            {/if}
                          {*  {$item.CharClass}*}
                        </td>
                        <td>{$item.Type}</td>
                        <td>{$item.Index}</td>
                        <td>{$item.Skill}</td>
                        <td>{$item.Luck}</td>
                        <td>{$item.Harmony}</td>
                        <td>{$item.Ancient1}|{$item.Ancient2}</td>
                        <td>{$item.MaxAddition}</td>
                        <td>{$item.MaxLevel}</td>
                        <td>{$item.MaxExcellent}</td>
                        <td>-</td>
                        <td>{$item.StartPrice}</td>
                        <td><button value="{$i}" name="update_item">Update</button></td>
                        <td><button value="{$i}" name="delete_item">Delete</button></td>
                    </tr>
                {/foreach}
                </tbody>
            </table>
                    </td></tr></table>
        </form>
        <form action="/admin/modules/shop" method="post">
            <table width="100%">
                <tr>
                    <th colspan="2" style="font-size: 18px;">Add item</th>
                </tr>
                <tr>
                    <td>Character class</td>
                    <td>
                        <select name="add_item_class" id="add_item_class">
                            {if $Update.CharClass == 0}
                                <option value="0" selected>Dark Wizard</option>
                            {else}
                                <option value="0">Dark Wizard</option>
                            {/if}
                            {if $Update.CharClass == 1}
                                <option value="1" selected>Dark Knight</option>
                            {else}
                                <option value="1">Dark Knight</option>
                            {/if}
                            {if $Update.CharClass == 2}
                                <option value="2" selected>Fairy Elf</option>
                            {else}
                                <option value="2">Fairy Elf</option>
                            {/if}
                            {if $Update.CharClass == 3}
                                <option value="3" selected>Summoner</option>
                            {else}
                                <option value="3">Summoner</option>
                            {/if}
                            {if $Update.CharClass == 4}
                                <option value="4" selected>Magic Gladiator</option>
                            {else}
                                <option value="4">Magic Gladiator</option>
                            {/if}
                            {if $Update.CharClass == 5}
                                <option value="5" selected>Dark Lord</option>
                            {else}
                                <option value="5">Dark Lord</option>
                            {/if}
                            {if $Update.CharClass == 6}
                                <option value="6" selected>Rage Fight</option>
                            {else}
                                <option value="6">Rage Fight</option>
                            {/if}
                            {if $Update.CharClass == 7}
                                <option value="7" selected>Other Item</option>
                            {else}
                                <option value="7">Other Item</option>
                            {/if}
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>Item name</td>
                    <td><input name="add_item_name" type="text" value="{$Update.Name}"></td>
                </tr>
                <tr>
                    <td>Item type</td>
                    <td><input name="add_item_type" type="number" value="{$Update.Type}"></td>
                </tr>
                <tr>
                    <td>Item index</td>
                    <td><input name="add_item_index" type="number" value="{$Update.Index}"></td>
                </tr>
                <tr><th colspan="2" style="font-size: 16px;">Option</th></tr>
                <tr>
                    <td>Luck</td>
                    {if $Update.Luck}
                        <td><input name="add_item_luck" type="checkbox" checked></td>
                    {else}
                    <td><input name="add_item_luck" type="checkbox"></td>
                    {/if}
                </tr>
                <tr>
                    <td>Skill</td>
                    {if $Update.Skill}
                    <td><input name="add_item_skill" type="checkbox"></td>
                    {else}
                    <td><input name="add_item_skill" type="checkbox"></td>
                    {/if}
                </tr>
                <tr>
                    <td>Harmony</td>
                    {if $Update.Harmony}
                    <td><input name="add_item_harmony" type="checkbox"></td>
                    {else}
                    <td><input name="add_item_harmony" type="checkbox"></td>
                    {/if}
                </tr>
                <tr><td colspan="2">Leave empty if not needed</td></tr>
                <tr>
                    <td>Ancient Name 1</td>
                    <td><input name="add_item_anc1" type="text" value="{$Update.Ancient1}"></td>
                </tr>
                <tr>
                    <td>Ancient Name 2</td>
                    <td><input name="add_item_anc2" type="text" value="{$Update.Ancient2}"></td>
                </tr>
                <tr>
                    <td>Max Level</td>
                    <td><input name="add_item_max_level" type="number" value="{$Update.MaxLevel}"></td>
                </tr>
                <tr>
                    <td>Max Excellent</td>
                    <td><input name="add_item_max_exl" type="number" value="{$Update.MaxExcellent}"></td>
                </tr>
                <tr>
                    <td>Max Addition</td>
                    <td><input name="add_item_max_add" type="number" value="{$Update.MaxAddition}"></td>
                </tr>
                <tr>
                    <td colspan="2">Sockets are disabled</td>
                </tr>
                <tr>
                    <td>Max Socket</td>
                    <td><input name="add_item_max_soc" type="number" value="{$Update.MaxSockets}"></td>
                </tr>
                <tr>
                    <td>Price ({$Valutes[$Config.MainValute].Name})</td>
                    <td><input name="add_item_price" type="number" value="{$Update.StartPrice}"></td>
                </tr>

                <tr>
                    <td colspan="2"><button class="def_adm_btn" value="{$Update.Key}" name="add_item">Add/Update</button></td>
                </tr>
            </table>
        </form>
    </div>
</div>


<script type="text/javascript">
    $(document).ready(function(){
        $('#list-shop-items').DataTable();
    });
</script>
