JavaLikeCalc.JavaScript
function messByLang(iMess) {
	if((tVl=iMess.match("^"+(this.ownerSess().reqLang().length?this.ownerSess().reqLang():SYS.lang())+":(.+)$","m")).length)
		return tVl[1];
	return iMess.parseLine(0);
}

function labSize( ltext, charW ) {
	if(charW == null)	charW = 11;
	for(labSz = 0, off = 0; off < ltext.length; labSz++)
		ltext.charAt(off, "UTF-8");

	return ceil(ceil(labSz*charW*0.6)/10)*10;
}

function itHighl( celO, itVl ) {
	if(celO == null)	return "";
	tLs = new Array();
	if(celO.fltr.indexOf("index") == 0 && itVl.length) { celO.ls[tVl=itVl.trim()] = true; tLs.push(tVl); }
	else if(celO.fltr.indexOf("list") == 0)
		for(tLs = itVl.split(celO.fltr[4]), iLs = 0; iLs < tLs.length; iLs++)
			celO.ls[tLs[iLs]=tLs[iLs].trim()] = true;

	for(iLn = 0, off = 0; tLs.length && (tVl=celO.fltr.parseLine(0,off)).length; iLn++)
		if(iLn && tLs.indexOf(tVl.parse(0,":")) >= 0) return tVl;

	return "";
}

function updProc(iR, dataTbl, clsLsO ) {
	procLng = "JavaLikeCalc.JavaScript";
	procArgs = new Object();

	updReq = "";
	for(iC = 0; iC < dataTbl[iR].length; iC++)
		if((itID=dataTbl[0][iC]).indexOf("SP_") == 0)
			procArgs[itID.slice(3)] = ((itVl=dataTbl[iR][iC]) != "<NULL>") ? itVl : "";
	for(iC = 0; iC < dataTbl[iR].length; iC++) {
		if((itID=dataTbl[0][iC]).indexOf("SP_") != 0 || (tClO=clsLsO[(itID=itID.slice(3))]).isEVal() || !tClO.prc.length || dataTbl[iR][iC] != "<NULL>") continue;
		if(tClO.prcId == null) tClO.prcId = this.nodePath("_")+"_"+itID;
			SYS.DAQ.funcCall(procLng, procArgs, tClO.prc, tClO.prcId);
			dataTbl[iR][iC] = procArgs[itID];
			updReq += (updReq.length?", ":"") + "`SP_"+itID+"`='"+SYS.strEncode(procArgs[itID],"SQL")+"'";
		}
	if(updReq.length)
		SYS.BD.nodeAt(db,".").SQLReq("UPDATE `sh_"+class+"` SET "+updReq+" WHERE `"+dataTbl[0][0]+"`='"+dataTbl[iR][0]+"';", true);
}

function getFileFIt(celId, celO, fNm, sz) {
	fItValFileNm = ((fNm != null) ? fNm : this["fItVal"+celId].attr("value")).parse(0,";;");
	if(celO.tp.parse(2,":").length)
		tVl = (sz==true) ? SYS.fileSize(celO.tp.parse(2,":")+"/"+fItValFileNm) : SYS.fileRead(celO.tp.parse(2,":")+"/"+fItValFileNm);
	else {
		dataTblOneReq = SYS.BD.nodeAt(db,".").SQLReq("SELECT `"+celId+"` FROM `sh_"+class+"` WHERE `ID`='"+dataTbl_value+"';");
		for(iF = 0, off = 0; (tVl=dataTblOneReq[1][0].parseLine(0,off)).length; iF++)
			if((iF%2) == 0 && tVl == fItValFileNm) {
				tVl = dataTblOneReq[1][0].parseLine(0,off);
				tVl = (sz == true) ? tVl.length : SYS.strDecode(tVl,"Base64");
				break;
			}
		delete dataTblOneReq;
	}

	return tVl;
}

var wUser;

if(f_start || wUser != this.ownerSess().reqUser()) {
	wUser = this.ownerSess().reqUser(), f_start = true;

	geomHOrig = 580;
	toUpdate = toReport = false;
	fMax = 5; fClrTo = 0;
	itEdFormMarg = 20;
	itEdFormX = itEdFormMarg;
	itEdFormY = this.lab_fltr.attr("geomY");
	itEdFormW = geomW - 2*itEdFormMarg;
	itEdFormLineHigh = 20;
	itEdFormOff = null;	//Height offset of the last item of the configuration form
	btClassEdit_en = dataEditable && classEditable;
	if(classFix.length)	classNm_text = class = classFix;
	else classSel_en = true;
	colVars = new Object(), colLists = new Object();
	btClassEdit_value = btEdit_en = btEdit_value = btItEdit_value = false;
	geomH = geomHOrig;
	dataTbl_geomY = fltrCol0_geomY + fltrCol0_geomH;
	dataTbl_geomH = itDel_geomY - dataTbl_geomY + itDel_geomH;
}

//Common events process
for(off = 0; (sval=event.parse(0,"\n",off)).length; )
	if(sval == "ws_BtToggleChange:/btClassEdit")	toUpdate = true, itDel_active = itCopy_active = false, dataTbl_value = "";
	else if(sval == "ws_BtToggleChange:/btEdit")	toUpdate = true;
	else if(sval == "ws_CombChange:/classSel") {
		class = ((tVl=classSel_value.match("\\((.+)\\)$")).length) ? tVl[1] : classSel_value;
		toUpdate = true; colVars = new Object(), colLists = new Object(); fClrTo = 0; dataTbl_value = "";
		if(itEdFormOff != null)	itEdFormOff = -1;
	}
	else if(sval == "ws_LnAccept:/classEd") {
		class = ((tVl=classEd_value.match("\\((.+)\\)$")).length) ? tVl[1] : classEd_value;
		toUpdate = true; colVars = new Object(), colLists = new Object();
	}

