<?php
include_once('c_poll_theme_card.php');
class c_page_cab_poll_theme_card_sections extends c_page_cab_poll_theme_card
{
    public $h1='Опрос - карточка раздела - подразделы';

    function block_main()
    {
        $this->page_title() ;
        $this->panel_poll_theme_sections() ;
    }

    function panel_poll_theme_sections()
    {
        $recs_subsections=[];
        $recs=execSQL('select t1.*
                       from view_poll_themes t1
                       where t1.parent='.$this->rec_section['pkey'].' and t1.clss=572');
        if (_sizeof($recs)) $recs_subsections=execSQL('select pkey,tkey,obj_name,parent,clss from view_poll_themes where parent in ('.implode(',',array_keys($recs)).') and clss=572') ;
        $recs_subsections_by_sections=group_by_field('parent',$recs_subsections) ;


        ?>
        <div id="panel_filter" class="full">
        <form id="sky-form" class="sky-form">
            <div id="panel_buttons">
                <button class="button v2" cmd="poll/get_panel_section_create" parent_id="<? echo $this->rec_section['pkey'] ?>">Добавить подраздел</button>
                <?if (_sizeof($recs)){?>
                <button class="button v2" cmd="poll/get_panel_section_move" section_id="<? echo $this->rec_section['pkey'] ?>">Переместить подраздел</button>
                <button class="button v2" cmd="poll/get_panel_section_delete" section_id="<? echo $this->rec_section['pkey'] ?>">Удалить подраздел</button>
                <?}?>
            </div>

        <table class="basic fz_small full auto">
            <tr>
                <th style="width:50px;">Выбор</th>
                <th style="width:50px;">ID</th>
                <!--<th style="width:100px;">Число билетов</th>-->
                <th>Наименование подраздела</th>
                <th style="width:700px;">Отбор сотрудников</th>
            </tr><?
            foreach($recs as $rec)
            {   ?>
                <tr>
                <td><input type="checkbox" name="_check[]" value="<? echo $rec['pkey'] ?>"></td>
                <td><? echo $rec['pkey'] ?></td>
                <!--<td><? echo $rec['cnt_tikets'] ?></td>-->
                <td class="left"><strong><a class="v1" href="/frame/poll/theme/card/<?echo $rec['pkey']?>/append/"><? echo $rec['obj_name'] ?></a></strong></td>
                <td class="left"><? PERSONALS_FILTER()->get_personals_filter_info_to_item($rec['_reffer']) ;?></td>
                </tr><?
                if (_sizeof($recs_subsections_by_sections[$rec['pkey']])) foreach($recs_subsections_by_sections[$rec['pkey']] as $rec_subsection)
                {   $icon='' ;
                    switch($rec_subsection['clss'])
                    { case 481: $icon='<i class="far fa-bookmark"></i>' ; break ;
                      case 572: $icon='<i class="fas fa-folder-open"></i>' ; break ;
                    }
                    ?>
                        <tr>
                        <td></td>
                        <!--<td><? echo $rec_subsection['pkey'] ?></td>
                        <td><? echo $rec_subsection['cnt_tikets'] ?></td>-->
                        <td class="left"><?echo $icon?><a style="color:gray;" class="v1" href="/frame/poll/theme/card/<?echo $rec_subsection['pkey']?>/"><? echo $rec_subsection['obj_name'] ?></a></td>
                        <td class="left"><? echo $rec_subsection['info_filter'] ?></td>
                        </tr>
                    <?
                }
            }
            ?></table>
        </form></div>
        <?
    }

}

?>
