/* exported gwork JSRepDrawDocumentViewProvider convertPxToString setCurrentDateTime getFieldsList getFieldsObjList getFieldsDescMap ToStringHTML b64toBlob generateBarcode _DrawDocumentViewProvider getBlob */ /* global gwork ArrayBuffer _srepFonts jspdffontMap getFromDesignObj blankJsonItem */ /* inclusione js nei portlet jsp/SPSmartReportPrint,jsp-system/SPPortalZoomSmartPrint,smartreport/smartreport.jsp smartreport/promise-ie-polyfill.js visualweb/jszip.js visualweb/xlsx.js visualweb/jspdf.js --> spostata inclusione in jsrepdocPDF visualweb/jspdf-more.js --> spostata inclusione in jsrepdocPDF visualweb/bcmath-min.js visualweb/pdf417.js visualweb/JsBarcode.all.js visualweb/qrcode2.js visualweb/html2canvas.js */ var docSettings = { A0:{w:"2383pt",h:"3370pt"}, A1:{w:"1683pt",h:"2383pt"}, A2:{w:"1190pt",h:"1683pt"}, A3:{w:"842pt",h:"1190pt"}, A4:{w:"595pt",h:"842pt"}, A5:{w:"419pt",h:"595pt"}, A6:{w:"297pt",h:"419pt"}, A7:{w:"209pt",h:"297pt"}, A8:{w:"147pt",h:"209pt"}, A9:{w:"104pt",h:"147pt"}, A10:{w:"73pt",h:"104pt"}, letter:{w:"612pt",h:"792pt"}, legal:{w:"612pt",h:"1008pt"}, tabloid:{w:"792pt",h:"1224pt"} }; function RepDocument(){ this.gwork = {}; this.propertyValue = []; this.allfields = []; this.mrows = 0; this.obj = {}; this.calcObjs = { sum: {}, count: {} }; this.lastRec = null; this.lastRecIndex = 0//-1; this.loadingDiv = null; this.container = null; this.lastGrpFooter = false; this.end = false; this.rootApp = "../"; this.rootAppB = "..\\"; this.imgfields = []; this.imgMap = []; this.optMapImg = []; this.mImages = 0; this.imgSrc = []; this.imgCount = 0; this.havnext = true; this.simulatedData = false; this.grpBreak = false; this.autoprint = false; this.autodownload = false; this.errorMessages = { JSVRP_NODATA: "RPT_ERROR_NO_RECORD", JSVRP_PRINTERR: "RPT_ERROR_GENERIC", JSVRP_NOTFDATAS: "RPT_ERROR_NOTFOUND_FIELD" }; this.listMissingFields = []; this.rowsCounter = 0; this.limitDataPreview = 5; this.watermark = ""; this.license = ""; this.watermarkIsImage = false; this.managed = false; this.checkedSrc = "../smartreport/images/checked.png"; this.uncheckedSrc = "../smartreport/images/unchecked.png" } RepDocument.prototype.beforeProcess = function(allfields,container,bprint,imgfields,simulatedData) { this.getAllFonts(); this.initProcess(allfields,container,bprint,imgfields,simulatedData); this.appendFontsInDocument(); } RepDocument.prototype.getAllFonts = function () { var list = getFontsFromObj(this.obj); if (window._fontMap) { var fkeys = Object.keys(window._fontMap), olist = fkeys.filter(function (font) { var tmpname = window._fontMap[font].name; if (window._fontMap[font].style != "normal") { if (window._fontMap[font].style == "bolditalic") tmpname += "_bold_italic"; else tmpname += ("_" + window._fontMap[font].style); } return (list.indexOf(tmpname) >= 0); }); this._fontList = olist; } } RepDocument.prototype.initPage = function(/*coverobj*/) { } RepDocument.prototype.addLicense = function() { if (Empty(this.license)) return; this.addCurrentZone({height:this.gwork.hh}, "license", this.gwork.rpagecounter) var item = {}; item.uid = "sreport_license"; item.type = "label"; item.typeView = "text"; item.value = this.license; item.position = {}; item.position.x = 0; item.position.height = 6*96/72; item.position.y = this.gwork.hh - ((this.getLastChildElement() ? this.getLastChildElement().top : 0) + this.gwork.margint) - item.position.height - this.gwork.marginb; item.position.yRelative = item.position.y; item.position.width = this.gwork.ww; item.style = {}; item.style.font = {}; item.style.font.fontName = 'Helvetica'; item.style.font.fontSize = '6pt'; item.style.font.center = true; item.style.font.fontColor = "#000000"; this.addItemInZone(null, item, "", "", this.license, item.position.y); } RepDocument.prototype.drawCover = function(coverobj){ if(!coverobj || Empty(coverobj) || coverobj==null) return; if(!coverobj.coverPrint) return; if(!coverobj.objString || Empty(coverobj.objString) || coverobj.objString == null) return; try { var ypos = 20; // 40px var flist = JSON.parse(coverobj.objString); if(flist.length < 1) return; var firsty = -1; var lastzoomY = -1; var zoomX = 0; var c = 1; this.initPage(coverobj); this.addCurrentZone({height:this.gwork.hh}, "cover", c) c++; for(var k=0; k= 0) { if (y == lastzoomY) { zoomX += obj.w; } } if (obj.h <= 0 || obj.w <= 0) { continue; } if ( y == lastzoomY){ x -= zoomX; } item.position.x = x; item.position.y = y + ypos - firsty; item.typeView = 'label'; if(item.position.y + item.position.height > this.gwork.limitpage) { this.newPage(); if(!coverobj.numPageCover) this.gwork.pagecounter--; this.addCurrentZone({height:0}, "cover", c) c++; firsty = y; item.position.y = y + ypos - firsty; } item.style = {}; item.style.font = {}; item.style.font.fontName = obj.font; item.style.font.fontSize = obj.fontSize; if ( type == 'check') { if(value == 'true') value = 'X'; else value = ''; } if( obj.align ) { if( obj.align == 'right' ) item.style.font.right = true; else item.style.font.right = false; if( obj.align == 'center' ) item.style.font.center = true; else item.style.font.center = false; } if ( type == 'label') item.style.font.italic = true; else item.style.font.italic = false; if ( type == 'group' ) item.style.font.bold = true; else item.style.font.bold = false; item.style.font.underline = false; item.style.font.strikeout = false; item.style.font.fontColor = "#000000"; item.fieldDetail = {}; item.fieldDetail.desc = value; this.addItemInZone(k,item,"","",value,ypos+item.position.y); var iteml, dims, xl, yl; if ( type == 'group' ) { iteml = {}; iteml.position = {}; dims = this.getTextDimensions(value, { name : item.style.font.fontName , size : item.style.font.fontSize , weight : item.style.font.bold ? 'bold' : 'normal' , italic : item.style.font.italic ? 'italic' : 'normal' }); xl = item.position.x + dims.width + 10; yl = item.position.y + dims.height/2 + 1; iteml.position.x = xl; iteml.position.y = yl; iteml.position.height = 1; iteml.typeView = 'line'; iteml.type = 'line'; iteml.style = item.style; iteml.style.line = {}; iteml.style.line.color = "#000000" var nl = this.gwork.ww - this.gwork.marginl - this.gwork.marginr - iteml.position.x; iteml.position.width = nl; iteml.fieldDetail = {}; iteml.fieldDetail.desc = value; this.addItemInZone(k,iteml,"","","",ypos+iteml.position.y); } else if( type == 'check' ) { iteml = {}; iteml.position = {}; dims = this.getTextDimensions('X', { name : item.style.font.fontName , size : item.style.font.fontSize , weight : item.style.font.bold ? 'bold' : 'normal' , italic : item.style.font.italic ? 'italic' : 'normal' }); xl = item.position.x; yl = item.position.y; iteml.position.x = xl; iteml.position.y = yl; iteml.position.height = dims.height; iteml.position.width = dims.width; iteml.typeView = 'line'; iteml.type = 'line'; iteml.style = item.style; iteml.style.line = {}; iteml.style.line.color = "#000000" iteml.style.line.onlyStroke = true; iteml.fieldDetail = {}; iteml.fieldDetail.desc = value; this.addItemInZone(k,iteml,"","","",ypos+iteml.position.y); } } this.newPage(); if(!coverobj.numPageCover) this.gwork.pagecounter--; } catch (e) { console.error(e.stack); } }; RepDocument.prototype.setGWork = function(obj){ var w, h; if(docSettings && docSettings[obj.page.format]){ w = docSettings[obj.page.format].w; h = docSettings[obj.page.format].h; } else{ if(obj.page.format == 'custom') { w = obj.page.width + "mm" h = obj.page.height + "mm" } else if(window.jsPDFPageFormats && window.jsPDFPageFormats[obj.page.format]){ w = window.jsPDFPageFormats[obj.page.format][0]+"pt"; h = window.jsPDFPageFormats[obj.page.format][1]+"pt"; } else { //A4 w = '595pt'; h = '842pt'; } } var tmp; this.gwork={}; if(obj.page.orientation=="landscape"){ tmp = w; w = h; h = tmp; } this.gwork.ww = convertStringToPx(w); this.gwork.hh = convertStringToPx(h); this.gwork.marginr = convertStringToPx(obj.page.margins.right,this.gwork.ww); this.gwork.marginl = convertStringToPx(obj.page.margins.left,this.gwork.ww); this.gwork.margint = convertStringToPx(obj.page.margins.top,this.gwork.hh); this.gwork.marginb = convertStringToPx(obj.page.margins.bottom,this.gwork.hh); this.obj = obj; var zones = []; if(this.obj.showGroupZone) zones.push('groupfooter'); if(this.obj.showPageZone) zones.push('pagefooter'); if(this.obj.showReportZone) zones.push('reportfooter'); //calcobjs - only footer for (var l = 0; l < zones.length; l++) { var melements = getZoneElementsType(obj, zones[l], 'field'); for (var k = 0; k < melements.length; k++) { if (melements[k].calculation && !Empty(melements[k].calculation.type) && melements[k].calculation.type != 'none') { if (Empty(this.calcObjs[melements[k].calculation.type][melements[k].fieldDetail.alias])) this.calcObjs[melements[k].calculation.type][melements[k].fieldDetail.alias] = {}; this.calcObjs[melements[k].calculation.type][melements[k].fieldDetail.alias][melements[k].uid] = 0; } } } return this.gwork; }; RepDocument.prototype.setLimitPage = function(){ this.gwork.limitpage = (this.gwork.hh-this.gwork.marginb); if(this.obj.showGroupZone) if(this.obj.groupfooter.options.reprintOnPage) this.gwork.limitpage = this.gwork.limitpage - this.obj.groupfooter.height; if(this.obj.showPageZone) this.gwork.limitpage = this.gwork.limitpage - this.obj.pagefooter.height; if(!Empty(this.license)) { var dims = this.getTextDimensions(this.license, { name : 'Helvetica' , size : '6pt' , weight : 'normal' , italic : 'normal' }); this.gwork.limitpage = this.gwork.limitpage - dims.height; } }; RepDocument.prototype.newPage = function(k,firstpage){ if (this.isEoPreview()) return; if (Empty(firstpage)) { if(this.obj.showPageZone && k) this.drawZone(k,'pagefooter','',false,true); this.pageNumber(); this.drawPreviewValidator(); this.addLicense(); this.gwork.pagecounter++; this.gwork.rpagecounter++; } if (this.isEoPreview()) return; this.drawNewPage(firstpage); if(Empty(firstpage)) if(this.obj.showPageZone && k) this.drawZone(k,'pageheader','',false); }; RepDocument.prototype.getZoneElementsYMap=function(items){ var ret = {}; var item; for(var k=0;k '2pt' * '2' -> '2px' * 2 -> '2px' * '2','pt' -> '2pt' * 2 ,'pt' -> '2pt' * '2pt','px' -> '2pt' */ var matches = ( '' + size ).match( /(-?\d+(?:\.\d*)?)(.*)/ ) || [ null, null, null ] , val = parseInt( matches[1], 10) || 0 ; um = matches[2] || um || 'px'; return val + um; } // cssSize /*http://stackoverflow.com/questions/118241/calculate-text-width-with-javascript*/ var id = 'smartreportpdftxtmeter' , el = document.getElementById( id ) ; if ( !el ) { el = document.createElement( id ); el.id = id; el.style.display = 'inline-block'; el.style.position = 'absolute'; el.style.whiteSpace = 'pre'; /*mantiene whiteSpace*/ el.style.visibility = 'hidden'; el.style.height = 'auto'; el.style.width = 'auto'; document.body.appendChild( el ); } el.textContent = text; el.style.fontFamily = font.name; el.style.fontStyle = font.style; el.style.fontWeight = font.weight; el.style.fontSize = cssSize( font.size, 'px' ); return { width : el.clientWidth /*px*/ , height: el.clientHeight /*px*/ } ; }; RepDocument.prototype.splitString = function(value, font, width, gap){ var mvalue = value; var p = value.length; if(p-gap <=0) return value; value = value.substring(0, p-gap); var dim = this.getTextDimensions(value, { name : font.fontName , size : font.fontSize , weight : font.bold ? 'bold' : 'normal' , italic : font.italic ? 'italic' : 'normal' }); if(dim.width<=width) return value; gap = gap + dim.width/width; return this.splitString (mvalue, font, width, gap); } RepDocument.prototype.drawZone = function(k,zoneid,numrec,check,useLastRecord){ if (this.isEoPreview()) return; if(typeof(numrec) == 'undefined') numrec = ''; if(typeof(check) == 'undefined') check = true; var objzone = this.obj[zoneid]; var lc = this.getLastChildElement(); if(!Empty(lc) && check){ if(this.checkLimitPage(lc,objzone)){ this.drawZoneGroupFooter(this.lastRecIndex,lc,false); this.newPage(k); if(this.obj.showGroupZone) if(this.obj.groupheader.options.reprintOnPage) this.drawZone(k,'groupheader','',false); } } if (this.isEoPreview()) return; this.addCurrentZone(objzone,zoneid,numrec); var delta = 0; if(objzone.items.length>0){ //strecth var zoneYMap = this.getZoneElementsYMap(objzone.items); var items; var value; var item; var zoneKeys = Object.keys(zoneYMap); zoneKeys.sort(function(a,b){ return a-b;}); var key = "", x, j, jj, ii, yRel; for(ii=0; ii 0) { var vori = value, valuev = this.splitString(vori, item.style.font, item.position.width, 0), isArray = Array.isArray(valuev), p = valuev.length; if (isArray && p > 0) { msobj.strings = msobj.strings.concat(valuev); value = ""; } else { value = vori.substring(p); if (valuev.length === 0) { msobj.strings.push(value); value = ""; } else msobj.strings.push(valuev); } } } stretchobj.push(msobj); maxrows = Math.max(maxrows, msobj.strings.length); } else{ yRel = item.position.yRelative + delta; this.addItemInZone(k,item,objzone,zoneid,value,yRel); } } //print stretch var xprog = 0; for(x=0; xthis.gwork.limitpage)){ for(jj=0; jjthis.gwork.limitpage); } RepDocument.prototype.splitStringCheck = function(check,item,value){ if(/*!check || */(item.type!='field' && !item.titleStretch) || (item.fieldDetail && item.fieldDetail.type!='M' && item.fieldDetail.type!='C') || Empty(value)) return false; if (item.typeView != 'text') return false; var nlcr = new RegExp('\\r|\\n','g'); var font = { name : item.style.font.fontName , size : item.style.font.fontSize , weight : item.style.font.bold ? 'bold' : 'normal' , italic : item.style.font.italic ? 'italic' : 'normal' }; return (value.search(nlcr)>=0 || this.getTextDimensions(value, font).width>item.position.width); } RepDocument.prototype.drawZoneGroupFooter = function(k,lc,breakg){ if (this.isEoPreview()) return; var p = this.gwork.limitpage-(this.gwork.margint+lc.top+lc.height); this.obj.emptyzone = {}; this.obj.emptyzone.items = []; this.obj.emptyzone.height = p; if(this.obj.showGroupZone){ var check = false; if (!this.obj.groupfooter.options.reprintOnPage && !this.obj.groupfooter.options.atEndOfPage) check = true; if (breakg) { var lm = this.gwork.limitpage; // aggiungo x valutazione ev. salto pagina if (this.obj.groupfooter.options.reprintOnPage && this.lastGrpFooter) lm = lm + this.obj.groupfooter.height; // altezza di pagina e di gruppo diverse if (!this.obj.groupfooter.options.reprintOnPage && this.obj.groupfooter.options.atEndOfPage) lm = lm - this.obj.groupfooter.height; if (this.gwork.margint + this.obj.groupfooter.height + lc.top + lc.height > lm) { lm = lm + this.obj.groupfooter.height; if (this.obj.groupfooter.options.reprintOnPage && this.lastGrpFooter) lm = lm - this.obj.groupfooter.height; p = lm-(this.gwork.margint+lc.top+lc.height); this.obj.emptyzone.height = p; this.drawZone(k,'emptyzone',this.gwork.rpagecounter,false); this.newPage(k); if(this.obj.showGroupZone) if(this.obj.groupheader.options.reprintOnPage) this.drawZone(k,'groupheader','',check); lc = this.getLastChildElement(); lm = this.gwork.limitpage; if(this.obj.groupfooter.options.atEndOfPage){ lm = lm - this.obj.groupfooter.height; p = lm-(this.gwork.margint+lc.top+lc.height); this.obj.emptyzone.height = p; this.drawZone(k,'emptyzone',this.gwork.rpagecounter,false); this.drawZone(k,'groupfooter','',check); } else{ this.drawZone(k,'groupfooter','',check); } } else{ if (this.obj.groupfooter.options.reprintOnPage && this.lastGrpFooter) lm = lm - this.obj.groupfooter.height; if(this.obj.groupfooter.options.atEndOfPage){ p = lm-(this.gwork.margint+lc.top+lc.height); this.obj.emptyzone.height = p; this.drawZone(k,'emptyzone',this.gwork.rpagecounter,false); this.drawZone(k,'groupfooter','',check); } else this.drawZone(k,'groupfooter','',check); } } else if (this.obj.groupfooter.options.reprintOnPage || (this.lastGrpFooter && !this.obj.groupfooter.options.reprintOnPage)) { if(this.obj.groupfooter.options.atEndOfPage) { this.drawZone(k,'emptyzone',this.gwork.rpagecounter,false); this.drawZone(k,'groupfooter','',check); } else{ this.drawZone(k,'groupfooter','',check); lc = this.getLastChildElement(); p = this.gwork.limitpage-(this.gwork.margint+lc.top); this.obj.emptyzone.height = p; this.drawZone(k,'emptyzone',this.gwork.rpagecounter,false); } } else this.drawZone(k,'emptyzone',this.gwork.rpagecounter,false); } else this.drawZone(k,'emptyzone',this.gwork.rpagecounter,false); delete this.obj.emptyzone; }; RepDocument.prototype.isEof = function(){ if (this.offline) { if (this.datasource.Eof()) { return true; } if (this.isPreview && this.rowsCounter >= 200) { return true } if (!this.isPreview && this.rowsCounter >= 1500) { return true; } } else { if (this.isPreview && this.rowsCounter >= 200) { this.end = true; return true } } return false; } RepDocument.prototype.isEoPreview = function () { if (this.isPreview) { if (this.gwork.rpagecounter > this.limitDataPreview || this.gwork.pagecounter > this.limitDataPreview) { if (this.gwork.rpagecounter > this.limitDataPreview) this.gwork.rpagecounter --; return true; } } return false; } RepDocument.prototype.paramUpdated = function(){ var tmpdata = []; var i = this.datasource.getGlobalCurRec(); var j; tmpdata[i]={}; for(j=0; j 0 && j < this.allfields.length - 1) { //ultima colonna grid sempre stampata if (this.propertyValue[i-1]) { var isDate = (IsA(this.propertyValue[i-1][field + "-bck"], 'T') && IsA(this.propertyValue[i][field + "-bck"], 'T')); if (isDate) { if (Empty(this.pictureMap) || Empty(this.pictureMap[field])) { if ((this.propertyValue[i-1][field + "-bck"]).getTime() == (this.propertyValue[i][field + "-bck"]).getTime()) this.propertyValue[i][field] = ""; else checkGroupR = false; } else { var dateCur = FormatDateTime(this.propertyValue[i][field + "-bck"], this.pictureMap[field]), datePrec = FormatDateTime(this.propertyValue[i-1][field + "-bck"], this.pictureMap[field]); if (datePrec == dateCur) this.propertyValue[i][field] = ""; else checkGroupR = false; } } else { if ((!Empty(this.propertyValue[i-1][field + "-bck"]) || this.propertyValue[i-1][field + "-bck"] == 0) && this.propertyValue[i-1][field + "-bck"] == this.propertyValue[i][field + "-bck"]) // eslint-disable-line max-len this.propertyValue[i][field] = ""; else checkGroupR = false; } } } } } if(Empty(this.listMissingFields) || this.listMissingFields.length == 0) this.exec(this.propertyValue[i], i); this.rowsCounter ++; } } function evaluateFieldValue(txt, idx, datasource) { // ripresa da ZtVWeb.fmtPctFldPct var nflist = [], notfound = false, txt_par = txt.split('%'); for (var fldname, fldval, i = 1, l = txt_par.length; i < l;) { notfound = false; fldname = txt_par[i]; fldval = datasource && datasource.hasField(fldname) ? datasource.getStr(idx, fldname) : (function() { notfound = true; return ""; }()); fldval = Trim(fldval.toString()); if (!notfound) { txt = Strtran(txt, '%' + fldname + '%', fldval); i += 2; } else { nflist.push(fldname); i++; } } return { value : txt, nflist : nflist }; } RepDocument.prototype.UpdateCurRec = function(datasource){ this.FillData(datasource); } RepDocument.prototype.exec = function(record,k){ if (this.isEoPreview()) { // e' sicuro la preview edt this.rowsCounter = 200; return; } if(this.mrows===0){ this.lastGrpFooter = false; this.grpBreak = false; this.newPage(this.mrows,true); if(this.obj.showReportZone){ if(this.obj.reportheader.options.afterPageHeader){ if(this.obj.showPageZone) this.drawZone(k,'pageheader'); this.drawZone(k,'reportheader'); } else{ this.drawZone(k,'reportheader'); if(this.obj.showPageZone) this.drawZone(k,'pageheader'); } } else if(this.obj.showPageZone) this.drawZone(k,'pageheader'); if(this.obj.showGroupZone) this.drawZone(k,'groupheader'); } else if(startNewGroup(record,this.obj,this.lastRec)){ this.lastGrpFooter = true; this.drawZoneGroupFooter(this.lastRecIndex,this.getLastChildElement(),true); if(startNewPage(this.obj)) this.newPage(k); this.grpBreak = true; if(this.obj.showGroupZone) this.drawZone(k,'groupheader'); var zones = []; if(this.obj.showGroupZone) zones.push('groupfooter'); if(this.obj.showPageZone) zones.push('pagefooter'); if(this.obj.showReportZone) zones.push('reportfooter'); //calcobjs - only footer for (var l = 0; l < zones.length; l++) { var melements = getZoneElementsType(this.obj, zones[l], 'field'); for (var kk = 0; kk < melements.length; kk++) { if (melements[kk].calculation && !Empty(melements[kk].calculation.type) && melements[kk].calculation.type != 'none' && melements[kk].calculation.byGroup) { this.calcObjs[melements[kk].calculation.type][melements[kk].fieldDetail.alias][melements[kk].uid] = 0; } } } this.lastGrpFooter = false; this.grpBreak = false; } this.drawZone(k, 'groupbody', this.mrows); this.mrows = this.mrows + 1; var key, uid; for (key in this.calcObjs.sum) { for (uid in this.calcObjs.sum[key]) { this.calcObjs.sum[key][uid] = this.calcObjs.sum[key][uid] + record[key]; } } for (key in this.calcObjs.count) { for (uid in this.calcObjs.count[key]) { this.calcObjs.count[key][uid] = this.calcObjs.count[key][uid] + 1; } } this.lastRec = record; this.lastRecIndex = k; }; RepDocument.prototype.startLoading = function(){ this.loadingDiv = this.document.createElement("div"); this.loadingDiv.id = this.container.id + "_loading"; /* this.loadingDiv.style.width = "100%"; this.loadingDiv.style.height = this.container.offsetHeight+"px"; this.loadingDiv.style.zIndex = 1500; this.loadingDiv.style.backgroundColor = "#F3F3F3"; this.loadingDiv.style.opacity = 0.5; this.loadingDiv.textContent = 'loading...';*/ this.loadingDiv.style.width = "100%"; this.loadingDiv.style.height = "100%"; this.loadingDiv.style.position = "absolute"; this.loadingDiv.style.zIndex = 2000; this.loadingDiv.style.backgroundColor = "#FFFFFF"; this.loadingDiv.style.display = "block"; this.loadingDiv.style.opacity = 1; this.loadingDiv.className = "spModalLayer loading"; this.parent.appendChild(this.loadingDiv); }; RepDocument.prototype.updateLoading = function(){ if(this.loadingDiv !== null) this.loadingDiv.style.height = this.loadingDiv.parentNode.offsetHeight+"px"; }; RepDocument.prototype.removeLoading = function(){ if(this.loadingDiv || ( this.loadingDiv = this.document.getElementById(this.container.id+"_loading"))){ if (!Empty(this.loadingDiv.parentNode)) this.loadingDiv.parentNode.removeChild(this.loadingDiv); else this.loadingDiv.remove(); this.loadingDiv = null; } }; RepDocument.prototype.setParent = function( _parent ){ this.parent = ( _parent ? _parent : ( this.container.tagName.toLowerCase() == "iframe" ? this.container.contentWindow.document.body : this.container ) ); }; RepDocument.prototype.setDocument = function( _document ){ this.document = ( _document ? _document : ( this.container.tagName.toLowerCase() == "iframe" ? this.container.contentWindow.document : document ) ); }; RepDocument.prototype.setWindow = function( _window ){ this.window = ( _window ? _window : ( this.container.tagName.toLowerCase() == "iframe" ? this.container.contentWindow : window ) ); }; RepDocument.prototype.setIFrame = function (w, h) { if (document.getElementById(this.container.id + "ifrprev")) return; var ifr = document.createElement("IFRAME"); ifr.id = this.container.id + "ifrprev"; ifr.name = this.container.id + "ifrprev"; ifr.frameBorder = 0; ifr.allowTransparency = true; ifr.style.border = 0; if (Empty(w)) ifr.width = "100%"//this.container.offsetWidth; else ifr.width = w; if (Empty(h)) ifr.height = "100%";//this.container.offsetHeight; else ifr.height = h; ifr.style.display = "block"; this.container.appendChild(ifr); }; RepDocument.prototype.download = function () { }; RepDocument.prototype.setFormatNumber = function (val,len,dec,pict) { var ret = ""; dec = parseInt(dec); if(!Empty(pict)){ ret = Format(val,len,dec,pict); return ret; } pict = "999999999"; if(dec!==0) ret = Format(val,len,dec,pict+"." + Replicate("9",dec)); else ret = Format(val,len,dec,pict); return ret; }; RepDocument.prototype.preloadImagesOFFLINE = function(repobj){ var myimg,msrc,i; var allsrc = repobj.imgSrc.concat(repobj.imgfields.generic); // immagini per checkbox allsrc = allsrc.concat([repobj.checkedSrc, repobj.uncheckedSrc]); var newImages = []; for(i=0; i0 && currimg==totimg && !repobj.end && repobj.isEof()) repobj.documentExecOFFLINE(repobj); if (repobj.end && repobj.format == "IARViewer" && window.navigator.userAgent.match( /zRuntime/ )) { repobj.view(repobj.fncCallBack); } if(repobj.fncCallBack && !Empty(repobj.args) && repobj.end && repobj.execCallback){ repobj.args.push(repobj); repobj.fncCallBack.apply(null,repobj.args); repobj.execCallback = false; } } RepDocument.prototype.documentExecOFFLINE = function(repobj){ if (repobj.end) return; repobj.totalNRecords = repobj.propertyValue.length; while (repobj.propertyValue.length > 1) { repobj.exec(repobj.propertyValue[0],0); repobj.propertyValue.splice(0,1); if (repobj.isEoPreview()) repobj.propertyValue = []; } if (!repobj.isEoPreview()) { repobj.exec(repobj.propertyValue[0],0); repobj.lastGrpFooter = true; repobj.drawZoneGroupFooter(repobj.propertyValue.length-1,repobj.getLastChildElement(), true); // lo tratto come rottura di gruppo perche' e' l'ultimo var p, lc = repobj.getLastChildElement(); if(repobj.obj.showGroupZone) if(repobj.obj.groupfooter.options.reprintOnPage) repobj.gwork.limitpage = repobj.gwork.limitpage + repobj.obj.groupfooter.height; if(repobj.obj.showReportZone && repobj.obj.reportfooter.items.length>0){ if(repobj.obj.reportfooter.options.beforePageFooter){ var zoneid = 'reportfooter'; if(repobj.gwork.margint+repobj.obj[zoneid].height+lc.top+lc.height>repobj.gwork.limitpage){ p = repobj.gwork.limitpage-(repobj.gwork.margint+lc.top+lc.height); repobj.obj.emptyzone = {}; repobj.obj.emptyzone.items = []; repobj.obj.emptyzone.height = p; repobj.drawZone(repobj.propertyValue.length-1,'emptyzone',repobj.gwork.rpagecounter,false); repobj.newPage(repobj.propertyValue.length-1); } repobj.drawZone(repobj.propertyValue.length-1,'reportfooter','',false); if(repobj.obj.showPageZone){ lc = repobj.getLastChildElement(); p = repobj.gwork.limitpage-(repobj.gwork.margint+lc.top+lc.height); repobj.obj.emptyzone = {}; repobj.obj.emptyzone.items = []; repobj.obj.emptyzone.height = p; repobj.drawZone(repobj.propertyValue.length-1,'emptyzone',repobj.gwork.rpagecounter,false); repobj.drawZone(repobj.propertyValue.length-1,'pagefooter','',false); } } else{ if(repobj.obj.showPageZone){ p = repobj.gwork.limitpage-(repobj.gwork.margint+lc.top+lc.height); repobj.obj.emptyzone = {}; repobj.obj.emptyzone.items = []; repobj.obj.emptyzone.height = p; repobj.drawZone(repobj.propertyValue.length-1,'emptyzone',repobj.gwork.rpagecounter,false); repobj.newPage(repobj.propertyValue.length-1); } repobj.drawZone(repobj.propertyValue.length-1,'reportfooter','',false); } } else if(repobj.obj.showPageZone){ p = repobj.gwork.limitpage-(repobj.gwork.margint+lc.top+lc.height); repobj.obj.emptyzone = {}; repobj.obj.emptyzone.items = []; repobj.obj.emptyzone.height = p; repobj.drawZone(repobj.propertyValue.length-1,'emptyzone',repobj.gwork.rpagecounter,false); repobj.drawZone(repobj.propertyValue.length-1,'pagefooter','',false); } repobj.pageNumber(); repobj.drawPreviewValidator(); repobj.removeLastLabelContinue(); repobj.addLicense(); } repobj.removeLastLabelContinue(); repobj._dontruncb = true; repobj.endProcess(); delete repobj.obj.emptyzone; repobj.propertyValue.splice(0,1); } RepDocument.prototype.documentExec = function () { this.lastGrpFooter = true; this.drawZoneGroupFooter(this.lastRecIndex, this.getLastChildElement(), true); // lo tratto come rottura di gruppo perche' e' l'ultimo var p, lc = this.getLastChildElement(); if (this.obj.showGroupZone) if (this.obj.groupfooter.options.reprintOnPage) this.gwork.limitpage = this.gwork.limitpage + this.obj.groupfooter.height; if (this.obj.showReportZone && this.obj.reportfooter.items.length > 0) { if(this.obj.reportfooter.options.beforePageFooter){ var zoneid = 'reportfooter'; if(this.gwork.margint+this.obj[zoneid].height+lc.top+lc.height>this.gwork.limitpage){ p = this.gwork.limitpage-(this.gwork.margint+lc.top+lc.height); this.obj.emptyzone = {}; this.obj.emptyzone.items = []; this.obj.emptyzone.height = p; this.drawZone(this.lastRecIndex,'emptyzone',this.gwork.rpagecounter,false); this.newPage(this.lastRecIndex); } this.drawZone(this.lastRecIndex,'reportfooter','',false); if(this.obj.showPageZone){ lc = this.getLastChildElement(); p = this.gwork.limitpage-(this.gwork.margint+lc.top+lc.height); this.obj.emptyzone = {}; this.obj.emptyzone.items = []; this.obj.emptyzone.height = p; this.drawZone(this.lastRecIndex,'emptyzone',this.gwork.rpagecounter,false); this.drawZone(this.lastRecIndex,'pagefooter','',false); } } else{ if(this.obj.showPageZone){ p = this.gwork.limitpage-(this.gwork.margint+lc.top+lc.height); this.obj.emptyzone = {}; this.obj.emptyzone.items = []; this.obj.emptyzone.height = p; this.drawZone(this.lastRecIndex,'emptyzone',this.gwork.rpagecounter,false); this.newPage(this.lastRecIndex); } this.drawZone(this.lastRecIndex,'reportfooter','',false); } } else if(this.obj.showPageZone){ p = this.gwork.limitpage-(this.gwork.margint+lc.top+lc.height); this.obj.emptyzone = {}; this.obj.emptyzone.items = []; this.obj.emptyzone.height = p; this.drawZone(this.lastRecIndex,'emptyzone',this.gwork.rpagecounter,false); this.drawZone(this.lastRecIndex,'pagefooter','',false); } this.pageNumber(); this.drawPreviewValidator(); this.removeLastLabelContinue(); this.addLicense(); // solo pdf images var _this = this; setTimeout( function () { _this.checkImages(); }, 0); this.managed = true; } RepDocument.prototype.checkImages = function () { this.endProcess(); delete this.obj.emptyzone; } RepDocument.prototype.renderHTMLtoCanvas = function (item, value, ctrlid) { var doc = document, mdiv = doc.createElement("div"), id = ctrlid + "_canvimg"; if (!Empty(doc.getElementById(id))) mdiv = doc.getElementById(id); else { mdiv.id = id; mdiv.className = "__canvimg"; mdiv.innerHTML = value; mdiv.style.position = "absolute"; mdiv.style.top = "0px"; mdiv.style.left = "0px"; mdiv.style.width = item.position.width + "px"; mdiv.style.height = item.position.height + "px"; doc.body.appendChild(mdiv); } if (typeof html2canvas !== 'undefined') { html2canvas(mdiv, { onrendered : function (newCanvas) { doc.getElementById(Strtran(id, "_canvimg", "") + "_img").src = newCanvas.toDataURL('image/png'); doc.getElementById(id).parentNode.removeChild(doc.getElementById(id)); }, width: item.position.width, height: item.position.height }); } } RepDocument.prototype.removeCanvasImages = function () { var imgs = document.getElementsByClassName("__canvimg"); for (var i = imgs.length - 1; i >= 0; i--) { var par = imgs[i].parentNode; if (par) par.removeChild(imgs[i]); } } RepDocument.prototype.execFncCallback = function () { if (this.fncCallBack && !Empty(this.args) && this.end && this.execCallback) { if (this.format != "IARViewer"){ this.args.push(this); this.fncCallBack.apply(null, this.args); } this.execCallback = false; } } /********** FUNZIONI COMUNI **********/ function JSRepDrawDocumentViewProvider(obj, format, SdataProvider, container, dwnlName, actionObj, isSimulatedData, fncCallBack, isPreview, offline) { if (format.toLowerCase() == "iarviewer") { format = 'IARViewer'; } if (offline === undefined) offline = true; if (offline) { JSRepDrawDocumentViewProviderOFFLINE(obj, format, SdataProvider, container, dwnlName, actionObj, isSimulatedData, fncCallBack, isPreview); return; } if (window._fontsDone) _DrawDocumentViewProvider(obj, format, SdataProvider, container, dwnlName, actionObj, isSimulatedData, fncCallBack, isPreview); else { window._tmpArgs = [obj, format, SdataProvider, container, dwnlName, actionObj, isSimulatedData, fncCallBack, isPreview]; preloadFonts(); } } function preloadFonts() { if (typeof ZtVWeb != "undefined") { var rootFonts = ZtVWeb.SPWebRootURL + "/fonts", xhr, blob, path, count = 0; for (var i = 0; i < _srepFonts.length; i++) { path = rootFonts + "/" + _srepFonts[i][0] + "/" + _srepFonts[i][1]; xhr = new XMLHttpRequest(); xhr.open('GET', path + ".ttf", true); xhr.responseType = 'blob'; xhr.onload = function (/*e*/) { if (this.status == 200) { blob = this.response; if (!(_srepFonts[this.__index][1] in jspdffontMap)) { jspdffontMap[_srepFonts[this.__index][1]] = {}; jspdffontMap[_srepFonts[this.__index][1]].blob = blob; } count++; if (count == _srepFonts.length) loadBlobs(); } }; xhr.__index = i; xhr.send(); } } } function loadBlobs() { var fblob, count = 0, fileReader; for (var i = 0; i < _srepFonts.length; i++) { fblob = jspdffontMap[_srepFonts[i][1]].blob; try { fileReader = new FileReader(); fileReader.__index = i; fileReader.onload = function (e) { var filecontent = e.target.result; filecontent = filecontent.substr(filecontent.indexOf('base64,') + 7); if (jspdffontMap[_srepFonts[this.__index][1]]) { jspdffontMap[_srepFonts[this.__index][1]].cont = filecontent; jspdffontMap[_srepFonts[this.__index][1]].name = _srepFonts[this.__index][2]; jspdffontMap[_srepFonts[this.__index][1]].style = _srepFonts[this.__index][3]; jspdffontMap[_srepFonts[this.__index][1]].css = Strtran(_srepFonts[this.__index][0], "_", ""); } count++; if (count == _srepFonts.length) { window._fontsDone = true; if (window._tmpArgs) _DrawDocumentViewProvider.apply(this, window._tmpArgs); } }; fileReader.readAsDataURL(fblob); } catch (e) { console.log("error in file reader"); } } } function mergeDeep (o1, o2) { var tempNewObj = o1; if(o1==null) return o2; //if o1 is an object - {} if(o1.length === undefined && typeof o1 !== "number" && typeof o1 != "function") { for(var key in o2){ if(typeof o2[key]=="function") continue; var value = o2[key]; if(o1[key] === undefined) { tempNewObj[key] = value; } else { tempNewObj[key] = mergeDeep(o1[key], o2[key]); } } } //else if o1 is an array - [] else if(o1.length > 0 && typeof o1 !== "string" && typeof o1 != "function") { for(var indexc in o2){ if(typeof o2[indexc] == "function") continue; if(o1[indexc] === undefined){ tempNewObj.push(o2[indexc]); } else{ var tmp = mergeDeep(o1[indexc], o2[indexc]); tempNewObj[indexc] = tmp; } }; } //handling other types like string or number else if(typeof o1 != "function"){ //taking value from the second object o2 //could be modified to keep o1 value with tempNewObj = o1; //if(typeof o1 !== "undefined") -- corretto EG if((Empty(o2+"") && !Empty(o1+"")) || (!Empty(o2+"") && !Empty(o1+"")) && o1!==o2) tempNewObj = o1; else tempNewObj = o2; } return tempNewObj; } function _DrawDocumentViewProvider(_obj, format, SdataProvider, container, dwnlName, actionObj, isSimulatedData, fncCallBack, isPreview) { delete window._tmpArgs; var obj = {}; function setDefaultProperties() { var strObj = JSON.stringify(getFromDesignObj(true)), zones = ["reportheader", "pageheader", "groupheader", "groupbody", "groupfooter", "pagefooter", "reportfooter"]; obj = Object.assign(JSON.parse(strObj), _obj); for (var i = 0; i < zones.length; i++) { var newItems = []; for (var j = 0; j < obj[zones[i]].items.length; j++) { newItems.push(mergeDeep(obj[zones[i]].items[j], blankJsonItem())) } obj[zones[i]].items = []; obj[zones[i]].items = newItems.slice(); } } setDefaultProperties(); actionObj || ( actionObj = {} ); var uid = container.id + "_jsrep", myobserver = { SdataProvider_ConsumersRendered : function () { exec(); } }, allfields = getZoneAlias(obj), imgfields = getImagesAlias(obj); if (Empty(dwnlName)) dwnlName = obj.name; if (format == "html") window[uid] = new RepDocumentHtml(dwnlName, uid); else if (format == "pdf" || format == "IARViewer") window[uid] = new RepDocumentPdf(dwnlName, uid); else if (format == "xls" || format == "xlsx") window[uid] = new RepDocumentXlsx(dwnlName, uid, format); else // CSVS CSV CSV2 XML XMLS window[uid] = new RepDocumentText(dwnlName, uid, format, format.toLowerCase() == "csvs", actionObj.coverobj.csvSeparator, actionObj.coverobj.csvHeader); window[uid].offline = false; window[uid].theme = actionObj.theme; window[uid].format = format; window[uid].group_repeated = actionObj.group_repeated; window[uid].pictureMap = actionObj.pictureMap; function downloadListener () { if (window[uid].datasource.getRecCount() == 0) return; window[uid].download(); } window[uid].autoprint = Empty(actionObj.autoprint) ? false : actionObj.autoprint; window[uid].autodownload = Empty(actionObj.autodownload) ? false : actionObj.autodownload; var downloadCtrl = actionObj.cdownload; if (downloadCtrl) { if (downloadCtrl.tagName) downloadCtrl.onclick = downloadListener; else if (downloadCtrl.addObserver) downloadCtrl.addObserver( 'downloadCtrl', { downloadCtrl_Click: downloadListener } ); } function printListener () { window[uid].print(); } var bprint = false, printCtrl = actionObj.cprint; if (printCtrl) { bprint = true; if (printCtrl.tagName) printCtrl.onclick = printListener; else if (printCtrl.addObserver) printCtrl.addObserver( 'printCtrl', { printCtrl_Click: printListener } ); } window[uid].isPreview = isPreview; if (window[uid].isPreview) window[uid].name = window[uid].name + "_preview"; var pprops = new JSURL("../servlet/SPReportGet?action=getReportLicenze&filename=printlicenze"); pprops = JSON.parse(pprops.Response()); if (window[uid].isPreview) window[uid].watermark = "VALID DOCUMENT ONLY AS PREVIEW"; else if(pprops.hasWatermark) window[uid].watermark = pprops.watermark; window[uid].license = pprops.license; window[uid].watermarkIsImage = pprops.hasWatermarkAsImage; gwork = window[uid].setGWork(obj); window[uid].beforeProcess(allfields, container, bprint, imgfields, isSimulatedData); window[uid].startLoading(); window[uid].setLimitPage(); window[uid].gwork.pagecounter = 1; window[uid].gwork.rpagecounter = 1; window[uid].drawCover(actionObj.coverobj); var cpDP = SdataProvider._getCloneForPrint(); cpDP.nRows = 1; cpDP.count = "true"; cpDP.Query(); SdataProvider.addRowConsumer(window[uid]); window[uid].datasource = SdataProvider; if (cpDP.querycount > 0) window[uid].datasource.nRows = cpDP.querycount; else window[uid].datasource.nRows = 5000; window[uid].execQuery = true; window[uid].datasource.addObserver("SdataProvider", myobserver); window[uid].datasource.Query(); window[uid].args = Array.prototype.slice.call(arguments); window[uid].fncCallBack = fncCallBack; window[uid].execCallback = true; window[uid]._dontruncb = (format == "IARViewer" && window.navigator.userAgent.match(/zRuntime/)); LibJavascript.Events.addEvent(window, 'resize', function (evt) { resize(evt, uid); }) function exec(){ if( !window[uid] ) return; try { if ((window[uid].end && !fncCallBack) || window[uid].managed) { window[uid].removeLoading(); return; } var hasnext; if (!window[uid].isEof() || (window[uid].isPreview && !window[uid].isEoPreview())) { hasnext = window[uid].datasource.getRecCount()>0 && window[uid].datasource.NextPage(); if (hasnext === undefined) hasnext = true; } else hasnext = false; if (window[uid].datasource.getRecCount() == 0) { printMessageDiv(uid, window[uid].errorMessages.JSVRP_NODATA); window[uid].end = true; } else if (!Empty(window[uid].listMissingFields) && window[uid].listMissingFields.length > 0) { getFieldsDetailMap(window[uid].obj); var msg = window[uid].errorMessages.JSVRP_NOTFDATAS; printMessageDiv(uid, msg); window[uid].end = true; } else if ((hasnext == false || window[uid].isEof()) && window[uid].datasource.getRecCount() > 0) window[uid].documentExec(); if (window[uid].end && format == "IARViewer" && window.navigator.userAgent.match(/zRuntime/)) window[uid].view(window[uid].fncCallBack); window[uid].execFncCallback(); } catch (e) { console.error(e.message); printMessageDiv(uid, window[uid].errorMessages.JSVRP_PRINTERR); } } } function JSRepDrawDocumentViewProviderOFFLINE(obj, format, SdataProvider, container, dwnlName, actionObj, isSimulatedData, fncCallBack, isPreview) { actionObj || ( actionObj = {} ); container || ( container = document.createElement( 'div' ) ); container.id || ( container.id = LibJavascript.AlfaKeyGen() ); var uid = container.id + "_jsrep"; var myobserver = { SdataProvider_ConsumersRendered:function(){ execOFFLINE(); } }; if (Empty(dwnlName)) dwnlName = obj.name; if (dwnlName && dwnlName.filePath) dwnlName = dwnlName.filePath; var allfields = getZoneAlias(obj); var imgfields = getImagesAlias(obj); //var isSimulatedData = Empty(SdataProvider.cmd); // da problemi su SPSmartReportPrint quando stampo BO off if(format=="html") window[uid] = new RepDocumentHtml(dwnlName, uid); else if(format=="pdf" || format=="IARViewer") window[uid] = new RepDocumentPdf(dwnlName, uid); window[uid].theme = actionObj.theme; function downloadListener () { if (window[uid].datasource.getRecCount() == 0) return; window[uid].download(); } window[uid].autoprint = Empty(actionObj.autoprint) ? false : actionObj.autoprint; window[uid].autodownload = Empty(actionObj.autodownload) ? false : actionObj.autodownload; var downloadCtrl = actionObj.cdownload; if ( downloadCtrl ) { if ( downloadCtrl.tagName /*HTMLElement*/) { downloadCtrl.onclick = downloadListener; //downloadCtrl.addEventListener( 'click', downloadListener, false ); //scatena due volte l'evento???? } else if ( downloadCtrl.addObserver /*PortalStudio Ctrl*/ ) { downloadCtrl.addObserver( 'downloadCtrl', { downloadCtrl_Click: downloadListener } ); } } function printListener () { window[uid].print(); } var bprint = false; var printCtrl = actionObj.cprint; if ( printCtrl ) { bprint = true; if ( printCtrl.tagName /*HTMLElement*/) { printCtrl.onclick=printListener; //printCtrl.addEventListener( 'click', printListener, false ); //scatena due volte l'evento???? } else if ( printCtrl.addObserver /*PortalStudio Ctrl*/ ) { printCtrl.addObserver( 'printCtrl', { printCtrl_Click: printListener } ); } } var pprops = new JSURL("../servlet/SPReportGet?action=getReportLicenze&filename=printlicenze"); pprops = JSON.parse(pprops.Response()); if(isPreview) window[uid].watermark = "VALID DOCUMENT ONLY AS PREVIEW"; else if(pprops.hasWatermark) window[uid].watermark = pprops.watermark; window[uid].license = pprops.license; window[uid].watermarkIsImage = pprops.hasWatermarkAsImage; gwork = window[uid].setGWork(obj); window[uid].beforeProcess(allfields,container,bprint,imgfields,isSimulatedData); window[uid].startLoading(); window[uid].setLimitPage(); window[uid].gwork.pagecounter = 1; window[uid].gwork.rpagecounter = 1; window[uid].drawCover(actionObj.coverobj); SdataProvider.addParmConsumer(window[uid]); window[uid].datasource = SdataProvider; window[uid].execQuery = true; SdataProvider.addObserver("SdataProvider", myobserver); SdataProvider.Query(); window[uid].args = Array.prototype.slice.call(arguments); window[uid].fncCallBack = fncCallBack; window[uid].execCallback = true; window[uid]._dontruncb = true; window[uid].offline = true; window[uid].format = format; window[uid].isPreview = isPreview; if (window[uid].isPreview) window[uid].name = window[uid].name + "_preview"; function execOFFLINE(){ try { if (window[uid].end && !fncCallBack) return; var currimg = window[uid].imgCount; var totimg = Object.keys(window[uid].imgMap).length; if(window[uid].datasource.getRecCount()==0){ printMessageDiv(uid, window.TransDict.RPT_ERROR_NO_RECORD); window[uid].end = true; } else if(!Empty(window[uid].listMissingFields) && window[uid].listMissingFields.length > 0) { var mapfields = getFieldsDetailMap(window[uid].obj); var msg = window.TransDict.RPT_ERROR_GENERIC; msg += "
"; for (var ff = 0; ff < window[uid].listMissingFields.length; ff++) { var alias = window[uid].listMissingFields[ff]; msg += alias + " ( " + mapfields[alias] + " ) " + window.TransDict.RPT_ERROR_NOTFOUND_FIELD; msg += "
"; } printMessageDiv(uid, msg); window[uid].end = true; } else if(window[uid].datasource.getRecCount() > 0 && window[uid].propertyValue.length > 0 && window[uid].isEof() && currimg == totimg && !window[uid].end) window[uid].documentExecOFFLINE(window[uid]); if (window[uid].end && format == "IARViewer" && window.navigator.userAgent.match(/zRuntime/)) window[uid].view(window[uid].fncCallBack); window[uid].execFncCallback(); } catch(e){ console.error(e.stack); printMessageDiv(uid, window.TransDict.RPT_ERROR_GENERIC); } } } function startNewPage(obj){ if(obj.groupbreak.options.startNewPage) return true; if(obj.showGroupZone) if(obj.groupfooter.options.atEndOfPage) return true; return false; } function startNewGroup(currRec,obj,lastRec){ var ret = false; for(var k=0; !ret && k0){ p_cVar = ToHTML(arrsplit[0]); for(var k=1; k' + ToHTML(arrsplit[k]); } p_cVar = Strtran(p_cVar, " ", " "); return p_cVar; } function getImagesAlias(obj){ var ret = {}; var zones = []; if(obj.showGroupZone){ zones.push('groupheader'); zones.push('groupfooter'); } if(obj.showPageZone){ zones.push('pageheader'); zones.push('pagefooter'); } if(obj.showReportZone){ zones.push('reportheader'); zones.push('reportfooter'); } zones.push('groupbody'); var l,k; ret.fields = []; ret.generic = []; for(l=0; l w) { item._newWidth = svg_w; } } break; } } catch(e) { //console.log(e) } } function resize(evt, uid) { if (evt && evt.srcElement) { var wnd = evt.srcElement; if (!wnd[uid] || !wnd[uid].end) return; wnd[uid].container.style.height = (wnd.innerHeight - 2) + "px"; } } function getFontsFromObj(obj) { var sections = [ 'reportheader' , 'pageheader' , 'groupheader' , 'groupbreak' , 'groupbody' , 'groupfooter' , 'pagefooter' , 'reportfooter' ], flist = [], tarr, font; for (var i = 0; i < sections.length; i++) { tarr = obj[sections[i]].items; for (var j = 0; j < tarr.length; j++) { if (tarr[j].style && tarr[j].style.font && tarr[j].style.font.fontName) { font = tarr[j].style.font.fontName; if (tarr[j].style.font.bold) font += "_bold"; if (tarr[j].style.font.italic) font += "_italic"; if (flist.indexOf(font) < 0) flist.push(font); } } } return flist; }