<?php
/**
* MiniClick
* Gestionnaire de tableau collaboratif
* Copyright (C) 2006 Guillaume Monet <gm@ibreizh.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 
*
* @package miniclick
* @version 3.1.0
*/


$num=$_GET['num'];

//Appel de la page pour annuler un import
if (isset($_GET['num'])){
	//Suppression des ajouts
	$sql_table=mysql_query("SELECT Table_Id, Object_Id FROM IMPORT WHERE Fichier_Id=$num");
	echo "SELECT Table_Id, Object_Id FROM IMPORT WHERE Fichier_Id=$num<br>";
	while($result_table=mysql_fetch_object($sql_table)){
		$sql_delete1="DELETE FROM ".$result_table->Table_Id." WHERE ".ucfirst(strtolower($result_table->Table_Id))."_Id='".$result_table->Object_Id."'";
		echo $sql_delete1."<br>";
		mysql_query($sql_delete1);
	}
	//Suppression des mise à jours
	$sql_up=mysql_query("SELECT Table_Id, Object_Id, Colone_Id, Value  FROM ARCHIVAGE WHERE Fichier_Id=$num ORDER BY Date DESC");
	echo "SELECT Table_Id, Object_Id, Colone_Id, Value  FROM ARCHIVAGE WHERE Fichier_Id=$num GROUP BY Table_Id, Object_Id<br>";
	while($result_up=mysql_fetch_object($sql_up)){
		$sql_restitution="UPDATE ".$result_up->Table_Id." SET ".$result_up->Colone_Id."='".$result_up->Value."' WHERE ".ucfirst(strtolower($result_up->Table_Id))."_Id=".$result_up->Object_Id;
		mysql_query($sql_restitution);
		$sql_delete2="DELETE FROM Archivage WHERE Object_Id='".$result_up->Object_Id."' AND Table_Id='".$result_up->Table_Id."' AND Colonne_Id='".$result_up->Colone_Id."' AND Value='".$result_up->Value."' AND Fichier_Id=".$num;
		echo $sql_restitution."<br>".$sql_delete2."<br>";
		mysql_query($sql_delete2);
	
	}
}
	

?>





