<?php
//ini_set('include_path', '../');
include("../conexion/class-sb-conexion.php");
$Button_Caption = "Aceptar";
$solo_imputables =1;// intval($solo_imputables);
//$caracter="A";
?>

<!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>Buscar Códigos Contables...</title>
<script language="JavaScript" src="global_script.js"></script>
<script language="javascript">
<?

if($flag=="change"){

if($codigo_contable=='')
   $codigo_contable=0;
$sql="SELECT cuenta_contable2 as codigo, descripcion from plan_cuenta where cuenta_contable2 = ".$codigo_contable.";";

$db = new sb_mysql();
$consulta2 = $db->consulta_free($sql);   
$row2 = $db->sb_array($consulta2);
if($num_reg=='')
	$num_reg=0;

?>
function carga(){
var codigo="<?=$row2['codigo']?>";
var texto="<?=$row2['descripcion']?>";

window.opener.coloca_codigo(codigo,<?=$numreg;?>,texto);
window.close();
}
<?
}
?>



function setAccion()
{


    var codigo=document.frmtmp.select.options[document.frmtmp.select.selectedIndex].value;
	var texto=document.frmtmp.select.options[document.frmtmp.select.selectedIndex].text;
    <?
	if($num_reg=='')
	$num_reg=0;
	
	?>
	

	window.opener.coloca_codigo(codigo,<?=$num_reg;?>,texto);
	window.close();
}

function setcerrar() {
window.close();
}

function carga_precio() {
//alert("sdfds");
var codigo_precio =document.frmtmp.select.options[document.frmtmp.select.selectedIndex].value;
//var precio=

document.frmtmp.precio.value=codigo_precio.substring(codigo_precio.indexOf("-",0)+1 ,codigo_precio.length);
}

</script>
<style type="text/css">
		
	.Estilo7 {
	background-color: #FFFFFF;
	color: #000080;
	border:3px;
	font-weight: bold;
	font-size: 10px;
	width:500px;
	
	

}
.Estilo10 {
	font-size: 12px;
	font-weight: normal;
	background-color: #F0F5FF;
	text-align: right;
	font-weight: bold;
	border: 0px 0;
}
	
	
</style>

</head>
<body >
<form name="frmtmp">
   <table width="40%" border="0" align="center" style="border:3px solid #000080">
	   <tr align="center">
	    <td width="100%" colspan="2">
 		<a href="busca_codigo_II.php?caracter=A&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">A</a>
 		<a href="busca_codigo_II.php?caracter=B&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">B</a>
 		<a href="busca_codigo_II.php?caracter=C&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">C</a>
		<a href="busca_codigo_II.php?caracter=D&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">D</a>
		<a href="busca_codigo_II.php?caracter=E&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">E</a>
		<a href="busca_codigo_II.php?caracter=F&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">F</a>
		<a href="busca_codigo_II.php?caracter=G&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">G</a>
		<a href="busca_codigo_II.php?caracter=H&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">H</a>
		<a href="busca_codigo_II.php?caracter=I&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">I</a>
		<a href="busca_codigo_II.php?caracter=J&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">J</a>
		<a href="busca_codigo_II.php?caracter=K&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">K</a>
		<a href="busca_codigo_II.php?caracter=L&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">L</a>
		<a href="busca_codigo_II.php?caracter=M&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">M</a>
		<a href="busca_codigo_II.php?caracter=N&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">N</a>
		<a href="busca_codigo_II.php?caracter=Ń&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">Ń</a>
		<a href="busca_codigo_II.php?caracter=O&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">O</a>
		<a href="busca_codigo_II.php?caracter=P&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">P</a>
		<a href="busca_codigo_II.php?caracter=Q&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">Q</a>
		<a href="busca_codigo_II.php?caracter=R&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">R</a>
		<a href="busca_codigo_II.php?caracter=S&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">S</a>
		<a href="busca_codigo_II.php?caracter=T&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">T</a>
		<a href="busca_codigo_II.php?caracter=U&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">U</a>
		<a href="busca_codigo_II.php?caracter=V&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">V</a>
		<a href="busca_codigo_II.php?caracter=W&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">W</a>
		<a href="busca_codigo_II.php?caracter=X&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">X</a>
		<a href="busca_codigo_II.php?caracter=Y&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">Y</a>
		<a href="busca_codigo_II.php?caracter=Z&num_reg=<?=$num_reg;?>&solo_imputables=<?=$solo_imputables;?>" target="_self">Z</a>
		</td>
	   </tr>
       
	   <tr align="center">
		<input type="hidden" name="num_reg"  value="<?=$num_reg?>" > 
		 <td width="100%" colspan="2">
               <div align="center">
 		               <select name="select" size="15" class="Estilo7" onChange="carga_precio()" onclinck="carga_precio()" >
                      <?
        $registros = 0;


if ($solo_imputables != 1 ){		
         $wsql = "select cuenta_contable2 as codigo, trim(descripcion) as descripcion from plan_cuenta where  trim(descripcion) LIKE '".$caracter."%' order by descripcion asc;";
		 }else{
		 $wsql = "select cuenta_contable2 as codigo, trim(descripcion) as descripcion from plan_cuenta where  trim(descripcion) LIKE '".$caracter."%' order by descripcion asc;";
		 };
		
		 $db = new sb_mysql();
		 $consulta2 = $db->consulta_free($wsql);   
		 
		 while($row2 = $db->sb_array($consulta2)){
                $registros++;
                ?>
                         <option   value="<?=$row2[0];?>">
                         <?=$row2[0]." - ".$row2[1];?>
                         </option>
                         <?
           echo "\n";
             };
  ?>
                       </select>
                   </div></td>
	 </tr>
      <tr>
	  <td  align="left">
		<b><font size="3" face="Arial, Helvetica, sans-serif" color="#000080">Código Contable
		<input type="text" name="precio" style="width:50" class="Estilo10" disabled>
		</font></b>
			</td>
         <td  align="right">
			<input type="button" name="Submit1" style="width:100" onClick="setAccion()" value="<?= $Button_Caption ?>">
			<input type="button" name="Submit2" style="width:100" onClick="setcerrar()" value="Cerrar">
		 </td>
	  </tr>
   </table>
</form>
<script>
<?
if($flag=="change"){
?>carga();<?
}
?>
</script>
</body>
</html>