if((f_start || toUpdate) /*&& !classFix.length*/) {
	clsLs = SYS.BD.nodeAt(db,".").SQLReq("SELECT DISTINCT CLASS FROM `classes`;");
	classSel_items = "";
	for(iR = 1; iR < clsLs.length; iR++) {
		clsNm = SYS.BD.nodeAt(db,".").SQLReq("SELECT `NAME` FROM `classes` WHERE `CLASS`='"+clsLs[iR][0]+"' AND `ID`='*TITLE';");
		classSel_items += (classSel_items.length?"\n":"") + ((clsNm.length==2)?messByLang(clsNm[1][0]) + " ("+clsLs[iR][0]+")":clsLs[iR][0]);
	}
	classEd_cfg = classSel_items;

	clsNm = SYS.BD.nodeAt(db,".").SQLReq("SELECT `NAME` FROM `classes` WHERE `CLASS`='"+class+"' AND `ID`='*TITLE';");
	classNm_text = classSel_value = classEd_value = class;
	if(clsNm.length == 2)	classNm_text = classSel_value = messByLang(clsNm[1][0]) + " ("+class+")";

	dataTbl_geomY = btClassEdit_value ? lab_fltr_geomY : fltrCol0_geomY + fltrCol0_geomH;
	dataTbl_geomH = itDel_geomY - dataTbl_geomY + ((btClassEdit_value||btEdit_value)?0:itDel_geomH);

	//Apply filter vertical offset and size
	if(!btClassEdit_value) {
		for(iF = fMax-1; iF > 0 && !this["fltr"+iF].attr("en"); iF--) ;
		dataTbl_geomY = this["fltr"+iF].attr("geomY") + this["fltr"+iF].attr("geomH");
		dataTbl_geomH = itDel_geomY + (btEdit_value?0:itDel_geomH) - dataTbl_geomY;
	}

	btClassEdit_en = !(btItEdit_en && btItEdit_value);
	btClassEdit_active = class.length;
	classEd_en = btClassEdit_en && !classFix.length && btClassEdit_value;
	classSel_en = btClassEdit_en && !classFix.length && !btClassEdit_value;

	go_report_en = go_reportIt_en = !btClassEdit_value;
}

//Removing old edition fields of the item configuration form
if(f_start || (btClassEdit_value && itEdFormOff != null) || itEdFormOff == -1) {
	itEdFormOff = null;
	geomH = geomHOrig;

	wLs = this.nodeList("wdg_");
	for(iW = 0; iW < wLs.length; iW++)
		if(wLs[iW].indexOf("wdg_fItLab") == 0 || wLs[iW].indexOf("wdg_fItVal") == 0)
			this.wdgDel(wLs[iW].slice(4));
}

//The class edition mode
if(btClassEdit_value) {
	dataTbl_en = itDel_en = itAdd_en = true;
	btEdit_en = btItEdit_en = btItEdit_value = itCopy_en = false;

	SYS.BD.nodeAt(db,".").SQLReq("CREATE TABLE IF NOT EXISTS `classes` (`CLASS` varchar(20) DEFAULT '', `ID` varchar(20) DEFAULT '', `NAME` text, `TP` varchar(100) DEFAULT '', `TBL` varchar(100) DEFAULT '', `FILTER` text, `PROC` text, PRIMARY KEY (`CLASS`,`ID`));", true);

	//Updation the main table
	if(f_start || toUpdate) {
		// Requesting the table structure
		dataTbl = SYS.BD.nodeAt(db,".").SQLReq("SELECT `ID`,`NAME`,`TP`,`TBL`,`FILTER`,`PROC` FROM `classes` WHERE `CLASS`='"+class+"';", false);
		dataTbl_items = "<tbl sel='row' colsWdthFit='0' hHdrVis='1' vHdrVis='1'>\n";
		for(iR = 0; iR < dataTbl.length; iR++) {
			dataTbl_items += iR ? "<r>" : "<h>";
			for(iC = 0; iC < dataTbl[iR].length; iC++) {
				itVl = dataTbl[iR][iC];
				tNm = "s", opt = "";
				if(iR == 0)	 {
					opt += " edit='1'";
					if(itVl == "ID")				itVl = tr("Identifier");
					else if(itVl == "NAME")	itVl = tr("Name");
					else if(itVl == "TP")		itVl = tr("Type");
					else if(itVl == "TBL")		itVl = tr("Table properties");
					else if(itVl == "FILTER") itVl = tr("Filter");
					else if(itVl == "PROC")	{ itVl = tr("Procedure"); opt += " width='400px'"; }
				}
				else {
				    if(iC == 1 || iC == 4 || iC == 5)	tNm = "t";
				    if(itVl == "<NULL>")	itVl = "";
				}
				dataTbl_items += "<"+tNm+opt+">"+SYS.strEncode(itVl,"HTML")+"</"+tNm+">";
			}
			dataTbl_items += iR ? "</r>\n" : "</h>\n";
		}
		dataTbl_items += "</tbl>";

		toUpdate = false;
	}

	//Class edition events process
	for(off = 0; (sval=event.parse(0,"\n",off)).length; ) {
		itDel_active = itCopy_active = dataTbl_value.length;
		if(sval == "ws_BtRelease:/itAdd") {
			// Creation the empty data table with the default structure
			if(dataTbl.length == 1) {
				SYS.BD.nodeAt(db,".").SQLReq("CREATE TABLE IF NOT EXISTS `sh_"+class+"` (`ID` INT AUTO_INCREMENT, `NAME` varchar(200) DEFAULT '', `DSCR` text, PRIMARY KEY (`ID`));", true);
				SYS.BD.nodeAt(db,".").SQLReq("INSERT INTO `classes` (`CLASS`,`ID`,`NAME`) VALUES ('"+class+"','*TITLE','');", true);
				SYS.BD.nodeAt(db,".").SQLReq("INSERT INTO `classes` (`CLASS`,`ID`,`NAME`) VALUES ('"+class+"','*ID','');", true);
				SYS.BD.nodeAt(db,".").SQLReq("INSERT INTO `classes` (`CLASS`,`ID`,`NAME`) VALUES ('"+class+"','*NAME','');", true);
				SYS.BD.nodeAt(db,".").SQLReq("INSERT INTO `classes` (`CLASS`,`ID`,`NAME`) VALUES ('"+class+"','*DSCR','');", true);
			}
			SYS.BD.nodeAt(db,".").SQLReq("INSERT INTO `classes` (`CLASS`,`ID`,`NAME`,`TP`) VALUES ('"+class+"','NewItem','"+tr("New item")+"','varchar(100)');", true);
			SYS.BD.nodeAt(db,".").SQLReq("ALTER TABLE `sh_"+class+"` ADD `SP_NewItem` varchar(100) DEFAULT '';", true);
			toUpdate = true; toCalcCycles = 1;
		}
		else if(sval == "dlg_Apply:/itDel" && dataTbl_value[0] != "*") {
		//else if(sval == "ws_BtRelease:/itDel") {
			SYS.BD.nodeAt(db,".").SQLReq("DELETE FROM `classes` WHERE `ID`='"+dataTbl_value+"' AND `CLASS`='"+class+"';", true);
			if(dataTbl.length > 2)	SYS.BD.nodeAt(db,".").SQLReq("ALTER TABLE `sh_"+class+"` DROP `SP_"+dataTbl_value+"`;", true);
			else SYS.BD.nodeAt(db,".").SQLReq("DROP TABLE `sh_"+class+"`;", true);
			toUpdate = true; toCalcCycles = 1;
		}
		else if(sval.indexOf("ws_TableEdit") == 0) {
			col = sval.parse(0,"_",13).toInt(); row = sval.parse(1,"_",13).toInt();
			colID = dataTbl[0][col];
			fldID = dataTbl[row+1][0];
			if(!SYS.BD.nodeAt(db,".").SQLReq("UPDATE `classes` SET `"+colID+"`='"+SYS.strEncode(dataTbl_set,"SQL")+"' WHERE `CLASS`='"+class+"' AND `ID`='"+fldID+"';",true).err.length) {
				if(colID == "ID"  && fldID[0] != "*") {
					SYS.BD.nodeAt(db,".").SQLReq("ALTER TABLE `sh_"+class+"` CHANGE `SP_"+fldID+"` `SP_"+dataTbl_set+"` "+dataTbl[row+1][2].parse(0,":")+";", true);
					toCalcCycles = 1; //2000/this.ownerSess().period();
				}
				else if(colID == "TP" && (fldID[0] != "*" || fldID == "*NAME")) {
					if((tVl=dataTbl_set.parse(0,":")) == "file") tVl = dataTbl_set.parse(2,":").length ? "TEXT" : "LONGTEXT";
					SYS.BD.nodeAt(db,".").SQLReq("ALTER TABLE `sh_"+class+"` MODIFY `"+(fldID[0]=="*"?fldID.slice(1):"SP_"+fldID)+"` "+tVl+";", true);
				}
				else if(colID == "PROC" && dataTbl_set.length)
					SYS.BD.nodeAt(db,".").SQLReq("UPDATE `sh_"+class+"` SET `SP_"+fldID+"`=NULL;", true);
			}
			toUpdate = true;
		}
	}

	if(toCalcCycles > 0.1) {
		this.attrSet("event", this.attr("event")+"usr_calc\n");	//!!!! Just to calc in the next session cycle for update
		toCalcCycles = max(0, toCalcCycles-1);
	}

	return;
}

