(function(e,t,n,r,i){var s={},o=function(t){return e.Function("return "+t)()},u=e.document,a,f=function(t,i){var o={exports:{}};s[t]=1,n[t]=o.exports;if(!i)i=i||e[t];else if(typeof i=="function"){var u=l;r[t]&&r[t].sandbox&&typeof u=="function"&&(u=a),i=i(u,o.exports,o)||o.exports}return i=i,n[t]=i},l=function(e){var t=n[e],r=[e,t];return r&&(e=r[0],t=r[1]),s[e]&&t?t:(typeof t=="string"&&t.indexOf("(function(")===0&&(t=o(t)),f(e,t))},c={exports:{}};for(var h in n)s[h]=0;t(l,c.exports,c)})(this,function(require,exports,module){function MetaEngine(){this.version="0.9.200",this.toString=function(){return"Oknosoft data engine. v:"+this.version}}function Messages(){this.toString=function(){return"Интернационализация сообщений"},typeof window!="undefined"&&"dhtmlx"in window&&(this.show_msg=function(e,t){if(!e)return;if(typeof e=="string"){if($p.iface.synctxt){$p.iface.synctxt.show_message(e);return}e={type:"info",text:e}}t&&typeof t.setText=="function"&&t.setText(e.text),dhtmlx.message(e)},this.check_soap_result=function(e){if(!e)return $p.msg.show_msg({type:"alert-error",text:$p.msg.empty_response,title:$p.msg.error_critical}),!0;if(e.error=="limit_query")return $p.iface.docs.progressOff(),$p.msg.show_msg({type:"alert-warning",text:$p.msg.limit_query.replace("%1",e.queries).replace("%2",e.queries_avalable),title:$p.msg.srv_overload}),!0;if(e.error=="network"||e.error=="empty")return $p.iface.docs.progressOff(),$p.msg.show_msg({type:"alert-warning",text:$p.msg.error_network,title:$p.msg.error_critical}),!0;if(e.error&&e.error_description)return $p.iface.docs.progressOff(),e.error_description.indexOf("Недостаточно прав")!=-1&&(e.error_type="alert-warning",e.error_title=$p.msg.error_rights),$p.msg.show_msg({type:e.error_type||"alert-error",text:e.error_description,title:e.error_title||$p.msg.error_critical}),!0;if(e.error&&!e.messages)return $p.iface.docs.progressOff(),$p.msg.show_msg({type:"alert-error",title:$p.msg.error_critical,text:$p.msg.unknown_error.replace("%1","unknown_error")}),!0},this.show_not_implemented=function(){$p.msg.show_msg({type:"alert-warning",text:$p.msg.not_implemented,title:$p.msg.main_title})})}function InterfaceObjs(){this.toString=function(){return"Объекты интерфейса пользователя"},this.clear_svgs=function(e){typeof e=="string"&&(e=document.getElementById(e));while(e.firstChild)e.removeChild(e.firstChild)},this.get_offset=function(e){var t={left:0,top:0};if(e.offsetParent)do t.left+=e.offsetLeft,t.top+=e.offsetTop;while(e=e.offsetParent);return t},this.normalize_xml=function(e){if(!e)return"";var t={"&":"&amp;",'"':"&quot;","'":"&apos;","<":"&lt;",">":"&gt;"};return e.replace(/[&"'<>]/g,function(e){return t[e]})},this.scale_svg=function(e,t,n){var r,i,s,o,u,a,f,l,c,h={};u=e.indexOf(">"),f=e.substring(5,u),s=f.split(" "),o=e.substr(u+1),o=o.substr(0,o.length-6);for(r in s){e=s[r].split("=");if(e[0]=="width"||e[0]=="height")e[1]=Number(e[1].replace(/"/g,"")),h[e[0]]=e[1]}return(a=f.indexOf("viewBox="))!=-1?(l=f.substring(a+9),c='viewBox="'+l.substring(0,l.indexOf('"'))+'"'):c='viewBox="0 0 '+(h.width-n)+" "+(h.height-n)+'"',i=t/(h.height-n),h.height=t,h.width=Math.round(h.width*i),'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="'+h.width+'" height="'+h.height+'" xml:space="preserve" '+c+">"+o+"</svg>"},this.bind_help=function(e,t){function n(e){if(!e.help_path){$p.msg.show_msg({title:"Справка",type:"alert-info",text:$p.msg.not_implemented});return}}e instanceof dhtmlXCellObject||(!e.help_path&&t&&(e.help_path=t),e.button("help").show(),e.button("help").enable(),e.attachEvent("onHelp",n))},this.set_hash=function(e,t,n,r){e||(e=""),t||(t=""),n||(n=""),r||(r="");var i="obj="+e+"&ref="+t+"&frm="+n+"&view="+r;location.hash.substr(1)==i?this.hash_route():location.hash=i},this.hash_route=function(e){var t=$p.job_prm.parse_url(),n=$p.eve.hash_route.execute(t),r;n!==!1&&(!$p.iface.before_route||$p.iface.before_route(e)!==!1)&&$p.ajax.authorized&&(t.ref&&typeof _md!="undefined"?(r=_md.mgr_by_class_name(t.obj),r&&r[t.frm||"form_obj"]($p.iface.docs,t.ref)):t.view&&$p.iface.swith_view&&$p.iface.swith_view(t.view));if(e)return $p.cancel_bubble(e)},this.oninit=null,this.ontimer=null,setTimeout(function(){$p.iface.ontimer&&typeof $p.iface.ontimer=="function"&&setInterval($p.iface.ontimer,9e4)},2e4)}function Modifiers(){var e=[];this.push=function(t){e.push(t)},this.detache=function(t){var n=e.indexOf(t);n!=-1&&e.splice(n,1)},this.execute=function(t){var n,r;return e.forEach(function(e){typeof e=="function"?r=e(t):r=require(e)(t),n!==!1&&(n=r)}),r}}function AppEvents(){this.toString=function(){return"События при начале работы программы"},this.__define("onload",{value:new Modifiers,enumerable:!1,configurable:!1}),this.__define("hash_route",{value:new Modifiers,enumerable:!1,configurable:!1})}function JobPrm(){function e(){return $p.wsql.get_user_param("rest_path")||$p.job_prm.rest_path||"/a/zd/%1/odata/standard.odata/"}this.parse_url=function(){function e(e){var t={},n=[],r;if(e.substr(0,1)==="#"||e.substr(0,1)==="?")e=e.substr(1);if(e.length>2){r=decodeURI(e).split("&");for(var i in r){n=r[i].split("=");if(n[0]=="m")try{t[n[0]]=JSON.parse(n[1])}catch(s){t[n[0]]={}}else t[n[0]]=n[1]||""}}return t}return e(location.search)._mixin(e(location.hash))},this.check_browser_compatibility=!0,this.check_app_installed=!1,this.check_dhtmlx=!0,this.use_builder=!1,this.offline=!1,this.local_storage_prefix="",this.url_prm=this.parse_url(),typeof $p.settings=="function"&&$p.settings(this,$p.modifiers);for(var t in this)t!=="url_prm"&&typeof this[t]!="function"&&this.url_prm.hasOwnProperty[t]&&(this[t]=this.url_prm[t]);this.hs_url=function(){var e=this.hs_path||"/a/zd/%1/hs/upzp",t=$p.wsql.get_user_param("zone","number");return t?e.replace("%1",t):e.replace("%1/","")},this.rest_url=function(){var t=e(),n=$p.wsql.get_user_param("zone","number");return n?t.replace("%1",n):t.replace("%1/","")},this.irest_url=function(){var t=e(),n=$p.wsql.get_user_param("zone","number");return t=t.replace("odata/standard.odata","hs/rest"),n?t.replace("%1",n):t.replace("%1/","")}}function WSQL(){function e(e,t){if(t=="object"){try{e=JSON.parse(e)}catch(n){e={}}return e}return t=="number"?$p.fix_number(e,!0):t=="date"?$p.fix_date(e,!0):t=="boolean"?$p.fix_boolean(e):e}var t=this,n={},r=0;t.exec=function(e,n,i,s){if(r<10){r++,setTimeout(function(){t.exec(e,n,i,s)},1e3);return}if(r<100)throw new TypeError("alasql init error");Array.isArray(n)||(n=[n]);var o,u=[];try{i?alasql(e,n,function(e){i(e,s)}):alasql(e,n)}catch(a){i&&i(a)}},t.promise=function(e,t){return new Promise(function(n,r){alasql(e,t||[],function(e,t){t?r(t):n(e)})})},t.set_user_param=function(e,t){return new Promise(function(r,i){var s=t;typeof t=="object"?s=JSON.stringify(t):t===!1&&(s=""),typeof localStorage!="undefined"&&localStorage.setItem($p.job_prm.local_storage_prefix+e,s),n[e]=t,r()})},t.get_user_param=function(t,r){return!n.hasOwnProperty(t)&&typeof localStorage!="undefined"&&(n[t]=e(localStorage.getItem($p.job_prm.local_storage_prefix+t),r)),n[t]},t.save_options=function(e,n){return t.set_user_param(e+"_"+n.name,n)},t.restore_options=function(e,n){var r=t.get_user_param(e+"_"+n.name,"object");for(var i in r)if(typeof r[i]!="object")n[i]=r[i];else{n[i]||(n[i]={});for(var s in r[i])n[i][s]=r[i][s]}return n},t.init_params=function(){var e=[{p:"user_name",v:"",t:"string"},{p:"user_pwd",v:"",t:"string"},{p:"browser_uid",v:$p.generate_guid(),t:"string"},{p:"zone",v:$p.job_prm.hasOwnProperty("zone")?$p.job_prm.zone:1,t:"number"},{p:"enable_save_pwd",v:"",t:"boolean"},{p:"reset_local_data",v:"",t:"boolean"},{p:"autologin",v:"",t:"boolean"},{p:"cache_cat_date",v:0,t:"number"},{p:"files_date",v:20151115e4,t:"number"},{p:"margin",v:60,t:"number"},{p:"discount",v:15,t:"number"},{p:"offline",v:$p.job_prm.offline||"",t:"boolean"},{p:"skin",v:"dhx_web",t:"string"},{p:"rest_path",v:"",t:"string"}],n;return $p.job_prm.additional_params&&(e=e.concat($p.job_prm.additional_params)),localStorage.getItem($p.job_prm.local_storage_prefix+"zone")||(n=$p.job_prm.hasOwnProperty("zone")?$p.job_prm.zone:1),$p.job_prm.url_prm.hasOwnProperty("zone")&&(n=$p.fix_number($p.job_prm.url_prm.zone,!0)),n!==undefined&&t.set_user_param("zone",n),e.forEach(function(e){(t.get_user_param(e.p,e.t)==undefined||!t.get_user_param(e.p,e.t)&&e.p.indexOf("url")!=-1)&&t.set_user_param(e.p,$p.job_prm.hasOwnProperty(e.p)?$p.job_prm[e.p]:e.v)}),t.set_user_param("cache_cat_date",0),t.set_user_param("reset_local_data",""),new Promise(function(e,t){typeof alasql!="undefined"?$p.job_prm.create_tables?$p.job_prm.create_tables_sql?alasql($p.job_prm.create_tables_sql,[],function(){r=1e3,delete $p.job_prm.create_tables_sql,e()}):$p.ajax.get($p.job_prm.create_tables).then(function(t){alasql(t.response,[],function(){r=1e3,e()})}):e():e()})},t.drop_tables=function(e){function t(){i--,i<=0?setTimeout(e,10):n()}function n(){var e=s[i-1].tableid;e.substr(0,1)=="_"?t():alasql("drop table IF EXISTS "+e,[],t)}function r(e){s=e,(i=e.length)?n():t()}var i=0,s=[];alasql("SHOW TABLES",[],r)},t.backup_database=function(e){},t.restore_database=function(){},t.idx_connect=function(e,n){return new Promise(function(r,i){var s=indexedDB.open(e,1);s.onerror=function(e){i(e)},s.onsuccess=function(){r(s.result)},s.onupgradeneeded=function(r){return r.currentTarget.result.createObjectStore(n,{keyPath:"ref"}),t.idx_connect(e,n)}})},t.idx_save=function(e,n,r){return new Promise(function(i,s){function o(t){var n=t.transaction([r],"readwrite").objectStore(r).put(e instanceof DataObj?e._obj:e);n.onerror=function(e){s(e)},n.onsuccess=function(){i(n.result)}}!r&&e._manager&&(r=e._manager.table_name),n?o(n):t.idx_connect(t.idx_name||$p.job_prm.local_storage_prefix||"md",r).then(o)})},t.idx_get=function(e,n,r){return new Promise(function(i,s){function o(t){var n=t.transaction([r],"readonly").objectStore(r).get(e);n.onerror=function(e){s(e)},n.onsuccess=function(){i(n.result)}}n?o(n):t.idx_connect(t.idx_name||$p.job_prm.local_storage_prefix||"md",r).then(o)})},t.idx_delete=function(e,n,r){return new Promise(function(i,s){function o(t){var n=t.transaction([r],"readwrite").objectStore(r).delete(e instanceof DataObj?e.ref:e);n.onerror=function(e){s(e)},n.onsuccess=function(){i(n.result)}}!r&&e._manager&&(r=e._manager.table_name),n?o(n):t.idx_connect(t.idx_name||$p.job_prm.local_storage_prefix||"md",r).then(o)})},typeof alasql!="undefined"?t.aladb=new alasql.Database("md"):r=1e3}function eXcell_ocombo(e){if(!e)return;var t=this;t.cell=e,t.grid=e.parentNode.grid,t.setValue=function(e){t.setCValue(e instanceof DataObj?e.presentation:e||"")},t.getValue=function(){return t.grid.get_cell_value()},t.shiftNext=function(){t.grid.editStop()},t.edit=function(){if(t.combo)return;t.val=t.getValue(),t.cell.innerHTML="",t.combo=new OCombo({parent:t.cell}._mixin(t.grid.get_cell_field())),t.combo.getInput().focus()},t.detach=function(){if(t.combo&&t.combo.getComboText){t.setValue(t.combo.getComboText()),t.combo.getSelectedValue()||t.combo.callEvent("onChange");var e=!$p.is_equal(t.val,t.getValue());return t.combo.unload(),e}return!0}}function eXcell_pwd(e){var t;e&&(this.cell=e,this.grid=e.parentNode.grid,eXcell_ed.call(this),t=this.edit,this.edit=function(){t.call(this),this.obj.type="password"},this.setValue=function(){this.setCValue("*********")},this.getValue=function(){return this.grid.get_cell_value()},this.detach=function(){if(this.grid.get_cell_field){var e=this.grid.get_cell_field();e.obj[e.field]=this.obj.value}return this.setValue(),t=null,this.val!=this.getValue()})}function ODropdownList(e){function t(t){o.innerHTML=e.values[o.getAttribute("current")],e.event_name&&!t&&dhx4.callEvent(e.event_name,[o.getAttribute("current")])}function n(){s.classList.remove("open")}var r=document.createElement("ul"),i,s,o;e.container.innerHTML='<div class="dropdown_list">'+e.title+'<a href="#" class="dropdown_list"></a></div>',s=e.container.firstChild,o=s.querySelector("a"),o.setAttribute("current",Array.isArray(e.values)?"0":Object.keys(e.values)[0]),s.onclick=function(e){if(!s.classList.contains("open"))s.classList.add("open");else{if(e.target.tagName=="LI")for(var i in r.childNodes)if(r.childNodes[i]==e.target){o.setAttribute("current",e.target.getAttribute("current")),t();break}n()}return $p.cancel_bubble(e)},s.appendChild(r),r.className="dropdown_menu",e.class_name&&(s.classList.add(e.class_name),r.classList.add(e.class_name));for(var u in e.values){i=document.createElement("li");var a=e.values[u].indexOf("<i");i.innerHTML=e.values[u].substr(a)+" "+e.values[u].substr(0,a),i.setAttribute("current",u),r.appendChild(i)}document.body.addEventListener("keydown",function(e){e.keyCode==27&&s.classList.remove("open")}),document.body.addEventListener("click",n),this.unload=function(){var t;while(t=s.lastChild)s.removeChild(t);e.container.removeChild(s),i=r=s=o=e=null},t(!0)}function OCombo(e){function t(e){var t={_top:30},n;if(l&&l.metadata().hierarchical&&l.metadata().group_hierarchy)if(f.choice_groups_elm=="elm")t.is_folder=!1;else if(f.choice_groups_elm=="grp"||a=="parent")t.is_folder=!0;for(var r in f.choice_links)n=f.choice_links[r],n.name&&n.name[0]=="selection"&&(u instanceof TabularSectionRow?n.path.length<2?t[n.name[1]]=typeof n.path[0]=="function"?n.path[0]:u._owner._owner[n.path[0]]:t[n.name[1]]=u[n.path[1]]:t[n.name[1]]=typeof n.path[0]=="function"?n.path[0]:u[n.path[0]]);return e&&(t.presentation={like:e}),t}function n(e){if(this.name=="select")l?l.form_selection(d,{initial_value:u[a].ref,selection:[t()]}):n.call({name:"type"});else if(this.name=="add")l&&l.create({},!0).then(function(e){e._set_loaded(e.ref),e.form_obj()});else if(this.name=="open")u&&u[a]&&!u[a].empty()&&u[a].form_obj();else if(this.name=="type"){var r=[],i,s,o=u,c=a;f.type.types.forEach(function(e){i=_md.mgr_by_class_name(e),s=i.metadata(),r.push({presentation:s.synonym||s.name,mgr:i,selected:l===i})}),$p.iface.select_from_list(r).then(function(e){if(!o[c]||o[c]&&o[c]._manager!=e.mgr)l=e.mgr,u=o,a=c,f=u._metadata.fields[a],l.form_selection({on_select:function(e){u[a]=e,u=null,a=null,f=null}},{selection:[t()]});l=null,i=null,s=null,o=null,c=null})}if(e)return $p.cancel_bubble(e)}function r(){h=!1,setTimeout(function(){h||$p.iface.popup.hide()},300)}function i(){if(l instanceof EnumManager)return;h=!0;var e=document.createElement("div"),t="<a href='#' name='select' title='Форма выбора {F4}'>Показать все</a><img src='"+dhtmlx.image_path+"dhxtoolbar"+dhtmlx.skin_suffix()+"blank9.png' />"+"&nbsp;<a href='#' name='open' title='Открыть форму элемента {Ctrl+Shift+F4}'><img src='"+dhtmlx.image_path+"dhxtoolbar"+dhtmlx.skin_suffix()+"tb_open.png' /></a>";$p.ajax.root&&(t+="&nbsp;<a href='#' name='add' title='Создать новый элемент {F8}'><img src='"+dhtmlx.image_path+"dhxtoolbar"+dhtmlx.skin_suffix()+"tb_add.png' /></a>"),f.type.types.length>1&&(t+="&nbsp;<a href='#' name='type' title='Выбрать тип значения {Alt+T}'><img src='"+dhtmlx.image_path+"custom_web/icss_text.png' /></a>"),e.innerHTML=t;for(var i=0;i<e.children.length;i++)e.children[i].onclick=n;$p.iface.popup.clear(),$p.iface.popup.attachObject(e),$p.iface.popup.show(dhx4.absLeft(p.getButton())-77,dhx4.absTop(p.getButton()),p.getButton().offsetWidth,p.getButton().offsetHeight),$p.iface.popup.p.onmouseover=function(){h=!0},$p.iface.popup.p.onmouseout=r}function s(e){if(!p||!p.getBase)return;p.getBase().parentElement?u instanceof TabularSectionRow||e.forEach(function(e){e.name==a&&o(u[a])}):setTimeout(p.unload)}function o(e){if(e&&e instanceof DataObj&&!e.empty()){p.getOption(e.ref)||p.addOption(e.ref,e.presentation);if(p.getSelectedValue()==e.ref)return;p.setComboValue(e.ref)}else p.getSelectedValue()||(p.setComboValue(""),p.setComboText(""))}var u,a,f,l,c,h,p=this,d={on_select:e.on_select||function(e){u[a]=e}};OCombo.superclass.constructor.call(p,e),e.on_select?(p.getBase().style.border="none",p.getInput().style.left="-3px",e.is_tabular||(p.getButton().style.right="9px")):p.getBase().style.marginBottom="4px",e.left&&(p.getBase().style.left=left+"px"),this.attachEvent("onChange",function(){u[a]=this.getSelectedValue()}),this.attachEvent("onBlur",function(){!this.getSelectedValue()&&this.getComboText()&&this.setComboText("")}),this.attachEvent("onDynXLS",function(e){l||(l=_md.value_mgr(u,a,f.type)),l&&(p.clearAll(),l.get_option_list(null,t(e)).then(function(e){p.addOption&&(p.addOption(e),p.openSelect())}))}),dhtmlxEvent(p.getButton(),"mouseover",i),dhtmlxEvent(p.getButton(),"mouseout",r),dhtmlxEvent(p.getBase(),"click",function(e){return $p.cancel_bubble(e)}),dhtmlxEvent(p.getBase(),"contextmenu",function(e){return setTimeout(i,10),e.preventDefault(),!1}),dhtmlxEvent(p.getInput(),"keyup",function(e){if(l instanceof EnumManager)return;if(e.keyCode==115)return e.ctrlKey&&e.shiftKey?u[a].empty()||u[a].form_obj():!e.ctrlKey&&!e.shiftKey&&l&&l.form_selection(d,{initial_value:u[a].ref,selection:[t()]}),$p.cancel_bubble(e)}),dhtmlxEvent(p.getInput(),"focus",function(e){setTimeout(function(){p&&p.getInput&&p.getInput().select()},50)}),this.attach=function(e){u&&Object.unobserve(u,s),u=e.obj,a=e.field,c=e.property,e.meta?f=e.meta:c?(f=u._metadata.fields[a]._clone(),f.type=c.type):f=u._metadata.fields[a],p.clearAll(),l=_md.value_mgr(u,a,f.type),l&&l.get_option_list(u[a],t()).then(function(e){p.addOption&&(p.addOption(e),o(u[a]))}),u instanceof TabularSectionRow?Object.observe(u._owner._owner,s,["row"]):Object.observe(u,s,["update"])};var v=this.unload;this.unload=function(){r(),u&&Object.unobserve(u,s),p.conf&&p.conf.tm_confirm_blur&&clearTimeout(p.conf.tm_confirm_blur),u=null,a=null,f=null,l=null,d=null;try{v.call(p)}catch(e){}},e.obj&&e.field&&this.attach(e),this.enableFilteringMode("between","dummy",!1,!1)}function _clear_all(){$p.iface.docs.__define({clear_all:{value:function(){this.detachToolbar(),this.detachStatusBar(),this.detachObject(!0)},enumerable:!1},"Очистить":{get:function(){return this.clear_all},enumerable:!1},"Контейнер":{get:function(){return this.cell.querySelector(".dhx_cell_cont_layout")},enumerable:!1}})}function OTooolBar(e){function t(e){for(var t=0;t<s.children.length;t++){var n=s.children[t];n.classList.contains("selected")&&n.classList.remove("selected")}e&&!this.classList.contains("selected")&&this.classList.add("selected")}function n(){u=!1,setTimeout(function(){u||$p.iface.popup.hide()},300)}function r(){var t=this.name.replace(e.name+"_","");e.onclick&&e.onclick.call(i,t)}var i=this,s=document.createElement("div"),o,u,a,f;e.image_path||(e.image_path=dhtmlx.image_path+"custom_web/"),s.className="wb-tools",i.cell=s,i.buttons={},this.add=function(t){var l=$p.iface.add_button(s,e,t);l.onclick=r,l.onmouseover=function(){t.title&&!t.sub&&(u=!0,$p.iface.popup.clear(),$p.iface.popup.attachHTML(t.title),$p.iface.popup.show(dhx4.absLeft(l),dhx4.absTop(l),l.offsetWidth,l.offsetHeight),$p.iface.popup.p.onmouseover=function(){u=!0},$p.iface.popup.p.onmouseout=n)},l.onmouseout=n,i.buttons[t.name]=l;if(t.sub){function c(e){e||(e=l);if(e.subdiv&&!a&&!f){while(e.subdiv.firstChild)e.subdiv.removeChild(e.subdiv.firstChild);e.subdiv.parentNode.removeChild(e.subdiv),e.subdiv=null}}l.onmouseover=function(){for(var n=0;n<l.parentNode.children.length;n++)if(l.parentNode.children[n]!=l&&l.parentNode.children[n].subdiv){c(l.parentNode.children[n]);break}f=!0;if(!this.subdiv){this.subdiv=document.createElement("div"),this.subdiv.className="wb-tools",o=$p.iface.get_offset(l),t.sub.align=="right"?this.subdiv.style.left=o.left+l.offsetWidth-(parseInt(t.sub.width.replace(/\D+/g,""))||56)+"px":this.subdiv.style.left=o.left+"px",this.subdiv.style.top=o.top+s.offsetHeight+"px",this.subdiv.style.height=t.sub.height||"198px",this.subdiv.style.width=t.sub.width||"56px";for(var n in t.sub.buttons){var i=$p.iface.add_button(this.subdiv,e,t.sub.buttons[n]);i.onclick=r}e.wrapper.appendChild(this.subdiv),this.subdiv.onmouseover=function(){a=!0},this.subdiv.onmouseout=function(){a=!1,setTimeout(c,500)},t.title&&$p.iface.popup.show(dhx4.absLeft(this.subdiv),dhx4.absTop(this.subdiv),this.subdiv.offsetWidth,this.subdiv.offsetHeight)}},l.onmouseout=function(){f=!1,setTimeout(c,500)}}},this.select=function(n){for(var r=0;r<s.children.length;r++){var i=s.children[r];if(i.name==e.name+"_"+n){t.call(i,!0);return}}},this.get_selected=function(){for(var e=0;e<s.children.length;e++){var t=s.children[e];if(t.classList.contains("selected"))return t.name}},this.unload=function(){while(s.firstChild)s.removeChild(s.firstChild);e.wrapper.removeChild(s)},e.wrapper.appendChild(s),s.style.width=e.width||"28px",s.style.height=e.height||"150px",s.style.position="absolute",e.top&&(s.style.top=e.top),e.left&&(s.style.left=e.left),e.bottom&&(s.style.bottom=e.bottom),e.right&&(s.style.right=e.right),e.buttons&&e.buttons.forEach(function(e){i.add(e)})}function _load(e){function t(){if(i.cachable)return $p.wsql.promise(i.get_sql_struct(e),[]).then($p.iface.data_to_tree)}function n(){}function r(){if(i.cachable)return $p.wsql.promise(i.get_sql_struct(e),[]).then(function(t){return $p.iface.data_to_grid.call(i,t,e)})}var i=_md.mgr_by_class_name(e.class_name),s;return e.action=="get_tree"&&(s=t())?s:e.action=="get_orders"&&(s=n())?s:e.action=="get_selection"&&(s=r())?s:$p.job_prm.offline?Promise.reject(Error($p.msg.offline_request)):(e.browser_uid=$p.wsql.get_user_param("browser_uid"),$p.ajax.post_ex($p.job_prm.hs_url(),JSON.stringify(e),!0).then(function(e){return e.response}))}function Meta(e,t){function n(e){for(var t in e)for(var n in e[t]){r[t][n]||(r[t][n]={});for(var i in e[t][n])r[t][n][i]?typeof r[t][n][i]=="object"&&r[t][n][i]._mixin(e[t][n][i]):r[t][n][i]=e[t][n][i]}}var r=e instanceof XMLHttpRequest?JSON.parse(e.response):e,i;t&&n(t instanceof XMLHttpRequest?JSON.parse(t.response):t),e=null,t=require("log"),typeof t=="string"&&(t=JSON.parse(t)),n(t),t=null,this.get=function(e,t){var n=e.split("."),i={multiline_mode:!1,note:"",synonym:"",tooltip:"",type:{is_ref:!1,types:["string"]}};return t?(n[0]=="doc"&&t=="number_doc"?(i.synonym="Номер",i.tooltip="Номер документа",i.type.str_len=11):n[0]=="doc"&&t=="date"?(i.synonym="Дата",i.tooltip="Дата документа",i.type.date_part="date_time",i.type.types[0]="date"):n[0]=="doc"&&t=="posted"?(i.synonym="Проведен",i.type.types[0]="boolean"):n[0]=="cat"&&t=="id"?i.synonym="Код":n[0]=="cat"&&t=="name"?i.synonym="Наименование":t=="deleted"?(i.synonym="Пометка удаления",i.type.types[0]="boolean"):t=="is_folder"?(i.synonym="Это группа",i.type.types[0]="boolean"):t=="lc_changed"?(i.synonym="Изменено в 1С",i.tooltip="Время записи в 1С",i.type.types[0]="number",i.type.digits=15,i.type.fraction_figits=0):t?i=r[n[0]][n[1]].fields[t]:i=r[n[0]][n[1]],i):r[n[0]][n[1]]},this.get_classes=function(){var e={};for(var t in r){e[t]=[];for(var n in r[t])e[t].push(n)}return e},this.create_tables=function(e){function t(t){typeof t=="number"?(r--,r==0?(e&&setTimeout(e,10),alasql.utils.saveFile("create_tables.sql",u)):n()):t.hasOwnProperty("message")&&($p.iface.docs.progressOff(),$p.msg.show_msg({title:$p.msg.error_critical,type:"alert-error",text:t.message}))}function n(){var e=i[r-1],n=e["class"][e.name].get_sql_struct();u+=n+";\n",t(1)}var r=0,i=[],s=this.get_classes(),o,u="USE md;\nCREATE TABLE IF NOT EXISTS refs (ref CHAR);\n";for(o in s.cat)i.push({"class":_cat,name:s.cat[o]});r=i.length;for(o in s.ireg)i.push({"class":_ireg,name:s.ireg[o]}),r++;for(o in s.doc)i.push({"class":_doc,name:s.doc[o]}),r++;for(o in s.enm)i.push({"class":_enm,name:s.enm[o]}),r++;for(o in s.cch)i.push({"class":_cch,name:s.cch[o]}),r++;for(o in s.cacc)i.push({"class":_cacc,name:s.cacc[o]}),r++;$p.wsql.exec(u),n()},this.sql_type=function(e,t,n){var r;return t=="type"&&e.table_name=="cch_properties"||t=="svg"&&e.table_name=="cat_production_params"?r=" JSON":n.is_ref||n.hasOwnProperty("str_len")?r=" CHAR":n.date_part?r=" Date":n.hasOwnProperty("digits")?n.fraction_figits==0?r=" INT":r=" FLOAT":n.types.indexOf("boolean")!=-1?r=" BOOLEAN":r=" CHAR",r},this.sql_mask=function(e,t){return", "+(t?"_t_.":"")+("`"+e+"`")},this.mgr_by_class_name=function(e){if(e){var t=e.split(".");if(t[1]&&$p[t[0]])return $p[t[0]][t[1]]}},this.value_mgr=function(e,t,n,r,i){function s(e){return e&&n.types.length==1&&(n._mgr=e),e}var o,u,a,f,l;if(n._mgr)return n._mgr;if(n.types.length==1){a=n.types[0].split(".");if(a.length>1&&$p[a[0]])return s($p[a[0]][a[1]])}else if(i&&i.type){a=i.type.split(".");if(a.length>1&&$p[a[0]])return s($p[a[0]][a[1]])}o=e.property||e.param;if(t!="value"||!o){f=[],n.types.forEach(function(e){a=e.split("."),a.length>1&&$p[a[0]][a[1]]&&f.push($p[a[0]][a[1]])});if(f.length==1)return s(f[0]);if(r)return f;if((o=e[t])instanceof DataObj)return o._manager;if($p.is_guid(o)&&o!=$p.blank.guid)for(var c in f){l=f[c];if(l.get(o,!1,!0))return l}}else{u=_cch.properties.get(o,!1);if($p.is_data_obj(u)){if(u.is_new())return _cat.property_values;for(f in u.type.types)if(u.type.types[f].indexOf(".")>-1){a=u.type.types[f].split(".");break}return a&&a.length>1&&$p[a[0]]?s($p[a[0]][a[1]]):u.type}}},this.control_by_type=function(e){var t;return e.is_ref?e.types.join().indexOf("enm.")==-1?t="ocombo":t="refc":e.date_part?t="dhxCalendar":e.digits?e.fraction_figits<5?t="calck":t="edn":e.types[0]=="boolean"?t="ch":e.hasOwnProperty("str_len")&&(e.str_len>=100||e.str_len==0)?t="txt":t="ed",t},this.ts_captions=function(e,t,n){n||(n={});var r=this.get(e).tabular_sections[t],i=this.get(e).form,s=r.fields,o;if(i&&i.obj){if(!i.obj.tabular_sections[t])return;n._mixin(i.obj.tabular_sections[t])}else{t==="contact_information"&&(s={type:"",kind:"",presentation:""}),n.fields=["row"],n.headers="№",n.widths="40",n.min_widths="",n.aligns="",n.sortings="na",n.types="cntr";for(var u in s)o=r.fields[u],o.hide||(n.fields.push(u),n.headers+=","+(o.synonym?o.synonym.replace(/,/g," "):u),n.types+=","+this.control_by_type(o.type),n.sortings+=",na")}return!0},this.syns_js=function(e){var t={DeletionMark:"deleted",Description:"name",DataVersion:"data_version",IsFolder:"is_folder",Number:"number_doc",Date:"date","Дата":"date",Posted:"posted",Code:"id",Parent_Key:"parent",Owner_Key:"owner",Owner:"owner",Ref_Key:"ref","Ссылка":"ref",LineNumber:"row"};return t[e]?t[e]:r.syns_js[r.syns_1с.indexOf(e)]||e},this.syns_1с=function(e){var t={deleted:"DeletionMark",name:"Description",data_version:"DataVersion",is_folder:"IsFolder",number_doc:"Number",date:"Date",posted:"Posted",id:"Code",ref:"Ref_Key",parent:"Parent_Key",owner:"Owner_Key",row:"LineNumber"};return t[e]?t[e]:r.syns_1с[r.syns_js.indexOf(e)]||e},this.printing_plates=function(e){if(e)for(var t in e.doc)r.doc[t].printing_plates=e.doc[t]},_md=$p.md=this;for(i in r.enm)_enm[i]=new EnumManager(r.enm[i],"enm."+i);for(i in r.cat)_cat[i]=new CatManager("cat."+i);for(i in r.doc)_doc[i]=new DocManager("doc."+i);for(i in r.ireg)i=="$log"?_ireg[i]=new LogManager("ireg."+i):_ireg[i]=new InfoRegManager("ireg."+i);for(i in r.dp)_dp[i]=new DataProcessorsManager("dp."+i);for(i in r.cch)_cch[i]=new ChartOfCharacteristicManager("cch."+i);for(i in r.cacc)_cacc[i]=new ChartOfAccountManager("cacc."+i);return $p.modifiers.execute($p),{md_date:r.md_date,cat_date:r.cat_date}}function DataManager(class_name){var _metadata=_md.get(class_name),_cachable,_async_write=_metadata.async_write,_events={after_create:[],after_load:[],before_save:[],after_save:[],value_change:[]};class_name.indexOf("enm.")!=-1?_cachable=!0:$p.job_prm.offline?_cachable=!0:class_name.indexOf("doc.")!=-1||class_name.indexOf("dp.")!=-1||class_name.indexOf("rep.")!=-1?_cachable=!1:_cachable=!0,!$p.job_prm.offline&&_metadata.hasOwnProperty("cachable")&&(_cachable=_metadata.cachable),this.__define({cachable:{value:_cachable,writable:!0,enumerable:!1},async_write:{value:_async_write,writable:!1,enumerable:!1},class_name:{value:class_name,writable:!1,enumerable:!1},alatable:{get:function(){return $p.wsql.aladb.tables[this.table_name]?$p.wsql.aladb.tables[this.table_name].data:[]},enumerable:!1},metadata:{value:function(e){return e?_metadata.fields[e]||_metadata.tabular_sections[e]:_metadata},enumerable:!1},attache_event:{value:function(e,t,n){n?_events[e].push(t):_events[e].push(t)},enumerable:!1},handle_event:{value:function(e,t,n){var r;return _events[t].forEach(function(t){r!==!1&&(r=t.call(e,n))}),r},enumerable:!1}});var _obj_сonstructor=this._obj_сonstructor||DataObj;if(!(this instanceof EnumManager)){var obj_сonstructor_name=class_name.split(".")[1];this._obj_сonstructor=eval("(function "+obj_сonstructor_name.charAt(0).toUpperCase()+obj_сonstructor_name.substr(1)+"(attr, manager){manager._obj_сonstructor.superclass.constructor.call(this, attr, manager)})"),this._obj_сonstructor._extend(_obj_сonstructor);if(this instanceof InfoRegManager){delete this._obj_сonstructor.prototype.deleted,delete this._obj_сonstructor.prototype.ref,delete this._obj_сonstructor.prototype.lc_changed;for(var f in this.metadata().dimensions)this._obj_сonstructor.prototype.__define(f,{get:new Function("return this._getter('"+f+"')"),set:new Function("v","this._setter('"+f+"',v)"),enumerable:!0});for(var f in this.metadata().resources)this._obj_сonstructor.prototype.__define(f,{get:new Function("return this._getter('"+f+"')"),set:new Function("v","this._setter('"+f+"',v)"),enumerable:!0})}else{this._ts_сonstructors={};for(var f in this.metadata().fields)this._obj_сonstructor.prototype.__define(f,{get:new Function("return this._getter('"+f+"')"),set:new Function("v","this._setter('"+f+"',v)"),enumerable:!0});for(var f in this.metadata().tabular_sections){var row_сonstructor_name=obj_сonstructor_name.charAt(0).toUpperCase()+obj_сonstructor_name.substr(1)+f.charAt(0).toUpperCase()+f.substr(1)+"Row";this._ts_сonstructors[f]=eval("(function "+row_сonstructor_name+"(owner) 			{owner._owner._manager._ts_сonstructors[owner._name].superclass.constructor.call(this, owner)})"),this._ts_сonstructors[f]._extend(TabularSectionRow);for(var rf in this.metadata().tabular_sections[f].fields)this._ts_сonstructors[f].prototype.__define(rf,{get:new Function("return this._getter('"+rf+"')"),set:new Function("v","this._setter('"+rf+"',v)"),enumerable:!0});this._obj_сonstructor.prototype.__define(f,{get:new Function("return this._getter_ts('"+f+"')"),set:new Function("v","this._setter_ts('"+f+"',v)"),enumerable:!0})}}}_obj_сonstructor=null}function RefDataManager(e){var t=this,n={};RefDataManager.superclass.constructor.call(t,e),t.push=function(e,t){t&&t!=e.ref?(delete n[e.ref],n[t]=e):n[e.ref]=e},t.all=function(){return n},t.each=function(e){for(var t in n){if(!t||t==$p.blank.guid)continue;if(e.call(this,n[t])==1)break}},t.get=function(e,r,i){var s=n[e]||n[e=$p.fix_guid(e)];if(!s){if(i)return;s=new t._obj_сonstructor(e,t,!0)}return r===!1?s:r===undefined&&e===$p.blank.guid?s:!t.cachable||s.is_new()?s.load():r?Promise.resolve(s):s},t.create=function(e,r){function i(){}if(!e||typeof e!="object")e={};if(!e.ref||!$p.is_guid(e.ref)||$p.is_empty_guid(e.ref))e.ref=$p.generate_guid();var s=n[e.ref];if(!s){s=new t._obj_сonstructor(e,t);if(!t.cachable&&r){var o={};return $p.ajax.default_attr(o,$p.job_prm.irest_url()),o.url+=t.rest_name+"/Create()",$p.ajax.get_ex(o.url,o).then(function(e){return s._mixin(JSON.parse(e.response),undefined,["ref"])})}if(r){var u=s._obj;for(var a in t.metadata().fields)u[a]==undefined&&(u[a]="")}}return Promise.resolve(s)},t.delete_loc=function(e){var r;delete n[e];for(var i in t.alatable)if(t.alatable[i].ref==e){r=i;break}r!=undefined&&t.alatable.splice(r,1)},t.find=function(e){return $p._find(n,e)},t.find_rows=function(e,r){return $p._find_rows.call(t,n,e,r)},t.save=function(e){return e&&(e.specify||$p.is_guid(e.ref)&&!t.cachable)?_load({class_name:t.class_name,action:e.action||"save",attr:e}).then(JSON.parse):Promise.reject()},t.load_array=function(e,r){var i,s;for(var o in e){i=$p.fix_guid(e[o]);if(!(s=n[i]))new t._obj_сonstructor(e[o],t);else if(s.is_new()||r)s._mixin(e[o]),s._set_loaded()}},t.predefined=function(e){var n=t.metadata().predefined[e];return n?t.get(n.ref):undefined},t.first_folder=function(e){for(var r in n){var i=n[r];if(i.is_folder&&(!e||$p.is_equal(e,i.owner)))return i}return t.get()}}function DataProcessorsManager(e){DataProcessorsManager.superclass.constructor.call(this,e),this.create=function(){return new this._obj_сonstructor({},this)}}function EnumManager(e,t){EnumManager.superclass.constructor.call(this,t),this._obj_сonstructor=EnumObj,this.push=function(e,t){this.__define(t,{value:e,enumerable:!1})},this.get=function(e){if(e instanceof EnumObj)return e;if(!e||e==$p.blank.guid)e="_";var t=this[e];return t||(t=new EnumObj({name:e},this)),t},this.each=function(e){this.alatable.forEach(function(t){t.ref&&t.ref!=$p.blank.guid&&e.call(this[t.ref])})};for(var n in e)new EnumObj(e[n],this)}function RegisterManager(e){var t={};this._obj_сonstructor=RegisterRow,RegisterManager.superclass.constructor.call(this,e),this.push=function(e,n){n&&n!=e.ref?(delete t[e.ref],t[n]=e):t[e.ref]=e},this.get=function(e,n,r){e||(e={}),e.action="select";var i=alasql(this.get_sql_struct(e),e._values),s;delete e.action,delete e._values;if(i.length)if(r)s=t[this.get_ref(i[0])];else{s=[];for(var o in i)s.push(t[this.get_ref(i[o])])}return n?Promise.resolve(s):s},this.load_array=function(e){var n,r,i=[];for(var s in e)n=this.get_ref(e[s]),(r=t[n])?r._mixin(e[s]):new this._obj_сonstructor(e[s],this),i.push(t[n]);return i},this.find_rows=function(e,t){return $p._find_rows.call(this,this.alatable,e,t)}}function InfoRegManager(e){InfoRegManager.superclass.constructor.call(this,e)}function LogManager(){LogManager.superclass.constructor.call(this,"ireg.$log");var e;this.record=function(t){if(t instanceof Error){console&&console.log(t);var n=t;t={"class":"error",note:n.toString()}}typeof t!="object"&&(t={note:t}),t.date=Date.now()+$p.eve.time_diff(),e||(e=alasql.compile("select MAX(`sequence`) as `sequence` from `ireg_$log` where `date` = ?"));var r=e([t.date]);!r.length||r[0].sequence===undefined?t.sequence=0:t.sequence=r[0].sequence+1,t.class||(t.class="note"),alasql("insert into `ireg_$log` (`date`, `sequence`, `class`, `note`, `obj`) values (?, ?, ?, ?, ?)",[t.date,t.sequence,t.class,t.note,t.obj?JSON.stringify(t.obj):""])},this.backup=function(e,t){},this.restore=function(e,t){},this.clear=function(e,t){},this.show=function(e){},this.get_sql_struct=function(e){if(e&&e.action=="get_selection"){var t="select * from `ireg_$log`";return e.date_from?e.date_till?t+=" where `date` >= ? and `date` <= ?":t+=" where `date` >= ?":e.date_till&&(t+=" where `date` <= ?"),t}return LogManager.superclass.get_sql_struct.call(this,e)},this.caption_flds=function(e){function t(e,t,n,r,i,s){this.id=e,this.width=t,this.type=n,this.align=r,this.sort=i,this.caption=s}var n='<column id="%1" width="%2" type="%3" align="%4" sort="%5">%6</column>',r=[],i=this.metadata(),s="";r.push(new t("date","140","ro","left","server","Дата")),r.push(new t("class","100","ro","left","server","Класс")),r.push(new t("note","*","ro","left","server","Событие"));if(e.get_header){s="<head>";for(var o in r)s+=n.replace("%1",r[o].id).replace("%2",r[o].width).replace("%3",r[o].type).replace("%4",r[o].align).replace("%5",r[o].sort).replace("%6",r[o].caption);s+="</head>"}return{head:s,acols:r}},this.data_to_grid=function(e,t){var n="<?xml version='1.0' encoding='UTF-8'?><rows total_count='%1' pos='%2' set_parent='%3'>".replace("%1",e.length).replace("%2",t.start).replace("%3",t.set_parent||""),r=this.caption_flds(t),i=$p.eve.time_diff();return n+=r.head,e.forEach(function(e){n+='<row id="'+e.date+"_"+e.sequence+'"><cell>'+$p.dateFormat(e.date-i,$p.dateFormat.masks.date_time)+(e.sequence?"."+e.sequence:"")+"</cell>"+"<cell>"+e.class+"</cell><cell>"+e.note+"</cell></row>"}),n+"</rows>"}}function AccumRegManager(e){AccumRegManager.superclass.constructor.call(this,e)}function CatManager(e){this._obj_сonstructor=CatObj,CatManager.superclass.constructor.call(this,e),this.metadata().hierarchical&&this.metadata().group_hierarchy&&this._obj_сonstructor.prototype.__define("is_folder",{get:function(){return this._obj.is_folder||!1},set:function(e){this._obj.is_folder=$p.fix_boolean(e)},enumerable:!0})}function ChartOfCharacteristicManager(e){this._obj_сonstructor=CatObj,ChartOfCharacteristicManager.superclass.constructor.call(this,e)}function ChartOfAccountManager(e){this._obj_сonstructor=CatObj,ChartOfAccountManager.superclass.constructor.call(this,e)}function DocManager(e){this._obj_сonstructor=DocObj,DocManager.superclass.constructor.call(this,e)}function DataObj(e,t){var n,r,i={},s={data_version:""},o=!(this instanceof EnumObj);!(t instanceof DataProcessorsManager)&&!(t instanceof EnumManager)&&(r=t.get(e,!1,!0));if(r)return r;t instanceof EnumManager?s.ref=n=e.name:t instanceof RegisterManager?n=t.get_ref(e):(s.ref=n=$p.fix_guid(e),s.deleted=!1,s.lc_changed=0),this.__define("_manager",{value:t,enumerable:!1}),this.__define("is_new",{value:function(){return o},enumerable:!1}),this.__define("_set_loaded",{value:function(e){o=!1,t.push(this,e)},enumerable:!1}),this.__define("_obj",{value:s,writable:!1,enumerable:!1}),this.__define("_ts_",{value:function(e){return i[e]||(i[e]=new TabularSection(e,this)),i[e]},enumerable:!1}),t.alatable&&t.push&&(t.alatable.push(s),t.push(this,n))}function CatObj(e,t){var n="";CatObj.superclass.constructor.call(this,e,t),this.__define("presentation",{get:function(){return this.name||this.id?this.name||this.id||this._metadata.obj_presentation:n},set:function(e){e&&(n=String(e))},enumerable:!1}),e&&typeof e=="object"&&this._mixin(e),!$p.is_empty_guid(this.ref)&&(e.id||e.name)&&this._set_loaded(this.ref)}function DocObj(e,t){var n="";DocObj.superclass.constructor.call(this,e,t),this.__define("presentation",{get:function(){return this.number_str||this.number_doc?this._metadata.obj_presentation+" №"+(this.number_str||this.number_doc)+" от "+$p.dateFormat(this.date,$p.dateFormat.masks.ru):n},set:function(e){e&&(n=String(e))},enumerable:!1}),e&&typeof e=="object"&&this._mixin(e),!$p.is_empty_guid(this.ref)&&e.number_doc&&this._set_loaded(this.ref)}function DataProcessorObj(e,t){DataProcessorObj.superclass.constructor.call(this,e,t);var n,r=t.metadata();for(n in r.fields)e[n]=$p.fetch_type("",r.fields[n].type);for(n in r.tabular_sections)e[n]=[];this._mixin(e),this.unload=function(){for(n in this)this[n]instanceof TabularSection?(this[n].clear(),delete this[n]):typeof this[n]!="function"&&delete this[n]}}function EnumObj(e,t){EnumObj.superclass.constructor.call(this,e,t),e&&typeof e=="object"&&this._mixin(e)}function RegisterRow(e,t){RegisterRow.superclass.constructor.call(this,e,t),e&&typeof e=="object"&&this._mixin(e)}function TabularSection(e,t){t._obj[e]||(t._obj[e]=[]),this.__define("_name",{value:e,enumerable:!1}),this.__define("_owner",{value:t,enumerable:!1}),this.__define("_obj",{value:t._obj[e],writable:!1,enumerable:!1})}function TabularSectionRow(e){var t={};this.__define("_owner",{value:e,enumerable:!1}),this.__define("_obj",{value:t,writable:!1,enumerable:!1})}function Rest(){this.filter_date=function(e,t,n){t||(t=new Date("2015-01-01"));var r=e+" gt datetime'"+$p.dateFormat(t,$p.dateFormat.masks.isoDateTime)+"'";return n&&(r+=" and "+e+" lt datetime'"+$p.dateFormat(n,$p.dateFormat.masks.isoDateTime)+"'"),r},this.to_data=function(e,t){var n={},r=t.metadata().fields,i=t.metadata().tabular_sections,s,o,u,a,f,l,c;t instanceof RefDataManager?(e.hasOwnProperty("DeletionMark")&&(n.deleted=e.DeletionMark),e.hasOwnProperty("DataVersion")&&(n.data_version=e.DataVersion),e.hasOwnProperty("Ref_Key")&&(n.ref=e.Ref_Key)):r=[]._mixin(t.metadata().dimensions)._mixin(t.metadata().resources),t instanceof DocManager?(e.hasOwnProperty("Number")?n.number_doc=e.Number||e.number_doc:e.hasOwnProperty("number_doc")&&(n.number_doc=e.number_doc),e.hasOwnProperty("Date")?n.date=e.Date:e.hasOwnProperty("date")&&(n.date=e.date),e.hasOwnProperty("Posted")?n.posted=e.Posted:e.hasOwnProperty("posted")&&(n.posted=e.posted)):(t.metadata().main_presentation_name&&(e.hasOwnProperty("Description")?n.name=e.Description:e.hasOwnProperty("name")&&(n.name=e.name)),t.metadata().code_length&&(e.hasOwnProperty("Code")?n.id=e.Code:e.hasOwnProperty("id")&&(n.id=e.id)));for(o in r){f=_md.syns_1с(o),f.indexOf("_Key")==-1&&r[o].type.is_ref&&e[f+"_Key"]&&(f+="_Key");if(!e.hasOwnProperty(f))continue;n[o]=e[f]}for(s in i){l=_md.syns_1с(s);if(!e.hasOwnProperty(l))continue;n[s]=[],e[l]&&(e[l].sort(function(e,t){return e.LineNumber>t.LineNumber}),e[l].forEach(function(e){a={};for(u in i[s].fields)f=_md.syns_1с(u),f.indexOf("_Key")==-1&&i[s].fields[u].type.is_ref&&e[f+"_Key"]&&(f+="_Key"),a[u]=e[f];n[s].push(a)}))}return n},this.ajax_to_data=function(e,t){return $p.ajax.get_ex(e.url,e).then(function(e){return JSON.parse(e.response)}).then(function(e){var n=[];return e.value.forEach(function(e){n.push(_rest.to_data(e,t))}),n})},this.build_select=function(e,t){function n(e,r){typeof r=="function"?s+=r(t,e):(o=_md.syns_1с(e),u=_md.get(t.class_name,e),u&&(u=u.type,u.is_ref&&o.indexOf("_Key")==-1&&u.types.length&&u.types[0].indexOf("enm.")==-1&&(o+="_Key"),u.types.length&&(["boolean","number"].indexOf(typeof r)!=-1?s+=o+" eq "+r:u.is_ref||r instanceof DataObj?s+=o+" eq guid'"+r+"'":typeof r=="string"?s+=o+" eq '"+r+"'":typeof r=="object"&&(r.hasOwnProperty("like")?s+=o+" like '%"+r.like+"%'":r.hasOwnProperty("not")&&(s+=" not ("+n(e,r.not)+") ")))))}function r(e){for(var t in e){s?s+=" and ":s="&$filter=";if(t=="or"&&Array.isArray(e[t])){var r=!0;e[t].forEach(function(e){r?(s+=" ( ",r=!1):s+=" or ";var t=Object.keys(e)[0];n(t,e[t])}),s+=" ) "}else n(t,e[t])}}var i,s,o,u,a="";e||(e={}),e.fields&&(e.fields.forEach(function(e){e=="ref"?o="Ref_Key":(o=_md.syns_1с(e),u=_md.get(t.class_name,e).type,u.is_ref&&o.indexOf("_Key")==-1&&u.types.length&&u.types[0].indexOf("enm.")==-1&&(o+="_Key")),i?i+=",":i="&$select=",i+=o}),a+=i),e.selection&&(typeof e.selection!="function"&&(Array.isArray(e.selection)?e.selection.forEach(r):r(e.selection)),s&&(a+=s)),$p.job_prm.rest&&t.rest_name.indexOf("Module_")==-1&&t.rest_name.indexOf("DataProcessor_")==-1&&t.rest_name.indexOf("Report_")==-1&&a.indexOf(" like ")==-1&&a.indexOf(" in ")==-1?$p.ajax.default_attr(e,$p.job_prm.rest_url()):$p.ajax.default_attr(e,$p.job_prm.irest_url()),e.url+=t.rest_name+"?allowedOnly=true&$format=json&$top="+(e.top||300)+a},this.load_array=function(e,t){return _rest.build_select(e,t),_rest.ajax_to_data(e,t)},this.load_obj=function(e){var t={};return $p.ajax.default_attr(t,$p.job_prm.rest?$p.job_prm.rest_url():$p.job_prm.irest_url()),t.url+=e._manager.rest_name+"(guid'"+e.ref+"')?$format=json",$p.ajax.get_ex(t.url,t).then(function(e){return JSON.parse(e.response)}).then(function(t){return e._mixin(_rest.to_data(t,e._manager))}).catch(function(t){if(t.status==404)return e;console.log(t)})},this.save_irest=function(e,t){var n=JSON.stringify(e),r=(t.post!=undefined?",post="+t.post:"")+(t.operational!=undefined?",operational="+t.operational:"");return $p.ajax.default_attr(t,$p.job_prm.irest_url()),t.url+=e._manager.rest_name+"(guid'"+e.ref+"'"+r+")",$p.ajax.post_ex(t.url,n,t).then(function(e){return JSON.parse(e.response)}).then(function(t){return e._mixin(t)})},this.save_rest=function(e,t){var n=e.to_atom(),r;return $p.ajax.default_attr(t,$p.job_prm.rest_url()),r=t.url+e._manager.rest_name,t.url=r+"(guid'"+e.ref+"')?$format=json&$select=Ref_Key,DeletionMark",$p.ajax.get_ex(t.url,t).catch(function(e){return e.status==404?{response:JSON.stringify({is_new:!0})}:Promise.reject(e)}).then(function(e){return JSON.parse(e.response)}).then(function(i){return i.is_new?$p.ajax.post_ex(r,n,t):$p.ajax.patch_ex(r+"(guid'"+e.ref+"')",n,t)}).then(function(t){var n=require("xml_to_json").parseString(t.response,{mergeCDATA:!1,grokAttr:!0,grokText:!1,normalize:!0,xmlns:!1,namespaceKey:"_ns",textKey:"_text",valueKey:"_value",attrKey:"_attr",cdataKey:"_cdata",attrsAsObject:!1,stripAttrPrefix:!0,stripElemPrefix:!0,childrenAsArray:!1});if(n.entry&&n.entry.content&&n.entry.updated){var r=n.entry.content.properties,i={},s;i.lc_changed=new Date(n.entry.updated._text);for(var o in r){if(o.indexOf("_")==0)continue;if(s=r[o].element){i[o]=[];if(Array.isArray(s))for(var u in s){i[o][u]={};for(var a in s[u])a.indexOf("_")!=0&&(i[o][u][a]=s[u][a]._text==="false"?!1:s[u][a]._text)}else{i[o][0]={};for(var a in s)a.indexOf("_")!=0&&(i[o][0][a]=s[a]._text==="false"?!1:s[a]._text)}}else i[o]=r[o]._text==="false"?!1:r[o]._text}return _rest.to_data(i,e._manager)}}).then(function(t){return e._mixin(t)})}}function wnd_appcache(e){function t(){r.wnd_appcache=e.iface.w.createWindow("wnd_appcache",0,0,490,250);var t=[{type:"block",name:"form_block_1",list:[{type:"label",name:"form_label_1",label:e.msg.sync_script},{type:"block",name:"form_block_2",list:[{type:"template",name:"img_long",className:"img_long"},{type:"newcolumn"},{type:"template",name:"text_processed"},{type:"template",name:"text_current"},{type:"template",name:"text_bottom"}]}]},{type:"button",name:"form_button_1",value:e.msg.sync_break}];r.frm_appcache=r.wnd_appcache.attachForm(t),r.frm_appcache.attachEvent("onButtonClick",function(e){r&&(r.do_break=!0)}),r.wnd_appcache.setText(e.msg.long_operation),r.wnd_appcache.denyResize(),r.wnd_appcache.centerOnScreen(),r.wnd_appcache.button("park").hide(),r.wnd_appcache.button("minmax").hide(),r.wnd_appcache.button("close").hide()}var n=e.iface.appcache={},r;n.create=function(e){r=e,t()},n.update=function(){r.frm_appcache.setItemValue("text_processed","Обработано элементов: "+r.loaded+" из "+r.total)},n.close=function(){r&&r.wnd_appcache&&(r.wnd_appcache.close(),delete r.wnd_appcache)}}function only_in_browser(w){var eve=$p.eve,iface=$p.iface,msg=$p.msg,stepper={},timer_setted=!1,cache;eve.set_offline=function(e){var t=$p.job_prm.offline;$p.job_prm.offline=!!e||!!$p.wsql.get_user_param("offline","boolean"),t!=$p.job_prm["offline"]&&(t=$p.job_prm.offline)},eve.on_rotate=function(e){$p.device_orient=w.orientation==0||w.orientation==180?"portrait":"landscape",typeof e!="undefined"&&w.dhx4.callEvent("onOrientationChange",[$p.device_orient])},typeof w.orientation=="undefined"?$p.device_orient=w.innerWidth>w.innerHeight?"landscape":"portrait":eve.on_rotate(),w.addEventListener("orientationchange",eve.on_rotate,!1),$p.__define("device_type",{get:function(){var e=$p.wsql.get_user_param("device_type");return e||(e=function(e){return e<1024?"phone":e<1280?"tablet":"desktop"}(Math.max(screen.width,screen.height)),$p.wsql.set_user_param("device_type",e)),e},set:function(e){$p.wsql.set_user_param("device_type",e)},enumerable:!1,configurable:!1}),w.addEventListener("online",eve.set_offline),w.addEventListener("offline",function(){eve.set_offline(!0)}),w.addEventListener("load",function(){function do_reload(){$p.ajax.authorized||(eve.redirect=!0,location.reload(!0))}function do_cache_update_msg(e){!stepper.wnd_appcache&&$p.iface.appcache?$p.iface.appcache.create(stepper):timer_setted||(timer_setted=!0,setTimeout(do_reload,25e3)),$p.iface.appcache&&(stepper.loaded=e.loaded||0,stepper.total=e.total||140,$p.iface.appcache.update()),stepper.do_break&&($p.iface.appcache.close(),setTimeout(do_reload,1e3))}setTimeout(function(){function IPInfo(){function e(){this.geocode=function(e){return Promise.resolve(!1)}}var t,n,r="",i;this.__define("yageocoder",{get:function(){return t||(t=new e),t},enumerable:!1,configurable:!1}),this.__define("ggeocoder",{get:function(){return n},enumerable:!1,configurable:!1}),this.__define({addr:{get:function(){return r}},parts:{get:function(){return i}},components:{value:function(e,t){var n,r,i,s="",o="",u="";for(n in t){r=t[n];for(i in r.types)switch(r.types[i]){case"route":r.short_name.indexOf("Unnamed")==-1&&(s=r.short_name+(s?" "+s:""),o=r.long_name.replace("улица","").trim());break;case"administrative_area_level_1":e.region=r.long_name;break;case"administrative_area_level_2":e.city=r.short_name,e.city_long=r.long_name;break;case"locality":u=(u?u+" ":"")+r.short_name;break;case"street_number":s=(s?s+" ":"")+r.short_name;break;case"postal_code":e.postal_code=r.short_name;break;default:}}e.region&&e.region==e.city_long?e.city.indexOf(u)==-1?e.city=u:e.city="":u&&e.city.indexOf(u)==-1&&e.region.indexOf(u)==-1&&(s=u+", "+s);if(!e.street||e.street.indexOf(o)==-1)e.street=s;return e}}}),this.location_callback=function(){n=new google.maps.Geocoder,navigator.geolocation.getCurrentPosition(function(e){$p.ipinfo.latitude=e.coords.latitude,$p.ipinfo.longitude=e.coords.longitude;var t=new google.maps.LatLng($p.ipinfo.latitude,$p.ipinfo.longitude);n.geocode({latLng:t},function(e,t){t==google.maps.GeocoderStatus.OK&&(!e[1]||e[0].address_components.length>=e[1].address_components.length?i=e[0]:i=e[1],r=i.formatted_address,dhx4.callEvent("geo_current_position",[$p.ipinfo.components({},i.address_components)]))})},$p.record_log,{timeout:3e4})}}function navigate(e){e&&(location.origin+location.pathname).indexOf(e)==-1&&location.replace(e)}function init_params(){$p.wsql.init_params().then(function(){function e(){var e,t,n,r=!0,i=!0,s=new RegExp("metadata.js$"),o=new RegExp("metadata.min.js$");for(e in document.scripts){if(document.scripts[e].src.match(s)){n=s,t=document.scripts[e].src;break}if(document.scripts[e].src.match(o)){n=o,t=document.scripts[e].src;break}}for(e=0;e<document.styleSheets.length;e++)document.styleSheets[e].href&&(document.styleSheets[e].href.indexOf("dhtmlx_")!=-1?r=!1:document.styleSheets[e].href.indexOf("metadata.css")!=-1&&(i=!1));dhtmlx.skin=$p.wsql.get_user_param("skin")||"dhx_web",r&&$p.load_script(t.replace(n,dhtmlx.skin=="dhx_web"?"dhtmlx_web.css":"dhtmlx_terrace.css"),"link"),i&&$p.load_script(t.replace(n,"metadata.css"),"link"),$p.job_prm.additional_css&&$p.job_prm.additional_css.forEach(function(e){(dhx4.isIE||e.indexOf("ie_only")==-1)&&$p.load_script(e,"link")}),dhtmlx.image_path=t.replace(n,"imgs/"),dhtmlx.skin_suffix=function(){return dhtmlx.skin.replace("dhx","")+"/"},dhx4.ajax.cache=!0,$p.iface.__define("w",{value:new dhtmlXWindows,enumerable:!1}),$p.iface.w.setSkin(dhtmlx.skin),$p.iface.__define("popup",{value:new dhtmlXPopup,enumerable:!1})}"dhtmlx"in w&&e(),eve.stepper={step:0,count_all:0,cat_date:0,step_size:57,files:0,cat_ini_date:$p.wsql.get_user_param("cache_cat_date","number")||0},eve.set_offline(!navigator.onLine),eve.update_files_version();if(document.documentElement.webkitRequestFullScreen&&navigator.userAgent.match(/Android|iPhone|iPad|iPod/i)&&($p.job_prm.request_full_screen||$p.wsql.get_user_param("request_full_screen"))){var t=function(){document.documentElement.webkitRequestFullScreen(),w.removeEventListener("touchstart",t)};w.addEventListener("touchstart",t,!1)}if($p.job_prm.use_builder||$p.job_prm.use_wrapper)$p.wrapper=document.getElementById("owb_wrapper"),$p.risdiv=document.getElementById("risdiv"),$p.ft=document.getElementById("msgfooter"),$p.ft&&($p.ft.style.display="none");eve.onload.execute($p),document&&document.querySelector("#splash")&&document.querySelector("#splash").parentNode.removeChild(document.querySelector("#splash")),$p.job_prm.use_builder&&$p.ft?dhtmlxEvent($p.ft,"click",function(e){$p.cancel_bubble(e),e.qualifier=="ready"?iface.oninit():$p.eve.builder_click&&$p.eve.builder_click(e)}):setTimeout(iface.oninit,100),$p.msg.russian_names();if($p.wsql.get_user_param("use_service_worker","boolean")&&typeof navigator!="undefined"&&"serviceWorker"in navigator&&location.protocol.indexOf("https")!=-1)navigator.serviceWorker.register("metadata_service_worker.js",{scope:"/"}).then(function(e){console.log("serviceWorker register succeeded")}).catch($p.record_log);else if(cache=w.applicationCache)cache.addEventListener("noupdate",function(e){},!1),cache.addEventListener("cached",function(e){timer_setted=!0,$p.iface.appcache&&$p.iface.appcache.close()},!1),cache.addEventListener("downloading",do_cache_update_msg,!1),cache.addEventListener("progress",do_cache_update_msg,!1),cache.addEventListener("updateready",function(e){try{cache.swapCache(),$p.iface.appcache&&$p.iface.appcache.close()}catch(e){}do_reload()},!1),cache.addEventListener("error",$p.record_log,!1)})}$p.job_prm=new JobPrm,navigator.geolocation&&$p.job_prm.use_google_geo&&($p.ipinfo=new IPInfo,!window.google||!window.google.maps?$p.eve.onload.push(function(){setTimeout(function(){$p.load_script(location.protocol+"//maps.google.com/maps/api/js?callback=$p.ipinfo.location_callback","script",function(){})},100)}):location_callback()),$p.job_prm.allow_post_message&&w.addEventListener("message",function(event){if($p.job_prm.allow_post_message=="*"||$p.job_prm.allow_post_message==event.origin)if(typeof event.data=="string")try{var res=eval(event.data);if(res&&event.source){if(typeof res=="object")res=JSON.stringify(res);else if(typeof res=="function")return;event.source.postMessage(res,"*")}}catch(e){$p.record_log(e)}}),eve.socket.connect();if($p.job_prm.check_browser_compatibility&&(!w.JSON||!w.indexedDB||!w.localStorage)){eve.redirect=!0,msg.show_msg({type:"alert-error",text:msg.unsupported_browser,title:msg.unsupported_browser_title}),setTimeout(function(){location.replace(msg.store_url_od)},6e3);return}if($p.job_prm.check_app_installed&&w.chrome&&w.chrome.app&&!w.chrome.app.isInstalled&&!location.hostname.match(/.local/)){eve.redirect=!0,msg.show_msg({type:"alert-error",text:msg.unsupported_mode,title:msg.unsupported_mode_title}),setTimeout(function(){location.replace(msg.store_url_od)},6e3);return}setTimeout(function(){typeof Promise!="function"?$p.load_script("//cdn.jsdelivr.net/es6-promise/latest/es6-promise.min.js","script",function(){ES6Promise.polyfill(),init_params()}):init_params()},20)},20)},!1),w.onbeforeunload=function(){if(!eve.redirect)return msg.onbeforeunload},w.addEventListener("popstat",$p.iface.hash_route),w.addEventListener("hashchange",$p.iface.hash_route)}function SocketMsg(){function e(e){if(e&&e.type=="react")try{var t=_md?_md.mgr_by_class_name(e.class_name):null;t&&t.load_array([e.obj],!0)}catch(n){$p.record_log(n)}}var t,n,r,i=0,s=this;s.connect=function(e){t||(t=$p.job_prm.parse_url().socket_uid||""),e&&(i=0),i++;if($p.job_prm.ws_url)if(!n||!r)try{n=new WebSocket($p.job_prm.ws_url),n.onopen=function(){r=!0,n.send(JSON.stringify({socket_uid:t,zone:$p.wsql.get_user_param("zone"),browser_uid:$p.wsql.get_user_param("browser_uid"),_side:"js",_mirror:!0}))},n.onclose=function(){r=!1,setTimeout(s.connect,i<3?3e4:6e5)},n.onmessage=function(e){var t;try{t=JSON.parse(e.data)}catch(n){t=e.data}s.handlers.execute(t)},n.onerror=$p.record_log}catch(o){setTimeout(s.connect,i<3?3e4:6e5),$p.record_log(o)}},s.handlers=new Modifiers,s.send=function(e){n&&r&&(e?"object"!=typeof e&&(e={data:e}):e={},e.socket_uid=t,e._side="js",n.send(JSON.stringify(e)))},typeof window!="undefined"&&s.handlers.push(e)}$p=new MetaEngine,typeof define=="function"&&define.amd?define("$p",$p):typeof module=="object"&&module&&(module.exports=$p),typeof window!="undefined"?$p.load_script=function(e,t,n){var r=document.createElement(t);t=="script"?(r.type="text/javascript",r.src=e,n?(r.async=!0,r.addEventListener("load",n,!1)):r.async=!1):(r.type="text/css",r.rel="stylesheet",r.href=e),document.head.appendChild(r)}:typeof WorkerGlobalScope=="undefined"&&(typeof localStorage=="undefined"&&(localStorage=(new require("node-localstorage")).LocalStorage("./localstorage")),typeof window=="undefined"&&typeof alasql=="undefined"&&(alasql=require("alasql"))),Object.defineProperty(Object.prototype,"__define",{value:function(e,t){return t?Object.defineProperty(this,e,t):Object.defineProperties(this,e),this},enumerable:!1}),Object.prototype.__define("_extend",{value:function(e){var t=function(){};t.prototype=e.prototype,this.prototype=new t,this.prototype.constructor=this,this.__define("superclass",{value:e.prototype,enumerable:!1})},enumerable:!1}),Object.prototype.__define("_mixin",{value:function(e,t,n){var r={},i,s;if(t&&t.length)for(i=0;i<t.length;i++){s=t[i];if(n&&n.indexOf(s)!=-1)continue;if(typeof r[s]=="undefined"||r[s]!=e[s])this[s]=e[s]}else for(s in e){if(n&&n.indexOf(s)!=-1)continue;if(typeof r[s]=="undefined"||r[s]!=e[s])this[s]=e[s]}return this},enumerable:!1}),Object.prototype.__define("_clone",{value:function(){if(!this||"object"!=typeof this)return this;var e,t,n="function"==typeof this.pop?[]:{};for(e in this)this.hasOwnProperty(e)&&(t=this[e],t?"function"==typeof t||t instanceof DataObj||t instanceof DataManager?n[e]=t:"object"==typeof t?n[e]=t._clone():n[e]=t:n[e]=t);return n},enumerable:!1}),!Object.observe&&!Object.unobserve&&!Object.getNotifier&&Object.__define({observe:{value:function(e,t){e._observers||e.__define({_observers:{value:[],enumerable:!1},_notis:{value:[],enumerable:!1}}),e._observers.push(t)},enumerable:!1},unobserve:{value:function(e,t){if(!e._observers)return;for(var n in e._observers)if(e._observers[n]===t){e._observers.splice(n,1);break}},enumerable:!1},getNotifier:{value:function(e){var t;return{notify:function(n){if(!e._observers)return;e._notis.push(n),t||(t=!0,setTimeout(function(){e._observers.forEach(function(t){t(e._notis)}),e._notis.length=0,t=!1},10))}}},enumerable:!1}}),$p.dateFormat=function(){var e=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,t=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,n=/[^-+\dA-Z]/g,r=function(e,t){e=String(e),t=t||2;while(e.length<t)e="0"+e;return e};return function(i,s,o){var u=$p.dateFormat;s||(s=$p.dateFormat.masks.ru),arguments.length==1&&Object.prototype.toString.call(i)=="[object String]"&&!/\d/.test(i)&&(s=i,i=undefined),i=i?new Date(i):new Date,isNaN(i)&&(i=new Date(0)),s=String(u.masks[s]||s||u.masks["default"]),s.slice(0,4)=="UTC:"&&(s=s.slice(4),o=!0);var a=o?"getUTC":"get",f=i[a+"Date"](),l=i[a+"Day"](),c=i[a+"Month"](),h=i[a+"FullYear"](),p=i[a+"Hours"](),d=i[a+"Minutes"](),v=i[a+"Seconds"](),m=i[a+"Milliseconds"](),g=o?0:i.getTimezoneOffset(),y={d:f,dd:r(f),ddd:u.i18n.dayNames[l],dddd:u.i18n.dayNames[l+7],m:c+1,mm:r(c+1),mmm:u.i18n.monthNames[c],mmmm:u.i18n.monthNames[c+12],yy:String(h).slice(2),yyyy:h,h:p%12||12,hh:r(p%12||12),H:p,HH:r(p),M:d,MM:r(d),s:v,ss:r(v),l:r(m,3),L:r(m>99?Math.round(m/10):m),t:p<12?"a":"p",tt:p<12?"am":"pm",T:p<12?"A":"P",TT:p<12?"AM":"PM",Z:o?"UTC":(String(i).match(t)||[""]).pop().replace(n,""),o:(g>0?"-":"+")+r(Math.floor(Math.abs(g)/60)*100+Math.abs(g)%60,4),S:["th","st","nd","rd"][f%10>3?0:(f%100-f%10!=10)*f%10]};return s.replace(e,function(e){return e in y?y[e]:e.slice(1,e.length-1)})}}(),$p.dateFormat.masks={"default":"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'",atom:"yyyy-mm-dd'T'HH:MM:ss'Z'",ru:"dd.mm.yyyy HH:MM",short_ru:"dd.mm.yyyy",date:"dd.mm.yy",date_time:"dd.mm.yy HH:MM"},$p.ajax=new function(){function e(e,t,n,r,i){return new Promise(function(s,o){var u=new XMLHttpRequest;typeof window!="undefined"&&dhx4.isIE&&(t=encodeURI(t));if(r){var a,f;typeof r=="object"&&r.username&&r.hasOwnProperty("password")?(a=r.username,f=r.password):$p.ajax.username&&$p.ajax.authorized?(a=$p.ajax.username,f=$p.ajax.password):(a=$p.wsql.get_user_param("user_name"),f=$p.wsql.get_user_param("user_pwd"),!a&&$p.job_prm&&$p.job_prm.guest_name&&(a=$p.job_prm.guest_name,f=$p.job_prm.guest_pwd)),u.open(e,t,!0,a,f),u.withCredentials=!0,u.setRequestHeader("Authorization","Basic "+btoa(unescape(encodeURIComponent(a+":"+f))))}else u.open(e,t,!0);i&&i.call(this,u),e!="GET"?!this.hide_headers&&!r.hide_headers&&(u.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),u.setRequestHeader("X-Requested-With","XMLHttpRequest")):n=null,u.onload=function(){u.status==200&&(u.response instanceof Blob||u.response.substr(0,9)!=="<!DOCTYPE")?(u.responseURL==undefined&&(u.responseURL=t),s(u)):u.response?o({message:u.statusText,description:u.response,status:u.status}):o(Error(u.statusText))},u.onerror=function(){o(Error("Network Error"))},u.send(n)})}this.username="",this.password="",this.authorized=!1,this.get=function(n){return e.call(this,"GET",n)},this.post=function(n,r){return arguments.length==1?r="":arguments.length==2&&typeof r=="function"?(onLoad=r,r=""):r=String(r),e.call(this,"POST",n,r)},this.get_ex=function(n,r,i){return e.call(this,"GET",n,null,r,i)},this.post_ex=function(n,r,i,s){return e.call(this,"POST",n,r,i,s)},this.put_ex=function(n,r,i,s){return e.call(this,"PUT",n,r,i,s)},this.patch_ex=function(n,r,i,s){return e.call(this,"PATCH",n,r,i,s)},this.delete_ex=function(n,r,i){return e.call(this,"DELETE",n,null,r,i)},this.get_and_show_blob=function(e,t,n){function r(t){return e=window.URL.createObjectURL(t.response),s=window.open(e,"wnd_print",i),s.onload=function(t){window.URL.revokeObjectURL(e)},s}var i="menubar=no,toolbar=no,location=no,status=no,directories=no,resizable=yes,scrollbars=yes",s;return!n||n.toLowerCase().indexOf("post")!=-1?this.post_ex(e,typeof t=="object"?JSON.stringify(t):t,!0,function(e){e.responseType="blob"}).then(r):this.get_ex(e,t,function(e){e.responseType="blob"}).then(r)},this.get_and_save_blob=function(e,t,n){return this.post_ex(e,typeof t=="object"?JSON.stringify(t):t,!0,function(e){e.responseType="blob"}).then(function(e){require("filesaver").saveAs(e.response,n)})},this.default_attr=function(e,t){e.url||(e.url=t),e.username||(e.username=this.username),e.password||(e.password=this.password),e.hide_headers=!0}},$p.m={point_pos:function(e,t,n,r,i,s){return Math.abs(n-i)<.2?(e-n)*(r-s):Math.abs(r-s)<.2?(t-r)*(i-n):(t-r)*(i-n)-(s-r)*(e-n)},arc_cntr:function(e,t,n,r,i,s){var o,u,a,f,l,c,h,p,d;if(s){var v=e,m=t;e=n,t=r,n=v,r=m}return e!=n?(o=(e*e-n*n-r*r+t*t)/(2*(e-n)),u=(r-t)/(e-n),a=u*u+1,f=-2*((e-o)*u+t),l=(e-o)*(e-o)-i*i+t*t,c=(-f+Math.sqrt(f*f-4*a*l))/(2*a),h=o+u*c,p=(-f-Math.sqrt(f*f-4*a*l))/(2*a),d=o+u*p):(o=(t*t-r*r-n*n+e*e)/(2*(t-r)),u=(n-e)/(t-r),a=u*u+1,f=-2*((t-o)*u+e),l=(t-o)*(t-o)-i*i+e*e,h=(-f-Math.sqrt(f*f-4*a*l))/(2*a),c=o+u*h,d=(-f+Math.sqrt(f*f-4*a*l))/(2*a),p=o+u*d),$p.m.point_pos(h,c,e,t,n,r)>0?{x:h,y:c}:{x:d,y:p}},arc_point:function(e,t,n,r,i,s,o){var u={x:(e+n)/2,y:(t+r)/2};if(i>0){var a=e-n,f=t-r,l=i*i-(a*a+f*f)/4,c,h,p;l>=0&&(p=$p.m.arc_cntr(e,t,n,r,i,s),a=p.x-u.x,f=u.y-p.y,c=Math.sqrt(a*a+f*f),o?h=i+Math.sqrt(l):h=i-Math.sqrt(l),u.x+=a*h/c,u.y+=f*h/c)}return u}},$p.blank=new function(){this.date=new Date("0001-01-01"),this.guid="00000000-0000-0000-0000-000000000000",this.by_type=function(e){var t;return e.is_ref?t=$p.blank.guid:e.date_part?t=$p.blank.date:e.digits?t=0:e.types&&e.types[0]=="boolean"?t=!1:t="",t}},$p.is_guid=function(e){return typeof e!="string"||e.length<36?!1:(e.length>36&&(e=e.substr(0,36)),/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(e))},$p.is_empty_guid=function(e){return!e||e===$p.blank.guid},$p.generate_guid=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=(e+Math.random()*16)%16|0;return e=Math.floor(e/16),(t=="x"?n:n&7|8).toString(16)})},$p.fix_guid=function(e,t){if(!e||typeof e!="string"){if(e instanceof DataObj)return e.ref;if(e&&typeof e=="object")if(e.presentation){if(e.ref)return e.ref;if(e.name)return e.name}else e=typeof e.ref=="object"&&e.ref.hasOwnProperty("ref")?e.ref.ref:e.ref}return $p.is_guid(e)||t===!1?e:t?$p.generate_guid():$p.blank.guid},$p.fix_number=function(e,t){var n=parseFloat(e);return isNaN(n)?t?0:e:n},$p.fix_boolean=function(e){return typeof e=="string"?!!e&&e.toLowerCase()!="false":!!e},$p.fix_date=function(e,t){var n=/(^\d{1,4}[\.|\\/|-]\d{1,2}[\.|\\/|-]\d{1,4})(\s*(?:0?[1-9]:[0-5]|1(?=[012])\d:[0-5])\d\s*[ap]m)?$/;if(e instanceof Date)return e;if(e&&typeof e=="string"&&n.test(e.substr(0,10))){var r=e.split(" "),i=r[0].split("."),s,o;i.length==1&&(i=r[0].split("/"),i.length==1&&(i=r[0].split("-")));if(i.length==3&&i[2].length==4){o=i[2]+"-"+i[1]+"-"+i[0];for(var u=1;u<r.length;u++)o+=" "+r[u];s=new Date(o)}else s=new Date(e);if(s&&s.getFullYear()>0)return s}return t?$p.blank.date:e},$p.date_add_day=function(e,t){var n=new Date;return n.setDate(e.getDate()+t),n},$p.cancel_bubble=function(e){var t=e||event;return t&&t.stopPropagation&&t.stopPropagation(),t&&!t.cancelBubble&&(t.cancelBubble=!0),!1},$p.msg=new Messages,$p.iface=new InterfaceObjs,$p.Modifiers=Modifiers,$p.eve=new AppEvents,$p.__define("modifiers",{value:new Modifiers,enumerable:!1,configurable:!1}),$p.wsql=new WSQL;var msg=$p.msg;$p.dateFormat.i18n={dayNames:["Вс","Пн","Вт","Ср","Чт","Пт","Сб","Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота"],monthNames:["Янв","Фев","Maр","Aпр","Maй","Июн","Июл","Aвг","Сен","Окт","Ноя","Дек","Январь","Февраль","Март","Апрель","Maй","Июнь","Июль","Август","Сентябрь","Oктябрь","Ноябрь","Декабрь"]},typeof window!="undefined"&&"dhx4"in window&&(dhx4.dateFormat.ru="%d.%m.%Y",dhx4.dateLang="ru",dhx4.dateStrings={ru:{monthFullName:["Январь","Февраль","Март","Апрель","Maй","Июнь","Июль","Август","Сентябрь","Oктябрь","Ноябрь","Декабрь"],monthShortName:["Янв","Фев","Maр","Aпр","Maй","Июн","Июл","Aвг","Сен","Окт","Ноя","Дек"],dayFullName:["Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота"],dayShortName:["Вс","Пн","Вт","Ср","Чт","Пт","Сб"]}}),$p.msg.russian_names=function(){$p.job_prm.russian_names&&(window.__define({"Метаданные":{get:function(){return _md},enumerable:!1},"Справочники":{get:function(){return _cat},enumerable:!1},"Документы":{get:function(){return _doc},enumerable:!1},"РегистрыСведений":{get:function(){return _ireg},enumerable:!1},"РегистрыНакопления":{get:function(){return _areg},enumerable:!1},"РегистрыБухгалтерии":{get:function(){return _aссreg},enumerable:!1},"Обработки":{get:function(){return _dp},enumerable:!1},"Отчеты":{get:function(){return _rep},enumerable:!1},"ОбластьКонтента":{get:function(){return $p.iface.docs},enumerable:!1},"Сообщить":{get:function(){return $p.msg.show_msg},enumerable:!1},"Истина":{value:!0,enumerable:!1},"Ложь":{value:!1,enumerable:!1}}),DataManager.prototype.__define({"ФормаВыбора":{get:function(){return this.form_selection},enumerable:!1},"ФормаОбъекта":{get:function(){return this.form_obj},enumerable:!1},"Найти":{get:function(){return this.find},enumerable:!1},"НайтиСтроки":{get:function(){return this.find_rows},enumerable:!1},"НайтиПоНаименованию":{get:function(){return this.by_name},enumerable:!1}}),DataObj.prototype.__define({"ФормаОбъекта":{get:function(){return this.form_obj},enumerable:!1}}))},$p.fias=function(){},function(e){e.toString=function(){return"Коды адресного классификатора"},e.types=["владение","здание","помещение"],e[1010]={name:"дом",type:1,order:1,fid:2,syn:[" д."," д "," дом"]},e[1020]={name:"владение",type:1,order:2,fid:1,syn:[" вл."," вл "," влад."," влад "," владен."," владен "," владение"]},e[1030]={name:"домовладение",type:1,order:3,fid:3},e[1050]={name:"корпус",type:2,order:1,syn:[" к."," к "," корп."," корп ","корпус"]},e[1060]={name:"строение",type:2,order:2,fid:1,syn:[" стр."," стр "," строен."," строен ","строение"]},e[1080]={name:"литера",type:2,order:3,fid:3,syn:[" л."," л "," лит."," лит ","литера"]},e[1070]={name:"сооружение",type:2,order:4,fid:2,syn:[" соор."," соор "," сооруж."," сооруж ","сооружение"]},e[1040]={name:"участок",type:2,order:5,syn:[" уч."," уч ","участок"]},e[2010]={name:"квартира",type:3,order:1,syn:["кв.","кв ","кварт.","кварт ","квартира","-"]},e[2030]={name:"офис",type:3,order:2,syn:["оф.","оф ","офис","-"]},e[2040]={name:"бокс",type:3,order:3},e[2020]={name:"помещение",type:3,order:4},e[2050]={name:"комната",type:3,order:5,syn:["комн.","комн ","комната"]},e[101e5]={name:"Почтовый индекс"},e[102e5]={name:"Адресная точка"},e[103e5]={name:"Садовое товарищество"},e[104e5]={name:"Элемент улично-дорожной сети, планировочной структуры дополнительного адресного элемента"},e[105e5]={name:"Промышленная зона"},e[106e5]={name:"Гаражно-строительный кооператив"},e[107e5]={name:"Территория"}}($p.fias),msg.store_url_od="https://chrome.google.com/webstore/detail/hcncallbdlondnoadgjomnhifopfaage",msg.align_node_right="Уравнять вертикально вправо",msg.align_node_bottom="Уравнять горизонтально вниз",msg.align_node_top="Уравнять горизонтально вверх",msg.align_node_left="Уравнять вертикально влево",msg.align_set_right="Установить размер сдвигом вправо",msg.align_set_bottom="Установить размер сдвигом вниз",msg.align_set_top="Установить размер сдвигом вверх",msg.align_set_left="Установить размер сдвигом влево",msg.align_invalid_direction="Неприменимо для элемента с данной ориентацией",msg.argument_is_not_ref="Аргумент не является ссылкой",msg.addr_title="Ввод адреса",msg.cache_update_title="Обновление кеша браузера",msg.cache_update="Выполняется загрузка измененных файлов<br/>и их кеширование в хранилище браузера",msg.delivery_area_empty="Укажите район доставки",msg.empty_login_password="Не указаны имя пользователя или пароль",msg.empty_response="Пустой ответ сервера",msg.empty_geocoding="Пустой ответ геокодера. Вероятно, отслеживание адреса запрещено в настройках браузера",msg.error_auth="Авторизация пользователя не выполнена",msg.error_critical="Критическая ошибка",msg.error_metadata="Ошибка загрузки метаданных конфигурации",msg.error_network="Ошибка сети или сервера - запрос отклонен",msg.error_rights="Ограничение доступа",msg.file_size="Запрещена загрузка файлов<br/>размером более ",msg.file_confirm_delete="Подтвердите удаление файла ",msg.file_new_date="Файлы на сервере обновлены<br /> Рекомендуется закрыть браузер и войти<br />повторно для применения обновления",msg.file_new_date_title="Версия файлов",msg.init_catalogues="Загрузка справочников с сервера",msg.init_catalogues_meta=": Метаданные объектов",msg.init_catalogues_tables=": Реструктуризация таблиц",msg.init_catalogues_nom=": Базовые типы + номенклатура",msg.init_catalogues_sys=": Технологические справочники",msg.init_login="Укажите имя пользователя и пароль",msg.requery="Повторите попытку через 1-2 минуты",msg.limit_query="Превышено число обращений к серверу<br/>Запросов за минуту:%1<br/>Лимит запросов:%2<br/>"+msg.requery,msg.long_operation="Длительная операция",msg.main_title="Окнософт: заказ дилера ",msg.meta_cat="Справочники",msg.meta_doc="Документы",msg.meta_cch="Планы видов характеристик",msg.meta_cacc="Планы счетов",msg.meta_ireg="Регистры сведений",msg.meta_areg="Регистры накопления",msg.meta_mgr="Менеджер",msg.meta_cat_mgr="Менеджер справочников",msg.meta_doc_mgr="Менеджер документов",msg.meta_enn_mgr="Менеджер перечислений",msg.meta_ireg_mgr="Менеджер регистров сведений",msg.meta_areg_mgr="Менеджер регистров накопления",msg.meta_accreg_mgr="Менеджер регистров бухгалтерии",msg.meta_dp_mgr="Менеджер обработок",msg.meta_reports_mgr="Менеджер отчетов",msg.meta_charts_of_accounts_mgr="Менеджер планов счетов",msg.meta_charts_of_characteristic_mgr="Менеджер планов видов характеристик",msg.meta_extender="Модификаторы объектов и менеджеров",msg.no_metadata="Не найдены метаданные объекта '%1'",msg.no_selected_row="Не выбрана строка табличной части '%1'",msg.no_dhtmlx="Библиотека dhtmlx не загружена",msg.not_implemented="Не реализовано в текущей версии",msg.offline_request="Запрос к серверу в автономном режиме",msg.onbeforeunload="Окнософт: легкий клиент. Закрыть программу?",msg.order_sent_title="Подтвердите отправку заказа",msg.order_sent_message="Отправленный заказ нельзя изменить.<br/>После проверки менеджером<br/>он будет запущен в работу",msg.request_title="Окнософт: Запрос регистрации",msg.request_message="Заявка зарегистрирована. После обработки менеджером будет сформировано ответное письмо",msg.select_from_list="Выбор из списка",msg.select_grp="Укажите группу, а не элемент",msg.select_elm="Укажите элемент, а не группу",msg.select_file_import="Укажите файл для импорта",msg.srv_overload="Сервер перегружен",msg.sub_row_change_disabled="Текущая строка подчинена продукции.<br/>Строку нельзя изменить-удалить в документе<br/>только через построитель",msg.sync_script="Обновление скриптов приложения:",msg.sync_data="Синхронизация с сервером выполняется:<br />* при первом старте программы<br /> * при обновлении метаданных<br /> * при изменении цен или технологических справочников",msg.sync_break="Прервать синхронизацию",msg.sync_no_data="Файл не содержит подходящих элементов для загрузки",msg.unsupported_browser_title="Браузер не поддерживается",msg.unsupported_browser="Несовместимая версия браузера<br/>Рекомендуется Google Chrome",msg.supported_browsers="Рекомендуется Chrome, Safari или Opera",msg.unsupported_mode_title="Режим не поддерживается",msg.unsupported_mode="Программа не установлена<br/> в <a href='"+msg.store_url_od+"'>приложениях Google Chrome</a>",msg.unknown_error="Неизвестная ошибка в функции '%1'",msg.value="Значение",msg.bld_constructor="Конструктор объектов графического построителя",msg.bld_title="Графический построитель",msg.bld_empty_param="Не заполнен обязательный параметр <br />",msg.bld_not_product="В текущей строке нет изделия построителя",msg.bld_not_draw="Отсутствует эскиз или не указана система профилей",msg.bld_wnd_title="Построитель изделия № ",msg.bld_from_blocks_title="Выбор типового блока",msg.bld_from_blocks="Текущее изделие будет заменено конфигурацией типового блока. Продолжить?",msg.bld_split_imp="В параметрах продукции<br />'%1'<br />запрещены незамкнутые контуры<br />Для включения деления импостом,<br />установите это свойство в 'Истина'";var eXcell_proto=new eXcell;eXcell_proto.input_keydown=function(e,t){function n(e){t.source.on_select&&t.source.on_select.call(t.source,e)}if(e.keyCode===8||e.keyCode===46)t.setValue(""),t.grid.editStop(),t.source.on_select&&t.source.on_select.call(t.source,"");else if(e.keyCode===9||e.keyCode===13)t.grid.editStop();else if(e.keyCode===115)t.cell.firstChild.childNodes[1].onclick(e);else if(e.keyCode===113)if(t.source.tabular_section){t.mgr=_md.value_mgr(t.source.row,t.source.col,t.source.row._metadata.fields[t.source.col].type);if(t.mgr){var r=t.source.row[t.source.col];t.mgr.form_obj(t.source.wnd,{o:r,on_select:n})}}else if(t.fpath.length==1){t.mgr=_md.value_mgr(t.source.o._obj,t.fpath[0],t.source.o._metadata.fields[t.fpath[0]].type);if(t.mgr){var r=t.source.o[t.fpath[0]];t.mgr.form_obj(t.source.wnd,{o:r,on_select:n})}}return $p.cancel_bubble(e)},eXcell_ocombo.prototype=eXcell_proto,window.eXcell_ocombo=eXcell_ocombo,window.eXcell_ref=eXcell_ocombo,window.eXcell_refc=eXcell_ocombo,eXcell_pwd.prototype=eXcell_proto,window.eXcell_pwd=eXcell_pwd,dhtmlXForm.prototype.btn_click=function(e){function t(){if(!this.itemPull[this.idPrefix+e]){var n=null;for(var i in this.itemPull)if(this.itemPull[i]._list&&!n)for(var s=0;s<this.itemPull[i]._list.length;s++)n==null&&(n=t.call(this.itemPull[i]._list[s]));return n}return r=this.itemPull[this.idPrefix+e],this.objPull[this.idPrefix+e]}var n=this,r,i=t.call(n);r&&(r.firstChild.dispatchEvent(new MouseEvent("mousedown"),{bubbles:!0,cancelable:!0,view:window}),setTimeout(function(){r.firstChild.dispatchEvent(new MouseEvent("mouseup"),{bubbles:!0,cancelable:!0,view:window})},1))},dhtmlXCalendarObject.prototype._dateToStr=function(e,t){return e instanceof Date&&e.getFullYear()<1e3?"":window.dhx4.date2str(e,t||this._dateFormat,this._dateStrings())},eXcell_dhxCalendar.prototype.edit=function(){var e=this.grid.getPosition(this.cell);this.grid._grid_calendarA._show(!1,!1),this.grid._grid_calendarA.setPosition(e[0],e[1]+this.cell.offsetHeight),this.grid._grid_calendarA._last_operation_calendar=!1,this.grid.callEvent("onCalendarShow",[this.grid._grid_calendarA,this.cell.parentNode.idd,this.cell._cellIndex]),this.cell._cediton=!0,this.val=this.cell.val,this.val instanceof Date&&this.val.getFullYear()<1e3&&(this.val=new Date),this._val=this.cell.innerHTML;var t=this.grid._grid_calendarA.draw;this.grid._grid_calendarA.draw=function(){},this.grid._grid_calendarA.setDateFormat(this.grid._dtmask||"%d.%m.%Y"),this.grid._grid_calendarA.setDate(this.val||new Date),this.grid._grid_calendarA.draw=t},function(){function e(e,t,n,r){if(n.indexOf("odata/standard.odata")!=-1||n.indexOf("/hs/rest")!=-1){var i,s;$p.ajax.authorized?(i=$p.ajax.username,s=$p.ajax.password):$p.job_prm.guest_name?(i=$p.job_prm.guest_name,s=$p.job_prm.guest_pwd):(i=$p.wsql.get_user_param("user_name"),s=$p.wsql.get_user_param("user_pwd")),e.open(t,n,r,i,s),e.withCredentials=!0,e.setRequestHeader("Authorization","Basic "+btoa(unescape(encodeURIComponent(i+":"+s))))}else e.open(t,n,r)}dhx4.ajax._call=function(t,n,r,i,s,o,u){var a=window.XMLHttpRequest&&!dhx4.isIE?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"),f=navigator.userAgent.match(/AppleWebKit/)!=null&&navigator.userAgent.match(/Qt/)!=null&&navigator.userAgent.match(/Safari/)!=null;i==1&&(a.onreadystatechange=function(){if(a.readyState==4||f==1&&a.readyState==3){if(a.status!=200||a.responseText=="")if(!dhx4.callEvent("onAjaxError",[{xmlDoc:a,filePath:n,async:i}]))return;window.setTimeout(function(){typeof s=="function"&&s.apply(window,[{xmlDoc:a,filePath:n,async:i}]),o!=null&&(typeof o.postData!="undefined"?dhx4.ajax.postLong(o.url,o.postData,s):dhx4.ajax.getLong(o.url,s)),s=null,a=null},1)}}),t=="GET"&&this.cache!=1&&(n+=(n.indexOf("?")>=0?"&":"?")+"dhxr"+(new Date).getTime()+"=1"),e(a,t,n,i);if(u!=null)for(var l in u)a.setRequestHeader(l,u[l]);else t=="POST"||t=="PUT"||t=="DELETE"?a.setRequestHeader("Content-Type","application/x-www-form-urlencoded"):t=="GET"&&(r=null);return a.setRequestHeader("X-Requested-With","XMLHttpRequest"),a.send(r),{xmlDoc:a,filePath:n,async:i}},dhtmlx.ajax.prototype.send=function(t,n,r){var i=this.getXHR();typeof r=="function"&&(r=[r]);if(typeof n=="object"){var s=[];for(var o in n){var u=n[o];if(u===null||u===dhtmlx.undefined)u="";s.push(o+"="+encodeURIComponent(u))}n=s.join("&")}n&&!this.post&&(t=t+(t.indexOf("?")!=-1?"&":"?")+n,n=null),e(i,this.post?"POST":"GET",t,!this._sync),this.post&&i.setRequestHeader("Content-type","application/x-www-form-urlencoded");var a=this;return i.onreadystatechange=function(){if(!i.readyState||i.readyState==4){if(r&&a)for(var e=0;e<r.length;e++)r[e]&&r[e].call(a.master||a,i.responseText,i.responseXML,i);a.master=null,r=a=null}},i.send(n||null),i}}(),$p.iface.data_to_grid=function(e,t){function n(e){var t;return e.is_folder?t="cell_ref_folder":t="cell_ref_elm",e.deleted&&(t+="_deleted"),t}function r(e,t){return t=="svg"?$p.iface.normalize_xml(e[t]):e[t]instanceof Date?e[t].getHours()||e.date.getMinutes()?$p.dateFormat(e[t],$p.dateFormat.masks.date_time):$p.dateFormat(e[t],$p.dateFormat.masks.date):e[t]||""}if(this.data_to_grid)return this.data_to_grid(e,t);var i="<?xml version='1.0' encoding='UTF-8'?><rows total_count='%1' pos='%2' set_parent='%3'>".replace("%1",e.length).replace("%2",t.start).replace("%3",t.set_parent||""),s=this.caption_flds(t);return i+=s.head,e.forEach(function(e){i+='<row id="'+e.ref+'"><cell class="'+n(e)+'">'+r(e,[s.acols[0].id])+"</cell>";for(var t=1;t<s.acols.length;t++)i+="<cell>"+r(e,[s.acols[t].id])+"</cell>";i+="</row>"}),i+"</rows>"},$p.iface.data_to_tree=function(e){function t(e,r){n=n+'<item text="'+e.presentation.replace(/"/g,"'")+'" id="'+e.ref+'" im0="folderClosed.gif">',$p._find_rows(r,{parent:e.ref},function(e){t(e,r)}),n+="</item>"}var n="<?xml version='1.0' encoding='UTF-8'?><tree id=\"0\">";return t({presentation:"...",ref:$p.blank.guid},[]),$p._find_rows(e,{parent:$p.blank.guid},function(n){t(n,e)}),n+"</tree>"},$p.iface.ODropdownList=ODropdownList,OCombo._extend(dhtmlXCombo),$p.iface.OCombo=OCombo,$p.iface.select_from_list=function(e,t){return new Promise(function(n,r){function i(e){e!="cancel"&&(o=f.getSelectedRowId()),a.close()}!Array.isArray(e)||!e.length?n(undefined):e.length==1&&n(e[0]);var s={name:"wnd_select_from_list",wnd:{id:"wnd_select_from_list",width:300,height:300,modal:!0,center:!0,caption:$p.msg.select_from_list,allow_close:!0,on_close:function(){return o&&n(e[parseInt(o)-1]),!0}}},o,u,a=$p.iface.dat_blank(null,s.wnd),f=a.attachGrid(),l=a.attachToolbar({items:[{id:"select",type:"button",text:$p.msg.select_from_list},{id:"cancel",type:"button",text:"Отмена"}],onClick:i});f.setIconsPath(dhtmlx.image_path),f.setImagePath(dhtmlx.image_path),f.setHeader($p.msg.value),f.setColTypes("ro"),f.enableAutoWidth(!0,1200,600),f.attachEvent("onRowDblClicked",i),f.enableMultiselect(!!t),f.setNoHeader(!0),f.init(),l.addSpacer("select"),a.hideHeader(),a.cell.offsetParent.querySelector(".dhxwin_brd").style.border="none",e.forEach(function(e,t){var n;typeof e=="object"?n=e.presentation||e.text||e.toString():n=e.toString(),f.addRow(1+t,n),e.selected&&(u=1+t)}),u&&f.selectRowById(u)})},dhtmlXCellObject.prototype.attachHeadFields=function(e){function t(e){if(!r){var i=[];e.forEach(function(e){i.indexOf[e.object]==-1&&(i.push(e.object),Object.unobserve(e.object,t),f&&f instanceof TabularSection&&Object.unobserve(e.object,n))}),i=null}else h.entBox&&!h.entBox.parentElement?setTimeout(h.destructor):e.forEach(function(e){e.type=="unload"?c&&c.close?c.close():h.destructor():h.forEachRow(function(t){t==e.name&&h.cells(t,1).setValue(r[e.name])})})}function n(t){var n;t.forEach(function(t){!n&&a==t.tabular&&(n=!0,h.clearAll(),h.parse(o.get_property_grid_xml(i,r,{title:e.ts_title,ts:a,selection:u,meta:s}),function(){},"xml"))})}var r,i,s,o,u,a,f,l,c=this,h=this.attachGrid(),p=h.destructor;return f&&!a&&(a=r.extra_fields?"extra_fields":"ДополнительныеРеквизиты"),new dhtmlXPropertyGrid(h),h.setInitWidthsP("40,60"),h.setDateFormat("%d.%m.%Y %H:%i"),h.init(),h.setSizes(),h.attachEvent("onPropertyChanged",function(e,t,n){if(e)return l.on_select(t)}),h.attachEvent("onCheckbox",function(e,t,n){if(r[e]!=undefined)return l.on_select(n,{obj:r,field:e})}),h.get_cell_field=function(){if(!r)return;var e={row_id:h.getSelectedRowId()},t=e.row_id.split("|");if(t.length<2)return{obj:r,field:t[0]}._mixin(l);var n=r[t[0]].find(t[1]);if(n)return e.obj=n,n["Значение"]?(e.field="Значение",e.property=n.Свойство||n.Параметр):(e.field="value",e.property=n.property||n.param),e._mixin(l)},h.destructor=function(){r&&Object.unobserve(r,t),f&&f instanceof TabularSection&&Object.unobserve(f,n),r=null,f=null,s=null,o=null,l=null,p.call(h)},h.__define("selection",{get:function(){return u},set:function(e){u=e,n([{tabular:a}])},enumerable:!1}),h.attach=function(e){r&&Object.unobserve(r,t),f&&f instanceof TabularSection&&Object.unobserve(r,n),e.oxml&&(i=e.oxml),e.selection&&(u=e.selection),r=e.obj,s=e.meta||r._metadata.fields,o=r._manager,a=e.ts||"",f=a?r[a]:r.extra_fields||r["ДополнительныеРеквизиты"],l={on_select:function(e,t){t||(t=h.get_cell_field());if(t){var n=o.handle_event(r,"value_change",{field:t.field,value:e,tabular_section:t.row_id?a:"",grid:h,cell:h.cells(t.row_id||t.field,1),wnd:l.pwnd});return typeof n!="boolean"&&(t.obj[t.field]=e,n=!0),n}},pwnd:e.pwnd||c},Object.observe(r,t,["update","unload"]),f&&f instanceof TabularSection&&Object.observe(r,n,["row"]),n([{tabular:a}])},e&&h.attach(e),h},dhtmlXGridObject.prototype.get_cell_value=function(){var e=this.get_cell_field();if(e&&e.obj)return e.obj[e.field]},dhtmlXCellObject.prototype.attachTabular=function(e){function t(e){var t=v.getSelectedRowId();if(t&&!isNaN(Number(t)))return Number(t)-1;e||$p.msg.show_msg({type:"alert-warning",text:$p.msg.no_selected_row.replace("%1",u._metadata.tabular_sections[a].synonym||a),title:(u._metadata.obj_presentation||u._metadata.synonym)+": "+u.presentation})}function n(){var e=f.add();setTimeout(function(){v.selectRowById(e.row)},100)}function r(){var e=t();e!=undefined&&f.del(e)}function i(e,t,n,r,i){if(e!=2||r==i)return!0;var s=v.get_cell_field(),o=l.handle_event(u,"value_change",{field:s.field,value:r,tabular_section:a,grid:v,row:s.obj,cell:t&&n?v.cells(t,n):v.cells(),wnd:y.pwnd});return typeof o!="boolean"&&(s.obj[s.field]=r,o=!0),o}function s(e){var t;e.forEach(function(e){!t&&a==e.tabular&&(t=!0,f.sync_grid(v,d))})}function o(e){if(e.length>4)try{f.sync_grid(v,d)}catch(t){}else e.forEach(function(e){if(a==e.tabular)if(v.getSelectedRowId()!=e.row.row)f.sync_grid(v,d);else{var t=v.cells(e.row.row,v.getColIndexById(e.name));t.setCValue($p.is_data_obj(e.row[e.name])?e.row[e.name].presentation:e.row[e.name])}})}var u=e.obj,a=e.ts,f=u[a],l=u._manager,c=e.meta||l.metadata().tabular_sections[a].fields,h=this,p={},d=e.selection;if(!_md.ts_captions(l.class_name,a,p))return;var v=this.attachGrid(),m=this.attachToolbar(),g=v.destructor,y={on_select:function(e){i(2,null,null,e)},pwnd:e.pwnd||h,is_tabular:!0};return v.setDateFormat("%d.%m.%Y %H:%i"),m.setIconsPath(dhtmlx.image_path+"dhxtoolbar"+dhtmlx.skin_suffix()),m.loadStruct(require("toolbar_add_del"),function(){this.attachEvent("onclick",function(e){e=="btn_add"?n():e=="btn_delete"&&r()})}),v.setIconsPath(dhtmlx.image_path),v.setImagePath(dhtmlx.image_path),v.setHeader(p.headers),p.min_widths&&v.setInitWidths(p.widths),p.min_widths&&v.setColumnMinWidth(p.min_widths),p.aligns&&v.setColAlign(p.aligns),v.setColSorting(p.sortings),v.setColTypes(p.types),v.setColumnIds(p.fields.join(",")),v.enableAutoWidth(!0,1200,600),v.enableEditTabOnly(!0),v.init(),v.attachEvent("onEditCell",i),v.get_cell_field=function(){var e=t(!0),n=v.getSelectedCellIndex(),r,i;if(f&&e!=undefined&&n>=0)return r=f.get(e),i=v.getColumnId(n),{obj:r,field:i}._mixin(y)},v.destructor=function(){u&&(Object.unobserve(u,o),Object.unobserve(u,s)),u=null,f=null,c=null,l=null,y=null,h.detachToolbar(),g.call(v)},v.__define("selection",{get:function(){return d},set:function(e){d=e,s([{tabular:a}])},enumerable:!1}),s([{tabular:a}]),Object.observe(u,o,["row"]),Object.observe(u,s,["rows"]),v};if(typeof window!="undefined"&&"dhtmlx"in window){function eXcell_rsvg(e){e&&(this.cell=e,this.grid=this.cell.parentNode.grid),this.edit=function(){},this.isDisabled=function(){return!0},this.setValue=function(e){this.setCValue(e?$p.iface.scale_svg(e,120,10):"нет эскиза")}}eXcell_rsvg.prototype=eXcell_proto,window.eXcell_rsvg=eXcell_rsvg,$p.iface.OSvgs=function(e,t,n){function r(){u.style.display=f?"none":"";if(t.setSizes)t.setSizes();else{var e=t.getDimension();t.setDimension(e[0],e[1]),t.maximize()}f?(o.style.backgroundPositionX="-32px",o.style.top=t.setSizes?"16px":"-18px"):(o.style.backgroundPositionX="0px",o.style.top="0px")}function i(e){var t,n,r,i;$p.iface.clear_svgs(u);if(!!e.svgs.length)for(t in e.svgs){if(!e.svgs[t]||e.svgs[t].substr(0,1)!="<")continue;i=document.createElement("div"),u.appendChild(i),i.style["float"]="left",i.innerHTML=$p.iface.scale_svg(e.svgs[t],88,22)}}var s=this,o=document.createElement("div"),u=document.createElement("div"),a=[],f=$p.wsql.get_user_param("svgs_area_hidden","boolean"),l=n.querySelector(".dhx_cell_statusbar_text");l&&(l.style.display="none"),u.className="svgs-area",n.firstChild?n.insertBefore(u,n.firstChild):n.appendChild(u),o.className="svgs-minmax",o.title="Скрыть/показать панель эскизов",o.onclick=function(){f=!f,$p.wsql.set_user_param("svgs_area_hidden",f),r(),!f&&a.length&&s.reload()},n.appendChild(o),r(),this.reload=function(t){t&&a.push(t),f||setTimeout(function(){a.length&&(e.save({ref:a.pop(),specify:"order_pics",action:"calc",async:!0}).then(i).catch(function(e){console.log(e)}),a.length=0)},300)}}}$p.iface.Toolbar_filter=function(e){function t(){s&&(clearTimeout(s),s=0),e.onchange.call(r,r.get_filter())}function n(){s&&clearTimeout(s),s=setTimeout(function(){s&&t()},600)}var r=this,i=350,s=0;e.pos||(e.pos=6);if(e.manager instanceof DocManager||e.period){function o(e,t){t=="min"?r.сalendar.setSensitiveRange(e.value,null):r.сalendar.setSensitiveRange(null,e.value)}i=180,e.toolbar.addText("lbl_date_from",e.pos,"Период с:"),e.pos++,e.toolbar.addInput("input_date_from",e.pos,"",72),e.pos++,e.toolbar.addText("lbl_date_till",e.pos,"по:"),e.pos++,e.toolbar.addInput("input_date_till",e.pos,"",72),e.pos++,r.input_date_from=e.toolbar.getInput("input_date_from"),r.input_date_from.setAttribute("readOnly","true"),r.input_date_from.onclick=function(){o(r.input_date_till,"max")},r.input_date_till=e.toolbar.getInput("input_date_till"),r.input_date_till.setAttribute("readOnly","true"),r.input_date_till.onclick=function(){o(r.input_date_from,"min")},r.сalendar=new dhtmlXCalendarObject([r.input_date_from,r.input_date_till]),r.сalendar.attachEvent("onclick",t),e.date_from||(e.date_from=new Date((new Date).getFullYear().toFixed()+"-01-01")),e.date_till||(e.date_till=$p.date_add_day(new Date,1)),r.input_date_from.value=$p.dateFormat(e.date_from,$p.dateFormat.masks.short_ru),r.input_date_till.value=$p.dateFormat(e.date_till,$p.dateFormat.masks.short_ru)}e.hide_filter?e.toolbar.addSpacer("input_date_till"):(e.toolbar.addText("lbl_filter",e.pos,"Фильтр"),e.pos++,e.toolbar.addInput("input_filter",e.pos,"",i),r.input_filter=e.toolbar.getInput("input_filter"),r.input_filter.onchange=t,r.input_filter.onkeydown=n,r.input_filter.type="search",e.toolbar.addSpacer("input_filter")),r.get_filter=function(){return{date_from:r.input_date_from?dhx4.str2date(r.input_date_from.value):"",date_till:r.input_date_till?dhx4.str2date(r.input_date_till.value):"",filter:r.input_filter?r.input_filter.value:""}}},dhtmlXCellObject.prototype.attachDynTree=function(e,t,n){this.setCollapsedText&&this.setCollapsedText("Дерево"),t||(t={is_folder:!0});var r=this.attachTree();return r.setImagePath(dhtmlx.image_path+"dhxtree"+dhtmlx.skin_suffix()),r.setIconsPath(dhtmlx.image_path+"dhxtree"+dhtmlx.skin_suffix()),$p.device_type=="desktop"&&r.enableKeyboardNavigation(!0),r.__define({filter:{get:function(){},set:function(e){t=e},enumerable:!1,configurable:!1}}),setTimeout(function(){$p.cat.load_soap_to_grid({action:"get_tree",class_name:e.class_name,filter:t},r,n)}),r},dhtmlXCellObject.prototype.attachDynDataView=function(e,t){function n(){i&&clearTimeout(i),i=setTimeout(s.requery,200)}t||(t={});var r={type:t.type||{template:"#name#"}},i,s;return t.pager&&(r.pager=t.pager),t.hasOwnProperty("drag")&&(r.drag=t.drag),t.hasOwnProperty("select")&&(r.select=t.select),t.hasOwnProperty("multiselect")&&(r.multiselect=t.multiselect),t.hasOwnProperty("height")&&(r.height=t.height),t.hasOwnProperty("tooltip")&&(r.tooltip=t.tooltip),t.hasOwnProperty("autowidth")&&(r.autowidth=t.autowidth),t.custom_css&&["list","large","small"].forEach(function(e){dhtmlXDataView.prototype.types[e].css=e}),t.container?(r.container=t.container,s=new dhtmlXDataView(r)):s=this.attachDataView(r),dv_tools=new $p.iface.OTooolBar({wrapper:t.outer_container||this.cell,width:"86px",height:"28px",bottom:"2px",right:"28px",name:"dataview_tools",image_path:dhtmlx.image_path+"dhxdataview"+dhtmlx.skin_suffix(),buttons:[{name:"list",img:"dataview_list.png",title:"Список (детально)","float":"left"},{name:"large",img:"dataview_large.png",title:"Крупные значки","float":"left"},{name:"small",img:"dataview_small.png",title:"Мелкие значки","float":"left"}],onclick:function(e){var t=dhtmlXDataView.prototype.types[e];e=="list"?s.config.autowidth=1:s.config.autowidth=Math.floor(s._dataobj.scrollWidth/(t.width+t.padding*2+t.margin*2+t.border*2)),s.define("type",e)}}),s.__define({filter:{get:function(){},set:function(e){t.filter=e}},requery:{value:function(){t.url="",_rest.build_select(t,e),t.filter_prop&&(t.url+="&filter_prop="+JSON.stringify(t.filter_prop)),dhx4.isIE&&(t.url=encodeURI(t.url)),s.clearAll(),s._settings&&(s._settings.datatype="json"),s.load(t.url,"json",function(e){e&&s.show(s.first())}),i=0}},hash_route:{value:function(e){e.obj&&t.selection.ВидНоменклатуры!=e.obj&&(t.selection.ВидНоменклатуры=e.obj,n())}}}),$p.eve.hash_route.push(s.hash_route),dhx4.attachEvent("search_text_change",function(e){e?t.selection.text=function(){return"text like '%25"+e+"%25'"}:t.selection.hasOwnProperty("text")&&delete t.selection.text,n()}),dhx4.attachEvent("filter_prop_change",function(e){t.filter_prop=e,n()}),setTimeout(function(){s.hash_route($p.job_prm.parse_url())},50),s},$p.iface.dat_blank=function(e,t){t||(t={});var n,r=!1,i=t.id||"wnd_dat_"+dhx4.newId();return n=(e||$p.iface.w).createWindow({id:i,left:t.left||900,top:t.top||20,width:t.width||220,height:t.height||300,move:!0,park:!t.allow_close,center:!!t.center,resize:!0,caption:t.caption||"Tools"}),e=null,t.allow_minmax||n.button("minmax").hide(),t.allow_close?n.button("park").hide():n.button("close").hide(),typeof t.on_close=="function"&&n.attachEvent("onClose",t.on_close),n.setIconCss("without_icon"),n.cell.parentNode.children[1].classList.add("dat_gui"),$p.iface.bind_help(n,t.help_path),n.elmnts={},n.__define("modified",{get:function(){return r},set:function(e){r=e;var t=n.getText();r&&t.lastIndexOf("*")!=t.length-1?n.setText(t+" *"):!r&&t.lastIndexOf("*")==t.length-1&&n.setText(t.replace(" *",""))},enumerable:!1,configurable:!1}),n.wnd_options=function(e){var t=n.getPosition(),r=n.getDimension(),i=n.isParked();e.left=t[0],e.top=t[1],e.width=r[0],e.parked=i,i||(e.height=r[1])},n.bottom_toolbar=function(e){var t={wrapper:n.cell,width:"100%",height:"28px",bottom:"0px",left:"0px",name:"tb_bottom",buttons:[{name:"btn_cancel",text:"Отмена",title:"Закрыть без сохранения",width:"60px","float":"right"},{name:"btn_ok",b:"Ок",title:"Применить изменения",width:"30px","float":"right"}],onclick:function(e){return!1}}._mixin(e),r=new OTooolBar(t),i=n.attachStatusBar({height:12});return i.style.zIndex=-1e3,i.firstChild.style.backgroundColor="transparent",i.firstChild.style.border="none",r},t.modal&&(t.pwnd&&t.pwnd.setModal&&t.pwnd.setModal(0),n.setModal(1)),n},$p.iface.dat_tree=function(e,t){var n=$p.iface.dat_blank(e,t),r=document.createElement("div"),i=document.createElement("div"),s=document.createElement("div"),o=[{type:"combo",name:"cb_sys",label:"Система"},{type:"combo",name:"cb_clr",label:"Цвет"},{type:"settings",labelWidth:50,inputWidth:160,offsetLeft:0,offsetTop:0}];return e=null,n.setMinDimension(250,300),n.attachObject(r),r.appendChild(i),r.appendChild(s),n.cell_a=i,n.tree=new dhtmlXTreeObject(s,"100%","100%",0),n.tree.setImagePath(dhtmlx.image_path+"dhxtree"+dhtmlx.skin_suffix()),n.tree.setIconsPath(dhtmlx.image_path+"dhxtree"+dhtmlx.skin_suffix()),n.tree.enableCheckBoxes(!0,!0),n.tree.enableTreeImages(!1),n},$p.iface.dat_pgrid=function(e,t){var n=$p.iface.dat_blank(e,t);e=null,n.setMinDimension(320,300);var r=n.elmnts.pgrid=n.attachPropertyGrid();return r.setDateFormat("%d.%m.%Y %H:%i"),r.init(),t.grid_struct&&r.parse(t.o._manager.get_property_grid_xml(t.grid_struct,t.v),function(){r.enableAutoHeight(!1),r.setSizes(),r.setUserData("","source",{o:t.v,grid:r,on_select:$p.iface.pgrid_on_select,slist:t.grid_slist,grid_on_change:t.grid_on_change,wnd:n}),r.attachEvent("onPropertyChanged",$p.iface.pgrid_on_change),r.attachEvent("onCheckbox",$p.iface.pgrid_on_checkbox)},"xml"),n},$p.iface.pgrid_on_select=function(e){if(e===undefined)return;var t=this.grid instanceof dhtmlXGridObject?this.grid:this,n=t.getUserData("","source"),r=t.getSelectedRowId();if(n.o[r]!=undefined)typeof n.o[r]=="number"?n.o[r]=$p.fix_number(e,!0):n.o[r]=e;else if(r.indexOf("fprms")>-1){var i=$p._find(n.o.fprms,r.split("|")[1]);i.value=e}t.cells().setValue($p.is_data_obj(e)?e.presentation:e||""),n.wnd&&(n.wnd.modified=!0),n.grid_on_change&&n.grid_on_change.call(t,r,e)},$p.iface.pgrid_on_change=function(e,t,n){e&&$p.iface.pgrid_on_select.call(this,t)},$p.iface.pgrid_on_checkbox=function(e,t,n){var r=this.grid instanceof dhtmlXGridObject?this.grid:this,i=r.getUserData("","source");i.o[e]!=undefined&&(i.o[e]=n),i.wnd&&(i.wnd.modified=!0),i.grid_on_change&&i.grid_on_change(e,n)},$p.iface.layout_2u=function(e){var t=$p.iface;return t.main=new dhtmlXLayoutObject({parent:document.body,pattern:"2U"}),t.main.attachEvent("onCollapse",function(e){if(e=="b")return t.docs.expand(),!1}),t.docs=t.main.cells("b"),_clear_all(),t.cell_tree=t.main.cells("a"),t.cell_tree.setText("Режим"),t.cell_tree.setWidth("190"),t.cell_tree.fixSize(!1,!1),t.cell_tree.collapse(),t.tree=t.cell_tree.attachTree(),t.tree.setImagePath(dhtmlx.image_path+"dhxtree"+dhtmlx.skin_suffix()),t.tree.setIconsPath(dhtmlx.image_path+"dhxtree"+dhtmlx.skin_suffix()),e?(t.tree.attachEvent("onSelect",e.onselect),new Promise(function(n,r){t.tree.loadXML(e.path+"?v="+$p.job_prm.files_date,function(){this.tree_filteres=e.path,n(this)})})):(t.tree.attachEvent("onSelect",function(e){var n=e.split(".");if(n.length>1&&t.swith_view(n[0])=="oper"){var r=$p.md.mgr_by_class_name(e.substr(5));typeof t.docs.close=="function"&&t.docs.close(),r&&r.form_list(t.docs,{})}}),Promise.resolve(t.tree))},$p.iface.layout_1c=function(){var e=$p.iface;return new Promise(function(t,n){try{e.main=new dhtmlXLayoutObject({parent:document.body,pattern:"1C",offsets:{top:4,right:4,bottom:4,left:4}}),e.docs=e.main.cells("a"),_clear_all(),t(!0)}catch(r){n(r)}})},$p.iface.frm_auth=function(e,t,n,r){function i(r,i,s){$p.ajax.username=r,$p.ajax.password=i,r?(s||$p.wsql.set_user_param("user_name",r),$p.is_guid($p.wsql.get_user_param("browser_uid"))||$p.wsql.set_user_param("browser_uid",$p.generate_guid()),$p.eve.log_in(e).then(o.on_auth||t).catch(function(e){a=!0,(o.on_error||n)&&(o.on_error||n)(e)}).then(function(e){$p.iface.sync&&$p.iface.sync.close(),$p.iface.docs&&($p.iface.docs.progressOff(),a||$p.iface.docs.hideHeader()),$p.iface.cell_tree&&!a&&$p.iface.cell_tree.expand()})):this.validate()}function s(e){this.resetValidateCss(),this.getCheckedValue("type")=="guest"?(i.call(this,this.getItemValue("guest"),"",!0),$p.wsql.set_user_param("user_name","")):this.getCheckedValue("type")=="auth"&&i.call(this,this.getItemValue("login"),this.getItemValue("password"))}var o=$p.iface.auth=$p.iface.docs.attachForm(),u,a,f;e||(e=function(e){var t=$p.eve.stepper;switch(e){case $p.eve.steps.authorization:t.frm_sync.setItemValue("text_processed","Авторизация");break;case $p.eve.steps.load_meta:$p.iface.docs.progressOn(),$p.msg.show_msg($p.msg.init_catalogues+$p.msg.init_catalogues_meta,$p.iface.docs),$p.iface.sync||$p.iface.wnd_sync(),$p.iface.sync.create(t);break;case $p.eve.steps.create_managers:t.frm_sync.setItemValue("text_processed","Обработка метаданных"),t.frm_sync.setItemValue("text_bottom","Создаём объекты менеджеров данных...");break;case $p.eve.steps.process_access:break;case $p.eve.steps.load_data_files:t.frm_sync.setItemValue("text_processed","Загрузка начального образа"),t.frm_sync.setItemValue("text_bottom","Читаем файлы данных зоны...");break;case $p.eve.steps.load_data_db:t.frm_sync.setItemValue("text_processed","Загрузка изменений из 1С"),t.frm_sync.setItemValue("text_bottom","Читаем изменённые справочники");break;case $p.eve.steps.load_data_wsql:break;case $p.eve.steps.save_data_wsql:t.frm_sync.setItemValue("text_processed","Кеширование данных"),t.frm_sync.setItemValue("text_bottom","Сохраняем таблицы в локальном SQL...");break;default:}}),f=require("form_auth").replace(/\/imgs\//g,dhtmlx.image_path),o.loadStruct(f,function(){$p.wsql.get_user_param("user_name")&&(o.setItemValue("login",$p.wsql.get_user_param("user_name")),o.setItemValue("type","auth"),$p.wsql.get_user_param("enable_save_pwd")&&$p.wsql.get_user_param("user_pwd")&&(o.setItemValue("password",$p.wsql.get_user_param("user_pwd")),$p.wsql.get_user_param("autologin")&&s())),(u=($p.iface.docs.getWidth()-500)/2)>=10?o.cont.style.paddingLeft=u.toFixed()+"px":o.cont.style.paddingLeft="20px",setTimeout(r)}),o.attachEvent("onButtonClick",s),o.attachEvent("onKeyDown",function(e,t,n,r){t.keyCode==13&&(n=="password"||this.getCheckedValue("type")=="guest")&&s.call(this)}),$p.msg.show_msg($p.msg.init_login,$p.iface.docs),o.onerror=function(e){$p.ajax.authorized=!1;var t=e.message.toLowerCase();t.indexOf("auth")!=-1?($p.msg.show_msg({title:$p.msg.main_title+$p.version,type:"alert-error",text:$p.msg.error_auth}),o.setItemValue("password",""),o.validate()):(t.indexOf("gateway")!=-1||t.indexOf("net")!=-1)&&$p.msg.show_msg({title:$p.msg.main_title+$p.version,type:"alert-error",text:$p.msg.error_network})}},$p.iface.open_settings=function(e){var t=e||(typeof event!="undefined"?event:undefined);return t&&t.preventDefault(),window.open(($p.job_prm.settings_url||"order_dealer/options.html")+"?v="+$p.job_prm.files_date),$p.cancel_bubble(t)},$p.iface.swith_view=function(e){var t,n=$p.iface,r=function(e){function t(e,t){if(e.text>t.text)return 1;if(e.text<t.text)return-1}if(!n.tree){var r=$p.job_prm.parse_url();if(r.obj){var i=r.obj.split(".");if(i.length>1){var s=$p.md.mgr_by_class_name(r.obj);typeof n.docs.close=="function"&&n.docs.close(),s&&s.form_list(n.docs,{})}}return}if(n.tree._view==e||["rep","cal"].indexOf(e)!=-1)return;n.tree.deleteChildItems(0);if(e=="oper"){var o={id:0,item:[{id:"oper_cat",text:$p.msg.meta_cat,open:!0,item:[]},{id:"oper_doc",text:$p.msg.meta_doc,item:[]},{id:"oper_cch",text:$p.msg.meta_cch,item:[]},{id:"oper_cacc",text:$p.msg.meta_cacc,item:[]}]},u,a,f=o.item[0].item;for(u in _cat){if(typeof _cat[u]=="function")continue;a=_cat[u].metadata();if(a.hide)continue;f.push({id:"oper.cat."+u,text:a.synonym||a.name,tooltip:a.illustration||a.list_presentation})}f.sort(t),f=o.item[1].item;for(u in _doc){if(typeof _doc[u]=="function")continue;a=_doc[u].metadata();if(a.hide)continue;f.push({id:"oper.doc."+u,text:a.synonym||a.name,tooltip:a.illustration||a.list_presentation})}f.sort(t),f=o.item[2].item;for(u in _cch){if(typeof _cch[u]=="function")continue;a=_cch[u].metadata();if(a.hide)continue;f.push({id:"oper.cch."+u,text:a.synonym||a.name,tooltip:a.illustration||a.list_presentation})}f.sort(t),f=o.item[3].item;for(u in _cacc){if(typeof _cacc[u]=="function")continue;a=_cacc[u].metadata();if(a.hide)continue;f.push({id:"oper.cacc."+u,text:a.synonym||a.name,tooltip:a.illustration||a.list_presentation})}f.sort(t),n.tree.parse(o,function(){var e=$p.job_prm.parse_url();e.obj&&n.tree.selectItem(e.view+"."+e.obj,!0)},"json")}else n.tree.loadXML(n.tree.tree_filteres+"?v="+$p.job_prm.files_date,function(){});n.tree._view=e};if(e.indexOf(n.docs.getViewName())==0)return n.docs.getViewName();t=n.docs.showView(e),t==1&&e=="cal"&&!window.dhtmlXScheduler&&($p.load_script("lib/dhtmlxscheduler.js","script",function(){$p.load_script("lib/ext/dhtmlxscheduler_minical.js","script"),$p.load_script("lib/ext/dhtmlxscheduler_timeline.js","script"),$p.load_script("lib/ext/dhtmlxscheduler_locale_ru.js","script",function(){scheduler.config.first_hour=8,scheduler.config.last_hour=22,n.docs.scheduler=n.docs.attachScheduler(new Date("2015-03-20"),"week","scheduler_here"),n.docs.scheduler.attachEvent("onBeforeViewChange",function(e,t,n,r){return n=="timeline"?($p.msg.show_not_implemented(),!1):!0})})}),$p.load_script("lib/dhtmlxscheduler.css","link")),r(e),e=="def"?n.main.showStatusBar():n.main.hideStatusBar()},$p.iface.OTooolBar=OTooolBar,$p.iface.add_button=function(e,t,n){var r=document.createElement("div"),i="";return r.name=(t?t.name+"_":"")+n.name,e.appendChild(r),r.className="wb-button",n.img&&(i='<img src="'+(t?t.image_path:"")+n.img+'">'),n.b?i+='<b style="vertical-align: super;"> '+n.b+"</b>":n.text&&(i+='<span style="vertical-align: super;"> '+n.text+"</span>"),r.innerHTML=i,n.float&&(r.style.float=n.float),n.clear&&(r.style.clear=n.clear),n.width&&(r.style.width=n.width),r};if(typeof window!="undefined"&&"dhtmlx"in window){function eXcell_addr(e){if(!e)return;var t=this,n,r=function(e){return eXcell_proto.input_keydown(e,t)},i=function(e){var n={grid:t.grid}._mixin(t.grid.get_cell_field());return wnd_address(n),$p.cancel_bubble(e)};t.cell=e,t.grid=t.cell.parentNode.grid,t.open_selection=i,t.setValue=function(e){t.setCValue(e)},t.getValue=function(){return t.grid.get_cell_value()},t.edit=function(){var e;t.val=t.getValue(),t.cell.innerHTML='<div class="ref_div21"><input type="text" class="dhx_combo_edit" style="height: 20px;"><div class="ref_field21">&nbsp;</div></div>',n=t.cell.firstChild,e=n.childNodes[0],e.value=t.val,e.onclick=$p.cancel_bubble,e.readOnly=!0,e.focus(),e.onkeydown=r,n.childNodes[1].onclick=i},t.detach=function(){return t.setValue(t.getValue()),!$p.is_equal(t.val,t.getValue())}}eXcell_addr.prototype=eXcell_proto,window.eXcell_addr=eXcell_addr;function wnd_address(e){function t(){var e={name:"wnd_addr",wnd:{id:"wnd_addr",top:130,left:200,width:800,height:560,modal:!0,center:!0,pwnd:g,allow_close:!0,allow_minmax:!0,on_close:d,caption:m.shipping_address}};g&&g.getHeight&&e.wnd.height>g.getHeight()&&(e.wnd.height=g.getHeight()),v=$p.iface.dat_blank(null,e.wnd),v.elmnts.layout=v.attachLayout("2E"),v.elmnts.cell_frm=v.elmnts.layout.cells("a"),v.elmnts.cell_frm.setHeight("110"),v.elmnts.cell_frm.hideHeader(),v.elmnts.cell_frm.fixSize(0,1),v.elmnts.pgrid=v.elmnts.cell_frm.attachPropertyGrid(),v.elmnts.pgrid.setDateFormat("%d.%m.%Y %H:%i"),v.elmnts.pgrid.init(),v.elmnts.pgrid.parse(m._manager.get_property_grid_xml({" ":[{id:"delivery_area",path:"o.delivery_area",synonym:"Район доставки",type:"ref",txt:b.delivery_area.presentation},{id:"region",path:"o.region",synonym:"Регион",type:"ro",txt:b.region},{id:"city",path:"o.city",synonym:"Населенный пункт",type:"ed",txt:b.city},{id:"street",path:"o.street",synonym:"Улица, дом, корпус, литера, квартира",type:"ed",txt:b.street}]},b),function(){v.elmnts.pgrid.enableAutoHeight(!0),v.elmnts.pgrid.setInitWidthsP("40,60"),v.elmnts.pgrid.setSizes(),v.elmnts.pgrid.attachEvent("onPropertyChanged",p)},"xml"),v.elmnts.pgrid.get_cell_field=function(){return{obj:b,field:"delivery_area",on_select:r,pwnd:v,meta:{synonym:"Район",tooltip:"Район (зона, направление) доставки для группировки при планировании и оптимизации маршрута геокодером",choice_groups_elm:"elm",type:{types:["cat.delivery_areas"],is_ref:!0}}}},v.elmnts.toolbar=v.attachToolbar({icons_path:dhtmlx.image_path+"dhxtoolbar"+dhtmlx.skin_suffix()}),v.elmnts.toolbar.loadStruct('<toolbar><item id="btn_select" type="button" title="Установить адрес" text="&lt;b&gt;Выбрать&lt;/b&gt;" /></toolbar>',function(){this.attachEvent("onclick",n)}),v.elmnts.cell_map=v.elmnts.layout.cells("b"),v.elmnts.cell_map.hideHeader();var t={center:new google.maps.LatLng(b.latitude,b.longitude),zoom:b.street?15:12,mapTypeId:google.maps.MapTypeId.ROADMAP};v.elmnts.map=v.elmnts.cell_map.attachMap(t),b.marker=new google.maps.Marker({map:v.elmnts.map,draggable:!0,animation:google.maps.Animation.DROP,position:t.center}),google.maps.event.addListener(b.marker,"click",c),google.maps.event.addListener(b.marker,"dragend",h),s()}function n(e){e=="btn_select"&&(m.delivery_area=b.delivery_area,a(),m.coordinates=JSON.stringify([b.latitude,b.longitude])),v.close()}function r(e){if(e===undefined)return;var t=y,n;$p.is_data_obj(e)?y=e:y=$p.cat.delivery_areas.get(e,!1),n=t!=y,$p.is_data_obj(y)||(y=$p.cat.delivery_areas.get()),v.elmnts.pgrid.cells().setValue(e.presentation),i(n)}function i(e){!b.delivery_area.empty()&&e&&(b.street=""),b.delivery_area.region?(b.region=b.delivery_area.region,v.elmnts.pgrid.cells("region",1).setValue(b.region)):e&&(b.region=""),b.delivery_area.city?(b.city=b.delivery_area.city,v.elmnts.pgrid.cells("city",1).setValue(b.city)):e&&(b.city="");if(b.delivery_area.latitude&&b.delivery_area.longitude){var t=new google.maps.LatLng(b.delivery_area.latitude,b.delivery_area.longitude);v.elmnts.map.setCenter(t),b.marker.setPosition(t)}s()}function s(){v.elmnts.pgrid.cells("region",1).setValue(b.region),v.elmnts.pgrid.cells("city",1).setValue(b.city),v.elmnts.pgrid.cells("street",1).setValue(b.street)}function o(){var e=b.street?15:12;v.elmnts.map.getZoom()!=e&&v.elmnts.map.setZoom(e),l(function(e,t){if(t==google.maps.GeocoderStatus.OK){var n=e[0].geometry.location;v.elmnts.map.setCenter(n),b.marker.setPosition(n),b.latitude=n.lat(),b.longitude=n.lng(),b.postal_code=$p.ipinfo.components({},e[0].address_components).postal_code||""}})}function u(){return(b.street?b.street.replace(/,/g," ")+", ":"")+(b.city?b.city+", ":"")+(b.region?b.region+", ":"")+b.country+(b.postal_code?", "+b.postal_code:"")}function a(){m.shipping_address=u();var e='<КонтактнаяИнформация  				xmlns="http://www.v8.1c.ru/ssl/contactinfo" 				xmlns:xs="http://www.w3.org/2001/XMLSchema" 				xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   				Представление="%1">   					<Комментарий/>  					<Состав xsi:type="Адрес" Страна="РОССИЯ">   						<Состав xsi:type="АдресРФ">'.replace("%1",m.shipping_address);b.region&&(e+="\n<СубъектРФ>"+b.region+"</СубъектРФ>"),b.city&&(b.city.indexOf("г.")!=-1||b.city.indexOf("г ")!=-1||b.city.indexOf(" г")!=-1?e+="\n<Город>"+b.city+"</Город>":e+="\n<НаселПункт>"+b.city+"</НаселПункт>");if(b.street){var t=b.street.replace(/,/g," "),n,r,i,s,o,a,f;for(var l in $p.fias){if($p.fias[l].type==1)for(var c in $p.fias[l].syn)if((r=t.indexOf($p.fias[l].syn[c]))!=-1){o=l,n=t.substr(r+$p.fias[l].syn[c].length).trim(),t=t.substr(0,r).trim();break}if(o)break}o||(o="1010",(r=t.indexOf(" "))!=-1&&(n=t.substr(r),t=t.substr(0,r))),e+="\n<Улица>"+t.trim()+"</Улица>";if(n){i=n.toLowerCase(),n="";for(var l in $p.fias){if($p.fias[l].type==3)for(var c in $p.fias[l].syn)if((r=i.indexOf($p.fias[l].syn[c]))!=-1){a=l,n=i.substr(r+$p.fias[l].syn[c].length),i=i.substr(0,r);break}if(a)break}a||(a="2010",(r=i.indexOf(" "))!=-1&&(n=i.substr(r),i=i.substr(0,r))),e+='\n<ДопАдрЭл><Номер Тип="'+o+'" Значение="'+i.trim()+'"/></ДопАдрЭл>'}n&&(e+='\n<ДопАдрЭл><Номер Тип="'+a+'" Значение="'+n.trim()+'"/></ДопАдрЭл>')}b.postal_code&&(e+='<ДопАдрЭл ТипАдрЭл="10100000" Значение="'+b.postal_code+'"/>'),e+="</Состав> 					</Состав></КонтактнаяИнформация>",m.address_fields=e}function f(e){if(m.address_fields){b.xml=(new DOMParser).parseFromString(m.address_fields,"text/xml");var t={},n={building_room:""},r,i=[],s="СубъектРФ,Округ,СвРайМО,СвРайМО,ВнутригРайон,НаселПункт,Улица,Город,ДопАдрЭл,Адрес_по_документу,Местоположение".split(",");function o(e){if(e.attributes&&e.attributes.length==2){var t={};return t[e.attributes[0].value]=e.attributes[1].value,t}}for(var u in s)t[s[u]]=b.xml.getElementsByTagName(s[u]);for(var u in t)for(var a in t[u]){if(a=="length"||!t[u].hasOwnProperty(a))continue;if(r=o(t[u][a]))n[u]||(n[u]=[]),n[u].push(r);else if(t[u][a].childNodes.length)for(var f in t[u][a].childNodes){if(f=="length"||!t[u][a].childNodes.hasOwnProperty(f))continue;(r=o(t[u][a].childNodes[f]))?(n[u]||(n[u]=[]),n[u].push(r)):t[u][a].childNodes[f].nodeValue&&(n[u]?n[u]+=" "+t[u][a].childNodes[f].nodeValue:n[u]=t[u][a].childNodes[f].nodeValue)}}for(var u in n["ДопАдрЭл"]){for(var a in $p.fias){if(a.length!=4)continue;n["ДопАдрЭл"][u][a]&&(i[$p.fias[a].type]=$p.fias[a].name+" "+n["ДопАдрЭл"][u][a])}n["ДопАдрЭл"][u][101e5]&&(b.postal_code=n["ДопАдрЭл"][u][101e5])}b.address_fields=n,b.region=n["СубъектРФ"]||n["Округ"]||"",b.city=n["Город"]||n["НаселПункт"]||"",b.street=n["Улица"]||"";for(var u in i)b.street+=" "+i[u]}b.coordinates.length?(b.latitude=b.coordinates[0],b.longitude=b.coordinates[1],e()):m.shipping_address?l(function(t,n){n==google.maps.GeocoderStatus.OK&&(b.latitude=t[0].geometry.location.lat(),b.longitude=t[0].geometry.location.lng()),e()}):$p.ipinfo.latitude&&$p.ipinfo.longitude?(b.latitude=$p.ipinfo.latitude,b.longitude=$p.ipinfo.longitude,e()):(b.latitude=55.635924,b.longitude=37.6066379,e(),$p.msg.show_msg($p.msg.empty_geocoding))}function l(e){var t=u();$p.ipinfo.ggeocoder.geocode({address:t},e)}function c(){b.marker.getAnimation()!=null?b.marker.setAnimation(null):(b.marker.setAnimation(google.maps.Animation.BOUNCE),setTimeout(function(){b.marker.setAnimation(null)},1500))}function h(e){$p.ipinfo.ggeocoder.geocode({latLng:e.latLng},function(t,n){if(n==google.maps.GeocoderStatus.OK&&t[0]){var r=t[0];v.setText(r.formatted_address),$p.ipinfo.components(b,r.address_components),s();var i=b.street?15:12;v.elmnts.map.getZoom()!=i&&(v.elmnts.map.setZoom(i),v.elmnts.map.setCenter(e.latLng)),b.latitude=e.latLng.lat(),b.longitude=e.latLng.lng()}})}function p(e,t,n){e&&(b.delivery_area.empty()?(t=n,$p.msg.show_msg({type:"alert",text:$p.msg.delivery_area_empty,title:$p.msg.addr_title}),setTimeout(function(){v.elmnts.pgrid.selectRowById("delivery_area")},50)):e=="delivery_area"?r(t):(b[v.elmnts.pgrid.getSelectedRowId()]=t,o()))}function d(t){return e.grid.editStop(),!t.error}var v,m=e.obj,g=e.pwnd,y=m.delivery_area,b={coordinates:m.coordinates?JSON.parse(m.coordinates):[],country:"Россия",region:"",city:"",street:"",postal_code:"",marker:{}};return b.__define("delivery_area",{get:function(){return y},set:function(e){r(e)}}),f(t),v}}$p.is_data_obj=function(e){return e&&e instanceof DataObj},$p.fetch_type=function(e,t){var n=e;return t.is_ref?n=$p.fix_guid(e):t.date_part?n=$p.fix_date(e,!0):t.digits?n=$p.fix_number(e,!0):t.types[0]=="boolean"&&(n=$p.fix_boolean(e)),n},$p.is_equal=function(e,t){return e==t?!0:typeof e==typeof t?!1:$p.fix_guid(e,false)==$p.fix_guid(t,false)},$p._find=function(e,t){var n,r,i;if(typeof t!="object")for(r in e){n=e[r];for(var s in n)if(typeof n[s]!="function"&&$p.is_equal(n[s],t))return n}else for(r in e){n=e[r],i=!0;for(var s in t)if(typeof n[s]!="function"&&!$p.is_equal(n[s],t[s])){i=!1;break}if(i)return n}},$p._find_rows=function(e,t,n){var r,i,s,o,u=[],a,f=0;t&&(t._top?(a=t._top,delete t._top):a=300);for(s in e){i=e[s],r=!0;if(t)if(typeof t=="function")r=t(i);else for(o in t){if(o.substr(0,1)=="_")continue;if(typeof t[o]=="function"){r=t[o](i,o);if(!r)break}else if(o=="or"&&Array.isArray(t[o])){r=t[o].some(function(e){var t=Object.keys(e)[0];return e[t].hasOwnProperty("like")?i[t].toLowerCase().indexOf(e[t].like.toLowerCase())!=-1:$p.is_equal(i[t],e[t])});if(!r)break}else if(t[o].hasOwnProperty("like")){if(i[o].toLowerCase().indexOf(t[o].like.toLowerCase())==-1){r=!1;break}}else if(t[o].hasOwnProperty("not")){if($p.is_equal(i[o],t[o].not)){r=!1;break}}else if(t[o].hasOwnProperty("in")){r=t[o].in.some(function(e){return $p.is_equal(e,i[o])});if(!r)break}else if(!$p.is_equal(i[o],t[o])){r=!1;break}}if(r){if(n){if(n.call(this,i)===!1)break}else u.push(i);if(a){f++;if(f>=a)break}}}return u};var _cat=$p.cat=new function(){this.toString=function(){return $p.msg.meta_cat_mgr}},_enm=$p.enm=new function(){this.toString=function(){return $p.msg.meta_enn_mgr}},_doc=$p.doc=new function(){this.toString=function(){return $p.msg.meta_doc_mgr}},_ireg=$p.ireg=new function(){this.toString=function(){return $p.msg.meta_ireg_mgr}},_areg=$p.areg=new function(){this.toString=function(){return $p.msg.meta_areg_mgr}},_aссreg=$p.aссreg=new function(){this.toString=function(){return $p.msg.meta_accreg_mgr}},_dp=$p.dp=new function(){this.toString=function(){return $p.msg.meta_dp_mgr}},_rep=$p.rep=new function(){this.toString=function(){return $p.msg.meta_reports_mgr}},_cacc=$p.cacc=new function(){this.toString=function(){return $p.msg.meta_charts_of_accounts_mgr}},_cch=$p.cch=new function(){this.toString=function(){return $p.msg.meta_charts_of_characteristic_mgr}},_md;$p.Meta=Meta,$p.record_log=function(e){$p.ireg.$log?$p.ireg.$log.record(e):console.log(e)},_cat.load_soap_to_grid=function(e,t,n){function r(e){e.substr(0,1)=="{"&&(e=JSON.parse(e)),typeof e=="string"?t.parse(e,function(){n&&n(e)},"xml"):n&&n(e)}t.xmlFileUrl="exec";var i=_md.mgr_by_class_name(e.class_name);!i.cachable&&($p.job_prm.rest||$p.job_prm.irest_enabled||e.rest)?i.rest_selection(e).then(r).catch(function(e){console.log(e)}):_load(e).then(r).catch(function(e){console.log(e)})},DataManager.prototype.__define("family_name",{get:function(){return $p.msg["meta_"+this.class_name.split(".")[0]+"_mgr"].replace($p.msg.meta_mgr+" ","")},enumerable:!1}),DataManager.prototype.register_ex=function(){},DataManager.prototype.sync_grid=function(e,t){var n;!this.cachable&&($p.job_prm.rest||$p.job_prm.irest_enabled||t.rest)&&(t.action=="get_tree"?n=this.rest_tree():t.action=="get_selection"&&(n=this.rest_selection()))},DataManager.prototype.get_option_list=function(e,t){function n(t){return $p.is_equal(t.value,e)&&(t.selected=!0),t}var r=this,i=[],s=0,o,u,a;t.presentation&&(o=r.metadata().input_by_string)&&(u=t.presentation.like,delete t.presentation,t.or=[],o.forEach(function(e){a={},a[e]={like:u},t.or.push(a)}));if(r.cachable||t&&t._local)return r.find_rows(t,function(e){i.push(n({text:e.presentation,value:e.ref}))}),Promise.resolve(i);var f={selection:t,top:t._top};return delete t._top,r instanceof DocManager?f.fields=["ref","date","number_doc"]:r.metadata().main_presentation_name?f.fields=["ref","name"]:f.fields=["ref","id"],_rest.load_array(f,r).then(function(e){return e.forEach(function(e){i.push(n({text:r instanceof DocManager?e.number_doc+" от "+$p.dateFormat(e.date,$p.dateFormat.masks.ru):e.name||e.id,value:e.ref}))}),i})},DataManager.prototype.tabular_captions=function(e,t){},DataManager.prototype.get_property_grid_xml=function(e,t,n){var r=this,i,s,o,u,a,f,l,c="<rows>",h=function(){if(e)return;o=r.metadata();if(o.form&&o.form.obj&&o.form.obj.head)e=o.form.obj.head;else{e={" ":[]},t instanceof CatObj?(o.code_length&&e[" "].push("id"),o.main_presentation_name&&e[" "].push("name")):t instanceof DocObj&&(e[" "].push("number_doc"),e[" "].push("date"));if(!t.is_folder)for(i in o.fields)o.fields[i].hide||e[" "].push(i);o.tabular_sections.extra_fields&&(e["Дополнительные реквизиты"]=[])}},p=function(e,t){$p.is_data_obj(e)?f=e.presentation:f=e,t.type.is_ref||(t.type.date_part?f=$p.dateFormat(f,""):t.type.types[0]=="boolean"&&(f=f?"1":"0"))},d=function(e){a=_md.control_by_type(o.type),p(e,o)},v=function(e,i){if(i){var s=e.property||e.param||e["Параметр"],h=e["value"]!=undefined?e.value:e["Значение"];s.empty()?(l=i+"|"+"empty",a="ro",f="",o={synonym:"?"}):(o={synonym:s.presentation,type:s.type},l=i+"|"+s.ref,d(h),a=="edn"&&(a="calck"),s.mandatory&&(a+='" class="cell_mandatory'))}else if(typeof e=="object")o={synonym:e.synonym},l=e.id,a=e.type,f="",e.hasOwnProperty("txt")?f=e.txt:(u=t[l])!==undefined&&p(u,_md.get(r.class_name,l));else if(n&&n.meta&&(o=n.meta[e])!==undefined)l=e,d(u=t[e]);else{if((u=t[e])===undefined)return;o=_md.get(r.class_name,l=e),d(u)}c+='<row id="'+l+'"><cell>'+(o.synonym||o.name)+'</cell><cell type="'+a+'">'+f+"</cell></row>"};h();for(i in e){i!=" "&&(c+='<row open="1"><cell>'+i+"</cell>");for(s in e[i])v(e[i][s]);if(n&&i==n.title&&t[n.ts]){var m=!1;t[n.ts].find_rows(n.selection,function(e){v(e,n.ts)})}i!=" "&&(c+="</row>")}return c+="</rows>",c},DataManager.prototype.__define("table_name",{get:function(){return this.class_name.replace(".","_")},enumerable:!1}),DataManager.prototype.print=function(e,t,n){function r(e){n&&n.progressOff&&n.progressOff(),e&&e.focus()}n&&n.progressOn&&n.progressOn();var i={};$p.ajax.default_attr(i,$p.job_prm.irest_url()),i.url+=this.rest_name+"(guid'"+$p.fix_guid(e)+"')"+"/Print(model="+t+", browser_uid="+$p.wsql.get_user_param("browser_uid")+")",$p.ajax.get_and_show_blob(i.url,i,"get").then(r).catch(function(e){console.log(e)}),setTimeout(r,3e3)},DataManager.prototype.printing_plates=function(){var e={},t=this;return $p.job_prm.offline?Promise.resolve({}):(t.metadata().printing_plates&&(t._printing_plates=t.metadata().printing_plates),t._printing_plates?Promise.resolve(t._printing_plates):($p.ajax.default_attr(e,$p.job_prm.irest_url()),e.url+=t.rest_name+"/Print()",$p.ajax.get_ex(e.url,e).then(function(e){return t.__define("_printing_plates",{value:JSON.parse(e.response),enumerable:!1}),t._printing_plates}).catch(function(e){return{}})))},RefDataManager._extend(DataManager),RefDataManager.prototype.get_sql_struct=function(e){function t(){function t(){var e=[],t="_t_.ref, _t_.`deleted`";return s.form&&s.form.selection?s.form.selection.fields.forEach(function(t){e.push(t)}):i instanceof DocManager?(e.push("posted"),e.push("date"),e.push("number_doc")):(s.hierarchical&&s.group_hierarchy?e.push("is_folder"):e.push("0 as is_folder"),i instanceof ChartOfAccountManager?(e.push("id"),e.push("name as presentation")):s.main_presentation_name?e.push("name as presentation"):s.code_length?e.push("id as presentation"):e.push("'...' as presentation"),s.has_owners&&e.push("owner"),s.code_length&&e.push("id")),e.forEach(function(e){e.indexOf(" as ")!=-1?t+=", "+e:t+=_md.sql_mask(e,!0)}),t}function n(){var e="",t;if(s.form&&s.form.selection)for(var n in s.form.selection.fields){if(s.form.selection.fields[n].indexOf(" as ")==-1||s.form.selection.fields[n].indexOf("_t_.")!=-1)continue;t=s.form.selection.fields[n].split(" as "),t[0]=t[0].split("."),t[0].length>1&&(e&&(e+="\n"),e+="left outer join "+t[0][0]+" on "+t[0][0]+".ref = _t_."+t[1])}return e}function r(){var t;i instanceof ChartOfAccountManager?t=" WHERE ("+(h?0:1):s.hierarchical?s.has_owners?t=" WHERE ("+(a||h?1:0)+" OR _t_.parent = '"+f+"') AND ("+(l==$p.blank.guid?1:0)+" OR _t_.owner = '"+l+"') AND ("+(h?0:1):t=" WHERE ("+(a||h?1:0)+" OR _t_.parent = '"+f+"') AND ("+(h?0:1):s.has_owners?t=" WHERE ("+(l==$p.blank.guid?1:0)+" OR _t_.owner = '"+l+"') AND ("+(h?0:1):t=" WHERE ("+(h?0:1);if(i.sql_selection_where_flds)t+=i.sql_selection_where_flds(h);else if(i instanceof DocManager)t+=" OR _t_.number_doc LIKE '"+h+"'";else{if(s.main_presentation_name||i instanceof ChartOfAccountManager)t+=" OR _t_.name LIKE '"+h+"'";s.code_length&&(t+=" OR _t_.id LIKE '"+h+"'")}return t+=") AND (_t_.ref != '"+$p.blank.guid+"')",e.selection&&typeof e.selection!="function"&&e.selection.forEach(function(e){for(var n in e)typeof e[n]=="function"?t+="\n AND "+e[n](i,n)+" ":s.fields.hasOwnProperty(n)?e[n]===!0?t+="\n AND _t_."+n+" ":e[n]===!1?t+="\n AND (not _t_."+n+") ":typeof e[n]=="string"||typeof e[n]=="object"?t+="\n AND (_t_."+n+" = '"+e[n]+"') ":t+="\n AND (_t_."+n+" = "+e[n]+") ":n=="is_folder"&&s.hierarchical&&s.group_hierarchy}),t}function o(){return i instanceof ChartOfAccountManager?"ORDER BY id":s.hierarchical?s.group_hierarchy?"ORDER BY _t_.is_folder desc, is_initial_value, presentation":"ORDER BY _t_.parent desc, is_initial_value, presentation":"ORDER BY is_initial_value, presentation"}function u(){function t(t){t?(p=e.set_parent=t.parent.ref,f=p,a=!1):(!!h||!!a)&&i.class_name=="cat.base_blocks"&&(l==$p.blank.guid&&(l=_cat.bases.predefined("main")),f=i.first_folder(l).ref),h&&h.indexOf("%")==-1&&(h="%"+h+"%")}s.has_owners&&(l=e.owner,e.selection&&typeof e.selection!="function"&&e.selection.forEach(function(e){e.owner&&(l=typeof e.owner=="object"?e.owner.valueOf():e.owner,delete e.owner)}),l||(l=$p.blank.guid)),c!=$p.blank.guid&&a?s.hierarchical?t(i.get(c,!1)):t():t()}var a=!e.parent,f=e.parent||$p.blank.guid,l,c=e.initial_value||$p.blank.guid,h=e.filter||"",p=$p.blank.guid;u();var d;return i.sql_selection_list_flds?d=i.sql_selection_list_flds(c):d=("SELECT %2, case when _t_.ref = '"+c+"' then 0 else 1 end as is_initial_value FROM `"+i.table_name+"` AS _t_ %j %3 %4 LIMIT 300").replace("%2",t()).replace("%j",n()),d.replace("%3",r()).replace("%4",o())}function n(){var e="CREATE TABLE IF NOT EXISTS `"+i.table_name+"` (ref CHAR PRIMARY KEY NOT NULL, `deleted` BOOLEAN, lc_changed INT";i instanceof DocManager?e+=", posted BOOLEAN, date Date, number_doc CHAR":e+=", id CHAR, name CHAR, is_folder BOOLEAN";for(u in s.fields)e+=_md.sql_mask(u)+_md.sql_type(i,u,s.fields[u].type);for(u in s.tabular_sections)e+=", `ts_"+u+"` JSON";return e+=")",e}function r(){var e=["ref","deleted","lc_changed"],t="INSERT INTO `"+i.table_name+"` (ref, `deleted`, lc_changed",n="(?";i.class_name.substr(0,3)=="cat"?(t+=", id, name, is_folder",e.push("id"),e.push("name"),e.push("is_folder")):i.class_name.substr(0,3)=="doc"&&(t+=", posted, date, number_doc",e.push("posted"),e.push("date"),e.push("number_doc"));for(u in s.fields)t+=_md.sql_mask(u),e.push(u);for(u in s.tabular_sections)t+=", `ts_"+u+"`",e.push("ts_"+u);t+=") VALUES ";for(u=1;u<e.length;u++)n+=", ?";return n+=")",t+=n,{sql:t,fields:e,values:n}}var i=this,s=i.metadata(),o={},u,a=e&&e.action?e.action:"create_table";return a=="create_table"?o=n():["insert","update","replace"].indexOf(a)!=-1?o[i.table_name]=r():a=="select"?o="SELECT * FROM `"+i.table_name+"` WHERE ref = ?":a=="select_all"?o="SELECT * FROM `"+i.table_name+"`":a=="delete"?o="DELETE FROM `"+i.table_name+"` WHERE ref = ?":a=="drop"?o="DROP TABLE IF EXISTS `"+i.table_name+"`":a=="get_tree"?!e.filter||e.filter.is_folder?o="SELECT ref, parent, name as presentation FROM `"+i.table_name+"` WHERE is_folder order by parent, name":o="SELECT ref, parent, name as presentation FROM `"+i.table_name+"` order by parent, name":a=="get_selection"&&(o=t()),o},RefDataManager.prototype.caption_flds=function(e){function t(e,t,n,r,i,s){this.id=e,this.width=t,this.type=n,this.align=r,this.sort=i,this.caption=s}var n='<column id="%1" width="%2" type="%3" align="%4" sort="%5">%6</column>',r=[],i=this.metadata(),s="";i.form&&i.form.selection?r=i.form.selection.cols:this instanceof DocManager?(r.push(new t("date","120","ro","left","server","Дата")),r.push(new t("number_doc","120","ro","left","server","Номер"))):this instanceof ChartOfAccountManager?(r.push(new t("id","120","ro","left","server","Код")),r.push(new t("presentation","*","ro","left","server","Наименование"))):r.push(new t("presentation","*","ro","left","server","Наименование"));if(e.get_header&&r.length){s="<head>";for(var o in r)s+=n.replace("%1",r[o].id).replace("%2",r[o].width).replace("%3",r[o].type).replace("%4",r[o].align).replace("%5",r[o].sort).replace("%6",r[o].caption);s+="</head>"}return{head:s,acols:r}},DataProcessorsManager._extend(DataManager),EnumManager._extend(RefDataManager),EnumManager.prototype.get_sql_struct=function(e){var t,n=e&&e.action?e.action:"create_table";return n=="create_table"?t="CREATE TABLE IF NOT EXISTS `"+this.table_name+"` (ref CHAR PRIMARY KEY NOT NULL, sequence INT, synonym CHAR)":["insert","update","replace"].indexOf(n)!=-1?(t={},t[this.table_name]={sql:"INSERT INTO `"+this.table_name+"` (ref, sequence, synonym) VALUES (?, ?, ?)",fields:["ref","sequence","synonym"],values:"(?, ?, ?)"}):n=="delete"&&(t="DELETE FROM `"+this.table_name+"` WHERE ref = ?"),t},EnumManager.prototype.get_option_list=function(e,t){function n(t){return $p.is_equal(t.value,e)&&(t.selected=!0),t}var r=[],i="";if(t)for(var s in t){if(s.substr(0,1)=="_")continue;i=t[s]}return typeof i=="object"&&(i.like?i=i.like:i=""),i=i.toLowerCase(),this.alatable.forEach(function(e){if(i)if(!e.synonym||e.synonym.toLowerCase().indexOf(i)==-1)return;r.push(n({text:e.synonym||"",value:e.ref}))}),Promise.resolve(r)},RegisterManager._extend(DataManager),RegisterManager.prototype.get_sql_struct=function(e){function t(){var e="CREATE TABLE IF NOT EXISTS `"+i.table_name+"` (",t=!0;for(u in s.dimensions)t?(e+="`"+u+"`",t=!1):e+=_md.sql_mask(u),e+=_md.sql_type(i,u,s.dimensions[u].type);for(u in s.resources)e+=_md.sql_mask(u)+_md.sql_type(i,u,s.resources[u].type);e+=", PRIMARY KEY (",t=!0;for(u in s.dimensions)t?(e+="`"+u+"`",t=!1):e+=_md.sql_mask(u);return e+="))",e}function n(){var e="INSERT OR REPLACE INTO `"+i.table_name+"` (",t=[],n=!0;for(u in s.dimensions)n?(e+=u,n=!1):e+=", "+u,t.push(u);for(u in s.resources)e+=", "+u,t.push(u);e+=") VALUES (?";for(u=1;u<t.length;u++)e+=", ?";return e+=")",{sql:e,fields:t}}function r(){var t="SELECT * FROM `"+i.table_name+"` WHERE ",n=!0;e._values=[];for(var r in e){if(r=="action"||r=="_values")continue;n?n=!1:t+=" and ",t+="`"+r+"`"+"=?",e._values.push(e[r])}return n&&(t+="1"),t}var i=this,s=i.metadata(),o={},u,a=e&&e.action?e.action:"create_table";return a=="create_table"?o=t():a in{insert:"",update:"",replace:""}?o[i.table_name]=n():a=="select"?o=r():a=="select_all"?o=r():a=="delete"?o="DELETE FROM `"+i.table_name+"` WHERE ref = ?":a=="drop"&&(o="DROP TABLE IF EXISTS `"+i.table_name+"`"),o},RegisterManager.prototype.get_ref=function(e){var t="",n,r=this.metadata().dimensions;e instanceof RegisterRow&&(e=e._obj);for(var i in r)t+=t?"_":"",r[i].type.is_ref?t+=$p.fix_guid(e[i]):!e[i]&&r[i].type.digits?t+="0":r[i].date_part?t+=$p.dateFormat(e[i]||$p.blank.date,$p.dateFormat.masks.atom):e[i]!=undefined?t+=String(e[i]):t+="$";return t},InfoRegManager._extend(RegisterManager),InfoRegManager.prototype.slice_first=function(e){},InfoRegManager.prototype.slice_last=function(e){},LogManager._extend(InfoRegManager),AccumRegManager._extend(RegisterManager),CatManager._extend(RefDataManager),CatManager.prototype.by_name=function(e){var t;return this.find_rows({name:e},function(e){return t=e,!1}),t||(t=this.get()),t},CatManager.prototype.by_id=function(e){var t;return this.find_rows({id:e},function(e){return t=e,!1}),t||(t=this.get()),t},CatManager.prototype.path=function(e){var t=[],n;e instanceof DataObj?n=e:n=this.get(e,!1,!0),n&&t.push({ref:n.ref,presentation:n.presentation});if(n&&this.metadata().hierarchical)for(;;){n=n.parent;if(n.empty())break;t.push({ref:n.ref,presentation:n.presentation})}return t},ChartOfCharacteristicManager._extend(CatManager),ChartOfAccountManager._extend(CatManager),DocManager._extend(RefDataManager),DataObj.prototype.valueOf=function(){return this.ref},DataObj.prototype.toJSON=function(){return this._obj},DataObj.prototype._getter=function(e){var t=this._metadata.fields[e].type,n,r;if(e=="type"&&typeof this._obj[e]=="object")return this._obj[e];if(e=="ref")return this._obj[e];if(!t.is_ref)return t.date_part?$p.fix_date(this._obj[e],!0):t.digits?$p.fix_number(this._obj[e],!0):t.types[0]=="boolean"?$p.fix_boolean(this._obj[e]):this._obj[e]||"";if(n=_md.value_mgr(this._obj,e,t))return n instanceof DataManager?n.get(this._obj[e],!1):$p.fetch_type(this._obj[e],n);if(this._obj[e])return console.log([e,t,this._obj]),null},DataObj.prototype.__setter=function(e,t){var n=this._metadata.fields[e].type,r;e=="type"&&t.types?this._obj[e]=t:e=="ref"?this._obj[e]=$p.fix_guid(t):n.is_ref?(this._obj[e]=$p.fix_guid(t),r=_md.value_mgr(this._obj,e,n,!1,t),r?r instanceof EnumManager?typeof t=="string"?this._obj[e]=t:t?typeof t=="object"&&(this._obj[e]=t.ref||t.name||""):this._obj[e]="":t&&t.presentation?(t.type&&!(t instanceof DataObj)&&delete t.type,r.create(t)):r instanceof DataManager||(this._obj[e]=$p.fetch_type(t,r)):typeof t!="object"&&(this._obj[e]=t)):n.date_part?this._obj[e]=$p.fix_date(t,!0):n.digits?this._obj[e]=$p.fix_number(t,!0):n.types[0]=="boolean"?this._obj[e]=$p.fix_boolean(t):this._obj[e]=t},DataObj.prototype.__notify=function(e){Object.getNotifier(this).notify({type:"update",name:e,oldValue:this._obj[e]})},DataObj.prototype._setter=function(e,t){if(this._obj[e]==t)return;this.__notify(e),this.__setter(e,t)},DataObj.prototype._getter_ts=function(e){return this._ts_(e)},DataObj.prototype._setter_ts=function(e,t){var n=this._ts_(e);n instanceof TabularSection&&Array.isArray(t)&&n.load(t)},DataObj.prototype.load=function(){function e(e){typeof e=="string"&&(e=JSON.parse(e));if($p.msg.check_soap_result(e))return;var n=$p.fix_guid(e);return t.is_new()&&!$p.is_empty_guid(n)&&t._set_loaded(n),t._mixin(e)}var t=this;return t._manager.cachable&&!t.is_new()?Promise.resolve(t):t.ref==$p.blank.guid?(t instanceof CatObj?t.id="000000000":t.number_doc="000000000",Promise.resolve(t)):!t._manager.cachable&&($p.job_prm.rest||$p.job_prm.irest_enabled)?_rest.load_obj(t):_load({class_name:t._manager.class_name,action:"load",ref:t.ref}).then(e)},DataObj.prototype.save=function(e,t){var n;return this._manager.handle_event(this,"before_save")===!1?Promise.resolve(this):(this instanceof DocObj&&$p.blank.date==this.date&&(this.date=new Date),$p.job_prm.offline?n=function(e){return Promise.resolve(e)}:n=$p.job_prm.irest_enabled?_rest.save_irest:_rest.save_rest,n(this,{post:e,operational:t}).then(function(e){return e._manager.handle_event(e,"after_save")}))},DataObj.prototype.empty=function(){return $p.is_empty_guid(this._obj.ref)},DataObj.prototype.__define("_metadata",{get:function(){return this._manager.metadata()},enumerable:!1}),DataObj.prototype.__define("ref",{get:function(){return this._obj.ref},set:function(e){this._obj.ref=$p.fix_guid(e)},enumerable:!0,configurable:!0}),DataObj.prototype.__define("deleted",{get:function(){return this._obj.deleted},set:function(e){this.__notify("deleted"),this._obj.deleted=!!e},enumerable:!0,configurable:!0}),DataObj.prototype.__define("data_version",{get:function(){return this._obj.data_version||""},set:function(e){this.__notify("data_version"),this._obj.data_version=String(e)},enumerable:!0}),DataObj.prototype.__define("lc_changed",{get:function(){return this._obj.lc_changed||0},set:function(e){this.__notify("lc_changed"),this._obj.lc_changed=$p.fix_number(e,!0)},enumerable:!0,configurable:!0}),CatObj._extend(DataObj),CatObj.prototype.__define("id",{get:function(){return this._obj.id||""},set:function(e){this.__notify("id"),this._obj.id=e},enumerable:!0}),CatObj.prototype.__define("name",{get:function(){return this._obj.name||""},set:function(e){this.__notify("name"),this._obj.name=String(e)},enumerable:!0}),DocObj._extend(DataObj),DocObj.prototype.__define("number_doc",{get:function(){return this._obj.number_doc||""},set:function(e){this.__notify("number_doc"),this._obj.number_doc=e},enumerable:!0}),DocObj.prototype.__define("date",{get:function(){return this._obj.date||$p.blank.date},set:function(e){this.__notify("date"),this._obj.date=$p.fix_date(e,!0)},enumerable:!0}),DocObj.prototype.__define("posted",{get:function(){return this._obj.posted||!1},set:function(e){this.__notify("posted"),this._obj.posted=$p.fix_boolean(e)},enumerable:!0}),DataProcessorObj._extend(DataObj),EnumObj._extend(DataObj),EnumObj.prototype.__define("order",{get:function(){return this._obj.sequence},set:function(e){this._obj.sequence=parseInt(e)},enumerable:!0}),EnumObj.prototype.__define("name",{get:function(){return this._obj.ref},set:function(e){this._obj.ref=String(e)},enumerable:!0}),EnumObj.prototype.__define("synonym",{get:function(){return this._obj.synonym||""},set:function(e){this._obj.synonym=String(e)},enumerable:!0}),EnumObj.prototype.__define("presentation",{get:function(){return this.synonym||this.name},enumerable:!1}),EnumObj.prototype.empty=function(){return this.ref=="_"},RegisterRow._extend(DataObj),RegisterRow.prototype.__define("_metadata",{get:function(){var e=this._manager.metadata();return e.fields||(e.fields={}._mixin(e.dimensions)._mixin(e.resources)),e},enumerable:!1}),RegisterRow.prototype.__define("ref",{get:function(){return this._manager.get_ref(this)},enumerable:!0}),TabularSection.prototype.toString=function(){return"Табличная часть "+this._owner._manager.class_name+"."+this._name},TabularSection.prototype.get=function(e){return this._obj[e]._row},TabularSection.prototype.count=function(){return this._obj.length},TabularSection.prototype.clear=function(e){for(var t in this._obj)delete this._obj[t];this._obj.length=0,e||Object.getNotifier(this._owner).notify({type:"rows",tabular:this._name})},TabularSection.prototype.del=function(e){var t,n=this._obj,r=0;if(typeof e=="undefined")return;if(typeof e=="number")t=e;else if(n[e.row-1]._row===e)t=e.row-1;else for(var i in n)if(n[i]._row===e){t=Number(i),delete n[i]._row;break}if(t==undefined)return;n.splice(t,1);for(var i in n)r++,n[i].row=r;Object.getNotifier(this._owner).notify({type:"rows",tabular:this._name})},TabularSection.prototype.find=function(e){var t=$p._find(this._obj,e);if(t)return t._row},TabularSection.prototype.find_rows=function(e,t){var n=this,r=t?function(e){return t.call(n,e._row)}:null;return $p._find_rows.call(n,n._obj,e,r)},TabularSection.prototype.swap=function(e,t){var n=this._obj[e];this._obj[e]=this._obj[t],this._obj[t]=n,Object.getNotifier(this._owner).notify({type:"rows",tabular:this._name})},TabularSection.prototype.add=function(e,t){var n=new this._owner._manager._ts_сonstructors[this._name](this);e||(e={});for(var r in n._metadata.fields)n[r]=e[r]||"";return n._obj.row=this._obj.push(n._obj),n._obj.__define("_row",{value:n,enumerable:!1}),t||Object.getNotifier(this._owner).notify({type:"rows",tabular:this._name}),e=null,n},TabularSection.prototype.each=function(e){var t=this;t._obj.forEach(function(n){return e.call(t,n._row)})},TabularSection.prototype.load=function(e){var t=this,n;t.clear(!0),e instanceof TabularSection?n=e._obj:Array.isArray(e)&&(n=e),n&&n.forEach(function(e){t.add(e,!0)}),Object.getNotifier(this._owner).notify({type:"rows",tabular:this._name})},TabularSection.prototype.sync_grid=function(e,t){var n={rows:[]},r=[];for(var i=0;i<e.getColumnCount();i++)r.push(e.getColumnId(i));e.clearAll(),this.find_rows(t,function(e){var t=[];r.forEach(function(n){$p.is_data_obj(e[n])?t.push(e[n].presentation):t.push(e[n])}),n.rows.push({id:e.row,data:t})});try{e.parse(n,"json")}catch(s){}e.callEvent("onGridReconstructed",[])},TabularSection.prototype.toJSON=function(){return this._obj},TabularSectionRow.prototype.__define("_metadata",{get:function(){return this._owner._owner._metadata.tabular_sections[this._owner._name]},enumerable:!1}),TabularSectionRow.prototype.__define("row",{get:function(){return this._obj.row||0},enumerable:!0}),TabularSectionRow.prototype.__define("_clone",{value:function(){return(new this._owner._owner._manager._ts_сonstructors[this._owner._name](this._owner))._mixin(this._obj)},enumerable:!1}),TabularSectionRow.prototype._getter=DataObj.prototype._getter,TabularSectionRow.prototype._setter=function(e,t){if(this._obj[e]==t)return;Object.getNotifier(this._owner._owner).notify({type:"row",row:this,tabular:this._owner._name,name:e,oldValue:this._obj[e]}),DataObj.prototype.__setter.call(this,e,t)};var _rest=$p.rest=new Rest;DataManager.prototype.__define("rest_name",{get:function(e){var t=this.class_name.split("."),n={cat:"Catalog",doc:"Document",ireg:"InformationRegister",areg:"AccumulationRegister",cch:"ChartOfCharacteristicTypes",cacc:"ChartOfAccounts"};return n[t[0]]+"_"+_md.syns_1с(t[1])+(e||"")},enumerable:!1}),DataManager.prototype.rest_tree=function(e){var t=this,n=t.metadata(),r=[],i=[],s,o,u,a;return $p.ajax.default_attr(e,$p.job_prm.rest?$p.job_prm.rest_url():$p.job_prm.irest_url()),e.url+=this.rest_name+"?allowedOnly=true&$format=json&$top=1000&$select=Ref_Key,DeletionMark,Parent_Key,Description&$filter=IsFolder eq true",$p.ajax.get_ex(e.url,e).then(function(e){return JSON.parse(e.response)}).then(function(e){for(var t=0;t<e.value.length;t++)o=e.value[t],s={ref:o.Ref_Key,deleted:o.DeletionMark,parent:o.Parent_Key,presentation:o.Description},i.push(s);return $p.iface.data_to_tree(i)})},DataManager.prototype.rest_selection=function(e){function t(){var e="$select=Ref_Key,DeletionMark";return r.form&&r.form.selection?r.form.selection.fields.forEach(function(e){i.push(e)}):n instanceof DocManager?(i.push("posted"),i.push("date"),i.push("number_doc")):(r.hierarchical&&r.group_hierarchy?i.push("is_folder"):i.push("0 as is_folder"),r.main_presentation_name?i.push("name as presentation"):r.code_length?i.push("id as presentation"):i.push("'...' as presentation"),r.has_owners&&i.push("owner"),r.code_length&&i.push("id")),i.forEach(function(t){var r;if(t.indexOf(" as ")!=-1){r=t.split(" as ")[0].split(".");if(r.length==1)t=r[0];else{if(r[0]!="_t_")return;t=r[1]}}if(t=="0")return;a=_md.syns_1с(t),_md.get(n.class_name,t).type.is_ref&&a.indexOf("_Key")==-1&&_md.get(n.class_name,t).type.types.length&&_md.get(n.class_name,t).type.types[0].indexOf("enm.")==-1&&(a+="_Key"),e+=","+a}),i.push("ref"),i.push("deleted"),e}if(e.action=="get_tree")return this.rest_tree(e);var n=this,r=n.metadata(),i=[],s=[],o,u,a,f,l=t(),c;return $p.ajax.default_attr(e,$p.job_prm.rest?$p.job_prm.rest_url():$p.job_prm.irest_url()),e.url+=this.rest_name+"?allowedOnly=true&$format=json&$top=1000&"+l,_md.get(n.class_name,"date")&&(e.url+="&$filter="+_rest.filter_date("Date",e.date_from,e.date_till),c=!0),e.parent&&(e.url+=c?" and ":"&$filter=",e.url+="Parent_Key eq guid'"+e.parent+"'",c=!0),$p.ajax.get_ex(e.url,e).then(function(e){return JSON.parse(e.response)}).then(function(t){for(var r=0;r<t.value.length;r++)u=t.value[r],o={},i.forEach(function(e){var t;if(e=="ref"){o[e]=u.Ref_Key;return}e.indexOf(" as ")!=-1?(t=e.split(" as ")[1],e=e.split(" as ")[0].split("."),e=e[e.length-1]):t=e,a=_md.syns_1с(e),f=_md.get(n.class_name,e),a.indexOf("_Key")==-1&&f.type.is_ref&&f.type.types.length&&f.type.types[0].indexOf("enm.")==-1&&(a+="_Key");if(f.type.date_part)o[t]=$p.dateFormat(u[a],$p.dateFormat.masks[f.type.date_part]);else if(f.type.is_ref)if(!u[a]||u[a]==$p.blank.guid)o[t]="";else{var r=_md.value_mgr(o,e,f.type,!1,u[a]);r?o[t]=r.get(u[a]).presentation:o[t]=""}else o[t]=u[a]}),s.push(o);return $p.iface.data_to_grid.call(n,s,e)})},InfoRegManager.prototype.rest_slice_last=function(e){e.period||(e.period=$p.date_add_day(new Date,1));var t=this,n=t.metadata(),r="Period=datetime'"+$p.dateFormat(e.period,$p.dateFormat.masks.isoDateTime)+"'",i="";for(var s in n.dimensions){if(e[s]===undefined)continue;var o=_md.syns_1с(s),u=n.dimensions[s];o.indexOf("_Key")==-1&&u.type.is_ref&&u.type.types.length&&u.type.types[0].indexOf("enm.")==-1?(o+="_Key",i&&(i+=" and "),i+=o+" eq guid'"+e[s].ref+"'"):(i&&(i+=" and "),u.type.digits?i+=o+" eq "+$p.fix_number(e[s]):u.type.date_part?i+=o+" eq datetime'"+$p.dateFormat(e[s],$p.dateFormat.masks.isoDateTime)+"'":i+=o+" eq '"+e[s]+"'")}return i&&(r+=",Condition='"+i+"'"),$p.ajax.default_attr(e,$p.job_prm.rest_url()),e.url+=this.rest_name+"/SliceLast(%sl)?allowedOnly=true&$format=json&$top=1000".replace("%sl",r),_rest.ajax_to_data(e,t).then(function(e){return t.load_array(e)})},DataObj.prototype.to_atom=function(e){function t(e){var t=e._metadata.fields,n=e instanceof TabularSectionRow?"\n	<d:":"\n<d:";for(i in t){s=t[i],f=_md.syns_1с(i),l=e[i];if(l instanceof EnumObj)l=l.empty()?"":l.name;else if(l instanceof DataObj)f.indexOf("_Key")==-1&&(f+="_Key"),l=l.ref;else if(s.type.date_part)l.getFullYear()<1e3?l="0001-01-01T00:00:00Z":l=$p.dateFormat(l,$p.dateFormat.masks.atom);else if(l==undefined)continue;r+=n+f+">"+l+"</d:"+f+">"}}var n='<entry><category term="StandardODATA.%n" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>				\n<title type="text"/><updated>%d</updated><author/><summary/><content type="application/xml">				\n<m:properties xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">			%p			\n</m:properties></content></entry>'.replace("%n",this._manager.rest_name).replace("%d",$p.dateFormat(new Date,$p.dateFormat.masks.atom)),r="\n<d:Ref_Key>"+this.ref+"</d:Ref_Key>"+"\n<d:DeletionMark>"+this.deleted+"</d:DeletionMark>"+"\n<d:DataVersion>"+this.data_version+"</d:DataVersion>",i,s,o,u,a,f,l;this instanceof DocObj?(r+="\n<d:Date>"+$p.dateFormat(this.date,$p.dateFormat.masks.atom)+"</d:Date>",r+="\n<d:Number>"+this.number_doc+"</d:Number>"):(this._metadata.main_presentation_name&&(r+="\n<d:Description>"+this.name+"</d:Description>"),this._metadata.code_length&&(r+="\n<d:Code>"+this.id+"</d:Code>"),this._metadata.hierarchical&&this._metadata.group_hierarchy&&(r+="\n<d:IsFolder>"+this.is_folder+"</d:IsFolder>")),t(this);for(o in this._metadata.tabular_sections)a=this._metadata.tabular_sections[o],f="StandardODATA."+this._manager.rest_name+"_"+_md.syns_1с(o)+"_RowType",u=this[o],u.count()?(r+="\n<d:"+_md.syns_1с(o)+' m:type="Collection('+f+')">',u.each(function(e){r+='\n	<d:element m:type="'+f+'">',r+="\n	<d:LineNumber>"+e.row+"</d:LineNumber>",t(e),r+="\n	</d:element>"}),r+="\n</d:"+_md.syns_1с(o)+">"):r+="\n<d:"+_md.syns_1с(o)+' m:type="Collection('+f+')" />';return n.replace("%p",r)},DataManager.prototype.export=function(e){function t(){$p.wsql.restore_options("data_manager",a),a.wnd.caption="Экспорт "+o.family_name+" '"+(o.metadata().synonym||o.metadata().name)+"'",u=$p.iface.dat_blank(null,a.wnd),u.bottom_toolbar({buttons:[{name:"btn_cancel",img:"tb_delete.png",text:"Отмена",title:"Отмена",width:"80px","float":"right"},{name:"btn_ok",img:"save.png",b:"Ок",title:"Выполнить экспорт",width:"50px","float":"right"}],onclick:function(e){return e=="btn_ok"?i():u.close(),!1}}),u.button("close").show(),u.button("park").hide(),u.attachEvent("onClose",s);var t=[{type:"fieldset",name:"form_range",label:"Выгрузить",list:[{type:"settings",labelWidth:320,labelAlign:"left",position:"label-right"},{type:"radio",name:"range",label:"Выделенные строки",value:"selected"},{type:"radio",name:"range",label:"Весь справочник",value:"all"}]},{type:"fieldset",name:"form_fieldset_2",label:"Дополнительно выгрузить",list:[{type:"settings",labelWidth:160,position:"label-right"},{type:"checkbox",name:"meta",label:"Описание метаданных",labelAlign:"left",position:"label-right",checked:a.meta},{type:"newcolumn"},{type:"checkbox",name:"relation",label:"Связанные объекты",position:"label-right",checked:a.relation,tooltip:"Связанные объекты по ссылкам (пока не реализовано)"}]},{type:"fieldset",name:"fieldset_format",label:"Формат файла",list:[{type:"settings",labelWidth:60,labelAlign:"left",position:"label-right"},{type:"radio",name:"format",label:"json",value:"json",tooltip:"Выгрузить в формате JSON"},{type:"newcolumn"},{type:"radio",name:"format",label:"xlsx",value:"xlsx",tooltip:"Выгрузить в офисном формате XLSX"},{type:"newcolumn"},{type:"radio",name:"format",label:"atom",value:"atom",tooltip:"Выгрузить в формате XML Atom"}]}];u.elmnts.frm=u.attachForm(t),u.elmnts.frm.setItemValue("range",a.range||"all"),e.items&&e.items.length==1?(e.obj?u.elmnts.frm.setItemLabel("range","selected","Тек. объект: "+e.items[0].presentation):o.get(e.items[0],!0).then(function(e){u.elmnts.frm.setItemLabel("range","selected","Тек. объект: "+e.presentation)}),u.elmnts.frm.setItemValue("range","selected")):e.items&&e.items.length&&u.elmnts.frm.setItemLabel("range","selected","Выделенные строки ("+e.items.length+" элем.)"),o instanceof DocManager&&u.elmnts.frm.setItemLabel("range","all","Все документы из кеша (0 элем.)"),u.elmnts.frm.setItemValue("format",a.format||"json"),u.elmnts.frm.attachEvent("onChange",n),n(),e.pwnd&&e.pwnd.isModal&&e.pwnd.isModal()&&(e.set_pwnd_modal=!0,e.pwnd.setModal(!1)),u.setModal(!0)}function n(){u.elmnts.frm.setItemValue("relation",!1),u.elmnts.frm.disableItem("relation"),u.elmnts.frm.getItemValue("range")=="all"?(u.elmnts.frm.disableItem("format","atom"),u.elmnts.frm.getItemValue("format")=="atom"&&u.elmnts.frm.setItemValue("format","json")):u.elmnts.frm.enableItem("format","atom"),u.elmnts.frm.getItemValue("format")=="json"?u.elmnts.frm.enableItem("meta"):u.elmnts.frm.getItemValue("format")=="sql"?(u.elmnts.frm.setItemValue("meta",!1),u.elmnts.frm.disableItem("meta")):(u.elmnts.frm.setItemValue("meta",!1),u.elmnts.frm.disableItem("meta"))}function r(){return a.format=u.elmnts.frm.getItemValue("format"),a.range=u.elmnts.frm.getItemValue("range"),a.meta=u.elmnts.frm.getItemValue("meta"),a.relation=u.elmnts.frm.getItemValue("relation"),a}function i(){function t(){e.obj?alasql("SELECT * INTO XLSX('"+o.table_name+".xlsx',{headers:true}) FROM ?",[e.items[0]._obj]):alasql("SELECT * INTO XLSX('"+o.table_name+".xlsx',{headers:true}) FROM "+o.table_name)}r();var n={meta:{},items:{}},i=n.items[o.class_name]=[];a.meta&&(n.meta[o.class_name]=o.metadata());if(a.format=="json")e.obj?i.push(e.items[0]._obj):o.each(function(t){(a.range=="all"||e.items.indexOf(t.ref)!=-1)&&i.push(t._obj)}),e.items.length&&!i.length?o.get(e.items[0],!0).then(function(e){i.push(e._obj),alasql.utils.saveFile(o.table_name+".json",JSON.stringify(n,null,4))}):alasql.utils.saveFile(o.table_name+".json",JSON.stringify(n,null,4));else if(a.format=="xlsx")window.xlsx?t():$p.load_script("//cdn.jsdelivr.net/js-xlsx/latest/xlsx.core.min.js","script",t);else if(a.format=="atom"&&e.items.length){var s=e.obj?Promise.resolve(e.items[0]):o.get(e.items[0],!0);s.then(function(e){alasql.utils.saveFile(o.table_name+".xml",e.to_atom())})}else $p.msg.show_not_implemented()}function s(t){return $p.iface.popup.hide(),u.wnd_options(a.wnd),$p.wsql.save_options("data_manager",r()),u.setModal(!1),e.set_pwnd_modal&&e.pwnd.setModal&&e.pwnd.setModal(!0),!0}e&&"string"==typeof e?e={items:e.split(",")}:e||(e={items:[]});var o=this,u,a={name:"export",wnd:{top:130,left:200,width:480,height:350}};t()},DataManager.prototype.import=function(e,t){function n(e){function n(e,n){var r=_md.mgr_by_class_name(e);if(n.length)if(!t)i=!0,r.load_array(n,!0);else if(t._manager==r)for(var s in n)$p.fix_guid(n[s])==t.ref&&(i=!0,r.load_array([n[s]],!0))}o.close();if(r.files.length){var s=new FileReader;s.onload=function(e){try{var t=JSON.parse(s.result);if(t.items)for(var r in t.items)n(r,t.items[r]);else["cat","doc","ireg","areg","cch","cacc"].forEach(function(e){if(t[e])for(var r in t[e])n(e+"."+r,t.cat[r])});i||$p.msg.show_msg($p.msg.sync_no_data)}catch(o){$p.msg.show_msg(o.message)}},s.readAsText(r.files[0])}}var r,i;if(!e&&typeof window!=undefined){var s={name:"import",wnd:{width:300,height:100,caption:$p.msg.select_file_import}},o=$p.iface.dat_blank(null,s.wnd);r=document.createElement("input"),r.setAttribute("id","json_file"),r.setAttribute("type","file"),r.setAttribute("accept",".json"),r.setAttribute("value","*.json"),r.onchange=n,o.button("close").show(),o.button("park").hide(),o.attachObject(r),o.centerOnScreen(),o.setModal(!0),setTimeout(function(){r.click()},100)}},$p.iface.wnd_sync=function(){function e(){var e={name:"wnd_sync",wnd:{id:"wnd_sync",top:130,left:200,width:496,height:290,modal:!0,center:!0,caption:"Подготовка данных"}};n.wnd_sync=$p.iface.dat_blank(null,e.wnd);var t=[{type:"block",name:"form_block_1",list:[{type:"label",name:"form_label_1",label:$p.msg.sync_data},{type:"block",name:"form_block_2",list:[{type:"template",name:"img_long",className:"img_long"},{type:"newcolumn"},{type:"template",name:"text_processed"},{type:"template",name:"text_current"},{type:"template",name:"text_bottom"}]}]},{type:"button",name:"form_button_1",value:$p.msg.sync_break}];n.frm_sync=n.wnd_sync.attachForm(t),n.frm_sync.attachEvent("onButtonClick",function(e){n&&(n.do_break=!0)}),n.frm_sync.setItemValue("text_processed","Инициализация"),n.frm_sync.setItemValue("text_bottom","Загружается структура таблиц...")}var t=$p.iface.sync={},n;t.create=function(t){n=t,e()},t.update=function(e){n.frm_sync.setItemValue("text_processed","Обработано элементов: "+n.step*n.step_size+" из "+n.count_all);var t="",r,i=0;for(var s in e){i++;if(i>4)break;t&&(t+="<br />"),r=$p.cat[s].metadata(),t+=(r.list_presentation||r.synonym)+" ("+e[s].length+")"}n.frm_sync.setItemValue("text_current","Текущий запрос: "+n.step+" ("+Math.round(n.step*n.step_size*100/n.count_all)+"%)"),n.frm_sync.setItemValue("text_bottom",t)},t.close=function(){n&&n.wnd_sync&&(n.wnd_sync.close(),delete n.wnd_sync)}},DataManager.prototype.form_obj=function(e,t){function n(){e instanceof dhtmlXLayoutCell&&(t.bind_pwnd||t.Приклеить)?(typeof e.close=="function"&&e.close(),d=e,d.close=function(){if(d||e)(d||e).detachToolbar(),(d||e).detachStatusBar(),(d||e).detachObject(!0);a()},d.elmnts={},setTimeout(function(){d.showHeader(),d.setText((p.obj_presentation||p.synonym)+": "+h.presentation)})):(v={name:"wnd_obj_"+c.class_name,wnd:{id:"wnd_obj_"+c.class_name,top:80+Math.random()*40,left:120+Math.random()*80,width:900,height:600,modal:!0,center:!1,pwnd:e,allow_close:!0,allow_minmax:!0,on_close:f,caption:(p.obj_presentation||p.synonym)+": "+h.presentation}},d=$p.iface.dat_blank(null,v.wnd)),d.ref||d.__define("ref",{get:function(){return h?h.ref:$p.blank.guid},enumerable:!1,configurable:!0}),d.elmnts.frm_tabs=d.attachTabbar({arrows_mode:"auto",offsets:{top:0,right:0,bottom:0,left:0}}),d.elmnts.frm_tabs.addTab("tab_header","&nbsp;Реквизиты&nbsp;",null,null,!0),d.elmnts.tabs={tab_header:d.elmnts.frm_tabs.cells("tab_header")};if(!h.is_folder)for(var n in p.tabular_sections){if(n==="extra_fields")continue;h[n]instanceof TabularSection&&o(n)}d.attachEvent("onResizeFinish",function(e){d.elmnts.pg_header.enableAutoHeight(!1,d.elmnts.tabs.tab_header._getHeight()-20,!0)}),d.elmnts.pg_header=d.elmnts.tabs.tab_header.attachHeadFields({obj:h,pwnd:d}),d.elmnts.frm_toolbar=d.attachToolbar(),d.elmnts.frm_toolbar.setIconsPath(dhtmlx.image_path+"dhxtoolbar"+dhtmlx.skin_suffix()),d.elmnts.frm_toolbar.loadStruct(require("toolbar_obj"),function(){this.addSpacer("btn_unpost"),this.attachEvent("onclick",r),h.hasOwnProperty("posted")?(this.enableItem("btn_post"),this.enableItem("btn_unpost")):(this.hideItem("btn_post"),this.hideItem("btn_unpost")),t.on_select&&this.setItemText("btn_save_close","Записать и выбрать"),c instanceof CatManager||c instanceof DocManager?c.printing_plates().then(function(e){for(var t in e)d.elmnts.frm_toolbar.addListOption("bs_print",t,"~","button",e[t])}):this.disableItem("bs_print"),d.elmnts.vault_pop=new dhtmlXPopup({toolbar:this,id:"btn_files"}),d.elmnts.vault_pop.attachEvent("onShow",s)}),$p.job_prm.russian_names&&(d.Элементы||d.__define({"Элементы":{get:function(){return this.elmnts},enumerable:!1}}),d.elmnts.Шапка||d.elmnts.__define({"Шапка":{get:function(){return this.pg_header},enumerable:!1}}))}function r(e){e=="btn_save_close"?u("close"):e=="btn_save"?u("save"):e=="btn_go_connection"?i():e.substr(0,4)=="prn_"?c.print(h.ref,e,d):e=="btn_import"?c.import(null,h):e=="btn_export"&&c.export({items:[h],pwnd:d,obj:!0})}function i(){$p.msg.show_not_implemented()}function s(){d.elmnts.vault||(d.elmnts.vault=d.elmnts.vault_pop.attachVault(400,250,{uploadUrl:$p.job_prm.hs_url()+"/files/?class_name="+c.class_name+"&ref="+h.ref,buttonClear:!1,autoStart:!0,filesLimit:10}),d.elmnts.vault.conf.wnd=d,d.elmnts.vault.attachEvent("onUploadFile",function(e,t){}),d.elmnts.vault.attachEvent("onBeforeFileAdd",function(e){return e.size<=this.getMaxFileSize()?!0:($p.msg.show_msg({type:"alert-warning",text:$p.msg.file_size+this._readableSize(this.getMaxFileSize()),title:$p.msg.main_title}),!1)}),d.elmnts.vault.attachEvent("onBeforeFileRemove",function(e){return d.elmnts.vault.file_data[e.id].delete_confirmed?!0:(dhtmlx.confirm({title:$p.msg.main_title,text:$p.msg.file_confirm_delete+e.name,cancel:"Отмена",callback:function(t){t&&$p.ajax.post_ex(d.elmnts.vault.actionUrl(e.id,"drop"),"",!0).then(function(t){d.elmnts.vault.file_data[e.id].delete_confirmed=!0,d.elmnts.vault._removeFileFromQueue(e.id)})}}),!1)}))}function o(e){if(!_md.ts_captions(c.class_name,e))return;d.elmnts.frm_tabs.addTab("tab_"+e,"&nbsp;"+p.tabular_sections[e].synonym+"&nbsp;"),d.elmnts.tabs["tab_"+e]=d.elmnts.frm_tabs.cells("tab_"+e),d.elmnts.tabs["tab_"+e].attachTabular({obj:h,ts:e,pwnd:d})}function u(e){d.progressOn(),h.save().then(function(){d.progressOff(),d.modified=!1,e=="close"&&(t.on_select&&t.on_select(h),d.close())}).catch(function(e){d.progressOff(),console.log(e)})}function a(){d&&d.elmnts&&d.elmnts.vault&&d.elmnts.vault.unload(),d&&d.elmnts&&d.elmnts.vault_pop&&d.elmnts.vault_pop.unload(),c=null,d=null}function f(e){return setTimeout(a,1),!0}var l=require("wnd/wnd_"+this.class_name.replace(".","_")+"_obj");if(l)return l($p,e,t);var c=this,h=t.o,p=c.metadata(),d,v;return $p.is_data_obj(h)?h.is_new()&&t.on_select?c.create({},!0).then(function(e){h=e,e=null,n()}):h.is_new()&&!h.empty()?h.load().then(n):n():(e.progressOn(),c.get(t.hasOwnProperty("ref")?t.ref:t,!0).then(function(t){h=t,t=null,e.progressOff(),n()}).catch(function(t){e.progressOff(),console.log(t)})),d},DataObj.prototype.form_obj=function(e,t){return t||(t={}),t.o=this,this._manager.form_obj(e,t)},DataManager.prototype.form_selection=function(e,t){function n(){e instanceof dhtmlXCellObject?(!(e instanceof dhtmlXTabBarCell)&&typeof e.close=="function"&&e.close(),m=e,m.close=function(){if(m||e)(m||e).detachToolbar(),(m||e).detachStatusBar(),(m||e).detachObject(!0);f()},t.hide_header||setTimeout(function(){m.showHeader()})):(m=$p.iface.w.createWindow("wnd_"+p.class_name.replace(".","_")+"_select",0,0,900,600),m.centerOnScreen(),m.setModal(1),m.button("park").hide(),m.button("minmax").show(),m.button("minmax").enable(),m.attachEvent("onClose",l)),$p.iface.bind_help(m),m instanceof dhtmlXTabBarCell||m.setText("Список "+(p.class_name.indexOf("doc.")==-1?'справочника "':'документов "')+(d.list_presentation||d.synonym)+'"'),dhtmlxEvent(document.body,"keydown",r),m.elmnts={status_bar:m.attachStatusBar()},m.elmnts.status_bar.setText("<div id='"+p.class_name.replace(".","_")+"_select_recinfoArea'></div>"),m.elmnts.toolbar=m.attachToolbar(),m.elmnts.toolbar.setIconsPath(dhtmlx.image_path+"dhxtoolbar"+dhtmlx.skin_suffix()),m.elmnts.toolbar.loadStruct(require("toolbar_selection"),function(){this.attachEvent("onclick",o);var e={manager:p,toolbar:this,onchange:i};t.date_from&&(e.date_from=t.date_from),t.date_till&&(e.date_till=t.date_till),m.elmnts.filter=new $p.iface.Toolbar_filter(e),$p.ajax.root||(this.disableItem("btn_new"),this.disableItem("btn_edit"),this.disableItem("btn_delete")),!w&&$p.iface.docs&&$p.iface.docs.getViewName&&$p.iface.docs.getViewName()=="oper"&&(this.hideItem("btn_select"),this.hideItem("sep1"),this.addListOption("bs_more","btn_order_list","~","button","Список заказов","tb_autocad.png")),this.addListOption("bs_more","btn_import","~","button","Загрузить из файла","document_load.png"),this.addListOption("bs_more","btn_export","~","button","Выгрузить в файл","document_save.png"),p instanceof CatManager||p instanceof DocManager?p.printing_plates().then(function(e){var t;for(var n in e)m.elmnts.toolbar.addListOption("bs_print",n,"~","button",e[n]),t=!0;t||m.elmnts.toolbar.hideItem("bs_print")}):m.elmnts.toolbar.hideItem("bs_print"),s()})}function r(e){function t(){var e;return $p.iface.w.forEachWindow(function(t){t.isModal()&&t!=m&&(e=!0)}),e}if(m)if(e.keyCode==113||e.keyCode==115){if(!t())return setTimeout(function(){m.elmnts.filter.input_filter.focus()}),$p.cancel_bubble(e)}else if(e.shiftKey&&e.keyCode==116){if(!t())return setTimeout(function(){m.elmnts.grid.reload()}),e.preventDefault&&e.preventDefault(),$p.cancel_bubble(e)}else e.keyCode==27&&!t()}function i(e){v&&(e.filter?m.elmnts.cell_tree.collapse():m.elmnts.cell_tree.expand()),m.elmnts.grid.reload()}function s(){var e,n,r,i,s,o;v?(e=m.attachLayout("2U"),r=e.cells("b"),r.hideHeader(),n=m.elmnts.cell_tree=e.cells("a"),n.setWidth("220"),n.hideHeader(),i=m.elmnts.tree=n.attachDynTree(p,null,function(){setTimeout(function(){s.reload()},20)}),i.attachEvent("onSelect",function(){this.do_not_reload?delete this.do_not_reload:setTimeout(function(){s.reload()},20)}),i.attachEvent("onDblClick",function(e){u(e)})):(r=m,setTimeout(function(){s.reload()},20)),s=m.elmnts.grid=r.attachGrid(),s.setIconsPath(dhtmlx.image_path),s.setImagePath(dhtmlx.image_path),s.setPagingWTMode(!0,!0,!0,[20,30,60]),s.enablePaging(!0,30,8,p.class_name.replace(".","_")+"_select_recinfoArea"),s.setPagingSkin("toolbar",dhtmlx.skin),s.attachEvent("onBeforeSorting",h),s.attachEvent("onBeforePageChanged",function(){return!!this.getRowsNum()}),s.attachEvent("onXLE",function(){r.progressOff()}),s.attachEvent("onXLS",function(){r.progressOn()}),s.attachEvent("onDynXLS",function(e,t){var n=c(e,t);if(!n)return;return $p.cat.load_soap_to_grid(n,s),!1}),s.attachEvent("onRowDblClicked",function(e,t){var n=null;i&&(n=i.getIndexById(e)),n!=null?i.selectItem(e,!0):u(e)}),$p.iface.docs&&$p.iface.docs.getViewName&&$p.iface.docs.getViewName()=="oper"&&s.enableMultiselect(!0),s.reload=function(){var e=c();if(!e)return;r.progressOn(),s.clearAll(),$p.cat.load_soap_to_grid(e,s,function(n){if(typeof n=="object")$p.msg.check_soap_result(n);else if(!o){if(e.initial_value){var u=n.indexOf("set_parent"),a=n.indexOf("'>",u),f=n.substr(u+12,a-u-12);$p.is_guid(f)&&v&&(i.do_not_reload=!0,i.selectItem(f,!1)),s.selectRowById(e.initial_value)}else e.parent&&$p.is_guid(e.parent)&&v&&(i.do_not_reload=!0,i.selectItem(e.parent,!1));s.setColumnMinWidth(200,s.getColIndexById("presentation")),s.enableAutoWidth(!0,1200,600),s.setSizes(),o=!0,m.elmnts.filter.input_filter.focus(),t.on_grid_inited&&t.on_grid_inited()}y&&o&&s.setSortImgState(!0,g,y),r.progressOff()})}}function o(e){if(e=="btn_select")u();else if(e=="btn_new")p.create({},!0).then(function(e){e._set_loaded(e.ref),$p.iface.set_hash(p.class_name,e.ref)});else if(e=="btn_edit"){var t=m.elmnts.grid.getSelectedRowId();t?$p.iface.set_hash(p.class_name,t):$p.msg.show_msg({type:"alert-warning",text:$p.msg.no_selected_row.replace("%1",""),title:$p.msg.main_title})}else e.substr(0,4)=="prn_"?a(e):e=="btn_order_list"?$p.iface.set_hash("","","","def"):e=="btn_delete"?$p.msg.show_not_implemented():e=="btn_import"?p.import():e=="btn_export"?p.export(m.elmnts.grid.getSelectedRowId()):e=="btn_requery"&&(b={},m.elmnts.grid.reload())}function u(n){n||(n=m.elmnts.grid.getSelectedRowId());var r;t.selection&&t.selection.forEach(function(e){for(var t in e)t=="is_folder"&&(r=e[t])});if(m.elmnts.tree&&m.elmnts.tree.getIndexById(n)!=null&&m.elmnts.tree.getSelectedItemId()!=n){m.elmnts.tree.selectItem(n,!0);return}if(n&&r===!0&&m.elmnts.grid.cells(n,0).cell.classList.contains("cell_ref_elm")){$p.msg.show_msg($p.msg.select_grp);return}if(!n&&m.elmnts.tree||m.elmnts.tree&&m.elmnts.tree.getSelectedItemId()==n){if(r===!1){$p.msg.show_msg($p.msg.select_elm);return}n=m.elmnts.tree.getSelectedItemId()}n&&(w?p.get(n,!0).then(function(t){m.close(),w.call(e.grid||e,t)}):$p.iface.set_hash(p.class_name,n))}function a(e){var t=m.elmnts.grid.getSelectedRowId();t?p.print(t,e,m):$p.msg.show_msg({type:"alert-warning",text:$p.msg.no_selected_row.replace("%1",""),title:$p.msg.main_title})}function f(){document.body.removeEventListener("keydown",r),p=m=d=b=w=e=t=null}function l(t){return setTimeout(f,10),e.on_unload&&e.on_unload.call(e.grid||e),!0}function c(e,n){var r=m.elmnts.filter.get_filter()._mixin({action:"get_selection",class_name:p.class_name,order_by:g,direction:y,start:e||((m.elmnts.grid.currentPage||1)-1)*m.elmnts.grid.rowsBufferOutSize,count:n||m.elmnts.grid.rowsBufferOutSize,get_header:b.get_header==undefined})._mixin(t),i=v?m.elmnts.tree.getSelectedItemId():null;r.parent=(i||t.parent)&&!r.filter?i||t.parent:null,v&&!r.parent&&(r.parent=$p.blank.guid);for(var s in r)if(b[s]!=r[s])return b=r,r}function h(e){var t=m.elmnts.grid.getSortingState();return g=e,y=t[1]=="des"?"asc":"des",m.elmnts.grid.reload(),!0}e||(e=t&&t.pwnd?t.pwnd:{}),!t&&!(e instanceof dhtmlXCellObject)&&(t=e,e={}),t||(t={});var p=this,d=p.metadata(),v=d.hierarchical&&!(p instanceof ChartOfAccountManager),m,g=0,y="asc",b={},w=e.on_select||t.on_select;return v&&t.initial_value&&t.initial_value!=$p.blank.guid&&!t.parent?p.get(t.initial_value,!0).then(function(e){t.parent=e.parent.ref,t.set_parent=t.parent,n()}):n(),m},DataManager.prototype.form_list=function(e,t){return this.form_selection(e,t)},typeof window!="undefined"&&only_in_browser(window),$p.eve.socket=new SocketMsg,$p.eve.steps={load_meta:0,authorization:1,create_managers:2,process_access:3,load_data_files:4,load_data_db:5,load_data_wsql:6,save_data_wsql:7},$p.eve.ontimer=function(){$p.eve.update_files_version()},setInterval($p.eve.ontimer,18e4),$p.eve.update_files_version=function(){if(!$p.job_prm||$p.job_prm.offline||!$p.job_prm.data_url)return;$p.job_prm.files_date||($p.job_prm.files_date=$p.wsql.get_user_param("files_date","number")),$p.ajax.get($p.job_prm.data_url+"sync.json?v="+Date.now()).then(function(e){var t=JSON.parse(e.response);!$p.job_prm.confirmation&&$p.job_prm.files_date!=t.files_date&&($p.wsql.set_user_param("files_date",t.files_date),$p.job_prm.confirmation=!0,dhtmlx.confirm({title:$p.msg.file_new_date_title,text:$p.msg.file_new_date,ok:"Перезагрузка",cancel:"Продолжить",callback:function(e){delete $p.job_prm.confirmation,e&&($p.eve.redirect=!0,location.reload(!0))}}))}).catch($p.record_log)},$p.eve.pop=function(){function e(e){return _load({action:"get_cachable_portion",cache_cat_date:n,step_size:$p.eve.stepper.step_size,step:e||0})}function t(e){$p.eve.stepper.cat_ini_date>$p.wsql.get_user_param("cache_cat_date","number")&&$p.wsql.set_user_param("cache_cat_date",$p.eve.stepper.cat_ini_date),e&&setTimeout(function(){$p.eve.pop(!0)},1e4)}var n=$p.eve.stepper.cat_ini_date;return $p.job_prm.offline||!$p.job_prm.irest_enabled?Promise.resolve(!1):Promise.resolve(!1)},$p.eve.push=function(){},$p.eve.from_json_to_data_obj=function(e){var t=$p.eve.stepper,n;typeof e=="string"?e=JSON.parse(e):e instanceof XMLHttpRequest&&(e.response?e=JSON.parse(e.response):e={});if(t.do_break)$p.iface.sync.close(),$p.eve.redirect=!0,location.reload(!0);else if(e.cat_date||e.force){e.cat_date>t.cat_ini_date&&(t.cat_ini_date=e.cat_date),e.cat_date>t.cat_date&&(t.cat_date=e.cat_date),e.count_all&&(t.count_all=e.count_all),e.current&&(t.current=e.current);for(n in e.cch)_cch[n]&&_cch[n].load_array(e.cch[n]);for(n in e.cacc)_cacc[n]&&_cacc[n].load_array(e.cacc[n]);for(n in e.cat)_cat[n]&&_cat[n].load_array(e.cat[n]);for(n in e.doc)_doc[n]&&_doc[n].load_array(e.doc[n]);for(n in e.ireg)_ireg[n]&&_ireg[n].load_array(e.ireg[n]);for(n in e.areg)_areg[n]&&_areg[n].load_array(e.areg[n]);return e.current&&e.current>=t.step_size}},$p.eve.reduce_promices=function(e,t){return e.reduce(function(e,n){return e.then(function(){return n}).then(t).catch(t)},Promise.resolve())},$p.eve.js_time_diff=-(new Date("0001-01-01")).valueOf(),$p.eve.time_diff=function(){var e=$p.wsql.get_user_param("time_diff","number");return!e||isNaN(e)||e<621355716e5||e>62135622e6?$p.eve.js_time_diff:e},$p.eve.log_in=function(e){var t=$p.eve.stepper,n={},r=[],i,s,o,u=$p.job_prm.data_url||"/data/";return e($p.eve.steps.load_meta),$p.ajax.default_attr(n,$p.job_prm.irest_url()),$p.job_prm.offline||r.push($p.ajax.get_ex(n.url,n)),r.push($p.ajax.get(u+"meta.json?v="+$p.job_prm.files_date)),r.push($p.ajax.get(u+"meta_patch.json?v="+$p.job_prm.files_date)),$p.eve.reduce_promices(r,function(t){t instanceof XMLHttpRequest&&t.status==200?t.responseURL.indexOf("/hs/rest")!=-1?$p.job_prm.irest_enabled=!0:t.responseURL.indexOf("meta.json")!=-1?(e($p.eve.steps.create_managers),i=JSON.parse(t.response)):t.responseURL.indexOf("meta_patch.json")!=-1&&(s=JSON.parse(t.response)):$p.record_log(t)}).then(function(){if(!i)throw Error("Ошибка чтения файла метаданных");return new Meta(i,s)}).then(function(n){return i=s=null,e($p.eve.steps.authorization),$p.job_prm.offline?n:$p.job_prm.rest||$p.job_prm.irest_enabled?$p.job_prm.irest_enabled?{root:!0}:$p.ajax.get_ex($p.job_prm.rest_url()+"?$format=json",!0).then(function(e){return{root:!0}}):_load({action:"get_meta",cache_cat_date:t.cat_ini_date,now_js:Date.now(),margin:$p.wsql.get_user_param("margin","number"),ipinfo:$p.ipinfo.hasOwnProperty("latitude")?JSON.stringify($p.ipinfo):""})}).catch(function(e){throw $p.iface.auth.onerror&&$p.iface.auth.onerror(e),e}).then(function(t){e($p.eve.steps.load_data_files);if($p.job_prm.offline)return t;$p.ajax.authorized=!0,typeof t=="string"&&(t=JSON.parse(t));if($p.msg.check_soap_result(t))return;return $p.wsql.get_user_param("enable_save_pwd")?$p.wsql.set_user_param("user_pwd",$p.ajax.password):$p.wsql.get_user_param("user_pwd")&&$p.wsql.set_user_param("user_pwd",""),$p.wsql.set_user_param("time_diff",t["now_1с"]-t.now_js),t.cat&&t.cat.clrs&&(_md.get("cat.clrs").predefined.white.ref=t.cat.clrs.predefined.white.ref),t.cat&&t.cat.bases&&(_md.get("cat.bases").predefined.main.ref=t.cat.bases.predefined.main.ref),t}).then(function(e){return o=e,t.zone=($p.job_prm.demo?"1":$p.wsql.get_user_param("zone"))+"/",$p.ajax.get(u+"zones/"+t.zone+"p_0.json?v="+$p.job_prm.files_date)}).then(function(e){var n=JSON.parse(e.response);t.files=n.files-1,t.step_size=n.files>0?Math.round(n.count_all/n.files):57,t.cat_ini_date=n.cat_date,$p.eve.from_json_to_data_obj(n)}).then(function(){r=[];for(var e=1;e<=t.files;e++)r.push($p.ajax.get(u+"zones/"+t.zone+"p_"+e+".json?v="+$p.job_prm.files_date));return r.push($p.ajax.get(u+"zones/"+t.zone+"ireg.json?v="+$p.job_prm.files_date)),$p.eve.reduce_promices(r,$p.eve.from_json_to_data_obj)}).then(function(){return e($p.eve.steps.load_data_db),t.step_size=57,$p.eve.pop()}).then(function(){o.access&&(o.access.force=!0,$p.eve.from_json_to_data_obj(o.access)),_md.printing_plates(o.printing_plates),$p.ajax.hasOwnProperty("root")&&delete $p.ajax.root,$p.ajax.__define("root",{value:!!o.root,writable:!1,enumerable:!1})}).then(function(){e($p.eve.steps.save_data_wsql)})},$p.eve.auto_log_in=function(){var e=$p.eve.stepper,t=$p.job_prm.data_url||"/data/",n=[],r,i,s,o;return e.zone=$p.wsql.get_user_param("zone")+"/",n.push($p.ajax.get(t+"meta.json?v="+$p.job_prm.files_date)),n.push($p.ajax.get(t+"meta_patch.json?v="+$p.job_prm.files_date)),n.push($p.ajax.get(t+"zones/"+e.zone+"p_0.json?v="+$p.job_prm.files_date)),$p.eve.reduce_promices(n,function(e){e instanceof XMLHttpRequest&&e.status==200?e.responseURL.indexOf("meta.json")!=-1?r=JSON.parse(e.response):e.responseURL.indexOf("meta_patch.json")!=-1?i=JSON.parse(e.response):e.responseURL.indexOf("p_0.json")!=-1&&(s=JSON.parse(e.response)):$p.record_log(e)}).then(function(){if(!r)throw Error("Ошибка чтения файла метаданных");return new $p.Meta(r,i)}).then(function(t){e.files=s.files-1,e.step_size=s.files>0?Math.round(s.count_all/s.files):57,e.cat_ini_date=s.cat_date,$p.eve.from_json_to_data_obj(s)}).then(function(){n=[];for(var r=1;r<=e.files;r++)n.push($p.ajax.get(t+"zones/"+e.zone+"p_"+r+".json?v="+$p.job_prm.files_date));return n.push($p.ajax.get(t+"zones/"+e.zone+"ireg.json?v="+$p.job_prm.files_date)),$p.eve.reduce_promices(n,$p.eve.from_json_to_data_obj)}).then(function(){e.step_size=57})}},{filesaver:function(e,t,n){var r=r||function(e){"use strict";if(typeof navigator!="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent))return;var t=e.document,n=function(){return e.URL||e.webkitURL||e},r=t.createElementNS("http://www.w3.org/1999/xhtml","a"),i="download"in r,s=function(n){var r=t.createEvent("MouseEvents");r.initMouseEvent("click",!0,!1,e,0,0,0,0,0,!1,!1,!1,!1,0,null),n.dispatchEvent(r)},o=e.webkitRequestFileSystem,u=e.requestFileSystem||o||e.mozRequestFileSystem,a=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},f="application/octet-stream",l=0,c=500,h=function(t){var r=function(){typeof t=="string"?n().revokeObjectURL(t):t.remove()};e.chrome?r():setTimeout(r,c)},p=function(e,t,n){t=[].concat(t);var r=t.length;while(r--){var i=e["on"+t[r]];if(typeof i=="function")try{i.call(e,n||e)}catch(s){a(s)}}},d=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["﻿",e],{type:e.type}):e},v=function(t,a){t=d(t);var c=this,v=t.type,m=!1,g,y,b=function(){p(c,"writestart progress write writeend".split(" "))},w=function(){if(m||!g)g=n().createObjectURL(t);if(y)y.location.href=g;else{var r=e.open(g,"_blank");r==undefined&&typeof safari!="undefined"&&(e.location.href=g)}c.readyState=c.DONE,b(),h(g)},E=function(e){return function(){if(c.readyState!==c.DONE)return e.apply(this,arguments)}},S={create:!0,exclusive:!1},x;c.readyState=c.INIT,a||(a="download");if(i){g=n().createObjectURL(t),r.href=g,r.download=a,s(r),c.readyState=c.DONE,b(),h(g);return}e.chrome&&v&&v!==f&&(x=t.slice||t.webkitSlice,t=x.call(t,0,t.size,f),m=!0),o&&a!=="download"&&(a+=".download");if(v===f||o)y=e;if(!u){w();return}l+=t.size,u(e.TEMPORARY,l,E(function(e){e.root.getDirectory("saved",S,E(function(e){var n=function(){e.getFile(a,S,E(function(e){e.createWriter(E(function(n){n.onwriteend=function(t){y.location.href=e.toURL(),c.readyState=c.DONE,p(c,"writeend",t),h(e)},n.onerror=function(){var e=n.error;e.code!==e.ABORT_ERR&&w()},"writestart progress write abort".split(" ").forEach(function(e){n["on"+e]=c["on"+e]}),n.write(t),c.abort=function(){n.abort(),c.readyState=c.DONE},c.readyState=c.WRITING}),w)}),w)};e.getFile(a,{create:!1},E(function(e){e.remove(),n()}),E(function(e){e.code===e.NOT_FOUND_ERR?n():w()}))}),w)}),w)},m=v.prototype,g=function(e,t){return new v(e,t)};return typeof navigator!="undefined"&&navigator.msSaveOrOpenBlob?function(e,t){return navigator.msSaveOrOpenBlob(d(e),t)}:(m.abort=function(){var e=this;e.readyState=e.DONE,p(e,"abort")},m.readyState=m.INIT=0,m.WRITING=1,m.DONE=2,m.error=m.onwritestart=m.onprogress=m.onwrite=m.onabort=m.onerror=m.onwriteend=null,g)}(typeof self!="undefined"&&self||typeof window!="undefined"&&window||this.content);typeof n!="undefined"&&n.exports?n.exports.saveAs=r:typeof define!="undefined"&&define!==null&&define.amd!=null&&define([],function(){return r})},xml_to_json:function(e,t,n){var r=function(){this.version="1.3";var e={mergeCDATA:!0,grokAttr:!0,grokText:!0,normalize:!0,xmlns:!0,namespaceKey:"_ns",textKey:"_text",valueKey:"_value",attrKey:"_attr",cdataKey:"_cdata",attrsAsObject:!0,stripAttrPrefix:!0,stripElemPrefix:!0,childrenAsArray:!0},t=new RegExp(/(?!xmlns)^.*:/),n=new RegExp(/^\s+|\s+$/g);return this.grokType=function(e){return/^\s*$/.test(e)?null:/^(?:true|false)$/i.test(e)?e.toLowerCase()==="true":isFinite(e)?parseFloat(e):e},this.parseString=function(e,t){return this.parseXML(this.stringToXML(e),t)},this.parseXML=function(i,s){for(var o in s)e[o]=s[o];var u={},a=0,f="";e.xmlns&&i.namespaceURI&&(u[e.namespaceKey]=i.namespaceURI);if(i.attributes&&i.attributes.length>0){var l={};for(a;a<i.attributes.length;a++){var c=i.attributes.item(a);v={};var h="";e.stripAttrPrefix?h=c.name.replace(t,""):h=c.name,e.grokAttr?v[e.valueKey]=this.grokType(c.value.replace(n,"")):v[e.valueKey]=c.value.replace(n,""),e.xmlns&&c.namespaceURI&&(v[e.namespaceKey]=c.namespaceURI),e.attrsAsObject?l[h]=v:u[e.attrKey+h]=v}e.attrsAsObject&&(u[e.attrKey]=l)}if(i.hasChildNodes())for(var p,d,v,m=0;m<i.childNodes.length;m++)p=i.childNodes.item(m),p.nodeType===4?e.mergeCDATA?f+=p.nodeValue:u.hasOwnProperty(e.cdataKey)?(u[e.cdataKey].constructor!==Array&&(u[e.cdataKey]=[u[e.cdataKey]]),u[e.cdataKey].push(p.nodeValue)):e.childrenAsArray?(u[e.cdataKey]=[],u[e.cdataKey].push(p.nodeValue)):u[e.cdataKey]=p.nodeValue:p.nodeType===3?f+=p.nodeValue:p.nodeType===1&&(a===0&&(u={}),e.stripElemPrefix?d=p.nodeName.replace(t,""):d=p.nodeName,v=r.parseXML(p),u.hasOwnProperty(d)?(u[d].constructor!==Array&&(u[d]=[u[d]]),u[d].push(v)):(e.childrenAsArray?(u[d]=[],u[d].push(v)):u[d]=v,a++));else f||(e.childrenAsArray?(u[e.textKey]=[],u[e.textKey].push(null)):u[e.textKey]=null);if(f)if(e.grokText){var g=this.grokType(f.replace(n,""));g!==null&&g!==undefined&&(u[e.textKey]=g)}else e.normalize?u[e.textKey]=f.replace(n,"").replace(/\s+/g," "):u[e.textKey]=f.replace(n,"");return u},this.xmlToString=function(e){try{var t=e.xml?e.xml:(new XMLSerializer).serializeToString(e);return t}catch(n){return null}},this.stringToXML=function(e){try{var t=null;if(window.DOMParser){var n=new DOMParser;return t=n.parseFromString(e,"text/xml"),t}return t=new ActiveXObject("Microsoft.XMLDOM"),t.async=!1,t.loadXML(e),t}catch(r){return null}},this}();typeof n!="undefined"&&n!==null&&n.exports?n.exports=r:typeof define=="function"&&define.amd&&define(function(){return r})},form_auth:'<?xml version="1.0" encoding="UTF-8"?>\n<items>\n	<item type="settings" position="label-left" labelWidth="150" inputWidth="230" noteWidth="230"/>\n	<item type="fieldset" name="data" inputWidth="auto" label="Авторизация">\n\n        <item type="radio" name="type" labelWidth="auto" position="label-right" checked="true" value="guest" label="Гостевой (демо) режим">\n            <item type="select" name="guest" label="Роль">\n                <option value="Дилер" label="Дилер"/>\n            </item>\n        </item>\n\n		<item type="radio" name="type" labelWidth="auto" position="label-right" value="auth" label="Есть учетная запись">\n			<item type="input" value="" name="login" label="Имя пользователя" validate="NotEmpty" />\n			<item type="password" value="" name="password" label="Пароль" validate="NotEmpty" />\n		</item>\n\n		<item type="button" value="Войти" name="submit"/>\n\n        <item type="template" name="text_options" className="order_dealer_options" inputWidth="231"\n              value="&lt;a href=\'#\' onclick=\'$p.iface.open_settings();\' &gt; &lt;img src=\'/imgs/dhxtoolbar_web/tb_settings.png\' align=\'top\' /&gt; Настройки &lt;/a&gt; &lt;img src=\'/imgs/dhxtoolbar_web/blank9.png\' align=\'top\' /&gt; &lt;a href=\'//www.oknosoft.ru/feedback\' target=\'_blank\' &gt; &lt;img src=\'/imgs/dhxtoolbar_web/cloud-question.png\' align=\'top\' /&gt; Задать вопрос &lt;/a&gt;"  />\n\n	</item>\n</items>\n',toolbar_add_del:'<?xml version="1.0" encoding=\'utf-8\'?>\r\n<toolbar>\r\n    <item type="button" id="btn_add"    text="Добавить" title="Добавить строку" img="tb_new.png"  />\r\n    <item type="button" id="btn_delete" text="Удалить"  title="Удалить строку" img="tb_delete.png"   imgdis="tb_delete_dis.png" />\r\n</toolbar>',toolbar_obj:'<?xml version="1.0" encoding=\'utf-8\'?>\r\n<toolbar>\r\n    <item type="button" id="btn_save_close" text="Записать и закрыть" img="save.gif" imgdis="" title="Рассчитать, записать и закрыть" />\r\n    <item type="button" id="btn_save" text="Записать" img="tb_calculate.png" title="Рассчитать и записать данные"/>\r\n    <item type="button" id="btn_post" img="tb_post.png" imgdis="tb_post.png" enabled="false" title="Провести документ" />\r\n    <item type="button" id="btn_unpost" img="tb_unpost.png" imgdis="tb_unpost.png" enabled="false" title="Отмена проведения" />\r\n\r\n    <item type="button" id="btn_files" text="Файлы" img="tb_screpka.png" imgdis="tb_screpka_dis.png" title="Присоединенные файлы"/>\r\n\r\n    <item type="buttonSelect" id="bs_create_by_virtue" text="Создать" title="Создать на основании" openAll="true" >\r\n        <item type="button" id="btn_message" enabled="false" text="Сообщение" image="" />\r\n    </item>\r\n\r\n    <item type="buttonSelect" id="bs_go_to" text="Перейти" title="" openAll="true" >\r\n        <item type="button" id="btn_go_connection" enabled="false" text="Связи" />\r\n    </item>\r\n\r\n    <item type="buttonSelect" id="bs_print"         img="print.gif"         text="Печать" openAll="true">\r\n    </item>\r\n\r\n    <item type="buttonSelect"   id="bs_more"        img="tb_more_w.png"  title="Дополнительно" openAll="true">\r\n        <item type="button" id="btn_import" img="document_load.png" text="Загрузить из файла" />\r\n        <item type="button" id="btn_export" img="document_save.png" text="Выгрузить в файл" />\r\n    </item>\r\n\r\n</toolbar>\r\n',toolbar_ok_cancel:'<?xml version="1.0" encoding=\'utf-8\'?>\r\n<toolbar>\r\n    <item id="btn_ok"       type="button"   img=""  imgdis=""   text="&lt;b&gt;Ок&lt;/b&gt;"  />\r\n    <item id="btn_cancel"   type="button"	img=""  imgdis=""   text="Отмена" />\r\n</toolbar>',toolbar_selection:'<?xml version="1.0" encoding=\'utf-8\'?>\r\n<toolbar>\r\n    <item id="btn_select"   type="button"   img=""              imgdis=""               title="Выбрать элемент списка" text="&lt;b&gt;Выбрать&lt;/b&gt;"  />\r\n\r\n    <item id="sep1" type="separator"/>\r\n    <item id="btn_new"      type="button"	img="tb_new.png"	imgdis="tb_new_dis.png"	title="Создать" />\r\n    <item id="btn_edit"     type="button"	img="tb_edit.png"	imgdis="tb_edit_dis.png"	title="Изменить" />\r\n    <item id="btn_delete"   type="button"	img="tb_delete.png"	imgdis="tb_delete_dis.png"	title="Удалить" />\r\n    <item id="sep2" type="separator"/>\r\n\r\n    <item type="buttonSelect" id="bs_print" img="print.gif"     text="Печать" openAll="true" >\r\n    </item>\r\n\r\n    <item type="buttonSelect"   id="bs_more"    img="tb_more_w.png" title="Дополнительно" openAll="true">\r\n        <item id="btn_requery"  type="button"	img="refresh.png"	text="Обновить список" />\r\n    </item>\r\n\r\n</toolbar>',log:{ireg:{$log:{name:"$log",note:"",synonym:"Журнал событий",dimensions:{date:{synonym:"Дата",multiline_mode:!1,tooltip:"Время события",type:{types:["number"],digits:15,fraction_figits:0}},sequence:{synonym:"Порядок",multiline_mode:!1,tooltip:"Порядок следования",type:{types:["number"],digits:6,fraction_figits:0}}},resources:{"class":{synonym:"Класс",multiline_mode:!1,tooltip:"Класс события",type:{types:["string"],str_len:100}},note:{synonym:"Комментарий",multiline_mode:!0,tooltip:"Текст события",type:{types:["string"],str_len:0}},obj:{synonym:"Объект",tooltip:"Объект, к которому относится событие",type:{types:["string"],str_len:0}}}}}}},{},{})