<?php
include_once(_DIR_TO_CLASS.'/c_page.php') ;
include_once(_DIR_EXT.'/aspmo_sv/i_sv.php');

class c_page_cab_sv extends c_page
{
    public $rec_SV ;
    public $h1='Сравнение подписей' ;

    function set_head_tags()
    {
        parent::set_head_tags() ;
        $this->HEAD['css'][]='/'._CLASS_.'/ext/aspmo_sv/style.css' ;
        $this->HEAD['js'][]='/'._CLASS_.'/ext/aspmo_sv/script.js' ;
    }

    function select_obj_info()
    {
        if (_CUR_ID)
        {
            $this->rec_SV =SV()->get_SV_by_id(_CUR_ID);
            if ($this->rec_SV['pkey'])
            {
                //$this->rec_personal = PERSONAL()->get_personal_by_id($this->rec_SV['personal_id']);
                $this->h1 = 'Сравнение подписей';
                $this->page_type = 'window';
            }
            else {
                $this->result = 404;
            }
        }
    }

    function menu_config()
    {
        if (!_CUR_ID) {
            parent::menu_config() ;
        }
    }

    function block_main()
    {
        $this->page_title() ;
        include_once(_DIR_EXT.'/aspmo_sv/panel_view_sv.php');
        if ($this->rec_SV['pkey']) {
            panel_view_sv($this->rec_SV);
        }
        else {
            $this->panel_list_sv();
        }
    }

    function panel_list_sv()
    {  include_once(_DIR_EXT.'/aspmo_sv/report_personals_sign.php') ;
       $report_obj=new report_personals_sign() ;
       $report_obj->setting() ;
       //$report_obj->filter['reffer']=$this->rec_personal['_reffer'];
       //$report_obj->filter['user_id']=$this->rec_personal['pkey'];
       //$report_obj->filter['order']='pkey';
       $report_obj->view_as_HTML() ;
       return ;


        //$stats=execSQL_van('select min(c_data) as time_from,max(c_data) as time_to,count(pkey) as cnt from '.$this->table_mo_sessions.' t1 where '.$usl)  ;

        $recs_park=execSQL('select * from obj_site_personals where clss=208 and enabled=1 order by obj_name') ;
              ?><div id=panel_search_member>
                      <form><span class="title">ПОИСК:</span> <input type="text" name="search_text" data-required size=50 id="personal_name" SetAutoComplete cmd="autocomplette_personal_name"><input type="submit" class="v2 fa fa-search" cmd="aspmo_sv/search_personal" value="Искать" validate="form">&nbsp;&nbsp;&nbsp;
                          <span class="title">ОРГАНИЗАЦИЯ:</span> <select name="filter_park" class="v2" cmd="aspmo_personal/set_filter_park"><option value="-1"></option>
                                  <? if (_sizeof($recs_park)) foreach($recs_park as $rec_park) {?><option value="<?echo $rec_park['pkey']?>" <?if ($_SESSION['list_members_filter_park']==$rec_park['pkey']) echo 'selected'?>><?echo $rec_park['obj_name']?></option><?}?>
                      </select>&nbsp;&nbsp;&nbsp;

                      <span class="title">СОРТИРОВКА:</span> <select name="sort_mode" class="v2" cmd="aspmo_personal/change_personal_sort">
                              <option value="pers.obj_name" <?if ($_SESSION['sv_list_members_sort_mode']=='pers.obj_name') echo 'selected'?>>По имени</option>
                              <option value="pers.age" <?if ($_SESSION['sv_list_members_sort_mode']=='pers.age') echo 'selected'?>>По возрасту (возрастание)</option>
                              <option value="pers.age desc" <?if ($_SESSION['sv_list_members_sort_mode']=='pers.age desc') echo 'selected'?>>По возрасту (убывание)</option>
                              <option value="mo_count" <?if ($_SESSION['sv_list_members_sort_mode']=='mo_count') echo 'selected'?>>По кол-ву МО (возрастание)</option>
                              <option value="mo_count desc" <?if ($_SESSION['sv_list_members_sort_mode']=='mo_count desc') echo 'selected'?>>По кол-ву МО (убывание)</option>
                              <option value="has_standart_sign desc" <?if ($_SESSION['sv_list_members_sort_mode']=='has_standart_sign') echo 'selected'?>>По эталону</option>
                          </select>
                          <input type="submit" class="v2 fa fa-sort-amount-asc" cmd="aspmo_sv/change_personal_sort" value="Применить">

                      </form><div class="clear"></div>
               </div><br><br><?

        //$recs_personal=execSQL_row('select DISTINCT(personal_id) from obj_site_narko_data where clss=300 group by personal_id order by c_data desc',2) ;
        ?><div id="panel_list_recs"><?
        //$now=getdate(time()) ;
        //$options['time_from']=mktime($now['hours']-24,$now['minutes'],0,$now['mon'],$now['mday'],$now['year']);
        //$recs_personal=execSQL_row('select personal_id,count(pkey) from obj_site_narko_data where clss=300 and c_data>='.$options['time_from'].' group by personal_id order by c_data desc',0) ;
        $order = 'mos.c_data desc';
        if (isset($_SESSION['sv_list_members_sort_mode'])) {
            $order = $_SESSION['sv_list_members_sort_mode'];
        }
        $recs_personal=execSQL_row('select mos.member_id,count(mos.pkey) as mo_count, if (pers.sign_id > 0, 1, 0) as has_standart_sign from obj_site_mo_session as mos '
                                    . 'inner join obj_site_mo_session_DTW as mos_DTW on mos_DTW.parent = mos.pkey '
                                    . 'inner join obj_site_personals as pers on pers.pkey = mos.member_id '
                                    . 'where 1 group by mos.member_id order by ' . $order,0);
        include_once('panel_list_rec_signature_verification.php') ;
        panel_list_rec_signature_verification($recs_personal) ;
        ?></div><?
        //damp_array($rec_personal) ;
    }
}

?>
