<?php
include ('logue.php');
include ('entete2.php');
include ('entete.php');
include ('ressource.php');
include ('chantiercalcul.php');
//include ('placevaisseaux.php');
include ('siege.php');

$sql2 = "SELECT robo_lvl,chantier_lvl,hangarfer_lvl,hangarfer_evolution,hangaror_lvl,hangaror_evolution,hangarada_lvl,hangarada_evolution,hangaror_lvl,hangarura_lvl,hangarura_evolution,labo_lvl,labo_evolution,fer_energie,or_energie,ada_energie,ura_energie,exfer_energie,exor_energie,central_energie FROM matgraph_users WHERE id='$planete' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
$row2 = mysql_fetch_array($res2); 


echo"<script language=\"javascript\">

function chrono(jours,heures,minutes,secondes,champs) {

  if (secondes > 0) {
    secondes--;
  }
  else {
    secondes = 59;

    if (minutes > 0) {
      minutes--;
    }
    else {
      minutes = 59;

      if (heures > 0) {
        heures--;
        jours--;
      }
      else {
        heures = 23;
      }
    }
  }

  if ( minutes == 59 && secondes == 59 && heures == 23 ) {
    window.history.go(0);
     }
  else {
    seconde = secondes;
    minute = minutes;
    text = '';
    if (jours > 0) {
      text +=jours + 'j ';
    }
    if (heures > 0) {
      text +=heures + 'h ';
    }
    if (minutes < 10) {
      minute = '0' + minutes;
    }
    if (seconde < 10) {
      seconde = '0' + secondes;
    }
      text +=minute + 'm ' + seconde + 's';

  document.getElementById('ligne_' + champs).innerHTML = 'Temps restant : <font color=#800000>'+ text +'</font>';
  setTimeout(\"chrono(\" + jours + \",\" + heures + \",\" + minutes + \",\" + secondes + \",'\" + champs + \"')\", 1000);
         }
    }
</script>
<style>
input {
border:1px solid #7E7E7E;
background-color:#000000;
font-family:'trebuchet ms',sans-serif;
color:white;
}
textarea {
border:1px solid #7E7E7E;
background-color:#000000;
font-family:'trebuchet ms',sans-serif;
color:white;
}
select, option {
background-color:#000000;
color:white;
}
</style>
<STYLE TYPE=text/css>
.Style1 {color: #0000FF}
.Style2 {color: #FF0000}
</STYLE>";
echo"<div align=\"center\"><form name=\"colo\" method=\"post\" action=\"colonie.php\" target=\"_parent\">
<table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
   <tr>
     <td width=\"100\" rowspan=\"2\" valign=\"middle\">
       <div align=\"center\">
         <input name=\"page\" value=\"" . $PHP_SELF . "\" type=\"hidden\" id=\"page\">
         <select name=\"idcolo\" onchange=submit()>";
include ('colo2.php'); 


$req = "SELECT planete,fer_ressource,or_ressource,ada_ressource,ura_ressource FROM matgraph_users WHERE idjoueur = $idlogin ORDER by id ASC";
$res = db_mysql_Query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);
if ( $num > 0 ) {
  $fer_total =0;
  $or_total =0;
  $ada_total =0;
  $ura_total =0;
  $total_ressource =0;
  While ( $row = mysql_fetch_array($res) ) {
  
  $fer = number_format($row[fer_ressource], 0, ',', ' ');
  $or = number_format($row[or_ressource], 0, ',', ' ');
  $ada = number_format($row[ada_ressource], 0, ',', ' ');
  $ura = number_format($row[ura_ressource], 0, ',', ' ');
  
  echo"<br>Sur  $row[planete] : $fer de fer, $or d'or, $ada de cristal, $ura de naquadah.";
  $fer_total += $row[fer_ressource];
  $or_total += $row[or_ressource];
  $ada_total += $row[ada_ressource];
  $ura_total += $row[ura_ressource];
  
  
  }
}
$total_ressource = number_format(($fer_total + $or_total + $ada_total + $ura_total), 0, ',', ' ');
  $fer_total = number_format($fer_total, 0, ',', ' ');
  $or_total = number_format($or_total, 0, ',', ' ');
  $ada_total = number_format($ada_total, 0, ',', ' ');
  $ura_total = number_format($ura_total, 0, ',', ' ');
  


echo"<br><br>Total fer : $fer_total
<br>Total or : $or_total
<br>Total cristal : $ada_total
<br>Total naquadah : $ura_total
<br>
<br>Total ressources : $total_ressource";
?>