<?php ob_start(); ?>
<?php $mobile= $_SESSION['user_mobile'];?>
<?php $touchs= $_SESSION['user_touchs'];?>

<?php if(file_exists('../_cfg/config.php')){include('../_cfg/config.php');} ?>

<?php if(empty($pidtxt)){$pidtxt='dl_'.$ptabla;}?>
<?php //if(empty($pcaption)){$pcaption=$pidtxt;}?>
<?php //if(empty($pphold) and $pobj==1 and $pcaption!=$pidtxt){$pphold=$pcaption;}?>
<?php //if(empty($pphold) and $pobj==1){$pphold=$pdefa;}?>
<?php //if(empty($ponblur)){$ponblur="";}?>
<?php if(empty($pwhere)){$pwhere="";}?>
<?php if(empty($pclass)){$pclass="";}?>
<?php //if(empty($ponchange)){$ponchange="";}?>
<?php //if(empty($pnotob)){$pnotob="";}?>
<?php //if(empty($pdisab)){$pdisab="";}?>
<?php //if(empty($pobj)){$pobj=3;} ?>
<?php //if(empty($psize)){$psize=12;} ?>
<?php //if(empty($pexact)){$pexact=0;} ?>
<?php //if(empty($phide)){$phide=0;} ?>
<?php //if(empty($preado)){$preado=0;} ?>
<?php //if(empty($pdatalist)){$pdatalist=2;} ?>
<?php //if($pobj>6){$pobj=3;} ?>
<?php //if(empty($pcolu)){$pcolu=$ptabla.'_descri,'.$ptabla.'_codigo';} ?>
<?php //if($preado==1){$pdatalist=-0.5;} ?>


<span>
<datalist id="<?php echo $pidtxt; ?>" style="display:none; font-family:arial;">
<?php
// 	if($pdatalist==2)
	{
	$list_sql='select ';
// 	if(mb_stristr('enti',$ptabla))
	$list_sql.= $ptabla.'_codigo as codigo, ';
	$list_sql.= $ptabla.'_descri as descri, ';
	if(mb_stristr('item',$ptabla))
	{
  	$list_sql.= $ptabla.'_codigov as codigov, ';
  	$list_sql.= $ptabla.'_puni as puni, ';
  	$list_sql.= $ptabla.'_pvp1 as pvp1, ';
//   	$list_sql.= 'tlla_descri as talla, ';
//   	$list_sql.= 'color_descri as color, ';
  }
    
	if(mb_stristr('item.enti',$ptabla))
	{
		$list_sql.= 'year('.$ptabla.'_lused) as fanio, ';
		$list_sql.= 'month('.$ptabla.'_lused) as fmes, ';
	}
    
	$list_sql.= $ptabla.'_status as status ';
	$list_sql.=' from '.$ptabla.'0 ';
	if(mb_stristr('item',$ptabla))
	{
// 		$list_sql.= 'left join tlla0 on item_tlla=tlla_codigo ';
// 		$list_sql.= 'left join clor0 on item_clor=clor_codigo ';
	}
	$list_sql.=' where '.$ptabla.'_status!="X" ';
  if($pwhere!=""){$list_sql.=' '.$pwhere.' ';}
	$list_sql.=' and '.$ptabla.'_status!="I" ';
		
	if(mb_stristr('item.enti',$ptabla))
	{
		$lyear=strtotime('-12 month');
		$lyear=date('Y-m-'.'01',$lyear);
		$list_sql.=' and '.$ptabla.'_lused>="'.$lyear.'" ';
	}

	if(mb_stristr('item.enti',$ptabla))
	{
// 		$list_sql.=' order by '.$ptabla.'_lused desc,'.$ptabla.'_descri';
		$list_sql.=' order by fanio desc, fmes desc,'.$ptabla.'_descri';
	}	
	else
	{
		if(mb_stristr('ctas.suco.cair.fpag.cntn.vhcl.tlla.asub',$ptabla) || mb_stristr('orat.bsqj',$ptabla))
		{$list_sql.=' order by '.$ptabla.'_codigo';}	
		else
		{$list_sql.=' order by '.$ptabla.'_descri';}
	}
    
  if($plimit>0)
  {$list_sql.=' limit '.$plimit;}

	if(mb_stristr('item.enti',$ptabla))
	{
	}
		
		
	$list_res=mysql_query($list_sql,$link_vcrx);
  echo '<options>';  
	while($list_aso=mysql_fetch_assoc($list_res))
	{
		$option='';
// 		$option.='<option style="font-family:arial;" value="'.$list_aso['codigo'].'">';
		$option.='<option value="'.$list_aso['codigo'].'">';
		$option.=$list_aso['descri'];

//     if($ptabla=='item')
//     {$option.=' ('.$list_aso['color'].')';}

    if($ptabla=='item' and $list_aso['codigov']!='')
    {$option.=' ('.$list_aso['codigov'].')';}
    else
    {$option.=' ('.$list_aso['codigo'].')';}

//     if($ptabla=='item' and $list_aso['pvp1']>0)
//     {$option.=' ($'.number_format($list_aso['pvp1'],2).')';}
    
		$option.='</option>';
		echo $option;
	}	
  echo '</options>';  
    
	}
?>	
</datalist>
</span>

<?php $pdatalist=0;?>
<?php $pphold='';?>
<?php $preado='';?>
<?php $pdisab='';?>
<?php $pcaption='';?>
<?php $ptabla='';?>
<?php $pidtxt='';?>
<?php $plong='';?>
<?php $pobj='';?>
<?php $ponblur='';?>
<?php $ponchange='';?>
<?php $pnotob='';?>
<?php $pdefa='';?>
<?php $psize='';?>
<?php $pcolu='';?>
<?php $phide=0; ?>
<?php $pexact=0; ?>
<?php $pclass='';?>
<?php $pwhere='';?>
<?php $obstart = ob_get_clean(); ?>
<?php //$obstart=alltrim($obstart); ?>
<?php $obstart = limpiahtml($obstart) ?>

<?php echo $obstart; ?>
