<?
//require("smodi.php");
session_start();
require("../conectar.php");


echo <<<h
<html>

<head>
<title>Buscar</title>
		 <style>
		     .cont-busc{position:relative;width:850px;height:auto;min-height:400px !important;font-family:arial;color:#086A87;top:10px;overflow-x:hidden;margin:auto;}
			  .cont-busc .bar-busc{position:relative;width:900px;height:90px;font-family:arial;color:#086A87;top:0px;margin:auto;}
			  .cont-res{position:relative;width:900px;font-family:arial;color:#086A87;top:0px;margin:auto;}
			  .datos{border:0;-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;-khtml-border-radius: 5px;border-collapse: collapse;color:#0d0d0d;}
			  .datos .tl{-moz-box-shadow:inset 0 0 20px #000000;-webkit-box-shadow: inset 0 0 20px #000000;box-shadow: inset 0 0 20px #000000;}
			  .datos .trs{min-height:30px !important;max-height:30px !important;height:30px !important;background:url(images/tcancion.jpg) repeat-x;color:#ffffff;font-size:12px;}
              .datos .trsb{min-height:15px !important;max-height:15px !important;height:15px !important;background:url(images/tcancion2.png);color:#58D3F7;font-size:12px;}
			  .datos .trsb td{border-left:solid 1px #6E6E6E;}
			  .datos .trsb td:first-child{border-left:none;}
			  .datos .tr{min-height:20px !important;max-height:20px !important;height:20px !important;background:#ffffff;border-top:solid 1px #D8D8D8; color:#084B8A;font-size:13px;}
			  .datos .trb{min-height:20px !important;max-height:20px !important;height:20px !important;background:#ffffff;border-top:solid 1px #D8D8D8; color:#084B8A;font-size:13px;}
			  .datos .trb td{border-left:solid 1px #D8D8D8;padding-left:10px;}
			  .datos .trb td:first-child{border-left:none;}
			   
			  .datos .tr td{border-left:solid 1px #D8D8D8;padding-left:10px;}
			  .datos .tr td:first-child{border-left:none;}
	          .datos .tr:hover{background:#01A9DB;color:#ffffff;}	
	          .datos .tr:hover a{color:#ffffff;}
              .datos .tr1{min-height:20px !important;max-height:20px !important;height:20px !important;background:#E0F8F7;border-top:solid 1px #D8D8D8; color:#084B8A;font-size:13px;}	
              .datos .tr1 td{border-left:solid 1px #D8D8D8;padding-left:10px;}
			  .datos .tr1 td:first-child{border-left:none;}
	          .datos .tr1:hover{background:#01A9DB;color:#ffffff;}	
	          .datos .tr1:hover a{color:#ffffff;}	
			  .datos .activo{min-height:20px !important;max-height:20px !important;height:20px !important;background:#F3E2A9;border-top:solid 1px #D8D8D8; color:#084B8A;font-size:13px;}
			  .loading{position:fixed;left:50%;top:50%;width:250px;height:70px;margin-left:-125px;margin-top:-35px;display:none;background:url(images/bkloading.png);background-repeat:no-repeat;color:#ffffff;padding-top:25px;text-align:center;font-family:arial;font-size:12px;}
               .rentas{position:absolute;top:40px;width:800px;left:50%;margin-left:-421px;border:solid 1px  #D8D8D8; background:#FFFFFF; display:none;padding:20px;-Moz-box-shadow: 0 0 85px #000;-webkit-box-shadow: 0 0 85px #000; box-shadow: 0 0 85px #000;}
               .rentatab{border-collapse:collapse;color:#0d0d0d;font-family:arial;font-size:12px;}
               .rentatab .filatit{min-height:20px !important;max-height:20px !important;height:20px !important;background:#D8D8D8;border-top:solid 1px #D8D8D8;font-size:13px;}			   
               .rentatab .fila{min-height:20px !important;max-height:20px !important;height:20px !important;background:#ffffff;border-top:solid 1px #D8D8D8; color:#084B8A;font-size:12px;}
               .rentatab .fila td{border-left:solid 1px #D8D8D8;padding-left:5px;}
               .rentatab .fila td:first-child{border-left:none;}
               .cerrar{float:right;margin-top:-20px;margin-right:-20px;}	
			   .sinfor{text-decoration:none}
             
p#vtip { display: none; position: absolute; padding: 5px; left: 5px; font-size: 1em; background-color: #83C023; border: 1px solid #83C023; -moz-border-radius: 5px; -webkit-border-radius: 5px; z-index: 9999;color:#000000 }
p#vtip #vtipArrow { position: absolute; top: -10px; left: 5px }
.vtip{cursor:pointer;}			   
	     </style>
<script src="funcion.js" type="text/javascript" language="javascript"></script>
<script>
			 function select(id){
				 var n=document.getElementById(id);
				 if(n.align=="false"){
			     $("#"+n).addClass("activo");
				 n.align="true";
				 }else{
				 $("#"+id).removeClass("activo");
				 n.align="false";
				 }
			 }
</script>
<SCRIPT LANGUAGE="JavaScript">
<!--
var msg  = 'Realmente desea borrar a';
function confirmLink(link, nombre)
{
    if (msg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed = confirm(msg + ':\\n' + nombre);
    
	return is_confirmed;
} 

function linkcombo(f){
	var findex=f.por.selectedIndex;
	var p=f.por.options[findex].value;
	if (p == "Todos"){
h;

if ($imp=='s'){
echo <<<h
 var opciones="toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=790,height=520,top=0,left=0";
 window.open('catalogoCuentasBus.php?b=s&por=Todos&nf=s',"",opciones);
h;
}
else
	echo "document.location=\"catalogoCuentasBus.php?b=s&por=Todos\";";
?>	
	}
}

//-->
</SCRIPT>
</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000" onLoad="this.document.forma.pal.focus();">
<?

if ($ac=='borr'){
	$sql="DELETE FROM catalogocuentas WHERE id='$cual'";
	mysql_query($sql);
}

if ($imp=='s'){
	$tar="target=blank";
	$agr="&nf=s";
}


echo <<<h
  <form name="forma" method="post" action="catalogoCuentasBus.php?b=s$agr" $tar>
   <table width=600 border=0 cellspacing=0 cellpadding=4 align=center>
     <tr BGCOLOR=WHITE>
	   <td>
	     <font face="Verdana, Arial, Helvetica, sans-serif" size=2>Búsqueda por: </font>
		  <select name="por" onChange="linkcombo(this.form)" class=imputbox>
		   <option value="descripcion">Descripcion</option>
		   <option value="num">No.Cuenta</option>
		   <option value="Todos">Mostrar Todos</option>
          </select>
		 <input type="text" name="pal" class="imputbox" size=20 maxlength=20>  <input type="submit" name="bus" value=" Buscar " class="botones">
	 </td>
    </tr> 
   </table>
  </form>
h;



if ($b=='s'){
	if (!$pal && $por!='Todos'){ 
		echo "<center>Debe especificar una cadena a buscar</center>";
		echo "</body></html>";
		mysql_close();
        exit(); 
	} 
      
	if ($por=='Todos'){
		$sql="SELECT * FROM catalogocuentas";
	}
	else{
		$sql="SELECT * FROM catalogocuentas WHERE $por LIKE '%$pal%'";
	}
        
	$r=mysql_query($sql );
	$cant=mysql_num_rows($r);
    if($cant == 0){
		echo"<center>No existe ningún registro con la palabra: <b>$pal</center>";
	}
	else{
echo <<<h
<table class="datos" width="850">
<tr class="trsb">
h;

echo <<<h
	<td></td>
	<td></td>
	<td align="center"><B>Id</B></td>
	<td align="center"><B>Cuenta</B></td>
	<td align="center"><B>Subcuenta</B></td>
	<td align="center"><B>Operación</B></td>
	<td align="center"><B>Descripción</B></td>
	<td align="center"><B>Tipo</B></td>
	<td align="center"><B>Grupo</B></td>
	<td align="center"><B>Naturaleza</B></td>
	<td align="center"><B>Saldo inicial</B></td>
	</tr>
h;
$c="";
$i=0;
$l=1;
		while ($l = mysql_fetch_object ($r)){
echo <<<h
<tr class="tr$c" id="fila$i" align="false" onclick="javascript:select(this.id);">
h;
$i++;
$l++;


echo <<<h
	<td>
		<a href="#x" onclick="window.open('catalogoCuentasCap.php?mod=s&cual=$l->id','','toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,top=0,left=0');">Modificar</a>
	<td NOWRAP>
		<a href="catalogoCuentasBus.php?ac=borr&b=s&cual=$l->id&por=$por&pal=$pal" target="prin"  onclick="return confirmLink(this, '$l->num . $l->numdet $l->descripcion');"><FONT  COLOR="#FF0000">Borrar</FONT></a>
	</td>
h;

echo <<<h
    <td>$l->id</td>
	<td>$l->num</td>
	<td>$l->numdet</td>
	<td>$l->operacion</td>
	<td>$l->descripcion</td>
	<td>$l->tipo</td>
	<td>$l->grupo</td>
	<td>$l->naturaleza</td>
	<td nowrap>$l->saldoinicial</td>
</tr>
h;
if($c==""){$c="1";}else{$c="";}
		}
		mysql_free_result ($r);
          
        echo "</table>";
	}
}

mysql_close();
?>
</body>

</html>
