dojo.provide("parus.balanceIndexConsComparationPrint");dojo.require("parus.parus8");dojo.require("parus.database");dojo.require("parus.balanceIndexConsComparation");dojo.mixin(parus,{balanceIndexConsComparationPrint:{print:function(){var j;var i;var g;var f;dojo.xhrGet({url:"../.system/session.xml",handleAs:"xml",sync:true,preventCache:true,load:function(m){if(!dojo.isIE){m.normalize()}var k=m.documentElement.getElementsByTagName("*");for(var l=0;l!=k.length;l++){if(k[l].nodeName=="query"){j=k[l].childNodes.item(0).nodeValue}else{if(k[l].nodeName=="handler"){g=k[l].childNodes.item(0).nodeValue}else{if(k[l].nodeName=="title"){f=k[l].childNodes.item(0).nodeValue}}}}return(m)}});parus.database.connected=g;document.body.style.width="260mm";document.body.insertAdjacentHTML("afterBegin","<div>Сравнение состава показателей</div>");var d=document.body.firstChild;d.style.height="auto";d.style.fontWeight="bold";d.style.fontFamily="Tahoma, Verdana, sans-serif";d.style.margin="10px";document.title=(!dojo.isIE||dojo.isIE>=10)?d.textContent:d.innerText;var c=document.body.appendChild(document.createElement("table"));c.width="100%";c.border="1";c.cellSpacing="0";var a=c.insertRow(-1);a.style.fontWeight="bold";j=dojo.fromJson(j);var h=parus.balanceIndexConsComparation.gridStore(j.comparationData);if(j.comparationData.result=="1"){a.insertCell(-1).appendChild(document.createTextNode("Разрез"+String.fromCharCode(160)+"(мнемокод)"));a.insertCell(-1).appendChild(document.createTextNode("Разрез"+String.fromCharCode(160)+"(наименование)"))}else{a.insertCell(-1).appendChild(document.createTextNode("Контрагент"+String.fromCharCode(160)+"(мнемокод)"));a.insertCell(-1).appendChild(document.createTextNode("Контрагент"+String.fromCharCode(160)+"(наименование)"))}var e=(j.comparationData.dataType=="1")?(j.comparationData.fracPart?function(m,l,k){return m?parus.parus8.formatIndexConsValue((m.toString()).split(".").join(","),j.comparationData.intPart,j.comparationData.skipUnsignificantZeroes?null:j.comparationData.fracPart):m}:parus.parus8.formatFloat):function(k){return k};dojo.forEach(j.comparationData.items,function(k){a.insertCell(-1).appendChild(document.createTextNode(parus.parus8.nodeField(k,"TITLE")))});var a=c.insertRow(-1);a.style.fontWeight="bold";var b=a.insertCell(-1);b.appendChild(document.createTextNode("Значение"+String.fromCharCode(160)+"показателя"));b.colSpan=2;dojo.forEach(j.comparationData.items,function(l){var k=a.insertCell(-1);if(j.comparationData.dataType=="1"){k.align="right"}k.appendChild(document.createTextNode(parus.parus8.nodeField(l,"VALUE")==null?"":e(parus.parus8.nodeField(l,"VALUE"))))});if(j.comparationData.dataType=="1"){var a=c.insertRow(-1);a.style.fontWeight="bold";var b=a.insertCell(-1);b.appendChild(document.createTextNode("Итог"+String.fromCharCode(160)+"по"+String.fromCharCode(160)+"составу"));b.colSpan=2;dojo.forEach(j.comparationData.items,function(l){var k=a.insertCell(-1);if(j.comparationData.dataType=="1"){k.align="right"}k.appendChild(document.createTextNode(parus.parus8.nodeField(l,"SUMMVALUE")==null?"":e(parus.parus8.nodeField(l,"SUMMVALUE"))))})}h.fetch({sort:j.order,query:j.conditions,onItem:function(k){var l=c.insertRow(-1);l.insertCell(-1).appendChild(document.createTextNode(parus.parus8.nodeField(k,"CODE")||String.fromCharCode(160)));l.insertCell(-1).appendChild(document.createTextNode(parus.parus8.nodeField(k,"NAME")||String.fromCharCode(160)));dojo.forEach(j.comparationData.items,function(n){var m=l.insertCell(-1);if(j.comparationData.dataType=="1"){m.align="right"}v=parus.parus8.nodeField(k,n.ID);m.appendChild(document.createTextNode(v==null?"":e(v)))})}})}}});