<?php require_once('../../Connections/controle.php'); ?>
<?php
// technocurve arc 3 php mv block1/3 start
$mocolor1 = "";
$mocolor2 = "#EBEBD8";
$mocolor3 = "#CCFF00";
$mocolor = $mocolor1;
// technocurve arc 3 php mv block1/3 end
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_controle, $controle);
$query_pgto = "SELECT * FROM pagamentos WHERE YEAR(data) = YEAR(NOW()) AND MONTH (data) = MONTH(NOW())ORDER BY data DESC";
$pgto = mysql_query($query_pgto, $controle) or die(mysql_error());
$row_pgto = mysql_fetch_assoc($pgto);
$totalRows_pgto = mysql_num_rows($pgto);

        //Busca dos Números para a Soma
mysql_select_db($database_controle, $controle);
$query_pgto = mysql_query("SELECT sum(valor) FROM pagamentos WHERE YEAR(data) = YEAR(NOW()) AND MONTH (data) = MONTH(NOW())");
while($sum = mysql_fetch_array($query_pgto)){
$soma = $sum['sum(valor)'];
}
       //Fim Busca dos Números para a Soma

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href='http://fonts.googleapis.com/css?family=Text+Me+One' rel='stylesheet' type='text/css'/>
<link href='http://fonts.googleapis.com/css?family=Petit+Formal+Script' rel='stylesheet' type='text/css'/>
<link href='http://fonts.googleapis.com/css?family=Cinzel:400,700' rel='stylesheet' type='text/css'/>
<link href='http://fonts.googleapis.com/css?family=Josefin+Slab:400,700,700italic' rel='stylesheet' type='text/css'/>
<link href="../css/estilos_clientes.css" rel="stylesheet" type="text/css" />

</head>

<body>
<div id="pgto">

  <div class="tablepgto"><table cellspacing="5" >
  <tr>
    <td colspan="4" align="center"><span>PAGAMENTOS</span></td>
    </tr>
  <tr>
    <td width="290">&nbsp;</td>
    <td width="145">&nbsp;</td>
    <td width="188">&nbsp;</td>
    <td width="97">&nbsp;</td>
  </tr>
  <tr>
    <td align="left">Cliente </td>
    <td align="center">Mes </td>
    <td align="center">Data </td>
    <td align="right">Valor R$</td>
  </tr>
  <?php do { ?>
    <tr<?php 
// technocurve arc 3 php mv block2/3 start
echo " style=\"background-color:$mocolor\" onMouseOver=\"this.style.backgroundColor='$mocolor3'\" onMouseOut=\"this.style.backgroundColor='$mocolor'\"";
// technocurve arc 3 php mv block2/3 end
?>>

      <td><?php echo $row_pgto['nome_clientes']; ?></td>
      <td align="center"><?php echo $row_pgto['mes_pgto']; ?></td>
      <td align="center"><?php echo date('d/m/Y', strtotime($row_pgto[data])); ?></td>
      <td align="right"><?php echo $row_pgto['valor']; ?></td>
     

    </tr>
    <?php 
// technocurve arc 3 php mv block3/3 start
if ($mocolor == $mocolor1) {
	$mocolor = $mocolor2;
} else {
	$mocolor = $mocolor1;
}
// technocurve arc 3 php mv block3/3 end
?>
    <?php } while ($row_pgto = mysql_fetch_assoc($pgto)); ?>
  <tr>
    <td>&nbsp;</td>
    <td colspan="3" align="right"><span>TOTAL R$ <?php echo number_format($soma, 2, ',', '.'); ?></span></td>
</tr>
</table>
</div>
</div>
</body>
</html>


<?php
mysql_free_result($pgto);
?>
