<?php
	include_once(__DIR__."/../../core.php");
	
	$idutente = $html->form('idutente');
	$module_name = 'Campi Personalizzati';


	
	$rs_stati = $dbo->fetchArray("select id as iddimensione , descrizione from zz_pannello_righe_dimensione");	
	$n3 = sizeof($rs_stati);
	
	
	
	
	echo "<label></label><br><br>\n";
	echo "<form id=\"link_form\" action=\"".$rootdir."/editor.php?id_module=".$modules_info[$module_name]['id']."&id_record=".$idutente."\" method=\"post\">\n";
	
	echo "	<input type='hidden' name='op' value='add_campo'>\n";
	echo "	<input type='hidden' name='backto' value='record-edit'>\n";

	
	//Seleziona tipologia documento
	echo "<div class='row'>\n";
			echo "		<div class='col-md-4'>\n";
				echo "			<label>Label</label>\n";
				echo "			<input type='text' name='id_label' id='id_label' class='form-control' >\n";
			echo "		</div>\n";
			
			echo "		<div class='col-md-4'>\n";
				echo "			<label>Nome campo</label>\n";
				echo "			<input type='text' name='id_campo' id='id_campo' class='form-control' >\n";
			echo "		</div>\n";

		echo "		<div class='col-md-4'>\n";
		echo "			<div class='form-group'>\n";
		echo "				<label>Dimensione</label>\n";	
		if( ($n3) == 0 ){
			echo "				... Non ci sono dimensioni  in archivio ...<br><br>\n";
			echo "				<input type=\"hidden\" id=\"iddimensione\" value=\"\">\n";
		}	
		else{
			echo "				<select id=\"iddimensione\" name=\"iddimensione\" class=\"superselect\" onchange=\"$('#descrizione').val( $(this).find(':selected').text() );  ;\">\n";
			echo "				<option value=\"\">- Seleziona una Dimensione -</option>\n";				
			echo "					<optgroup label=\"Dimensioni trovate (".$n3.")\">\n";		
			for( $i=0;$i<$n3;$i++ ){					
				echo "				<option value=\"".$rs_stati[$i]['iddimensione']."\"  >".$rs_stati[$i]['descrizione']." </option>\n";
			}		
			echo "				</optgroup>\n";
		}	
		echo "				</select>\n";
		echo "			</div>\n";
		echo "		</div>\n";	
	echo "		</div>\n";	

	

	
	
	
	
	
	echo "	<a onclick=\"duplica();\" class=\"btn btn-primary pull-right\"><i class=\"fa fa-plus\"></i> Aggiungi</a>\n";
	echo "</form>\n";
?>

	<script type="text/javascript">
	
		function duplica(){
			$("#link_form").submit();				
		}
		
		$(document).ready( function(){
			start_superselect();
			start_inputmask();
		});
	</script>

	<div class="clearfix"></div>

