

<script type="text/javascript" src="/class_v2.01/ext/aspmo_narko/visualize/js/jquery.js"></script>
<script type="text/javascript" language="JavaScript" >
    var pluginObject;
    function addEvent(obj, name, func)
    {
        if (obj.attachEvent) {
            obj.attachEvent(name, func);
        } else {
            obj.addEventListener(name, func, false);
        }
    }

    $(document).ready(function(){
        pluginObject = document.getElementById( 'AuthorizationPlugin' );
        pluginObject.initialize();
        document.getElementById("inputPassNumber").focus();
    });
    function startScan()
    {
        pluginObject.startScan();
    }



    function printQR(inputData)
    {
        var passNumber=$("#inputPassNumber").val();
        var textForQR;
        var num=0;
        for(var key in inputData)
        {
            if (key!="$family")
            {
                if (num == 0)
                    textForQR = inputData[key] + "\n";
                else
                    textForQR += inputData[key] + "\n";
                num++;
            }
        }
        pluginObject.generateQR(passNumber);
        pluginObject.printQR(textForQR);
    }

    function getDataFromServer(passNumber)
    {
        jQuery.ajax({
            dataType: "json",
            type:"POST",
            async:false,
            url: "/ajax.php?cmd=aspmo_authorization/getMOInfo",
            data: "passNumber="+passNumber,
            success: function(data) {
                var nameString=data['name'];
                if (nameString.length==0)
                {
                    $('#result').html("Сотрудник не найден!");
                    return;
                }

                data['name']=data['name'].toUpperCase();
                var workedData=new Array();
                workedData["name"]=data['name'].substring(0,data['name'].indexOf(" "));
                var curString=data['name'];
                data['name']=curString.substring(curString.indexOf(" ")+1);
                workedData["secondName"]=data['name'].substring(0,data['name'].indexOf(" "));
                workedData["thirdName"]=data['name'].substring(data['name'].indexOf(" ")+1);
                workedData["br1"]=" ";
                workedData["txt1"]="ВРЕМЯ ПРОХОЖДЕНИЯ";
                workedData["txt2"]="ПОСЛЕДНЕГО МО";
                workedData["br2"]=" ";
                workedData["dateMo"]=data['date'];
                workedData["br3"]=" ";
                workedData["br4"]=" ";
                if (data["dopusk"]==1)
                    workedData["dopusk"]="ДОПУЩЕН";
                else {
                    $('#result').html("Сотрудник не получил допуск!");
                    return;
                }
                workedData["br5"]=" ";
                workedData["br6"]=" ";
                workedData["txt3"]="ВРЕМЯ ПЕЧАТИ ТАЛОНА:";
                workedData["br7"]=" ";
                workedData["datePrint"]=data["curDate"];
                printQR(workedData);
            },
            error: function(jqXHR, textStatus, errorThrown){
                $('#result').html("Не удается произвести соединение с сервером!");
            }
        });
    }
    function newWord()
    {
        $('#result').html("");
        var currentString=$("#inputPassNumber").val();
        if (currentString.length==8)
        {
            getDataFromServer($("#inputPassNumber").val());
            $("#inputPassNumber").val("");
            return;
        }
    }



</script>
<object id="AuthorizationPlugin" type="application/x-authorization" width="1" height="1">
    <param name="onload" value="pluginLoaded" />
</object><br />
<div id="main" style="text-align: center;">
    <div class="leftSide" style="float: left;width: 25%; height:600px">
        <input id="inputPassNumber" style="vertical-align: middle;" onkeyup="newWord()">
    </div>
    <div class="rightSide"style="float:right; width:70%; height:600px; background-color: #ccc;">
        <div id="result" style="vertical-align: middle; font-size: 30px; border:1 px solid rgb(120,120,120);"></div>
    </div>
</div>

