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

<html>

<head>
<title>Buscar</title>
<LINK href="estilo.css" rel=stylesheet>
<script src="funcion.js" type="text/javascript" language="javascript"></script>
<SCRIPT LANGUAGE="JavaScript">
<!--
var msg ='Realmente desea borrar a';
function confirmLink(link, nombre)
{
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    if (msg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed=confirm(msg + ':\n' + nombre);
    
	return is_confirmed;
} // end of the 'confirmLink()' function


function linkcombo(f) {
  var findex=f.por.selectedIndex;
  var p=f.por.options[findex].value;
  if (p == "Todos")
    {
<?php
if ($imp=='s')
  {
echo <<<html
 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('buscarproveedor.php?b=s&por=Todos&nf=s',"",opciones);
html;

}
else
	echo "document.location=\"buscarproveedor.php?b=s&por=Todos\";";
?>	
	}
}

//-->
</SCRIPT>
		 <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>
</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000" <?php if ($nf != 's') echo"onLoad=\"this.document.forma.pal.focus();\""; ?> >
<?php

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

if ($imp=='s')
 {
  $tar="target=blank";
  $agr="&nf=s";
 }
if ($nf != 's')
{
	$clas="class=tbuscar";
echo <<<html
  <form name="forma" method="post" action="buscarproveedor.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="nombre">Nombre</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>
html;
 }
else $clas="class=tpeque";

  

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


echo <<<h
	<td></td>
	<td></td>
	<td>No</td>
	<td>NOMBRE</td>
	<td>RFC</td>
	<td>CONTACTO</td>
h;
$c="";
$i=0;
              while ($liga=mysql_fetch_object ($r)) 
                {
echo <<<h
<tr class="tr$c" id="fila$i" onclick="javascript:select(this.id);">
h;
$i++;


echo <<<h
	<td> 
		<a href="#x" onclick="window.open('proveedores.php?acc=captura&s=s&cual=$liga->id','','toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,top=0,left=0,width=900');">Modificar</a>
	</td>
	<td>
		<a href="buscarproveedor.php?acc=borr&b=s&cual=$liga->id&por1=$por1&por2=$por2&pal1=$pal1&pal2=$pal2&li=$li&lf=$lf" target="prin"  onclick="return confirmLink(this, '$liga->nombre');"><FONT  COLOR="#FF0000">Borrar</FONT></a>
	</td>
    <td>$liga->id</td>
	<td>$liga->nombre</td>
	<td>$liga->rfc</td>
	<td>$liga->contacto</td>
  </tr>
	
h;
if($c==""){$c="1";}else{$c="";}
	          }
			
          mysql_free_result ($r);
          
          print "</table>";
        }
    }

mysql_close();
?>
</body>

</html>
