<?php
include_once("c_esmo_gateway_upload.php");
class c_page_cab_esmo_gateway_upload_personals_gate_log extends c_page_cab_esmo_gateway_upload

{
    public $h1='Загрузка данных через шлюз - лог загрузки' ;

    function block_main()
    { $this->page_title() ;
      //show_list_items('obj_site_post_log','clss=362 and obj_name="upload_persons"','aspmo_client/log_upload_persons',array('debug'=>0,'panel_select_pages'=>1,'order'=>'c_data desc')) ;
      $recs=execSQL('select * from obj_site_post_log where clss=362 and  (obj_name="upload_persons" or obj_name="upload_cars" or obj_name="upload_relationcar") order by pkey desc limit 100') ;
      if (_sizeof($recs)) $this->log_upload_persons($recs) ;
    }

	// шаблон - вывод ссылками без разделитея
	  function log_upload_persons($list_recs,$options=array())
	  { $id=($options['id'])? 'id='.$options['id']:'' ;
	    ?>
	      <table class="log_upload_persons basic fz_small full auto" <?echo $id?>>
	        <colgroup><col id=c1><col id=c2><col id=c3><col id=c3><col id=c4><col id=c5><col id=c6><col id=c7><col id=c8></colgroup>
          <tr>
              <th>Дата, время</th>
              <th>IP</th>
              <th>Источник</th>
              <th>Обработано записей</th>
              <th>Обновлено<br>записей</th>
              <th>Добавлено<br>записей</th>
              <th>Деактивировано<br>записей</th>
              <th>Лог</th>
          </tr><? ;
	        if (_sizeof($list_recs)) foreach($list_recs as $rec)
	    	{   $result=unserialize($rec['result'])  ;
	            ?><tr>
	    	      <td class=data><? echo date('d.m.Y H:i:s',$rec['c_data']) ;?></td>
	    	      <td class=name><? echo $rec['IP'] ?></td>
                  <td class=name><? echo $rec['obj_name'] ?></td>
	    	      <td>
                        <?
                        switch ($rec['obj_name']) {
                            case 'upload_persons':      echo $result['person_count'] ;      break;
                            case 'upload_cars':         echo $result['car_count'] ;         break;
                            case 'upload_relationcar':  echo $result['relation_count'] ;    break;
                        }
                        ?>
                  </td>
                  <td>
                        <?
                        switch ($rec['obj_name']) {
                            case 'upload_persons':      echo $result['person_update'] ;     break;
                            case 'upload_cars':         echo $result['car_update'] ;        break;
                            case 'upload_relationcar':  echo $result['relation_update'] ;       break;
                        }
                        ?>
                  </td>
                  <td>
                        <?
                        switch ($rec['obj_name']) {
                            case 'upload_persons':      echo $result['person_adding'] ;     break;
                            case 'upload_cars':         echo $result['car_adding'] ;        break;
                            case 'upload_relationcar':  echo $result['relation_adding'] ;       break;
                        }
                        ?>
                  </td>
                  <td>
                        <?
                        switch ($rec['obj_name']) {
                            case 'upload_relationcar':  echo $result['relation_deactivate'] ;       break;
                        }
                        ?>
                  </td>
	    	      <td><? if ($rec['session_uid'] and file_exists(_DIR_TO_ROOT.'/logs/import_trace_'.$rec['session_uid'].'.html')) echo '<a target="blank" href="/logs/import_trace_'.$rec['session_uid'].'.html">'.$rec['session_uid'].'</a>' ?></td>
	    	   </tr><?
	    	}
	    ?></table><?
    }



}



?>
