index.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Система учёта рабочего времени (CPS) НИЯУ МИФИ: Приветствие</title>
  5. <meta name="robots" content="noindex,nofollow">
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  7. <meta http-equiv="Content-Language" content="ru">
  8. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  9. <meta name="keywords" content="cps,нияу мифи,мифи,система учёта рабочего времени,сурв">
  10. <link rel="shortcut icon" type="image/png" href="/img/favicon.ico">
  11. <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>
  12. <style>
  13. body input[type="submit"], body .button, body button {
  14. background: transparent;
  15. }
  16. body .select2-container--default.select2-container--focus .select2-selection--multiple {
  17. border: none;
  18. }
  19. body select {
  20. min-width: 545px;
  21. }
  22. html body .select2-container--default .select2-selection--multiple .select2-selection__rendered input {
  23. min-width: 530px;
  24. padding: 23px;
  25. }
  26. body select, body input[type="text"], body .select2-container--default .select2-selection--multiple .select2-selection__rendered input {
  27. font-size: 24px;
  28. padding: 13px;
  29. border-radius: 20px;
  30. width: 500px;
  31. }
  32. .parameter {
  33. white-space: nowrap;
  34. }
  35. html body .button {
  36. box-shadow: rgb(84, 163, 247) 0px 1px 0px 0px inset;
  37. background: linear-gradient(rgb(0, 125, 193) 5%, rgb(0, 97, 167) 100%) rgb(0, 125, 193);
  38. border-radius: 20px;
  39. border: 1px solid rgb(18, 77, 119);
  40. display: inline-block;
  41. cursor: pointer;
  42. color: rgb(255, 255, 255);
  43. font-size: 24px;
  44. padding: 20px 24px;
  45. text-decoration: none;
  46. text-shadow: rgb(21, 70, 130) 0px 1px 0px;
  47. }
  48. html body .button:hover {
  49. background: linear-gradient(rgb(100, 225, 255) 5%, rgb(0, 97, 167) 100%) rgb(0, 125, 193);
  50. }
  51. body .select2-container--default .select2-selection--multiple {
  52. background-color: transparent;
  53. border: none;
  54. }
  55. #employee-search, body .select2-container--default .select2-selection--multiple .select2-selection__rendered input {
  56. text-transform: capitalize;
  57. }
  58. #search-page, body select, body input[type="text"], body .select2-container--default .select2-selection--multiple .select2-selection__rendered input {
  59. background: #006397;
  60. }
  61. #search-page, #title a, body input[type="text"], body .select2-container--default .select2-selection--multiple .select2-selection__rendered input {
  62. color: #e0eeff;
  63. text-shadow: 0 0 10px rgba(255,255,255,0.35);
  64. }
  65. body select, body input[type="text"], body .select2-container--default .select2-selection--multiple .select2-selection__rendered input {
  66. border-color: rgba(82,168,236,0.8);
  67. box-shadow: inset 0 1px 1px rgba(0,0,0,0.075), 0 0 8px rgba(82,168,236,0.6);
  68. }
  69. body select, body input[type="text"]:focus, body .select2-container--default .select2-selection--multiple .select2-selection__rendered input:focus {
  70. border-color: #fff;
  71. box-shadow: 0 0 6px #fff;
  72. }
  73. body select, body input[type="text"]:focus:required:invalid, body .select2-container--default .select2-selection--multiple .select2-selection__rendered input:focus:required:invalid {
  74. border-color: #e9322d;
  75. box-shadow: 0 0 6px #e9322d;
  76. }
  77. body h1, body h2, body h3, body h4, #title a {
  78. font-weight: bold;
  79. }
  80. #title a:hover {
  81. color: #fff !important;
  82. text-shadow: 0 0 10px rgba(255,255,255,0.8);
  83. }
  84. #logoa {
  85. padding: 10px;
  86. box-shadow: 0 0 20px rgba(255,255,255,1);
  87. background: rgba(255,255,255,1);
  88. border-radius: 100px;
  89. }
  90. #logoa img {
  91. padding: 0px;
  92. }
  93. #search-page {
  94. position: absolute;
  95. width: 100%;
  96. padding: 20px;
  97. }
  98. #data {
  99. position: absolute;
  100. z-index: -3;
  101. width: 100%;
  102. height: 100%;
  103. }
  104. #parameters, #calculate-button {
  105. z-index: 256;
  106. }
  107. #parameters {
  108. color: #006397;
  109. width: 148px;
  110. display: block;
  111. position: fixed;
  112. bottom: 50px;
  113. right: 0;
  114. padding: 20px;
  115. border: 1px #0078e7 solid;
  116. background: #fff;
  117. }
  118. #parameters-faces, #parameters-units {
  119. max-height: 300px;
  120. overflow-y: auto;
  121. overflow-x: hidden;
  122. }
  123. #calculate-button:hover, #parameters-button:hover {
  124. background-color: #309cff;
  125. }
  126. #calculate-button, #parameters-button {
  127. display: block;
  128. position: fixed;
  129. bottom: 0;
  130. height: 50px;
  131. width: 190px;
  132. text-transform: uppercase;
  133. background-color: #0078e7;
  134. color: #fff;
  135. text-align: center;
  136. line-height: 53px;
  137. font-size: 24px;
  138. cursor: pointer;
  139. -webkit-transition: background-color 0.1s ease-in-out 0s;
  140. -moz-transition: background-color 0.1s ease-in-out 0s;
  141. -o-transition: background-color 0.1s ease-in-out 0s;
  142. transition: background-color 0.1s ease-in-out 0s;
  143. }
  144. #calculate-button {
  145. right: 0;
  146. }
  147. #parameters-button {
  148. right: left;
  149. }
  150. @media all and (max-width: 1550px) {
  151. #title {
  152. display: none !important;
  153. }
  154. }
  155. @media all and (max-width: 880px) {
  156. header {
  157. display: none !important;
  158. }
  159. }
  160. @media all and (max-width: 920px) {
  161. body #parameters {
  162. display: none;
  163. }
  164. html body input[type="text"] {
  165. font-size 20px;
  166. max-width: 250px;
  167. }
  168. html body .select2-container--default .select2-selection--multiple .select2-selection__rendered input {
  169. min-width: 280px;
  170. }
  171. body #units-tree {
  172. margin: 20px 30px 30px 0;
  173. }
  174. }
  175. #units-tree {
  176. color: #000;
  177. width: 100%;
  178. position: absolute;
  179. background: #fff;
  180. z-index: 64;
  181. margin: 20px 0px 0px 0;
  182. padding: 0 0 0 20px;
  183. left: 0px;
  184. box-shadow: 0 0 20px rgba(255,255,255,1);
  185. }
  186. .clear-input:before {
  187. content: "✖";
  188. }
  189. .clear-input {
  190. opacity: 0.5;
  191. width: 20px;
  192. font-size: 24px;
  193. margin: 0 20px 0 -40px;
  194. cursor: pointer;
  195. }
  196. body input[type="submit"]:hover {
  197. background-color: #2885c1;
  198. }
  199. .jstree-anchor {
  200. /*enable wrapping*/
  201. white-space : normal !important;
  202. /*ensure lower nodes move down*/
  203. height : auto !important;
  204. /*offset icon width*/
  205. padding-right : 24px;
  206. }
  207. body .select2-container--default .select2-selection--multiple .select2-selection__choice {
  208. position: absolute;
  209. top: 70px;
  210. color: #000;
  211. display: none;
  212. }
  213. #paillette {
  214. background-color: #0ff;
  215. border-radius: 20px;
  216. position: fixed;
  217. display: none;
  218. width: 15px;
  219. height: 15px;
  220. opacity: 0.7;
  221. box-shadow: 0 0 6px #0ff;
  222. z-index: 512;
  223. }
  224. .smooth-motion {
  225. -webkit-transition: top 0.5s ease-in-out 0s, left 0.5s ease-out 0s, right 0.5s ease-out 0s, margin 0.5s ease-out 0s;
  226. -moz-transition: top 0.5s ease-in-out 0s, left 0.5s ease-out 0s, right 0.5s ease-out 0s, margin 0.5s ease-out 0s;
  227. -o-transition: top 0.5s ease-in-out 0s, left 0.5s ease-out 0s, right 0.5s ease-out 0s, margin 0.5s ease-out 0s;
  228. transition: top 0.5s ease-in-out 0s, left 0.5s ease-out 0s, right 0.5s ease-out 0s, margin 0.5s ease-out 0s;
  229. }
  230. #search-page-bg {
  231. position:fixed;
  232. background-color:#fff;
  233. left:0;
  234. top:0;
  235. width:100%;
  236. height:100%;
  237. z-index:-2;
  238. }
  239. body iframe {
  240. border: 0;
  241. position: fixed;
  242. width: 100%;
  243. height: 100%;
  244. top: 0;
  245. left: 0;
  246. }
  247. .jstree-leaf, .jstree-node {
  248. font-size: 18px;
  249. }
  250. </style>
  251. </head>
  252. <body>
  253. <header style='right:0;left:initial'>
  254. <span id="title" style="padding-top: 0px; padding-right: 20px; opacity: 1;">
  255. <h2 style="font-size: 30px; line-height: 40px;"><a href="/">Система учёта рабочего времени</a></h2>
  256. <h3 style="margin-top: -13px; font-size: 24px; line-height: 40px; float: right"><a href="https://voip.mephi.ru/units/0153600">Управления информатизации</a></h3>
  257. </span>
  258. <a id='logoa' href="/" style='display:inline-block'>
  259. <img id="logo" src="https://voip.mephi.ru/public/img/nrnu_mephi.png" width="100px" height="100px" style="width: 100px; height: 100px;">
  260. </a>
  261. </header>
  262. <div style='position: relative'>
  263. <div id="right-waitbar">&nbsp;</div>
  264. <section id='search-page'>
  265. <div id='search-page-bg'></div>
  266. <h1>Поиск по физ. лицам:</h1>
  267. <form action='#' method='GET' onsubmit="employeeSearchSubmit(); return false">
  268. <input id='employee-search' class="cyrillic-only" name="employeesQuery" type="text" placeholder="">
  269. <span id="employee-search-clear" class="clear-input" onclick='$("#employee-search").val("")'></span>
  270. <span id='employees-reset' class='button' onclick="employeesReset()" >Сбросить</span>
  271. <!--input type='submit' value="" name="search" style='margin-left:10px;width:132px;height:132px;background-image:url(/img/search.png);background-size:100%;border-radius:100px'-->
  272. <div id='paillette'></div>
  273. </form>
  274. <h1>Фильтр по подразделениям:</h1>
  275. <input id='units-filter' class="cyrillic-only" type='text' onkeyup="considerUnitsFilter()">
  276. <span id="units-filter-clear" class="clear-input" onclick='$("#units-filter").val(""); considerUnitsFilter()'></span>
  277. &nbsp;
  278. <span id='units-select' class='button' onclick="unitsSelect()">Выбрать</span>
  279. <span id='units-reset' class='button' onclick="unitsReset()" >Сбросить</span><br><input id="ppsOnlyCheckBox" type="checkbox" name="ppsOnly"> <label style='display:inline-block' for="ppsOnlyCheckBox">только ППС?</label>
  280. <ul id='units-tree'>
  281. </ul>
  282. <div id='parameters'>
  283. Физ. лица:
  284. <ul id='parameters-faces'>
  285. </ul>
  286. Подразделения:
  287. <ul id='parameters-units'>
  288. </ul>
  289. </div>
  290. <div id="calculate-button" onclick="calculate()">посчитать</div>
  291. </section>
  292. <section id='data'>
  293. <iframe src='empty.html'>Ваш браузер не поддерживает плавающие фреймы!</iframe>
  294. <div id="parameters-button" onclick="showSearchPage()">параметры</div>
  295. </section>
  296. </div>
  297. </body>
  298. </html>
  299. <script src="https://voip.mephi.ru/public/js/3rdparty/jquery-1.9.1.min.js" type="text/javascript" charset="utf-8"></script>
  300. <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>
  301. <script src="https://voip.mephi.ru/public/js/3rdparty/cursor.js" type="text/javascript" charset="utf-8"></script>
  302. <script src="https://voip.mephi.ru/public/js/3rdparty/jstree.min.js" type="text/javascript" charset="utf-8"></script>
  303. <script src="https://voip.mephi.ru/public/js/3rdparty/select2.full.min.js" type="text/javascript" charset="utf-8"></script>
  304. <script src="https://voip.mephi.ru/public/js/misc.js" type="text/javascript" charset="utf-8"></script>
  305. <script src="/js/common.js?v=2.18" type="text/javascript" charset="utf-8"></script>
  306. <!--script src="https://voip.mephi.ru/public/js/3rdparty/clamp.min.js" type="text/javascript" charset="utf-8"></script-->
  307. <link rel="stylesheet" type="text/css" href="https://voip.mephi.ru/public/css/voip.css">
  308. <link rel="stylesheet" type="text/css" href="https://voip.mephi.ru/public/css/voip-portable.css">
  309. <link rel="stylesheet" type="text/css" href="https://voip.mephi.ru/public/css/revel.css-minified.css">
  310. <link rel="stylesheet" type="text/css" href="https://voip.mephi.ru/public/css/3rdparty/jstree/style.min.css">
  311. <link rel="stylesheet" type="text/css" href="https://voip.mephi.ru/public/3rdparty/jquery-ui-1.11.4.custom/jquery-ui.min.css">
  312. <link rel="stylesheet" type="text/css" href="https://voip.mephi.ru/public/3rdparty/perfect-scrollbar-0.6.7/perfect-scrollbar.min.css">
  313. <link rel="stylesheet" type="text/css" href="https://voip.mephi.ru/public/css/3rdparty/select2.min.css">
  314. <script>
  315. var startDate = (new Date(new Date() - 30*24*3600*1000).getFullYear())+'-01-01';
  316. var endDate = (parseInt(startDate.split('-')[0])+1)+'-01-01';
  317. function convert_lat2cyr(ev) {
  318. var found = 0;
  319. var el = ev.target;
  320. if (typeof(el.value) == 'undefined') {
  321. return;
  322. }
  323. el.value.replace(/[A-Za-z\[\];',.`~]/g, function (m) { // TODO: replace this "replace" with a search function
  324. found = 1;
  325. });
  326. if (found) {
  327. caretPos = getSelectionStart(el);
  328. el.value = el.value.replace(/[A-Za-z\[\];',.`~]/g, function (m) {
  329. return {
  330. 'q': 'й',
  331. 'w': 'ц',
  332. 'e': 'у',
  333. 'r': 'к',
  334. 't': 'е',
  335. 'y': 'н',
  336. 'u': 'г',
  337. 'i': 'ш',
  338. 'o': 'щ',
  339. 'p': 'з',
  340. '[': 'х',
  341. ']': 'ъ',
  342. 'a': 'ф',
  343. 's': 'ы',
  344. 'd': 'в',
  345. 'f': 'а',
  346. 'g': 'п',
  347. 'h': 'р',
  348. 'j': 'о',
  349. 'k': 'л',
  350. 'l': 'д',
  351. ';': 'ж',
  352. '\'': 'э',
  353. 'z': 'я',
  354. 'x': 'ч',
  355. 'c': 'с',
  356. 'v': 'м',
  357. 'b': 'и',
  358. 'n': 'т',
  359. 'm': 'ь',
  360. ',': 'б',
  361. '.': 'ю',
  362. 'Q': 'Й',
  363. 'W': 'Ц',
  364. 'E': 'У',
  365. 'R': 'К',
  366. 'T': 'Е',
  367. 'Y': 'Н',
  368. 'U': 'Г',
  369. 'I': 'Ш',
  370. 'O': 'Щ',
  371. 'P': 'З',
  372. '{': 'Х',
  373. '}': 'Ъ',
  374. 'A': 'Ф',
  375. 'S': 'Ы',
  376. 'D': 'В',
  377. 'F': 'А',
  378. 'G': 'П',
  379. 'H': 'Р',
  380. 'J': 'О',
  381. 'K': 'Л',
  382. 'L': 'Д',
  383. ':': 'Ж',
  384. '"': 'Э',
  385. 'Z': 'Я',
  386. 'X': 'Ч',
  387. 'C': 'С',
  388. 'V': 'М',
  389. 'B': 'И',
  390. 'N': 'Т',
  391. 'M': 'Ь',
  392. '<': 'Б',
  393. '>': 'Ю',
  394. '`': 'ё',
  395. '~': 'Ё',
  396. }[m];
  397. });
  398. el.setSelectionRange(caretPos, caretPos);
  399. }
  400. };
  401. function setup_cyrilliconly() {
  402. $('.cyrillic-only').unbind('keyup', convert_lat2cyr).keyup(convert_lat2cyr);
  403. }
  404. function generateUnitsTags(nodes) {
  405. nodes.sort(function(a, b) {
  406. return a.SortNumber - b.SortNumber;
  407. });
  408. var ul = document.createElement('ul');
  409. for (var key in nodes) {
  410. var node = nodes[key];
  411. var li=document.createElement('li');
  412. li.innerText = node.Code+" "+node.Name+" ["+node.BriefName+"]";
  413. li.dataset.unitId = node.Id;
  414. li.dataset.unitCode = node.Code;
  415. li.dataset.unitBriefName = node.BriefName;
  416. $(li).append(generateUnitsTags(node.Children));
  417. ul.appendChild(li);
  418. }
  419. return ul;
  420. }
  421. function showSearchPage() {
  422. var els = $('#search-page, #units-tree, #calculate-button, #parameters');
  423. els.removeClass('smooth-motion').addClass('smooth-motion').css('right', '0')
  424. $('#search-page').css('left', '0');
  425. $('#data').css('z-index', -3);
  426. $('header').css('display','');
  427. }
  428. function hideSearchPage() {
  429. var els = $('#search-page, #units-tree, #calculate-button, #parameters');
  430. els.removeClass('smooth-motion').addClass('smooth-motion').css('right', '120%');
  431. $('#search-page').css('left', '-120%');
  432. $('#data').css('z-index', -1);
  433. $('header').css('display','none');
  434. }
  435. function calculate() {
  436. if ($('#parameters input').length == 0) {
  437. alert('Необходимо выбрать хотя бы одного сотрудника или подразделение');
  438. return;
  439. }
  440. var personIds = [];
  441. var unitIds = [];
  442. $('input[name="faces[]"]').each(function(i,e){
  443. personIds.push(e.value);
  444. })
  445. $('input[name="units[]"]').each(function(i,e){
  446. unitIds.push(e.value);
  447. })
  448. var ppsOnly = $('input[name="ppsOnly"]').prop('checked');
  449. var newLocation = '/calculate.html?ppsOnly='+ppsOnly+'&unitIds='+unitIds.join(",")+'&personIds='+personIds.join(",");
  450. /*var oldtitle = document.title;
  451. var olddata = $('html').html();
  452. try{window.history.pushState({'html': olddata, 'pageTitle': oldtitle}, "", newLocation)}catch(e){window.history.pushState({'html': '', 'pageTitle': oldtitle}, "", newLocation)};*/
  453. $('iframe').attr('src', newLocation);
  454. hideSearchPage();
  455. }
  456. /*function showFoundEmployees(source, people) {
  457. var results = []
  458. for (var i = 0; i < people.length; i++) {
  459. var person = people[i];
  460. results[results.length] = {
  461. id: person.Id,
  462. text: person.Fullname,
  463. }
  464. }
  465. console.log(results);
  466. }*/
  467. function subscribersToPeople(subscribers) {
  468. return subscribersToAsuFaces(subscribers); // from misc.js of voip.mephi.ru
  469. }
  470. /*function findEmployees() {
  471. var v = $('#employee-search').val();
  472. if (v.length < 3) {
  473. hideFoundEmployees();
  474. return;
  475. }
  476. request("people?prepareFormulars=true&q="+encodeURI(v), function(people){
  477. showFoundEmployees('asu', people);
  478. });
  479. voipRequest("subscribers.json?q="+encodeURI(v), function(data){
  480. showFoundEmployees('voip', subscribersToPeople(data.subscribers));
  481. });
  482. }*/
  483. function addEmployee(face) {
  484. if (face == null) {
  485. return;
  486. }
  487. var liId = "parameter-face-"+face.Id;
  488. if (document.getElementById(liId) != null) {
  489. return false;
  490. }
  491. var list = $('#parameters-faces');
  492. var li=document.createElement('li');
  493. li.id = liId;
  494. li.className = 'parameter'
  495. var input=document.createElement('input');
  496. input.name='faces[]';
  497. input.type='hidden';
  498. input.value=face.Id;
  499. $(li).append(input);
  500. var button=document.createElement('a');
  501. button.href='#';
  502. button.onclick=function(){
  503. $('#'+liId).remove();
  504. return false;
  505. }
  506. button.innerText = '✖';
  507. $(li).append(button);
  508. var span=document.createElement('span');
  509. //span.innerText = face.Lastname+' '+face.Firstname.substr(0, 1)+'.'+(face.Patronymic == null ? '' : ' '+face.Patronymic.substr(0, 1)+'.');
  510. span.innerText = face.Fullname;
  511. $(li).append(span);
  512. // paillette:
  513. if (true) {
  514. li.style.visibility='hidden';
  515. x_position = $('#employee-search').offset().left - $(window).scrollLeft() + 50;
  516. y_position = $('#employee-search').offset().top - $(window).scrollTop() + 40;
  517. $('#paillette').removeClass('smooth-motion').css('top', y_position+'px').css('left', x_position+'px').css('display', 'block').addClass('smooth-motion');
  518. setTimeout(function(){
  519. dest_pos = $('#parameters-units').offset();
  520. dest_pos.top -= 50;
  521. $('#paillette').css('top', dest_pos.top+'px').css('left', dest_pos.left+'px');
  522. setTimeout(function(){
  523. $('#paillette').removeClass('smooth-motion').css('display', 'none');
  524. li.style.visibility = 'visible';
  525. }, 500);
  526. }, 10);
  527. }
  528. list.append(li);
  529. }
  530. function setupSearchEmployees() {
  531. $('#employee-search-clear').css('margin', '0 30px 0 -50px');
  532. $("#employee-search").replaceWith("<select id='employee-search' name='personIds'></select>");
  533. $("#employee-search").select2({
  534. tags: true,
  535. multiple: true,
  536. tokenSeparators: [','],
  537. minimumInputLength: 3,
  538. ajax: {
  539. url: 'https://api.cps.mephi.ru/people',
  540. dataType: "json",
  541. type: "GET",
  542. cache: false,
  543. xhrFields: {
  544. withCredentials: true
  545. },
  546. data: function (v, page) {
  547. var queryParameters = {
  548. requestfrom: 'cps',
  549. prepareFormulars: true,
  550. q: v.term,
  551. }
  552. return queryParameters;
  553. },
  554. processResults: function (data) {
  555. return {
  556. results: $.map(data.arg, function (item) {
  557. return {
  558. item: item,
  559. id: item.Id,
  560. }
  561. })
  562. };
  563. }
  564. },
  565. templateResult: function(d) {
  566. if (d.text != null) {
  567. return false; //$('<span>'+d.text+'</span>');
  568. }
  569. var item = d.item;
  570. var appointmentsHtml = ''
  571. if (item.Formulars != null) {
  572. for (var i = 0; i < item.Formulars.length; i++) {
  573. var formular = item.Formulars[i];
  574. if (!formular.IsActive) {
  575. continue;
  576. }
  577. appointmentsHtml += '<br>'+formular.AppointmentName+' '+formular.UnitShortName.toUpperCase();
  578. }
  579. }
  580. return $('<table><tr><td><img src="https://voip.mephi.ru/subscribers/'+item.Id+'.jpg" alt="✖" height="50px" width="33px"></td><td>'+item.Fullname+appointmentsHtml+'</td></tr></table>');
  581. },
  582. templateSelection: function(d) {
  583. setTimeout(function(){$('.select2-selection__choice__remove').click()},1);
  584. var item = d.item;
  585. if (item == null) {
  586. return;
  587. }
  588. console.log(item);
  589. addEmployee(item);
  590. return item.Fullname;
  591. },
  592. });
  593. }
  594. function employeesReset() {
  595. $('#employee-search').val('');
  596. $('#parameters-faces').html('');
  597. }
  598. var unitsFilterTimeout = false;
  599. function considerUnitsFilter() {
  600. if (unitsFilterTimeout) {
  601. clearTimeout(unitsFilterTimeout);
  602. }
  603. unitsFilterTimeout = setTimeout(function () {
  604. var v = $('#units-filter').val();
  605. if (v.length < 3) {
  606. v = '';
  607. }
  608. $('#units-tree').jstree(true).search(v);
  609. }, 50);
  610. }
  611. function unitsSelect() {
  612. $('.jstree-search').closest('li').each(function(idx,e){$('#units-tree').jstree('check_node', $(e))});
  613. }
  614. function unitsReset() {
  615. $('#units-filter').val('');
  616. considerUnitsFilter();
  617. $('#units-tree').jstree(true).deselect_all()
  618. $('#units-tree').jstree("close_all");
  619. rootsTags_open();
  620. }
  621. var updateParametersTimeout = false;
  622. function updateParametersLists() {
  623. if (updateParametersTimeout) {
  624. clearTimeout(updateParametersTimeout);
  625. }
  626. updateParametersTimeout = setTimeout(function () {
  627. var list = $('#parameters-units');
  628. var unitsTags = [];
  629. var selected = $("#units-tree").jstree("get_checked", true);
  630. for (var i = 0; i < selected.length; i++) {
  631. var el = selected[i];
  632. var li=document.createElement('li');
  633. li.className = 'parameter'
  634. li.innerText = el.data.unitCode+': '+el.data.unitBriefName;
  635. unitsTags[unitsTags.length] = li;
  636. var input=document.createElement('input');
  637. input.name='units[]';
  638. input.type='hidden';
  639. input.value=el.data.unitId;
  640. unitsTags[unitsTags.length] = input;
  641. }
  642. list.html(unitsTags)
  643. }, 50);
  644. }
  645. var rootsTags = null
  646. function rootsTags_open() {
  647. for (var i = 0; i < rootsTags.length; i++) {
  648. $("#units-tree").jstree("open_node", rootsTags[i].id);
  649. }
  650. }
  651. function update_unitscatalog() {
  652. request("units?activeOnly=true&realOnly=true&startDate="+startDate+"&endDate="+endDate+"&setIfHasFormularsRecursive=true", function(units){
  653. var roots = [];
  654. var unitsMap = {};
  655. for (var i = 0; i < units.length; i++) {
  656. var unit = units[i];
  657. if (!unit.HasFormularsRecursive) {
  658. continue;
  659. }
  660. unit.Children = [];
  661. if (unit.Name == null) {
  662. unit.Name = "";
  663. }
  664. if (unit.BriefName == null) {
  665. unit.BriefName = "";
  666. }
  667. unit.Name = unit.Name.trim();
  668. unit.Name = unit.Name.split(' - филиал')[0];
  669. unit.BriefName = unit.BriefName.trim();
  670. unitsMap[unit.Id] = unit;
  671. }
  672. for (var key in unitsMap) {
  673. var parentId = unitsMap[key].ParentId;
  674. if (unitsMap[parentId] == undefined) {
  675. roots[roots.length] = unitsMap[key];
  676. continue;
  677. }
  678. unitsMap[parentId].Children[unitsMap[parentId].Children.length] = unitsMap[key];
  679. }
  680. var unitsTag = generateUnitsTags(roots);
  681. $('#units-tree').html(unitsTag).on("changed.jstree", function (e, data) {
  682. updateParametersLists();
  683. }).jstree({
  684. plugins: ["checkbox","search"],
  685. search: {
  686. show_only_matches: true,
  687. show_only_matches_children: true,
  688. },
  689. });
  690. rootsTags = $('#units-tree').children().children();
  691. rootsTags_open();
  692. });
  693. }
  694. function setup_inputs() {
  695. $('input').keydown(function (e) {
  696. if(e.keyCode==27){
  697. $(e.currentTarget).val("");
  698. }
  699. });
  700. }
  701. setup_cyrilliconly();
  702. update_unitscatalog();
  703. setup_inputs();
  704. setupSearchEmployees();
  705. </script>