<?php
@session_start();
include_once( "f_admin.php" );
include_once( "f_wfl.php" );
include_once( "w_fkt.php" );


$mandant_name = $_SESSION[ "mandant_name" ];

if ( isset( $_GET[ "cmd" ] ) )
{
	$kommando					= $_GET[ "cmd" ];					// _GET wird über die URL übergeben
}
else
{
	$kommando					= "";
}
if ( isset( $_GET[ "mandant_name" ] ) )
{
	$mandant_name				= urldecode( $_GET[ "mandant_name" ] );			// _POST wird als Formularelement übergeben
}
if ( isset( $_GET[ "alpha_01" ] ) )
{
	$alpha_01					= $_GET[ "alpha_01" ];
}
if ( isset( $_GET[ "alpha_02" ] ) )
{
	$alpha_02					= $_GET[ "alpha_02" ];
}
if ( isset( $_GET[ "alpha_03" ] ) )
{
	$alpha_03					= $_GET[ "alpha_03" ];
}
if ( isset( $_GET[ "alpha_04" ] ) )
{
	$alpha_04					= $_GET[ "alpha_04" ];
}
if ( isset( $_GET[ "alpha_05" ] ) )
{
	$alpha_05					= $_GET[ "alpha_05" ];
}
if ( isset( $_GET[ "alpha_06" ] ) )
{
	$alpha_06					= $_GET[ "alpha_06" ];
}
if ( isset( $_GET[ "alpha_07" ] ) )
{
	$alpha_07					= $_GET[ "alpha_07" ];
}
if ( isset( $_GET[ "alpha_08" ] ) )
{
	$alpha_08					= $_GET[ "alpha_08" ];
}
if ( isset( $_GET[ "alpha_09" ] ) )
{
	$alpha_09					= $_GET[ "alpha_09" ];
}
if ( isset( $_GET[ "alpha_10" ] ) )
{
	$alpha_10					= $_GET[ "alpha_10" ];
}
if ( isset( $_GET[ "alpha_11" ] ) )
{
	$alpha_11					= $_GET[ "alpha_11" ];
}
if ( isset( $_GET[ "alpha_12" ] ) )
{
	$alpha_12					= $_GET[ "alpha_12" ];
}
if ( isset( $_GET[ "alpha_13" ] ) )
{
	$alpha_13					= $_GET[ "alpha_13" ];
}
if ( isset( $_GET[ "alpha_14" ] ) )
{
	$alpha_14					= $_GET[ "alpha_14" ];
}
if ( isset( $_GET[ "alpha_15" ] ) )
{
	$alpha_15					= $_GET[ "alpha_15" ];
}
if ( isset( $_GET[ "alpha_16" ] ) )
{
	$alpha_16					= $_GET[ "alpha_16" ];
}
if ( isset( $_GET[ "alpha_17" ] ) )
{
	$alpha_17					= $_GET[ "alpha_17" ];
}
if ( isset( $_GET[ "alpha_18" ] ) )
{
	$alpha_18					= $_GET[ "alpha_18" ];
}
if ( isset( $_GET[ "alpha_19" ] ) )
{
	$alpha_19					= $_GET[ "alpha_19" ];
}
if ( isset( $_GET[ "alpha_20" ] ) )
{
	$alpha_20					= $_GET[ "alpha_20" ];
}
if ( isset( $_GET[ "aufgerufen" ] ) )
{
	$aufgerufen					= $_GET[ "aufgerufen" ];
}




if ( isset( $_POST[ "mandant_name" ] ) )
{
	$mandant_name				= $_POST[ "mandant_name" ];			// _POST wird als Formularelement übergeben
}
if ( isset( $_POST[ "aufgerufen" ] ) )
{
	$aufgerufen					= $_POST[ "aufgerufen" ];
}
if ( isset( $_POST[ "alpha_01" ] ) )
{
	$alpha_01					= $_POST[ "alpha_01" ];
}
if ( isset( $_POST[ "alpha_02" ] ) )
{
	$alpha_02					= $_POST[ "alpha_02" ];
}
if ( isset( $_POST[ "alpha_03" ] ) )
{
	$alpha_03					= $_POST[ "alpha_03" ];
}
if ( isset( $_POST[ "alpha_04" ] ) )
{
	$alpha_04					= $_POST[ "alpha_04" ];
}
if ( isset( $_POST[ "alpha_05" ] ) )
{
	$alpha_05					= $_POST[ "alpha_05" ];
}
if ( isset( $_POST[ "alpha_06" ] ) )
{
	$alpha_06					= $_POST[ "alpha_06" ];
}
if ( isset( $_POST[ "alpha_07" ] ) )
{
	$alpha_07					= $_POST[ "alpha_07" ];
}
if ( isset( $_POST[ "alpha_08" ] ) )
{
	$alpha_08					= $_POST[ "alpha_08" ];
}
if ( isset( $_POST[ "alpha_09" ] ) )
{
	$alpha_09					= $_POST[ "alpha_09" ];
}
if ( isset( $_POST[ "alpha_10" ] ) )
{
	$alpha_10					= $_POST[ "alpha_10" ];
}
if ( isset( $_POST[ "alpha_11" ] ) )
{
	$alpha_11					= $_POST[ "alpha_11" ];
}
if ( isset( $_POST[ "alpha_12" ] ) )
{
	$alpha_12					= $_POST[ "alpha_12" ];
}
if ( isset( $_POST[ "alpha_13" ] ) )
{
	$alpha_13					= $_POST[ "alpha_13" ];
}
if ( isset( $_POST[ "alpha_14" ] ) )
{
	$alpha_14					= $_POST[ "alpha_14" ];
}
if ( isset( $_POST[ "alpha_15" ] ) )
{
	$alpha_15					= $_POST[ "alpha_15" ];
}
if ( isset( $_POST[ "alpha_16" ] ) )
{
	$alpha_16					= $_POST[ "alpha_16" ];
}
if ( isset( $_POST[ "alpha_17" ] ) )
{
	$alpha_17					= $_POST[ "alpha_17" ];
}
if ( isset( $_POST[ "alpha_18" ] ) )
{
	$alpha_18					= $_POST[ "alpha_18" ];
}
if ( isset( $_POST[ "alpha_19" ] ) )
{
	$alpha_19					= $_POST[ "alpha_19" ];
}
if ( isset( $_POST[ "alpha_20" ] ) )
{
	$alpha_20					= $_POST[ "alpha_20" ];
}



if ( isset( $_POST[ "alpha_05_c" ] ) )
{
	$alpha_05_c					= $_POST[ "alpha_05_c" ];
}
if ( isset( $_POST[ "alpha_06_c" ] ) )
{
	$alpha_06_c					= $_POST[ "alpha_06_c" ];
}
if ( isset( $_POST[ "alpha_07_c" ] ) )
{
	$alpha_07_c					= $_POST[ "alpha_07_c" ];
}
if ( isset( $_POST[ "alpha_08_c" ] ) )
{
	$alpha_08_c					= $_POST[ "alpha_08_c" ];
}
if ( isset( $_POST[ "alpha_09_c" ] ) )
{
	$alpha_09_c					= $_POST[ "alpha_09_c" ];
}
if ( isset( $_POST[ "alpha_10_c" ] ) )
{
	$alpha_10_c					= $_POST[ "alpha_10_c" ];
}
if ( isset( $_POST[ "alpha_11_c" ] ) )
{
	$alpha_11_c					= $_POST[ "alpha_11_c" ];
}
if ( isset( $_POST[ "alpha_12_c" ] ) )
{
	$alpha_12_c					= $_POST[ "alpha_12_c" ];
}
if ( isset( $_POST[ "alpha_13_c" ] ) )
{
	$alpha_13_c					= $_POST[ "alpha_13_c" ];
}
if ( isset( $_POST[ "alpha_14_c" ] ) )
{
	$alpha_14_c					= $_POST[ "alpha_14_c" ];
}

if ( isset( $_POST[ "alpha_05_b" ] ) )
{
	$alpha_05_b					= $_POST[ "alpha_05_b" ];
}
if ( isset( $_POST[ "alpha_06_b" ] ) )
{
	$alpha_06_b					= $_POST[ "alpha_06_b" ];
}
if ( isset( $_POST[ "alpha_07_b" ] ) )
{
	$alpha_07_b					= $_POST[ "alpha_07_b" ];
}
if ( isset( $_POST[ "alpha_08_b" ] ) )
{
	$alpha_08_b					= $_POST[ "alpha_08_b" ];
}
if ( isset( $_POST[ "alpha_09_b" ] ) )
{
	$alpha_09_b					= $_POST[ "alpha_09_b" ];
}
if ( isset( $_POST[ "alpha_10_b" ] ) )
{
	$alpha_10_b					= $_POST[ "alpha_10_b" ];
}
if ( isset( $_POST[ "alpha_11_b" ] ) )
{
	$alpha_11_b					= $_POST[ "alpha_11_b" ];
}
if ( isset( $_POST[ "alpha_12_b" ] ) )
{
	$alpha_12_b					= $_POST[ "alpha_12_b" ];
}
if ( isset( $_POST[ "alpha_13_b" ] ) )
{
	$alpha_13_b					= $_POST[ "alpha_13_b" ];
}
if ( isset( $_POST[ "alpha_14_b" ] ) )
{
	$alpha_14_b					= $_POST[ "alpha_14_b" ];
}



if ( isset( $_POST[ "alpha_05_e" ] ) )
{
	$alpha_05_e					= $_POST[ "alpha_05_e" ];
}
if ( isset( $_POST[ "alpha_06_e" ] ) )
{
	$alpha_06_e					= $_POST[ "alpha_06_e" ];
}
if ( isset( $_POST[ "alpha_07_e" ] ) )
{
	$alpha_07_e					= $_POST[ "alpha_07_e" ];
}
if ( isset( $_POST[ "alpha_08_e" ] ) )
{
	$alpha_08_e					= $_POST[ "alpha_08_e" ];
}
if ( isset( $_POST[ "alpha_09_e" ] ) )
{
	$alpha_09_e					= $_POST[ "alpha_09_e" ];
}
if ( isset( $_POST[ "alpha_10_e" ] ) )
{
	$alpha_10_e					= $_POST[ "alpha_10_e" ];
}
if ( isset( $_POST[ "alpha_11_e" ] ) )
{
	$alpha_11_e					= $_POST[ "alpha_11_e" ];
}
if ( isset( $_POST[ "alpha_12_e" ] ) )
{
	$alpha_12_e					= $_POST[ "alpha_12_e" ];
}
if ( isset( $_POST[ "alpha_13_e" ] ) )
{
	$alpha_13_e					= $_POST[ "alpha_13_e" ];
}
if ( isset( $_POST[ "alpha_14_e" ] ) )
{
	$alpha_14_e					= $_POST[ "alpha_14_e" ];
}

if ( isset( $_POST[ "alpha_05_a" ] ) )
{
	$alpha_05_a					= $_POST[ "alpha_05_a" ];
}
if ( isset( $_POST[ "alpha_06_a" ] ) )
{
	$alpha_06_a					= $_POST[ "alpha_06_a" ];
}
if ( isset( $_POST[ "alpha_07_a" ] ) )
{
	$alpha_07_a					= $_POST[ "alpha_07_a" ];
}
if ( isset( $_POST[ "alpha_08_a" ] ) )
{
	$alpha_08_a					= $_POST[ "alpha_08_a" ];
}
if ( isset( $_POST[ "alpha_09_a" ] ) )
{
	$alpha_09_a					= $_POST[ "alpha_09_a" ];
}
if ( isset( $_POST[ "alpha_10_a" ] ) )
{
	$alpha_10_a					= $_POST[ "alpha_10_a" ];
}
if ( isset( $_POST[ "alpha_11_a" ] ) )
{
	$alpha_11_a					= $_POST[ "alpha_11_a" ];
}
if ( isset( $_POST[ "alpha_12_a" ] ) )
{
	$alpha_12_a					= $_POST[ "alpha_12_a" ];
}
if ( isset( $_POST[ "alpha_13_a" ] ) )
{
	$alpha_13_a					= $_POST[ "alpha_13_a" ];
}
if ( isset( $_POST[ "alpha_14_a" ] ) )
{
	$alpha_14_a					= $_POST[ "alpha_14_a" ];
}




