<div class="form_wrapper">
<div class="buttons">
    <a href="/admin/delete_member/{$user_data.uk_id}" class="addbutton delete-big">Törlés</a>
</div>
<form method="post">
    <input type="hidden" name="action" id="action" value="user_data_edit">
    <input type="hidden" name="user_type" id="user_type" value="1">
    <input type="hidden" name="uk_id" id="uk_id" value="{$user_data.uk_id}">

        <div>
            <label class="desc" for="uk_name">Név:</label>
            <div><input type="text" name="uk_name" id="uk_name" size="8" class="field text fn" value="{$user_data.uk_name}" required></div>
        </div>

        <div>
            <label class="desc" for="uk_is_active">Aktív:</label>
            <div><input type="checkbox" name="uk_is_active" id="uk_is_active" value="1" {if 1==$user_data.uk_is_active}checked{/if}></div>
        </div>

        <div>
            <label for="uk_lease">Bérletes:</label>
            <div><input type="checkbox" name="uk_lease" id="uk_lease" value="1" {if 1==$user_data.uk_lease}checked{/if}></div>
        </div>

        <div>
            <label class="desc" for="uk_last_modified">Utolsó módosítás dátuma:</label>
            <div><input type="text" name="uk_last_modified" id="uk_last_modified" value="{$user_data.uk_last_modified}"></div>
        </div>

        <div style="padding-top: 15px; border-top: 1px solid;">
            <label for="uk_balance_expires">Egyenleg lejár:</label>
            <div><input type="checkbox" name="uk_balance_expires" id="uk_balance_expires" value="1" {if 1==$user_data.uk_balance_expires}checked{/if}></div>
        </div>

