<?php
//suppression du fichier xml
$seq = mysqli_query($bdd,"SELECT niveau, seq_nom FROM ".$prefix."_sequences WHERE seq_id = '$seq_id'");
$seq_info = mysqli_fetch_array($seq);
$rep_xml = "xml";
$rep_xml_open = opendir($rep_xml);
$chemin = $rep_xml."/idlog-".$seq_info['niveau']."e-".$seq_info['seq_nom'].".xml";
@unlink($chemin);
closedir($rep_xml_open);
//suppression ou archivage dans la bdd
$event_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT seq_id FROM ".$prefix."_edtevent WHERE seq_id = '$seq_id'"));
$brik_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT seq_id FROM ".$prefix."_edtbrik WHERE seq_id = '$seq_id'"));
if($event_nb==0&&$brik_nb==0) {
	mysqli_query($bdd,"DELETE FROM ".$prefix."_sequences WHERE seq_id = '$seq_id'");
	mysqli_query($bdd,"DELETE FROM ".$prefix."_seqsav WHERE seq_id = '$seq_id'");
}
else {
	mysqli_query($bdd,"UPDATE ".$prefix."_sequences SET seq_actif = 0, progression = '1000' WHERE seq_id = '$seq_id'");
}
//sélection et suppression des documents
$imgdel = mysqli_query($bdd,"SELECT * FROM ".$prefix."_seqdocs WHERE seq_id = '$seq_id'");
$rep_img = 'seqfichiers/'.$prefix;
$rep_img_open = opendir($rep_img);
while($imgdel_infos=mysqli_fetch_assoc($imgdel)) {
	$chemin = $rep_img."/".$imgdel_infos['docurl'];
	@unlink($chemin);
}
closedir($rep_img_open);
mysqli_query($bdd,"DELETE FROM ".$prefix."_seqnot WHERE seq_id = '$seq_id'");
mysqli_query($bdd,"DELETE FROM ".$prefix."_seqdocs WHERE seq_id = '$seq_id'");
echo '<script language="Javascript">
<!--
document.location.replace("edit.php?page=consult");
// -->
</script>';
?>