#
#		ITSV GmbH
#	CCDB - Command and Control Database
#
#	FILE:			dquermfile_personinfo.txt
#	DESCRIPTION:	DQUERY definition for CCDB DQUERY "personinfo"
#
@querytitle	Informationen zu einer Person
@querydescription	
@group	GROUPS
@paramnames	uskurzz:uskurzz
@formpagetitle	Informationen zu einer Person
@formitems.paramformextension	<ul><li><a href="/dquery?dataname=addperson">Neue Person hinzufügen</a></li></ul>
@querytype	dbselect
@sql	select (CASE WHEN ua.USKURZZ is not null THEN ua.USKURZZ ELSE ::uskurzz:: END) as "Kurzzeichen", 
		       (CASE WHEN ua.ATTNAME is not null THEN ua.ATTNAME ELSE an.ATTNAME END) as "Eigenschaft", 
			   (CASE WHEN an.ATTDESC is not null THEN an.ATTDESC ELSE an.ATTNAME END) as "Eigenschaftsbezeichnung", 
		       (CASE WHEN ua.ATTWERT is null THEN '' ELSE ua.ATTWERT  END) as "Wert", 
		       CONCAT('{"action": "',(CASE WHEN ua.ATTWERT is null THEN '' ELSE 'DELETE' END),
		              '", "attribute": "',ua.ATTNAME,'", "key": "',ua.USKURZZ,'"}')  as "DeleteAction"
		from (select RWNAME as ATTNAME, RWVALUE as ATTDESC
		                from CCRW ar
		              where ar.RWTYP='PERSATTNAME' and RWPARENT='PERSATTNAMES') an
		left outer join CCVUSATT ua on ua.ATTNAME=an.ATTNAME and ua.USKURZZ=::uskurzz::
		order by ua.ATTRANG asc
@title	Personen-Informationen über [[personname]]
@post_query	
	that.sr = aux.select_result_data(that.result,{select: {cmd: 'select', colnum: 3, where: 'rowvalue[1]=="NAME"'}});
	if (that.sr.error) {
		that.result.setResultAttribute('personname','Fehler: '+aux.objTxt(that.sr.error));
	} else if (that.sr.getRowCount()<1) {
		that.result.setResultAttribute('personname','NAME nicht gefunden');
	} else {
		that.result.setResultAttribute('personname',that.sr.getCellValue(0,0));
	}
	let c4v,c4o;
	for (var ri=0; ri<that.result.getRowCount(); ri++) {
		c4v = that.result.getCellValue(ri,4)
		c4o = aux.txtObjDecode(c4v);
		if (c4o.error) {
			aux.error_callback(that.callback,c4o.error,"Error parsing: \""+c4v+"\" in Row "+ri);
			break;
		}
		logger.debug("personinfo.row="+ri+".c4o: "+aux.objTxt(c4o));
		that.result.setCellValue(ri,4,{ value: c4o });
	}
@bottomtext
	<h3>Weitere Informationen</h3>
	<ul>
		<li><a href="/dquery?dataname=qryGroupMemberships&uskurzz={{uskurzz}}">Gruppen, in denen [[personname]] Mitglied ist, anzeigen</a></li>
		<li><a href="/dquery?dataname=addpersongroup&uskurzz={{uskurzz}}">Die Person [[personname]] zu einer Gruppe hinzufügen</a></li>
		<li><a href="/dquery?dataname=konvertpersonoegk&uskurzz={{uskurzz}}">Die Person [[personname]] von GKK zu ÖGK konvertieren (Email,Telefon) </a></li>
	</ul>
@decoration.decorate_colcell.3					$CONTROL:werteingabe:c3options
@decoration.debug								false
@c3options.control_type							edit
@c3options.value								@@celldata@@
@c3options.url									/dquery?dataname=performObjectAction&objtype=person&key=@@row.Kurzzeichen@@&attribute=@@row.Eigenschaft@@&action=SET
@c3options.submitlabel							Speichern
@c3options.textinput_fieldname					value
@c3options.size									80
@decoration.decorate_colcell.4.hyperlink.href	/dquery?dataname=performObjectAction&objtype=person&key=@@row.Kurzzeichen@@&attribute=@@row.Eigenschaft@@&action=@@row.DeleteAction.action@@
@decoration.decorate_colcell.4.hyperlink.title	@@row.DeleteAction.action@@ Personen-Attribut @@row.DeleteAction.attribute@@ für Person USKURZZ=@@row.Kurzzeichen@@
@decoration.decorate_colcell.4.value			Löschen
@decoration.debug	false