<?php
include_once(_DIR_TO_CLASS."/c_page.php");
class c_page_cab_pl_packet extends c_page
{
    public $h1 = 'Карточка пакета';
    public $rec_packet=[] ;

    function select_obj_info()
    {
        $this->rec_packet=\esmo\pl\i_pl_packets::get_rec_by_id(_CUR_ID) ;
    }

    function menu_config()
     { // вкладки для сотрудника
       if ($this->rec_packet['pkey'])
       { $this->menu['/window/pl/packet/'.$this->rec_packet['pkey'].'/']='Карточка пакета' ;
         $this->menu['/window/pl/packet/'.$this->rec_packet['pkey'].'/log/']='Лог пакета' ;
         $this->menu['/window/pl/packet/'.$this->rec_packet['pkey'].'/db/']='БД' ;
       }

     }

    function block_main()
    {
        $this->page_title();
        //damp_array($this->rec_packet);
        //$rec_packet=PL()->get_packet_by_id($_POST['packet_id']) ;
        $titul2_fname=PL()->get_file_dir_by_packet_id($this->rec_packet['packet_type'],$this->rec_packet['pkey'],'xml') ;
        echo 'Файл: <strong>'.hide_server_dir($titul2_fname).'</strong><br>' ;
        $xml_content=file_get_contents($titul2_fname) ;
        ?><link rel="stylesheet" href="/AddOns/EnlighterJS/dist/enlighterjs.min.css"/>
           <script type="text/javascript" src="/AddOns/EnlighterJS/dist/enlighterjs.min.js"></script>
            <script type="text/javascript">
                $j(document).ready(function()
                {
                    // INIT CODE - simple page-wide initialization based on css selectors
                    // - highlight all pre + code tags (CSS3 selectors)
                    // - use javascript as default language
                    // - use theme "enlighter" as default theme
                    // - replace tabs with 2 spaces
                    EnlighterJS.init('pre', 'code', {
                            language : 'javascript',
                            theme: 'enlighter',
                            indent : 2
                    });
                }) ;
            </script>
        <div style="max-width:100%"><pre data-enlighter-language="less"><? echo ENGINE()->htmlentities_open_tag($xml_content) ?></pre></div>
        <?


        if ($this->rec_packet['packet_type']==2)
         { ?><h2>Формирование имени файла пакета</h2><?
           $rec_titul1=\esmo\pl\i_pl_packets::get_rec_by_id($this->rec_packet['titul1_id']) ;
           PL()->generate_titul2_file_uid($rec_titul1['file_uid'],['debug'=>1]) ;
        }

        if ($this->rec_packet['packet_type']==1)
        {   ?><h2>Парсинг содержимого пакета титул 1</h2><?
            include_once(_DIR_EXT.'/pl/c_services_pl_put_titul_1.php') ;
            $service=new c_services_pl_put_titul_1 ;
            $rec=$service->parse_xml_packet_to_rec($titul2_fname) ;
            damp_array($rec,1,-1);
        }

        //damp_array($this->rec_packet);

    }


}


?>
