<div class="form_wrapper">
    <form method="post">
        <div class="buttons">
            <a href="/admin/delete_training/{$training_data.tr_id}" class="addbutton delete-big">Törlés</a>
        </div>
        <input type="hidden" name="action" id="action" value="training_data_edit">
        <input type="hidden" name="tr_id" id="tr_id" value="{$training_data.tr_id}">

        <div>
            <label class="desc" id="title1" for="tr_date">Dátum:</label>
            <div><input type="text" name="tr_date" id="tr_date" value="{$training_data.tr_date|substr:0:-3}" required></div>
        </div>

        <div>
            <label class="desc" id="title2" for="tr_training_type_trt_id">Típus:</label>
            <div>
                <select name="tr_training_type_trt_id" id="tr_training_type_trt_id">
                    <option value="null"> - </option>
                    {foreach $training_type_assoc_array as $training_type_array}
                        <option value="{$training_type_array.trt_id}"{if $training_type_array.trt_id == $training_data.tr_training_type_trt_id} selected{/if}>
                            {$training_type_array.trt_name}
                        </option>
                    {/foreach}
                </select>
            </div>
        </div>

        <div>
            <label class="desc" id="title1" for="tr_duration">Időtartam (perc):</label>
            <div><input type="text" name="tr_duration" id="tr_duration" value="{$training_data.tr_duration}" required></div>
        </div>

        {* <div>
            <label class="desc" for="tr_price">Ár:</label>
            <div><input type="text" name="tr_price" id="tr_price" value="{$training_data.tr_price}" required></div>
        </div> *}

        <div>
            <label class="desc" for="tr_note">Megjegyzés:</label>
            <div>
                <textarea rows="4" name="tr_note" id="tr_note">{$training_data.tr_note}</textarea>
            </div>
        </div>

        <div>
            <label class="desc" id="title1" for="coaches">Edző(k):</label>
            <table>
                <tr>
                    <td class="bold">Név</td>
                    <td class="bold center">E</td>
                    <td class="bold center">SE</td>
                </tr>
                {foreach $coach_array as $coach}
                <tr>
                    <td class="coach">{$coach->get_ua_name()}</td>
                    <td><input type="checkbox" name="coaches[]" value="{$coach->get_ua_id()}" class="coach_type"{if $coach->is_coach_at_training($tr_id)} checked{/if}></td>
                    <td><input type="checkbox" name="helpers[]" value="{$coach->get_ua_id()}" class="coach_type"{if $coach->is_helper_at_training($tr_id)} checked{/if}></td>
                </tr>
                {/foreach}
            </table>
        </div>

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

    </form>
</div>

{* <script type="text/javascript">
    $('#tr_training_type_trt_id').on('change', function(e) {
        //get trt default price by ajax
        let selectedType = $('#tr_training_type_trt_id option:selected').val();
        $.ajax({
            url: '/_ajax/get_trt_default_price.php',
            //method: 'GET',
            data: {
                'trt_id' : selectedType
            },
            success: function(data, status, jqXHR) {
                let pdata = JSON.parse(data);
                console.log(pdata);
                if (null === pdata) {
                    $('#tr_price').val('');
                    return;
                }

                $('#tr_price').val(pdata);
            }
        });

    });
</script> *}
