<?php 
declare(strict_types=0);
// session_start();
// https://aplicaciones.controlsanitario.gob.ec/publico/consultas/lista?str_consultar=881-MEN-0616
foreach($_GET  as $key => $value){${$key}=trim($value);} 
foreach($_POST as $key => $value){${$key}=trim($value);} 
include_once('lib_main.php');

if($_SESSION['user_codigo']==2)
{$show_timei=1;}
$show_timei=0;


if($show_timei>=1)
{echo '<br>=== valid maes modu ==== '.date('H:i:s');}

$modu=strtolower($modu);
vali_maes($modu);

if($show_timei>=1)
{echo '<br>=== valid maes modu ==== '.date('H:i:s');}

// echo date_default_timezone_get() ;
// echo date('H:i:s');

if($tkn=='1234567890'){$_SESSION['user_codigo']='2'; $prnt=1;}

if(!empty($empr)){$link_data=msql_connect('','','',$empr); $cfg_empr=$empr;}
$user_codigo=$_SESSION['user_codigo'];
$user0=data_maes('user',$user_codigo);

if(empty($user_codigo)){include('user_login0.php');return;}

if($newitem>1000){$newitem=0;}
if(mb_stristr2('.item.',$modu))
if($newitem>1){for($idx=1; $idx<=$newitem; $idx++){new_item();}}

// if(empty($fecha1)){$fecha1=date('Y-m-d',strtotime($fecha0.' +1 day'));}
if(empty($fecha1)){$fecha1=date('Y-m-01',strtotime($fecha0.' -11 month'));}
if(empty($fecha2) and date('H')<6){$fecha2=date('Y-m-d',strtotime('-1 day'));}
if(empty($fecha2)){$fecha2=date('Y-m-d');}
if(empty($fecha1)){$fecha1=date('Y-m-01', strtotime($fecha2));}
if($fecha1>$fecha2 and $fecha1<date('Y-m-01')){$fecha2=date('Y-m-t', strtotime($fecha1));}
if($fecha1>$fecha2 and $fecha1<date('Y-m-t')){$fecha2=date('Y-m-d');}
if($fecha1>$fecha2){$fecha1=date('Y-m-01', strtotime($fecha2));}

$modu0=data_maes('modu',$modu);
$modu=strtolower($modu);
$docu0=data_maes('docu',$modu);

if($empr0['empr_veterinaria']==1 and $modu=='enti')
{set_enti_veter();}

//           $plvh1=get_pla_atm('GRX4823');
//           set_placa($plvh1);
//           $plvh_prop=get_plvh_prop('GRX4823');
//           set_propietario($plvh_prop);

if($modu=='plvh')
{
//      $sql_desc='select * from plvh0 where length(trim(ifnull(plvh_descri,"")))<10 limit 10';
//      $res_desc=msql_query($sql_desc,$link_data);
//      while($aso_desc=msql_fetch_assoc($res_desc))
     {
//           $plvh1=get_pla_atm($aso_desc['plvh_codigo']);
//           set_placa($plvh1);
//           echo '<br>*/*'.$aso_desc['plvh_codigo'];
//           var_dump($plvh1);
//           $plvh_prop=get_plvh_prop($aso_desc['plvh_codigo']);
//           set_propietario($plvh_prop);
     }
}


if(empty($user0['user_tipo'])){$cost='false';}
if(empty($user0['user_tipo'])){$prec='false';}

if(!mb_stristr2('.sist.supe',$user0['user_tipo']))
{
     $sql_acce='select * from acce1 left join acce2 on idnum1=idnum2 where numero="'.$user_codigo.'" and docum="COST" and info=1';
     $res_acce=msql_query($sql_acce,$link_data);
     if(msql_num_rows($res_acce)==0){$cost='false';}
     $sql_acce='select * from acce1 left join acce2 on idnum1=idnum2 where numero="'.$user_codigo.'" and docum="PREC" and info=1';
     $res_acce=msql_query($sql_acce,$link_data);
     if(msql_num_rows($res_acce)==0){$prec='false';}
}



$modu_descri=$docu0['docu_descri'];
$info_descri='GENERAL';

$xtitulo='MAESTROS';
$xtitle=$xtitulo;
$xtopcenter='MAESTROS';

if(empty($pgsize)){$pgsize='A4-V';}
if(!empty($modu)){$xtitle=strtoupper($modu);}
if(!empty($modu)){$xtopcenter=strtoupper($modu_descri).' (Info)';}
$xtitle.=' /'.$modu_descri.' /Info';
// $xtitle.=' /'.$info_descri;

$dom = new DOMDocument();
     $dom->encoding = 'utf-8';
     $dom->xmlVersion = '1.0';
     $dom->formatOutput = true;

     $src='//'.$domain.'/_lib/info_maes3.js'.$js_version;
     $script=$dom->appendChild($dom->createElement("script"," "));
     $script->setAttribute("src",$src);

echo $dom->saveXML();


$maes=strtolower($maes);
$modu=strtolower($modu);
$tabla=$modu;


