<td colspan="2" align="center">
    <h2>{$params_tpl['title']}{$params_tpl['help']}</h2>
    <!-- Селект: Фиксированный / Динамический -->
    <div class="correlation__row">
   
        <div class="correlation__key">
            <span>Выберите тип шаблона печати</span><span class="help_bt" h_id="tpl_print_calc_type_tpl"></span>:
        </div>
        <div style="text-align: left; padding: 3px;">
            <select id="modeSelector" name="calc_params[0][type_template]" onchange="toggleMode()" class="form-control form-control-160 dont_use_chosen" title="" style="width: 150px;">
                <option value="fixed" {if $construct_params.params.0.type_template != 'dynamic'}selected{/if}>Фиксированный</option>
                <option value="dynamic" {if $construct_params.params.0.type_template == 'dynamic'}selected{/if}>Динамический</option>
            </select>
        </div>
    </div>
    <div id="fixedBlock" style="display: flex; flex-direction: column;">
        {$tpl_types['print_tpl']}
    </div>

    <!-- Блок динамического режима -->
    <div id="dynamicBlock" style="display: none; flex-direction: column;">
         <div class="correlation__row">
            <div class="correlation__key">
                <span>Выберите таблицу</span><span class="help_bt" h_id="tpl_print_calc_table"></span>:
            </div>
            <div style="text-align: left; padding: 3px;">
                <select id="sourceSelector" onchange="toggleMode()" name="calc_params[0][tabel_for_tpl]" class="form-control form-control-160 dont_use_chosen" title="" style="width: 150px;">
                    <option value="current" {if $construct_params.params.0.tabel_for_tpl != 'parent'}selected{/if}>Текущая</option>
                    <option value="parent" {if $construct_params.params.0.tabel_for_tpl == 'parent'}selected{/if}>Родительская таблица</option>
                </select>
            </div>
        </div>
        {$tpl_types['field_id_template']}
    </div>
    <div style="display: flex; flex-direction: column;">{$tpl_types['field']}</div>
</td>

<script>
toggleMode();
function toggleMode() {
    const isFixed = document.getElementById('modeSelector').value === 'fixed';

    document.getElementById('fixedBlock').style.display = isFixed ? 'flex' : 'none';
    document.getElementById('dynamicBlock').style.display = isFixed ? 'none' : 'flex';
}
</script>