<?php
include_once(_DIR_TO_CLASS.'/c_page.php') ;
//include_once(_DIR_EXT.'/aspmo_rmt/i_mrt.php') ;
class c_page_cab_rml extends c_page
{
    public $h1='Рабочее место ламповщика' ;
    public $allow_access_to_rol=8 ; //

    function set_head_tags()
    {
        parent::set_head_tags() ;
        $this->HEAD['js'][]=_PATH_TO_EXT.'/jquery/buzz.min.js' ;
        $this->HEAD['css'][]=_PATH_TO_EXT.'/aspmo_rml/style.css' ;
    }
    
    function second_menu_config()
    {
        $this->second_menu=$this->menu['/cab/rml/']['items'] ;
        if ($GLOBALS['LS_lamp_counting']) {
            $this->second_menu['/cab/rml/lamp_events/']='Выдаваемые лампы - события';
            $this->second_menu['/cab/rml/lamp_in_hand/']='Выданные лампы';
        }
    }

    function block_main()
    {
        if (!$GLOBALS['LS_lamp_counting']) {
           $this->panel_check_personal() ;
        } else {
           $this->panel_check_personal_counting_lamp() ;
        }
    }

    function panel_check_personal()
    {
        ?>
        <div id="panel_filter" class="one_row">
            <form id="sky-form" class="sky-form">
                <fieldset>
                    <div class="row" id="person_info">
                        <section class="col col-6">
                            <label class="label">Введите номер пропуска</label>
                            <label class="input">
                                <input autofocus type="text" name="propusk" id="propusk"  placeholder="" lang="LAT" case="UPPER" value="">
                            </label>
                        </section>
                        <section class="col col-6 buttons">
                            <button class="v2 button" onclick="javascript:$j('input#propusk')[0].focus();" cmd="aspmo_rml/get_personal_info">Проверить</button>
                        </section>
                    </div>
                </fieldset>
            </form>
        </div>
        <br>
        <div id="panel_result"></div>
        <script type="text/javascript">
            $j('input#propusk')[0].focus() ;

            $j('input#propusk').on('keyup',function()
            {   if ($j(this).val().length==<?echo $GLOBALS['LS_pass_for_lamp_lenght']?>)
                { send_ajax_request({cmd:"aspmo_rml/get_personal_info",propusk:$j(this).val()}) ;
                    $j('input#propusk').val('') ;
                    $j('input#propusk').focus() ;
                }
            });
            $j(document).ready(function()
            {
                $j('body').everyTime(1000,'set_focus',function(){$j('#propusk').focus();})
            });
        </script>

        <?
    }

    function panel_check_personal_counting_lamp()
    {
        include_once('panel_check_personal.php');
        include_once('panel_lamp_count.php');
        include_once('panel_lamp_in_hand.php');
        ?>
        <table id="lamp_panel">
            <tr>
                <td class="panel_line">
                    <div id="current_panel">
                        <?
                        panel_check_personal();
                        ?>
                    </div>
                </td>
                <td class="panel_line cnt_info">
                    <div id="lamp_info">
                        <div id="lamp_count" onclick="send_ajax_request({cmd:'aspmo_rml/change_lamp_in_hand_panel'})">
                            <?
                            panel_lamp_count();
                            ?>
                        </div>
                        <?if ($GLOBALS['LS_lamp_time_show']) {?>
                        <div id="lamp_time">
                            <span id="time_string"></span>
                            <script type="text/javascript">
                                function digitalClock() {
                                    var tag = $j('#time_string');
                                    function time() {
                                        date = new Date();
                                        hou = date.getHours().toString();min = date.getMinutes().toString();sec = date.getSeconds().toString();
                                        min = (min<10)?0+min:min;sec = (sec<10)?0+sec:sec;
                                        tag.html(hou+':'+min+':'+sec);
                                        setTimeout(time,1000);
                                    }time();
                                }
                                $j(document).ready(digitalClock);
                            </script>
                        </div>
                        <?}?>
                        <div id="lamp_in_hands">
                            <?
                            if ($_SESSION['ARR_lamp_in_hand_panel']) panel_lamp_in_hand();
                            ?>
                        </div>
                    </div>
                </td>
            </tr>
        </table>
        <script type="text/javascript">
            let RFHIDtimeout = false;
        </script>
        <?
    }




}

?>