if(!empty($modu))
{

if($modu=='docu'){view_maes('docu','docd');}
     
// if($cfg_empr=='hg01'){view_rgsn();}
// if($_SESSION['farmacia']==1)
if($modu=='rgsn'){view_rgsn();}
// if($modu=='clie'){view_maes('enti','clie','(left(enti_codigo,10) in(select left(enti,10) from vtas1 where status!="X") or left(enti_codigo,10) in(select left(enti,10) from clie1 where status!="X"))');}

// if($modu=='clie'){view_maes('enti','clie','(left(enti_codigo,10) in(select left(enti,10) from vtas1 where status!="X") or left(enti_codigo,10) in(select left(enti,10) from clie1 where status!="X") or left(enti_codigo,10) in(select left(enti,10) from plan1 where status!="X"))');}
// if($modu=='prov'){view_maes('enti','prov','(left(enti_codigo,10) in(select left(enti,10) from comp1 where status!="X") or left(enti_codigo,10) in(select left(enti,10) from prov1 where status!="X"))');}
if($modu=='caja'){view_caba();}
if($modu=='ctab'){view_caba();}
     
if($modu=='clie'){view_maes('enti','clie','(enti_codigo in(select enti from vtas1 where status!="X") or enti_codigo in(select enti from clie1 where status!="X") or enti_codigo in(select enti from plan1 where status!="X"))');}
if($modu=='prov'){view_maes('enti','prov','(enti_codigo in(select enti from comp1 where status!="X") or enti_codigo in(select enti from prov1 where status!="X"))');}
if($modu=='adqu'){view_maes('enti','adqu','(enti_codigo in(select toenti from comp1 where status!="X"))');}
if($modu=='user'){view_maes('user','rfex','');}
// if($modu=='rfex'){view_maes('user','rfex','');}
if($modu=='refx')
{
//      if(empty($refx))
     {view_maes('user','refx','');}

     if(1==2)
     if(!empty($refx))
     {
          $sql_refx1='drop view refx1';
          $res_refx1=msql_query($sql_refx1,$link_data);
          $sql_refx1='create view refx1 as select 1 as user_nivel, user0.* from user0 where user_referx="'.$refx.'" ';
          $res_refx1=msql_query($sql_refx1,$link_data);
          
          $sql_refx1='drop view refx2';
          $res_refx1=msql_query($sql_refx1,$link_data);
          $sql_refx1='create view refx2 as select 2 as user_nivel, user0.* from user0 where user_referx in (select user_codigo from refx1)';
          $res_refx1=msql_query($sql_refx1,$link_data);
          
          $sql_refx1='drop view refx3';
          $res_refx1=msql_query($sql_refx1,$link_data);
          $sql_refx1='create view refx3 as select 3 as user_nivel, user0.* from user0 where user_referx in (select user_codigo from refx2)';
          $res_refx1=msql_query($sql_refx1,$link_data);
          
          $sql_refx1='drop view refx0';
          $res_refx1=msql_query($sql_refx1,$link_data);
          
          $sql_refx1='create view refx0 as ';
          $sql_refx1.='select * from refx1 ';
          $sql_refx1.='union ';
          $sql_refx1.='select * from refx2 ';
          $sql_refx1.='union ';
          $sql_refx1.='select * from refx3';
          $res_refx1=msql_query($sql_refx1,$link_data);
          
          
     }
     
//      $info='';
}
    
maes_view($modu);     
     
// if($modu=='empl')
// {view_maes('enti','empl',
//            '(
//            (left(enti_codigo,10) in(select left(enti,10) from susa1 where status!="X") 
//            or left(enti_codigo,10) in(select left(user_cedula,10) from user0 where user_tipo in ("sist","supe","admi") and user_status not in("I","X")))
//            and length(trim(enti_codigo))=10 )'
//           ); }
// if($modu=='pcnt'){view_maes('enti','pcnt','enti_codigo like "99%" or enti_codigo in(select distinct pcnt from vtas1 where status!="X")  or enti_codigo in(select distinct pcnt from clie1 where status!="X")');}
// if($modu=='vndd'){view_maes('enti','vndd','enti_codigo in(select distinct vndd from vtas1 where status!="X")  or enti_codigo in(select distinct vndd from clie1 where status!="X")');}
// if($modu=='rcdd'){view_maes('enti','rcdd','enti_codigo in(select distinct rcdd from vtas1 where status!="X")  or enti_codigo in(select distinct rcdd from clie1 where status!="X")');}
// if($modu=='codt'){view_maes('enti','codt','enti_codigo in(select distinct cedula1 from guia1 where status!="X")');}
// if($modu=='rfrx'){view_maes('user','rfrx','ifnull(user_referx,"")!=""');}
     
// if($modu=='rpis'){view_maes('enti','segu','enti_actividad like "%SEGURO%"');}
// if($modu=='rpis'){if(!is_dir('rpis')){mkdir('rpis');}}


     

// if($modu=='ctas'){view_maes('ctas','cta1','left(ctas_codigo,1)="1"');}
// if($modu=='ctas'){view_maes('ctas','cta2','left(ctas_codigo,1)="2"');}
// if($modu=='ctas'){view_maes('ctas','cta3','left(ctas_codigo,1)="3"');}
// if($modu=='ctas'){view_maes('ctas','cta4','left(ctas_codigo,1)="4"');}
// if($modu=='ctas'){view_maes('ctas','cta5','left(ctas_codigo,1)="5"');}
// if($modu=='ctas'){view_maes('ctas','cta6','left(ctas_codigo,1)="6"');}

     
// if($modu=='iinv'){view_maes('item','iinv','(left(item_codigo,10) in(select left(item,10) from inve1 left join inve2 on idnum1=idnum2 and docu in("IB00","IB10","IB15")))');}
// if($modu=='ibod'){view_maes('item','ibod','(left(item_codigo,10) in(select left(item,10) from inve1 left join inve2 on idnum1=idnum2 and docu in("IB00","IB10","IB15")))');}
// if($modu=='ivta'){view_maes('item','ivta','(left(item_codigo,10) in(select left(item,10) from vtas2) or left(item_codigo,10) in(select left(item,10) from clie2))');}
// if($modu=='igas'){view_maes('item','igas','(item_codigo like "99%")');}
// if($modu=='prod'){view_maes('item','prod','(left(item_codigo,10) in(select left(item,10) from inve2) or left(item_codigo,10) in(select left(item,10) from prod2))');}
// if($modu=='serv'){view_maes('item','serv','(left(item_codigo,10) not in(select left(item,10) from inve2) and left(item_codigo,10) not in(select left(item,10) from prod2))');}
     
// if($modu=='team'){view_maes('team','sqad');}
     
// if($modu=='asub'){view_maes('asub','atvd');}
     
// if($modu=='ctas'){set_ctasgd();}
// if($modu=='ctas'){view_maes('ctas','ctag','(ctas_tipogd="G")');}
// if($modu=='ctas'){view_maes('ctas','ctad','(ctas_tipogd="D")');}
     
// if($modu=='team'){view_maes('team','tem2');}
     
}


// if(empty($info)){$info='mt'.$modu;}
if(empty($info) and !empty($modu)){$info='mt'.$modu;}

if(@mb_stristr2('.clie.prov.empl',$modu)){$tabla='enti';}
if(@mb_stristr2('.inve.prec.teki',$modu)){$tabla='item';}


if(date('Y-m-d')<="2024-01-31")
if(mb_stristr2('.item',$tabla))
{
//      echo '======';
//      inse_maes($tabla,"LIT.","LITRO");
     $sql_updt='update item0 set item_umdd="UNI." where trim(item_umdd)in("UNID","UND","UND.","UNDS")';
     $res_updt=msql_query($sql_updt,$link_data);
     
     $sql_updt='update item0 set item_umdd="GR." where trim(item_umdd)in("GR","GRS")';
     $res_updt=msql_query($sql_updt,$link_data);
     
     $sql_updt='update item0 set item_umdd="KG." where trim(item_umdd)in("KG","KGS")';
     $res_updt=msql_query($sql_updt,$link_data);
     
     $sql_updt='update item0 set item_umdd="MT." where trim(item_umdd)in("MT","MTS","MTS.","MTR")';
     $res_updt=msql_query($sql_updt,$link_data);
     
     $sql_updt='update item0 set item_umdd="LT." where trim(item_umdd)in("LT","LT.","LIT.","LITR")';
     $res_updt=msql_query($sql_updt,$link_data);
     
     $sql_updt='update item0 set item_umdd="LB." where trim(item_umdd)in("LB","LB.","LIB.","LIBR")';
     $res_updt=msql_query($sql_updt,$link_data);
     
     $sql_updt='update umdd0 set umdd_status="X" where trim(umdd_codigo)in("LB","LIB.","LIBR","LT","LIT.","LITR","MT","MTS","MTS.","MTR","UND","UND.","UNDS","GR","KG")';
     $res_updt=msql_query($sql_updt,$link_data);
     
}     