if ( ( $_SESSION[ "wfl" ] != "konf_0" ) && ( $kommando == "" ) && ( $_SESSION[ "wfl" ] != "schritt_0" ) && ( $_SESSION[ "wfl" ] != "detail_0" ) )
{
	header( "Location: /ca/us_uebersicht.php" );
}






if ( $kommando == "" )
{
	$exec = besitzt_benutzer_systemrecht( $_SESSION[ "mandant_name" ], $_SESSION[ "benutzer_anmeldename" ], "ADMINISTRATOR" );
	
	if ( $exec[ 0 ] != 1 )
	{
		header( "Location: us_uebersicht.php" );
	}
	////////////////////////////////////////
	// Javascript-Dateien
	$_SESSION[ "javascript_dateien" ] = "jquery.dataTables.min.js|globalize.js|globalize.culture.de-DE.js";
	////////////////////////////////////////
	
	////////////////////////////////////////
	// Javascript-Startup
	$_SESSION[ "javascript_startup" ] = "";
	////////////////////////////////////////
	
	////////////////////////////////////////
	// CSS-Dateien
	$_SESSION[ "css_dateien" ] = "jquery.dataTables_themeroller.css|jquery.dataTables.min.css";
	////////////////////////////////////////
	
	
	
	
	$_SESSION[ "title" ] = "Workflowkonfiguration";
	include( 'ssi_header.php' );
	$_SESSION[ "title" ] = "";
	
	////////////////////////////////////////
	// Javascript-Dateien
	$_SESSION[ "javascript_dateien" ] = "";
	////////////////////////////////////////
	
	////////////////////////////////////////
	// Javascript-Startup
	$_SESSION[ "javascript_startup" ] = "";
	////////////////////////////////////////
	
	////////////////////////////////////////
	// CSS-Dateien
	$_SESSION[ "css_dateien" ] = "";
	////////////////////////////////////////
	
	
	
		
	echo "<div style='margin-left:20px; margin-top:12px; padding-bottom:30px;  min-height:750px;'>";
	
	
	if ( $_SESSION[ "wfl" ] == "konf_0" )
	{
		$_SESSION[ "wfl" ] = "";
		
		echo "<input type='button' value='Workflow anlegen' onclick='$( \"#ergebnis_2\" ).load( \"w_wfl.php?cmd=workflow_anlegen&mandant_name=".urlencode( $_SESSION[ "mandant_name" ] )."\" )' /><div name='ergebnis_2' id='ergebnis_2' style=' margin-top:10px;' ></div><div name='ergebnis_3' id='ergebnis_3' style=' margin-top:10px;' >".$_SESSION[ 'wfl_meld' ]."</div><hr /><h3>Liste angelegter Workflows</h3>";
		
		$_SESSION[ "wfl_meld" ] = "";
		
		$ergebnis = liefere_workflows( $_SESSION[ "mandant_name" ] );
		if ( $ergebnis[ 0 ] > 0 )
		{
			$html = "<table id='wfl_basis' class='display compact' ><thead><tr><th>Workflow-ID</th><th>Workflow-Name</th><th>Dokumentart</th><th>Start-Art</th><th>Start-Maske</th><th>Status</th><th>Protokoll anlegen</th><th>Aktionen</th></tr></thead>";
			
			$html = $html."<tbody>";
			
			foreach( $ergebnis[ 2 ] as $wfl )
			{
				$dokart = liefere_dokartinformationen( $_SESSION[ "mandant_name" ], $wfl[ "dokart_kuerzel" ], false );
				
				$html = $html."<tr><td>".$wfl[ "workflow_id" ]."</td><td>".$wfl[ "workflow_name" ]."</td><td>".$dokart[ 2 ][ "dokart_name" ]." (".$wfl[ "dokart_kuerzel" ].")</td><td>".$wfl[ "start_art" ]."</td><td>".$wfl[ "start_maske" ]."</td><td>".$wfl[ "status" ]."</td><td>".$wfl[ "protokoll" ]."</td><td><input type='button' value='löschen' onclick='wfl_loeschen( ".$wfl[ "workflow_id" ].", \"".$wfl[ "workflow_name" ]."\" );' /><input type='button' value='bearbeiten' onclick='$( \"#ergebnis_2\" ).load( \"w_wfl.php?cmd=wfl_bearbeiten&mandant_name=".urlencode( $_SESSION[ "mandant_name" ] )."&alpha_01=".urlencode( $wfl[ "workflow_name" ] )."\" );' /></td></tr>";
				
			}
			$html = $html."</tbody></table>";
			$skript = "<script>function wfl_loeschen( workflow_id, workflow_name ) {  $( \"#ergebnis_2\" ).html( \"<form action=\u0022w_wfl.php\u0022><input type='hidden' name='cmd' value='workflow_loeschen' /><input type='hidden' name='mandant_name' value='".$_SESSION[ "mandant_name" ]."' /><input type='hidden' name='alpha_01' value='\"+workflow_name+\"' /><p>Wollen Sie wirklich den Workflow \"+workflow_name+\" mit der ID \"+workflow_id+\" löschen?</p><input type='submit' value='OK' /><input type='button' value='Abbrechen' onclick='$( \u0022#ergebnis_2\u0022 ).html( \u0022\u0022 );' /></form>\" ); } $('#wfl_basis').dataTable({ 'language': { 'url': 'js/dataTables.german.lang' }, 'bJQueryUI': true, 'searching': false, 'lengthchange':false, 'ordering':false, 'paging':false });</script>";
			echo $html.$skript;
			
		}
		else
		{
			echo "Es wurden keine Workflows gefunden.";
		}
		
		//workflow_id, workflow_name, dokart_kuerzel, start_art, protokoll
		
		//echo "<div name='maske' id='maske' style=' padding-left: 12px; vertical-align:top; margin-top:10px;' ></div>		<div name='m_konf' id='m_konf' style=' padding-left: 12px; vertical-align:top;  margin-top:10px;' ></div><div name='p_konf' id='p_konf' style=' padding-left: 12px; vertical-align:top;   margin-top:10px;' ></div><div name='ergebnis_1' id='ergebnis_1' style=' padding-left: 12px; vertical-align:top;  margin-top:10px;' ></div>";
	
		
		
		
		echo "</div>";
		
		include( 'ssi_footer.php' );
		
		
	}
	
	if ( $_SESSION[ "wfl" ] == "schritt_0" )
	{
		$_SESSION[ "wfl" ]			= "";
		
		//$_SESSION[ "wfl_meld" ]		= "";
		
		$ergebnis = liefere_workflows( $_SESSION[ "mandant_name" ] );
		
		if ( $ergebnis[ 0 ] > 0 )
		{
			foreach( $ergebnis[ 2 ] as $wf )
			{
				$options = $options."<option>".$wf[ "workflow_name" ]."</option>";
			}
			
			$html = "<h2>Masken-Basiskonfiguration</h2>
						<div style='display:inline; '>
							<select size='20' style='width:220px;' onchange='
							$(\"#masken\").load( \"w_wfl.php?cmd=liefere_masken&alpha_02=0&alpha_01=\"+encodeURIComponent( this.value ) +\"&mandant_name=".urlencode( $_SESSION[ "mandant_name" ] )."\" ); $(\"#aufgabe\").html( \"\" ); $(\"#optionen\").load(\"w_wfl.php?cmd=liefere_maskenoptionen&alpha_01=\"+encodeURIComponent(this.value)+\"&mandant_name=".urlencode( $_SESSION[ "mandant_name" ] )."\" ); 
							$(\"#information\").html( \"\" ); ' >".$options."</select></div>
						<div style='display:inline;  vertical-align:top; margin-left:15px;' id='masken'>
							<select size='20'  style='width:220px;' ></select></div>
						<div id='information' style='display:inline; position:absolute; vertical-align:top; margin-left:15px;' >
							</div>
						<div id='optionen' style='margin-top:55px;'></div>
						<div id='aufgabe'>".$_SESSION[ "wfl_meld" ]."</div>
					";
			
			$_SESSION[ "wfl_meld" ] = "";
			
			
		}
		else
		{
			$html = "Es wurden keine Workflows gefunden.";
		}
		
		//workflow_id, workflow_name, dokart_kuerzel, start_art, protokoll
		
		
		
		echo $html;
		
		echo "</div>";
		
		include( 'ssi_footer.php' );
		
		
	}
	
	if ( $_SESSION[ "wfl" ] == "detail_0" )
	{
		$_SESSION[ "wfl" ]			= "";
		
		//$_SESSION[ "wfl_meld" ]		= "";
		
		$ergebnis = liefere_workflows( $_SESSION[ "mandant_name" ] );
		
		if ( $ergebnis[ 0 ] > 0 )
		{
			foreach( $ergebnis[ 2 ] as $wf )
			{
				$options = $options."<option>".$wf[ "workflow_name" ]."</option>";
			}
			
			//$(\"#optionen\").load(\"w_wfl.php?cmd=liefere_maskenoptionen&alpha_01=\"+this.value+\"&mandant_name=".urlencode( $_SESSION[ "mandant_name" ] )."\" );
			
			$html = "<h2>Masken-Detailkonfiguration</h2>
						<div style='display:inline; '>
							<select size='20' style='width:220px;' onchange='
							$(\"#masken\").load( \"w_wfl.php?cmd=liefere_masken&alpha_02=1&alpha_01=\"+encodeURIComponent( this.value )+\"&mandant_name=".urlencode( $_SESSION[ "mandant_name" ] )."\" ); $(\"#aufgabe\").html( \"\" ); 
							$(\"#information\").html( \"\" ); ' >".$options."</select></div>
						<div style='display:inline;  vertical-align:top; margin-left:15px;' id='masken'>
							<select size='20'  style='width:220px;' ></select></div>
						<div id='information' style='display:inline; position:absolute; vertical-align:top; margin-left:15px;' >
							</div>
						<div id='optionen' style='margin-top:15px;'></div>
						<div id='aufgabe'>".$_SESSION[ "wfl_meld" ]."</div>
					";
			
			$_SESSION[ "wfl_meld" ] = "";
			
			
		}
		else
		{
			$html = "Es wurden keine Workflows gefunden.";
		}
		
		//workflow_id, workflow_name, dokart_kuerzel, start_art, protokoll
		
		
		
		echo $html;
		
		echo "</div>";
		
		include( 'ssi_footer.php' );
		
		
	}
	
}
else
{
	switch( $kommando )
	{
		case "workflow_anlegen":
			$html = _web_workflow_anlegen( $mandant_name, $aufgerufen, $alpha_01, $alpha_02, $alpha_03, $alpha_04 );
			break;
		case "workflow_loeschen":
			$html = _web_workflow_loeschen( $mandant_name, $alpha_01 );
			break;
		case "wfl_bearbeiten":
			$html = _web_wfl_bearbeiten( $mandant_name, $aufgerufen, $alpha_01, $alpha_02, $alpha_03, $alpha_04, $alpha_05, $alpha_06 );
			break;
		case "liefere_masken":
			$html = _web_liefere_masken( $mandant_name, $alpha_01, $alpha_02 );
			break;
		case "liefere_maskenoptionen":
			$html = _web_liefere_maskenoptionen( $mandant_name,  $alpha_01  );
			break;
		case "maske_anlegen":
			$html = _web_maske_anlegen( $mandant_name, $aufgerufen, $alpha_01, $alpha_02, $alpha_03, $alpha_04, $alpha_16, $alpha_05, $alpha_06, $alpha_07, $alpha_08, $alpha_09,  $alpha_10, $alpha_11, $alpha_12, $alpha_13, $alpha_14, $alpha_05_c, $alpha_06_c, $alpha_07_c, $alpha_08_c, $alpha_09_c, $alpha_10_c, $alpha_11_c, $alpha_12_c, $alpha_13_c, $alpha_14_c, $alpha_05_b, $alpha_06_b, $alpha_07_b, $alpha_08_b, $alpha_09_b, $alpha_10_b, $alpha_11_b, $alpha_12_b, $alpha_13_b, $alpha_14_b, $alpha_05_e, $alpha_06_e, $alpha_07_e, $alpha_08_e, $alpha_09_e, $alpha_10_e, $alpha_11_e, $alpha_12_e, $alpha_13_e, $alpha_14_e, $alpha_05_a, $alpha_06_a, $alpha_07_a, $alpha_08_a, $alpha_09_a, $alpha_10_a, $alpha_11_a, $alpha_12_a, $alpha_13_a, $alpha_14_a );
			break;
		case "liefere_maskenoptionen_2":
			$html = _web_liefere_maskenoptionen_2( $mandant_name, $alpha_01, $alpha_02 );
			break;
		case "loesche_maske":
			$html = _web_loesche_maske( $mandant_name, $aufgerufen, $alpha_01, $alpha_02 );
			break;
		case "aendere_maske":
			$html = _web_aendere_maske( $mandant_name, $aufgerufen, $alpha_01, $alpha_02, $alpha_03, $alpha_16, $alpha_04, $alpha_05, $alpha_06, $alpha_07, $alpha_08, $alpha_09,  $alpha_10, $alpha_11, $alpha_12, $alpha_13, $alpha_14, $alpha_15,$alpha_05_c, $alpha_06_c, $alpha_07_c, $alpha_08_c, $alpha_09_c, $alpha_10_c, $alpha_11_c, $alpha_12_c, $alpha_13_c, $alpha_14_c, $alpha_05_b, $alpha_06_b, $alpha_07_b, $alpha_08_b, $alpha_09_b, $alpha_10_b, $alpha_11_b, $alpha_12_b, $alpha_13_b, $alpha_14_b, $alpha_05_e, $alpha_06_e, $alpha_07_e, $alpha_08_e, $alpha_09_e, $alpha_10_e, $alpha_11_e, $alpha_12_e, $alpha_13_e, $alpha_14_e, $alpha_05_a, $alpha_06_a, $alpha_07_a, $alpha_08_a, $alpha_09_a, $alpha_10_a, $alpha_11_a, $alpha_12_a, $alpha_13_a, $alpha_14_a );
			break;
		case "liefere_maskeninformationen":
			$html = _web_liefere_maskeninformationen( $mandant_name, $alpha_01, $alpha_02 );
			break;
		case "liefere_plugin_liste":
			$html = _web_liefere_plugin_liste( $mandant_name, $alpha_01, $alpha_02 );
			break;
			
			
			
			
			
			
			
	}
	
	echo $html;
}











	function _web_workflow_anlegen( $mandant_name, $aufgerufen, $alpha_01, $alpha_02, $alpha_03, $alpha_04 )
	{
		
		if ( $aufgerufen == "aufgerufen" )
		{
			//xlog( 5, "alpha_01 ".$alpha_01 );
			//xlog( 5, "alpha_02 ".$alpha_02 );
			//xlog( 5, "alpha_03 ".$alpha_03 );
			//xlog( 5, "alpha_04 ".$alpha_03 );
			
			$ergebnis = workflow_anlegen( $_SESSION[ "mandant_name" ], $alpha_01, $alpha_02, $alpha_03, $alpha_04 );
			
			$_SESSION[ "wfl" ] = "konf_0";
			$_SESSION[ "wfl_meld" ] = $ergebnis[ 1 ];
			
			header( "Location: w_wfl.php" );
		}
		else
		{
			
			$ergebnis = liefere_dok_akten_art_liste( $mandant_name, "", false );
			
			
			
			if ( $ergebnis[ 0 ] > 0 )
			{
				foreach( $ergebnis[ 2 ] as $dokart )
				{
					$dokart_options	= $dokart_options."<option value='".$dokart[ "dokart_kuerzel" ]."'>".$dokart[ "dokart_name" ]."</option>";
				}
			}
			$html = "<h3 style='margin-left:15px;'>Workflow anlegen</h3>
						<form name='workflow_anlegen' action='w_wfl.php?cmd=workflow_anlegen&mandant_name=".urlencode( $mandant_name )."' method='post'>
							<input type='hidden' name='aufgerufen' value='aufgerufen' />
							<table border='0' style='font-size:90%; '>
								<tr>
									<td style='width:180px;'>Workflow-Name</td>
									<td ><input type='text' style='height:90%; width:200px;' name='alpha_01' /></td>
									
								</tr>
								<tr>
									<td>Dokumentart</td>
									<td><select name='alpha_02' style='height:90%; width:206px;' >".$dokart_options."</select></td>
								</tr>
								<tr>
									<td>Startart</td>
									<td><select name='alpha_03' style='height:90%; width:206px;'><option>Import eines Dokuments</option><option>manuell</option><option>Einsprungspunkt</option></select></td>
								</tr>
								<tr>
									<td >Workflow-Protokoll anlegen</td>
									<td><input type='checkbox' name='alpha_04' /></td>
								</tr>
								
								
							</table>
							<input type='submit' value='OK'>
							<input type='reset' value='Abbrechen' onclick='$( \"#ergebnis_2\" ).html( \"\" );' >
						</form>";
		}
		
		return $html;
	}
	
	function _web_workflow_loeschen( $mandant_name, $workflow_name )
	{
		//$_SESSION[ "wfl_meld" ] = "Der Workflow ".$workflow_id." wurde gelöscht.";
		$ergebnis = workflow_loeschen( $mandant_name, $workflow_name );
		$_SESSION[ "wfl_meld" ] = $ergebnis[ 1 ];
		$_SESSION[ "wfl" ] = "konf_0";
		header( "Location: w_wfl.php" );
	}
	
	function _web_wfl_bearbeiten( $mandant_name, $aufgerufen, $workflow_name, $alpha_02, $alpha_03, $alpha_04, $alpha_05, $alpha_06 )
	{
		if ( $aufgerufen == "aufgerufen" )
		{
			
			//          workflow_bearbeiten( $mandant_name, $workflow_name, $dokart_kuerzel, $start_art, $protokoll_anlegen );
			
			if ( $alpha_04 == "" )
			{
				$alpha_04 = "nein";
			}
			//workflow_bearbeiten( $mandant_name, $workflow_name, $dokart_kuerzel, $start_art, $status, $start_maske, $protokoll_anlegen )
			$ergebnis = workflow_bearbeiten( $mandant_name, $workflow_name, $alpha_02, $alpha_03, $alpha_05, $alpha_06, $alpha_04 );
			$_SESSION[ "wfl_meld" ] = $ergebnis[ 1 ];
			$_SESSION[ "wfl" ] = "konf_0";
			header( "Location: w_wfl.php" );
		}
		else
		{
			
			$wfl = liefere_workflowinformationen( $mandant_name, $workflow_name );
			
			$ergebnis = liefere_dok_akten_art_liste( $mandant_name, "", false );
			
			if ( $ergebnis[ 0 ] > 0 )
			{
				foreach( $ergebnis[ 2 ] as $dokart )
				{
					if ( $dokart[ "dokart_kuerzel" ] == $wfl[ 2 ][ "dokart_kuerzel" ] )
					{
						$selected = "selected";
					}
					else
					{
						$selected = "";
					}
					$dokart_options	= $dokart_options."<option value='".$dokart[ "dokart_kuerzel" ]."' ".$selected."  >".$dokart[ "dokart_name" ]."</option>";
				}
			}
			
			$a = array( "in Entwicklung", "produktiv", "im Test" );
			
			if ( $wfl[ 2 ][ "status" ] == "in Entwicklung" )
			{
				$ie = " selected ";
			}
			else
			{
				$ie = "";
			}
			
			if ( $wfl[ 2 ][ "status" ] == "produktiv" )
			{
				$p = " selected ";
			}
			else
			{
				$p = "";
			}
			
			if ( $wfl[ 2 ][ "status" ] == "im Test" )
			{
				$t = " selected ";
			}
			else
			{
				$t = "";
			}
			
			if ( $wfl[ 2 ][ "protokoll" ] == "ja" )
			{
				$c = " checked='checked' ";
			}
			else
			{
				$c = "";
			}
			
			$options_a = "<option ".$ie." >in Entwicklung</option><option ".$p." >produktiv</option><option ".$t." >im Test</option>";
			
			$masken = liefere_masken_zu_workflow( $mandant_name, $workflow_name );
			
			foreach( $masken[ 2 ] as $maske )
			{
				$options_b = $options_b."<option ".$sel." value='".$maske[ "maske_id" ]."' >".$maske[ "maske_name" ]."</option>";
			}
			
			$html = "<h3 style='margin-left:15px;'>Workflow bearbeiten</h3>
						<form name='workflow_bearbeiten' action='w_wfl.php?cmd=wfl_bearbeiten&mandant_name=".urlencode( $mandant_name )."' method='post'>
							<input type='hidden' name='aufgerufen' value='aufgerufen' />
							<input type='hidden' name='alpha_01' value='".$workflow_name."' />
							<table border='0' style='font-size:90%; '>
								<tr>
									<td style='width:180px;'>Workflow-Name</td>
									<td ><input type='text' style='height:90%; width:200px;' value='".$workflow_name."' disabled /></td>
									
								</tr>
								<tr>
									<td>Dokumentart</td>
									<td><select name='alpha_02' style='height:90%; width:206px;' >".$dokart_options."</select></td>
								</tr>
								<tr>
									<td>Startart</td>
									<td><select name='alpha_03' style='height:90%; width:206px;'><option>Import eines Dokuments</option><option>manuell</option><option>Einsprungspunkt</option></select></td>
								</tr>
								<tr>
									<td >Status</td>
									<td><select name='alpha_05' style='height:90%; width:206px;' >".$options_a."</select></td>
								</tr>
								<tr>
									<td >Start-Maske</td>
									<td><select  name='alpha_06' style='height:90%; width:206px;' >".$options_b."</select></td>
								</tr>
								<tr>
									<td >Workflow-Protokoll anlegen</td>
									<td><input type='checkbox' name='alpha_04' value='ja' ".$c." /></td>
								</tr>
								
								
							</table>
							<input type='submit' value='OK'>
							<input type='reset' value='Abbrechen' onclick='$( \"#ergebnis_2\" ).html( \"\" );' >
						</form>";
			return $html;
		}
		
		
	}
	
	function _web_liefere_masken( $mandant_name, $workflow_name, $js )
	{
		switch ( $js )
		{
			case "0":
				$onclick = "$(\"#aufgabe\").html(\"\" ); $(\"#optionen\").load(\"w_wfl.php?cmd=liefere_maskenoptionen_2&alpha_01=".urlencode( $workflow_name )."&mandant_name=".urlencode( $_SESSION[ "mandant_name" ] )."&alpha_02=\"+encodeURIComponent( this.value ) ); $(\"#information\").load( \"w_wfl.php?cmd=liefere_maskeninformationen&alpha_01=".urlencode( $workflow_name )."&mandant_name=".urlencode( $_SESSION[ "mandant_name" ] )."&alpha_02=\"+encodeURIComponent( this.value ) );";
				break;
			case "1":
				$onclick = "$(\"#information\").load(\"w_wfl.php?cmd=liefere_plugin_liste&alpha_01=".urlencode( $workflow_name )."&mandant_name=".urlencode( $_SESSION[ "mandant_name" ] )."&alpha_02=\"+encodeURIComponent( this.value ) ); $(\"#aufgabe\").html(\"\" ); ";
				break;
		}
		
		$m = liefere_masken_zu_workflow( $mandant_name, $workflow_name );
		
		if ( $m[ 0 ] > 0 )
		{
			//$html = "Es wurden ".$m[ 0 ]." Masken gefunden.";
			
			foreach( $m[ 2 ] as $maske )
			{
				$options = $options."<option>".$maske[ "maske_name" ]."</option>";
			}
			
			$html = "<select size='20'  style='width:220px;'  onclick='".$onclick."' >".$options."</select>";
			
		}
		else
		{
			$html = "<select size='20'  style='width:220px;' ></select>";
		}
		
		return $html;
	}
	
	function _web_liefere_maskenoptionen( $mandant_name, $workflow_name )
	{
		$html = "<input type='button' value='Maske anlegen' style='display:inline; margin-left: 0px;' onclick='$(\"#aufgabe\").load( \"w_wfl.php?cmd=maske_anlegen&alpha_01=".urlencode( $workflow_name )."\" );'  />"; //<input type='button' value='Maske löschen' style='display:inline; margin-left: 15px;' /><input type='button' value='Maske bearbeiten' style='display:inline;  margin-left: 15px;' />";
		
		
		return $html;
	}
	
	function _web_maske_anlegen( $mandant_name, $aufgerufen, $workflow_name, $maske_name, $maske_default_empfaenger, $maske_default_folgemaske_id, $maske_default_frist, $plugin_01, $plugin_02 = "", $plugin_03 = "", $plugin_04 = "", $plugin_05 = "",  $plugin_06 = "", $plugin_07 = "", $plugin_08 = "", $plugin_09 = "", $plugin_10 = "", $p01_c = "", $p02_c = "", $p03_c = "", $p04_c = "", $p05_c = "", $p06_c = "", $p07_c = "", $p08_c = "", $p09_c = "", $p10_c = "", $p01_b = "", $p02_b = "", $p03_b = "", $p04_b = "", $p05_b = "", $p06_b = "", $p07_b = "", $p08_b = "", $p09_b = "", $p10_b = "", $p01_e = "", $p02_e = "", $p03_e = "", $p04_e = "", $p05_e = "", $p06_e = "", $p07_e = "", $p08_e = "", $p09_e = "", $p10_e = "", $p01_a = "", $p02_a = "", $p03_a = "", $p04_a = "", $p05_a = "", $p06_a = "", $p07_a = "", $p08_a = "", $p09_a = "", $p10_a = ""  )
	{
		if ( $aufgerufen == "aufgerufen" )
		{
			if ( strlen( $maske_default_empfaenger ) > 0 )
			{
				if ( strpos( $maske_default_empfaenger, "(" ) === false )
				{
					// Gruppe
					$maske_default_empfaenger_typ			= "g";
				}
				else
				{
					$anfang									= bcadd( strpos( $maske_default_empfaenger, "(" ), 1, 0 );
					$laenge									= bcsub( strpos( $maske_default_empfaenger, ")" ), $anfang, 0 );
					$benutzer_anmelde_name					= substr( $maske_default_empfaenger, $anfang, $laenge );
					
					$maske_default_empfaenger				= $benutzer_anmelde_name;
					$maske_default_empfaenger_typ			= "b";
				}
			}
			
			/*
			xlog( 5, "alpha_01 ".$workflow_name );
			xlog( 5, "alpha_02 ".$maske_name );
			xlog( 5, "alpha_03 ".$maske_default_empfaenger );
			xlog( 5, "         ".$maske_default_empfaenger_typ );
			xlog( 5, "alpha_04 ".$maske_default_folgemaske );
			xlog( 5, "alpha_05 ".$plugin_01 );
			xlog( 5, "alpha_06 ".$plugin_02 );
			xlog( 5, "alpha_07 ".$plugin_03 );
			xlog( 5, "alpha_08 ".$plugin_04 );
			xlog( 5, "alpha_09 ".$plugin_05 );
			xlog( 5, "alpha_10 ".$plugin_06 );
			xlog( 5, "alpha_11 ".$plugin_07 );
			xlog( 5, "alpha_12 ".$plugin_08 );
			xlog( 5, "alpha_13 ".$plugin_09 );
			xlog( 5, "alpha_14 ".$plugin_10 );
			*/
			
			$p01[ "name" ] 			= $plugin_01;
			$p01[ "aufgeklappt" ]	= $p01_c;
			$p01[ "einklappbar" ]	= $p01_e;
			$p01[ "bezeichnung" ]	= $p01_b;
			$p01[ "accordion" ]		= $p01_a;
			
			
			$p02[ "name" ] 			= $plugin_02;
			$p02[ "aufgeklappt" ]	= $p02_c;
			$p02[ "einklappbar" ]	= $p02_e;
			$p02[ "bezeichnung" ]	= $p02_b;
			$p02[ "accordion" ]		= $p02_a;
			
			
			$p03[ "name" ] 			= $plugin_03;
			$p03[ "aufgeklappt" ]	= $p03_c;
			$p03[ "einklappbar" ]	= $p03_e;
			$p03[ "bezeichnung" ]	= $p03_b;
			$p03[ "accordion" ]		= $p03_a;
			
			$p04[ "name" ] 			= $plugin_04;
			$p04[ "aufgeklappt" ]	= $p04_c;
			$p04[ "einklappbar" ]	= $p04_e;
			$p04[ "bezeichnung" ]	= $p04_b;
			$p04[ "accordion" ]		= $p04_a;
			
			
			$p05[ "name" ] 			= $plugin_05;
			$p05[ "aufgeklappt" ]	= $p05_c;
			$p05[ "einklappbar" ]	= $p05_e;
			$p05[ "bezeichnung" ]	= $p05_b;
			$p05[ "accordion" ]		= $p05_a;
			
			
			$p06[ "name" ] 			= $plugin_06;
			$p06[ "aufgeklappt" ]	= $p06_c;
			$p06[ "einklappbar" ]	= $p06_e;
			$p06[ "bezeichnung" ]	= $p06_b;
			$p06[ "accordion" ]		= $p06_a;
			
			$p07[ "name" ] 			= $plugin_07;
			$p07[ "aufgeklappt" ]	= $p07_c;
			$p07[ "einklappbar" ]	= $p07_e;
			$p07[ "bezeichnung" ]	= $p07_b;
			$p07[ "accordion" ]		= $p07_a;
			
			$p08[ "name" ] 			= $plugin_08;
			$p08[ "aufgeklappt" ]	= $p08_c;
			$p08[ "einklappbar" ]	= $p08_e;
			$p08[ "bezeichnung" ]	= $p08_b;
			$p08[ "accordion" ]		= $p08_a;
			
			$p09[ "name" ] 			= $plugin_09;
			$p09[ "aufgeklappt" ]	= $p09_c;
			$p09[ "einklappbar" ]	= $p09_e;
			$p09[ "bezeichnung" ]	= $p09_b;
			$p09[ "accordion" ]		= $p09_a;
			
			$p10[ "name" ] 			= $plugin_10;
			$p10[ "aufgeklappt" ]	= $p10_c;
			$p10[ "einklappbar" ]	= $p10_e;
			$p10[ "bezeichnung" ]	= $p10_b;
			$p10[ "accordion" ]		= $p10_a;
			
			//xlog( 4, json_encode( $p01 ) );
			
			$ergebnis = erstelle_maske( $mandant_name, $workflow_name, $maske_name, $maske_default_empfaenger, $maske_default_empfaenger_typ, $maske_default_folgemaske_id, $maske_default_frist, $p01, $p02, $p03, $p04, $p05,  $p06, $p07, $p08, $p09, $p10 );
			
			
			//$ergebnis = workflow_anlegen( $_SESSION[ "mandant_name6 ], $alpha_01, $alpha_02, $alpha_03, $alpha_04 );
			
			$_SESSION[ "wfl" ] = "schritt_0";
			$_SESSION[ "wfl_meld" ] = $ergebnis[ 1 ];
			
			header( "Location: w_wfl.php" );
		}
		else
		{
			
			$wfl_plugins = liefere_wertemenge_elemente( $mandant_name, "wfl_plugins" );
			
			$p_options = "<option />";
			
			foreach( $wfl_plugins[ 2 ] as $plugin )
			{
				$p_options = $p_options."<option>".$plugin[ "alpha_01" ]."</option>";
			}
			
			$gruppen_liste = liefere_alle_gruppen( $mandant_name, true );
			
			$options = "";
			
			if ( $gruppen_liste[ 0 ] > 0 )
			{
				$options = "<optgroup label='Gruppen'>";
				foreach( $gruppen_liste[ 2 ] as $benny )
				{
					if ( ( $benutzer[ 2 ][ "benutzer_vertreter" ] == $benny ) && ( $benutzer[ 2 ][ "benutzer_vertreter_typ" ] == "g" ) )
					{
						$selecte_d = " selected ";
					}
					else
					{
						$selecte_d = " ";
					}
					
					$options = $options."<option ".$selecte_d." >".$benny."</option>";
				}
				$options = $options."</optgroup>";
			}
			
			$benutzer_liste = liefere_alle_benutzer_bavn( $mandant_name, true, false );
			
			if ( $benutzer_liste[ 0 ] > 0 )
			{
				$options = $options."<optgroup label='Benutzer'>";
				foreach( $benutzer_liste[ 2 ] as $benny )
				{
					if ( ( $benutzer[ 2 ][ "benutzer_vertreter" ] == $benny[ "benutzer_anmeldename" ] ) && ( $benutzer[ 2 ][ "benutzer_vertreter_typ" ] == "b" ) )
					{
						$selecte_d = " selected ";
					}
					else
					{
						$selecte_d = " ";
					}
					
					if ( $benutzer_anmeldename != $benny[ "benutzer_anmeldename" ] )
					{
						$options = $options."<option ".$selecte_d." >".$benny[ "benutzer_vorname" ]." ".$benny[ "benutzer_nachname" ]." (".$benny[ "benutzer_anmeldename" ].")</option>";
					}
				}
				$options = $options."</optgroup>";
			}
			
			$m_options = "<option value='0'>--Workflow-Ende--</option>";
			
			$m = liefere_masken_zu_workflow( $mandant_name, $workflow_name );
			
			if ( $m[ 0 ] > 0 )
			{
				foreach( $m[ 2 ] as $maske )
				{
					$m_options = $m_options."<option value='".$maske[ "maske_id" ]."' >".$maske[ "maske_name" ]."</option>";
				}
			}
			
			$frist = liefere_wertemenge_elemente( $mandant_name, "zahlen_0_30" );
			
			foreach ( $frist[ 2 ] as $element )
			{
				if ( $element[ "alpha_01" ] == 3 )
				{
					$sel = " selected ";
				}
				else
				{
					$sel = "";
				}
				$f_options = $f_options."<option ".$sel.">".$element[ "alpha_01" ]."</option>";
			}
			
			$html = "<h3 style='margin-left:15px;'>Maske im Workflow ".$workflow_name." anlegen</h3>
						<form name='maske_anlegen' action='w_wfl.php?cmd=maske_anlegen&mandant_name=".$mandant_name."' method='post'>
							<input type='hidden' name='aufgerufen' value='aufgerufen' />
							<input type='hidden' name='alpha_01' value='".$workflow_name."' />
							<table border='0' style='font-size:90%; '>
								<tr>
									<td style='width:180px;'>Masken-Name</td>
									<td ><input type='text' style='height:90%; width:400px;' name='alpha_02' /></td>
									
								</tr>
								<tr>
									<td>Standard-Empfänger</td>
									<td><select name='alpha_03' id='alpha_03' style='height:90%; width:406px;' >".$options."</select></td>
								</tr>
								<tr>
									<td>Standard-Folgemaske</td>
									<td><select name='alpha_04' id='alpha_04' style='height:90%; width:406px;' >".$m_options."</select></td>
								</tr>
								<tr>
									<td>Standard-Bearbeitungsfrist <br />(in Tagen, 0=>keine Frist)</td>
									<td><select name='alpha_16' id='alpha_16' style='height:90%; width:406px;' >".$f_options."</select></td>
								</tr>
								<tr>
									<td />
								</tr><tr><td colspan='5' >
									<hr></td>
								</tr>
								<tr>
									<td colspan='2' />
									<td style='width:160px;' >Bezeichnung</td>
									<td style='width:80px;' >aufgeklappt</td>
									<td style='width:80px;' >einklappbar</td>
									<td style='width:160px;' >Accordion verwenden</td>
								</tr>
								<tr>
									<td>Plugin 1</td>
									<td><select name='alpha_05' style='height:90%; width:406px;'>".$p_options."</select></td>
									<td><input type='text' name='alpha_05_b' /></td>
									<td><input type='checkbox' name='alpha_05_c' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_05_e' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_05_a' checked='checked' value='ja' /> </td>
								</tr>
								<tr>
									<td>Plugin 2</td>
									<td><select name='alpha_06' style='height:90%; width:406px;'>".$p_options."</select></td>
									<td><input type='text' name='alpha_06_b' /></td>
									<td><input type='checkbox' name='alpha_06_c' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_06_e' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_06_a' checked='checked' value='ja' /> </td>
								</tr>
								<tr>
									<td>Plugin 3</td>
									<td><select name='alpha_07' style='height:90%; width:406px;'>".$p_options."</select></td>
									<td><input type='text' name='alpha_07_b' /></td>
									<td><input type='checkbox' name='alpha_07_c' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_07_e' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_07_a' checked='checked' value='ja' /> </td>
								</tr>
								<tr>
									<td>Plugin 4</td>
									<td><select name='alpha_08' style='height:90%; width:406px;'>".$p_options."</select></td>
									<td><input type='text' name='alpha_08_b' /></td>
									<td><input type='checkbox' name='alpha_08_c' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_08_e' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_08_a' checked='checked' value='ja' /> </td>
								</tr>
								<tr>
									<td>Plugin 5</td>
									<td><select name='alpha_09' style='height:90%; width:406px;'>".$p_options."</select></td>
									<td><input type='text' name='alpha_09_b' /></td>
									<td><input type='checkbox' name='alpha_09_c' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_09_e' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_09_a' checked='checked' value='ja' /> </td>
								</tr>
								<tr>
									<td>Plugin 6</td>
									<td><select name='alpha_10' style='height:90%; width:406px;'>".$p_options."</select></td>
									<td><input type='text' name='alpha_10_b' /></td>
									<td><input type='checkbox' name='alpha_10_c' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_10_e' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_10_a' checked='checked' value='ja' /> </td>
								</tr>
								<tr>
									<td>Plugin 7</td>
									<td><select name='alpha_11' style='height:90%; width:406px;'>".$p_options."</select></td>
									<td><input type='text' name='alpha_11_b' /></td>
									<td><input type='checkbox' name='alpha_11_c' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_11_e' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_11_a' checked='checked' value='ja' /> </td>
								</tr>
								<tr>
									<td>Plugin 8</td>
									<td><select name='alpha_12' style='height:90%; width:406px;'>".$p_options."</select></td>
									<td><input type='text' name='alpha_12_b' /></td>
									<td><input type='checkbox' name='alpha_12_c' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_12_e' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_12_a' checked='checked' value='ja' /> </td>
								</tr>
								<tr>
									<td>Plugin 9</td>
									<td><select name='alpha_13' style='height:90%; width:406px;'>".$p_options."</select></td>
									<td><input type='text' name='alpha_13_b' /></td>
									<td><input type='checkbox' name='alpha_13_c' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_13_e' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_13_a' checked='checked' value='ja' /> </td>
								</tr>
								<tr>
									<td>Plugin 10</td>
									<td><select name='alpha_14' style='height:90%; width:406px;'>".$p_options."</select></td>
									<td><input type='text' name='alpha_14_b' /></td>
									<td><input type='checkbox' name='alpha_14_c' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_14_e' checked='checked' value='ja' /> </td>
									<td><input type='checkbox' name='alpha_14_a' checked='checked' value='ja' /> </td>
								</tr>
								
								
							</table>
							<input type='submit' value='OK'>
							<input type='reset' value='Abbrechen' onclick='$( \"#ergebnis_2\" ).html( \"\" );' >
						</form>";
						
						
			$skript = "<script>$( '#alpha_03' ).chosen({ allow_single_deselect:true });</script>";
		}
		
		
		
		
		return $html.$skript;
		
	}
	
	function _web_liefere_maskenoptionen_2( $mandant_name, $workflow_name, $maske_name )
	{
		$html = "<input type='button' value='Maske anlegen' style='display:inline; margin-left: 0px;' onclick='$(\"#aufgabe\").load( \"w_wfl.php?cmd=maske_anlegen&alpha_01=".urlencode( $workflow_name )."\" );'  />
		
		
		<input type='button' value='Maske löschen' style='display:inline; margin-left: 15px;' onclick='$(\"#aufgabe\").load( \"w_wfl.php?cmd=loesche_maske&alpha_01=".urlencode( $workflow_name )."&alpha_02=".urlencode( $maske_name )."\" );' />
		
		
		<input type='button' value='Maske bearbeiten' style='display:inline;  margin-left: 15px;' onclick='$(\"#aufgabe\").load( \"w_wfl.php?cmd=aendere_maske&alpha_01=".urlencode( $workflow_name )."&alpha_02=".urlencode( $maske_name )."\" );' />
		
		<br />
		
		";
		
		//<input type='button' value='Plugin-Detailkonfiguration' style='display:inline;  margin-top: 15px;' onclick='$(\"#aufgabe\").load( \"w_wfl.php?cmd=aendere_maske&alpha_01=".urlencode( $workflow_name )."&alpha_02=".urlencode( $maske_name )."\" );' />";
		
		
		return $html;
	}
	
	function _web_loesche_maske( $mandant_name, $aufgerufen, $workflow_name, $maske_name )
	{
		if ( $aufgerufen == "aufgerufen" )
		{
			
			$ergebnis = loesche_maske( $mandant_name, $workflow_name, $maske_name );
			
			$_SESSION[ "wfl" ] = "schritt_0";
			$_SESSION[ "wfl_meld" ] = $ergebnis[ 1 ];
			
			header( "Location: w_wfl.php" );
		}
		else
		{
			$html = "<h3>Löschen der Maske ".$maske_name."</h3>
			<form name='loesche_maske' action='w_wfl.php?cmd=loesche_maske&mandant_name=".urlencode( $mandant_name )."' method='post'>
			<input type='hidden' name='aufgerufen' value='aufgerufen' />
			<input type='hidden' name='alpha_01' value='".$workflow_name."' />
			<input type='hidden' name='alpha_02' value='".$maske_name."' />
				<p style='margin-left:15px; font-size:90%;'>Wollen Sie die Maske <b>".$maske_name."</b> wirklich l&ouml;schen?</p>
			<input type='submit' style='margin-left:15px;' value='OK'>
			
			</form>";
		}
		
		return $html;
	}
	
	function _web_aendere_maske( $mandant_name, $aufgerufen, $alpha_01, $alpha_02, $alpha_03, $alpha_16, $alpha_04, $alpha_05, $alpha_06, $alpha_07, $alpha_08, $alpha_09,  $alpha_10, $alpha_11, $alpha_12, $alpha_13, $alpha_14, $alpha_15, $alpha_05_c, $alpha_06_c, $alpha_07_c, $alpha_08_c, $alpha_09_c, $alpha_10_c, $alpha_11_c, $alpha_12_c, $alpha_13_c, $alpha_14_c, $alpha_05_b, $alpha_06_b, $alpha_07_b, $alpha_08_b, $alpha_09_b, $alpha_10_b, $alpha_11_b, $alpha_12_b, $alpha_13_b, $alpha_14_b, $alpha_05_e, $alpha_06_e, $alpha_07_e, $alpha_08_e, $alpha_09_e, $alpha_10_e, $alpha_11_e, $alpha_12_e, $alpha_13_e, $alpha_14_e, $alpha_05_a, $alpha_06_a, $alpha_07_a, $alpha_08_a, $alpha_09_a, $alpha_10_a, $alpha_11_a, $alpha_12_a, $alpha_13_a, $alpha_14_a )
	{
		if ( $aufgerufen == "aufgerufen" )
		{
			
			//xlog( 5, "Parameter: ".$mandant_name."|".$aufgerufen."|".$alpha_01."|".$alpha_02."|".$alpha_03."|".$alpha_04."|".$alpha_05."|".$alpha_06."|".$alpha_07."|".$alpha_08."|".$alpha_09."|". $alpha_10."|".$alpha_11."|".$alpha_12."|".$alpha_13."|".$alpha_14."|".$alpha_05_c."|".$alpha_06_c."|".$alpha_07_c."|".$alpha_08_c."|".$alpha_09_c."|".$alpha_10_c."|".$alpha_11_c."|".$alpha_12_c."|".$alpha_13_c."|".$alpha_14_c."|".$alpha_05_b."|".$alpha_06_b."|".$alpha_07_b."|".$alpha_08_b."|".$alpha_09_b."|".$alpha_10_b."|".$alpha_11_b."|".$alpha_12_b."|".$alpha_13_b."|".$alpha_14_b."|".$alpha_05_e."|".$alpha_06_e."|".$alpha_07_e."|".$alpha_08_e."|".$alpha_09_e."|".$alpha_10_e."|".$alpha_11_e."|".$alpha_12_e."|".$alpha_13_e."|".$alpha_14_e );
			
			//$ergebnis = loesche_maske( $mandant_name, $workflow_name, $maske_name );
			
			/*
				Beispiel:
				
				$plugin_04[ "name" ]			=> Name der PHP-Plugin-Datei
				$plugin_04[ "Bezeichnung" ]		=> Bezeichnung
				$plugin_04[ "aufgeklappt" ]		=> Startet in der Maske aufgeklappt
				$plugin_04[ "einklappbar" ]		=> ist einklappbar
			*/
			
			$plugin_01[ "name" ] = $alpha_05;
			$plugin_02[ "name" ] = $alpha_06;
			$plugin_03[ "name" ] = $alpha_07;
			$plugin_04[ "name" ] = $alpha_08;
			$plugin_05[ "name" ] = $alpha_09;
			$plugin_06[ "name" ] = $alpha_10;
			$plugin_07[ "name" ] = $alpha_11;
			$plugin_08[ "name" ] = $alpha_12;
			$plugin_09[ "name" ] = $alpha_13;
			$plugin_10[ "name" ] = $alpha_14;
			
			$plugin_01[ "bezeichnung" ] = $alpha_05_b;
			$plugin_02[ "bezeichnung" ] = $alpha_06_b;
			$plugin_03[ "bezeichnung" ] = $alpha_07_b;
			$plugin_04[ "bezeichnung" ] = $alpha_08_b;
			$plugin_05[ "bezeichnung" ] = $alpha_09_b;
			$plugin_06[ "bezeichnung" ] = $alpha_10_b;
			$plugin_07[ "bezeichnung" ] = $alpha_11_b;
			$plugin_08[ "bezeichnung" ] = $alpha_12_b;
			$plugin_09[ "bezeichnung" ] = $alpha_13_b;
			$plugin_10[ "bezeichnung" ] = $alpha_14_b;
			
			if ( $alpha_05_e == "ja" )
			{
				$plugin_01[ "einklappbar" ] = "ja";
			}
			else
			{
				$plugin_01[ "einklappbar" ] = "nein";
			}
			
			if ( $alpha_06_e == "ja" )
			{
				$plugin_02[ "einklappbar" ] = "ja";
			}
			else
			{
				$plugin_02[ "einklappbar" ] = "nein";
			}
			
			if ( $alpha_07_e == "ja" )
			{
				$plugin_03[ "einklappbar" ] = "ja";
			}
			else
			{
				$plugin_03[ "einklappbar" ] = "nein";
			}
			
			if ( $alpha_08_e == "ja" )
			{
				$plugin_04[ "einklappbar" ] = "ja";
			}
			else
			{
				$plugin_04[ "einklappbar" ] = "nein";
			}
			
			if ( $alpha_09_e == "ja" )
			{
				$plugin_05[ "einklappbar" ] = "ja";
			}
			else
			{
				$plugin_05[ "einklappbar" ] = "nein";
			}
			
			if ( $alpha_10_e == "ja" )
			{
				$plugin_06[ "einklappbar" ] = "ja";
			}
			else
			{
				$plugin_06[ "einklappbar" ] = "nein";
			}
			
			if ( $alpha_11_e == "ja" )
			{
				$plugin_07[ "einklappbar" ] = "ja";
			}
			else
			{
				$plugin_07[ "einklappbar" ] = "nein";
			}
			
			if ( $alpha_12_e == "ja" )
			{
				$plugin_08[ "einklappbar" ] = "ja";
			}
			else
			{
				$plugin_08[ "einklappbar" ] = "nein";
			}
			
			if ( $alpha_13_e == "ja" )
			{
				$plugin_09[ "einklappbar" ] = "ja";
			}
			else
			{
				$plugin_09[ "einklappbar" ] = "nein";
			}
			
			if ( $alpha_14_e == "ja" )
			{
				$plugin_10[ "einklappbar" ] = "ja";
			}
			else
			{
				$plugin_10[ "einklappbar" ] = "nein";
			}
			
			if ( $alpha_05_c == "ja" )
			{
				$plugin_01[ "aufgeklappt" ] = "ja";
			}
			else
			{
				$plugin_01[ "aufgeklappt" ] = "nein";
			}
			
			if ( $alpha_06_c == "ja" )
			{
				$plugin_02[ "aufgeklappt" ] = "ja";
			}
			else
			{
				$plugin_02[ "aufgeklappt" ] = "nein";
			}
			
			if ( $alpha_07_c == "ja" )
			{
				$plugin_03[ "aufgeklappt" ] = "ja";
			}
			else
			{
				$plugin_03[ "aufgeklappt" ] = "nein";
			}
			
			if ( $alpha_08_c == "ja" )
			{
				$plugin_04[ "aufgeklappt" ] = "ja";
			}
			else
			{
				$plugin_04[ "aufgeklappt" ] = "nein";
			}
			
			if ( $alpha_09_c == "ja" )
			{
				$plugin_05[ "aufgeklappt" ] = "ja";
			}
			else
			{
				$plugin_05[ "aufgeklappt" ] = "nein";
			}
			
			if ( $alpha_10_c == "ja" )
			{
				$plugin_06[ "aufgeklappt" ] = "ja";
			}
			else
			{
				$plugin_06[ "aufgeklappt" ] = "nein";
			}
			
			if ( $alpha_11_c == "ja" )
			{
				$plugin_07[ "aufgeklappt" ] = "ja";
			}
			else
			{
				$plugin_07[ "aufgeklappt" ] = "nein";
			}
			
			if ( $alpha_12_c == "ja" )
			{
				$plugin_08[ "aufgeklappt" ] = "ja";
			}
			else
			{
				$plugin_08[ "aufgeklappt" ] = "nein";
			}
			
			if ( $alpha_13_c == "ja" )
			{
				$plugin_09[ "aufgeklappt" ] = "ja";
			}
			else
			{
				$plugin_09[ "aufgeklappt" ] = "nein";
			}
			
			if ( $alpha_14_c == "ja" )
			{
				$plugin_10[ "aufgeklappt" ] = "ja";
			}
			else
			{
				$plugin_10[ "aufgeklappt" ] = "nein";
			}
			
			if ( $alpha_05_a == "ja" )
			{
				$plugin_01[ "accordion" ] = "ja";
			}
			else
			{
				$plugin_01[ "accordion" ] = "nein";
			}
			
			if ( $alpha_06_a == "ja" )
			{
				$plugin_02[ "accordion" ] = "ja";
			}
			else
			{
				$plugin_02[ "accordion" ] = "nein";
			}
			
			if ( $alpha_07_a == "ja" )
			{
				$plugin_03[ "accordion" ] = "ja";
			}
			else
			{
				$plugin_03[ "accordion" ] = "nein";
			}
			
			if ( $alpha_08_a == "ja" )
			{
				$plugin_04[ "accordion" ] = "ja";
			}
			else
			{
				$plugin_04[ "accordion" ] = "nein";
			}
			
			if ( $alpha_09_a == "ja" )
			{
				$plugin_05[ "accordion" ] = "ja";
			}
			else
			{
				$plugin_05[ "accordion" ] = "nein";
			}
			
			if ( $alpha_10_a == "ja" )
			{
				$plugin_06[ "accordion" ] = "ja";
			}
			else
			{
				$plugin_06[ "accordion" ] = "nein";
			}
			
			if ( $alpha_11_a == "ja" )
			{
				$plugin_07[ "accordion" ] = "ja";
			}
			else
			{
				$plugin_07[ "accordion" ] = "nein";
			}
			
			if ( $alpha_12_a == "ja" )
			{
				$plugin_08[ "accordion" ] = "ja";
			}
			else
			{
				$plugin_08[ "accordion" ] = "nein";
			}
			
			if ( $alpha_13_a == "ja" )
			{
				$plugin_09[ "accordion" ] = "ja";
			}
			else
			{
				$plugin_09[ "accordion" ] = "nein";
			}
			
			if ( $alpha_14_a == "ja" )
			{
				$plugin_10[ "accordion" ] = "ja";
			}
			else
			{
				$plugin_10[ "accordion" ] = "nein";
			}
			
			if ( strlen( $alpha_03 ) > 0 )
			{
				if ( strpos( $alpha_03, "(" ) === false )
				{
					// Gruppe
					$maske_default_empfaenger				= $alpha_03;
					$maske_default_empfaenger_typ			= "g";
				}
				else
				{
					$anfang									= bcadd( strpos( $alpha_03, "(" ), 1, 0 );
					$laenge									= bcsub( strpos( $alpha_03, ")" ), $anfang, 0 );
					$benutzer_anmelde_name					= substr( $alpha_03, $anfang, $laenge );
					
					$maske_default_empfaenger				= $benutzer_anmelde_name;
					$maske_default_empfaenger_typ			= "b";
				}
			}
			
			//aendere_maske( $mandant_name, $workflow_name, $maske_name, $neuer_maske_name, $maske_default_empfaenger, $maske_default_empfaenger_typ, $maske_default_folgemaske_id, $maske_default_frist, $plugin_01, $plugin_02 = array(), $plugin_03 = array(), $plugin_04 = array(), $plugin_05 = array(),  $plugin_06 = array(), $plugin_07 = array(), $plugin_08 = array(), $plugin_09 = array(), $plugin_10 = array() )
			
			$maske_default_frist = $alpha_16;
			$maske_default_folgemaske_id = $alpha_04;
			
			$ergebnis = aendere_maske( $mandant_name, $alpha_01, $alpha_15, $alpha_02, $maske_default_empfaenger, $maske_default_empfaenger_typ, $maske_default_folgemaske_id, $maske_default_frist, $plugin_01, $plugin_02, $plugin_03, $plugin_04, $plugin_05,  $plugin_06, $plugin_07, $plugin_08, $plugin_09, $plugin_10 );
			
			$_SESSION[ "wfl" ] = "schritt_0";
			$_SESSION[ "wfl_meld" ] = $ergebnis[ 1 ];
			
			header( "Location: w_wfl.php" );
		}
		else
		{
			$workflow_name	= $alpha_01;
			$maske_name		= $alpha_02;
			
			$maske = liefere_maskeninformationen( $mandant_name, $workflow_name, $maske_name );
			
			
			
			$wfl_plugins = liefere_wertemenge_elemente( $mandant_name, "wfl_plugins" );
			
			$p_options_01 = "<option />";
			$p_options_02 = "<option />";
			$p_options_03 = "<option />";
			$p_options_04 = "<option />";
			$p_options_05 = "<option />";
			$p_options_06 = "<option />";
			$p_options_07 = "<option />";
			$p_options_08 = "<option />";
			$p_options_09 = "<option />";
			$p_options_10 = "<option />";
			
			foreach( $wfl_plugins[ 2 ] as $plugin )
			{
				
				if ( $maske[ 2 ][ "maske_plugin_01" ] == $plugin[ "alpha_01" ] )
				{
					$p_01_sel = " selected ";
				}
				else
				{
					$p_01_sel = "";
				}
				
				if ( $maske[ 2 ][ "maske_plugin_02" ] == $plugin[ "alpha_01" ] )
				{
					$p_02_sel = " selected ";
				}
				else
				{
					$p_02_sel = "";
				}
				
				if ( $maske[ 2 ][ "maske_plugin_03" ] == $plugin[ "alpha_01" ] )
				{
					$p_03_sel = " selected ";
				}
				else
				{
					$p_03_sel = "";
				}
				
				if ( $maske[ 2 ][ "maske_plugin_04" ] == $plugin[ "alpha_01" ] )
				{
					$p_04_sel = " selected ";
				}
				else
				{
					$p_04_sel = "";
				}
				
				if ( $maske[ 2 ][ "maske_plugin_05" ] == $plugin[ "alpha_01" ] )
				{
					$p_05_sel = " selected ";
				}
				else
				{
					$p_05_sel = "";
				}
				
				if ( $maske[ 2 ][ "maske_plugin_06" ] == $plugin[ "alpha_01" ] )
				{
					$p_06_sel = " selected ";
				}
				else
				{
					$p_06_sel = "";
				}
				
				if ( $maske[ 2 ][ "maske_plugin_07" ] == $plugin[ "alpha_01" ] )
				{
					$p_07_sel = " selected ";
				}
				else
				{
					$p_07_sel = "";
				}
				
				if ( $maske[ 2 ][ "maske_plugin_08" ] == $plugin[ "alpha_01" ] )
				{
					$p_08_sel = " selected ";
				}
				else
				{
					$p_08_sel = "";
				}
				
				if ( $maske[ 2 ][ "maske_plugin_09" ] == $plugin[ "alpha_01" ] )
				{
					$p_09_sel = " selected ";
				}
				else
				{
					$p_09_sel = "";
				}
				
				if ( $maske[ 2 ][ "maske_plugin_10" ] == $plugin[ "alpha_01" ] )
				{
					$p_10_sel = " selected ";
				}
				else
				{
					$p_10_sel = "";
				}
				
				
				$p_options_01 = $p_options_01."<option ".$p_01_sel." >".$plugin[ "alpha_01" ]."</option>";
				$p_options_02 = $p_options_02."<option ".$p_02_sel." >".$plugin[ "alpha_01" ]."</option>";
				$p_options_03 = $p_options_03."<option ".$p_03_sel." >".$plugin[ "alpha_01" ]."</option>";
				$p_options_04 = $p_options_04."<option ".$p_04_sel." >".$plugin[ "alpha_01" ]."</option>";
				$p_options_05 = $p_options_05."<option ".$p_05_sel." >".$plugin[ "alpha_01" ]."</option>";
				$p_options_06 = $p_options_06."<option ".$p_06_sel." >".$plugin[ "alpha_01" ]."</option>";
				$p_options_07 = $p_options_07."<option ".$p_07_sel." >".$plugin[ "alpha_01" ]."</option>";
				$p_options_08 = $p_options_08."<option ".$p_08_sel." >".$plugin[ "alpha_01" ]."</option>";
				$p_options_09 = $p_options_09."<option ".$p_09_sel." >".$plugin[ "alpha_01" ]."</option>";
				$p_options_10 = $p_options_10."<option ".$p_10_sel." >".$plugin[ "alpha_01" ]."</option>";
			}
			
			/*
				$ergebnis[ "workflow_id" ]					= $m[ 1 ][ 0 ][ "workflow_id" ];
				$ergebnis[ "workflow_id" ]						= $m[ 1 ][ 0 ][ "workflow_id" ];
				$ergebnis[ "maske_id" ]						= $m[ 1 ][ 0 ][ "maske_id" ];
				$ergebnis[ "maske_name" ]					= $m[ 1 ][ 0 ][ "maske_name" ];
				$ergebnis[ "maske_default_empfaenger" ]		= $m[ 1 ][ 0 ][ "maske_default_empfaenger" ];
				$ergebnis[ "maske_default_empfaenger_typ" ]	= $m[ 1 ][ 0 ][ "maske_default_empfaenger_typ" ];
				$ergebnis[ "maske_default_folgemaske" ]		= $m[ 1 ][ 0 ][ "maske_default_folgemaske" ];
				
				$ergebnis[ "maske_plugin_01_bez" ]			= $m[ 1 ][ 0 ][ "maske_p01_bez" ];
				$ergebnis[ "maske_plugin_01_bezeichnung" ]	= $m[ 1 ][ 0 ][ "maske_p01_bez" ];
				
				
				$ergebnis[ "maske_plugin_01" ]				= $m[ 1 ][ 0 ][ "maske_plugin_01" ];
				
				if ( substr( $m[ 1 ][ 0 ][ "maske_p01_einst" ], 0, 1 ) == "1" )
				{
					$ergebnis[ "maske_plugin_01_geoeffnet" ] = "ja";
				}
				else
				{
					$ergebnis[ "maske_plugin_01_geoeffnet" ] = "nein";
				}
				
				if ( substr( $m[ 1 ][ 0 ][ "maske_p01_einst" ], 1, 1 ) == "1" )
				{
					$ergebnis[ "maske_plugin_01_einklappbar" ] = "ja";
				}
				else
				{
					$ergebnis[ "maske_plugin_01_einklappbar" ] = "nein";
				}
			*/
			
			$plu = array( "maske_plugin_01", "maske_plugin_02", "maske_plugin_03", "maske_plugin_04", "maske_plugin_05", "maske_plugin_06", "maske_plugin_07", "maske_plugin_08", "maske_plugin_09", "maske_plugin_10" );
		
			foreach ( $plu as $p )
			{
				if ( $maske[ 2 ][ $p."_geoeffnet" ] == "ja" )
				{
					$maske_plugin_geoeffnet[ $p."_geoeffnet" ] = " checked='checked' ";
				}
				else
				{
					$maske_plugin_geoeffnet[ $p."_geoeffnet" ] = "";
				}
				
				if ( $maske[ 2 ][ $p."_einklappbar" ] == "ja" )
				{
					$maske_plugin_einklappbar[ $p."_einklappbar" ] = " checked='checked' ";
				}
				else
				{
					$maske_plugin_einklappbar[ $p."_einklappbar" ] = "";
				}
				
				if ( $maske[ 2 ][ $p."_accordion" ] == "ja" )
				{
					$maske_plugin_accordion[ $p."_accordion" ] = " checked='checked' ";
				}
				else
				{
					$maske_plugin_accordion[ $p."_accordion" ] = "";
				}
			}
			
			
			$gruppen_liste = liefere_alle_gruppen( $mandant_name, false );
			
			$options = "";
			
			if ( $gruppen_liste[ 0 ] > 0 )
			{
				$options = "<optgroup label='Gruppen'>";
				foreach( $gruppen_liste[ 2 ] as $benny )
				{
					if ( ( $maske[ 2 ][ "maske_default_empfaenger" ] == $benny ) && ( $maske[ 2 ][ "maske_default_empfaenger_typ" ] == "g" ) )
					{
						$selecte_d = " selected ";
					}
					else
					{
						$selecte_d = " ";
					}
					
					$options = $options."<option ".$selecte_d." >".$benny."</option>";
				}
				$options = $options."</optgroup>";
			}
			
			$benutzer_liste = liefere_alle_benutzer_bavn( $mandant_name, true, false );
			
			if ( $benutzer_liste[ 0 ] > 0 )
			{
				$options = $options."<optgroup label='Benutzer'>";
				foreach( $benutzer_liste[ 2 ] as $benny )
				{
					if ( ( $maske[ 2 ][ "maske_default_empfaenger" ] == $benny[ "benutzer_anmeldename" ] ) && ( $maske[ 2 ][ "maske_default_empfaenger_typ" ] == "b" ) )
					{
						$selecte_d = " selected ";
					}
					else
					{
						$selecte_d = " ";
					}
					
					if ( $benutzer_anmeldename != $benny[ "benutzer_anmeldename" ] )
					{
						$options = $options."<option ".$selecte_d." >".$benny[ "benutzer_vorname" ]." ".$benny[ "benutzer_nachname" ]." (".$benny[ "benutzer_anmeldename" ].")</option>";
					}
				}
				$options = $options."</optgroup>";
			}
			
			$m_options = "<option value='0'>--Workflow-Ende--</option>";
			
			$m = liefere_masken_zu_workflow( $mandant_name, $workflow_name );
			
			if ( $m[ 0 ] > 0 )
			{
				foreach( $m[ 2 ] as $ma )
				{
					if ( $maske[ 2 ][ "maske_default_folgemaske" ] == $ma[ "maske_id" ] )
					{
						$m_selected = " selected ";
					}
					else
					{
						$m_selected = "  ";
					}
					$m_options = $m_options."<option value='".$ma[ "maske_id" ]."' ".$m_selected." >".$ma[ "maske_name" ]."</option>";
				}
			}
			
			$frist = liefere_wertemenge_elemente( $mandant_name, "zahlen_0_30" );
			
			foreach ( $frist[ 2 ] as $element )
			{
				if ( $element[ "alpha_01" ] == $maske[ 2 ][ "maske_default_frist" ] )
				{
					$sel = " selected ";
				}
				else
				{
					$sel = "";
				}
				$f_options = $f_options."<option ".$sel." >".$element[ "alpha_01" ]."</option>";
			}
			
			$html = "<h3 style='margin-left:15px;'>Maske im Workflow ".$workflow_name." ändern</h3>
						<form name='aendere_maske' action='w_wfl.php?cmd=aendere_maske&mandant_name=".urlencode( $mandant_name )."' method='post'>
							<input type='hidden' name='aufgerufen' value='aufgerufen' />
							<input type='hidden' name='alpha_01' value='".$workflow_name."' />
							<input type='hidden' name='alpha_15' value='".$maske[ 2 ][ "maske_name" ]."' />
							<table border='0' style='font-size:90%; '>
								<tr>
									<td style='width:180px;'>Masken-Name</td>
									<td ><input type='text' style='height:90%; width:400px;' name='alpha_02' value='".$maske[ 2 ][ "maske_name" ]."' /></td>
									
								</tr>
								<tr>
									<td>Standard-Empfänger</td>
									<td><select name='alpha_03' id='alpha_03' style='height:90%; width:406px;' >".$options."</select></td>
								</tr>
								<tr>
									<td>Standard-Folgemaske</td>
									<td><select name='alpha_04' id='alpha_04' style='height:90%; width:406px;' >".$m_options."</select></td>
								</tr>
								<tr>
									<td>Standard-Bearbeitungsfrist <br />(in Tagen, 0=>keine Frist)</td>
									<td><select name='alpha_16' id='alpha_16' style='height:90%; width:406px;' >".$f_options."</select></td>
								</tr>
								<tr>
									<td />
								</tr><tr><td colspan='5' >
									<hr></td>
								</tr>
								<tr>
									<td colspan='2' />
									<td style='width:160px;' >Bezeichnung</td>
									<td style='width:80px;' >aufgeklappt</td>
									<td style='width:80px;' >einklappbar</td>
									<td style='width:160px;' >Accordion verwenden</td>
								</tr>
								<tr>
									<td>Plugin 1</td>
									<td><select name='alpha_05' style='height:90%; width:406px;'>".$p_options_01."</select></td>
									<td><input type='text' name='alpha_05_b' value='".$maske[ 2 ][ "maske_plugin_01_bez" ]."' /></td>
									<td><input type='checkbox' name='alpha_05_c' ".$maske_plugin_geoeffnet[ "maske_plugin_01_geoeffnet" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_05_e' ".$maske_plugin_einklappbar[ "maske_plugin_01_einklappbar" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_05_a' ".$maske_plugin_accordion[ "maske_plugin_01_accordion" ]." value='ja' /> </td>
								</tr>
								<tr>
									<td>Plugin 2</td>
									<td><select name='alpha_06' style='height:90%; width:406px;'>".$p_options_02."</select></td>
									<td><input type='text' name='alpha_06_b' value='".$maske[ 2 ][ "maske_plugin_02_bez" ]."' /></td>
									<td><input type='checkbox' name='alpha_06_c' ".$maske_plugin_geoeffnet[ "maske_plugin_02_geoeffnet" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_06_e' ".$maske_plugin_einklappbar[ "maske_plugin_02_einklappbar" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_06_a' ".$maske_plugin_accordion[ "maske_plugin_02_accordion" ]." value='ja' /> </td>
								</tr>
								<tr>
									<td>Plugin 3</td>
									<td><select name='alpha_07' style='height:90%; width:406px;'>".$p_options_03."</select></td>
									<td><input type='text' name='alpha_07_b' value='".$maske[ 2 ][ "maske_plugin_03_bez" ]."' /></td>
									<td><input type='checkbox' name='alpha_07_c' ".$maske_plugin_geoeffnet[ "maske_plugin_03_geoeffnet" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_07_e' ".$maske_plugin_einklappbar[ "maske_plugin_03_einklappbar" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_07_a' ".$maske_plugin_accordion[ "maske_plugin_03_accordion" ]." value='ja' /> </td>
								</tr>
								<tr>
									<td>Plugin 4</td>
									<td><select name='alpha_08' style='height:90%; width:406px;'>".$p_options_04."</select></td>
									<td><input type='text' name='alpha_08_b' value='".$maske[ 2 ][ "maske_plugin_04_bez" ]."' /></td>
									<td><input type='checkbox' name='alpha_08_c' ".$maske_plugin_geoeffnet[ "maske_plugin_04_geoeffnet" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_08_e' ".$maske_plugin_einklappbar[ "maske_plugin_04_einklappbar" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_08_a' ".$maske_plugin_accordion[ "maske_plugin_04_accordion" ]." value='ja' /> </td>
								</tr>
								<tr>
									<td>Plugin 5</td>
									<td><select name='alpha_09' style='height:90%; width:406px;'>".$p_options_05."</select></td>
									<td><input type='text' name='alpha_09_b' value='".$maske[ 2 ][ "maske_plugin_05_bez" ]."' /></td>
									<td><input type='checkbox' name='alpha_09_c' ".$maske_plugin_geoeffnet[ "maske_plugin_05_geoeffnet" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_09_e' ".$maske_plugin_einklappbar[ "maske_plugin_05_einklappbar" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_09_a' ".$maske_plugin_accordion[ "maske_plugin_05_accordion" ]." value='ja' /> </td>
								</tr>
								<tr>
									<td>Plugin 6</td>
									<td><select name='alpha_10' style='height:90%; width:406px;'>".$p_options_06."</select></td>
									<td><input type='text' name='alpha_10_b' value='".$maske[ 2 ][ "maske_plugin_06_bez" ]."' /></td>
									<td><input type='checkbox' name='alpha_10_c' ".$maske_plugin_geoeffnet[ "maske_plugin_06_geoeffnet" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_10_e' ".$maske_plugin_einklappbar[ "maske_plugin_06_einklappbar" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_10_a' ".$maske_plugin_accordion[ "maske_plugin_06_accordion" ]." value='ja' /> </td>
								</tr>
								<tr>
									<td>Plugin 7</td>
									<td><select name='alpha_11' style='height:90%; width:406px;'>".$p_options_07."</select></td>
									<td><input type='text' name='alpha_11_b' value='".$maske[ 2 ][ "maske_plugin_07_bez" ]."' /></td>
									<td><input type='checkbox' name='alpha_11_c' ".$maske_plugin_geoeffnet[ "maske_plugin_07_geoeffnet" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_11_e' ".$maske_plugin_einklappbar[ "maske_plugin_07_einklappbar" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_11_a' ".$maske_plugin_accordion[ "maske_plugin_07_accordion" ]." value='ja' /> </td>
								</tr>
								<tr>
									<td>Plugin 8</td>
									<td><select name='alpha_12' style='height:90%; width:406px;'>".$p_options_08."</select></td>
									<td><input type='text' name='alpha_12_b' value='".$maske[ 2 ][ "maske_plugin_08_bez" ]."' /></td>
									<td><input type='checkbox' name='alpha_12_c' ".$maske_plugin_geoeffnet[ "maske_plugin_08_geoeffnet" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_12_e' ".$maske_plugin_einklappbar[ "maske_plugin_08_einklappbar" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_12_a' ".$maske_plugin_accordion[ "maske_plugin_08_accordion" ]." value='ja' /> </td>
								</tr>
								<tr>
									<td>Plugin 9</td>
									<td><select name='alpha_13' style='height:90%; width:406px;'>".$p_options_09."</select></td>
									<td><input type='text' name='alpha_13_b' value='".$maske[ 2 ][ "maske_plugin_09_bez" ]."' /></td>
									<td><input type='checkbox' name='alpha_13_c' ".$maske_plugin_geoeffnet[ "maske_plugin_09_geoeffnet" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_13_e' ".$maske_plugin_einklappbar[ "maske_plugin_09_einklappbar" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_13_a' ".$maske_plugin_accordion[ "maske_plugin_09_accordion" ]." value='ja' /> </td>
								</tr>
								<tr>
									<td>Plugin 10</td>
									<td><select name='alpha_14' style='height:90%; width:406px;'>".$p_options_10."</select></td>
									<td><input type='text' name='alpha_14_b' value='".$maske[ 2 ][ "maske_plugin_10_bez" ]."' /></td>
									<td><input type='checkbox' name='alpha_14_c' ".$maske_plugin_geoeffnet[ "maske_plugin_10_geoeffnet" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_14_e' ".$maske_plugin_einklappbar[ "maske_plugin_10_einklappbar" ]." value='ja' /> </td>
									<td><input type='checkbox' name='alpha_14_a' ".$maske_plugin_accordion[ "maske_plugin_10_accordion" ]." value='ja' /> </td>
								</tr>
								
								
							</table>
							<input type='submit' value='OK'>
							<input type='reset' value='Abbrechen' onclick='$( \"#ergebnis_2\" ).html( \"\" );' >
						</form>";
						
						
			$skript = "<script>$( '#alpha_03' ).chosen({ allow_single_deselect:true });</script>";
			
			$html = $html.$skript;
		}
		
		
		return $html;
	}

	function _web_liefere_maskeninformationen( $mandant_name, $workflow_name, $maske_name )
	{
		$maske = liefere_maskeninformationen( $mandant_name, $workflow_name, $maske_name );
		
		$html = "<h3>Maske ".$maske_name."</h3>";
		
		/*
				$ergebnis[ "workflow_id" ]					= $m[ 1 ][ 0 ][ "workflow_id" ];
				$ergebnis[ "workflow_id" ]						= $m[ 1 ][ 0 ][ "workflow_id" ];
				$ergebnis[ "maske_id" ]						= $m[ 1 ][ 0 ][ "maske_id" ];
				$ergebnis[ "maske_name" ]					= $m[ 1 ][ 0 ][ "maske_name" ];
				$ergebnis[ "maske_default_empfaenger" ]		= $m[ 1 ][ 0 ][ "maske_default_empfaenger" ];
				$ergebnis[ "maske_default_empfaenger_typ" ]	= $m[ 1 ][ 0 ][ "maske_default_empfaenger_typ" ];
				$ergebnis[ "maske_default_folgemaske" ]		= $m[ 1 ][ 0 ][ "maske_default_folgemaske" ];
				
				
				$ergebnis[ "maske_plugin_01" ]				= $m[ 1 ][ 0 ][ "maske_plugin_01" ];
				
				if ( substr( $m[ 1 ][ 0 ][ "maske_p01_einst" ], 0, 1 ) == "1" )
				{
					$ergebnis[ "maske_plugin_01_geoeffnet" ] = "ja";
				}
				else
				{
					$ergebnis[ "maske_plugin_01_geoeffnet" ] = "nein";
				}
				
				if ( substr( $m[ 1 ][ 0 ][ "maske_p01_einst" ], 1, 1 ) == "1" )
				{
					$ergebnis[ "maske_plugin_01_einklappbar" ] = "ja";
				}
				else
				{
					$ergebnis[ "maske_plugin_01_einklappbar" ] = "nein";
				}
		*/
		
		if ( $maske[ 2 ][ "maske_default_empfaenger_typ" ] == "b" )
		{
			$ben = liefere_benutzerinformationen( $mandant_name, $maske[ 2 ][ "maske_default_empfaenger" ] );
			$maske_default_empfaenger = $ben[ 2 ][ "benutzer_name_komplett" ];
		}
		else
		{
			$maske_default_empfaenger = "Gruppe ".$maske[ 2 ][ "maske_default_empfaenger" ];
		}
		
		
		if ( $maske[ 2 ][ "maske_default_folgemaske" ] == 0 )
		{
			$folgemaske = "Workflow-Ende";
		}
		else
		{
			$fm = liefere_maskeninformationen( $mandant_name, $workflow_name, "", $maske[ 2 ][ "maske_default_folgemaske" ] );
			$folgemaske = $fm[ 2 ][ "maske_name" ]." (ID ".$fm[ 2 ][ "maske_id" ].")";
		}
		
		$plu = array( "maske_plugin_01", "maske_plugin_02", "maske_plugin_03", "maske_plugin_04", "maske_plugin_05", "maske_plugin_06", "maske_plugin_07", "maske_plugin_08", "maske_plugin_09", "maske_plugin_10" );
		
		foreach ( $plu as $p )
		{
			if ( strlen( $maske[ 2 ][ $p ] ) > 0 )
			{
				$p_html = $p_html."<tr><td >".substr( $p, -2 )." / <span style='font-weight:bold;'>".$maske[ 2 ][ $p."_bez" ]."</span></td><td style='font-weight:bold;'>".$maske[ 2 ][ $p ]."</td><td style='font-weight:bold;'>".$maske[ 2 ][ $p."_geoeffnet" ]."</td><td style='font-weight:bold;'>".$maske[ 2 ][ $p."_einklappbar" ]."</td><td style='font-weight:bold;'>".$maske[ 2 ][ $p."_accordion" ]."</td></tr>";
			}
			
		}
		
		//xlog( 4, $maske[ 2 ][ "maske_default_frist" ] );
		
		if ( $maske[ 2 ][ "maske_default_frist" ] == 0 )
		{
			$maske_default_frist = "nicht gesetzt";
		}
		else
		{
			$maske_default_frist = $maske[ 2 ][ "maske_default_frist" ]." Tage";
		}
		
		
		$html = $html."<table>
							<tr>
								<td style='width:200px;'>Workflow</td>
								<td style='font-weight:bold;'>".$workflow_name." (ID ".$maske[ 2 ][ "workflow_id" ].")</td>
								<td></td>
								<td></td>
							</tr>
							<tr>
								<td style='width:200px;'>Maske</td>
								<td style='font-weight:bold;'>".$maske_name." (ID ".$maske[ 2 ][ "maske_id" ].")</td>
								<td></td>
								<td></td>
							</tr>
							<tr>
								<td style='width:200px;'>Standard-Empfänger</td>
								<td style='font-weight:bold;'>".$maske_default_empfaenger."</td>
								<td></td>
								<td></td>
							</tr>
							<tr>
								<td style='width:200px;'>Standard-Folgemaske</td>
								<td style='font-weight:bold;'>".$folgemaske."</td>
								<td></td>
								<td></td>
							</tr>
							<tr>
								<td style='width:200px;'>Standard-Bearbeitungsfrist</td>
								<td style='font-weight:bold;'>".$maske_default_frist."</td>
								<td></td>
								<td></td>
							</tr>
							<tr>
								<td style='width:200px;'>erstellt am</td>
								<td style='font-weight:bold;'>".$maske[ 2 ][ "erstellt_am_date" ]."</td>
								<td></td>
								<td></td>
							</tr>
							<tr>
								<td style='width:200px;'>geändert am</td>
								<td style='font-weight:bold;'>".$maske[ 2 ][ "geaendert_am_date" ]."</td>
								<td></td>
								<td></td>
							</tr>
							<tr>
								<td colspan='4'><hr /></td>
							</tr>
							<tr>
								<td>Position / Bezeichnung</td>
								<td style='width:200px;'>Plugin</td>
								<td style='width:100px;'>geöffnet</td>
								<td style='width:100px;'>einklappbar</td>
								<td style='width:160px;'>Accordion verwenden</td>
							</tr>
							".$p_html."
							
						</table>";
		
		return $html;
	}
	
	function _web_liefere_plugin_liste( $mandant_name, $workflow_name, $maske_name )
	{
		//$html = "echtzeit! ".$mandant_name."|".$workflow_name."|".$maske_name;
		
		$maske = liefere_maskeninformationen( $mandant_name, $workflow_name, $maske_name );
		
		$html = "<h3>Plugins der Maske ".$maske_name." (Workflow ".$workflow_name.")</h3>";
		
		$html = $html."<table>";
		
		$plu = array( "maske_plugin_01", "maske_plugin_02", "maske_plugin_03", "maske_plugin_04", "maske_plugin_05", "maske_plugin_06", "maske_plugin_07", "maske_plugin_08", "maske_plugin_09", "maske_plugin_10" );
		
		foreach ( $plu as $p )
		{
			if ( strlen( $maske[ 2 ][ $p ] ) > 0 )
			{
				$k = explode( "_", $p );
				$html = $html."<tr><td>".$k[ 2 ]."</td><td style='width:290px;' ><b>".$maske[ 2 ][ $p ]."</b></td><td><input type='button' value='Konfiguration' style='font-size:90%;' onclick='$( \"#aufgabe\" ).load( \"wfl_plugins/".$maske[ 2 ][ $p ]."?mandant_name=".urlencode( $mandant_name )."&workflow_name=".urlencode( $workflow_name )."&maske_name=".urlencode( $maske_name )."&maske_pos=".$k[ 2 ]."&cmd=konfig\" );'	/></td></tr> ";
			}
		}
		$html = $html."</table>";
		
		
		return $html;
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	





?>