<style type="text/css">
.donate_red{
border: 1px solid rgba(236, 120, 120, 0.13);
font: 11px Tahoma, "Times New Roman", Times, serif;
color: rgb(255, 255, 255);
background:#F30;
text-shadow: rgba(0, 0, 0, 0.31) 0px 1px;
padding: 5px;
}
.donate_green{
border: 1px solid rgba(236, 120, 120, 0.13);
font: 11px Tahoma, "Times New Roman", Times, serif;
color: rgb(255, 255, 255);
background:#0C0;
text-shadow: rgba(0, 0, 0, 0.31) 0px 1px;
padding: 5px;
}
</style>
<?php
if(isset($_SESSION['user']) && isset($_SESSION['pass'])) {
	if(isset($_POST['trimite']))
	{
		$cod = replace($_POST['cod']);
		$retea = $_POST['retea'];
		$donator = $_SESSION['user'];
		$valoare = $_POST['valoare'];
		$status = "In curs de verificare";
		$data = date("H:i:s d-M-y ");
		if(!empty($cod) && is_numeric($cod))
		{
			$check_cod = mysql_query("Select * from web.donate where cod='$cod'");
			if(mysql_num_rows($check_cod)==0)
			{
				mysql_query("Insert into web.donate (data,cont,cod,retea,valoarea,status) values ('$data','$donator','$cod','$retea','$valoare','$status')");
				echo succes("Codul a fost trimis.Acesta va fi verificat in maxim 24h.");
			}
			else
			{
				error("Codul a mai fost folosit deja.");
			}
		}
		else
		{
			echo error("Codul trebuie sa aiba minim 14 cifre, in functie de retea.");	
		}
	}
?>
<h4>DONATII CARTELE REINCARCABILE ( 1 &euro; = 4 MD ) : </h4>
<table width="100%" border="0">
  <tr>
    <td class="top">Total donat : <?php 
	$cuantum = mysql_query("Select SUM(valoarea) from web.donate where cont='".$_SESSION['user']."' and status='Valid'");
  $total = mysql_fetch_array($cuantum);
  if($total['SUM(valoarea)']==NULL)
  {
	echo "0 &euro;";
  }
  else
  {
	echo $total['SUM(valoarea)']." &euro;";  
  }
	?></td>
  </tr>
</table><?php 
$query1 = mysql_query("Select * from web.donate where cont='".$_SESSION['user']."' and status='Invalid'");
if(mysql_num_rows($query1)<=3)
{
?>
Puteti cumpara monezi cu coduri reincarcare in retele de mai jos. <br>
<font color="red">La 3 coduri invalide accesul dumneavoastra la acest serviciu va fi restrictionat</font>

<form action="" method="POST"><table width="100%" border="0">
  <tr>
    <td width="12%">Retea : </td>
    <td width="88%"><select name="retea" class="iRg_input">
    <option name="Orange" >Orange</option>
    <option name="Vodafone">Vodafone</option>
    <option name="Cosmote">Cosmote</option>
    </select>
    
    </td>
  </tr>
   <tr>
    <td>Valoare :</td>
    <td><select name="valoare" class="iRg_input">
    <?php for($i=5;$i<=50;$i++) { ?>
    <option value="<?=$i?>"><?=$i?> &euro;</option>
    <?php } ?>
    </select></td>
  </tr>
  <tr>
    <td>Cod :</td>
    <td><input name="cod" type="text" maxlength="16" class="iRg_input"/></td>
  </tr>
  <tr>
    <td colspan="2"><input type="submit" value="TRIMITE DONATIA" name="trimite" class="buton"/></td>
  </tr>
</table>
</form>
<?php }
else
{
	echo error("Accesul tau la acest serviciu a fost restrictionat.Contactati un administrator."); 
} ?>
<h4>DONATIILE MELE </h4>


<table width="100%" border="0">
  <tr class="top">
    <td width="2%" class="iR_stats_level">#</td>
    <td width="23%" class="iR_stats_level">Data</td>
    <td width="28%" class="iR_stats_level">Cod</td>
    <td width="9%" class="iR_stats_level">Valoare</td>
    <td width="19%" class="iR_stats_level">Retea</td>
    <td width="19%" class="iR_stats_level">Status</td>
  </tr>
  <?php
  
  $donatii = mysql_query("Select * from web.donate where cont='".$_SESSION['user']."'");
  while($ds = mysql_fetch_object($donatii))
  {
	  $count++;
	  if($ds->status == "In curs de verificare")
	  {
			$clasa =  "iR_stats_reset"; 
	  }
	  elseif($ds->status == "Invalid")
	  {
			$clasa = "msg_error";  
	  }
	  elseif($ds->status == "Valid")
	  {
			$clasa = "msg_succes";  
	  }
	  $str = chunk_split($ds->cod, 4, ' ');
  ?>
  <tr class="top">
    <td class="<?=$clasa?>"><?=$count?>#</td>
    <td class="<?=$clasa?>"><?=$ds->data;?></td>
    <td class="<?=$clasa?>"><?=$str?></td>
    <td class="<?=$clasa?>"><?=$ds->valoarea?> &euro;</td>
    <td class="<?=$clasa?>"><?=$ds->retea?></td>
    <td class="<?=$clasa?>"><?=$ds->status?></td>
  </tr>
  <?php } ?>
</table>

<?php
} else { error("Zona restrictionata.Logati-va pentru a avea acces."); } ?>