<?php

// VAR

	$_SELECT['permis']['1'] = 'Oui';
	$_SELECT['permis']['0'] = 'Non';
	$_SELECT['select']['permis'] = '
		<select name="permis">
			<option value="0">Non</option>
			<option value="1">Oui</option>
		</select>
	';

	$_SELECT['vehicule']['1'] = 'Oui';
	$_SELECT['vehicule']['0'] = 'Non';
	$_SELECT['select']['vehicule'] = '
		<select name="vehicule">
			<option value="0">Non</option>
			<option value="1">Oui</option>
		</select>
	';




// VALEURS

	if ($value == "" || $value==" ")						$value			='<i class="lighter">Non renseigné</i>';
	if ($value == '<i class="lighter">Non renseigné</i>')	$input_value	= "";
	else													$input_value	= $value;

// REQUIRED
	
	if(isset($_DATA['required'][$key]))		$required = 'required="required"';
	else									$required = '';
		
// OPTIONS

	// adresse
	if($_DATA['type'][$key] == 'adresse'){
		$style		= 'style="width:350px;"';
		$max_length	= '255';
		$class		= '';
		$type		= 'text';
	}
	// tel
	elseif($_DATA['type'][$key] == 'tel'){
		$style		= '';
		$max_length	= '14';
		$class		= 'phone-mask';
		$type		= 'text';
	}
	// code_postal
	elseif($_DATA['type'][$key] == 'code_postal'){
		$style		= '';
		$max_length	= '5';
		$class		= '';
		$type		= 'text';
	}
	// mail
	elseif($_DATA['type'][$key] == 'email'){
		$style		= '';
		$max_length	= '30';
		$class		= '';
		$type		= 'email';
	}
	// select
	elseif($_DATA['type'][$key] == 'select'){
		$style		= '';
		$class		= '';
		$type		= 'select';
		
	}
	// radio oui/non
	elseif($_DATA['type'][$key] == 'radio'){
		$style		= '';
		$class		= '';
		$type		= 'radio';
		
	}
	elseif($_DATA['type'][$key] == 'textarea'){
		$style		= 'style="width:280px;height:50px;"';
		$class		= '';
		$type		= 'textarea';
		
	}
	else{
		$style		= '';
		$max_length	= '30';
		$class		= '';
		$type		= 'text';
	}

// CHAMP
	// select
	if($_DATA['type'][$key]== 'select'){
		$select = str_replace('value="'.$value.'"','value="'.$value.'" selected ', $_SELECT['select'][$key]);
		$field	= $_DATA['label'][$key]." : ".$select;
		$value	= $_SELECT[$key][$value];
		if($value=='')	$value='<i class="lighter">Non renseigné</i>';
	}
	//radio oui/non
	elseif($_DATA['type'][$key] == 'radio'){
		if( $value == 1 )			{$checked1 = 'checked = "checked"';$checked2 = "";$value="Oui";}
		elseif( $value == 0 )		{$checked2 = 'checked = "checked"';$checked1 = "";$value="Non";}
		else						{$checked2 = 'checked = "checked"';$checked1 = "";}
		$field = $_DATA['label'][$key].' :&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp Oui <input type="radio" name="'.$key.'" value="Oui" '.$checked1.'> Non<input type="radio" name="'.$key.'" value="Non" '.$checked1.'>';
	}
	// textarea
	elseif($_DATA['type'][$key] == 'textarea'){
		if($value == '<i class="lighter">Non renseigné</i>' )	$textarea = "";
		else													$textarea = $value;
		$field = '<textarea name="'.$key.'" '.$style.'>'.$textarea.'</textarea><br><br>';
	}
	else {
		$field = $_DATA['label'][$key].' : <input type="'.$type.'" name="'.$key.'" class="'.$class.'"  value="'.$input_value.'" '.$style.' '.$required.' maxlength="'.$max_length.'" />';
	}
?>