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

    function block_main()
    { $this->page_title() ;
      ?><div id="check_cars_export"><form>
          <table>
              <tr><td>URL внешнего источника:</td><td><input type="text" name="server_url" class="server_url" value=""> <input type="submit" class=v1 cmd=upload_ext_data value="Загрузить" value="form"></td></tr>
          </table>

          </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()
    {  ob_start() ;
       ?><strong>Загрузка внешних данных:</strong> <? echo $_POST['server_url'].'<br>' ;
       $XML_cont=file_get_contents($_POST['server_url']) ;
       ?><strong>Размер внешних данных:</strong> <? echo show_size(strlen($XML_cont)).'<br>' ;
       include_once('c_XML.php') ;
       $options=array() ;
       $XML=new c_page_XML($options) ;
       $XML->rec_member=ACCOUNTS()->get_member_by_id(MEMBER()->id) ;
       $XML->client = new c_client($XML->rec_member['pkey']) ;
       $result=$XML->upload_persons($XML_cont) ;
       damp_array($result,1,-1) ;
       adding_rec_to_table('obj_site_post_log',array('obj_name'=>'upload_persons','IP'=>$_SERVER['REMOTE_ADDR'],'result'=>$result,'clss'=>362,'client_id'=>MEMBER()->id)) ;
       $debug=ob_get_clean() ;
       LOGS()->reg_log($_GET['mode'],$debug,array('member_id'=>MEMBER()->id)) ;
       echo $debug ;
       reboot_engine() ;
    }
}

?>