<?php
@session_start();

// Welche Cascading-Style-Sheet-Dateien sollen geladen werden? Dateien müssen im Verzeichnis </stil/theme.css/> liegen
$_SESSION[ "css_dateien" ] = "jquery.fileupload-ui.css"; //  "js_datei_1.js|js_datei_2.js"

// Welche Javascript-Dateien sollen geladen werden? Dateien müssen im js-Verzeichnis liegen
$_SESSION[ "javascript_dateien" ] = "jquery.fileupload.js|jquery.fileupload-ui.js"; //  "js_datei_1.js|js_datei_2.js"


// Welche Javascript-Befehle sollen beim Laden des Dokuments ausgeführt werden?
$_SESSION[ "javascript_startup" ] = '$(function() {
		$( ".date-pick" ).datepicker({ showAnim: "clip", buttonImageOnly: true,  showOn: "both", buttonImage: "img/kalender.png", showWeek: true });
		$( "#suchergebnis" ).accordion({collapsible: true, active: false, event: "click", autoHeight: false });
		$( "#file_upload" ).fileUploadUI({
        uploadTable: $( "#files" ),
        buildUploadRow: function (files, index, handler) {
            return $( "<tr><td>" + files[index].name + "<\/td>" +
                    \'<td class="file_upload_progress"><div><\/div><\/td>\' +
                    \'<td class="file_upload_cancel">\' +
                    \'<button class="ui-state-default ui-corner-all" title="Cancel">\' +
                    \'<span class="ui-icon ui-icon-cancel">Cancel<\/span>\' +
                    \'<\/button><\/td><\/tr>\');
        },
        buildDownloadRow: function (file, handler) {
            return $(\'<tr><td>\' + file.name + \'<\/td><\/tr>\');
        }
		});
	});';
	
	
	
$_SESSION[ "title" ] = "Vertragsakte anlegen";
include( 'ssi_header.php' );
$_SESSION[ "title" ] = "";

$zstr = liefere_zufaelligen_string( );


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

$e = liefere_wertemenge_elemente( $mandant_name, "attribute_vertragsmanagement" );

if ( $e[ 0 ] > 0 )
{
	echo "<form name='vertrag_anlegen' action='ver_func.php?cmd=vertrag_anlegen' method='post' accept-charset='UTF-8' >";
	
	echo "<div style='float:left;border: 0px solid white;'>(<b>Fettdruck</b> => Pflichtfeld)<table >";
	
	foreach( $e[ 2 ] as $element )
	{
		$feldtyp = explode( "_", $element[ "alpha_02" ] );
		
		$feldtyp = $feldtyp[ 0 ];				// Feldtyp: alpha, datum, num, geld
		
		$pflichtfeld = $element[ "alpha_03" ];	// ja/nein
		
		if ( $pflichtfeld == "ja" )
		{
			$pflicht_an		= "<b>";
			$pflicht_aus	= "</b>";
		}
		else
		{
			$pflicht_an		= "";
			$pflicht_aus	= "";
		}
		
		$wertemenge = $element[ "alpha_04" ];	// Wertemengenkürzel, wenn Wertemengenfeld, sonst leer
		
		if ( strlen( $wertemenge ) > 0 )
		{
			// Wertemenge
			$wertem = liefere_wertemenge_elemente( $mandant_name, $wertemenge );
			$feld = "<select style='width:255px;' >";
			if ( $wertem[ 0 ] > 0 )
			{
				foreach( $wertem[ 2 ] as $welement )
				{
					$feld = $feld."<option value='".$welement[ "alpha_01" ]."'>".$welement[ "alpha_01" ]."</option>";
				}
			}
			$feld = $feld."</select>";
			
		}
		else
		{
			// keine Wertemenge
			
			switch( $feldtyp )
			{
				case "datum":
					$feld = "<input style='width:240px;' type='text' name='".$element[ "alpha_02" ]."' class='date-pick' >";
					break;
				case "alpha":
					$feld = "<input style='width:255px;' type='text' name='".$element[ "alpha_02" ]."'   >";
					break;
				case "num":
					$feld = "<input style='width:255px;' type='text' name='".$element[ "alpha_02" ]."'   >";
					break;
				case "geld":
					$feld = "<input style='width:255px;' type='text' name='".$element[ "alpha_02" ]."'   >";
					break;
				
			}
			
		}
		
		
		
		echo "<tr><td>".$pflicht_an.$element[ "alpha_01" ].$pflicht_aus."</td><td>".$feld."</td></tr>";
	}
	
	echo "</table><input type='hidden' value='".$zstr."' name='praefix_1' />
	
	<input type='submit' value='Vertragsakte anlegen' /><input type='reset' value='Abbrechen'></div>

	</form>";
}
echo "<div style='float:left; border: 0px solid yellow;'>

<form id='file_upload' action='ver_upload.php' method='POST' enctype='multipart/form-data'>
    <input type='file' name='file[]' multiple>
	<input type='hidden' value='".$zstr."' name='praefix_2' />
    <button>Upload</button>
    <div class='file_upload_label'>Dateien hochladen</div>
</form>

<table id='files'></table></div><div style='clear:left; border: 0px solid yellow;'></div>";


echo '<div name="ergebnis_3" id="ergebnis_3" style=" margin-top:25px; margin-left:25px;" >'.$_SESSION[ "meldung_ver" ].'</div>';
$_SESSION[ "meldung_ver" ] = "";
echo '</div>';



echo "</div>";
include( 'ssi_footer.php' );

?>