// echo '*/*/*'.$fecha2;     


//  SELECT DB
// echo '*/*/*/'.$modu.$info;
include('sele_info.php');
// echo '*/*/*'.$sql_info;
if(!empty($sql_info))
{
     if($modu=='enti')
     {
          // llena enti_descri
//           $res_info=msql_query($sql_info,$link_data);
//           while($aso_enti=msql_fetch_assoc($res_info))
//           {vali_enti($aso_enti['codigo']); echo '<br>=='.$aso_enti['codigo'];}
     }

     if($empr0['empr_ceuser']==1)
     if(mb_stristr2('.enXti.clie.prov',$modu))
     {
          $sql_info='select * from ('.$sql_info.')as q1 ';
          
//           $user0['user_contador']
          
          if($user0['user_tipo']=='cont')
          {
          }
          
          if(mb_stristr2('.sist.supe.cont',$user0['user_tipo']))
          {
               if($modu=='clie')
               {$sql_info.='where left(codigo,10) in (select left(enti,10) from vtas1 )';}

               if($modu=='prov')
               {$sql_info.='where left(codigo,10) in (select left(enti,10) from comp1 )';}
               
          }
          else
          {
               if($modu=='clie')
               {$sql_info.='where left(codigo,10) in (select left(enti,10) from vtas1 where iuser="'.$user0['user_codigo'].'")';}

               if($modu=='prov')
               {$sql_info.='where left(codigo,10) in (select left(enti,10) from comp1 where toenti like "'.$user0['user_cedula'].'%")';}
          }
          
     }
     
//      echo '==='.$sql_info;
     
     if($modu=='clac')
     {
          $sql_clac ='select * from clac0 ';
          $sql_clac.='where ifnull(clac_status,"")not in("X") ';
          $sql_clac.='and clac_tipo in ("01","04","05","07") ';
          $sql_clac.='and clac_fecha>="'.$fecha1.'" ';
          $sql_clac.='and clac_fecha<="'.$fecha2.'" ';
          $sql_clac.='and clac_enti != "'.$empr0['empr_ruc'].'" ';
          $sql_clac.='and clac_codigo not in (';
               $sql_clac.='select claveacc from comp1 where status!="X" and ifnull(claveacc,"")!="" ';
               $sql_clac.='union  ';
               $sql_clac.='select claveacc from retc1 where status!="X" and ifnull(claveacc,"")!="" ';
               $sql_clac.=') ';
          if(!empty($enti))
          {$sql_clac.='and clac_codigo like "%'.$enti.'%" ';}
          $sql_clac.='order by clac_fecha ';

//           echo $sql_clac;
          
          $res_clac=msql_query($sql_clac,$link_data);
          while($aso_clac=msql_fetch_assoc($res_clac))
          {upl_cexml($aso_clac['clac_codigo']);}
          
//           $res_clac=msql_query($sql_clac,$link_data);
//           while($aso_clac=msql_fetch_assoc($res_clac))
//           {ws_autor($aso_clac['clac_codigo']);}
          
          
     }     
     
     
     if($modu=='rpis')
     {
          $sql_rpis ='select * from rpis0 ';
          $sql_rpis.='where ifnull(rpis_status,"")not in("X") ';
          $sql_rpis.='and ifnull(rpis_pdf,0)=0 ';
          $sql_rpis.='order by rpis_fecha desc ';

//           echo $sql_clac;
          
          $res_rpis=msql_query($sql_rpis,$link_data);
          while($aso_rpis=msql_fetch_assoc($res_rpis))
          {set_rpispdf($aso_rpis['rpis_fecha'],$aso_rpis['rpis_cedula']);}
          
//           $res_clac=msql_query($sql_clac,$link_data);
//           while($aso_clac=msql_fetch_assoc($res_clac))
//           {ws_autor($aso_clac['clac_codigo']);}
          
          
     }     
     
//      $res_info=msql_query($sql_info,$link_data);
     $date1=date('H:i:s');
     $res_info=msql_query($sql_info,$link_data);
     $date2=date('H:i:s');
     
     $msgres=number_format(msql_num_rows($res_info)).' Resultado(s)...';
//      $msgres.=$_SESSION['qtime'].' secs';
//      $msgres.=$date1.$date2;
}




$xtitulo='Maestros';
if(empty($prnt))
{
echo '<div id="filtros" noprint style="background-color:;">';

// OCULTOS
echo '<div hide>';     
// $info='mt'.$modu;     
echo '<input id="format" value="'.$format.'">';
echo '<input id="limit" value="'.$limit.'">';
echo '<input id="info" value="'.$info.'">';
// echo '<input id="docu" hide value="'.msql_result($res_info,0,'docu').'">';
// echo '<input id="idnum1" hide value="'.msql_result($res_info,0,'idnum1').'">';
echo '</div>';     

     
// if($format!=4)
// {$ztitulo='FILTROS'; include('ele_title.php');}

$zobj=2;     
include('ele_break.php');

     
// echo '*/*/*/*/'.$modu;
$zid='modu'; 
// $zvalue=$modu;
// $ztodo=1;
$ztabla='docu';
$zwhere='(docu_tipo="maes")';     
$zlabel='Maestro';
$zvalue=$modu; 
$zsize=1.2;     
if(!empty($modu)){$zreado=1;}
$zondblclick='{document.getElementById("modu").removeAttribute("disabled");}';     
// $zonchange='{info_maes(event);}';
$zonchange='{location.href="?scri='.basename(__FILE__,'.php').'&modu="+document.getElementById("modu").value;}';
$zonblur=$zonchange;
     
include('ele_select.php');

// echo '*/*/*/*/'.$modu;
     
     

$zid='pgsize';
$zlabel='Pág';
$zvalue=$pgsize;
$zdefa=$pgsize;
$zoptions='';
$zoptions.='A4-V;';
$zoptions.='A4-H;';
$zalign='right';
include('ele_select.php');
     
     
     

$zid='orden'; $zvalue=$orden;
$zlabel='Ordenar X';
$zoptions='Código;Descripción;Tipo';
     
if(mb_stristr2('enti.clie',$tabla))     
{$zoptions.=';Zona';}
     
if(mb_stristr2('enti.prov',$tabla))     
{$zoptions.=';T.Prov.';}
     
if(mb_stristr2('item.ibod.tmpr',$tabla))     
{$zoptions.=';Linea';}
     
$zonchange='{info_maes(event);}';
$zalign='right';
include('ele_select.php');

     
$zid='btn_nuevo'; 
$zlabel='Nuevo';
$zalign='right';
$zsize=1.2;     
$zonclick='{window.open("?scri=regi_maes3&modu="+document.getElementById("modu").value,"_blank");}';
if(mb_stristr2('.item.',$modu))
{
     $zonclick='';     
     $zonclick.='if(document.getElementById("newitem").value==1)';
     $zonclick.='{window.open("?scri=regi_maes3&modu="+document.getElementById("modu").value,"_blank");}';
     $zonclick.='else ';
     $zonclick.='Swal.fire({
       title: "Confirmar",
       text: "Se Crearán "+document.getElementById("newitem").value+" Códigos Nuevos",
       icon: "warning",
       showCancelButton: true,
       confirmButtonColor: "",
       cancelButtonColor: "darkred",
       confirmButtonText: "Si, Crear Códigos"
     }).then((result) => {
       if(result.isConfirmed){info_maes(event);}
     });';     
}     
include('ele_button.php');

