<?php

// SELECT //////////////////////////////////////////////////////
	
//// Secteurs d'activité
	
	$_SELECT['select']['secteur_activite'] = '<select name="secteur_activite" style="max-width:300px">';
	$_SELECT['search']['secteur_activite'] = '<select name="secteur_activite"><option value="null">Indifférent</option>';
	$_TAB['secteur_activite'] = array();

	$sql = dbquery(" SELECT * FROM secteurs_activite ORDER BY secteur_activite");
	
	for($i=0;$i<dbnumrows($sql);$i++){
		$secteur_id		= dbresult($sql,$i,"secteur_activite");
		$secteur_nom	= dbresult($sql,$i,"nom");

		$_SELECT['secteur_activite'][$secteur_id] = $secteur_nom;

		$_SELECT['select']['secteur_activite'] .= '<option value="'.$secteur_id.'">'.$secteur_nom.'</option>';
		$_SELECT['search']['secteur_activite'] .= '<option value="'.$secteur_id.'">'.$secteur_nom.'</option>';
		$_TAB['secteur_activite'][$secteur_id]  = $secteur_nom;
	}

	$_SELECT['select']['secteur_activite'] .= '</select>';
	$_SELECT['search']['secteur_activite'] .= '</select>';

//// CSP

	$_SELECT['select']['csp'] = '<select name="csp">';
	$_SELECT['search']['csp'] = '<select name="csp"><option value="null">Indifférent</option>';

	$sqlCSP = dbquery('SELECT * FROM csp');

	for($i=0;$i<dbnumrows($sqlCSP);$i++){
		$csp		= dbresult($sqlCSP,$i,'csp');
		$nom		= dbresult($sqlCSP,$i,'nom');
		
		$_SELECT['select']['csp'] .= '<option value="'.$csp.'">'.$nom.'</option>';
		$_SELECT['search']['csp'] .= '<option value="'.$csp.'">'.$nom.'</option>';
	}

	$_SELECT['select']['csp'] .= '</select>';
	$_SELECT['search']['csp'] .= '</select>';


//// Intitulé diplome
	
	$_DIPLOME_TYPE = Array("secondaire","superieur","diplomes_etrangers","en_cours","autres_formations");

	foreach($_DIPLOME_TYPE as $key => $value){

		if($key==3){$value="superieur";} // les formations en cours sont des diplomes supérieurs

		$_SELECT['select']['diplome_intitule'][$key] = '<select name="diplome_intitule_'.$key.'">';
			
		$sql = dbquery("SELECT * FROM codes_diplomes WHERE categorie_diplome='".$value."' ORDER BY intitule");
		for($i=0;$i<dbnumrows($sql);$i++) {
			$intitule						= dbresult($sql,$i,'intitule');
			$id_code_diplome				= dbresult($sql,$i,'id_code_diplome');
			$_SELECT['select']['diplome_intitule'][$key]	.= '<option value="'.$id_code_diplome.'">'.$intitule.'</option>';
		}

		$_SELECT['select']['diplome_intitule'][$key].= '</select>';
	}
		



//// Spécialités diplomes

	$_SELECT['select']['specialite_diplome'] = '<select name="specialite_diplome" ><optgroup label=""><option value="0">Aucune</option></optgroup>';
	$_SELECT['search']['specialite_diplome'] = '<select name="specialite_diplome" ><option value="null">Indifférent</option>';
	
	$sql_specialites = dbquery("SELECT * FROM nsf ORDER BY id_nsf");
	
	for($i=0;$i<dbnumrows($sql_specialites);$i++) {
		$id_nsf		 = dbresult($sql_specialites,$i,'id_nsf');
		$specialite	 = dbresult($sql_specialites,$i,'specialite');

		$_TAB['specialite_diplome'][$id_nsf] = $specialite; 

		if(preg_match('#0#',$id_nsf) && $id_nsf <> '201'){				// 201 seule exception
			if(preg_match('#00#',$id_nsf)){
				$_SELECT['select']['specialite_diplome'].= '<optgroup label="'.$specialite.'" class="a"></optgroup>';
				$_SELECT['search']['specialite_diplome'].= '<optgroup label="'.$specialite.'" class="a"></optgroup>';
			}
			else {
				if ($i>3){
					$_SELECT['select']['specialite_diplome'].= '</optgroup>';
					$_SELECT['search']['specialite_diplome'].= '</optgroup>';
				}
				$_SELECT['select']['specialite_diplome'].= '<optgroup label="'.$specialite.'" class="b">';
				$_SELECT['search']['specialite_diplome'].= '<optgroup label="'.$specialite.'" class="b">';
			}
		}
		else{
			$_SELECT['select']['specialite_diplome'].= '<option value="'.$id_nsf.'">'.$specialite.'</option>';
			$_SELECT['search']['specialite_diplome'].= '<option value="'.$id_nsf.'">'.$specialite.'</option>';
		}
	}
	$_SELECT['select']['specialite_diplome'].= '</optgroup></select>';
	$_SELECT['search']['specialite_diplome'].= '</optgroup></select>';