{*         <div class="balance_expire_date">
            <label for="uk_balance_expire_date">Egyenleg lejárati dátuma (ha üres, akkor automatikusan lejár a legutóbbi befizetéshez képest):</label>
            <div><input type="text" name="uk_balance_expire_date" id="uk_balance_expire_date" placeholder="ÉÉÉÉ-HH-NN" value="{$user_data.uk_balance_expire_date}"></div>
        </div> *}

        <div>
            <label>Egyenleg:</label>
            <div style="padding-top: 6px;">{{$user_data.uk_balance|number_format:0:'':' '}} Ft</div>
        </div>

        <div style="padding-bottom: 15px; border-bottom: 1px solid;">
            {if $user_data.uk_balance}
                <label>Lejár:</label>
                <div style="padding-top: 6px;">
                    {if $user_data.uk_balance_expire_date}
                        {{$user_data.uk_balance_expire_date|date_format:"%Y.%m.%d"}}
                    {elseif $user_data.uk_last_deposit}
                        {strtotime("+1 month",strtotime($user_data.uk_last_deposit))|date_format:"%Y.%m.%d"}
                    {else}
                        Automatikusan
                    {/if}
                </div>
            {/if}
        </div>

        <div>
            <label class="desc" for="uk_password">Jelszó:</label>
            <div><input type="text" name="uk_password" id="uk_password" value="{$user_data.uk_password}"></div>
        </div>

        <div>
            <legend class="desc" for="uk_gender">Nem: </legend>
            <div>
                <input id="r_01" type="radio" name="uk_gender" value="1" {if 1==$user_data.uk_gender}checked{/if}>
                <label class="choice" for="r_01">Fiú</label>
            </div>
            <div>
                <input id="r_02" type="radio" name="uk_gender" value="2" {if 2==$user_data.uk_gender}checked{/if}>
                <label class="choice" for="r_02">Lány</label>
            </div>
        </div>

        <div>
            <label class="desc" for="uk_birth_date">Születési dátum:</label>
            <div><input type="text" name="uk_birth_date" id="uk_birth_date" value="{$user_data.uk_birth_date}"></div>
        </div>

        <div>
            <label class="desc" for="uk_birth_year">Születési év:</label>
            <div><input type="text" name="uk_birth_year" id="uk_birth_year" value="{$user_data.uk_birth_year}"></div>
        </div>

        <div>
            <label class="desc" for="uk_address_scc_id">Lakhely (település):</label>
            <div>
                <select name="uk_address_scc_id" id="uk_address_scc_id">
                    <option value="null"> - </option>
                    {foreach $school_city_assoc_array as $school_city_array}
                        <option value="{$school_city_array->get_scc_id()}"{if $user_data.uk_address_scc_id == $school_city_array->get_scc_id()} selected{/if}>
                            {$school_city_array->get_scc_city()}
                        </option>
                    {/foreach}
                </select>
            </div>
        </div>

        <div>
            <label class="desc" for="uk_first_training">Első edzés dátuma:</label>
            <div><input type="text" name="uk_first_training" id="uk_first_training" value="{$user_data.uk_first_training}"></div>
        </div>

        <div>
            <label class="desc" for="uk_beforehand">Előzmény:</label>
            <div><input type="text" name="uk_beforehand" id="uk_beforehand" value="{$user_data.uk_beforehand}"></div>
        </div>

        <div>
            <legend class="desc" for="uk_hand">Kéz: </legend>
            <div>
                <input id="r_03" type="radio" name="uk_hand" value="1" {if 1==$user_data.uk_hand}checked{/if}>
                <label class="choice" for="r_03">Bal</label>
            </div>
            <div>
                <input id="r_04" type="radio" name="uk_hand" value="2" {if 2==$user_data.uk_hand}checked{/if}>
                <label class="choice" for="r_04">Jobb</label>
            </div>
        </div>

        <div>
            <label for="level">Szint:</label>
            {foreach $tt_assoc_array as $tt}
                <div>
                    <input type="checkbox" name="level[]" value="{$tt['trt_id']}"{if user_kid::has_training_type($user_data.uk_id, $tt['trt_id'])} checked{/if}>
                    <span style="position: relative; bottom: 3px;">{$tt['trt_name']}</span>
                </div>
            {/foreach}
        </div>


        <div>
            <label class="desc" for="uk_email">E-mail cím:</label>
            <div><input type="email" name="uk_email" id="uk_email" value="{$user_data.uk_email}"></div>
        </div>

        <div>
            <label class="desc" for="uk_phone">Telefonszám:</label>
            <div><input type="text" name="uk_phone" id="uk_phone" value="{$user_data.uk_phone}"></div>
        </div>

        <div>
            <label class="desc" for="uk_facebook">Facebook:</label>
            <div><input type="text" name="uk_facebook" id="uk_facebook" value="{$user_data.uk_facebook}"></div>
        </div>

        <div>
            <label class="desc" for="uk_shirt_size_ss_id">Pólóméret:</label>
            <div>
                <select name="uk_shirt_size_ss_id" id="uk_shirt_size_ss_id">
                    <option value="null"> - </option>
                    {foreach $shirt_size_assoc_array as $shirt_size_array}
                        <option value="{$shirt_size_array.shirt_id}"{if $shirt_size_array.shirt_id == $user_data.uk_shirt_size_ss_id} selected{/if}>
                            {$shirt_size_array.shirt_name}
                        </option>
                    {/foreach}
                </select>
            </div>
        </div>

        <div>
            <label class="desc" for="uk_shirt_note">Póló megjegyzés:</label>
            <div><input type="text" name="uk_shirt_note" id="uk_shirt_note" value="{$user_data.uk_shirt_note}"></div>
        </div>

        <div>
            <label class="desc" for="uk_school_sc_id">Iskola neve:</label>
            <div>
                <select name="uk_school_sc_id" id="uk_school_sc_id">
                    <option value="null"> - (állítsd erre új iskola felvételéhez)</option>
                    {foreach $school_assoc_array as $school_array}
                        <option value="{$school_array->get_sc_id()}"{if $school_array->get_sc_id() == $user_data.uk_school_sc_id} selected{/if}>
                            {$school_array->get_sc_name()}
                            {if $school_array->get_sc_school_city()}({$school_array->get_sc_school_city()->get_scc_city()}){/if}
                        </option>
                    {/foreach}
                </select>
            </div>
        </div>

        <div class="add_school">
            <label class="desc" for="add_school">Új iskola neve:</label>
            <div><input type="text" name="add_school" id="add_school"></div>
        </div>

        <div class="add_school">
            <label class="desc" for="uk_school_city_scc_id">Új iskola települése:</label>
            <div>
                <select name="uk_school_city_scc_id" id="uk_school_city_scc_id">
                    <option value="null"> - </option>
                    {foreach $school_city_assoc_array as $school_city_array}
                        <option value="{$school_city_array->get_scc_id()}">
                            {$school_city_array->get_scc_city()}
                        </option>
                    {/foreach}
                </select>
            </div>
        </div>



        <div>
            <label class="desc" for="uk_region_reg_id">Diákolimpia körzet:</label>
            <div>
                <select name="uk_region_reg_id" id="uk_region_reg_id">
                    <option value="null"> - </option>
                    {foreach $region_assoc_array as $region_array}
                        <option value="{$region_array.reg_id}"{if $region_array.reg_id == $user_data.uk_region_reg_id} selected{/if}>
                            {$region_array.reg_name}
                        </option>
                    {/foreach}
                </select>
            </div>
        </div>

        <div>
            <label class="desc" for="uk_age_category">Diákolimpia korcsoport:</label>
            <div><input type="text" name="uk_age_category" id="uk_age_category" value="{$user_data.uk_age_category}"></div>
        </div>

        <div>
            <label class="desc" for="uk_official_age_category">MTLSz korosztály:</label>
            <div><input type="text" name="uk_official_age_category" id="uk_official_age_category" value="{$user_data.uk_official_age_category}"></div>
        </div>

        <div>
            <label class="desc" for="uk_parent_1">Szülő:</label>
            <div>
                <select name="uk_parent_1" id="uk_parent_1">
                    <option value="null"> - (állítsd erre új szülő felvételéhez)</option>
                    {foreach $parent_assoc_array as $parent_array}
                        <option value="{$parent_array.up_id}"{if $parent_array.up_id == $user_data.uk_parent_1} selected{/if}>
                            {$parent_array.up_name}
                        </option>
                    {/foreach}
                </select>
            </div>
        </div>

        <div class="add_parent_1_block">
            <label class="desc" for="add_parent_1">Új szülő neve:</label>
            <div><input type="text" name="add_parent_1" id="add_parent_1"></div>
        </div>

        <div>
            <label class="desc" for="parent_1_email">E-mail cím:</label>
            <div><input type="text" name="parent_1_email" id="parent_1_email"></div>
        </div>

        <div>
            <label class="desc" for="parent_1_phone">Telefonszám:</label>
            <div><input type="text" name="parent_1_phone" id="parent_1_phone"></div>
        </div>
        <div>
            <label class="desc" for="parent_1_facebook">Facebook:</label>
            <div><input type="text" name="parent_1_facebook" id="parent_1_facebook"></div>
        </div>




        <div>
            <label class="desc" id="title2" for="uk_parent_2">Szülő:</label>
            <div>
                <select name="uk_parent_2" id="uk_parent_2">
                    <option value="null"> - (állítsd erre új szülő felvételéhez)</option>
                    {foreach $parent_assoc_array as $parent_array}
                        <option value="{$parent_array.up_id}"{if $parent_array.up_id == $user_data.uk_parent_2} selected{/if}>
                            {$parent_array.up_name}
                        </option>
                    {/foreach}
                </select>
            </div>
        </div>

        <div class="add_parent_2_block">
            <label class="desc" id="title2" for="add_parent_2">Új szülő neve:</label>
            <div><input type="text" name="add_parent_2" id="add_parent_2"></div>
        </div>

        <div>
            <label class="desc" id="title2" for="parent_2_email">E-mail cím:</label>
            <div><input type="text" name="parent_2_email" id="parent_2_email"></div>
        </div>
        <div>
            <label class="desc" id="title2" for="parent_2_phone">Telefonszám:</label>
            <div><input type="text" name="parent_2_phone" id="parent_2_phone"></div>
        </div>

        <div>
            <label class="desc" id="title2" for="parent_2_facebook">Facebook:</label>
            <div><input type="text" name="parent_2_facebook" id="parent_2_facebook"></div>
        </div>

        <br>

        <div>
            <label class="desc" id="title2" for="uk_contact">Kapcsolat tartás:</label>
            <div><textarea rows="7" name="uk_contact" id="uk_contact">{$user_data.uk_contact}</textarea></div>
        </div>

        <br>

        <div>
            <label class="desc" id="title2" for="uk_other">Egyéb:</label>
            <div><textarea rows="5" name="uk_other" id="uk_other">{$user_data.uk_other}</textarea></div>
        </div>

        <br>


        <div>
            <div>
                <input class="button black" type="submit" value="Mentés">
            </div>
        </div>


