<?php
  $requette = "SELECT c.NoCommande, c.`MontantTotal`, SUM(ca.PrixMulti) TotalCalcule FROM `commande".ID_GARAGE."` c, `commandearticles".ID_GARAGE."` ca WHERE c.Genre = 'F' AND c.Type != 'FI' AND c.DateCommande > '2005' AND c.NoCommande = ca.NoCommande AND ca.TypeData = 0 GROUP BY ca.NoCommande";
  $resultat = Connection::executeRawQueryWithfetchAll($requette);
  echo "<table border='1'><tr><th>No commande</th><th>Montant commande</th><th>Montant calculé</th></tr>\n";
  foreach ($resultat as $ligne)
  {
    if ($ligne["MontantTotal"] != $ligne["TotalCalcule"])
    {
      echo "<tr><td><a href='?NoCommande=".$ligne["NoCommande"]."&Type=4&Sous_Type=1&Etape=3&NoVisu=0'>".$ligne["NoCommande"]."</a></td><td>".$ligne["MontantTotal"]."</td><td>".$ligne["TotalCalcule"]."</td></tr>\n";
    }
  }
  echo "</table>\n";
  $requette = "SELECT c.NoCommande, c.`MontantTotal`, SUM(dc.Somme) TotalEncaisse FROM `commande".ID_GARAGE."` c, dbcash".ID_GARAGE." dc WHERE c.NoCommande = dc.NoFacture AND c.Paye = 'O' AND c.DateCommande > '2005' GROUP BY dc.NoFacture";
  $resultat = Connection::executeRawQueryWithfetchAll($requette);
  echo "<table border='1'><tr><th>No commande</th><th>Montant commande</th><th>Montant payé</th></tr>\n";
  foreach ($resultat as $ligne)
  {
    if (abs($ligne["MontantTotal"]) != abs($ligne["TotalEncaisse"]))
    {
      echo "<tr><td><a href='?NoCommande=".$ligne["NoCommande"]."&Type=4&Sous_Type=1&Etape=3&NoVisu=0'>".$ligne["NoCommande"]."</a></td><td>".$ligne["MontantTotal"]."</td><td>".$ligne["TotalEncaisse"]."</td></tr>\n";
    }
  }
  echo "</table>\n";
?>