<?php

class Builder{
	
	public $rendu ='';
	
	
	public function init($numero_sondage){
		$ligne='
				<form name="sauvegarder" action="3.php" method="POST">
					<input type="text" name="titre" value="' . $_POST['titre'] . '" />
					<input type="text" name="sous_titre" value="' . $_POST['sous_titre'] . '" />
						<input type="hidden" name="numero_sondage" value="'.$numero_sondage.'" />
				
						
				<table border="0">
				<thead>
				<tr>
				<th>N°Q</th>
				<th>N°S</th>
				<th>type</th>
				<th>requis</th>
				<th>stat</th>
				<th>defaut</th>
				<th>illu</th>
				<th>points</th>
				<th>titre Q°</th>
				<th>suppr</th>
				</tr>
				</thead>
				<tbody>

				';
		$this->rendu.= $ligne;
	}
	public function newline($question_num, $sondage_num, $type,$titre=''){
		$ligne='
				<tr>
				<td>'.$question_num.'</td>
				<td>'.$sondage_num.'</td>
				<td>'.$type.'<input type="hidden" name="type_'.$sondage_num.'_'.$question_num.'" value="'.$type.'" /></td>
				
				<td>
					<input type="checkbox" name="requis_'.$sondage_num.'_'.$question_num.'" value="oui" checked="" />
				</td>
				<td>
					<input type="checkbox" name="stat_'.$sondage_num.'_'.$question_num.'" value="oui" checked="checked" />
				</td>
				
				<td><input type="text" name="defaut_' . $sondage_num . '_' . $question_num . '" value="" /></td>
				<td><input type="text" name="illu_' . $sondage_num . '_' . $question_num . '" value="" /></td>
				<td>
						<input type="text" size="2" name="points_oui_' . $sondage_num . '_' . $question_num . '" value="" />oui / non
						<input type="text" size="2" name="points_non_' . $sondage_num . '_' . $question_num . '" value="" />
				</td>
				
				<td><input type="text" name="titre_' . $sondage_num . '_' . $question_num . '" value="'.$titre.'" /></td>
				<td>x</td>
				</tr>

				';
		$this->rendu.= $ligne;
	}
	public function finish($i){
		$this->rendu.= '</tbody> </table>
			<input type="hidden" name="total" value="'.$i.'" />
				
			<br/>
			<input type="submit" value="enregistrer enregistrer enregistrer enregistrer enregistrer " name="save" />
			
			<br/>

		</form>';
		echo $this->rendu;
	}
	public function pseudoline($question_num, $sondage_num){
		$ligne='
				<tr>
				<td>'.$question_num.'</td>
				<td>'.$sondage_num.'</td>
				<td>txt</td>
				
				<td>
					<input type="checkbox" name="requis_'.$sondage_num.'_'.$question_num.'" value="oui" checked="checked" />
				</td>
				<td>
					<input type="checkbox" name="stat_'.$sondage_num.'_'.$question_num.'" value="oui" checked="checked" />
				</td>
				
				<td><input type="text" name="defaut_' . $sondage_num . '_' . $question_num . '" value="Pseudo" /></td>
				<td><input type="text" name="illu_' . $sondage_num . '_' . $question_num . '" value="" /></td>
				<td>
						<input type="text" size="2" name="points_oui_' . $sondage_num . '_' . $question_num . '" value="" />oui / non
						<input type="text" size="2" name="points_non_' . $sondage_num . '_' . $question_num . '" value="" />
				</td>
				
				<td><input type="text" name="titre_' . $sondage_num . '_' . $question_num . '" value="Votre Pseudo" /></td>
				<td>x</td>
				</tr>

				';
		$this->rendu.= $ligne;
	}
	public function newgrades($sondage_num){
		$ligne='grades séparés par des virgules. Seront répartis équitablement par calcul<br/>
				<textarea name="grades_' . $sondage_num . '" value="" cols=100 rows:2/>
Une oie blanche du slip,
Allumeur / allumeuse de PC tactile,
Télétubbie qui agite son antenne,
Triopiqueur glissant,
L’éponge qui aimait un hérisson,
Pompe à pétrole,
Slip in(can)décent,
Cerf qui s’astique les bois contre un arbre,
Métrosexuel en heure de pointe,
James bond de la pougnette, rapide et vif,
Gode of war aux doigts de fée,
Ludwig Van Bitauvent,
Fonctionnaire en vacances (hannn!),
Fapinator
</textarea>
					';
		$this->rendu.= $ligne;
	}
	public function table($sondage_num, $tableau){
		
		$this->init($sondage_num);
		$this->newgrades($sondage_num);
		$i=1;
		for ($j=0;$j<$tableau['boolean'];$j++){
				$this->newline($i,$sondage_num,'O/N');
			$i++;
		}
		if($tableau['demander_pseudo']=='oui'){
			$this->newline($i,$sondage_num,'pseudo','Votre Pseudo');
			$i++;
		}
		if($tableau['age']=='oui'){
			$this->newline($i,$sondage_num,'age','Votre âge');
			$i++;
		}
		if($tableau['radio_homme_femme']=='oui'){
			$this->newline($i,$sondage_num,'sexe','Votre sexe');
			$i++;
		}
		
		$this->finish($i);
		
		
	}
	
}
