<?php
include_once("c_esmo_gateway_upload.php");
class c_page_cab_esmo_gateway_upload_personals_ext_source extends c_page_cab_esmo_gateway_upload
{
    public $h1='Загрузка списка сотрудников - проверка - загрузка из внешнего источника' ;

    function block_main()
    { $this->page_title() ;
        $domain=(function_exists('AD'))? 'localhost':_MAIN_DOMAIN ;
      if (!$GLOBALS['LS_esmo_gateway_ext_source']) $GLOBALS['LS_esmo_gateway_ext_source']=_MAIN_PROTOCOL.$domain.'/services/esmo_gateway/demo/demo_persons.xml' ;
      ?><div id="check_cars_export"><form>
          <table>
              <tr><td>URL внешнего источника:</td><td><input type="text" name="server_url" class="server_url" value="<?echo $GLOBALS['LS_esmo_gateway_ext_source']?>"> <input type="submit" class=v1 cmd=upload_ext_data value="Загрузить" value="form"></td></tr>
          </table>
            Пример: <strong><? echo _MAIN_PROTOCOL.$domain?>/services/esmo_gateway/demo/demo_persons.xml</strong>
          </form>
        </div><div id="panel_debug"></div>
        <style type="text/css">
          div#check_cars_export{}
          div#check_cars_export input.server_url{width:700px;font-size:12px;}
          div#check_cars_export textarea.xml_data{width:700px;height:300px;font-size:12px;}
        </style>
      <?
    }

    function CMD_upload_ext_data()
    {  if ($_POST['server_url'])  update_site_setting('LS_esmo_gateway_ext_source',$_POST['server_url']) ;
       $result=PERSONAL()->upload_personal_from_ext_data() ;
       // показ результата
       damp_array($result,1,-1) ;
       // показ лога
       if ($result['session_uid'] and file_exists(_DIR_TO_ROOT.'/logs/import_trace_'.$result['session_uid'].'.html'))
       { ?><h2>Ход импорта</h2><?
         $cont=file_get_contents(_DIR_TO_ROOT.'/logs/import_trace_'.$result['session_uid'].'.html') ;
         echo $cont ;
       }
    }
}

?>