$zid='edit';
$zlabel='Editar';
$zdefa=2;     
$zonchange='{info_maes(event);}';
if(empty($user_codigo)){$zhide=1;}
$zbool=1;     
$zexact=1;     
$zalign='right';
include('ele_select.php');
     
     
     
     
if(mb_stristr2('.item.',$modu))
{
     $zobj=1;
     $zid='newitem'; 
     $zlabel='Nuevos Items';
//      $zonclick='{window.open("?scri=regi_maes3&modu="+document.getElementById("modu").value,"_blank");}';
     $zvalue=1;
     $zsize=1.2;     
     $zalign='right';
     $zexact=1;
     $zoptions='';
     $zoptions.='1,1 Código;';
     $zoptions.='10,10 Códigos;';
     $zoptions.='50,50 Códigos;';
     $zoptions.='100,100 Códigos;';
     $zoptions.='500,500 Códigos;';
     $zoptions.='1000,1000 Códigos;';
     if(!mb_stristr2('.sist.supe',$user0['user_tipo'])){$zhide=1;}

     include('ele_select.php');
}
     
     

{    
     
$zsize=3;     
include('ele_break.php');

if(!empty($modu))
{
     $zid='dl_stat';
     $ztabla='stat';
     $zwhere='(stat_codigo in(select distinct '.$modu.'_status from '.$modu.'0))';     
     include('ele_datalist.php');
}
     
if(mb_stristr2('.ctas',$tabla))
{
     $zid='dl_grupo';
     $ztabla='ctas';
     $zwhere='('.$tabla.'_tipogd="G")';
     include('ele_datalist.php');
     
}     

     
if(mb_stristr2('.refx',$tabla))
{
     $zid='dl_refx';
     $ztabla='refx';
//      $zwhere='('.$tabla.'_tipogd="G")';
     include('ele_datalist.php');
     
}     

     
     
if(mb_stristr2('.ppdd',$tabla) )
{
//      $ztabla='ppdd';
//      $zcolu='ppdd_ciudad';
//      $zcolu2='ppdd_ciudad';
//      include('ele_datalist.php');
}     

     
if(mb_stristr2('.bbii',$tabla))
{
     $ztabla='bbii';
     $zcolu='bbii_ciudad';
     $zcolu2='bbii_ciudad';
     include('ele_datalist.php');
}     

     
     
     

if(mb_stristr2('.nrol',$tabla))
{
//      $zid='dl_grupo';
     $ztabla='enti';
     $zwhere='(enti_codigo in (select distinct nrol_enti from nrol0))';
     include('ele_datalist.php');
     
}     


if(mb_stristr2('.rpis',$tabla))
{
     $ztabla='enti';
     $zwhere='(length(trim(enti_codigo))=10)';
     include('ele_datalist.php');
     
}     


if(mb_stristr2('.lote.seri',$tabla))
{
//      $zid='dl_grupo';
     $ztabla='item';
     $zwhere='(item_codigo in (select item from inve1 left join inve2 on idnum1=idnum2 ))';
     include('ele_datalist.php');
     
}     

     
if($tabla=='pcnt')
{
     if($empr0['empr_veterinaria']==1)
     {
     $zid='dl_especie';
     $ztabla='enti';
     $zcolu='enti_especie';
     include('ele_datalist.php');
          
     }
}

     
if(mb_stristr2('.clac',$tabla))
{
//      $zid='dl_grupo';
     $zid='dl_clactipo';
     $ztabla='clac';
     $zcolu='clac_tipo';
     $zcolu2='clac_tipo';
//      $zwhere='(item_codigo in (select item from inve1 left join inve2 on idnum1=idnum2 ))';
//      $zid='dl_ciudad';
//      $ztabla='enti';
//      $zcolu='enti_ciudad';
//      include('ele_datalist.php');
     include('ele_datalist.php');

     $ztabla='enti';
//      $zwhere='(item_codigo in (select item from inve1 left join inve2 on idnum1=idnum2 ))';
     include('ele_datalist.php');
     
     
}     


     
if(mb_stristr2('.clie.prov.item',$modu))
{

if($modu=='item'){$fecha0=fecha0('vtas');}
if($modu=='clie'){$fecha0=fecha0('vtas');}
if($modu=='prov'){$fecha0=fecha0('comp');}
// if($modu=='clac'){$fecha0=fecha0('comp');}
     
$fecha0=substr($fecha0,0,7);     
     
$zid='fecha1';
$ztype='date';
// $zlabel='Fec.Ini.';
$zlabel='Desde';
$zvalue=$fecha1;
$zdefa=$fecha0;    
$zmin=$fecha0;
$zmax=date('Y-m-01',strtotime('+1 month'));     
$ztype='month';     
include('ele_input.php');  
     
     
$zid='fecha2';
$ztype='date';
// $zlabel='Fec.Fin';
$zlabel='Hasta';
$zvalue=$fecha2;
$zmin=$fecha0;     
$zmax=date('Y-m-01',strtotime('+1 month'));     
$ztype='month';     
include('ele_input.php');  

$zsize=1;     
include('ele_break.php');

     
}     
     
     

     
if($tabla=='trty')
{
     $zid='dl_sector';
     $ztabla='trty';
     $zcolu='trty_sector';
     include('ele_datalist.php');
     

     $zid='grupo';
     $zlabel='Grupo';
     $zvalue=$grupo;
     $zoptions='1;2;3;4;5;6;7;8;9';
     $ztodo=1;
     $zonchange='{fn_consulta(event);}';
     include('ele_select.php');

     $zid='sector';
     $zlabel='Sector';
     $zvalue=$sector;
     $zlist='dl_sector';
//      $zoptions='1;2;3;4;5;6;7;8;9';
     $ztodo=1;
     $zonchange='{fn_consulta(event);}';
     include('ele_input.php');
}
     
     
     
     
if($tabla=='ciex')
{
     $zid='letra'; 
     $zvalue=$letra;
     $ztodo=1;
//      $ztabla='tpro';
     $zlabel='Letra';
     $zonchange='{info_maes(event);}';
//      include('ele_input.php');
     $zabc=1;
     include('ele_select.php');
     
}
     
     
     
     
if($tabla=='docu')
{
     $zid='dl_tabla';
     $ztabla='docu';
     $zcolu='docu_tabla';
     include('ele_datalist.php');
     
     $zid='dtabla'; 
     $zvalue=$dtabla;
     $zlabel='Tabla';
     $zlist='dl_tabla';
     include('ele_input.php');
     
     
}
     
     

     
if($tabla=='enti')
{
     $zid='dl_ciudad';
     $ztabla='enti';
     $zcolu='enti_ciudad';
     include('ele_datalist.php');
     
     $zid='dl_provincia';
     $ztabla='enti';
     $zcolu='enti_provincia';
     include('ele_datalist.php');
     
     
     if($modu=='enti' or $modu=='clie')
     {
          
     $sql_zsub='select distinct enti_zsub from enti0 ';
     $sql_zsub.='left join zsub0 on zsub_codigo=enti_zsub ';
     $sql_zsub.='left join vtas1 on enti_codigo=enti ';
     $sql_zsub.='where zsub_status not in ("O","X") and length(trim(zsub_codigo))>=4';
     $res_zsub=msql_query($sql_zsub,$link_data);
     if(msql_num_rows($res_zsub)>1){$zsub_ok=1;}
          
     if($zsub_ok==1)
     {
          $zid='zsub'; $zvalue=$zsub; $ztodo=1;
          $ztabla='zsub';
          $zlabel='Zona';
          $zonchange='{info_maes(event);}';
          include('ele_select.php');
     }
          
     }

     if($modu=='enti' or $modu=='prov')
     {
     $zid='tpro'; $zvalue=$tpro; $ztodo=1;
     $ztabla='tpro';
     $zlabel='T.Provee';
     $zonchange='{info_maes(event);}';
     include('ele_select.php');
     }

     $zid='provincia'; 
     $zvalue=$provincia;
     $zlabel='Provincia';
     $zlist='dl_provincia';
     include('ele_input.php');
     
     $zid='ciudad'; 
     $zvalue=$ciudad;
     $zlabel='Ciudad';
     $zlist='dl_ciudad';
     include('ele_input.php');

     $zid='direcc'; 
     $zvalue=$direcc;
     $zlabel='Dirección';
     include('ele_input.php');

     
}     

     
// echo '===='.$tabla;     
// echo '===='.$modu;     
     
if($modu=='clie')
{
     $zobj=1;
     include('ele_break.php');
     
     
     $sql_vndd='select distinct enti_vndd from enti0 ';
     $sql_vndd.='left join vndd0 on vndd_codigo=enti_vndd ';
     $sql_vndd.='left join vtas1 on enti_codigo=enti ';
     $sql_vndd.='where vndd_status not in ("O","X") and length(trim(vndd_codigo))>=10';
     $res_vndd=msql_query($sql_vndd,$link_data);
     if(msql_num_rows($res_vndd)>1){$vndd_ok=1;}
     
     $sql_rcdd='select distinct enti_rcdd from enti0 ';
     $sql_rcdd.='left join rcdd0 on rcdd_codigo=enti_rcdd ';
     $sql_rcdd.='left join vtas1 on enti_codigo=enti ';
     $sql_rcdd.='where rcdd_status not in ("O","X") and length(trim(rcdd_codigo))>=10';
     $res_rcdd=msql_query($sql_rcdd,$link_data);
     if(msql_num_rows($res_rcdd)>1){$rcdd_ok=1;}
     
     
     
     
     if($vndd_ok==1)
     {
          $ztabla='vndd';
          include('ele_datalist.php');
          $zid='vndd';
          $zvalue=$vndd;
          $ztabla='vndd';
          $zlabel='Vendedor';
          include('ele_input.php');
     }     
     
     if($rcdd_ok==1)
     {
          $ztabla='rcdd';
          include('ele_datalist.php');
          $zid='rcdd';
          $zvalue=$rcdd;
          $ztabla='rcdd';
          $zlabel='Recaudador';
          include('ele_input.php');
     }     
}     
     

     
     
     
if(mb_stristr2('.ppdd',$tabla))
{
     $zid='calle2'; 
     $zvalue=$calle2;
     $zlabel='Manzana';
     if($_SESSION['empr_edificio']==1)
     {$zlabel='Piso';}
     $zwidth=4;
     include('ele_input.php');

     
     
}     

     
if(mb_stristr2('.ctas',$tabla))
{
     
     
     $zid='grupo';
     $ztabla='ctas';
     $zlabel='Grupo';
     $zonchange='{info_maes(event);}';
//      $zwhere='(ctas_tipogd="G")';
     $zvalue=$grupo;
     $zlist='dl_grupo';
//      include('ele_select.php');
     include('ele_input.php');

}

     

if(mb_stristr2('.rpis',$tabla))
{
     $zid='fecha1';
     $zlabel='Desde';
     $zvalue=$fecha1;
     $zmin=date('2020-01-01');
     $ztype='date';
     include('ele_input.php');

     $zid='fecha2';
     $zlabel='Hasta';
     $zvalue=$fecha2;
     $zmin=date('2020-01-01');
//      $zmin=date('Y-m-d');
     $ztype='date';
     include('ele_input.php');

     
     
     $zid='cedula'; 
     $zvalue=$cedula;
     $ztodo=1;
     $ztabla='enti';
     $zlabel='Cédula';
//      $zonchange='{info_maes(event);}';
     include('ele_input.php');
     
     $zid='rpisfile';
     $zlabel='Archivos';
     $ztype='file';
     $zmulti=1;
     $zaccept='.xls,.xl5,.pdf';
     $zonclick2="upld_rpis('rpisfile')";
     $zlabel2='';
     $zplace='xls.pdf';
     $zalign='right';
     include('ele_input.php');

     $zobj=1;
     include('ele_break.php');
     
     
}

     

if(mb_stristr2('.lote.seri',$tabla))
{
     $zid='item'; 
     $zvalue=$item;
     $ztodo=1;
     $ztabla='item';
     $zlabel='Item';
//      $zonchange='{info_maes(event);}';
     include('ele_input.php');
     
}
     
if(mb_stristr2('.nrol',$tabla))
{
     $zid='enti'; 
     $zvalue=$enti;
     $ztabla='enti';
     $zlabel='Nombre';
     include('ele_input.php');

     $zid='psco'; 
     $zvalue=$psco;
     $ztodo=1;
     $ztabla='psco';
     $zlabel='Período';
     include('ele_input.php');
     
     
     $zid='curs'; 
     $zvalue=$curs;
     $ztabla='curs';
     $zlabel='Curso';
     include('ele_input.php');

     $zid='nivel';
     $zlabel='Nivel';
     $zvalue=$nivel;
     $zwidth=3;
     include('ele_input.php');

     $zid='seccion';
     $zlabel='Sección';
     $zvalue=$seccion;
     $zwidth=2;
     include('ele_input.php');
     
     
}
     
if(mb_stristr2('.curs',$tabla))
{
     $zid='psco'; 
     $zvalue=$psco;
     $ztodo=1;
     $ztabla='psco';
     $zlabel='Período';
     include('ele_input.php');
     
     $zid='nivel';
     $zlabel='Nivel';
     $zvalue=$nivel;
     $zwidth=3;
     include('ele_input.php');

     $zid='seccion';
     $zlabel='Sección';
     $zvalue=$seccion;
     $zwidth=2;
     include('ele_input.php');
     
     
}
     
     
// if($tabla=='item')
if(mb_stristr2('.item.ivta.iinv.ibod',$tabla))
{
     $zid='lsub'; 
     $zvalue=$lsub;
     $ztodo=1;
     $ztabla='lsub';
     $zlabel='Linea';
     $zonchange='{info_maes(event);}';
     include('ele_select.php');

     $zid='mrca'; 
     $zvalue=$mrca; 
     $ztodo=1;
     $ztabla='mrca';
     $zlabel='Marca';
     $zonchange='{info_maes(event);}';
//      $zwhere='(mrca_codigo in(select distinct '.$tabla.'_mrca from inve1 left join inve2 on idnum1=idnum2 left join item0 on item='.$tabla.'_codigo where status not in ("O","X")))';
     $zwhere='(mrca_codigo in(select distinct '.$tabla.'_mrca from inve1 left join inve2 on idnum1=idnum2 left join '.$tabla.'0 on item='.$tabla.'_codigo where status not in ("O","X")))';
     include('ele_select.php');
     
}


if(mb_stristr2('.bbii',$tabla))
{
     $zid='vtalq';
     $zvalue=$vtalq;
     $ztodo=1;
     // $ztabla='lsub';
     $zlabel='Tipo';
     $zoptions='';     
     $zoptions.='V,Venta;';     
     $zoptions.='A,Alquiler;';     
     $zonchange='{info_maes(event);}';
     include('ele_select.php');
     
     
     $zid='lsub'; 
     $zvalue=$lsub;
     $ztodo=1;
     $ztabla='lsub';
     $zlabel='Linea';
     $zonchange='{info_maes(event);}';
     include('ele_select.php');

 
//      if($empr0['empr_inmobil']==1)
     {
     $zid='prvc'; $zvalue=$prvc; $ztodo=1;
     $ztabla='prvc';
     $zlabel='Provincia';
     $zonchange='{info_maes(event);}';
     $zwhere='(prvc_codigo in(select distinct '.$tabla.'_prvc from bbii0 where '.$tabla.'_status not in ("O","X")))';
//      $zwhere='(mrca_codigo in(select distinct '.$tabla.'_mrca from inve1 left join inve2 on idnum1=idnum2 left join '.$tabla.'0 on item='.$tabla.'_codigo where status not in ("O","X")))';
     include('ele_select.php');
     }
     
}

     
     
if(mb_stristr2('.docu',$tabla))
{
//      $zid='dl_tabla';
//      $ztabla='docu';
//      $zcolu='docu_tabla';
//      include('ele_datalist.php');
     
//      $zid='tabla'; 
//      $zvalue=$tabla;
//      $zlabel='Tabla';
//      $zlist='dl_tabla';
//      include('ele_input.php');
}     

     
if(mb_stristr2('.clac',$tabla))
{
     $fecha0=fecha0('clac');
     
     $zid='fecha1';
     $zlabel='Desde';
     $zvalue=$fecha1;
     $zmin=$fecha0;
     $zmax=date('Y-m-d');
     $ztype='date';
     include('ele_input.php');

     $zid='fecha2';
     $zlabel='Hasta';
     $zvalue=$fecha2;
     $zmin=$fecha0;
     $zmax=date('Y-m-d');
     $ztype='date';
     include('ele_input.php');

     
//      📁📂🗄🗃
//      $zobj=1;
     $zid='celfile';
     $zlabel='Archivos';
     $ztype='file';
     $zmulti=1;
     $zaccept='.xml,.txt,.pdf';
     $zonclick2="upld_cele('celfile')";
     $zlabel2='';
     $zplace='txt.xml.pdf';
     $zalign='right';
     include('ele_input.php');

     $zid='claveacc';
     $zlabel='Claves';
     $zlabel2='';
     $zsize=0.8;
     $zvalue=$claveacc;
     $zonblur="upld_cele('claveacc')";
     $zalign='right';
     include('ele_input.php');
     
     
     
     $zobj=1;
     include('ele_break.php');

//      $zobj=1;
     $zid='locaexte';
     $zlabel='Tipo.Emis.';
     $zvalue=$locaexte;
//      $ztabla='tcel';
//      $zoptions='1,Locales;2,Externas;';
     $zoptions='1,'.$cfg_descri.';2,Otros;';
     $ztodo=1;
     include('ele_select.php');
     
     $zid='tcel';
     $zlabel='Tipo.CEle.';
     $zvalue=$tcel;
     $ztabla='tcel';
     $ztodo=1;
     include('ele_select.php');

     
     $zid='enti';
     $ztabla='enti';
     $zlabel='Emisor';
     $zvalue=$enti;
     $zopen=1;
     include('ele_input.php');

}
     
     
     
if(mb_stristr2('.user',$tabla))
{

}
     
if(mb_stristr2('.refx',$tabla))
{
     $zid='refx';
     $ztabla='refx';
     $zlabel='Código';
     $zvalue=$refx;
//      $zopen=1;
     include('ele_input.php');


}
     
     
     
if(mb_stristr2('.pcnt',$tabla))
{
     if($empr0['empr_veterinaria']==1)
     {
          $zid='especie';
          $zlabel='🐾 Especie';
          $zvalue=$especie;
          $zlist='dl_especie';
          include('ele_input.php');
          
          $zid='raza';
          $zlabel='🐾 Raza';
          $zvalue=$raza;
          $zlist='dl_raza';
          include('ele_input.php');
          
     }     
     
}
     

if(mb_stristr2('.mdvh',$tabla))
{
     ////////// datalist
     {
     $ztabla='mrca';
     include('ele_datalist.php');
     
     $zid='dl_modelo';
     $ztabla='mdvh';
     $zcolu='mdvh_modelo';
     include('ele_datalist.php');
     
     $zid='dl_anio';
     $ztabla='mdvh';
     $zcolu='mdvh_anio';
     include('ele_datalist.php');
          
     $zid='dl_clase';
     $ztabla='mdvh';
     $zcolu='mdvh_clase';
     include('ele_datalist.php');
     
          
     }

     //////////
     
     $zid='mrca';
     $zvalue=$mrca;
     $zlabel='Marca';
     $ztabla='mrca';
     include('ele_input.php');

     $zid='modelo';
     $zvalue=$modelo;
     $zlabel='Modelo';
     $zlist='dl_modelo';
     include('ele_input.php');
     
     $zid='anio'; 
     $zvalue=$anio;
     $zlabel='Año';
     $zlist='dl_anio';
     $zclass='numeric-int';
     $zmin=1950;
     $zmax=date('Y');
     include('ele_input.php');

     $zobj=1;
     include('ele_break.php');

     $zid='clase';
     $zvalue=$clase;
     $zlabel='Clase';
     $zlist='dl_clase';
     include('ele_input.php');
     
     $zid='ntec';
     $zvalue=$ntec;
     $zlabel='Niv.Téc.';
     $zdefa=1;
     $zclass='numeric-dec';
     $zmin=1;
     $zmax=10;
     include('ele_input.php');
     
     
}
     
     
     
if(mb_stristr2('.vinn',$tabla))
{
     ////////// datalist
     {
     $ztabla='mrca';
     include('ele_datalist.php');
     
     $ztabla='mdvh';
     include('ele_datalist.php');
     
     $zid='dl_anio';
     $ztabla='vinn';
     $zcolu='vinn_anio';
     include('ele_datalist.php');
          
     $zid='dl_clase';
     $ztabla='vinn';
     $zcolu='vinn_clase';
     include('ele_datalist.php');
     
     $zid='dl_clor';
     $ztabla='vinn';
     $zcolu='vinn_clor';
     include('ele_datalist.php');
     
          
     }
     /////////
     
     $zid='mrca';
     $zvalue=$mrca;
     $zlabel='Marca';
     $ztabla='mrca';
     include('ele_input.php');

     
     $zid='mdvh';
     $zvalue=$mdvh;
     $zlabel='Modelo';
     $ztabla='mdvh';
     include('ele_input.php');
     
     
     $zid='anio'; 
     $zvalue=$anio;
     $zlabel='Año';
     $zlist='dl_anio';
     $zwidth=4;
     include('ele_input.php');


     $zobj=1;
     include('ele_break.php');


     $zid='clase';
     $zvalue=$clase;
     $zlabel='Clase';
     $zlist='dl_clase';
     include('ele_input.php');
     
     $zid='ntec';
     $zvalue=$ntec;
     $zlabel='Niv.Téc.';
     $zdefa=1;
     $zclass='numeric-dec';
     $zmin=1;
     $zmax=10;
     include('ele_input.php');
     
     
     
     $zid='clor'; 
     $zvalue=$clor;
     $zlabel='Color';
     $zlist='dl_clor';
     $zwidth=4;
     include('ele_input.php');

}
     
     
if(mb_stristr2('.plvh',$tabla))
{
 
     /////// datalist
     {
     $zid='dl_mrca';
     $ztabla='plvh';
     $zcolu='plvh_mrca';
     include('ele_datalist.php');
     
     $zid='dl_anio';
     $ztabla='plvh';
     $zcolu='plvh_anio';
     include('ele_datalist.php');
     
     $zid='dl_clase';
     $ztabla='plvh';
     $zcolu='plvh_clase';
     include('ele_datalist.php');
     
     $zid='dl_clor';
     $ztabla='plvh';
     $zcolu='plvh_clor';
     include('ele_datalist.php');
          
     }

     ///////////////
     
     
     $zid='mrca';
     $zvalue=$mrca;
     $zlabel='Marca';
     $zlist='dl_mrca';
     include('ele_input.php');
     
     $zid='anio'; 
     $zvalue=$anio;
     $zlabel='Año';
     $zlist='dl_anio';
     $zclass='numeric-int';
     $zmin=1950;
     $zmax=date('Y');
     include('ele_input.php');
     
     $zobj=1;
     include('ele_break.php');
     
     
     $zid='clase';
     $zvalue=$clase;
     $zlabel='Clase';
     $zlist='dl_clase';
     include('ele_input.php');

     $zid='ntec';
     $zvalue=$ntec;
     $zlabel='Niv.Téc.';
     $zdefa=1;
     $zclass='numeric-dec';
     $zmin=1;
     $zmax=10;
     include('ele_input.php');
     
     
     
     $zid='clor'; 
     $zvalue=$clor;
     $zlabel='Color';
     $zlist='dl_clor';
     $zwidth=4;
     include('ele_input.php');

}


if(mb_stristr2('.tmpr',$tabla))
{
     
     $ztabla='mdvh';
     include('ele_datalist.php');
     
     $zid='mdvh';
     $zvalue=$mdvh;
     $zlabel='Modelo';
     $ztabla='mdvh';
     include('ele_input.php');

     
     $ztabla='item';
     $zwhere='(item_lsub like "MMOO%")';
     include('ele_datalist.php');
     
     $zid='item';
     $zvalue=$item;
     $zlabel='Trabajo';
     $ztabla='item';
     include('ele_input.php');
     
     
     

}

if(mb_stristr2('.tcvh',$tabla))
{
     
     $ztabla='clvh';
     include('ele_datalist.php');
     
     $zid='clvh';
     $zvalue=$clvh;
     $zlabel='Clase VH.';
     $ztabla='clvh';
     include('ele_input.php');

     
     $ztabla='item';
     $zwhere='(item_lsub like "MMOO%")';
     include('ele_datalist.php');
     
     $zid='item';
     $zvalue=$item;
     $zlabel='Trabajo';
     $ztabla='item';
     include('ele_input.php');
     
     
     

}

     
     
     
if($tabla=='rgsn')
{
     $ztabla='pcom';
     $zwhere='(pcom_codigo in(select distinct substring(item_rgsn,locate(":",item_rgsn)+1) from item0 where ifnull(item_rgsn,"")!=""))';
     include('ele_datalist.php');

     $ztabla='ffar';
     $zwhere='(ffar_codigo in(select rgsn_formaf from rgsn0 where rgsn_codigo in(select item_rgsn from item0)))';
     include('ele_datalist.php');

     $zid='pcom';
     $zvalue=$pcom;
     $zlabel='Pres.Comer.';
     $ztodo=1;
     $ztabla='pcom';
     $zwhere='(pcom_codigo in(select distinct substring(item_rgsn,locate(":",item_rgsn)+1) from item0 where ifnull(item_rgsn,"")!=""))';
     include('ele_select.php');
//      include('ele_input.php');

     $zid='ffar';
     $zvalue=$ffar;
     $zlabel='Form.Farma.';
//      $ztodo=1;
//      $ztabla='ffar';
//      $zwhere='(ffar_codigo in(select rgsn_formaf from rgsn0 where rgsn_codigo in(select item_rgsn from item0)))';
//      include('ele_select.php');
     $zlist='dl_ffar';
     include('ele_input.php');

     
     
}

if($tabla=='mtch')
{
     $zid='liga'; $zvalue=$liga; $ztodo=1;
     $ztabla='liga';
     $zlabel='Liga';
     $zonchange='{info_maes(event);}';
     include('ele_select.php');

     $zid='torn'; $zvalue=$torn; $ztodo=1;
     $ztabla='torn';
     $zlabel='Torneo';
     $zonchange='{info_maes(event);}';
//      $zwhere='(mrca_codigo in(select distinct '.$tabla.'_mrca from inve1 left join inve2 on idnum1=idnum2 left join item0 on item='.$tabla.'_codigo where status not in ("O","X")))';
     $zwhere='(torn_liga="'.$liga.'" )';
     include('ele_select.php');
     
     $zid='jornada'; 
     $zvalue=$jornada; 
     $zclass='numeric-int';
     $zmin=1;
     $zmax=50;
//      $ztabla='jor';
     $zlabel='Jornada';
     $zoptn1=1;
     $zoptn2=50;
     $ztodo=1;
//      $zonchange='{info_maes(event);}';
     include('ele_select.php');

//      $zid='fecha';
//      $zlabel='Fecha';
//      $zvalue=$fecha;
//      $ztype='date';
//      $zmin=date('2020-01-01');
//      $zmax=date('Y-12-31',strtotime('+1 year'));
//      include('ele_input.php');
     
     
     
}

$zid='buscar'; 
$zvalue=$buscar;
$zlabel='Texto';
$zplace='buscar';
$zonenter='{info_maes(event);}';
include('ele_input.php');

     

     
     
$zid='btn_consul'; 
$zlabel='Consultar';
$zalign='right';
$zonclick='{info_maes(event);}';
// if($format==4){$zhide=1;}
include('ele_button.php');

echo '<span style="float:right; white-space:nowrap;">';     
if($format!=4)
{echo $msgres;}
echo '</span>';     
     

     
$zid='stat'; 
$zlabel='Status';
$zvalue=$stat;
// $zplace='Status';
$ztabla='stat';
$zalign='right';     
$zonenter='{info_maes(event);}';
// $zlist='dl_stat';
if(!empty($modu))     
{$zwhere='(stat_codigo in (select distinct '.$modu.'_status from '.$modu.'0 where '.$modu.'_status not in ("X")))';}
$ztodo=1;     
include('ele_select.php');  
// include('ele_input.php');


// if(@mb_stristr2('.item',$modu))
if(mb_stristr2('.item.ivta',$tabla))
{
     $zid='prec';
     $zlabel='Precio$';
     $zvalue=$prec;
     $zalign='right';
//      $zoptions='puni,Unit.;pvp,P.V.P.;punipvp,- TODO -';
     $zoptions='puni,Unit.;pvp,P.V.P.;punipvp,- TODO -';
//      $zoptions='puni,Unit.;pvp,P.V.P.';
//      $zhide=1;
     include('ele_select.php');  
}     
     
     
     
     

//      $zid='stat';
//      $zlabel='Status';
//      $zvalue=$stat;     
//      $ztabla='stat';
//      $ztodo=1;
//      {$zwhere='(stat_codigo in (select distinct status from '.$modu.'1 where status not in ("X")))';}
//      include('ele_select.php');  
     
     
     
     
     
     
// $ztitulo=$xtitulo;     
// include('ele_title.php');
     
 // if(@mb_stristr2('.sist.supe.admi',$user0['user_tipo']))
{

//      if($format==2 or $format==5)


}//filtros
     
     
     
echo '</div>';
     
      echo '<div id="cliedatos">';
      $zobj=1;include('ele_break.php');
      echo '</div>';
     
}
     
