<?php
$i=0;
foreach($briks as $briksup) {
	$seq = mysqli_query($bdd,"SELECT seq_id, seq_nom, SUBSTR(seq_nom,1,20), SUBSTR(seq_nom,1,13), niveau FROM ".$prefix."_sequences WHERE seq_id ='".$briksup['seq_id']."'");
	$seq_info = mysqli_fetch_assoc($seq);
	$seq_nomaff = @mb_ereg_replace("[?]","",mb_convert_encoding($seq_info['SUBSTR(seq_nom,1,13)'],"utf-8"));
	$seq_nomaffopt = @mb_ereg_replace("[?]","",mb_convert_encoding($seq_info['SUBSTR(seq_nom,1,20)'],"utf-8"));
	if($colorsys_info['valeur']=='niv') {
		$colorniv = substr($briksup['division'],0,1);
		if($colorniv!='6'&&$colorniv!='5'&&$colorniv!='4'&&$colorniv!='3'&&$colorniv!='2'&&$colorniv!='1'&&$colorniv!='t'&&$colorniv!='T') { $colorniv = 'a'; }
		$color = mysqli_query($bdd,"SELECT bgcolor FROM ".$prefix."_edtnivcolor WHERE niveau = '".$colorniv."'");
		$color_info = mysqli_fetch_assoc($color);
		$bgcolor = $color_info['bgcolor'];
	}
	else if($colorsys_info['valeur']=='cod') {
		if(isset($briksup['code'])) {
			$color = mysqli_query($bdd,"SELECT bgcolor_code FROM ".$prefix."_edtcode WHERE code = '".$briksup['code']."'");
			$color_info = mysqli_fetch_assoc($color);
			$bgcolor = @$color_info['bgcolor_code'];
		}
		else {
			$bgcolor = '#fff';
		}
	}
	
	if($noseq==0) { 
		echo '<td'; 
		if($briksup['activ_brik']==0) { echo ' class="brik_desactiv"'; }
		else if($briksup['activ_brik']==1) { echo ' class="brik_activ"'; }
		else if($briksup['activ_brik']==2) { echo ' class="brik_archiv archiv"'; }
		$event_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT uid FROM ".$prefix."_edtevent WHERE brik_id = '".$briksup['brik_id']."'"));
		$verif_brik = mysqli_num_rows(mysqli_query($bdd,"SELECT brik_id FROM ".$prefix."_edtbrik WHERE code='".$briksup['code']."' AND seq_id='".$briksup['seq_id']."' AND division='".$briksup['division']."'"));
		echo ' id="td'.$briksup['brik_id'].'">'; include('./db/proc/edt_cartouche.php'); echo ' <img style="height:24px;" src="./img/nav/help.png" title="';
		if($event_nb==0) { echo EDT_BRIKA2; }
		else { echo $event_nb.' '.EDIT_INFO3; if($event_nb>1) { echo PLURIEL; } echo EDT_BRIKA3; }
		if($verif_brik>1) { echo EDT_BRIKA4; }
		echo '"/><div class="radio-item-emb"><form action="" method="POST" name="react">';
		if($verif_brik==1) { echo '<input type="submit" class="boutontab" name="reactivb'.$briksup['brik_id'].'" value="'.REACT_TINY.'" />'; }
		if($event_nb==0) { echo ' <input type="submit" class="boutontab" name="supprb'.$briksup['brik_id'].'" value="'.SUPPR_TINY.'" />'; }
		echo '</form>';
		echo '</div></td>'; 
	}
	else if($noseq==1) {
		echo '<td'; 
		if($briksup['activ_brik']==0) { echo ' class="brik_desactiv"'; }
		else if($briksup['activ_brik']==1) { echo ' class="brik_activ"'; }
		else if($briksup['activ_brik']==2) { echo ' class="brik_archiv archiv"'; }
		$event_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT uid FROM ".$prefix."_edtevent WHERE brik_id = '".$briksup['brik_id']."'"));
		$verif_brik = mysqli_num_rows(mysqli_query($bdd,"SELECT brik_id FROM ".$prefix."_edtbrik WHERE code='".$briksup['code']."' AND seq_id='".$briksup['seq_id']."' AND division='".$briksup['division']."'"));
		echo ' id="td'.$briksup['brik_id'].'">'; include('./db/proc/edt_cartouche.php'); echo ' <img style="height:24px;" src="./img/nav/help.png" title="';
		if($event_nb==0) { echo EDT_BRIKA2; }
		else { echo $event_nb.' '.EDIT_INFO3; if($event_nb>1) { echo PLURIEL; } echo EDT_BRIKA3; }
		if($verif_brik>1) { echo EDT_BRIKA4; }
		echo '"/><div class="radio-item-emb"><form action="" method="POST" name="react">';
		if($verif_brik==1) { echo '<input type="submit" class="boutontab" name="reactivb'.$briksup['brik_id'].'" value="'.REACT_TINY.'" />'; }
		if($event_nb==0) { echo ' <input type="submit" class="boutontab" name="supprb'.$briksup['brik_id'].'" value="'.SUPPR_TINY.'" />'; }
		echo '</form>';
		echo '</div></td>';
		$k++;
	}
	if(isset($_POST['reactivb'.$briksup['brik_id'].''])) {
		$brik_id = $briksup['brik_id'];
		mysqli_query($bdd,"UPDATE ".$prefix."_edtbrik SET activ_brik = '1' WHERE brik_id = '".$brik_id."'");
		echo '<script language="Javascript">
		<!--
		document.location.replace("edt.php?page=briques");
		// -->
		</script>';	
	}
	if(isset($_POST['supprb'.$briksup['brik_id'].''])) {
		$brik_id = $briksup['brik_id'];
		mysqli_query($bdd,"DELETE FROM ".$prefix."_edtbrik WHERE brik_id = '".$brik_id."'");
		echo '<script language="Javascript">
		<!--
		document.location.replace("edt.php?page=briques");
		// -->
		</script>';	
	}
	$i++;
}
?>