//The data representing mode
if(f_start || toUpdate) {
	go_report_active = dataTbl_en = lab_fltr_en = btEdit_en = itDel_en = itAdd_en = itCopy_en = fltr0_en = fltrCol0_en = !btItEdit_value;

	//Generic table
	//------------------
	if(dataTbl_en) {
		geomH = geomHOrig;

		// Initiate the filter
		for(iF = 0; iF < fMax; iF++)
			this["fltrCol"+iF].attrSet("items", tr("Disabled")+"\n"+tr("Name")+" (NAME)\n"+tr("Description")+" (DSCR)");

		// Requesting the table structure
		clsLs = SYS.BD.nodeAt(db,".").SQLReq("SELECT `ID`,`NAME`,`TP`,`TBL`,`FILTER`,`PROC` FROM `classes` WHERE `CLASS`='"+class+"';");
		clsLsO = new Object();	 clsLsSort = new Array();
		hasProc = false;		//The scheme has procedures of the logical columns
		for(iR = 1; iR < clsLs.length; iR++) {
			clsLsO[clsLs[iR][0]] = tO = new Object();
			tO.name = ((tO.name=clsLs[iR][1]) == "<NULL>" || !tO.name.length) ? clsLs[iR][0] : messByLang(tO.name);
			tO.tp = clsLs[iR][2];
			tO.tbl = clsLs[iR][3];
			if((tO.fltr=clsLs[iR][4]) == "<NULL>") tO.fltr = "";
			if((tO.prc=clsLs[iR][5]) == "<NULL>")  tO.prc = "";
			if(tO.prc.length) hasProc = true;
			if(clsLs[iR][0] == "*ID") {
				tO.name = (tO.name==clsLs[iR][0]) ? tr("Identifier") : tO.name;
				tO.tp = "int";
				tO.tbl = tO.tbl.length ? tO.tbl : "center:0px";
			}
			else if(clsLs[iR][0] == "*NAME") {
				tO.name = (tO.name==clsLs[iR][0]) ? tr("Name") : tO.name;
				tO.tp = tO.tp.length ? tO.tp : "varchar(200)";
				tO.tbl = tO.tbl.length ? tO.tbl : "center:170px";
			}
			else if(clsLs[iR][0] == "*DSCR") {
				tO.name = (tO.name==clsLs[iR][0]) ? tr("Description") : tO.name;
				tO.tp = tO.tp.length ? tO.tp : "text";
				tO.tbl = tO.tbl.length ? tO.tbl : ":350px";
			}

			if(clsLs[iR][0][0] != "*")
				for(iF = 0; iF < fMax; iF++)
					this["fltrCol"+iF].attrSet("items", this["fltrCol"+iF].attr("items")+"\n"+tO.name+" (SP_"+clsLs[iR][0]+")");

			if(clsLs[iR][0] != "*TITLE") clsLsSort.push(tO.tbl.parse(2,":")+":"+iR.toString(10,3));
		}
		clsLsSort.sort();
		clsLsReq = "";
		for(iL = 0; iL < clsLsSort.length; iL++)
			if((tVl=clsLs[clsLsSort[iL].parse(1,":").toInt()][0]) != "*ID")
				clsLsReq += (clsLsReq.length?",":"") + "`"+((tVl[0]=="*")?tVl.slice(1):"SP_"+tVl)+"`";

		//Updation the main table
		// Where prepairing for the filter
		noFilter = true;
		for(wherePart = "", iF = 0; iF < fMax; iF++) {
			if(!(tVl=this["fltr"+iF].attr("value")).length)	continue;
			itVl = this["fltrCol"+iF].attr("value").match("\\((.+)\\)")[1];
			wherePart += (wherePart.length?"AND":"") + " `"+itVl+"` REGEXP '"+tVl+"' ";
			if(!colVars[itVl].isEVal())	colVars[itVl]["<lock>"] = true;
			noFilter = false;
		}
		for(var iC in colVars)
			if(colVars[iC]["<lock>"] == true)	delete colVars[iC]["<lock>"];
			else delete colVars[iC];
		// Same requesting
		dataTbl = SYS.BD.nodeAt(db,".").SQLReq("SELECT `ID`,"+clsLsReq+" FROM `sh_"+class+"` "+(wherePart.length?"WHERE"+wherePart:"")+"ORDER BY 'ID';");
		dataTbl_items = "<tbl sel='row' sortEn='"+(btEdit_value?0:1)+"' colsWdthFit='0' hHdrVis='1' vHdrVis='1'>\n";
		colTps = new Object();
		if(toReport)	tRep = "<body>\n"
								"<h1>"+classNm_text+"</h1>\n"
								"<table class='data' width='100%' export='1'>\n";
		noDataTbl_value = true;
		for(iR = 0; iR < dataTbl.length; iR++) {
			cntR = optR = "";
			if(toReport) tRep += "<tr>";
			//   ... the header
			if(iR == 0)
				for(iC = 0; iC < dataTbl[iR].length; iC++) {
					itVl = dataTbl[iR][iC];
					opt = "";
					if(itVl == "ID" && clsLsO["*"+itVl] == null)	opt += " width='0px'";
					else if((itVl.indexOf("SP_") == 0 && !(tVl=clsLsO[itVl.slice(3)]).isEVal()) || ((itVl == "ID" || itVl == "NAME" || itVl == "DSCR") && !(tVl=clsLsO["*"+itVl]).isEVal()))
					{
						if((tVl.fltr == "index" || tVl.fltr.indexOf("list") == 0) && colVars[itVl] == null) {
							colVars[itVl] = new Object();
							colVars[itVl].ls = new Object();
							colVars[itVl].fltr = tVl.fltr;
						}
						opt += (btEdit_value && !tVl.prc.length && itVl != "ID" && tVl.tp.parse(0,":") != "file") ? " edit='1'" : "";
						itVl = tVl.name;
						if(tVl.tp.search("bool","i") >= 0)			colTps[iC] = "b";
						else if(tVl.tp.search("int","i") >= 0)	colTps[iC] = "i";
						else if(tVl.tp.search("(float|double)","i") >= 0) colTps[iC] = "r";
						else if(tVl.tp.search("text","i") >= 0 || tVl.tp.parse(0,":") == "file")
																				colTps[iC] = "t";
						if((tVl2=tVl.tbl.parse(0,":")).length)	opt += " align='"+tVl2+"'";
						if((tVl2=tVl.tbl.parse(1,":")).length)	opt += " width='"+tVl2+"'";
						//this.messInfo("iC="+iC+"; tp="+tVl.tp+" = "+colTps[iC]+"; tVl.fltr="+tVl.fltr);
					}
					cntR += "<s"+opt+">"+SYS.strEncode(itVl,"HTML")+"</s>";
					if(toReport) tRep += "<th>"+SYS.strEncode(itVl,"HTML")+"</th>";
				}
			//  ... the data
			else {
				//  ... prepairing the logical cells
				if(hasProc) updProc(iR, dataTbl, clsLsO);

				//  ... representing
				for(iC = 0; iC < dataTbl[iR].length; iC++) {
					itVlCol = dataTbl[0][iC];
					itVl = dataTbl[iR][iC];
					opt = "";
					if(itVl == "<NULL>")	itVl = "";
					if((celO=clsLsO[itVlCol.slice(3)]) != null && celO.tp.parse(0,":") == "file" && !celO.tp.parse(2,":").length) {
						for(iF = 0, off = 0, itVlRez = ""; (itVlEl=itVl.parseLine(0,off)).length; iF++)
							if((iF%2) == 0)	itVlRez += (itVlRez.length?"\n":"") + itVlEl;
						itVl = itVlRez;
					}
					if((tVl1=itHighl(colVars[itVlCol],itVl)).length) {
						tVl = ((tVl=tVl1.parse(2,":")).length?" color='"+tVl+"'":"") + ((tVl=tVl1.parse(3,":")).length?" font='"+tVl+"'":"");
						if(tVl1.parse(1,":")[0] == "1") optR += tVl; else opt += tVl;
					}
					if(noFilter)	colLists[itVlCol] = colVars[itVlCol].ls;
					if(dataTbl_value.length && itVlCol == "ID" && itVl == dataTbl_value)	noDataTbl_value = false;
				
					if(!colTps[iC].isEVal())	cntR += "<"+colTps[iC]+opt+">"+SYS.strEncode(itVl,"HTML")+"</"+colTps[iC]+">";
					else cntR += "<s"+opt+">"+SYS.strEncode(itVl,"HTML")+"</s>";
					if(toReport)
						tRep += "<td style='white-space: pre-wrap;"+((colTps[iC]=="t")?"text-align: left;":"")+"'>"+
							SYS.strEncode(((tVl1=SYS.strEncode(itVl,"Limit",300))==itVl)?tVl1:tVl1+"...","HTML").replace(new RegExp("(http|https|ftp)://(\\S+)","g"),"<a target='_blank' href='$1://$2'>$2</a>")+
							"</td>";
				}
			}
			dataTbl_items += (iR?"<r":"<h")+optR+">" + cntR + (iR?"</r>\n":"</h>\n");
			if(toReport) tRep += "</tr>\n";
		}
		dataTbl_items += "</tbl>\n";
		if(toReport) { tRep += "</table>\n</body>\n"; go_report_report = tRep; tRep = ""; }

		if(noDataTbl_value)	dataTbl_value = "";

		//Filter's selection list update
		for(iF = 0; iF < fMax; iF++) {
			iFCo = this["fltrCol"+iF]; iFo = this["fltr"+iF];
			fCol = iFCo.attr("value").match("\\((.+)\\)")[1];
			//this.messInfo("iF="+iF+"; fCol="+fCol+"; colVars[fCol]="+colVars[fCol]);
			if((tO=colVars[fCol]).isEVal())	continue;
			tO = tO.ls;
			fCfg = "";
			fCfgPref = iFo.attr("value");
			for(sumVl = "", tVl1 = "", off = 0; (tVl=fCfgPref.parse(0,"|",off)).length; tVl1 = tVl)
				if(tVl1.length) { sumVl += (sumVl.length?"|":"")+tVl1; fCfg += sumVl + "\n"; }
			for(var iFv in tO)
				if(iFv.length && fCfgPref.indexOf(iFv) < 0)
					fCfg += (fCfgPref.length?fCfgPref+"|":"") + iFv + "\n";
				//fCfg += iFv+"\n";
			iFo.attrSet("cfg", fCfg);
		}
	}
	//Item edition form
	//------------------
	else if(btItEdit_value) {
		toCreatFormIt = (itEdFormOff == null);	//Creating the form items

		dataTblOneReq = SYS.BD.nodeAt(db,".").SQLReq("SELECT `ID`,"+clsLsReq+" FROM `sh_"+class+"` WHERE `ID`='"+dataTbl_value+"';");
		for(iR = 1; iR < dataTblOneReq.length; iR++) {
			if(dataTblOneReq[iR][0] != dataTbl_value) continue;

			if(hasProc) updProc(iR, dataTblOneReq, clsLsO);

			for(iC = 0; iC < dataTblOneReq[iR].length; iC++) {
				itVlNm = itVlId = dataTblOneReq[0][iC];
				celO = null;
				if((itVlId.indexOf("SP_") == 0 && !(celO=clsLsO[itVlId.slice(3)]).isEVal()) || ((itVlId == "NAME" || itVlId == "DSCR") && !(celO=clsLsO["*"+itVlId]).isEVal()))
					itVlNm = celO.name;
				if((itVl=dataTblOneReq[iR][iC]) == "<NULL>") itVl = "";
				if(celO != null && celO.tp.parse(0,":") == "file" && !celO.tp.parse(2,":").length) {
					for(iF = 0, off = 0, itVlRez = ""; (itVlEl=itVl.parseLine(0,off)).length; iF++)
						if((iF%2) == 0)	itVlRez += (itVlRez.length?"\n":"") + itVlEl;
					itVl = itVlRez;
				}
				if(toCreatFormIt) {
					if(itEdFormOff == null)	itEdFormOff = itEdFormY, geomZoff = 100;
					// Label
					nwlO = this.wdgAdd("fItLab"+itVlId, "", "/wlb_originals/wdg_Text");
					nwlO.attrSet("geomX", itEdFormX).attrSet("geomW", tVl2=labSize(itVlNm+":"))
						.attrSet("geomY", itEdFormOff).attrSet("geomH", itEdFormLineHigh)
						.attrSet("text", itVlNm+":").attrSet("alignment", 8);
					// Value
					if(celO.prc.length || itVlId == "ID") {	//RO items
						nwO = this.wdgAdd("fItVal"+itVlId, "", "/wlb_originals/wdg_Text");
						nwO.attrSet("geomX", itEdFormX+tVl2).attrSet("geomW", (itEdFormW - tVl2) / ((itVlId=="ID")?2:1))
							.attrSet("geomY", itEdFormOff).attrSet("geomH", itEdFormLineHigh).attrSet("geomZ", geomZoff++)
							.attrSet("alignment", 8);
						itEdFormOff += itEdFormLineHigh;
					}
					else if(celO.tp.parse(0,":") == "file") {
						nwO = this.wdgAdd("fItVal"+itVlId, "", "/wlb_originals/wdg_FormEl");
						nwO.attrSet("geomX",itEdFormX+tVl2).attrSet("geomW",300)
							.attrSet("geomY",itEdFormOff).attrSet("geomH",itEdFormLineHigh).attrSet("geomZ",geomZoff++)
							.attrSet("active",1).attrSet("elType",4).attrSet("tipTool",tr("Select file"));
						nwOe = this.wdgAdd("fItVal"+itVlId+"_GT", "", "/wlb_originals/wdg_FormEl");
						nwOe.attrSet("geomX",itEdFormX+tVl2+nwO.attr("geomW")).attrSet("geomW",itEdFormLineHigh)
							.attrSet("geomY",itEdFormOff).attrSet("geomH",itEdFormLineHigh).attrSet("geomZ",geomZoff++)
							.attrSet("elType",3).attrSet("mode",4).attrSet("tipTool",tr("Get")).attrSet("img","upm");
						nwOe = this.wdgAdd("fItVal"+itVlId+"_LD", "", "/wlb_originals/wdg_FormEl");
						nwOe.attrSet("geomX",itEdFormX+tVl2+nwO.attr("geomW")+itEdFormLineHigh).attrSet("geomW",itEdFormLineHigh)
							.attrSet("geomY",itEdFormOff).attrSet("geomH",itEdFormLineHigh).attrSet("geomZ",geomZoff++)
							.attrSet("active",1).attrSet("elType",3).attrSet("mode",3).attrSet("tipTool",tr("Load")).attrSet("img","downm");
						nwOe = this.wdgAdd("fItVal"+itVlId+"_CL", "", "/wlb_originals/wdg_FormEl");
						nwOe.attrSet("geomX",itEdFormX+tVl2+nwO.attr("geomW")+2*itEdFormLineHigh).attrSet("geomW",itEdFormLineHigh)
							.attrSet("geomY",itEdFormOff).attrSet("geomH",itEdFormLineHigh).attrSet("geomZ",geomZoff++)
							.attrSet("elType",3).attrSet("tipTool",tr("Clear")).attrSet("name","X");
						itEdFormOff += itEdFormLineHigh;
						if((tVl=celO.tp.parse(4,":").toInt())) {
							nwOe = this.wdgAdd("fItVal"+itVlId+"_VW", "", "/wlb_originals/wdg_Media");
							nwOe.attrSet("geomX",itEdFormX+tVl2).attrSet("geomW",tVl)
								.attrSet("geomY",itEdFormOff).attrSet("geomH",tVl).attrSet("geomZ",geomZoff++)
								.attrSet("tipTool",tr("Overview")).attrSet("fit",1).attrSet("keepAspect",1);
							itEdFormOff += tVl.toInt();
						}
						delete nwOe;
					}
					else {
						nwO = this.wdgAdd("fItVal"+itVlId, "", "/wlb_originals/wdg_FormEl");
						nwO.attrSet("geomX", itEdFormX+tVl2).attrSet("geomW", itEdFormW - tVl2)
							.attrSet("geomY", itEdFormOff).attrSet("geomH", itEdFormLineHigh).attrSet("geomZ", geomZoff++)
							.attrSet("active", 1).attrSet("confirm", 0);
						itEdFormOff += itEdFormLineHigh;
						//this.messInfo("TEST 00: "+itVlId+" > "+celO.tp);
						if(celO.tp.search("bool","i") >= 0)
							nwO.attrSet("elType", 2);
						else if(celO.tp.search("int","i") >= 0)
							nwO.attrSet("geomW", 100).attrSet("elType", 0).attrSet("view", 0);
						else if(celO.tp.search("(float|double)","i") >= 0)
							nwO.attrSet("geomW", 100).attrSet("elType", 0).attrSet("view", 0);
						else if(celO.tp.search("text","i") >= 0) {
							txtH = 10*itEdFormLineHigh;
							if((tVl3=celO.tbl.parse(1,":")).length) {
								if(tVl3.indexOf("px") > 0)	txtH = (tVl3.toInt()/geomW)*geomHOrig;
								else if(tVl3.indexOf("%") > 0)	txtH = (tVl3.toInt()/100)*geomHOrig;
								else txtH = 3*itEdFormLineHigh;
							}
							nwO.attrSet("geomX", itEdFormX).attrSet("geomW", itEdFormW)
								.attrSet("geomY", itEdFormOff).attrSet("geomH", txtH).attrSet("elType", 1);
							itEdFormOff += txtH;
						}
					}
				} else nwlO = this.wdgAt("fItLab"+itVlId), nwO = this.wdgAt("fItVal"+itVlId);
				//Dynamic
				// Selection for indexes
				if((celO.fltr == "index" || celO.fltr.indexOf("list") == 0) && nwO.attr("elType") == 0) {
					nwO.attrSet("view", 1);
					fCfg = "", fCfgPref = (celO.fltr == "index" || !itVl.length) ? "" :
														itVl+((celO.fltr[4]==" ")?" ":celO.fltr[4]+" ");
					if(celO.fltr.indexOf("list") == 0)
						for(fCfgAdd = "", off = 0; (iFv=itVl.parse(0,celO.fltr[4],off)).length; )
							fCfgAdd += (fCfgAdd.length?celO.fltr[4]:"") + iFv, fCfg += fCfgAdd + "\n";
					for(var iFv in colLists[itVlId])
						if(fCfg.indexOf(iFv) < 0)
							fCfg += fCfgPref + iFv + "\n";
					nwO.attrSet("cfg", fCfg);
				}
				// Highlighting
				nwlO.attrSet("backColor","").attrSet("font","Arial 11");
				if((tVl1=itHighl(celO,itVl)).length) {
					if((tVl=tVl1.parse(2,":")).length)	nwlO.attrSet("backColor", tVl);
					if((tVl=tVl1.parse(3,":")).length)	nwlO.attrSet("font", tVl);
				}
				// Value
				if(celO != null && celO.tp.parse(0,":") == "file") {
					//  Size appending
					for(tVl2 = "", off = 0; (tVl=itVl.parseLine(0,off)).length; )
						tVl2 += (tVl2.length?"\n":"") + tVl + ";;" + (getFileFIt(itVlId,celO,tVl,true)/1024).toPrecision(4) + "KiB";
					itVl = tVl2;

					nwO.attrSet("items", itVl).attrSet("value",itVl.parseLine(0));
					this["fItVal"+itVlId+"_GT"].attrSet("active",itVl.length);
					this["fItVal"+itVlId+"_CL"].attrSet("active",itVl.length);
					this["fItVal"+itVlId+"_LD"].attrSet("value","|||"+celO.tp.parse(3,":")).attrSet("active", itVl.split("\n").length < max(1,celO.tp.parse(1,":").toInt()));
					if(celO.tp.parse(4,":").toInt())
						this["fItVal"+itVlId+"_VW"].attrSet("src", (itVl.parseLine(0).length && (tVl=SYS.UI.mimeGet(itVl.parseLine(0).parse(0,";;"))).indexOf("image/") >= 0)
										? "data:"+tVl+"\n"+ SYS.strEncode(getFileFIt(itVlId,celO),"Base64") : "");
				} else nwO.attrSet((celO.prc.length||itVlId == "ID")?"text":"value", itVl);
				delete nwlO; delete nwO;

				if(itEdFormOff && (itEdFormOff+itEdFormMarg) > geomH)	geomH = itEdFormOff + itEdFormMarg;
			}
			break;
		}
		delete dataTblOneReq;
	}

	toUpdate = toReport = false;
}

