//'});">
//
//
//
//
// Дата завершения
//
// -->
//'});">
//
//
//
// " id="docID" placeholder="ID документа">*/?>
-->
// $('div.warlog, div.informer').hide();
// //
// /* show all pages by click */
// function ShowAllPages(docID){
// //console.log(docID);
// getDbData({
// url: window.location.protocol + '//'+window.ELASTIC_IP+'/ind/pamyat/page_document/_search',
// type: 'POST',
// contentType: "text/plain; charset=utf-8",
// dataType : "json",
// data: '{"query":{"bool":{"must":[{"match":{"document_id":' + docID + '}}]}},"sort":[{"id":{"order":"asc"}}], "size": "10000"}',
// success: function (data) {
// if (data.hits.total > 0){
// $('.controls').toggleClass('show', true);
// $('td.page span').html(data.hits.total);
//
// $.each(data.hits.hits, function(i, hit) {
//
// var parentCont = $('table.controls select');
// var page_link = '
';
// var page_linkTemp = $.parseHTML(page_link);
// var pageCont = $(page_linkTemp).clone();
//
// $(pageCont)
// .html(i+1)
// .attr('data-source', window.location.protocol + '//'+window.ELASTIC_IP+'/images/' + hit._source.image_path)
// .attr('id', 'p' + (i+1));
//
// $(pageCont).appendTo(parentCont);
// $('.page-selector').selectric();
// });
// }else{
// // if no pages (except for 1) then hide table with page selector
// $('.controls').toggleClass('show', false);
//
// }
// },
// error: function (x, a, e) {
// console.log("Error: " + e);
// }
// });
// }
// /* show all pages by click */
// //
// /**** ДОУ start ПОИСК ****/
// // showOY();
// // arDocumentsByTypes = [];
// arDocumentTypeNames = new Array;
//
// function showOY() {
// var parentObj = $('.warlog-list');
// var operation = $('#operation').val();
// var division = $('#division').val();
// var author = $('#author').val();
// var docnum = $('#docnum').val();
// var doc_type = $('#doc_type').val();
//
//
//
// var slide = '
'+
// ''+
// '
'+
// ' '+
// '
'+
// ''+
// '
'+
// ' ';
//
// // var date_begin = '//';
// var date_end = '//';
//
//
// var que = {query:{filtered:{query:{bool:{should:[]}}, filter:{and:{filters:[]}}}}, fields:["id","document_type","document_number","document_date_b","document_date_f","document_name","archive","fond","opis","delo","date_from","date_to","authors","geo_names","operation_name","secr","image_path","delo_id","deal_type"], size:100, sort:{document_date_b:"asc"}};
// if(division!='') {
// var b = {bool:{must:[{'match_phrase':{authors:division}}]}};
// }
// if(author!=''){
// if(division!='') {
// var d = {bool: {must: [{'match': {authors: {query: author, operator: "and"}}}]}};
// }else{
// var b = {bool: {must: [{'match': {authors: {query: author, operator: "and"}}}]}};
// }
// }
// if(division=='' && author=='') {
// var b = {bool: {must: []}};
// }
// if(doc_type != '' && doc_type!='0') {
// b.bool.must.push({'match_phrase': {'document_type': doc_type}});
// if(d && d.bool) d.bool.must.push({'match_phrase': {'document_type': doc_type}});
// }
// if(operation!='') {
// b.bool.must.push({match:{'operation_name':{query:operation, operator:"and"}}});
// if(d && d.bool) d.bool.must.push({match:{'operation_name':{query:operation, operator:"and"}}});
// }
// if(docnum!='') {
// b.bool.must.push({match:{'document_number':{query:docnum, operator:"and"}}});
// if(d && d.bool) d.bool.must.push({match:{'document_number':{query:docnum, operator:"and"}}});
// }
// if(b && b.bool) que.query.filtered.query.bool.should.push(b);
// if(d && d.bool) que.query.filtered.query.bool.should.push(d);
//
//
// if(date_begin!='' || date_end!=''){
// que.query.filtered.filter.and.filters.push({exists: {field: "document_date_b"}});
// que.query.filtered.filter.and.filters.push({
// range: {
// "document_date_b": {
// "gte": date_begin,
// "lte": date_end
// }
// }
// });
// que.query.filtered.filter.and.filters.push({
// range: {
// "document_date_f": {
// "gte": date_begin,
// "lte": date_end
// }
// }
// });
// }
//
//
// /*var q = '';
// q+=' {';
// q+=' "query":{';
// q+=' "filtered":{';
// q+=' "query":{';
// q+=' "bool":{';
// q+=' "should":[';
//
// // q+= '{"match_phrase_prefix": {"operation_name": "' + operation + '"}}';
// //
// // // q+= ',';
// // q+= '{"match_phrase": {"authors": "' + division + '"}}';
// //
// // // q+= ',';
// // q+= '{"match_phrase": {"authors": "' + author + '"}}';
// //
// // // q+= ',';
// // q+= '{"match_phrase": {"document_type": "' + doc_type + '"}}';
// //
// // // q+= ',';
// // q+= '{"match": {"document_number": "' + docnum + '"}}';
// //
// q+=' ]';
// q+=' }';
//
//
//
// //
// q+=' },';
// q+=' "filter":{';
// q+=' "and":{';
// q+=' "filters":[';
// q+=' {';
// q+=' "exists":{';
// q+=' "field":"document_date_b"';
// q+=' }';
// q+=' },';
// q+=' {';
// q+=' "range":{';
// q+=' "document_date_b":{';
// q+=' "gte":"//",';
// q+=' "lte":"//"';
// q+=' }';
// q+=' }';
// q+=' },';
// q+=' {';
// q+=' "range":{';
// q+=' "document_date_f":{';
// q+=' "gte":"//",';
// q+=' "lte":"//"';
// q+=' }';
// q+=' }';
// q+=' }';
// q+=' ]';
// q+=' }';
// q+=' }';
//
// // q+=' }';
//
// // q+=' }';
// q+=' },"size": 100,"sort": {"document_date_b": "asc"}';
// q+=' }';*/
// console.log(que);
// var q = JSON.stringify(que);
//
// getDbData({
// url: window.location.protocol + '//'+window.ELASTIC_IP+'/ind/pamyat/document,map/_search',
// type: 'POST',
// contentType: "text/plain; charset=utf-8",
// dataType : "json",
// data: q,
// success: function (data) {
// if (data.hits.total == 0){
// $('.informer').text('Поиск не дал результатов. Попробуйте расширить критерии поиска.');
// $('.warlog').hide();
// return false;
// } else if (data.hits.total <= 100) {
// $('informer').hide();
// } else {
// $('.informer').text('По вашему запросу найдено результатов: '+data.hits.total+'. Пожалуйста, уточните критерии поиска. Показаны первые 100 документов.');
// }
// $('.warlog-dou-side span span').empty().text(data.hits.total);
//
// arDocumentsByTypes = [];
// arDocumentTypeNames = [];
//
// $.each(data.hits.hits, function(i, hit) {
// var pos = position_in_array(hit.fields.document_type[0], arDocumentTypeNames);
// if(typeof(pos) == 'boolean') {
// arDocumentTypeNames.push(hit.fields.document_type[0]);
// pos = position_in_array(hit.fields.document_type[0], arDocumentTypeNames);
// arDocumentsByTypes[pos] = [];
// }
// arDocumentsByTypes[pos].push(hit.fields);
// });
//
// $.each(arDocumentTypeNames, function(i, hit) {
// if((doc_type!='0' && doc_type == arDocumentTypeNames[i]) || doc_type == '0') {
// var objSlide = $(slide).clone();
// $.each(objSlide, function () {
// if ($(this).attr('data-apply') == 'next-toggle') {
// $(this).attr('data-doc-id', i);
// $(this).find('.warlog-list-item-title').text(arDocumentTypeNames[i]);
// $(this).append('
документов: ' + arDocumentsByTypes[i].length + ' ');
// }
// else {
// var self = this;
// $(self).find('.side_doc_wrapper').attr('id', 'box-' + i);
// var dbegin = '';
// //var currentPage = 1;
// $.each(arDocumentsByTypes[i], function (j, doc) {
// var desc = JSON.stringify({
// "Заголовок": arDocumentTypeNames[i],
// 'Документ оперативного управления': doc.document_name[0]
// });
// dbegin = doc.document_date_b!=undefined?$.datepicker.formatDate('dd.mm.yy', new Date(doc.document_date_b[0])):'';
// $(self).find('.side_doc_wrapper')
// .append($('
')
// .append($('
' + '
'+doc.document_name[0] + ' '+dbegin+'
')
// .append($('
').data('doc-desc', desc))));
// })
// }
// });
// $(objSlide).appendTo(parentObj);
// }
// });
//
// // re-init drag func to archive
// if (typeof RP == 'object') RP.reInitDraggables();
//
// // Scroll
// $('[data-apply="scroll"]').tinyscrollbar({
// wheelLock: false
// });
// // Next toggle
// $('[data-apply="next-toggle"]').on('click', function(){
// var self = this;
//
// $(self).next().slideToggle('fast', function(){
// if(!$(self).hasClass('expanded')) {
// $(self).addClass('expanded');
// $('[data-preview="anchor"]', $(this))[0].click();
// }
// else {
// $(self).removeClass('expanded');
// }
//
// var objScrollbar = $('[data-apply="scroll"]').data("plugin_tinyscrollbar");
// if (typeof(objScrollbar) != "undefined") {
// objScrollbar.update();
//
// //if (objScrollbar.hasContentToSroll === true){
// var intOffsetTop = $(self)[0].offsetTop;
// objScrollbar.update(intOffsetTop);
// //}
// }
// });
// });
//
// if (arDocumentsByTypes.length == 1) {
// setTimeout(function () {
// $('.warlog-list-item-title').first().trigger('click');
// }, 500);
// } else {
// var objScrollbar = $('[data-apply="scroll"]').data("plugin_tinyscrollbar");
// if (typeof(objScrollbar) != "undefined") objScrollbar.update();
// }
//
// },
// error: function (x, a, e) {
// console.log("Error: " + e);
// }
// });
// }
// /**** ДОУ start by ID ****/
// /* if got here by link from another page with var docID in URL */
// // showOYbyID();
// // function showOYbyID() {
// var parentObj = $('.warlog-list');
//
// // var docID = //;
// //
//// var slide = '
'+
//// '
'+
//// '
'+
//// '
'+
//// '
'+
//// '
'+
//// '
'+
//// '
'+
//// '
';
//
//
// var slide = '
'+
// ''+
// '
'+
// ' '+
// '
'+
// ''+
// '
'+
// ' ';
//
//
// var objSlide = $.parseHTML(slide);
//
// getDbData({
// url: window.location.protocol + '//'+window.ELASTIC_IP+'/ind/pamyat/document/' + docID,
// type: 'GET',
// contentType: "text/plain; charset=utf-8",
// dataType : "json",
// success: function (data) {
// // найдено 1 документов
// $('.warlog-dou-side span span').empty().html('1');
// $('div.informer').empty().text('Внимание, показан 1 документ по ID, остальные параметры не учтены!');
// //console.log(docID);
// var allPages = ShowAllPages(docID);
// //console.log(allPages);
// var desc = JSON.stringify({"Заголовок": data._source.document_type, 'Документ оперативного управления': data._source.document_name});
//
//// $('img.side_doc_preview_image', objSlide)
//// .attr('data-source', window.location.protocol + '//'+window.ELASTIC_IP+'/images/' + getUrl( data._source.image_path ))
//// .attr('data-doc-id', + data._source.id)
//// .prop('src', window.location.protocol + '//'+window.ELASTIC_IP+'/images/' + getPreviewUrl(getUrl( data._source.image_path )));
//// $('.side_doc_preview_block_wrapper', objSlide)
//// .attr('data-source', window.location.protocol + '//'+window.ELASTIC_IP+'/images/' + getUrl( data._source.image_path ))
//// .attr('data-doc-id', + data._source.id)
//// .text(data._source.document_name);
//// $('div.side_doc_preview_date.name', objSlide).html(data._source.document_type);
//// $('div.side_doc_preview_date.date', objSlide).html($.datepicker.formatDate('dd.mm.yy', new Date(data._source.document_date_b)));
//// $('div.side_doc_preview_title', objSlide).html(data._source.document_name);
////
//// $('div.view_this_to_archive', objSlide)
//// .data('doc-desc', desc)
/////* .data('doc-id', data._source.id)*/
//// .data('doc-name', data._source.document_name)
//// .attr('data-doc-name', data._source.document_name)
//// .data('doc-desc', desc)
//// .data('doc-url', window.location.protocol + '//'+window.ELASTIC_IP+'/images/' + data._source.image_path);
//
//
//
// $('.warlog-list-item-title', objSlide).text(data._source.document_type);
// $('.warlog-list-item-title', objSlide).after('
документов: 1 ');
//
//
// var desc = JSON.stringify({
// "Заголовок": data._source.document_type,
// 'Документ оперативного управления': data._source.document_name
// });
//
// $(objSlide)
// .attr('data-doc-id', 0)
// .find('.side_doc_wrapper')
// .append($('
')
// .append($('
' +
// '
'+data._source.document_name + ' '+$.datepicker.formatDate('dd.mm.yy', new Date(data._source.document_date_b))+'
')
// .append($('
').data('doc-desc', desc))));
//
//
// //$('#image').prop('src', window.location.protocol + '//'+window.ELASTIC_IP+'/images/' + data._source.image_path );
//
// $(objSlide).appendTo(parentObj);
//
// // re-init drag func to archive
// if (typeof RP == 'object') RP.reInitDraggables();
//
// setTimeout(function(){
// $('[data-preview="anchor"]').trigger('click');
// }, 500);
//
//
//
// $('[data-apply="next-toggle"]').on('click', function(){
// var self = this;
//
// $(self).next().slideToggle('fast', function(){
// if(!$(self).hasClass('expanded')) {
// $(self).addClass('expanded');
// $('[data-preview="anchor"]', $(this))[0].click();
// }
// else {
// $(self).removeClass('expanded');
// }
//
// var objScrollbar = $('[data-apply="scroll"]').data("plugin_tinyscrollbar");
// if (typeof(objScrollbar) != "undefined") {
// objScrollbar.update();
//
// //if (objScrollbar.hasContentToSroll === true){
// var intOffsetTop = $(self)[0].offsetTop;
// objScrollbar.update(intOffsetTop);
// //}
// }
// });
// });
//
// setTimeout(function () {
// $('.warlog-list-item-title').first().trigger('click');
// }, 500);
//
// },
// error: function (x, a, e) {
// console.log("Error: " + e);
// }
// });
// }
//
// function position_in_array(value, array)
// {
// for(var i = 0; i < array.length; i++)
// {
// if(array[i] == value) return i;
// }
// return false;
// }
//