<?
include_once(_DIR_EXT.'/HTML/c_page_XML_AJAX.php') ;
class c_page_ajax extends c_page_XML_AJAX
{

    function sv_calculate_number_of_points() {
        signature()->recalculate_number_of_points();
        $this->add_element('update_page',1) ;
    }

  function set_standart()
    {
        if (_sizeof($_POST['use_standart'])) {
       PERSONAL()->set_personal_sign($_POST['personal_id'], $_POST['use_standart']);
       signature()->recalculate_signatures($_POST['personal_id'], $_POST['use_standart']);
       $this->add_element('update_page',1) ;
        } else  {
            $this->add_element('show_notife','Не выбрана запись') ;
  }
  }

    function change_personal_sort()
  {
        $_SESSION['sv_list_members_sort_mode']=$_POST['sort_mode'] ;
        $this->add_element('show_notife','Сортировка изменена',array('type'=>'info')) ;
     $this->add_element('update_page',1) ;
  }

  function draw_preview()
    {
        ob_start() ;
        ?><div class="draw_preview">
            <table>
                <tr class="draw_preview_tr">
                    <td class="draw_preview_td"><?
                        if ($_POST['st_id']) {?>
                        <div>Эталонная подпись</div>
                        <img src="/services/esmo_signature/graf_signature/?mo_id=<?echo $_POST['st_id']?>" width="300" height="200" /><?} else {?>
                        <div class="sign_not_exist" width="300">
                            <div>
                            Эталонная подпись не назначена
                            </div>
                        </div><?}?>
                    </td>
                    <td class="draw_preview_td"><?if ($_POST['sv_id']) {?>
                        <div>Текущая подпись</div>
                        <img src="/services/esmo_signature/graf_signature/?mo_id=<?echo $_POST['sv_id']?>" width="300" height="200" /><?} else {?>
                        <div class="sign_not_exist" width="300">
                            <div>
                            Подпись не выбрана
                            </div>
                        </div>
                        <?}?>
                    </td>
                </tr>
            </table>
       </div><?

    $this->add_element('panel_preview_'.$_POST['sv_id'].'.HTML',ob_get_clean()) ;
  }

  function save_comment()
    {
        //damp_array($_POST,1,-1) ;
    //update_rec_in_table('obj_site_narko_data',array('comment'=>$_POST['value']),'pkey='.$_POST['pp_id'],array('debug'=>0)) ;
    $this->add_element('show_notife','Сохранено') ;
    //$this->add_element('show_modal_window','HTML') ;
  }

 function search_personal()
    {
    if ($_POST['search_text'])
        {
            $members_ids=PERSONAL()->search_personal_ids($_POST['search_text']) ;
      if (!_sizeof($members_ids)) $this->add_element('show_notife','Ничего не найдено',array('type'=>'info')) ;
    }
    //elseif (_sizeof($members_ids)==1) $this->add_element('go_url','/cab/personal/'.$members_ids[0].'.html') ;
    //else
        {
            ob_start() ;

      $_usl=array('clss=300') ;
      if ($members_ids) $_usl[]='personal_id in ('.implode(',',$members_ids).')' ;
      $usl=implode(' and ',$_usl) ;
      $recs_personal=execSQL_row('select personal_id,count(pkey) from obj_site_narko_data where '.$usl.' group by personal_id order by c_data desc') ;
      //if ($_SESSION['list_members_filter_park']) $_usl[]='parent='.$_SESSION['list_members_filter_park'] ;

      //PERSONAL()->show_list_items($usl,'aspmo_personal/list_personal_table_img',array('debug'=>0,'panel_select_pages'=>1,'order'=>$_SESSION['list_members_sort_mode'],'pages_base_url'=>'/cab/personal/')) ;
      include_once('panel_list_rec_signature_verification.php') ;
      panel_list_rec_signature_verification($recs_personal) ;
      $this->add_element('panel_list_recs.HTML',ob_get_clean()) ;
      $this->add_element('show_notife','Найдено '._sizeof($recs_personal).' сотрудников',array('type'=>'info')) ;
    }
 }

    function sv_journal_apply_filter()
    {
        $options['text_info']=$_POST['name'];
   $options['time_from']=$_POST['time_from'] ;
   $options['time_to']=$_POST['time_to'] ;
   $options['terminal_id']=$_POST['terminal'] ;
        $options['has_standart']=$_POST['has_standart'];
        $options['valid']=$_POST['valid'];

        $options['point_count_from'] = $_POST['point_count_from'];
        $options['point_count_to'] = $_POST['point_count_to'];
        $options['time_sign_from'] = $_POST['time_sign_from'];
        $options['time_sign_to'] = $_POST['time_sign_to'];
        $options['point_per_sec_from'] = $_POST['point_per_sec_from'];
        $options['point_per_sec_to'] = $_POST['point_per_sec_to'];
        $options['valid']=$_POST['valid'];

        $options['time_deviation_from'] = $_POST['time_deviation_from'];
        $options['time_deviation_to'] = $_POST['time_deviation_to'];

        $_SESSION['sv_journal_members_sort_mode']=$_POST['sort_mode'] ;
        include_once('panel_sv_journal.php') ;
        panel_sv_journal($options) ;
        $this->add_element('panel_filter_result.HTML',ob_get_clean()) ;
        //$this->add_element('show_modal_window','HTML') ;
    }
}