if(event.length) {
	itDel_active = itCopy_active = go_reportIt_active = dataTbl_value.length;
	btItEdit_en = ((btEdit_en || btItEdit_value) && dataTbl_value.length);
	if(btItEdit_en)	btItEdit_tipTool = btItEdit_value ? tr("Go to the Table") : tr("Go to the Item");
}

//Representing events process
for(offEv = 0; (sval=event.parse(0,"\n",offEv)).length; ) {
	if(sval == "ws_BtToggleChange:/btItEdit")	{
		toUpdate = true, toCalcCycles = 1;
		// Dynamic filter fields hide/show
		var fClrToEd;
		for(iF = 1; iF < fMax; iF++) {
			tVal = (fClrToEd && iF <= fClrToEd);
			if(this["fltr"+iF].attr("en"))	fClrToEd = iF;
			this["fltrCol"+iF].attrSet("en", tVal); this["fltr"+iF].attrSet("en", tVal);
		}
		if(!btItEdit_en)	fClrToEd = null;
		// Item edition fields show/hide
		wLs = this.nodeList("wdg_");
		for(iW = 0; iW < wLs.length; iW++)
			if(wLs[iW].indexOf("wdg_fItLab") == 0 || wLs[iW].indexOf("wdg_fItVal") == 0)
				this[wLs[iW]].attrSet("en", btItEdit_value);
	}
	else if(sval == "ws_BtRelease:/itAdd") {
		nmLs = vlLs = "";
		//Prepairing the filter values
		for(iF = 0; iF < fMax; iF++) {
			if(!(tVl=this["fltr"+iF].attr("value")).length)	continue;
			nmLs += (nmLs.length?",":"") + "`"+this["fltrCol"+iF].attr("value").match("\\((.+)\\)")[1]+"`";
			vlLs += (vlLs.length?",":"") + "'"+tVl+"'";
		}
		if(nmLs.indexOf("`NAME`") < 0)	{ nmLs += (nmLs.length?",":"") + "`NAME`"; vlLs += (vlLs.length?",":"") + "'"+tr("New item")+"'"; }
		SYS.BD.nodeAt(db,".").SQLReq("INSERT INTO `sh_"+class+"` ("+nmLs+") VALUES ("+vlLs+");");
		toUpdate = true; toCalcCycles = 1;
	}
	else if(sval == "dlg_Apply:/itDel") {
		// Delete files on FS for "file" fields
		dataTblOneReq = SYS.BD.nodeAt(db,".").SQLReq("SELECT `ID`,"+clsLsReq+" FROM `sh_"+class+"` WHERE `ID`='"+dataTbl_value+"';");
		for(iR = 1; iR < dataTblOneReq.length; iR++) {
			if(dataTblOneReq[iR][0] != dataTbl_value) continue;
			for(iC = 0; iC < dataTblOneReq[iR].length; iC++)
				if((itVlNm=dataTblOneReq[0][iC]).indexOf("SP_") == 0 && (celO=clsLsO[itVlNm.slice(3)]) != null &&
						(itVl=dataTblOneReq[iR][iC]) != "<NULL>" && itVl.length &&
						celO.tp.parse(0,":") == "file" && celO.tp.parse(2,":").length)
					for(off = 0; (itVlEl=itVl.parseLine(0,off)).length; )
						SYS.fileRemove(celO.tp.parse(2,":")+"/"+itVlEl);
		}
		delete dataTblOneReq;

		// Delete same the fiels
		SYS.BD.nodeAt(db,".").SQLReq("DELETE FROM `sh_"+class+"` WHERE `ID`='"+dataTbl_value+"';");
		toUpdate = true; toCalcCycles = 1;
	}
	else if(sval == "ws_BtRelease:/itCopy") {
		for(colLs = "", iC = 1; iC < dataTbl[0].length; iC++)
			// Without copying types of the "file" type and the files storage on FS
			if(!(dataTbl[0][iC].indexOf("SP_") == 0 && (celO=clsLsO[dataTbl[0][iC].slice(3)]) != null && celO.tp.parse(0,":") == "file" && celO.tp.parse(4,":").toInt()))
				colLs += (colLs.length?", ":"") + "`"+dataTbl[0][iC]+"`";
		SYS.BD.nodeAt(db,".").SQLReq("INSERT INTO `sh_"+class+"` ("+colLs+") (SELECT "+colLs+" FROM `sh_"+class+"` WHERE `ID` = "+dataTbl_value+");");
		toUpdate = true; toCalcCycles = 1;
	}
	else if((isTbl=(sval.slice(0,12)=="ws_TableEdit")) || (tVl=sval.match("^ws_(LnAccept|TxtAccept|ChkChange):/fItVal(.+)$")).length) {
		if(isTbl)	col = dataTbl[0][sval.parse(0,"_",13).toInt()], row = dataTbl[sval.parse(1,"_",13).toInt()+1][0], toVal = dataTbl_set;
		else {
			col = tVl[2], row = this.fItValID.attr("text"), toVal = this["fItVal"+col].attr("value");
			if(this["fItVal"+col].attr("view") == 1)	toUpdate = true;
		}
		if(toUpdate || colVars[col].fltr.parseLine(1).length || hasProc)	toUpdate = true, toCalcCycles = 1;
		//this.messInfo("TEST 00: col="+col+", row="+row+", toVal="+toVal);
		//SYS.BD.nodeAt(db,".").SQLReq("UPDATE `sh_"+class+"` SET `"+dataTbl[0][col]+"`='"+SYS.strEncode(dataTbl_set,"SQL")+"' WHERE `"+dataTbl[0][0]+"`='"+dataTbl[row+1][0]+"';");
		updReq = "`"+col+"`='"+SYS.strEncode(toVal,"SQL")+"'";
		for(var itID in clsLsO)
			if(itID[0] != "*" && clsLsO[itID].prc.length)
				updReq += ", `SP_"+itID+"`=NULL";
		SYS.BD.nodeAt(db,".").SQLReq("UPDATE `sh_"+class+"` SET "+updReq+" WHERE `"+dataTbl[0][0]+"`='"+row+"';");
	}
	else if(sval.slice(0,22) == "ws_CombChange:/fltrCol") {
		fN = sval.slice(22).toInt();
		fAct = !this["fltrCol"+fN].attr("value").match("\\((.+)\\)")[1].isEVal();
		this["fltr"+fN].attrSet("active", fAct).attrSet("value", "").attrSet("cfg", "");
		if(fAct && (fN+1) < fMax && !this["fltrCol"+(fN+1)].attr("en")) {
			this["fltrCol"+(fN+1)].attrSet("en", true);
			this["fltr"+(fN+1)].attrSet("en", true).attrSet("active", false).attrSet("value", "");
		}
		else if(!fAct) fClrTo = fN+1;

		toUpdate = true; toCalcCycles = 1;
	}
	else if(sval.slice(0,17) == "ws_LnAccept:/fltr")	toUpdate = true, toCalcCycles = 1;
	//File Load
	else if((tVl=sval.match("^ws_BtLoad:/fItVal(.+)_LD$")).length) {
		celO = clsLsO[celId=tVl[1].slice(3)];
		fItVal = (fItValFileLD=this["fItValSP_"+celId+"_LD"]).attr("value");
		dataTblOneReq = SYS.BD.nodeAt(db,".").SQLReq("SELECT `SP_"+celId+"` FROM `sh_"+class+"` WHERE `ID`='"+this.fItValID.attr("text")+"';");
		off = 0; tVl = fItVal.parseLine(0, off);
		fItValFileNm = tVl.parse(2,"|");
		fItValFile = fItVal.slice(off);
		fItValFileSL = this["fItValSP_"+celId];
		if(celO.tp.parse(2,":").length) {
			if(SYS.fileSize(celO.tp.parse(2,":")+"/"+fItValFileNm) > 0) {
				off = fItValFileNm.length; fItValFileExt = fItValFileNm.parseEnd(0, ".", off); fItValFileNm = fItValFileNm.slice(0, off+1);
				for(iF = 2; SYS.fileSize(celO.tp.parse(2,":")+"/"+fItValFileNm+iF+"."+fItValFileExt) > 0; iF++) ;
				fItValFileNm = fItValFileNm+iF+"."+fItValFileExt;
			}
			SYS.fileWrite(celO.tp.parse(2,":")+"/"+fItValFileNm, fItValFile);
			SYS.BD.nodeAt(db,".").SQLReq("UPDATE `sh_"+class+"` SET `SP_"+celId+"`="
					"'"+SYS.strEncode(fItValFileNm+((dataTblOneReq[1][0].length && dataTblOneReq[1][0] != "<NULL>")?"\n"+dataTblOneReq[1][0]:""),"SQL")+"' "
					"WHERE `ID`='"+this.fItValID.attr("text")+"';");
		}
		else {
			if(fItValFileSL.attr("items").indexOf(fItValFileNm) >= 0) {	//Enumeration equal files
				off = fItValFileNm.length; fItValFileExt = fItValFileNm.parseEnd(0, ".", off); fItValFileNm = fItValFileNm.slice(0, off+1);
				for(iF = 2; fItValFileSL.attr("items").indexOf(fItValFileNm+iF+"."+fItValFileExt) >= 0; iF++) ;
				fItValFileNm = fItValFileNm+iF+"."+fItValFileExt;
			}
			SYS.BD.nodeAt(db,".").SQLReq("UPDATE `sh_"+class+"` SET `SP_"+celId+"`="
					"'"+SYS.strEncode(fItValFileNm+"\n"+SYS.strEncode(fItValFile,"Base64")+((dataTblOneReq[1][0].length && dataTblOneReq[1][0] != "<NULL>")?"\n"+dataTblOneReq[1][0]:""),"SQL")+"' "
					"WHERE `ID`='"+this.fItValID.attr("text")+"';");
		}
		fItValFileSL.attrSet("items",fItValFileNm+";;"+(fItValFile.length/1024).toPrecision(4)+"KiB\n"+fItValFileSL.attr("items"))
						.attrSet("value",fItValFileNm+";;"+(fItValFile.length/1024).toPrecision(4)+"KiB");
		delete dataTblOneReq;
		delete fItValFile;
		delete fItVal;
		this["fItValSP_"+celId+"_GT"].attrSet("active",1);
		this["fItValSP_"+celId+"_CL"].attrSet("active",1);
		fItValFileLD.attrSet("value","|||"+celO.tp.parse(3,":")).attrSet("active",fItValFileSL.attr("items").split("\n").length < max(1,celO.tp.parse(1,":").toInt()));

		if(celO.tp.parse(4,":").toInt())
			this["fItValSP_"+celId+"_VW"].attrSet("src", ((tVl=SYS.UI.mimeGet(fItValFileNm)).indexOf("image/") >= 0)
				? "data:"+tVl+"\n"+SYS.strEncode(getFileFIt("SP_"+celId,celO),"Base64") : "");
	}
	//File Clear
	else if((tVl=sval.match("^ws_BtRelease:/fItVal(.+)_CL$")).length) {
		celO = clsLsO[celId=tVl[1].slice(3)];
		fItValFileNm = this["fItValSP_"+celId].attr("value").parse(0,";;");
		dataTblOneReq = SYS.BD.nodeAt(db,".").SQLReq("SELECT `SP_"+celId+"` FROM `sh_"+class+"` WHERE `ID`='"+this.fItValID.attr("text")+"';");
		isFStor = celO.tp.parse(2,":").length;
		for(iF = 0, off = 0; (tVl=dataTblOneReq[1][0].parseLine(0,off)).length; iF++)
			if((isFStor || (iF%2) == 0) && tVl == fItValFileNm) {
				tVl = off - fItValFileNm.length - ((dataTblOneReq[1][0][off-1]=="\n")?1:0);
				if(!isFStor) dataTblOneReq[1][0].parseLine(0, off);
				else SYS.fileRemove(celO.tp.parse(2,":")+"/"+fItValFileNm);
				dataTblOneReq[1][0] = dataTblOneReq[1][0].replace(tVl, off-tVl, "");
				break;
			}
		SYS.BD.nodeAt(db,".").SQLReq("UPDATE `sh_"+class+"` SET `SP_"+celId+"`='"+SYS.strEncode(dataTblOneReq[1][0],"SQL")+"' "
					"WHERE `ID`='"+this.fItValID.attr("text")+"';");

		if(!isFStor) {
			for(iF = 0, off = 0, itVlRez = ""; (itVlEl=dataTblOneReq[1][0].parseLine(0,off)).length; iF++)
				if((iF%2) == 0)	itVlRez += (itVlRez.length?"\n":"") + itVlEl;
		} else itVlRez = dataTblOneReq[1][0];
		delete dataTblOneReq;

		// Size appending
		for(tVl2 = "", off = 0; (tVl=itVlRez.parseLine(0,off)).length; )
			tVl2 += (tVl2.length?"\n":"") + tVl + ";;" + (getFileFIt("SP_"+celId,celO,tVl,true)/1024).toPrecision(4) + "KiB";
		itVlRez = tVl2;

		this["fItValSP_"+celId].attrSet("items",itVlRez).attrSet("value",itVlRez.parseLine(0));
		this["fItValSP_"+celId+"_GT"].attrSet("active",itVlRez.length);
		this["fItValSP_"+celId+"_CL"].attrSet("active",itVlRez.length);

		if(celO.tp.parse(4,":").toInt())
			this["fItValSP_"+celId+"_VW"].attrSet("src", (itVlRez.length && (tVl=SYS.UI.mimeGet(itVlRez.parseLine(0).parse(0,";;"))).indexOf("image/") >= 0)
						? "data:"+tVl+"\n"+SYS.strEncode(getFileFIt("SP_"+celId,celO),"Base64") : "");
	}
	//File Get
	else if((tVl=sval.match("^ws_BtRelease:/fItVal(.+)_GT$")).length && (celO=clsLsO[tVl[1].slice(3)]).tp.parse(0,":") == "file")
		this["fItVal"+tVl[1]+"_GT"].attrSet("value","||"+(tVl2=this["fItVal"+tVl[1]].attr("value").parse(0,";;"))+"|"+SYS.UI.mimeGet(tVl2)+"\n"+getFileFIt(tVl[1],celO));
	//File Select
	else if((tVl=sval.match("^ws_CombChange:/fItVal(.+)$")).length && (celO=clsLsO[tVl[1].slice(3)]).tp.parse(0,":") == "file")
		this["fItVal"+tVl[1]+"_VW"].attrSet("src",((tVl=SYS.UI.mimeGet(this["fItVal"+tVl[1]].attr("value").parse(0,";;"))).indexOf("image/") >= 0)
				? "data:"+tVl+"\n"+SYS.strEncode(getFileFIt(tVl[1],celO),"Base64") : "");
	else if(sval == "ws_BtRelease:/go_reportIt") {
		go_reportIt_report = "<body>\n"
			"<h1>"+tr("%1 item:").replace("%1",classNm_text)+"</h1>\n";
		dataTblOneReq = SYS.BD.nodeAt(db,".").SQLReq("SELECT `ID`,"+clsLsReq+" FROM `sh_"+class+"` WHERE `ID`='"+dataTbl_value+"';");
		for(iR = 1; iR < dataTblOneReq.length; iR++) {
			if(dataTblOneReq[iR][0] != dataTbl_value) continue;
			for(iC = 0; iC < dataTblOneReq[iR].length; iC++) {
				itVlNm = itVlId = dataTblOneReq[0][iC];
				celO = null;
				if((itVlNm.indexOf("SP_") == 0 && !(celO=clsLsO[itVlNm.slice(3)]).isEVal()) || ((itVlNm == "NAME" || itVlNm == "DSCR") && !(celO=clsLsO["*"+itVlNm]).isEVal()))
					itVlNm = celO.name;
				if((itVl=dataTblOneReq[iR][iC]) == "<NULL>" || !itVl.length) continue;
				if(celO != null && celO.tp.parse(0,":") == "file" && !celO.tp.parse(2,":").length) {
						for(iF = 0, off = 0, itVlRez = ""; (itVlEl=itVl.parseLine(0,off)).length; iF++)
							if((iF%2) == 0)	itVlRez += (itVlRez.length?"\n":"") + itVlEl;
						itVl = itVlRez;
					}
				go_reportIt_report += "<span style='font: bold 15px/25px Arial, sans-serif'>"+SYS.strEncode(itVlNm,"HTML")+":</span>";
				if(colTps[iC] == "t")	go_reportIt_report += "<br/>";
				// Inserting images
				if(celO == null || celO.tp.parse(0,":") != "file")
					go_reportIt_report += "<span style='white-space: pre-wrap;"+((colTps[iC] == "t")?"":" margin-left: 3pt;")+"'>"+
							SYS.strEncode(itVl,"HTML").replace(new RegExp("(http|https|ftp)://(\\S+)","g"),"<a target='_blank' href='$1://$2'>$2</a>")+
							"</span><br/>";
				else for(off = 0; (itVlEl=itVl.parseLine(0,off)).length; ) {
					go_reportIt_report += "<span>"+SYS.strEncode(itVlEl,"HTML")+"</span><br/>";
					if((tVl=SYS.UI.mimeGet(itVlEl)).indexOf("image/") >= 0)
						go_reportIt_report += "<img src='data:"+tVl+";base64,"+SYS.strEncode(getFileFIt(itVlId,celO,itVlEl),"Base64")+"' /><br/>";
				}
			}
			break;
		}
		delete dataTblOneReq;
		go_reportIt_report += "</body>";

		this.attrSet("event", this.attr("event")+"usr_report:/go_reportIt\n");
	}
	else if(sval == "ws_BtRelease:/go_report") {
		toUpdate = toReport = true, toCalcCycles = 1;

		this.attrSet("event", this.attr("event")+"usr_report:/go_report\n");
	}
}

//Clearing the filter up to fClrTo
if(fClrTo >= 0) {
	for(iF = fMax-1; iF >= fClrTo; iF--) {
		if(iF) { this["fltrCol"+iF].attrSet("en", false); this["fltr"+iF].attrSet("en", false); }
		this["fltrCol"+iF].attrSet("value", tr("Disabled")); this["fltr"+iF].attrSet("active", false).attrSet("value", "");
	}
	fClrTo = -1; toUpdate = true; toCalcCycles = 1;
}

if(toCalcCycles > 0.1) {
	this.attrSet("event", this.attr("event")+"usr_calc\n");	//!!!! Just to calc in the next session cycle for update
	toCalcCycles = max(0, toCalcCycles-1);
}