<?php
include_once('c_daily_briefing_card.php') ;

class c_page_cab_daily_briefing_card_conduct_base extends c_page_cab_daily_briefing_card
{
    public $h1='Проведение инструктажа' ;
    public $conduct_step=1;

    function get_step_urls()
    {
        return array(
            1=>$this->rec_briefing['__href'].'conduct/',
            2=>$this->rec_briefing['__href'].'conduct/step2/',
            3=>$this->rec_briefing['__href'].'conduct/step3/',
        );
    }

    function block_main()
    {
        $bid=(int)$this->rec_briefing['pkey'];
        $this->page_title('Проведение инструктажа') ;
        daily_briefing_render_conduct_layout_styles();
        ?>
        <div class="daily_briefing_stitch_page">
            <div class="daily_briefing_session_note">
                Текущая страница отражает один сеанс инструктажа для группы. Один и тот же инструктаж может проводиться несколько раз в течение дня в заданное время.
            </div>
            <div id="daily_briefing_stepper_wrap"><?php daily_briefing_render_stitch_stepper($this->conduct_step,$this->get_step_urls()); ?></div>
            <div class="daily_briefing_stitch_flex">
                <div class="daily_briefing_stitch_main_col">
                    <?php $this->render_stage_panel(); ?>
                </div>
                <div class="daily_briefing_stitch_sidebar_col" id="daily_briefing_sidebar_wrap">
                    <?php daily_briefing_render_conduct_sidebar($bid); ?>
                </div>
            </div>
            <h2>Журнал инструктажа</h2>
            <div id="daily_briefing_journal"><?php daily_briefing_render_recent_journal($bid)?></div>
        </div>
        <?php
        if ($this->need_pass_input_script()) $this->panel_pass_input_script();
    }

    function render_stage_panel()
    {
        daily_briefing_render_stage1_registration_card((int)$this->rec_briefing['pkey']);
    }

    function need_pass_input_script()
    {
        return true;
    }

    function panel_pass_input_script()
    {
        ?>
        <script type="text/javascript">
            var dailyBriefingRFIDtimeout = false;

            $j(document).ready(function()
            {
                $j('#propusk').focus();
                $j("body").stopTime('daily_briefing_focus');
                $j('body').everyTime(1000,'daily_briefing_focus',function(){$j('#propusk').focus();});

                $j('#propusk').on('keyup',function()
                {
                    dailyBriefingRFIDtimeout = Date.now();
                });

                $j("body").stopTime('daily_briefing_check_pass');
                $j('body').everyTime(100,'daily_briefing_check_pass',function()
                {
                    if (dailyBriefingRFIDtimeout && (Date.now() - dailyBriefingRFIDtimeout) > 300) {
                        send_ajax_request({
                            cmd:"daily_briefing/register_arrive",
                            briefing_id:$j('#daily_briefing_id').val(),
                            propusk:$j('#propusk').val()
                        });
                        dailyBriefingRFIDtimeout = false;
                    }
                });
            });
        </script>
        <?php
    }
}
?>