//// Niveau diplome

	$_SELECT['search']['niveau_diplome'] = '<select name="niveau_diplome"><option value="null">Indifférent</option><optgroup label="Jusqu\'à BAC+2">';
	
	$sql = dbquery("SELECT * FROM niveaux_diplome ");
	
	for($i=0;$i<dbnumrows($sql);$i++) {
		$id_niveau_diplome	 = dbresult($sql,$i,'id_niveau_diplome');
		$niveau_diplome		 = dbresult($sql,$i,'niveau_diplome');
		
		if($id_niveau_diplome == 6)
			$_SELECT['search']['niveau_diplome'] .= '<option value="<=2">Tous les diplômes jusqu\'à Bac + 2</option></optgroup><optgroup label="Supérieur à BAC+2">';

		$_SELECT['search']['niveau_diplome'] .= '<option value="'.$id_niveau_diplome.'">'.$niveau_diplome.'</option>';
	}

	$_SELECT['search']['niveau_diplome'] .= '<option value=">2">Tous les diplômes supérieurs à Bac + 2</option></optgroup></select>';

//// Taille entreprise (CV)

	$_SELECT['select']['taille_entreprise'] = '
				<select name="taille_entreprise">
					<option value="0">De 1 à 9</option>
					<option value="1">De 10 à 49</option>
					<option value="2">De 50 à 499</option>
					<option value="3">De 500 à 999</option>
					<option value="4">+ de 1000</option>
				</select>
	';

//// Langue étrangère (CV)
	
	$_TAB['langue'] = array('Anglais','Allemand','Espagnol','Italien','Portugais','Arabe','Chinois','Japonais','Russe');


	$_SELECT['select']['langue']	= '<select name="langue"><option value="null">Choisir ...</option>';
	$_SELECT['search']['langue']	= '<select name="langue"><option value="null">Indifférent</option>';

	foreach( $_TAB['langue'] as $key => $value){
		$_SELECT['select']['langue'] .= '<option value="'.$key.'">'.$value.'</option>';
		$_SELECT['search']['langue'] .= '<option value="'.$key.'">'.$value.'</option>';
	}
	
	$_SELECT['select']['langue'] .= '</select>';
	$_SELECT['search']['langue'] .= '</select>';

	$_SELECT['select']['langue1'] = str_replace('name="langue"','name="langue1"', $_SELECT['select']['langue'] );
	$_SELECT['select']['langue2'] = str_replace('name="langue"','name="langue2"', $_SELECT['select']['langue'] );
	$_SELECT['select']['langue3'] = str_replace('name="langue"','name="langue3"', $_SELECT['select']['langue'] );


//// Pratique langue étrangère (CV)

	$_TAB['pratique'] = array('Écrit seulement','Parlé seulement','Écrit et parlé');

	$_SELECT['select']['pratique'] = '<select name="pratique"><option value="null">Choisir ...</option>';
	$_SELECT['search']['pratique'] = '<select name="pratique"><option value="null">Indifférent</option>';

	foreach( $_TAB['pratique'] as $key => $value){
		$_SELECT['select']['pratique'] .= '<option value="'.$key.'">'.$value.'</option>';
		$_SELECT['search']['pratique'] .= '<option value="'.$key.'">'.$value.'</option>';
	}
	
	$_SELECT['select']['pratique'] .= '</select>';
	$_SELECT['search']['pratique']  .= '</select>';

	$_SELECT['select']['pratique1'] = str_replace('name="pratique"','name="pratique1"', $_SELECT['select']['pratique'] );
	$_SELECT['select']['pratique2'] = str_replace('name="pratique"','name="pratique2"', $_SELECT['select']['pratique'] );
	$_SELECT['select']['pratique3'] = str_replace('name="pratique"','name="pratique3"', $_SELECT['select']['pratique'] );


