<?php
@session_start();

$mandant_name = $_SESSION[ "mandant_name" ];


if ( $_SESSION[ "w_benutzernotizen" ] != "a" )
{
	
	header( "Location: us_uebersicht.php" );
	
}
else
{
	$_SESSION[ "w_benutzernotizen" ] = "";
}

$_SESSION[ "title" ] = "Persönliche Benutzer-Notizen";
include( 'ssi_header.php' );
$_SESSION[ "title" ] = "";

$exec = besitzt_benutzer_systemrecht( $_SESSION[ "mandant_name" ], $_SESSION[ "benutzer_anmeldename" ], "D_USERNOTE" );

if ( $exec[ 0 ] != 1 )
{
	header( "Location: us_uebersicht.php" );
}



echo "<div style='margin-left:20px; margin-top:12px; padding-bottom:30px;  min-height:550px;'>";


//<div name="ergebnis_1" id="ergebnis_1" style=" padding-left: 12px; vertical-align:top;  position:absolute;  display:inline; margin-top:10px;" ></div>

//<div name="ergebnis_2" id="ergebnis_2" style=" margin-top:10px;" ></div>

$ergebnis = variable_recherche( $_SESSION[ "mandant_name" ], "USERNOTE", $_SESSION[ "benutzer_anmeldename" ], array( array( "feld"=>"alpha_01", "operator"=>"EQUAL", "wert"=>$_SESSION[ "benutzer_anmeldename" ] ) ) );

if ( $ergebnis[ 0 ] > 0 )
{
	$dok_id = $ergebnis[ 2 ][ 0 ][ "dok_id" ];
	
	$bin = liefere_dokumentbinary( $_SESSION[ "mandant_name" ], $_SESSION[ "benutzer_anmeldename" ], $dok_id );
	
	if ( $bin[ 0 ] > 0 )
	{
		$binary = $bin[ 2 ];
		
		$bin_arr = explode( "|||||", $binary );
		
		$dok_vorhanden = true;
	}
}
else
{
	$dok_vorhanden = false;
}


$divine = '<div id="tab"><ul>';

for ( $j = 1; $j <= 10; $j++ )
{
	if ( $dok_vorhanden == true )
	{
		$textarea = $bin_arr[ $j ];
	}
	else
	{
		$textarea = "";
	}
	
	$divine = $divine.'<li><a id="li_'.$j.'" href="#pbn_'.$j.'">Notizen '.$j.'</a></li>';
	$o = $o."<div id='pbn_".$j."'><textarea name='name_".$j."' id='id_".$j."' cols='150' rows='35' >".$textarea."</textarea></div>";
}

$divine = $divine."</ul>".$o."</div>";

$skript = "function notizen_speichern() { 
	
	var not1 = document.getElementById( 'id_1' );
	var not2 = document.getElementById( 'id_2' );
	var not3 = document.getElementById( 'id_3' );
	var not4 = document.getElementById( 'id_4' );
	var not5 = document.getElementById( 'id_5' );
	var not6 = document.getElementById( 'id_6' );
	var not7 = document.getElementById( 'id_7' );
	var not8 = document.getElementById( 'id_8' );
	var not9 = document.getElementById( 'id_9' );
	var not10 = document.getElementById( 'id_10' );
	
	not1 = encodeURIComponent( not1.value );
	not2 = encodeURIComponent( not2.value );
	not3 = encodeURIComponent( not3.value );
	not4 = encodeURIComponent( not4.value );
	not5 = encodeURIComponent( not5.value );
	not6 = encodeURIComponent( not6.value );
	not7 = encodeURIComponent( not7.value );
	not8 = encodeURIComponent( not8.value );
	not9 = encodeURIComponent( not9.value );
	not10 = encodeURIComponent( not10.value );
	
	ajaxFunction( 'su_web.php?cmd=speichere_notizen_pbn&element_id=".$_SESSION[ "benutzer_anmeldename" ]."&alpha_01='+not1+'&alpha_02='+not2+'&alpha_03='+not3+'&alpha_04='+not4+'&alpha_05='+not5+'&alpha_06='+not6+'&alpha_07='+not7+'&alpha_08='+not8+'&alpha_09='+not9+'&alpha_10='+not10, 'ergebnis_1' );
	
	
 }";

$skript = "<script>".$skript."</script>";
 
$button = "<button style='width:150px; height: 35px;' onclick='notizen_speichern();' >Speichern</button><br /><br />";


echo $button.$divine.$skript;
?>





	
	

	
	


<script>
	$(function() {
		$( "#tab" ).tabs();
	});
</script>
<?php

echo '<div name="ergebnis_1" id="ergebnis_1" style=" margin-top:10px;" >'.$_SESSION[ "wkz_meld" ].'</div>';
	$_SESSION[ "wkz_meld" ] = "";

echo "</div>";

include( 'ssi_footer.php' );

?>   