<?php require_once('../Connections/paivaconex.php'); 
require_once('funcoes.php'); 

?>
<?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;
}
}

$sql ='';

	if(isset($_POST['data'])){
	
	$sql = "WHERE Baixa <= '".convertdata($_POST['data'])."'";
	
	}


mysql_select_db($database_paivaconex, $paivaconex);
$query_saldos = "Select NomeConta, sum(vl_rec-vl_pag) as valor From saldos 
". $sql ."
Group by NomeConta";
$saldos = mysql_query($query_saldos, $paivaconex) or die(mysql_error());
$row_saldos = mysql_fetch_assoc($saldos);
$totalRows_saldos = mysql_num_rows($saldos);
?>
<?php 

	require_once 'controls/verifylogin.php';

?>

<!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>
	
		<title>Módulo Financeiro</title>
		
		<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
		<?php include_once('controls/import.php'); ?>
	
	<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
	</head>
<body>
	
<?php include_once('controls/header.php'); ?>

	<div class="content">
	
		<div class="form">
		
		<?php include_once('controls/menu.php'); ?>
			
			<div id="conteudo-site">
			
			  <div class="titulo-conteudo-site">
				<img src="images/applications.png" title="" alt="" /> Saldos dos Bancos</div>
			
		      <p>&nbsp;</p>
		      <form id="form1" name="form1" method="post" action="saldos.php">
		        <p>Verificar Saldo em Data Anterior</p>
		        
		        
		        <p>
		          <label for="data"></label>
		          <span id="sprytextfield1">
                  <input name="data" type="text" id="data" />
                  <span class="textfieldRequiredMsg">Um valor e necessario.</span><span class="textfieldInvalidFormatMsg">Formato invalido.</span></span></p>
                <p>
                  <input type="submit" name="button" id="button" value="Verificar" />
                </p>
		      </form>
		      <p>&nbsp;</p>
		      <p>&nbsp;</p>
		      <table width="257" height="60" border="1">
		        <?php do { ?>
	            <tr>
	              <td width="119"><?php echo $row_saldos['NomeConta']; ?></td>
	              <td width="122" align="right"><?php echo number_format($row_saldos['valor'], 2,',', '.'); ?></td>
                </tr>
		          <?php } while ($row_saldos = mysql_fetch_assoc($saldos)); ?>
	          </table>
		      <p>&nbsp;</p>
		      <p>&nbsp;</p>
		      <p>&nbsp;</p>
		
          </div>
			
		</div>
		
	</div>
	
	<?php include_once('controls/footer.php'); ?>
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "date", {format:"dd/mm/yyyy"});
</script>
</body>
</html>
<?php
mysql_free_result($saldos);
?>