//// Niveau langue étrangère (CV)
	
	$_TAB['niveau'] = array('Langue maternelle','Notions','Courant');

	$_SELECT['select']['niveau'] = '<select name="niveau"><option value="null">Choisir ...</option>';
	$_SELECT['search']['niveau'] = '<select name="niveau"><option value="null">Indifférent</option>';

	foreach( $_TAB['niveau'] as $key => $value){
		$_SELECT['select']['niveau'] .= '<option value="'.$key.'">'.$value.'</option>';
		$_SELECT['search']['niveau'] .= '<option value="'.$key.'">'.$value.'</option>';
	}
	
	$_SELECT['select']['niveau'] .= '</select>';
	$_SELECT['search']['niveau']  .= '</select>';

	$_SELECT['select']['niveau1'] = str_replace('name="niveau"','name="niveau1"', $_SELECT['select']['niveau'] );
	$_SELECT['select']['niveau2'] = str_replace('name="niveau"','name="niveau2"', $_SELECT['select']['niveau'] );
	$_SELECT['select']['niveau3'] = str_replace('name="niveau"','name="niveau3"', $_SELECT['select']['niveau'] );


//// Niveau formation
		
		$_TAB['niveau_formation'] = Array("Aucun","BAC","BAC+2","BAC+3","BAC+4","BAC+5");
		
		$_SELECT['select']['niveau_formation'] = '<select name="niveau_formation">';
		$_SELECT['search']['niveau_formation'] = '<select name="niveau_formation"><option value="null">Indifférent</option>';

		foreach($_TAB['niveau_formation'] as $key => $value){
			$_SELECT['select']['niveau_formation'] .= '<option value="'.$key.'">'.$value.'</option>';
			$_SELECT['search']['niveau_formation'] .= '<option value="'.$key.'">'.$value.'</option>';
		}
		
		$_SELECT['select']['niveau_formation'] .= '</select>';
		$_SELECT['search']['niveau_formation'] .= '</select>';




//// Type contrat

		$_TAB['type_contrat'] = array( 
			"stage"		=> "Stage", 
			"cdi"		=> "CDI",
			"cdd"		=> "CDD",
			"pro"		=> "Contrat Pro",
			"autre"		=> "Autre"
			);

		$_SELECT['select']['type_contrat'] = '<select name="type_contrat" id="type_contrat">';
		$_SELECT['search']['type_contrat'] = '<select name="type_contrat" id="type_contrat"><option value="null">Indifférent</option>';

		foreach($_TAB['type_contrat'] as $key => $value){
			$_SELECT['select']['type_contrat'] .= '<option value="'.$key.'">'.$value.'</option>';
			$_SELECT['search']['type_contrat'] .= '<option value="'.$key.'">'.$value.'</option>';
		}
		
		$_SELECT['select']['type_contrat'] .= '</select>';
		$_SELECT['search']['type_contrat'] .= '</select>';



//// MOIS

	$_TAB['mois'] = Array(
					"01" => "Janvier",
					"02" => "Février",
					"03" => "Mars",
					"04" => "Avril",
					"05" => "Mai",
					"06" => "Juin",
					"07" => "Juillet",
					"08" => "Août",
					"09" => "Septembre",
					"10" => "Octobre",
					"11" => "Novembre",
					"12" => "Décembre"	
					);

	$mois_options = '';
	foreach($_TAB['mois'] as $key => $value){
		$mois_options .= '<option value="'.$key.'">'.$value.'</option>';	
	}
	$mois_options .= '</select>';

	$_SELECT['select']['debut_mois']	= '<select name="debut_mois" id="debut_mois">'.$mois_options;
	$_SELECT['select']['fin_mois']		= '<select name="fin_mois" id="fin_mois">'.$mois_options;


