<?php

		

	for( $i=0; $i<sizeof($_SESSION['infos']); $i++ ){
		echo "	<div class='alert alert-success'><i class='fa fa-check'></i> ".$_SESSION['infos'][$i]."</div>";
	}
	for( $i=0; $i<sizeof($_SESSION['errors']); $i++ ){
		echo "	<div class='alert alert-danger'><i class='fa fa-warning'></i> ".$_SESSION['errors'][$i]."</div>";
		if ($i==0)
		echo "<script> $(document).ready( function(){ $('#login-box').shake(); }); </script>\n";
	}
	unset( $_SESSION['infos'] );
	unset( $_SESSION['errors'] );

	$rs = $dbo->fetchArray("select id as idintervento , descrizione from co_tipidocumento");	
	$n2 = sizeof($rs);

	  echo "<br><br>\n";
	  
	  echo "<div class='row'>\n";
	  echo "	<div class='col-md-12'>\n";
	  echo "		<h3>Seleziona un Documento in formato xml da caricare</h3>\n";

	  echo "<form action=\"".$rootdir."/controller.php?id_module=".$id_module."\" method=\"post\" enctype=\"multipart/form-data\" class='form-inline' id='new-module'>\n";
	  echo "	<input type='hidden' name='op' value='upload'>\n";
	  

//Seleziona tipologia documento
	echo "		<div class='row'>\n";
		echo "		<div class='col-md-6'>\n";
		echo "			<div class='form-group'>\n";
		echo "				<label>Tipologia documento</label>\n";	
		if( ($n2) == 0 ){
			echo "				... Non ci sono tipologie documenti in archivio ...<br><br>\n";
			echo "				<input type=\"hidden\" id=\"idintervento\" value=\"\">\n";
		}	
		else{
			echo "				<select id=\"idintervento\" name=\"idintervento\" class=\"superselect\" onchange=\"$('#descrizione').val( $(this).find(':selected').text() );  ;\">\n";
			echo "				<option value=\"\">- Seleziona una tipologia -</option>\n";				
			echo "					<optgroup label=\"Tipologie documento (".$n2.")\">\n";		
			for( $i=0;$i<$n2;$i++ ){					
				echo "				<option value=\"".$rs[$i]['idintervento']."\"  >".$rs[$i]['descrizione']." </option>\n";
			}		
			echo "				</optgroup>\n";
		}	
		echo "				</select>\n";
		echo "			</div>\n";
		echo "		</div>\n";	
	echo "		</div>\n";	
	
	echo "		</br>\n";	
	
	echo "		<div class='row'>\n";	
		echo "		<div class='col-md-6'>\n";
			echo "	<label><input type=\"file\" name=\"blob\"></label><button type='button'   class='btn btn-primary' onclick=\"if( confirm('Confermi caricamento documento ?') ){ $('#new-module').submit(); }\"><i class='fa fa-upload'></i> Carica...</button>\n";
		echo "		</div>\n";	
	echo "		</div>\n";	
	echo "</form><br>\n\n";
	

	echo "	</div>\n";
	echo "</div>\n";
    
    
    
?>
   