include('ele_break.php');
//      echo $sql_maes;

}
     
     
echo '<div id="main2">';     
// if(!empty($user_codigo))
{     
//      $domd = new DOMDocument();
//           $domd->encoding = 'utf-8';
//           $domd->xmlVersion = '1.0';
//           $domd->formatOutput = true;
//      $elem=$domd;
     
//      $table=$elem->appendChild($domd->createElement("table"));
//      $table->setAttribute("border","1");

//      $html=reso2file($res_info,'html');
//      echo $html;
     
     
// for($idx=1; $idx<=$sql_idx; $idx++)
{
//      if($info=='iikrdx'){$res_info=msql_query($sql_array[$idx],$link_data);}
//      if($info=='iikrdx' and msql_num_rows($res_krdx)>1 and msql_num_rows($res_info)==0){continue;}     

     if(gettype($res_info)!='NULL')
     {
          $zreso=$res_info;
          $zinfo=$info;
          $zname=$zname;
          $zhead=1;
          $zheightrow='1.6em';

//           $xlsf=$cfg_empr.'_'.$modu.'_'.$info.'_'.date('ymd_His');
          $xlsf=$cfg_empr.'_'.$modu.'_'.date('ymd_His');
          if($prnt==1){$xlsf='';}
          
          include('ele_grid.php');     
     
//           if($info=='iikrdx')
//           {if($idx<msql_num_rows($res_krdx)){echo '<div id="pgbreak" style="height:2em;"></div>';}}
     }
     
}

// if($modu=='refx')
if($info=='mtrefx')
{
     $zcodigo=$refx;
     include('ele_listg.php');
}
     
     
if(1==2)
{
     msql_data_seek($res_info,0);     
     while($aso_maes=msql_fetch_assoc($res_info))
     {
          $ztabla=$modu;
//           $zcodigo=$aso_maes[$tabla.'_codigo'];;
          $zcodigo=$aso_maes[$tabla.'_codigo'];;
          include ('ele_master.php');
     }
}     

//      echo $domd->saveXML();
     
}
echo '</div>';     
     
     

$psize =substr($pgsize,0,2).' ';
if(substr($pgsize,-1,1)=='V'){$psize.='portrait';}else{$psize.='landscape';}
?>


<style>
@page
{
size: <?php echo $psize; ?>;
margin: 10mm 10mm 10mm 10mm; /*	top right bottom left */
}        
</style>  

<script>
function info_maes(event)
{
     var xhref='',dataget;
     xhref=xhref+'?scri=<?php echo basename(__FILE__,'.php');?>';
     
     dataget=new_FormData('filtros','get');
     xhref=xhref+dataget;

     document.getElementById("main2").innerHTML='Espere...';
     location.href=xhref;
}
</script>


<script>document.title="<?php echo $xtitle;?>"</script>
<script>document.getElementById('topcenter').innerHTML="<?php echo $xtopcenter;?>"</script>