//// ANNEES

	$annee_options = '';

	for($i=0;$i<50;$i++){
		$annee = (2014-$i);
		$annee_options .= '<option value="'.$annee.'">'.$annee.'</option>';
	}

	$annee_options .= '</select>';

	$_SELECT['select']['debut_annee']	= '<select name="debut_annee"  id="debut_annee">'.$annee_options;
	$_SELECT['select']['fin_annee']		= '<select name="fin_annee" id="fin_annee">'.$annee_options;



//// CODES POSTAUX + COMMUNES
	
	$cp		= '';
	$cedex	= '<optgroup label="Cedex">';

	$sql = dbquery("SELECT * FROM codes_postaux ORDER BY code_postal");
	
	for($i=0;$i<dbnumrows($sql);$i++){
		$code		= dbresult($sql,$i,"code_postal");
		$commune	= dbresult($sql,$i,"commune");
		
		if($code<>"14400" && $code<>"97600"){
			if(!preg_match('/CEDEX/',$commune)){
				$cp	.= '<option value="'.$code.'">'.$code.' - '.$commune.'</option>';
				$_TAB['commune'][$code] = $code.' - '.$commune;
			}
			else
				$cedex	.= '<option value="'.$code.'">'.$code.' - '.$commune.'</option>';
		}
	}
	
	$_SELECT['select']["commune"] = '<select name="commune">'.$cp.'</select>';
	$_SELECT['select']["commune_cedex"] = '<select name="commune">'.$cp.$cedex.'</select>';

	$_SELECT['search']["commune"] = '<select name="commune">
										<option value="null">Indifférent</option>
										<optgroup label="Région">
											<option value="NORD">Nord</option>
											<option value="OUEST">Ouest</option>
											<option value="SUD">Sud</option>
											<option value="EST">Est</option>
										</optgroup>
										<optgroup label="Commune">
										'.$cp.'
										</optgroup>
									</select>';

