<?
ini_set('error_reporting', 1);
session_start();
if ($_SESSION['estado'] != "ON")
		{
		?>
		<script>
			parent.location.href = 'index.php';
		</script>
		<? 
		exit();
		}
$id_empresa = $_SESSION['ss_empresa'];
$id_user = $_SESSION['ss_user'];
$id_autoriza=34;
//$txtbuscar="";
?>
<?
/*Sesiones*/
include("../conex.php");
include("../autoriza.php");

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Mantenimiento de Nombres...</title>
<style type="text/css">
<!--
.Estilo7 {
	font-size: small;
	color: #000099;
}
.Estilo11 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small; color: #000099; }
.Estilo13 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 9px;
	color: #000099;
	text-decoration: underline;
}
.Estilo14 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 9px;
	color: #000099;
}
.titulos2 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #003366;
	background-color: #FFFFFF;
	font-style: normal;
	font-weight: bold;
}
.botones {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
	height:26px;
}
-->
</style>
</head>

<body>

<form name="form3" method="post" action="muestra_nombres.php" target="_self">
<div align="center" class="titulos2">Mantenimiento de Nombres
  <table width="50%" border="0">
    <tr>
      <td width="25%"><div align="center">Buscar:</div></td>
      <td width="50%">
        <input name="txtbuscar" type="text" id="txtbuscar" size="35">
      </td>
      <td width="25%"><input name="bproducto" type="button" class="botones" id="bproducto" value="Buscar" onClick="busca_nombres();">
        </td>
    </tr>
  </table>
  </div>
      <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif" color="#000080"><span lang="es-cl"><b>
   		<a onClick="JavaScript:post_letra('A');" style="cursor:pointer">A</a>
 		<a onClick="JavaScript:post_letra('B');" style="cursor:pointer">B</a>
 		<a onClick="JavaScript:post_letra('C');" style="cursor:pointer">C</a>
		<a onClick="JavaScript:post_letra('D');" style="cursor:pointer">D</a>
		<a onClick="JavaScript:post_letra('E');" style="cursor:pointer">E</a>
		<a onClick="JavaScript:post_letra('F');" style="cursor:pointer">F</a>
		<a onClick="JavaScript:post_letra('G');" style="cursor:pointer">G</a>
		<a onClick="JavaScript:post_letra('H');" style="cursor:pointer">H</a>
		<a onClick="JavaScript:post_letra('I');" style="cursor:pointer">I</a>
		<a onClick="JavaScript:post_letra('J');" style="cursor:pointer">J</a>
		<a onClick="JavaScript:post_letra('K');" style="cursor:pointer">K</a>
		<a onClick="JavaScript:post_letra('L');" style="cursor:pointer">L</a>
		<a onClick="JavaScript:post_letra('M');" style="cursor:pointer">M</a>
		<a onClick="JavaScript:post_letra('N');" style="cursor:pointer">N</a>
		<a onClick="JavaScript:post_letra('O');" style="cursor:pointer">O</a>
		<a onClick="JavaScript:post_letra('P');" style="cursor:pointer">P</a>
		<a onClick="JavaScript:post_letra('Q');" style="cursor:pointer">Q</a>
		<a onClick="JavaScript:post_letra('R');" style="cursor:pointer">R</a>
		<a onClick="JavaScript:post_letra('S');" style="cursor:pointer">S</a>
		<a onClick="JavaScript:post_letra('T');" style="cursor:pointer">T</a>
		<a onClick="JavaScript:post_letra('U');" style="cursor:pointer">U</a>
		<a onClick="JavaScript:post_letra('V');" style="cursor:pointer">V</a>
		<a onClick="JavaScript:post_letra('W');" style="cursor:pointer">W</a>
		<a onClick="JavaScript:post_letra('X');" style="cursor:pointer">X</a>
		<a onClick="JavaScript:post_letra('Y');" style="cursor:pointer">Y</a>
		<a onClick="JavaScript:post_letra('Z');" style="cursor:pointer">Z</a>
		<br></b></span></font> </div> 
