<?php require_once('../Connections/cn_conexion.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;
}
}

mysql_select_db($database_cn_conexion, $cn_conexion);
$query_rs_clientesgastos = "SELECT * FROM gastos, clientes WHERE clientes.id_cliente=gastos.id_cliente AND gastos.hab_gasto='1'  GROUP BY gastos.id_cliente";
$rs_clientesgastos = mysql_query($query_rs_clientesgastos, $cn_conexion) or die(mysql_error());
$row_rs_clientesgastos = mysql_fetch_assoc($rs_clientesgastos);
$totalRows_rs_clientesgastos = mysql_num_rows($rs_clientesgastos);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td height="30">Lista de Cajas Abiertas por Cliente</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td width="1%">&nbsp;</td>
    <td width="3%">&nbsp;</td>
    <td width="61%" height="30">Nombre del Cliente</td>
    <td width="17%">&nbsp;</td>
    <td width="12%">Fecha</td>
    <td width="6%">&nbsp;</td>
  </tr>
  <?php do { ?>
    <tr>
      <td>&nbsp;</td>
      <td><img src="../imagenes/cierre_caja.png" width="24" height="24" border="0">&nbsp;</td>
      <td height="25"><a href="#" class="enlace_normal" onClick="cerrar_caja('<?php echo $row_rs_clientesgastos['id_cliente']; ?>')"><?php echo $row_rs_clientesgastos['nom_cliente']; ?></a></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <?php } while ($row_rs_clientesgastos = mysql_fetch_assoc($rs_clientesgastos)); ?>
<tr>
  <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<?php
mysql_free_result($rs_clientesgastos);
?>
