{include file="mobile/templates/index_top.tpl"}

<div class="pages navbar-through toolbar-through">
    <!-- Page, "data-page" contains page name -->
    <div data-page="fields" class="page">
        <!-- Scrollable page content -->
        <div class="page-content pull-to-refresh-content">
            <!-- Default pull to refresh layer-->
            <div class="pull-to-refresh-layer">
                <div class="preloader"></div>
                <div class="pull-to-refresh-arrow"></div>
            </div>

            {if $no_tables}
                {$lang.no_tables_report}
                <br>
            {elseif $no_fields}
                {$lang.no_tables_fields_report}
                <br>
            {else}

            {if $a_style}
                <style>{$a_style}</style>{/if}
                <script class="m-cb-fields-validation">
                    function op_sel_send(op_sel, $page) {

                        {if $deleted}
                        if (op_sel == "delete") {
                            {if $user.group_id==1 || $user.sub_admin==1}
                            if (confirm('{$lang.delete_lines_alert}')) {
                                $page.find('input.op_sel').val(op_sel);
                                $page.find('form.sel_records').submit();
                            }
                            {else}
                            myApp.alert('{$lang.delete_lines_info}');
                            {/if}
                        }
                        else
                        {/if}
                        {
                            $page.find('input.op_sel').val(op_sel);
//                $page.find('form.sel_records').submit();
                            if (op_sel == "print" || op_sel == "send" || op_sel == "sms" || op_sel == "search") {
                                open_dialog(op_sel, $page);
                            }
                            else {
                                $page.find('form.sel_records').submit();
                            }
                        }
                    }

                    function sel_alert(op_sel, $page, but_id) {
                        var _all_lines = $page.find(".m-cb-fields li:not(.item-divider)");
                        {if $cnt_line} // определим js сколько записей
                        var sel = 0;
                        $.each(_all_lines, function (i, el) {
                            if ($(el).find("input:checked").length > 0) {
                                sel++;
                            }
                        });
                        //valid
                        if (op_sel == "copy" && sel != 1) {
                            myApp.alert('{$lang.sel_copy_alert}');
                            sel = -1;
                        }
                        if (op_sel == "sms" && {$sms_balance}== 0) {
                            myApp.alert('{$lang.modules.sms.balance_is_empty}');
                            sel = -1;
                        }
                        if (op_sel == "sms" && sel >{$sms_balance}) {
                            myApp.alert('{$lang.modules.sms.sel_sms_alert} ({$sms_balance})');
                            sel = -1;
                        }

                        if (but_id > 0) {
                            $page.find('input.button_id').val(but_id);
                        }

                        if (!sel) {
                            myApp.confirm('{$lang.all_checked_line_funtion}', function () {
                                if (op_sel == "sms" && {$cnt_line}>{$sms_balance}) {
                                    myApp.alert('{$lang.modules.sms.sel_sms_alert} ({$sms_balance})');
                                    sel = -1;
                                } else {
                                    sel = 1;
                                    op_sel_send(op_sel, $page);
                                }
                            });
                        }

                        if (sel > 0) {
                            op_sel_send(op_sel, $page);
                        }
                        {else}
                        myApp.alert('1{$lang.no_lines_selected}');
                        {/if}
                    }
                </script>
                <div class="m-cb-dyn-script" style="display: none;"></div>
                <!-- костыль для выборки имени подфильтра -->
                {assign var=filter_sub_name value= ''}
                {if $user_filters[0][$filter_id].name}
                {else}
                    {foreach from=$user_filters item=one_main_filter}
                        {foreach from=$one_main_filter item=sub_filter_info key=key_id}
                            {if $filter_id == $key_id}
                                {$filter_sub_name = $sub_filter_info.name}
                            {/if}
                        {/foreach}
                    {/foreach}
                {/if}
                <div class="m__table-view--table-name">
                    {if $name_table}{$name_table}{else}{$full_name}{/if}
                    {if $archive} &nbsp;<i>({$lang.archive})</i>{/if}
                    {if $deleted} &nbsp;<i>({$lang.deleted})</i>{/if}
                </div>
                {if $user_filters_cnt > 1}
                    <div class="content-block-filters">
                        <div>
                            <span>{$lang.Filter} ({$user_filters[0]|count_cb}):</span>
                            <select class="form-control form-control-250" id="filter-value" table_id="{$table_id}">
                                {foreach from=$user_filters[0] item=one_filter}
                                    <option value="{$one_filter['id']}" {if $one_filter['id'] == $filter_id}selected{/if}>{$one_filter['name']}</option>
                                    {if $user_filters[$one_filter['id']]}
                                        {foreach from=$user_filters[$one_filter['id']] item=one_sub_filter}
                                            <option value="{$one_sub_filter['id']}" {if $one_sub_filter['id'] == $filter_id}selected{/if}>&nbsp;&nbsp;&nbsp;{$one_sub_filter['name']}</option>
                                            {if $user_filters[$one_sub_filter['id']]}
                                                {foreach from=$user_filters[$one_sub_filter['id']] item=one_sub_sub_filter}
                                                    <option value="{$one_sub_sub_filter['id']}" {if $one_sub_sub_filter['id'] == $filter_id}selected{/if}>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$one_sub_sub_filter['name']}</option>
                                                {/foreach}
                                            {/if}
                                        {/foreach}
                                    {/if}
                                {/foreach}
                            </select>
                        </div>
                    </div>
                {/if}

            {if $search_text}
                <div class="content-block" style="background: #fff4d6;margin: 0 15px;border-radius: 7px;border: 1px solid #c8c7cc;margin-bottom: 8px;" id="search">
                    <div class="content-block-inner" style="background: transparent;padding: 10px;">
                        <div class="row no-gutter">
                            <div class="col-95" style="background: #fff4d6;grid-template-columns: 3em 4em auto;display: inline-grid; align-items: center">
                                <img src="./images/search.gif">
                                <b>{$lang.Search}:</b> {$search_text}
                            </div>
                            <div class="col-5"><a
                                        href="#"
                                        title="{$lang.Reset_search}"
                                        class="button button-cancel"
                                        style="width: 22px;height: 22px;background: url(images/bullet.png) no-repeat top right;cursor: pointer;border-color: transparent;"
                                        onclick="location.href= 'fields.php?table={$table_id}{if $rel_table}&rel_table={$rel_table}&rel_line={$rel_line}&rel_field={$rel_field}{/if}{if $filter_id}&filter={$filter_id}{/if}{if $archive}&archive{/if}{if $deleted}&deleted{/if}&search_reset=on'">
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            {/if}
            {if $fix_search}
                <form action="fields.php" id="fix_search_form" method="get" class="no_print">
                    <input type=hidden name="table" value="{$table_id}">
                    {if $rel_table}
                        <input type=hidden name="rel_table" value="{$rel_table}">
                        <input type=hidden name="rel_line" value="{$rel_line}">
                        <input type=hidden name="rel_field" value="{$rel_field}">
                    {/if}
                    {if $filter_id}<input type=hidden name="filter" value="{$filter_id}">{/if}
                    {if $archive}<input type=hidden name="archive" value=1>{/if}
                    {if $deleted}<input type=hidden name="deleted" value=1>{/if}
                    {if $all_records}<input type=hidden name="all" value=1>{/if}
                    <div class="fields__search-template">
                        {foreach from=$fix_search item=one_search}
                            <div class="fields__search-template-item">
                                {if $one_search.type_field!=5}<span class="fields__search-template-name" title="{$one_search.name_field}">{$one_search.name_field}</span><span style="font-weight: bold;padding-right: 4px; width: 6px; text-align: right;">:</span><br/>{/if}
                                {if $one_search.type_field==1 or $one_search.type_field==8 or $one_search.type_field==10}
                                    {if !$one_search.fix_search_mult}
                                        <input type=text name="fix_search[{$one_search.id}][value]" value="{$one_search.value}"
                                               class="form-control form-control-250"
                                                {if !$table.fix_search_submit} onchange="document.getElementById('fix_search_form').submit()"{/if}>
                                    {else}
                                        {$lang.since_from}
                                        <input type=text name="fix_search[{$one_search.id}][value]" value="{$one_search.value}"
                                               class="form-control form-control-75"
                                                {if !$table.fix_search_submit} onchange="document.getElementById('fix_search_form').submit()"{/if}>

                                        {$lang.since_to}
                                        <input type=text name="fix_search[{$one_search.id}][value2]" value="{$one_search.value2}"
                                               class="form-control form-control-75"
                                                {if !$table.fix_search_submit} onchange="document.getElementById('fix_search_form').submit()"{/if}>
                                    {/if}

                                {elseif $one_search.type_field==2 or $one_search.type_field==12}
                                    <input type="date" name="fix_search[{$one_search.id}][value]" value="{date('Y-m-d', strtotime($one_search.value))}"
                                           class="form-control form-control-75 {if !$one_search.display_time}fix-search__date{else}fix-search__datetime{/if}" id="fix_search_{$one_search.id}"
                                           onchange="fixed_search_datapicker_values({$one_search.id}); fixed_search_chage_period({$one_search.id}, this);">
                                    <span style="margin: 0 3px; margin-right: 5px;">-</span>
                                    <input type="date" name="fix_search[{$one_search.id}][value2]" value="{date('Y-m-d', strtotime($one_search.value2))}"
                                           class="form-control form-control-75 {if !$one_search.display_time}fix-search__date{else}fix-search__datetime{/if}" id="fix_search2_{$one_search.id}"
                                           onchange="fixed_search_datapicker_values({$one_search.id}); {if !$table.fix_search_submit} document.getElementById('fix_search_form').submit();{/if}">

                                {elseif $one_search.type_field==3 or $one_search.type_field==6 or $one_search.type_field==9}

                                    <input type=text name="fix_search[{$one_search.id}][value]" value="{$one_search.value}"
                                           class="form-control form-control-250"
                                           {if !$table.fix_search_submit}onchange="document.getElementById('fix_search_form').submit()"{/if}>

                                {elseif $one_search.type_field==4 or $one_search.type_field==7 or $one_search.type_field==11 or $one_search.type_field==13 or $one_search.type_field==14}
                                    {if $one_search.fix_search_mult && $one_search.type_field neq 11 && $one_search.type_field neq 13}
                                        <div style="display: inline-block;" class="form-control form-control-250" id="pseudo_select{$one_search.id}"
                                             onclick="viewPseudoSelectOptions({$one_search.id}); event.cancelBubble=true">
                                            <div class="pseudo_select_text"
                                                 id="pseudo_select_text{$one_search.id}">{if $one_search.mult_text_value}{$one_search.mult_text_value}{else}&nbsp;{/if}</div>
                                            <div class="pseudo_select_options" id="pseudo_select_options{$one_search.id}"
                                                 onclick="event.cancelBubble=true"
                                                 style="z-index: 999; height:{$one_search.select_height}px; overflow:auto">
                                                <div class="pseudo_select_option__wrap">
                                                    {foreach from=$one_search.pseudo_select_options item=one_value name=search_list_values}
                                                        <div class="pseudo_select__wrap">
                                                            <input type="checkbox"
                                                                   name="fix_search[{$one_search.id}][value][]"{if $one_value.checked} checked{/if}
                                                                   value="{$one_value.value}"
                                                                   id="fix_search_ch{$one_search.id}_{$one_value.value}"
                                                                   onclick="completePseudoSelect({$one_search.id}, undefined, {$table_id})"/>
                                                            <label for="fix_search_ch{$one_search.id}_{$one_value.value}"
                                                                   onclick="completePseudoSelect({$one_search.id}, undefined, {$table_id})">{$one_value.text}</label>
                                                        </div>
                                                    {/foreach}
                                                    <input type="hidden"
                                                           value="{if $one_search.mult_text_value}{$one_search.mult_text_value}{/if}"
                                                           name="fix_search[{$one_search.id}][value][text_value]"
                                                           id="fix_search_mult{$one_search.id}"/>
                                                </div>
                                            </div>
                                        </div>

                                    {else}

                                        <select class="form-control form-control-250 m__fix-search--select" name="fix_search[{$one_search.id}][value]"
                                                {if !$table.fix_search_submit}onchange="document.getElementById('fix_search_form').submit()"{/if}>
                                            {$one_search.value}
                                        </select>
                                    {/if}
                                {elseif $one_search.type_field==5}
                                    <a href="#"
                                       class="item-link {if $one_search.type_field eq 5}m-cb-control-multi-link{/if}"
                                       data-table-id="{$table_id}" data-filter-id="{$filter_id}"
                                       data-line-id="{$line_id}" data-field-id="{$one_search.id}"
                                       data-s-table-id="{$one_search.s_table_id}"
                                       data-s-field-id="{$one_search.s_field_id}"
                                       {if $one_search.parent_link_field}fixed-search-parent-field="{$one_search.parent_link_field}"{/if}
                                       {if $one_search.child_link_field}fixed-search-child-field="{$one_search.child_link_field}"{/if}
                                       ac_value="{if !$one_search.fix_search_mult}{foreach from=$set_cond item=cond}{if $cond.field==$one_search.id}{$cond.value_link}{/if}{/foreach}{/if}"
                                       data-filter-value="{foreach from=$show_grp_fld item=temp_field}{if $one_search.parent_link_field==$temp_field.id}{if $temp_field['value']|is_array }{$temp_field['value']['raw']}{elseif $temp_field['value']!='{$lang.No_access}'}{$temp_field['value']}{/if}{/if}{/foreach}"
                                       data-csrf="{$csrf}"
                                       fix_search="1">
                                        {*<select ac_name="{if $one_search.fix_search_mult}select_link_mult{else}fix_search[{$one_search.id}][value]{/if}"
                                                {foreach from=$set_cond item=cond key=num}
                                                    {if $one_search.value == $cond.value}
                                                        first_link_init="{$cond.value_link}"
                                                    {/if}
                                                {/foreach}
                                                ac_value="{if !$one_search.fix_search_mult}{foreach from=$set_cond item=cond}{if $cond.field==$one_search.id}{$cond.value_link}{/if}{/foreach}{/if}"
                                                id="fix_search_{$one_search.id}"
                                                class="combobox {if $one_search.fix_search_mult}combobox--multiple{/if}"
                                                field_id="{$one_search.id}"
                                                {if $one_search.parent_link_field}fixed-search-parent-field="{$one_search.parent_link_field}"{/if}
                                                {if $one_search.child_link_field}fixed-search-child-field="{$one_search.child_link_field}"{/if}>
                                        </select>*}
                                        <div class="item-content">
                                            <div class="item-inner {if $one_search.type_field eq 5}ie_component_fuck{/if}">
                                                <div class="item-title label {if $one_search.main}supamida{/if}">
                                                    {if $lang.conf.{$one_search.name_field}}{$lang.conf.{$one_search.name_field}}{else}{$one_search.name_field}{/if}
                                                    {if $one_search.main}<span style="color: #f00"
                                                                              title="{$lang.required_field}">
                                                            *</span>{/if}
                                                </div>
                                                <div class="item-input">

                                                    {if $one_search.type_field eq 1 or $one_search.type_field eq 2 or $one_search.type_field eq 8 or $one_search.type_field eq 10 or $one_search.type_field eq 12 or ($one_search.type_field eq 3 and !($one_search.mult_value))}     {* число | дата | номер | текст одностр. *}
                                                        {if $one_search.Split_template_mask}
                                                            {$one_search.Split_template_mask}
                                                        {else}
                                                            {if $line_id!="array"}<input type="hidden"
                                                                                         {if $one_search.write}name="edit[{$line_id}][{$one_search.id}]"{/if}
                                                                                         value="1"/>{/if}

                                                            <input type="{if $one_search.type_field eq 2 or $one_search.type_field eq 12}{if $one_search.type_value==1}datetime-local{else}date{/if}{else}text{/if}"
                                                                   {if $one_search.write}name="value[{$line_id}][{$one_search.id}]"{/if}
                                                                   id="value{$one_search.id}"
                                                                   value="{$one_search.input}"
                                                                   field-type="{$one_search.type_field}"
                                                                   data-default="{$one_search.default_value}"
                                                                   class="valval {if $one_search.type_field eq 3}single_input{else}short_input{/if} {if $one_search.type_field eq 2 or $one_search.type_field eq 12}datepicker{/if} {if $one_search.action_yes}extra-ajax-field{/if}"
                                                                    {if $line_id=='array'}onChange="document.getElementById('edit{$one_search.id}').checked=1"{/if}
                                                                    {if $one_search.type_field eq 3 and !$one_search.mult_value and $one_search.template|count_characters gt 0} onkeypress="return check_txt({$one_search.id},event)" onClick="check_click({$one_search.id})" onFocus="check_click({$one_search.id})" onBlur="tmpl_clean_bg(this)" onInput="recheck_txt({$one_search.id})"{/if} >
                                                        {/if}

                                                        {if !$one_search.write}<input type="hidden"
                                                                                     class="valval"
                                                                                     name="value[{$line_id}][{$one_search.id}]"
                                                                                     id="value{$one_search.id}"
                                                                                     value="{$one_search.value}">{/if}
                                                    {elseif $one_search.type_field eq 3 and $one_search.mult_value}     {* текст многостр. *}

                                                        {if $line_id!="array"}<input type="hidden"
                                                                                     {if $one_search.write}name="edit[{$line_id}][{$one_search.id}]"{/if}
                                                                                     value="1"/>{/if}
                                                        <textarea
                                                                {if $one_search.write}name="value[{$line_id}][{$one_search.id}]"{/if}
                                                                            id="value{$one_search.id}" rows="10"
                                                                cols="20" {if $line_id=='array'}onChange="document.getElementById('edit{$one_search.id}').checked=1"{/if}
                                                                            class="valval {if $one_search.action_yes}extra-ajax-field{/if}">{$one_search.input}</textarea>
                                                        {if !$one_search.write}<input type="hidden"
                                                                                     class="valval"
                                                                                     name="value[{$line_id}][{$one_search.id}]"
                                                                                     id="value{$one_search.id}"
                                                                                     value="{$one_search.value}">{/if}
                                                    {elseif $one_search.type_field eq 4 or $one_search.type_field eq 7 or $one_search.type_field eq 11 or $one_search.type_field eq 13 or $one_search.type_field eq 14}     {* список | пользователь | группа *}
                                                        {if !$one_search.mult_value}
                                                            <select class="valval"
                                                                    {if $one_search.write}name="value[{$line_id}][{$one_search.id}]"{/if}
                                                                    id="value{$one_search.id}" {if $line_id=='array'}onChange="document.getElementById('edit{$one_search.id}').checked=1"{/if}>{$one_search.input}</select>
                                                            {if $line_id!="array"}<input type="hidden"
                                                                                         name="edit[{$line_id}][{$one_search.id}]"
                                                                                         value="1">{/if}

                                                            {if !$one_search.write}<input type="hidden"
                                                                                         class="valval"
                                                                                         name="value[{$one_search.table_id}][{$line_id}][{$one_search.id}]"
                                                                                         id="value{$one_search.id}"
                                                                                         value="{$one_search.value}">{/if}
                                                        {else}
                                                            {if $line_id!="array"}<input type="hidden"
                                                                                         name="edit[{$line_id}][{$one_search.id}]"
                                                                                         value="1">{/if}

                                                            <input type="hidden" id="value{$one_search.id}"
                                                                   value="{$one_search.value}">
                                                            {foreach from=$one_search.input item=one_value}
                                                                <input class="valval" type="checkbox"
                                                                       {if $one_search.write}name="value[{$line_id}][{$one_search.id}][]"{/if}
                                                                       value="{$one_value.list_value}"
                                                                       onClick="{if $line_id=='array'}document.getElementById('edit{$one_search.id}').checked=1;{/if} if (this.checked) document.getElementById('value{$one_search.id}').value++; else document.getElementById('value{$one_search.id}').value--; $('#value{$one_search.id}').change();" {if $one_value.checked}checked{/if} >
                                                                <span class="m_mult_value"{if !$one_search.write}style="color:#ACA899"{/if}>{$one_value.display_value}</span>
                                                                <br>
                                                                {if !$one_search.write and $one_value.checked}<input
                                                                    class="valval" type="hidden"
                                                                    name="value[{$line_id}][{$one_search.id}][]"
                                                                    id="value{$one_search.id}"
                                                                    value="{$one_value.list_value}">{/if}
                                                            {/foreach}
                                                        {/if}
                                                    {elseif $one_search.type_field eq 5}     {* связь *}
                                                        <span class="link_field_pretend_to_be_input m__fixed-search--link">
                                                            {if $one_search['value']|is_array }
                                                                {$one_search['value']['raw']}
                                                            {else}
                                                                {$one_search['value']}
                                                            {/if}
                                                        </span>
                                                        <input type="hidden"
                                                               name="fix_search[{$one_search.id}][value]"
                                                               id="fix_search_value{$one_search.id}"
                                                               table_id="{$table_id}"
                                                               field_id="{$one_search.id}"
                                                               class="valval value{$one_search.id} {if $one_search.action_yes}extra-ajax-field{/if}"
                                                               value="{if $one_search['value']|is_array }{$one_search['value']['raw']}{else}{$one_search['value']}{/if}"
                                                               {if $one_search['fix_search_mult']}mult_value="1"{/if}
                                                               onChange="setTimeout(() => deleteTrimAndBrackets(this), 10); {if $one_search.child_link_field}get_childos_filter({$one_search.child_link_field}, {$one_search.id});{/if}">
                                                        {* {if $one_search.parent_link_field}
                                                             <script>eval(get_childos_filter({$one_search.id}, {$one_search.parent_link_field}));</script>
                                                         {/if} *}
                                                        {if $line_id!="array"}<input type="hidden"
                                                                                     name="edit[{$one_search.id}][value]"
                                                                                     value="1">{/if}
                                                        {*
                                                        <input type="text" id="edit_value{$one_search.id}" value="{$one_search.display_edit}" class="input_edit_line" {if $one_search.write}onfocus="last_focus=this; this.nextSibling.className='drop_down_icon_hover';$(this).addClass('input_edit_line_hover');" onblur="last_focus=0; if (this.nextSibling!=under_mouse_object) {ldelim}this.nextSibling.className='drop_down_icon'; $(this).removeClass('input_edit_line_hover');{rdelim}" onmouseover="this.nextSibling.className='drop_down_icon_hover';$(this).addClass('input_edit_line_hover');" onmouseout="if (this!=last_focus) {ldelim}this.nextSibling.className='drop_down_icon';$(this).removeClass('input_edit_line_hover');{rdelim}"{/if}><span
                                                        {if $one_search.write}class="drop_down_icon" onmouseover="under_mouse_object=this;$(this.previousSibling).addClass('input_edit_line_hover');this.className='drop_down_icon_hover';" onmouseout="under_mouse_object=0; if (this.previousSibling!=last_focus) {ldelim}this.className='drop_down_icon'; $(this.previousSibling).removeClass('input_edit_line_hover');{rdelim}" onclick="{if $one_search.write}this.blur();this.previousSibling.focus();$(this.previousSibling).show_search();{/if}return false;" onmousedown="$(this.previousSibling).prevent_blur();return false;" onmouseup="$(this.previousSibling).enable_blur();" ondragstart="event.returnValue=!1;"{else}class="drop_down_icon_disabled"{/if}></span>
                                                        {if $one_search.add_acc_link_value}
                                                          <img src="images/green_plus.png" title="{$one_search.add_link_text}" class="add_link_img" onclick="add_link_block_show({$one_search.id})" onmouseover="this.src='images/green_plus_active.png'" onmouseout="this.src='images/green_plus.png'" style="width:1.3em; height:1.5em;">
                                                        {/if}
                                                        *}
                                                    {elseif $one_search.type_field eq 6}     {* файл *}
                                                        {foreach from=$one_search.input item=file}
                                                            <a href="open_file.php?table={$table_id}&field={$one_search.id}&line={$line_id}&file={$file.url}"
                                                               onclick="location.href='open_file.php?table={$table_id}&field={$one_search.id}&line={$line_id}&file={$file.url}'; return false;">{$file.name}</a>
                                                            {if $one_search.write}<a href="" class="red_link"
                                                                                    onclick="delfile({$one_search.id},'{$file.js}'); return false;">{$lang.Delete}</a>{/if}
                                                            <br>
                                                        {/foreach}
                                                        <input type=hidden class="valval"
                                                               name="value[{$line_id}][{$one_search.id}]"
                                                               id="value{$one_search.id}"
                                                               value="{$one_search.value}">
                                                        {if $one_search.write}
                                                            <input type=hidden
                                                                   name="del_file[{$line_id}][{$one_search.id}]"
                                                                   id="del_file{$one_search.id}">
                                                            <input type=file
                                                                   onchange="checkFileValue(this)"
                                                                   name="add_file[{$line_id}][{$one_search.id}][]"
                                                                   id="add_file{$one_search.id}" size="20"
                                                                   multiple="multiple">
                                                            <input type=button onClick="addfile()"
                                                                   disabled
                                                                   value="{$lang.Add}" title="{$lang.Add_file}">
                                                            {if $one_search.type_value}
                                                                <br>{/if}{if $one_search.max_size}{$one_search.max_size} kB{/if} {foreach from=$one_search.file_types item=ext name=ft}{$ext}{if $smarty.foreach.ft.last}{else},{/if}{/foreach}
                                                        {/if}
                                                    {elseif $one_search.type_field eq 9}     {* изображение *}
                                                        {foreach from=$one_search.input item=file}
                                                            <a href="open_file.php?field={$one_search.id}&line={$line_id}&file={$file.url}&is_show=1"
                                                               onclick="location.href='open_file.php?field={$one_search.id}&line={$line_id}&file={$file.url}&is_show=1'; return false">
                                                                <img src="cache/{$table_id}_{$one_search.id}_{$line_id}_{$file.file}.png">
                                                            </a>
                                                            {if $one_search.write}<a href="" class="red_link"
                                                                                    onclick="delfile({$one_search.id},'{$file.js}'); return false;">{$lang.Delete}</a>{/if}
                                                            <br>
                                                        {/foreach}
                                                        <input type=hidden class="valval"
                                                               name="value[{$line_id}][{$one_search.id}]"
                                                               id="value{$one_search.id}"
                                                               value="{$one_search.value}">
                                                        {if $one_search.write}
                                                            <input type=hidden
                                                                   name="del_file[{$line_id}][{$one_search.id}]"
                                                                   id="del_file{$one_search.id}"
                                                                   class="del_file{$one_search.id}">
                                                            <input type=file
                                                                   name="add_file[{$line_id}][{$one_search.id}][]"
                                                                   id="add_file{$one_search.id}"
                                                                   class="add_file{$one_search.id}" size="20"
                                                                   multiple="multiple">
                                                            <!--<input type=button onClick="addfile({$one_search.id})" value="{$lang.Add}" title="{$lang.Add_image}">
                            {if $one_search.max_size}<br>{$one_search.max_size} kB{/if}-->
                                                        {/if}
                                                    {/if}

                                                </div>
                                            </div>
                                        </div>
                                    </a>
                                    {if $one_search.fix_search_mult}
                                        <div class="pseudo_select_options mult_select_link"
                                             id="pseudo_select_options{$one_search.id}"
                                             onclick="event.cancelbubble=true">
                                            <div class="pseudo_select_option__wrap">
                                                {foreach from=$one_search.mult_text_value key=link_line_id item=link_line_text}
                                                    <div class="pseudo_select__wrap">
                                                        <input type="checkbox" name="fix_search[{$one_search.id}][value][]" checked
                                                               value="{$link_line_text}"
                                                               id="fix_search_ch{$one_search.id}_{$link_line_text}"
                                                               onclick="completePseudoSelect({$one_search.id}, 1, {$table_id}); event.cancelBubble=true"/>
                                                        <label for="fix_search_ch{$one_search.id}_{$link_line_text}"
                                                               onclick="completePseudoSelect({$one_search.id}, 1, {$table_id}); event.cancelBubble=true">
                                                            {$link_line_text}
                                                            <input type="hidden"
                                                                   name="fix_search[{$one_search.id}][value_link][]"
                                                                   value="{$link_line_id}"/>
                                                        </label>
                                                    </div>
                                                {/foreach}
                                            </div>
                                        </div><input type="hidden"
                                                     value="{if $one_search.mult_text_value}{$one_search.mult_text_value}{/if}"
                                                     name="fix_search[{$one_search.id}][value][text_value]"
                                                     id="fix_search_mult{$one_search.id}" />
                                    {/if}</span>
                                    <input type=hidden id="fix_search_{$one_search.id}_link_value"
                                           value="{if !$one_search.fix_search_mult}{foreach from=$set_cond item=cond}{if $cond.field==$one_search.id}{$cond.value_link}{/if}{/foreach}{/if}"
                                           onchange="{if $one_search.fix_search_mult}addSelectVal({$one_search.id});{elseif !$table.fix_search_submit}document.getElementById('fix_search_form').submit();{else}if (document.getElementById('fix_search_{$one_search.child_link_field}')) document.getElementById('fix_search_{$one_search.child_link_field}').value='';{/if}">

                                    {if $one_search.fix_search_mult}
                                        <span id="mult_link_count{$one_search.id}" class="mult_link_count"
                                              onclick="viewPseudoSelectOptions({$one_search.id}); event.cancelBubble=true">{if $one_search.mult_link_count}+{$one_search.mult_link_count}{/if}</span>
                                    {/if}
                                {/if}
                            </div>
                        {/foreach}
                        {if $table.fix_search_submit}
                            <a class="default-btn fields__search-btn fields__template-btn" href=""
                               onclick="document.getElementById('fix_search_form').submit(); return false;">{$lang.Apply}</a>
                        {/if}
                    </div>
                </form>
            {/if}
                <form
                        action="fields.php?table={$table_id}{if $rel_table}&rel_table={$rel_table}&rel_line={$rel_line}&rel_field={$rel_field}{/if}{if $all_filters_on}&all_filters_on{elseif $filter_id}&filter={$filter_id}{/if}{if $archive}&archive{/if}{if $deleted}&deleted{/if}{if $page}&page={$page}{/if}&csrf={$csrf}"
                        class="sel_records ajax-submit" method="POST" id="sel_records">
                    <input type="submit" class="ajax-submit-button" style="display: none;"/>
                    <input type="hidden" name="op_sel" class="op_sel" id="op_sel">
                    <input type="hidden" name="form_sel" class="form_sel" id="form_sel">
                    <input type="hidden" name="form_type" class="form_type" id="form_type">
                    <input type="hidden" name="csrf" value="{$csrf}">
                    <input type="hidden" name="button_id" class="button_id" value="-1">

                    <div class="m-cb-fields list-block media-list">
                        <ul>
                            {foreach from=$all_values item=one_line}
                                {if $one_line[0].group_field_pp}
                                    <li class="m-fields-group">
                                        {$one_line[0].group_field_text}
                                    </li>
                                {/if}
                                <li {*class="swipeout"*}>
                                    {counter start=0 skip=1 assign='num_val'}

                                    <a class="item-link item-content {*swipeout-content*}"
                                       style=" background: {if $one_line.0.bg_color}{$one_line.0.bg_color}{/if}"
                                       href="view_line{$config.vlm}.php?table={$table_id}{if $rel_table}&rel_table={$rel_table}&rel_line={$rel_line}&rel_field={$rel_field}{/if}{if $all_filters_on}&all_filters_on{elseif $filter_id}&filter={$filter_id}{/if}{if $archive}&archive{/if}{if $deleted}&deleted{/if}{if $page}&page={$page}{/if}&line={$one_line.0.line_id}{if $base64_current_url}&back_url={$base64_current_url}{/if}">
                                        <div class="item-inner" style="">
                                            {foreach from=$one_line item=one_value}
                                                {if $show_fields[$one_value.field_id].hidden_tbl==0 and $show_fields[$one_value.field_id].group_field==0 and $one_value.type_field != 9}
                                                    {if $num_val == 1}
                                                      <div class="item-title-row" style="{if $one_value.bg_color}background-color:{$one_value.bg_color};{/if}{if $one_value.font_color}color:{$one_value.font_color};{/if}padding: 10px 0 10px 5px;">
                                                      <div class="item-title" style="{if $one_value.txt_color}background-color:{$one_value.txt_color};border-radius: 5px;{/if}
                                                      {if $one_value.font_style[0] == '1'}font-weight: bold;{/if}
                                                      {if $one_value.font_style[1] == '1'}font-style: italic;{/if}
                                                      {if $one_value.font_style[2] == '1'}text-decoration: underline{if $one_value.font_style[3] == '1'} line-through;{else};{/if}{/if}">
                                                                    {if $one_value.type_field == 6}
                                                                            <object>
                                                                                <a href="open_file.php?table={$table_id}&field={$one_value.field_id}&line={$one_value.line_id}&file={$one_value.value}"
                                                                                    onclick="location.href='open_file.php?table={$table_id}&field={$one_value.field_id}&line={$one_value.line_id}&file={$one_value.value}'; return false;">{$one_value.value}</a>
                                                                            </object>
                                                                    {else}
                                                                        {if $one_value.type_field == 5}
                                                                            {$one_value.value|strip_tags}
                                                                        {else}
                                                                            {if $show_fields[$one_value.field_id].hyperlink == 1 and $one_value.value}
                                                                                {* Для гиперссылок добавляем тег object, иначе верстка будет съезжать, т.к. пытаемся отобразить ссылку в ссылке *}
                                                                                <object>{$one_value.value}</object>
                                                                            {else}
                                                                                {$one_value.value|truncate:70:"...":true}
                                                                            {/if}
                                                                        {/if}
                                                                    {/if}
                                                            </div>
                                                        </div>
                                                    {/if}
                                                    {if $num_val == 2}
                                                      <div class="item-subtitle" style="{if $one_value.bg_color}background-color:{$one_value.bg_color};{/if}{if $one_value.font_color} color:{$one_value.font_color};{/if} padding: 10px 0 10px 5px;">
                                                      <span style="display: inline-block; padding: 5px 15px;{if $one_value.txt_color} background-color:{$one_value.txt_color}; border-radius: 5px;{/if}
                                                      {if $one_value.font_style[0] == '1'}font-weight: bold;{/if}
                                                      {if $one_value.font_style[1] == '1'}font-style: italic;{/if}
                                                      {if $one_value.font_style[2] == '1'}text-decoration: underline{if $one_value.font_style[3] == '1'} line-through;{else};{/if}{/if}">
                                                                {if $one_value.type_field == 5}
                                                                    {$one_value.value|strip_tags}
                                                                {else}
                                                                    {if $one_value.type_field == 6}
                                                                        <object>
                                                                            <a href="open_file.php?table={$table_id}&field={$one_value.field_id}&line={$one_value.line_id}&file={$one_value.value}"
                                                                                onclick="location.href='open_file.php?table={$table_id}&field={$one_value.field_id}&line={$one_value.line_id}&file={$one_value.value}'; return false;">{$one_value.value}</a>
                                                                        </object>
                                                                    {else}
                                                                        {if $show_fields[$one_value.field_id].hyperlink == 1 and $one_value.value}
                                                                            {* Для гиперссылок добавляем тег object, иначе верстка будет съезжать, т.к. пытаемся отобразить ссылку в ссылке *}
                                                                            <object>{$one_value.value}</object>
                                                                        {else}
                                                                            {if $one_value.is_html eq 1}
                                                                                <object>
                                                                                    {$one_value.open_tag}
                                                                                        {$one_value.value|truncate:70:"...":true}
                                                                                    {$one_value.close_tag}
                                                                                </object>
                                                                            {else}
                                                                                {$one_value.value|truncate:70:"...":true}
                                                                            {/if}
                                                                        {/if}
                                                                    {/if}
                                                                {/if}
                                                            </span>
                                                        </div>
                                                    {/if}
                                                    {if $num_val == 3}
                                                      <div class="item-subtitle" style="{if $one_value.bg_color}background-color:{$one_value.bg_color};{/if}{if $one_value.font_color} color:{$one_value.font_color};{/if} padding: 10px 0 10px 5px;">
                                                      <span style="display: inline-block; padding: 5px 15px;{if $one_value.txt_color} background-color:{$one_value.txt_color}; border-radius: 5px;{/if}
                                                      {if $one_value.font_style[0] == '1'}font-weight: bold;{/if}
                                                      {if $one_value.font_style[1] == '1'}font-style: italic;{/if}
                                                      {if $one_value.font_style[2] == '1'}text-decoration: underline{if $one_value.font_style[3] == '1'} line-through;{else};{/if}{elseif $one_value.font_style[3] == '1'}text-decoration: line-through;{/if}">
                                                                {if $one_value.type_field == 6}
                                                                        <object>
                                                                            <a href="open_file.php?table={$table_id}&field={$one_value.field_id}&line={$one_value.line_id}&file={$one_value.value}"
                                                                                onclick="location.href='open_file.php?table={$table_id}&field={$one_value.field_id}&line={$one_value.line_id}&file={$one_value.value}'; return false;">{$one_value.value}</a>
                                                                        </object>
                                                                {else}
                                                                    {if $show_fields[$one_value.field_id].hyperlink == 1 and $one_value.value}
                                                                        {* Для гиперссылок добавляем тег object, иначе верстка будет съезжать, т.к. пытаемся отобразить ссылку в ссылке *}
                                                                        <object>{$one_value.value}</object>
                                                                    {else}
                                                                        {if $one_value.is_html eq 1}
                                                                            <object>
                                                                                {$one_value.open_tag}
                                                                                    {$one_value.value|truncate:70:"...":true}
                                                                                {$one_value.close_tag}
                                                                            </object>
                                                                        {else}
                                                                            {$one_value.value|truncate:70:"...":true}
                                                                        {/if}
                                                                    {/if}
                                                                {/if}
                                                            </span>
                                                        </div>
                                                    {/if}

                                                    {counter assign='num_val'}
                                                {/if}
                                            {/foreach}
                                        </div>
                                    </a>
                                    {counter start=0 skip=1 assign='num_val'}
                                    <label class="label-checkbox item-content" style="display: none;">
                                        <input type="checkbox" name="sel[]" id="sel{$one_line.0.line_id}"
                                               value="{$one_line.0.line_id}"
                                               title="{$lang.Mark}">

                                        <div class="item-media"><i class="icon icon-form-checkbox"></i></div>
                                        <div class="item-inner">
                                            {foreach from=$one_line item=one_value}
                                                {if $show_fields[$one_value.field_id].hidden_tbl==0 and $show_fields[$one_value.field_id].group_field==0 and $one_value.type_field != 9}
                                                    {if $num_val == 1}
                                                        <div class="item-title-row"
                                                             style="background-color:{if $one_line.0.bg_color}{$one_line.0.bg_color}{/if}{if $one_value.bg_color}{$one_value.bg_color}{/if}; color:{if $one_value.font_color}{$one_value.font_color}{/if}; {if $one_value.font_style}{$one_value.font_style}{/if}">
                                                            <div class="item-title">
                                                                {if $one_value.type_field == 5}
                                                                    {$one_value.value}
                                                                {else}
                                                                    {$one_value.value|truncate:70:"...":true}
                                                                {/if}
                                                            </div>
                                                        </div>
                                                    {/if}
                                                    {if $num_val == 2}
                                                        <div class="item-subtitle"
                                                             style="background-color:{if $one_line.0.bg_color}{$one_line.0.bg_color}{/if}{if $one_value.bg_color}{$one_value.bg_color}{/if};; color:{if $one_value.font_color}{$one_value.font_color}{/if};{if $one_value.font_style}{$one_value.font_style}{/if}">
                                                            <span>
                                                                {if $one_value.type_field == 5}
                                                                    {$one_value.value}
                                                                {else}
                                                                    {$one_value.value|truncate:70:"...":true}
                                                                {/if}
                                                            </span>
                                                        </div>
                                                    {/if}
                                                    {if $num_val == 3}
                                                        <div class="item-subtitle"
                                                             style="background-color:{if $one_line.0.bg_color}{$one_line.0.bg_color}{/if}{if $one_value.bg_color}{$one_value.bg_color}{/if};; color:{if $one_value.font_color}{$one_value.font_color}{/if};{if $one_value.font_style}{$one_value.font_style}{/if}">
                                                            <span>
                                                                {$one_value.value|strip_tags}
                                                            </span>
                                                        </div>
                                                    {/if}
                                                    {counter assign='num_val'}
                                                {/if}
                                            {/foreach}
                                            <input type=hidden id="bg{$one_line.0.line_id}"
                                                   value="{if $one_line.0.bg_color}{$one_line.0.bg_color}{else}#ffffff{/if}">
                                        </div>
                                    </label>
                                </li>
                            {/foreach}
                        </ul>
                        <div class="list-block-label">
                            {if $search_text}
                                {$lang.Found_lines}: {$cnt_line}
                                <!--{if $cnt_line!=$cnt_rec} {$lang.lines_from} {$cnt_rec}{/if} --> &nbsp;
                            {else}
                                {if $cnt_line}
                                    {$lang.Total_lines}:&nbsp;{$cnt_line}{if $cnt_line!=$total_rec} {$lang.lines_from} {$total_rec}{/if}
                                    <!-- {if $cnt_line!=$cnt_rec} {$lang.lines_from} {$cnt_rec}{/if} -->
                                {else}
                                    {$lang.No_lines}
                                {/if}
                            {/if}
                            {if $unique}
                                <br/>
                                {$lang.show_dublicate_mode} <a href="#"
                                                               onclick="mainView.goBack();return false;">{$lang.return_to_edit_line}</a>{/if}
                        </div>
                    </div>

                    {if $all_pages}
                        <div class="content-block" style="text-align:center;font-size: 16px;">
                            {if $all_pages|@count<6}
                                <p class="buttons-row" style="margin-bottom: 100px;">
                                    {foreach from=$all_pages item=one_page}
                                        {if $one_page eq $page}
                                            <span class="button" style="color:gray;">{$one_page}</span>
                                        {else}
                                            <a class="button"
                                               href="fields.php?table={$table_id}{if $rel_table}&rel_table={$rel_table}&rel_line={$rel_line}&rel_field={$rel_field}{/if}{if $all_filters_on}&all_filters_on{elseif $filter_id}&filter={$filter_id}{/if}{if $archive}&archive{/if}{if $deleted}&deleted{/if}&page={$one_page}">{$one_page}</a>
                                        {/if}
                                    {/foreach}
                                </p>
                            {else}
                                {foreach from=$all_pages item=one_page}
                                    {if $one_page eq $page}
                                        <span>{$one_page}</span>
                                    {else}
                                        <a href="fields.php?table={$table_id}{if $rel_table}&rel_table={$rel_table}&rel_line={$rel_line}&rel_field={$rel_field}{/if}{if $all_filters_on}&all_filters_on{elseif $filter_id}&filter={$filter_id}{/if}{if $archive}&archive{/if}{if $deleted}&deleted{/if}&page={$one_page}">{$one_page}</a>
                                    {/if}
                                {/foreach}
                            {/if}
                        </div>
                    {/if}

                    <div class="content-block">
                      <p class="buttons-row" style="margin-bottom: 100px;">
                        <a
                          class="button {if !$archive && !$deleted && !$all_records}active{/if}"
                          href="fields.php?table={$table_id}{if $rel_table}&rel_table={$rel_table}&rel_line={$rel_line}&rel_field={$rel_field}{/if}{if $all_filters_on}&all_filters_on{elseif $filter_id}&filter={$filter_id}{/if}"
                        >{$lang.active}</a>

                        <a
                          class="button {if $archive}active{/if}"
                          href="fields.php?table={$table_id}{if $rel_table}&rel_table={$rel_table}&rel_line={$rel_line}&rel_field={$rel_field}{/if}{if $all_filters_on}&all_filters_on{elseif $filter_id}&filter={$filter_id}{/if}&archive"
                        >{$lang.archive}</a>

                        <a
                          class="button {if $deleted}active{/if}"
                          href="fields.php?table={$table_id}{if $rel_table}&rel_table={$rel_table}&rel_line={$rel_line}&rel_field={$rel_field}{/if}{if $all_filters_on}&all_filters_on{elseif $filter_id}&filter={$filter_id}{/if}&deleted"
                        >{$lang.deleted}</a>

                        <a
                          class="button {if $all_records}active{/if}"
                          href="fields.php?table={$table_id}{if $rel_table}&rel_table={$rel_table}&rel_line={$rel_line}&rel_field={$rel_field}{/if}{if $all_filters_on}&all_filters_on{elseif $filter_id}&filter={$filter_id}{/if}&all"
                        >{$lang.all}</a>
                      </p>
                    </div>
                </form>
            {/if}
            <input type="hidden" class="page_to_back" value="{$cur_cat}"/>
            <input type="hidden" class="page_to_back_table" value="{if $rel_table}{$rel_table}{/if}"/>
            <input type="hidden" class="page_to_back_line" value="{if $rel_line}{$rel_line}{/if}"/>

            {include file="mobile/templates/footer.tpl" set_bt=1}