</form>

  <table width="50%" border="0" align="center">
    <tr><div align="center">
      <td width="20%"><input name="Submit" type="button" class="botones" style="width:60px" value="Crear" onClick="nuevo_nombres();"></td>
		<td width="30%">
		  <input type="button" name="salir" class="botones" value="Salir" onClick="window.top.open('','_parent','');window.top.close();">		</td>
         <?
	if ($id_user==1)
	{
	?>
   <td width="30%"><input type="button" name="cuadra" class="botones" value="T_Clientes" onClick="traspaso_clientes();">	</td>
    
    <td width="30%"><input type="button" name="varios" class="botones" value="T_varios" onClick="traspaso_varios();">	</td>
    
    <? 
	}
	?>   
        
    </div></tr>
  </table>
 
</form>

<form name="form1" method="post" action="" target="mainFrame">
  <table width="90%" border="1" align="center" cellspacing="0">
  <tr bgcolor="#00CCFF" class="detalle_tablas_II_negrita">
    <th width="80%" scope="col">Nombres</th>
    <th width="10%" scope="col">Editar</th>
    <th width="10%" scope="col">Borrar</th>
    <th width="10%" scope="col">Sucursal</th>
    </tr>
	<? 
		$cont=0;	
	$caract=$_GET["caracter"];
	if (isset($caract)) 
		{
		$bsql = "SELECT codigo, razon_social AS descripcion, rut FROM nombres WHERE razon_social LIKE '$caract%' ORDER BY razon_social ASC";
		$resultado =mysql_query($bsql,$enlace);
		}
	else if ( $txtbuscar !='')
				{
				$bsql = "SELECT codigo, razon_social AS descripcion FROM nombres WHERE razon_social LIKE '%$txtbuscar%' ORDER BY razon_social ASC";
				$resultado = mysql_query($bsql,$enlace);
				}
			else
				{
				$bsql = "SELECT codigo, razon_social AS descripcion FROM nombres WHERE razon_social LIKE '%' ORDER BY razon_social ASC";
				$resultado = mysql_query($bsql,$enlace);
				}

while (mysql_fetch_object ($resultado))
	{
	?>
	<tr bgcolor="#CBFEC2">
    <td class="Estilo14">
    <?=mysql_result($resultado, $cont, "descripcion");?></td>
    <td class="Estilo14"><div align="center">
        <span align="center" class="Estilo13" onClick="javascript:enviar('editar_nombres.php?cp=<?=mysql_result($resultado, $cont, "codigo");?>')" style="cursor:pointer" title="Click aqui para modificar datos del nombre">
		<img src="../Images/edit.gif"></span></div>
	</td>
    <td class="Estilo14"><div align="center">
		<span align="center" class="Estilo13" onClick="javascript:if(confirm('¿Desea eliminar este Nombre (Si lo elimina borrara todas las sucursales)?')) { enviar('eliminar_nombres.php?cp=<?=mysql_result($resultado, $cont, "codigo");?>')}" style="cursor:pointer" title="Click aqui para eliminar Nombre">
		<img src="../Images/delete.gif"></span></div>
	</td>
    <td class="Estilo14"><div align="center">
        <span align="center" class="Estilo13" onClick="javascript:enviar('sucursales.php?cp=<?=mysql_result($resultado, $cont, "codigo");?>')" style="cursor:pointer" title="Click aqui para modificar datos del nombre">
		<img src="../Images/ir.gif"></span></div>	</td>
    </tr>
  <?
  $cont=$cont+1;
}

?>
</table>
</form>

<form name="form2" method="post" action="" target="mainFrame">
  <input name="cod_bodega" type="hidden" id="cod_bodega">
</form>

</body>
</html>
<script language="javascript" type="text/javascript">
	function post_letra(letra)
	{
	
	document.form3.action = "muestra_nombres.php?caracter="+letra;
	document.form3.submit();
	}
	
function nuevo_nombres()
	{
	document.form2.action = "editar_nombres.php?cp=0";
	document.form2.submit();
	}
	
function traspaso_clientes()
	{
	document.form2.action = "Traspasa_client.php";
	document.form2.submit();
	}
function traspaso_rutas()
	{
	document.form2.action = "traspaso_rutas.php";
	document.form2.submit();
	}
function traspaso_varios()
	{
	document.form2.action = "Traspaso_f.php";
	document.form2.submit();
	}			
function busca_nombres()
	{
	document.form3.action = "muestra_nombres.php";
	document.form3.submit();
	}

function enviar(aux){
	document.form2.action = aux;
	document.form2.submit();
} 

</script>
