{include file="./index_top.tpl"}
<script type="text/javascript" src="mybic.js?{$revision}"></script>
<script language="JavaScript" type="text/javascript">
    var ajaxObj = new XMLHTTP("edit_questionare.php");
    ajaxObj.format = 0;
    function dis_resp() {
    }
    function switchOnObjectQst(qst_id) {
        $('#switch-on-btn_'+qst_id).toggleClass('switch-on');
        $('#switch-on-btn_'+qst_id).trigger('on.switch');
        ajaxObj.call('qst_id='+qst_id+'&sel=disable&enbl='+($('#switch-on-btn_'+qst_id).hasClass('switch-on')?1:0)+'&csrf={$csrf}',dis_resp);
    }
</script>
<div align=center>
    <br>{$lang.Questionaries} {$lang.of_table} "{$name_table}"<span class='help_bt' h_id='Questionaries'></span><br><br>
    {include file="./conf_nav.tpl"}
    <p style="font-size:14px;">
        {if $archive}<a style="font-size:14px;" href="edit_questionare.php?table={$table_id}">{/if}
            {$lang.active}
        {if $archive}</a>{/if}
        /
        {if !$archive}
            {if $has_archive}
                <a style="font-size:14px;" href="edit_questionare.php?table={$table_id}&archive">
            {else}
                <span style="color:gray" title="{$lang.Empty_archive}">
            {/if}
        {/if}
            {$lang.archive}
        {if !$archive}{if $has_archive}</a>{else}</span>{/if}{/if}
    </p>
    <table border=0 cellpadding=3>
        {foreach from=$all_qst item=one_qst}
            {if $user.group_id==1 || $user.sub_admin_rights.tables.{$table_id}>=2 || $one_qst.owner_id==$user.group_id}
            {if $config.display_protected_elements || $one_qst.blocked != 2}
                <tr>
                    <td>
                        {if $user.group_id==1 || $user.sub_admin_rights.tables.{$table_id}==2 || $one_qst.owner_id==$user.group_id}
                        {if !$one_qst.blocked}
                        {if !$archive}
                            <a class='href_post'
                            href="edit_questionare.php?table={$table_id}&qst_id={$one_qst.id}&sel=archive"><img
                                        alt="{$lang.into_archive}" title="{$lang.send_in_archive}"
                                        src="images/b_archive.png" border=0></a>
                        {else}
                            <a class='href_post'
                            href="edit_questionare.php?table={$table_id}&qst_id={$one_qst.id}&sel=restore"><img
                                        alt="{$lang.restore}" title="{$lang.restore_from_archive}"
                                        src="images/b_restore.png" border=0></a>
                        {/if}
                        {/if}
                        {/if}
                    </td>
                    <td>{if ($user.group_id==1 || ($user.sub_admin_rights.tables.{$table_id}==2 && $user.sub_admin_rights.allow_del) || $one_qst.owner_id==$user.group_id) && !$one_qst.blocked}
                            <a class='href_post'
                               href="edit_questionare.php?sel=delete&qst_id={$one_qst.id}&table={$sel_table}"
                               onclick='return href_post=jconfirm("{$lang.confirm_delete_questionare}", this);'><img
                                    alt="{$lang.delete}" title="{$lang.Delete_questionare}" src="images/b_drop.png"
                                    border=0></a>{/if}</td>
                    {if !$archive}
                        <td>{if $one_qst.blocked != 2 && !$add_blocked}<a class='href_post'
                               href="edit_questionare.php?sel=copy&qst_id={$one_qst.id}&table={$sel_table}"
                               onclick="{if !$full_version}jalert('{$lang.Qst_disabled}'); href_post=false;{else}if (copy_name=prompt('{$lang.Copy_as}','{$one_qst.name|escape:'html'} {$lang['(copy)']}')) {ldelim}this.href=this.href+'&amp;copy_name='+copy_name; href_post=true;{rdelim} else href_post=false;{/if}"><img
                                        alt="{$lang.copy}" title="{$lang.Copy_questionare}" src="images/b_copy.png"
                                        border=0></a>{/if}</td>
                        <td>
                            {if !$one_qst.blocked}
                                <div style="left: 1px; top: 2px; margin: 0 5px;"
                                    onclick="switchOnObjectQst('{$one_qst.id}')"
                                    class="switch-btn {if !$one_qst.disabled}switch-on{/if}"
                                    id="switch-on-btn_{$one_qst.id}">
                                    <div></div>
                                </div>
                            {/if}
                        </td>
                    {/if}
                    <td>
                        {if ($user.group_id==1 || $user.sub_admin_rights.tables.{$table_id}>=2 || $one_qst.owner_id==$user.group_id) && $one_qst.blocked != 2}
                            <a class="cb_form_title__link {if $one_qst.blocked}gray_link{/if}" href='edit_questionare.php?qst_id={$one_qst.id}&table={$sel_table}'>
                                <b>{$one_qst.name}</b>
                            </a>
                        {else}
                            <span style="color:gray;"><b>{$one_qst.name}</b></span>
                        {/if}
                    </td>
                    {if $one_qst.protected}<td><img src="images/lock.svg" style="width:13px" title="{$one_qst.protect_comment}"></td>{/if}
                </tr>
            {/if}
            {/if}
            {foreachelse}
            <tr>
                <td>{$lang.Empty_qst}</td>
            </tr>
        {/foreach}
    </table>
    <br>
    <form method="POST">
        <input type="hidden" name="qst_id" value="-1">
        <input type="hidden" name="sel_tab" value="settings">
        <input type="hidden" name="qst_table" value="{$sel_table}">
        <input type="hidden" name="sel" value="save">
        <input type="hidden" name=csrf value='{$csrf}'>
        {if !$archive && !$add_blocked}<input class="btn btn-default btn-sm" type=submit value="{$lang.Add_qst}"
               {if !$full_version}onclick="jalert('{$lang.Qst_disabled}'); return false;"{/if}>{/if}
    </form>
    <br><br>
    <br><a href="{if $back_url}{$back_url}{else}edit_tabrep.php?cat={$cat_id}{/if}">{$lang.return_to_tables}</a> | <a href="fields.php?table={$table_id}" target="_blank">{$lang.view_table}</a><br><br>
    <br><br>
</div>

<script src="themes/clientbase/js/cut_title_field.js"></script>
