<?php
include_once("c_debug_info.php");
class c_page_cab_debug_info_cleaning extends c_page_cab_debug_info
{
  public $h1='Чистка' ;


  function block_main()
  { $this->page_title() ;
    ?><button class="v1" cmd="clear_jurnals">Очистка журналов (оперативные данные)</button><?
    /*$cmd_metod=$_POST['cmd'] ;
         if ($cmd_metod and method_exists($this,$cmd_metod))
         { ?><hr><?
           $this->{$cmd_metod}() ;
         }    */
  }
  
    function clear_jurnals()
       {  ob_start() ;
          $stats=array() ;
          ?><h2>Очистка журналов</h2><?
          $stats['Журнал событий']=execSQL_van('select min(c_data) as c_data,max(c_data) as r_data,count(pkey) as cnt from obj_site_mo_log')  ;
          $stats['Журнал страниц']=execSQL_van('select min(c_data) as c_data,max(c_data) as r_data,count(pkey) as cnt from log_site_pages')  ;
          $stats['Журнал обмена']=execSQL_van('select min(c_data) as c_data,max(c_data) as r_data,count(pkey) as cnt from obj_site_req_log')  ;
          $stats['Журнал ошибок SQL']=execSQL_van('select min(c_data) as c_data,max(c_data) as r_data,count(pkey) as cnt from '.TM_LOG_SQL_ERRORS)  ;
          $stats['Журнал долгих SQL']=execSQL_van('select min(c_data) as c_data,max(c_data) as r_data,count(pkey) as cnt from 	'.TM_LOG_SQL_LONG)  ;
          print_2x_arr($stats) ;
          //$stats['Журнал событий']=execSQL_van('select min(c_data) as c_data,max(c_data) as r_data,count(pkey) as cnt from  obj_site_mo_log')  ;
      
          ?><h3>Производим очистку журналов</h3><?
          $now=getdate() ;   // damp_array($now) ;
          $from_time=mktime(0,0,0,$now['mon'],$now['mday']-1,$now['year']);
          //echo 'from_time='.date('d.m.Y',$from_time) ;
          execSQL_update('delete LOW_PRIORITY from log_site_pages',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_req_log',1) ;
          execSQL_update('delete LOW_PRIORITY from '.TM_LOG_SQL_ERRORS,1) ;
          execSQL_update('delete LOW_PRIORITY from '.TM_LOG_SQL_LONG,1) ;
  
          // очищаем результаты ПП из Базы
          if ($GLOBALS['_SETTING']['modules']['pp'])execSQL_update('update obj_site_narko_data set rightEye=NULL,leftEye=NULL',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="terminal_save"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="Изменение данных терминала"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="Оценка результатов по критериям"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="check_access"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="check_personal_access"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="Окончание медосмотра"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="check_doctor"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="Автодопуск сотрудника"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="Отправлена команда терминалу"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="doPut"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="Ручной медосмотр"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="check_status"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="Биллинг"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="Включение терминала"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="Асинхронная команда терминалу"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="Перевод МО в статус Уклонился"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="Команда с интерфейса"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="check_osmotr"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="Автодобавление фото персонала"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="Подписание документа"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="Пропуск команды терминалу"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="HTML2PDF"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="Переход в режим неисправности"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="power_on"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="Начало ручного медосмотра"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="Проверка терминала при check_access"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="Очистка журналов"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="event_lister"',1) ;
          execSQL_update('delete LOW_PRIORITY from obj_site_mo_log where obj_name="on_event_examination_result"',1) ;
  
          execSQL_update('OPTIMIZE TABLE  log_site_pages',1) ;
          execSQL_update('OPTIMIZE TABLE  obj_site_req_log',1) ;
          execSQL_update('OPTIMIZE TABLE  '.TM_LOG_SQL_ERRORS,1) ;
          if ($GLOBALS['_SETTING']['modules']['pp']) execSQL_update('OPTIMIZE TABLE  obj_site_narko_data',1) ;
          execSQL_update('OPTIMIZE TABLE  obj_site_mo_log',1) ;
      
      
          $stats['Журнал событий']=execSQL_van('select min(c_data) as c_data,max(c_data) as r_data,count(pkey) as cnt from obj_site_mo_log')  ;
          $stats['Журнал страниц']=execSQL_van('select min(c_data) as c_data,max(c_data) as r_data,count(pkey) as cnt from log_site_pages')  ;
          $stats['Журнал обмена']=execSQL_van('select min(c_data) as c_data,max(c_data) as r_data,count(pkey) as cnt from obj_site_req_log')  ;
          $stats['Журнал ошибок SQL']=execSQL_van('select min(c_data) as c_data,max(c_data) as r_data,count(pkey) as cnt from  '.TM_LOG_SQL_ERRORS)  ;
          $stats['Журнал долгих SQL']=execSQL_van('select min(c_data) as c_data,max(c_data) as r_data,count(pkey) as cnt from '.TM_LOG_SQL_LONG)  ;
      
          print_2x_arr($stats) ;
          $text=ob_get_clean()  ;
          echo $text ;
          LOGS()->reg_log('Очистка журналов',$text) ;
       }
  
}



?>