/*
$_CODE_POSTAL = array(
	
	"97400" => array (
		"ST DENIS",
		"BELLEPIERRE",
		"ST FRANCOIS",
		"LE BRULE"
		),
	
	
	"97410" => array(
		"ST PIERRE",
		"BASSE TERRE",
		"GRAND BOIS",
		"MONT VERT LES BAS",
		"MONT VERT LES HAUTS",	
		"TERRE SAINTE"
		),
	"97411" => array(
		"BOIS DE NEFLES ST PAUL"
		),
	"97412" => array(
		"BRAS PANON",
		"RIVIERE DU MAT"
		),
	"97413" => array(
		"CILAOS",
		"PALMISTE ROUGE"
		),
	"97414" => array(
		"ENTRE DEUX"
		),
	"97416" => array(
		"LA CHALOUPE",
		),
	"97417" => array(
		"LA MONTAGNE",
		"ST BERNARD",
		"ST DENIS",
		),
	"97418" => array(
		"LE TAMPON",
		"LA PLAINE DES CAFRES"
		),
	"97419" => array(
		"LA POSSESSION",
		"STE THERESE",
		"LA RIVIERE DES GALETS",
		"DOS D ANE"
		),
	"97420" => array(
		"LE PORT",
		),
	"97421" => array(
		"ST LOUIS",
		"LA RIVIERE",
		"LES MAKES",
		),
	"97422" => array(
		"LA SALINE",
		),
	"97423" => array(
		"LE GUILLAUME",
		),
	"97424" => array(
		"PITON ST LEU",
		"LE PLATE"
		),
	"97425" => array(
		"LES AVIRONS",
		"TEVELAVE"
		),
	"97426" => array(
		"TROIS BASSINS",
		),
	"97425" => array(
		"LES AVIRONS",
		"TEVELAVE"
		),




97427 L ETANG SALE
97427 L ETANG SALE LES BAINS
97428 CIRQUE DE MAFATE
97428 LA NOUVELLE
97428 LA NOUVELLE
97428 LA POSSESSION
97428 ST PAUL
97429 PETITE ILE
97429 PITON GOYAVES
97430 LE QUATORZIEME
97430 LE TAMPON
97430 LES TROIS MARES

97430 PONT D YVES
97430 TAMPON 17EME KM
97431 LA PLAINE DES PALMISTES
97432 RAVINE DES CABRIS
97433 HELL BOURG
97433 SALAZIE
97434 LA SALINE LES BAINS
97434 ST GILLES LES BAINS
97435 BERNICA
97435 ST GILLES LES HAUTS
97435 TAN ROUGE
97436 ST LEU
97437 STE ANNE
97438 GILLOT
97438 LA GRANDE MONTEE
97438 RIVIERE DES PLUIES
97438 STE MARIE
97439 LE PITON STE ROSE
97439 STE ROSE
97440 CAMBUSTON
97440 LA CRESSONNIERE
97440 ST ANDRE
97441 STE SUZANNE
97442 BASSE VALLEE
97442 ST PHILIPPE
97450 ST LOUIS
97460 BELLEMENE
97460 PLATEAU CAILLOUX
97460 ST PAUL
97470 BEAUFONDS
97470 ST BENOIT
97480 JEAN PETIT
97480 LES LIANES
97480 ST JOSEPH
97480 VINCENDO
97490 BOIS DE NEFLES
97490 LA BRETAGNE
97490 MOUFIA
97490 ST DENIS CHAUDRON
97490 STE CLOTILDE


	97425	LES AVIRONS	LES AVIRONS	
	97425	TEVELAVE	LES AVIRONS	

	97426	LES TROIS BASSINS	LES TROIS BASSINS	
	97427	L ETANG SALE	L ETANG SALE	
	97427	L ETANG SALE LES BAINS	L ETANG SALE	
	97428	CIRQUE DE MAFATE	CIRQUE DE MAFATE	
	97428	LA NOUVELLE	CIRQUE DE MAFATE	
	97428	LA POSSESSION	CIRQUE DE MAFATE	
	97428	ST PAUL	CIRQUE DE MAFATE	
	97429	PETITE ILE	PETITE ILE	
	97430	LE QUATORZIEME	LE TAMPON	
	97430	LE TAMPON	LE TAMPON	
	97430	LES TROIS MARES	LE TAMPON	
	97430	PONT D YVES	LE TAMPON	
	97431	LA PLAINE DES PALMISTES	LA PLAINE DES PALMISTES	
	97432	RAVINE DES CABRIS	RAVINE DES CABRIS	
	97432	ST PIERRE	RAVINE DES CABRIS	
	97433	HELL BOURG	SALAZIE	
	97433	SALAZIE	SALAZIE	
	97434	LA SALINE LES BAINS	ST GILLES LES BAINS	
	97434	ST GILLES LES BAINS	ST GILLES LES BAINS	
	97434	ST PAUL	ST GILLES LES BAINS	
	97435	BERNICA	ST GILLES LES HAUTS	
	97435	ST GILLES LES HAUTS	ST GILLES LES HAUTS	
	97435	ST PAUL	ST GILLES LES HAUTS	
	97435	TAN ROUGE	ST GILLES LES HAUTS	
	97436	ST LEU	ST LEU	
	97437	ST BENOIT	STE ANNE	
	97437	STE ANNE	STE ANNE	
	97438	GILLOT	STE MARIE	
	97438	RIVIERE DES PLUIES	STE MARIE	
	97438	STE MARIE	STE MARIE	
	97439	LE PITON STE ROSE	STE ROSE	
	97439	STE ROSE	STE ROSE	
	97440	CAMBUSTON	ST ANDRE	
	97440	LA CRESSONNIERE	ST ANDRE	
	97440	ST ANDRE	ST ANDRE	
	97441	STE SUZANNE	STE SUZANNE	
	97442	BASSE VALLEE	ST PHILIPPE	
	97442	ST PHILIPPE	ST PHILIPPE	
	97450	ST LOUIS	ST LOUIS	
	97460	BELLEMENE	ST PAUL	
	97460	ST PAUL	ST PAUL	
	97470	ST BENOIT	ST BENOIT	
	97480	LES LIANES	ST JOSEPH	
	97480	ST JOSEPH	ST JOSEPH	
	97480	VINCENDO	ST JOSEPH	
	97490	BOIS DE NEFLES	STE CLOTILDE	
	97490	LA BRETAGNE	STE CLOTILDE	
	97490	MOUFIA	STE CLOTILDE	
	97490	ST DENIS	STE CLOTILDE	
	97490	STE CLOTILDE	STE CLOTILDE	

);
*/
?>