</form>
</div>

<script type="text/javascript">
    $( document ).ready(function() {
        if ($("#uk_parent_1").val() == 'null') $(".add_parent_1_block").show();
        else $(".add_parent_1_block").hide();
        if ($("#uk_parent_2").val() == 'null') $(".add_parent_2_block").show();
        else $(".add_parent_2_block").hide();
        if ($("#uk_school_sc_id").val() == 'null') $(".add_school").show();
        else $(".add_school").hide();
        $("#uk_parent_1").trigger("change");
        $("#uk_parent_2").trigger("change");
    });

    $('#uk_parent_1').change(function() {
        $(".add_parent_1_block").toggle(this.value == 'null');
    });

    $('#uk_parent_2').change(function() {
        $(".add_parent_2_block").toggle(this.value == 'null');
    });

    $('#uk_school_sc_id').change(function() {
        $(".add_school").toggle(this.value == 'null');
    });


    $("#uk_parent_1").change(function(){
    $.post("/_ajax/get_parent_data.php",
    {
        parent_id: $("#uk_parent_1").val(),
        parent_number: 1
    },
    function(data, status){
        if (!data) {
            $("#parent_1_phone").val('');
            $("#parent_1_email").val('');
            $("#parent_1_facebook").val('');
        }
        else {
            var pdata = JSON.parse(data);
            $("#parent_1_phone").val(pdata[1]);
            $("#parent_1_email").val(pdata[0]);
            $("#parent_1_facebook").val(pdata[2]);

        }
    });
    });


    $("#uk_parent_2").change(function(){
        $.post("/_ajax/get_parent_data.php",
        {
            parent_id: $("#uk_parent_2").val(),
            parent_number: 2
        },
        function(data, status){
            if (!data) {
                $("#parent_2_phone").val('');
                $("#parent_2_email").val('');
                $("#parent_2_facebook").val('');
            }
            else {
                var pdata = JSON.parse(data);
                $("#parent_2_phone").val(pdata[1]);
                $("#parent_2_email").val(pdata[0]);
                $("#parent_2_facebook").val(pdata[2]);

            }
        });
    });

    $("#uk_balance_expires").on('change', function() {
        if (!$(this).is(':checked')) {
            $('#uk_balance_expire_date').val('');
            $('#uk_balance_expire_date').prop('disabled', 'disabled');
        }
        else {
            $('#uk_balance_expire_date').removeAttr('disabled');
        }
    });

    $("#uk_balance_expires").trigger('change');

</script>
