<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>

<head>
	<title>Title here!</title>
</head>

<body>
	<?php
	set_time_limit(600);
	require 'database.inc.php';
	$requette = "SELECT * FROM `commande" . ID_GARAGE . "` WHERE `DateModification` >= '2011-08-20'";
	$resultat = Connection::executeRawQueryWithfetchAll($requette);
	foreach ($resultat as $ligne) {
		$requette2 = "SELECT * FROM `commandearticles" . ID_GARAGE . "` WHERE NoCommande = " . $ligne["NoCommande"] . " AND TypeData = 0 AND GM = 0";
		$resultat2 = Connection::executeRawQueryWithfetchAll($requette2);
		foreach ($resultat2 as $ligne2) {
			$resultat3 = Article::getArticleByNoArticle($$ligne2["NoArticle"]);
			foreach ($resultat3 as $ligne3) {
				if ($ligne2["GM"] != $ligne3["GroupeMarchandise"]) {
					echo $ligne2["NoCommande"] . " " . $ligne2["NoArticle"] . " " . $ligne2["GM"] . " " . $ligne3["GroupeMarchandise"] . "<br />\n";
					$requette4 = "UPDATE commandearticles" . ID_GARAGE . " SET GM = " . $ligne3["GroupeMarchandise"] . " WHERE NoCommande = " . $ligne2["NoCommande"] . " AND Position = " . $ligne2["Position"];
					Connection::executeRawQuery($requette4);
					echo $requette4 . "<br />\n";
				}
			}
		}
	}
	?>
</body>

</html>