<?php require_once('../Connections/cn_conexion.php'); ?>
<?php include_once("../includes/funciones.php");?>
<?php
$txt=trim($_GET['txt']);
if($txt==""){
	$consult_parcial="";
	}else{
		$consult_parcial="  AND clientes.nom_cliente='".cadenaopt($txt)."'  ";	
		}
?>
<?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_cn_conexion, $cn_conexion);
$query_rs_gastos = "SELECT * FROM gastos, cuentas, clientes WHERE  cuentas.id_cuenta= gastos.id_cuenta AND gastos.hab_gasto='1' AND gastos.id_cliente=clientes.id_cliente  ".$consult_parcial." ORDER BY gastos.id_gasto DESC";
$rs_gastos = mysql_query($query_rs_gastos, $cn_conexion) or die(mysql_error());
$row_rs_gastos = mysql_fetch_assoc($rs_gastos);
$totalRows_rs_gastos = mysql_num_rows($rs_gastos);


?>
<?php
if($totalRows_rs_gastos>0){
?>
<?php do { ?>
<?php
	if($row_rs_gastos['tipo_cuenta']=='-1'){
		$classe_colortexto="enlace_rojo";
		$clase_texto='class="texto_rojo"';
		}else{
			$classe_colortexto="enlace_normal";
			$clase_texto="";
			}
  ?>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
	  <td width="14%" height="25"><p <?php echo($clase_texto);?>><?php echo fecha_peru($row_rs_gastos['fecha']); ?></p></td>
	  <td width="57%"><p><a href="#" class="<?php echo($classe_colortexto);?>" onclick="modificar_gasto('<?php echo $row_rs_gastos['id_gasto']; ?>')"><?php echo $row_rs_gastos['nom_cuenta']; ?></a></p></td>
	  <td width="9%"><p <?php echo($clase_texto);?>>
	    <?php $ruc=$row_rs_gastos['monto_real']; echo $ruc ; ?>
      </p></td>
	  <td width="20%" align="center"><p <?php echo($clase_texto);?>>
	    <?php $moneda=$row_rs_gastos['moneda']; if($moneda=='S'){echo("Soles");}else{echo("Dolares");}?>
      </p>	    </p></td>
	</tr>
  </table>
  <?php } while ($row_rs_gastos = mysql_fetch_assoc($rs_gastos)); ?>
<?php
}else{
	echo("No se ha encontrado documentos");
	}
?>
              <?php
mysql_free_result($rs_gastos);
?>
