123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>Система учёта рабочего времени (CPS) НИЯУ МИФИ: Приветствие</title>
- <meta name="robots" content="noindex,nofollow">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta http-equiv="Content-Language" content="ru">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta name="keywords" content="cps,нияу мифи,мифи,система учёта рабочего времени,сурв">
- <link rel="shortcut icon" type="image/png" href="/img/favicon.ico">
- <script type='application/ld+json'>{"@context":"http://schema.org","@type":"CollegeOrUniversity","address":"115409, Moscow, Kashirskoe shosse, 31","email":"rector@mephi.ru","name":"National research nuclear university \"MEPhI\"","sameAs":"https://en.wikipedia.org/wiki/National_Research_Nuclear_University_MEPhI","telephone":"+7 (495) 788-5699"}</script>
- <style>
- #employee-details {
- padding: 20px;
- }
- #employee-details li {
- width: 50%;
- }
- #employee-details ul {
- width:100%;
- max-width: 1200px;
- margin:0px;
- overflow:hidden;
- }
- #employee-details li {
- min-width: 400px;
- line-height:1.5em;
- float:left;
- display:inline;
- }
- #employee-details h1 {
- padding: 0;
- margin: 0;
- font-size: 24px;
- border-bottom:1px solid #ccc;
- }
- #employee-details table td {
- line-height:1em;
- padding: 5px;
- }
- #person-info td:nth-child(1) {
- display: none;
- }
- #statistics td:nth-child(1) {
- text-align: right;
- }
- #statistics td:nth-child(2) {
- font-weight: bold;
- }
- .event-falseExit, .event-falseEntry {
- color: #888;
- }
- #events tr:nth-child(even) {
- background: #eee;
- }
- #events tr:nth-child(odd) {
- background: #ddd;
- }
- #events tr:nth-child(even):hover {
- background: #bbf;
- }
- #events tr:nth-child(odd):hover {
- background: #ccF;
- }
- .holiday {
- color: #888;
- }
- .fakeRow {
- visibility: hidden;
- }
- .startEndDatesPanel {
- padding: 10px 0 0 10px;
- display: block;
- position: fixed;
- width: 100%;
- background: #222c3c;
- }
- </style>
- </head>
- <body>
- <div class='startEndDatesPanel'>
- <!--input type='date' name='startDate'>
- <input type='date' name='endDate'-->
- <input type='number' name='year' min=2016 max=2099 maxlength=4 size=4 onchange='datesChanged(); return false'>
- <select name='month' onchange='datesChanged(); return false'>
- <option value="" selected>весь год</option>
- <option value="1">январь</option>
- <option value="2">февраль</option>
- <option value="3">март</option>
- <option value="4">апрель</option>
- <option value="5">май</option>
- <option value="6">июнь</option>
- <option value="7">июль</option>
- <option value="8">август</option>
- <option value="9">сентябрь</option>
- <option value="10">октябрь</option>
- <option value="11">ноябрь</option>
- <option value="12">декабрь</option>
- </select>
- </div>
- <br>
- <div id='employee-details'>
- <span id='details' style='display:none'>
- <h1>Детализация: (<a href='#' style='color:#0088cc' onclick='exportToXls()'>экспортировать в XLS</a>)</h1>
- <table id='events'>
- <tr id='eventsHeader'><th>Дата</th><th>Вход</th><th>Вых.</th><th>Отработано</th><th>СТУ</th><th>Переработка</th></tr>
- <tr class='fakeRow'><td> </td></tr>
- </table>
- </span>
- <span id='loading'>
- Загрузка…
- </span>
- <ul>
- <li>
- <h1>Физ. лицо:</h1>
- <table id='person'>
- <tr>
- <td>
- <a id='photoLink' href='#'><img id='photo' src='https://voip.mephi.ru/public/photos/no_photo.png' style='min-width:100px' width='100px' height='133px' alt='photo'></a>
- </td>
- <td>
- <table id='person-info'>
- <tr><td>ФИО:</td> <td id='fullname'></td></tr>
- <tr><td>Должность:</td> <td id='appointment'></td></tr>
- <tr><td title='Суммарная ставка'>Ставка:</td> <td id='stake'></td></tr>
- <tr><td>Обязанности:</td> <td id='appointmentDescription'></td></tr>
- <tr id='controls' style='display:none'><td></td><td><a style='cursor:pointer' id='voipLink' href='#' target="_blank">найти в справочной книге</a></td></tr>
- </table>
- </td>
- </tr>
- <tr id='personnelNumberRow' style='display:none'><td>Таб. номер (шифр):</td><td id="personnelNumber" style='font-weight:bold'></td></tr>
- </table>
- </li>
- <li id='statisticsLi' style='display:none'>
- <h1>Статистика:</h2>
- <table id='statistics'>
- <!--tr><td>Рабочих дней:</td><td id='workdays'></td></tr>
- <tr><td>Вых. и праздн. дней:</td><td id='holidays'></td></tr-->
- <tr><td>Средний рабочий день:</td><td id='averageWorkday'></td></tr>
- <tr><td>Явок по табелю:</td><td id='turnoutByTimesheets'></td></tr>
- <tr><td>Посещений:</td><td id='visits'></td></tr>
- <tr><td>Разница посещений:</td><td id='visitsDiff'></td></tr>
- <tr><td>Требуется часов:</td><td id='hoursExpected'></td></tr>
- <tr><td>Отработано часов:</td><td id='hoursWorked'></td></tr>
- <tr><td>Переработано/пропущено часов:</td><td id='hoursDiff'></td></tr>
- <!--tr><td>Переработано часов:</td><td id='hoursOverWorked'></td></tr-->
- <tr><td>Нагрузка:</td><td id='loadage'></td></tr>
- </table>
- </li>
- </ul>
- <br><br>
- </div>
- </body>
- </html>
- <script src="https://voip.mephi.ru/public/js/3rdparty/jquery-1.9.1.min.js" type="text/javascript" charset="utf-8"></script>
- <script src="https://voip.mephi.ru/public/3rdparty/jquery-ui-1.11.4.custom/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>
- <script src="https://voip.mephi.ru/public/js/misc.js" type="text/javascript" charset="utf-8"></script>
- <script src="https://voip.mephi.ru/public/js/misc-3rdparty.js" type="text/javascript" charset="utf-8"></script>
- <script src="/js/common.js?v=2.18" type="text/javascript" charset="utf-8"></script>
- <script src="/js/3rdparty/alasql/dist/alasql.min.js" type="text/javascript" charset="utf-8"></script>
- <script src="/js/3rdparty/xlsx.js/dist/xlsx.full.min.js" type="text/javascript" charset="utf-8"></script>
- <link rel="stylesheet" type="text/css" href="https://voip.mephi.ru/public/css/voip.css">
- <link rel="stylesheet" type="text/css" href="https://voip.mephi.ru/public/css/voip-portable.css">
- <link rel="stylesheet" type="text/css" href="https://voip.mephi.ru/public/css/revel.css-minified.css">
- <link rel="stylesheet" type="text/css" href="https://voip.mephi.ru/public/css/3rdparty/jstree/style.min.css">
- <link rel="stylesheet" type="text/css" href="https://voip.mephi.ru/public/3rdparty/jquery-ui-1.11.4.custom/jquery-ui.min.css">
- <link rel="stylesheet" type="text/css" href="https://voip.mephi.ru/public/3rdparty/perfect-scrollbar-0.6.7/perfect-scrollbar.min.css">
- <link rel="stylesheet" type="text/css" href="https://voip.mephi.ru/public/css/3rdparty/select2.min.css">
- <script>
- var personId = getUrlParameter('personId');
- //var startDate = '2011-01-01';
- var startDate = (new Date(new Date() - 30*24*3600*1000).getFullYear())+'-01-01';
- var endDate = (parseInt(startDate.split('-')[0])+1)+'-01-01';
- var startDate_param = getUrlParameter('startDate');
- var endDate_param = getUrlParameter('endDate');
- if (startDate_param != null) {
- startDate = startDate_param;
- }
- if (endDate_param != null) {
- endDate = endDate_param;
- }
- function changePhotoToURL(url) {
- $('#photoLink').attr('href', url);
- $('#photo').attr('src', url);
- }
- function showPerson(person) {
- console.log("person", person);
- $('#fullname').text(person.Fullname);
- var appointments = [];
- var appointmentsFull = [];
- var stake = 0.0;
- for (var fIdx = 0; fIdx < person.Formulars.length; fIdx++) {
- var formular = person.Formulars[fIdx];
- if (!formular.IsActive) {
- continue;
- }
- if (formular.UnitShortName == null) {
- formular.UnitShortName = "";
- }
- appointments.push(formular.AppointmentName+' <a href="calculate.html?unitIds='+formular.UnitId+'"&startDate='+startDate+'&endDate='+endDate+'&yearPicker='+yearPicker+'&monthPicker='+monthPicker+'>'+formular.UnitShortName.trim().toUpperCase()+'</a>');
- var fullAppointment = formular.AppointmentName+' '+formular.UnitName;
- if (formular.Rate != null && formular.Rate > 0) {
- fullAppointment += ' ['+formular.Rate+'ст. '+formular.FormularType.toLowerCase()+']';
- }
- appointmentsFull.push(fullAppointment);
- stake += formular.Rate;
- }
- if (appointments.length > 0) {
- $('#appointment').html(appointments.join(', ')).attr('title', appointmentsFull.join(', ')+' ('+person.Description+')');
- } else {
- $('#appointment').html(person.Description);
- }
- if (stake > 0) {
- $('#stake').text((Math.round(stake*100)/100)+' ст.').attr('title', appointmentsFull.join(', '));
- }
- $('#controls').css('display', 'table-row');
- }
- function fallbackPhotoToSecurityDepartment(personId) {
- changePhotoToURL('https://api.cps.mephi.ru/people/'+personId+'.jpg');
- }
- function showSubscriber(personId, subscriber) {
- var appointmentDescriptions = [];
- if (subscriber == null) {
- fallbackPhotoToSecurityDepartment(personId);
- return;
- }
- if (subscriber.Appointments == null) {
- subscriber.Appointments = [];
- }
- var appointmentDescriptions = {};
- for (var aIdx = 0; aIdx < subscriber.Appointments.length; aIdx++) {
- var appointment = subscriber.Appointments[aIdx];
- if (appointment.Description != null && appointment.Description != "" && appointment.Description != "-") {
- appointmentDescriptions[appointment.Description] = appointment.Description;
- }
- }
- console.log(subscriber);
- $('#appointmentDescription').text(Object.keys(appointmentDescriptions).join(', '));
- }
- function requestVoipFaceInfo(personId) {
- voipRequest("subscribers/"+personId+".json?renderFilter=subscriber_selected&effectiveSecurityLevel=1024", function(data){
- var subscriber = data.subscriber_selected;
- showSubscriber(personId, subscriber);
- }, null);
- }
- function showStatistics(statistics) {
- //$('#workdays').text(…);
- //$('#holidays')
- var averageWorkday = Math.round((statistics.secondsExpected / statistics.visitsExpected) / 60);
- $('#averageWorkday').text(Math.floor(averageWorkday / 60)+'ч '+(averageWorkday%60)+'м');
- $('#turnoutByTimesheets').text(statistics.visitsExpected);
- $('#visits').text(statistics.visits);
- $('#visitsDiff').text(statistics.visitsDiff);
- $('#hoursExpected').text(Math.round(statistics.secondsExpected / 3600));
- $('#hoursWorked').text(Math.round(statistics.secondsWorked / 3600));
- $('#hoursDiff').text(Math.abs(Math.round(statistics.secondsDiff / 3600)));
- $('#hoursOverWorked').text(Math.round((statistics.secondsWorked - statistics.secondsExpected)/ 3600));
- $('#loadage').text(Math.round(100 * statistics.secondsWorked / statistics.secondsExpected)+' %').attr('title', Math.round(statistics.secondsWorked/3600)+' / '+Math.round(statistics.secondsExpected/3600));
- $('#statisticsLi').css('display', 'inline');
- var colorGood = [0, 128, 0];
- var colorBad = [255, 0, 0];
- var colorNorm = [0, 0, 0];
- var colorRatioHoursDiff = 65535*Math.abs(statistics.secondsDiff) / statistics.secondsExpected;
- if (colorRatioHoursDiff > 1) {
- colorRatioHoursDiff = 1;
- }
- var dColorHoursDiff = colorNorm
- if (statistics.secondsDiff >= 0) {
- dColorHoursDiff = colorGood;
- } else {
- dColorHoursDiff = colorBad;
- }
- var colorNormRatioHoursDiff = 1-colorRatioHoursDiff;
- var colorHoursDiff = [
- colorNorm[0]*colorNormRatioHoursDiff+dColorHoursDiff[0]*colorRatioHoursDiff,
- colorNorm[1]*colorNormRatioHoursDiff+dColorHoursDiff[1]*colorRatioHoursDiff,
- colorNorm[2]*colorNormRatioHoursDiff+dColorHoursDiff[2]*colorRatioHoursDiff,
- ];
- $('#hoursDiff').css('color', 'rgba('+colorHoursDiff[0]+','+colorHoursDiff[1]+','+colorHoursDiff[2]+',1)');
- $('#statistics tr').each(function(idx, el){
- var jel = $(el);
- if (jel.text().indexOf("NaN") != -1) {
- jel.css('display', 'none');
- }
- })
- }
- function showDetails(person, perDayInfo, status) {
- //console.log('showDetails', person, perDayInfo, status);
- var formulars = {};
- for (var fIdx = 0; fIdx < person.Formulars.length; fIdx++) {
- var formular = person.Formulars[fIdx];
- formulars[formular.StfCardId] = formular;
- }
- var dateIter = dateString2date(startDate).getTime() + 12*3600*1000;
- var dateEndTS0 = dateString2date(endDate).getTime() - 12*3600*1000;
- var dateEndTS1 = dateString2date(status.lastEventDatetime.split('T')[0]).getTime();
- var dateEndTS = Math.min(dateEndTS0, dateEndTS1) + 18*3600*1000;
- var dates = [];
- while (dateIter < dateEndTS) {
- var _date = new Date(dateIter);
- dates.push(dateToDateStr(_date));
- dateIter += 24 * 3600 * 1000;
- }
- dates.sort(datesStrCompFunc);
- var secondsExpectedTotal = 0;
- for (var dateIdx = 0; dateIdx < dates.length; dateIdx++) {
- var date = dates[dateIdx];
- var dayInfo = perDayInfo[date];
- if (dayInfo == null) {
- continue;
- }
- secondsExpectedTotal += dayInfo.secondsExpected;
- }
- for (var dateIdx = 0; dateIdx < dates.length; dateIdx++) {
- var date = dates[dateIdx];
- var dayInfo = perDayInfo[date];
- var exits = [];
- var entries = [];
- var dayOfWeek = ( dateString2date(date+' 00:00:00').getDay())%7;
- var dayOfWeekMap = { 0: 'Вс', 1: 'Пн', 2: 'Вт', 3: 'Ср', 4: 'Чт', 5: 'Пт', 6: 'Сб' };
- if (dayInfo == null) {
- dayInfo = {};
- dayInfo.timesheetRows = [];
- dayInfo.visited = false;
- dayInfo.secondsExpected = 0;
- dayInfo.secondsWorked = 0;
- dayInfo.events = [];
- dayInfo.skipped = true;
- }
- var workedMins = Math.round(dayInfo.secondsWorked/60);
- var workedDescription = '';
- if (workedMins > 0) {
- workedDescription = Math.floor(workedMins/60)+'ч '+(workedMins%60)+'м';
- }
- if (dayInfo.skipped && workedDescription != '' && secondsExpectedTotal > 0) {
- workedDescription = '('+workedDescription+')';
- }
- //var expectedSecs = 0;
- var timesheetTitlesMap = {};
- var timesheetDescription = [];
- for (var i = 0; i < dayInfo.timesheetRows.length; i++) {
- var timesheetRow = dayInfo.timesheetRows[i];
- var hoursRequired = 0;
- if (timesheetRow.HoursRequired != null) {
- hoursRequired = timesheetRow.HoursRequired;
- //expectedSecs += hoursRequired*3600;
- }
- timesheetTitlesMap[timesheetRow.TimeUseCode] = true;
- timesheetDescription.push((hoursRequired*formulars[timesheetRow.StfCardId].Rate)+' ч. ('+timesheet_rowDescriptions[timesheetRow.TimeUseCode]+')');
- }
- var timesheetTitles = [];
- for (var timeUseCode in timesheetTitlesMap) {
- timesheetTitles.push(timeUseCode);
- }
- if (timesheetTitles.length == 0) {
- timesheetTitles.push('--');
- timesheetDescription.push('нет табельных данных');
- }
- var expectedMins = 0;
- var expectedDescription = '0 ч. 0 м.';
- var overWorkedMins = 0;
- var overWorkedDescription = '';
- if (!dayInfo.skipped) {
- expectedMins = Math.round(dayInfo.secondsExpected/60);
- expectedDescription = Math.floor(expectedMins/60)+' ч. '+(expectedMins%60)+' м.';
- overWorkedMins = Math.round((dayInfo.secondsWorked - dayInfo.secondsExpected)/60);
- if (Math.abs(overWorkedMins) > 0) {
- if (overWorkedMins > 0) {
- overWorkedDescription = Math.floor(overWorkedMins/60)+'ч '
- overWorkedDescription += (overWorkedMins%60)!=0?(overWorkedMins%60)+'м':'';
- } else {
- overWorkedDescription = '- '+Math.floor(Math.abs(overWorkedMins)/60)+'ч '
- overWorkedDescription += (overWorkedMins%60)!=0?(Math.abs(overWorkedMins)%60)+'м':'';
- }
- }
- }
- entriesExitsTitle = '';
- for (var i = 0; i < dayInfo.events.length; i++) {
- var ev = dayInfo.events[i];
- var time = ev.DtDate.split(" ")[1];
- var shortTime = time.substring(0, time.length-3);
- switch(ev.Direction) {
- case 0:
- case 2:
- while (entries.length-1 > exits.length) {
- exits.push(" ");
- }
- exits.push("<span class='"+(ev.Direction==0?'event-exit':'event-falseExit')+"'>"+shortTime+"</span>");
- break;
- case 1:
- case 3:
- while (exits.length > entries.length) {
- entries.push(" ");
- }
- entries.push("<span class='"+(ev.Direction==0?'event-entry':'event-falseEmtry')+"'>"+shortTime+"</span>");
- break;
- }
- }
- while (exits.length > entries.length) {
- entries.push(" ");
- }
- while (entries.length > exits.length) {
- exits.push(" ");
- }
- if (prodCalendar[date] == null) {
- console.log('Invalid date', date);
- }
- if (prodCalendar[date].cps_isfilled == 0) {
- timesheetTitles.push("✖");
- expectedDescription += ' (нет данных с проходной)';
- }
- $('#eventsHeader').after($('<tr'+(expectedMins==0&&secondsExpectedTotal>0?' class="holiday"':'')+'><td>'+date+': '+dayOfWeekMap[dayOfWeek]+'</td><td title="'+entriesExitsTitle+'">'+entries.join('<br>')+'</td><td title="'+entriesExitsTitle+'">'+exits.join('<br>')+'</td><td>'+workedDescription+'</td><td title="'+timesheetDescription.join(', ')+' = '+expectedDescription+'">'+timesheetTitles.join(',')+'</td><td>'+overWorkedDescription+'</td></tr>'));
- }
- var personnelNumberMap = {};
- for (var fIdx = 0; fIdx < person.Formulars.length; fIdx++) {
- var formular = person.Formulars[fIdx];
- if (!formular.IsActive) {
- continue;
- }
- if (personnelNumberMap[formular.PersonnelNumber] == null) {
- personnelNumberMap[formular.PersonnelNumber] = []
- }
- personnelNumberMap[formular.PersonnelNumber].push(formular);
- }
- var personnelNumberValues = Object.keys(personnelNumberMap);
- var personnelNumberDescriptions = [];
- for (var personnelNumber in personnelNumberMap) {
- var formulars = personnelNumberMap[personnelNumber];
- var unitNameMap = {};
- for (var fIdx = 0; fIdx < formulars.length; fIdx++) {
- var formular = formulars[fIdx];
- unitNameMap[formular.UnitShortName] = true;
- }
- var unitNames = Object.keys(unitNameMap);
- personnelNumberDescriptions.push(personnelNumber+' ['+unitNames.join(', ')+']');
- }
- if (personnelNumberValues.length > 0) {
- $('#personnelNumber').text(personnelNumberValues.join(', ')).attr('title', personnelNumberDescriptions.join(';'));
- $('#personnelNumberRow').css('display', 'inline-block');
- } else {
- $('#personnelNumberRow').css('display', 'none');
- }
- $('#details').css('display', 'block');
- window.scrollTo(0,document.body.scrollHeight);
- }
- var person = null
- var cpsInfo = null;
- var timesheet = null;
- var prodCalendar = null;
- var statistics = null;
- var apiStatus = null;
- function tryDisplayStatisticsAndDetails() {
- if (person == null || cpsInfo == null || timesheet == null || prodCalendar == null || apiStatus == null) {
- //console.log('try', person, cpsInfo, timesheet, prodCalendar, apiStatus);
- return;
- }
- var formularsMap = {};
- for (var fIdx = 0; fIdx < person.Formulars.length; fIdx++) {
- var formular = person.Formulars[fIdx];
- formularsMap[formular.StfCardId] = formular;
- }
- statistics = calculateStatistics(person, cpsInfo, timesheet, prodCalendar, formularsMap);
- showStatistics(statistics);
- showDetails(person, statistics.perDayInfo, apiStatus);
- }
- function requestFaceInfo(personId) {
- personId=parseInt(personId);
- request("people?person.Id="+personId+"&prepareFormulars=true&startDate="+startDate+"&endDate="+endDate, function(people){
- person = people[0];
- if (person == null) {
- person = {};
- }
- if (person.Formulars == null) {
- person.Formulars = [];
- }
- if (person.EmpGUID != null) {
- $('#voipLink').attr('href', 'https://voip.mephi.ru/subscribers?Subscriber.PersonId='+personId+'&effectiveSecurityLevel=1024').css('display', 'inline-block');
- } else {
- $('#voipLink').css('display', 'none');
- }
- showPerson(person);
- tryDisplayStatisticsAndDetails();
- }, null);
- return;
- }
- function displayPassesProblem() {
- $('#details').prepend("<hr><h1 style='color:red'>Отсутствует информация об актуальных пропусках сотрудника. Необходимо внести справления через <a href='https://fixok.ut.mephi.ru/' target='_blank'>https://fixok.ut.mephi.ru/</a></h1>");
- return;
- }
- function requestFacePassesInfo(personId) {
- personId=parseInt(personId);
- request("passes?pass.PersonId="+personId+'&startDate='+startDate+'&endDate='+endDate, function(passes){
- if (passes == null) {
- passes = [];
- }
- if (passes.length == 0) {
- displayPassesProblem();
- }
- }, null);
- return;
- }
- function requestFaceCPSInfo(personId) {
- personId=parseInt(personId);
- request("events?event.PersonId="+personId+"&optimizeOutput=true&startDate="+startDate+'&endDate='+endDate, function(events){
- cpsInfo = events;
- if (cpsInfo == null) {
- cpsInfo = [];
- }
- $('#loading').css('display', 'none');
- tryDisplayStatisticsAndDetails();
- }, null);
- return;
- }
- function requestFaceTimesheet(personId) {
- personId=parseInt(personId);
- request("timesheetRows?timesheetRow.PersonId="+personId+"&optimizeOutput=true&startDate="+startDate+'&endDate='+endDate, function(_timesheet){
- timesheet = _timesheet;
- if (timesheet == null) {
- timesheet = [];
- }
- tryDisplayStatisticsAndDetails();
- }, null);
- return;
- }
- function requestStatus() {
- request("status", function(_status) {
- apiStatus = _status;
- tryDisplayStatisticsAndDetails();
- }, null);
- return;
- }
- function exportToXls() {
- var statisticsClean = {};
- statisticsClean[l("days")] = statistics.days;
- statisticsClean[l("visits")] = statistics.visits;
- statisticsClean[l("visitsExpected")] = statistics.visitsExpected;
- statisticsClean[l("visitsDiff")] = statistics.visitsDiff;
- statisticsClean[l("hoursWorked")] = Math.round(statistics.secondsWorked / 3600);
- statisticsClean[l("hoursExpected")] = Math.round(statistics.secondsExpected / 3600);
- statisticsClean[l("hoursDiff")] = Math.round(statistics.secondsDiff / 3600);
- var headers = [{sheetid:'Физ. лицо', headers:false},{sheetid:'статистика',header:true},{sheetid:'журнал',header:true}];
- var datas = [];
- datas.push([{
- 'Полное имя': person.Fullname,
- 'Описание': person.Description,
- }]);
- datas.push([statisticsClean]);
- var cpsInfoLocalized = [];
- for (var idx = 0; idx < cpsInfo.length; idx++) {
- var origRow = cpsInfo[idx];
- var row = {};
- row['Отметка времени'] = origRow['DtDate'];
- //row['Идент. физ. лица'] = origRow['PersonId'];
- //row['Номер сотрудника'] = origRow['EmpGUID'];
- switch (origRow['Direction']) {
- case 0:
- row['Тип события'] = 'выход';
- break;
- case 1:
- row['Тип события'] = 'вход';
- break;
- case 2:
- row['Тип события'] = '(выход)';
- break;
- case 3:
- row['Тип события'] = '(вход)';
- break;
- }
- cpsInfoLocalized.push(row);
- }
- console.log(cpsInfoLocalized);
- datas.push(cpsInfoLocalized);
- for (var month in statistics.perMonthInfo) {
- headers.push({sheetid:'месяц_'+month,header:true});
- console.log(statistics.perMonthInfo[month]);
- var statsLocalized = {};
- statsLocalized[l('days')] = statistics.perMonthInfo[month]['days'];
- statsLocalized[l('visits')] = statistics.perMonthInfo[month]['visits'];
- statsLocalized[l('visitsExpected')] = statistics.perMonthInfo[month]['visitsExpected'];
- statsLocalized[l('visitsMissed')] = statistics.perMonthInfo[month]['visitsMissed'];
- statsLocalized[l('visitsDiff')] = statistics.perMonthInfo[month]['visitsDiff'];
- statsLocalized[l('hoursWorked')] = Math.round(statistics.perMonthInfo[month]['secondsWorked'] / 3600);
- statsLocalized[l('hoursExpected')] = Math.round(statistics.perMonthInfo[month]['secondsExpected'] / 3600);
- //statsLocalized[l('hoursMissed')] = Math.round(statistics.perMonthInfo[month]['secondsMissed'] / 3600);
- statsLocalized[l('hoursDiff')] = Math.round(statistics.perMonthInfo[month]['secondsDiff'] / 3600);
- datas.push([statsLocalized]);
- }
- var res = alasql('SELECT * INTO XLSX("statistics.xlsx",?) FROM ?', [headers,datas]);
- }
- getProdCalendar(startDate, endDate, function(_prodCalendar){
- prodCalendar = _prodCalendar;
- tryDisplayStatisticsAndDetails();
- });
- if (personId != null) {
- changePhotoToURL('https://voip.mephi.ru/subscribers/.jpg?Subscriber.PersonId='+personId);
- requestFaceInfo(personId);
- requestFaceCPSInfo(personId);
- requestFaceTimesheet(personId);
- requestFacePassesInfo(personId);
- requestVoipFaceInfo(personId);
- requestStatus();
- }
- initDatepickers();
- initStartEndDatesPanel();
- </script>
|