<?php
declare(strict_types=0);
// graphemica.com
// php 8.0 inicializar variables
if(!array_key_exists("oscreen",$_SESSION)){$_SESSION['oscreen']='';}
if(!isset($zxml)){$zxml='';}

// $zclass.=' form-control ';

// if(abs($zvalue*1)>0 and mb_stristr2($zvalue,'.')){$zvalue=(float)$zvalue;}


$inputtag='input';
$zstyle='height:1.2em;';
if(mb_stristr2($zclass,'numeric')){$zstyle.='text-align:right;';}


if(mb_stristr2($zclass,'numeric'))
if(mb_stristr2($zvalue,','))
{$zvalue=str_replace(',','',$zvalue);}


if(!empty($ztype))
if(mb_stristr('.date.month.week',$ztype)){$zstyle.='font-size:0.9em;';}
// if(!mb_stristr('.date.month.week',$ztype)){$zstyle.='padding:0px;';}
// $zstyle.='padding:0px;';

// $zstyle='height:1.1em;';
$zstyle1='';
$zstyle3='line-height:1em;';

$zlist2=$zid."_dl";
$zclear=1;
$r_descrip='';
$zstep=(float)$zstep;
if($zrows>=2){$ztype='area';}
if($zrows>=2 and empty($ztxt)){$ztxt=4;}

// ✴▶
// if(strtolower($zlabel)=='fecha'){$zlabel='🗓📆📅 '.$zlabel;}
// if(strtolower($zlabel)=='fecha'){$zlabel='📅 '.$zlabel;}
// if(strtolower($zlabel)=='fecha'){$ztype='date';}
if(!empty($zlabel))
{if(mb_stristr('.fecha',strtolower($zlabel))){$ztype='date';}}

if($ztype=='date'){$zlist='';}
if($ztype=='date' and !empty($zdefa)){$zdefa=date('Y-m-d');}
if($ztype=='date' and !empty($zlabel)){$zlabel='📅 '.$zlabel;}
// if($ztype=='time' and !empty($zlabel)){$zlabel='⌚ '.$zlabel;}
if($ztype=='month' and !empty($zlabel)){$zlabel='📆 '.$zlabel;}
if($ztype=='week' and !empty($zlabel)){$zlabel='🗓 '.$zlabel;}




if(!mb_stristr($zlabel,'&#'))
{$zlabel=add_unicode($zlabel);}

if($zvalue=='..'){$zvalue='';}



if(empty($zobj)){$zobj=3;}
if(empty($zsize)){$zsize=1;}
if(empty($zalign)){$zalign='left';}
if(empty($zmaxlen)){$zmaxlen=0;}
if(empty($zid)){$zid=$ztabla;}
if(empty($zid)){$zid=$zlabel;}
if(empty($zlabel)){$zlabel=$zid;}
if(empty($zlabel2) and $ztype=='file' and $zobj==1){$zlabel2='🔼'; }
if(empty($zlabel2) and $ztype=='file'){$zlabel2='🔼 Cargar'; }
if(empty($zlabel2)){$zlabel2='OK';}
if(empty($zid)){$zid=microtime()*1000000;}
if(empty($zvalue) and !empty($zdefa)){$zvalue=$zdefa;}
if(empty($ztype)){$ztype='search';}
if(empty($zwidth)){$zwidth=10;}
if(empty($zaccept)){$zaccept='.*';}
if(empty($zplace) and $zobj==1){$zplace=$zsavef;}
if(empty($zplace) and $zobj==1){$zplace=$zlabel;}
if(empty($ztxt)){$ztxt=3;}
// if(empty($ztxt)){$ztxt=4;}
if(empty($ztabla)){$zstyle.='min-width:2em;';}
if(!empty($ztabla)){$zstyle.='min-width:3em;';}


if(empty($zplace))
{
     if(mb_stristr2($zclass,'numeric')){$zplace='0';}
     if(mb_stristr2($zclass,'-dec')){$zplace='0.00';}
     if(mb_stristr2($zclass,'-int')){$zplace=str_repeat('0',$zwidth);}
     if(!empty($zmax))
     {if(mb_stristr2($zclass,'-int')){$zplace=str_repeat('0',strlen($zmax));}}
     if(mb_stristr2($zlabel,'%')){$zplace='0.0';}
}

//90 dias
$set_cookie='{document.cookie = "'.$zid.'= "+encodeURIComponent(this.value)+"; max-age=" + '.(60*60*24*90).' + "; path=/";}';
$zonblur=$set_cookie.$zonblur;
// if(empty($zvalue)){$zvalue=$zvalue=$_COOKIE[$zid];}

// if($ztxt==1){$zonchange.='{this.value=this.value.toLowerCase();}';}
// if($ztxt==2){$zonchange.='{this.value=this.value.toUpperCase();}';}

if($ztxt==1){$zonblur.='{this.value=this.value.toLowerCase();}';}
if($ztxt==2){$zonblur.='{this.value=this.value.toUpperCase();}';}

if(empty($zakey)){$zakey=substr_letra($zlabel);}
// $zakey=strtoupper($zakey);
if(strcasecmp($zakey, "c") == 0 and !mb_stristr($zlabel,'consulta')){$zakey=substr_letra($zlabel,2);}
if(strcasecmp($zakey, "c") == 0 and substr($ztype,0,2)=='ch'){$zakey='';}
if(strcasecmp($zakey, "c") == 0 and $zobj=='1' ){$zakey='';}
if($zreado==1){$zakey='';}






// if(empty($ztxt)){$ztxt=4;}
// if(empty($zvalue)){$zreado=0;}
if(empty($zvalue) or (int)$zvalue==0){$zblank=1;}
else{$zblank=0;}

if(empty($ztitle) and $zid=='fecha1'){$ztitle='Fecha Inicial';}
if(empty($ztitle) and $zid=='fecha2'){$ztitle='Fecha Final';}

if($ztype=='date' and !empty($zvalue))
{$ztitle.=' : '.date('d/M/Y',strtotime($zvalue));}


// if($zreado==1)
// {$zondblclick.='{swal.fire({icon:"error",title:"Error",html:"Acceso Negado",confirmButtonColor:"darkred"})}';}

if($zreado==1)
{$zondblclick.='{swal.fire({icon:"info",title:"'.$ztitle.'",html:document.getElementById("'.$zid.'").value,confirmButtonColor:"black"})}';}

if($zreado==2)
{
     $zondblclick2='{';
//      $zondblclick2.='{document.getElementById("'.$zid.'").removeAttribute("disabled"); ';
     $zondblclick2.='document.getElementById("'.$zid.'").style.background=""; ';
     $zondblclick2.='document.getElementById("'.$zid.'").style.color=""; ';
     $zondblclick2.='document.getElementById("'.$zid.'").focus(); ';
     $zondblclick2.='document.getElementById("'.$zid.'").select(); ';
     $zondblclick2.='}';
     $zondblclick.=$zondblclick2;
}

if(mb_stristr($zid,'mail')){$ztxt=1;}
if(mb_stristr($zid,'user')){$ztxt=4;}
if(mb_stristr($ztype,'files')){$ztype='file';}
if(mb_stristr($ztype,'pass')){$ztype='password'; $ztxt=4;}
if(mb_stristr($ztype,'check')){$ztype='checkbox';}
if(mb_stristr($ztype,'radio') and empty($zname)){$zname=$znamer;}
if(mb_stristr($zclass,'numeric')){$ztype='number';}
if(mb_stristr($zclass,'numeric-int')){$zstep=intval($zstep*1);}
if(mb_stristr($zclass,'numeric-dec') and empty($zstep)){$zstep='any';}
if(mb_stristr($ztype,'color')){$zstyle='height:3em; width:10em;';}
if(mb_stristr($ztype,'color')){$zclear=0;}

// if(substr($zaccept,0,1)!='.'){$zaccept=".".$zaccept;}
if(substr($zaccept,0,1)!='.' and strlen(trim($zaccept))<=4){$zaccept=".".$zaccept;}
if(strlen(trim($zaccept))>4){$zaccept.="/*";}

// if($ztxt==3){$zonblur.='{this.value=this.value.toUpperCase();}';}


if($ztype=='file'){$zstyle='height:2em;';}
if($ztype=='file'){$znoprint=1;}
// if($ztype=='file'){$zplace='📷'.$zplace;}
// if($ztype=='file'){$zclear=0;}
if($ztype=='area'){$inputtag='textarea'; $zstyle='resize:none;overflow:hidden;';}  
// if($ztype=='area' and $zobj>2){$zobj=2;}  
if($ztype=='area' and $zobj==3){$zobj=2;}  
if($ztype=='area' and $zrows<2){$zrows=2;}
if($ztype=='area'){$ztxt=4;}
// if($ztype=='area'){$zonchange.='{set_arearows("'.$zid.'")}';}
// if($ztype=='number' and empty($zreado)){$zwidth=0;}
if($ztype=='password'){$zonblur.='{this.type="password";}'; }
if($ztype=='checkbox'){$zautoc='off';}
if($ztype=='checkbox'){$zplace='';}
if($ztype=='checkbox'){$zclear=0;}
// if($ztype=='checkbox' and $zobj!=1){$zobj=5;}
if($ztype=='checkbox' and $zobj==3){$zobj=5;}
if($ztype=='radio'){$zclear=0;}
if($ztype=='radio' and $zobj!=1){$zobj=5;}
/////////////
if(mb_stristr('.date.time.datetime-local.month.week.year',$ztype)){$zmaxlen=0; $zwidth=0; $zclear=0; }
if($ztype=='month' and !empty($zvalue)){$zvalue=substr($zvalue,0,7);}     
//if($ztype=='week' and !empty($zvalue)){$zvalue=substr($zvalue,0,8);}

if($ztype=='date' and empty($zvalue)){$zvalue=date('Y-m-d'); if(date('H')<='5'){$zvalue=date('Y-m-d',strtotime('-0 day'));}}     
if($ztype=='month' and empty($zvalue)){$zvalue=date('Y-m');}     
if($ztype=='week' and empty($zvalue)){$zvalue=date('Y-\WW');}     
// if($ztype=='time' and empty($zvalue)){$zvalue=date('H:i:s');}     
if($ztype=='time' and empty($zvalue)){$zvalue=date('H:i'); }     
/////////////
if(empty($zreado))
{
     if(mb_stristr('.date.month.week.year.time.',$ztype)){$zonclick='{set_inputdate("'.$zid.'",2);}';}
     
     if(substr($zid,-1)=='1')
     {if(mb_stristr('.date.month.week.year.time.',$ztype)){$zonclick='{set_inputdate("'.$zid.'",1);}';}}
     
     if(!empty($zdefa))
     {$zondblclick='{document.getElementById("'.$zid.'").value="'.$zdefa.'";}';}
     
     if(mb_stristr('.date.month.week.year.time.',$ztype)){$zondblclick='{set_inputdate("'.$zid.'",0);}';}
     
     if(substr($zid,-1)=='2')
     {if(mb_stristr('.date.month.week.year.time.',$ztype)){$zondblclick='{set_inputdate("'.$zid.'",3);}';}}

     if($ztype=='time' and $zdefa=='now')
     {$zonclick="{document.getElementById('".$zid."').value=new Date().getHours()+':'+new Date().getMinutes();}";}
     
}



// if($ztype=='month' and !empty($zlabel)){$zlabel='📅'.$zlabel;}
// if($ztype=='date' and !empty($zlabel)){$zlabel='📆'.$zlabel;}
// if($ztype=='week' and !empty($zlabel)){$zlabel='🗓'.$zlabel;}

// if(!empty($zdefa))
// {$zonclick='{document.getElementById("'.$zid.'").value="'.$zdefa.'";}';}


if($ztype=='date'){$zonchange.='{set_daynomb(this.id);}';}
if($ztype=='month'){if(empty($zmin)){$zmin=date('Y-m'); $zmax=date('Y-m',strtotime('+12 month'));}}
if($ztype=='week') {if(empty($zmin)){$zmin=date('Y-\WW'); $zmax=date('Y-\WW',strtotime('+52 week'));}}
if($ztype=='year' and empty($zvalue)){$zvalue=date('Y');}    
if($ztype=='year') {if(empty($zmin)){$zmin=date('Y')-(9); $zmax=date('Y')+(9);}}
if($ztype=='year'){$ztype='number';}    

if($zmin==$zmax and !empty($zmin)){$zreado=1;}



// echo '<br>=='.$zid;
// echo '<br>=='.$user0['user_hide_wsapp'];
// echo '<br>=='.$zvalue;
if($user0['user_hide_wsapp']==1 and strlen($zvalue)>=8)
{
//      if($zid=='wsapp' or $zid=='telefono')
     if(
          mb_stristr($zid,'wsapp')
        or mb_stristr($zid,'telefono')
        or mb_stristr($zlabel,'wsapp')
        or mb_stristr($zlabel,'teléfono')
       )
     {
          $zreado=1;
          $ztype='password';
     }
}
     


$oscreen=$_SESSION['oscreen'];
$getplat=getPlatform();
// if(($zobj==2 or $zobj==3 or $zobj==6) and $ztcell<=1 and getPlatform()=='Android'){$zobj=4;}
if(($zobj==2 or $zobj==3) and $ztcell<=1 and $getplat=='Android'){$zobj=4;}
if(($zobj==2 or $zobj==3) and $ztcell<=1 and $getplat=='Linux'){$zobj=4;}


// echo '*/*/*'.$getplat;

// if(!empty($zreado)){$zwidth=strlen($zvalue)*(0.67);}
// if(!empty($zreado) and strlen($zvalue)>4){$zwidth=strlen($zvalue)*(0.67);}
// if(!empty($zmax) and $zclass=='numeric-dec'){$zwidth=strlen($zmax)+2;}

// if($zreado==1){$zwidth=strlen($zvalue)*1; $zwidth=ceil($zwidth); echo '==='.$zid.$zwidth; }
// if($zreado==1){$zwidth=strlen($zvalue)*(0.8); $zwidth=ceil($zwidth);   }
if($zreado==2){$zwidth=strlen($zvalue)*(1.2); $zwidth=ceil($zwidth); }
if(!empty($zmax)){$zwidth=strlen($zmax);}
if(!empty($zmax) and $zclass=='numeric-dec'){$zwidth=strlen((int)$zmax)+2; $zwidth=ceil($zwidth);}


// if(empty($zmax) and $ztype=='number'){$zmax=pow(10,$zmaxlen)-1; $zmin=$zmax*(-1); $zmaxlen=0;}
if(empty($zmax) and $ztype=='number'){$zmax=pow(10,$zmaxlen)-1;}
// if(empty($zmin) and $ztype=='number'){$zmin=$zmax*(-1);}

if(empty($zmin) and $ztype=='date'){$zmin=date('Y-m-d');}
if(empty($zmax) and $ztype=='date'){$zmax=date('Y-m-d');}


// if(!empty($zmin) or !empty($zmax)){$zonchange.='{val_minmax(this.id)}';}
if(!empty($zmin) or !empty($zmax)){$zonblur.='{val_minmax(this.id);}';}
if(!empty($zmin) or !empty($zmax)){$zautoc='off';}
if(mb_stristr('.date.month.week',$ztype)){$zonblur.='{set_fecha12(this.id);}';}

if(empty($ztabla)){$zcodeo=0;}
if($ztabla=='plvh')
{
   $zonblur.='{vali_plvh("'.$zid.'")}';
}

// echo'*/*/*/'.$ztabla;
$ztabla_ok=0;
if(!empty($ztabla))
{
   $sql_input='describe '.$ztabla.'0';
   $res_input=msql_query($sql_input,$link_data);
   
   if(!msql_error($link_data))	
   {
      $zmaxlen=msql_result($res_input,0,1);
      $zmaxlen=str_replace(')','',$zmaxlen);
      $zmaxlen=str_replace('varchar(','',$zmaxlen);
      $zmaxlen=str_replace('char(','',$zmaxlen);
      $zmaxlen=str_replace('smallint(','',$zmaxlen);
      $zmaxlen=str_replace('int(','',$zmaxlen);
//       $zmaxlen=$xmaxlen*1;
      $ztype='search';
//       $zwidth=0;
        
        
//      if($zreado!=0)
     if(!mb_stristr($zwidth,'auto'))
     {
          $zwidth=$zmaxlen+1;
     }
        
     if(mb_stristr('.enti.item',$ztabla)  and $zexact==1)
     {$ztype='number';}
        
        
//      if(!empty($zvalue))
     if(!empty($zvalue) and ($zobj==3 or $zobj==4))
     {
          $sql_input='select * from  '.$ztabla.'0 where '.$ztabla.'_codigo="'.$zvalue.'"';
          $res_input=msql_query($sql_input,$link_data);
          $r_descrip=msql_result($res_input,0,$ztabla.'_descri');
          $r_descrip=str_replace('/ ','/',$r_descrip);
          $r_descrip=str_replace('/','/ ',$r_descrip);
          
          if(mb_stristr('.enti.clie.prov.empl.codt.vndd.rcdd..item.ibod.igas',$ztabla))
          {$r_descrip=ucwords2(strtolower($r_descrip));}
          
          $r_descrip=str_replace('/ ','/',$r_descrip);
     }
        
   }else{$ztabla='';}
   
}


$datamaes='';
if(empty($zopen))
{
//      if(!empty($ztabla))
     $xdmcodigo=0;
     if(!empty($ztabla))
     {
          $xdmcodigo=1;
          if(mb_stristr('.enti.clie.ptov.empl',$ztabla))
          {$xdmcodigo=0;}
     }
          
     if($xdmcodigo==1)
     {$datamaes.='{data_maes("'.$ztabla.'",this.value,"'.$ztabla.'_codigo","'.$zid.'","'.$zexact.'")}';}
     
     if(!empty($ztabla) and $zobj>=3)
     {$datamaes.='{data_maes("'.$ztabla.'",this.value,"'.$ztabla.'_descri","'.$zid.'_r","'.$zexact.'")}';}
}
// $zonblur=$datamaes.$zonblur;
$zonblur=$zonblur.$datamaes;
// $zonchange=$zonchange.$datamaes;

if(!empty($ztabla))
{
//      echo '<br>===='.$ztabla;
     $zonblur.='{vali_maes("'.$ztabla.'",this.value);}';
     $zonenter.='{vali_maes("'.$ztabla.'",this.value);}';
}

if(!empty($zsave)){$zonblur.="{save_data(event,'".$zid."');}";}

if(!empty($ztabla) and empty($zlist)){$zlist='dl_'.$ztabla;}
// if(!empty($zreado)){$zclear=0;$zlist='';}
if($zreado==1){$zclear=0;$Xzlist='';}
if($zreado>=1 and mb_stristr($zclass,'numeric')){$zclear=0;$Xzlist='';}

if(!empty($zexact)){$Xzlist=''; $zlist2=''; $zautoc="off";}

if(empty($zautoc))
{
     $zautoc="on";
     if(!empty($zlist)){$zautoc="off";}
}



if(empty($zmaxlen) and mb_stristr($zclass,'numeric')){$zmaxlen=7;}
if(mb_stristr($zclass,'numeric') and !empty($zmax)){$zmaxlen=strlen($zmax);}
// if(mb_stristr($zclass,'numeric-int') and !empty($zmax)){$zmaxlen=strlen($zmax);}
// if(empty($zwidth) and !empty($zmaxlen)){$zwidth=(int)$zmaxlen*(.7)+1.5;}
// echo '*/*/*'.$zwidth.$zid.$zmaxlen;
if(empty($zwidth) and !empty($zmaxlen)){$zwidth=($zmaxlen+1)*(0.67); $zwidth=ceil($zwidth);}

if(!empty($zfontcolor)){$zstyle.='color:'.$zfontcolor.';';}
if(!empty($zbackcolor)){$zstyle.='background-color:'.$zbackcolor.';';}


if(!empty($zsize) and $zsize!=1){$zstyle.='font-size:'.($zsize).'em;';}
if(!empty($zsize) and $zsize!=1){$zstyle1.='font-size:'.($zsize).'em;';}
// if(!empty($zsize) and $zsize!=1){$zstyle3.='font-size:'.($zsize).'em;';$zstyle3.='height:'.($zsize).'em;';}
if(!empty($zsize) and $zsize!=1){$zstyle3.='font-size:'.($zsize).'em;';}

$zstyle1.='vertical-align:top;';
if($ztcell>=2){$zstyle1.='width:100%;';}

{
     if(mb_stristr($zwidth,'auto')){$zstyle.='width:auto;';}
     elseif(mb_stristr($zwidth,'%'))
     {
          if($ztype=='text'){$zstyle.='width:'.($zwidth).';';}
          if($ztype=='area'){$zstyle.='width:'.($zwidth).';';}
          if($ztype=='password'){$zstyle.='width:'.($zwidth).';';}
          if($ztype=='number'){$zstyle.='width:'.($zwidth).';';}
          if($ztype=='search'){$zstyle.='width:'.($zwidth).';';}
     }
     else
     {
          if(!empty($zlist)){$zwidth++;}
          if($ztype=='text'){$zstyle.='width:'.($zwidth).'em;';}
          if($ztype=='area'){$zstyle.='width:'.($zwidth).'em;';}
          if($ztype=='password'){$zstyle.='width:'.($zwidth).'em;';}
          if($ztype=='number'){$zstyle.='width:'.($zwidth*(0.75)).'em;'; }
          if($ztype=='search' and empty($ztabla)){$zstyle.='width:'.($zwidth).'em;'; }
          if($ztype=='search' and !empty($ztabla)){$zstyle.='width:'.(($zwidth+2)*0.75).'em;'; }
          if($ztype=='time'){$zstyle.='width:7em;';}
//           if($ztype=='search' and !empty($ztabla)){$zstyle.='width:auto'; }
     }
     
//      echo '*/*/'.$zid;
//      echo '*/*/'.$ztype;
     
//      if($ztype=='number' and !empty($zreado)){$zstyle.='text-align:right;';}
     if(!empty($ztalign)){$zstyle.='text-align:'.$ztalign.';';}
     
     
     if($ztype=='checkbox'){$zstyle.='zoom:1.4; margin-top:0px;';}
     if($ztype=='radio'){$zstyle.='zoom:1;';}
     
     if($ztype=='date' and $zreado!=1){$zstyle.='width:'.(9).'em;';}
     if($ztype=='date' and $zreado==1){$zstyle.='width:'.(7).'em;';}
//      if($ztype=='time' and $zreado!=1){$zstyle.='width:'.(5).'em;';}
     if($ztype=='time' and $zreado!=1){$zstyle.='width:'.(7).'em;';}
     if($ztype=='datetime'){$ztype='datetime-local';}
     if($ztype=='datetime-local'){$zstyle.='width:'.(11).'em;';}
}


$zonblur=$zonblur.$zonblur2;
// if(!empty($zonblur2))
// {
// $zonblur='await{'.$zonblur.'}() {'.$zonblur2.'}';
// }



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

if(!empty($zdom)){$domd_i=$zdom;}
if(!empty($zele)){$elem_i=$zele;}

// if($zobj>1)
{
     
if($ztcell>=2 and $zobj>=2 and $zobj<=3)
{
     $element=$elem_i->appendChild($domd_i->createElement("td"," "));
     $element->setAttribute("valign","top");
}
else
{
//      echo '=== ';
     $element=$elem_i->appendChild($domd_i->createElement("span"," "));
     if(empty($zdom))
     {
          $xstyle0="float:".$zalign.";margin-left:".$zsize*(0.5)."em;margin-right:".$zsize*(0.5)."em;margin-bottom:0.1em;";
          if($zobj==4)
          {$xstyle0.="margin-top:10px;";}
          $element->setAttribute("style",$xstyle0);
     }
     if(mb_stristr($zwidth,'%'))
     {$element->setAttribute("style","width:".$zwidth.";");}
}
     
// if($ztype=='checkbox'){$element->setAttribute('v',$zvalue);}     
// if($ztype=='checkbox'){$element->setAttribute('val',$zvalue);}     
     
$element->setAttribute("id",$zid.'_ele');     
if(!empty($zhide)){$element->setAttribute("hide","");}
if(!empty($znoprint)){$element->setAttribute("noprint","");}
if(!empty($ztitle)){$element->setAttribute("title",$ztitle);}
if($zreado==2){$element->setAttribute("ondblclick","habilitarInput('".$zid."')");}
     
// if(!empty($znoprint))
{
//      $element->setAttribute("unselectable","on");
//      $element->setAttribute("onmousedown","{return false;}");
//      $element->setAttribute("onselectstart","{return false;}");
}

     
     
     
  // windows
//    if($zobj==2 or $zobj==3)
//    if($zobj==2 or $zobj==3 or ($zobj==6 and $getplat!='Android'))
   if($zobj==2 or $zobj==3)
   {
      $zclass1='';
      $label=$element->appendChild($domd_i->createElement("button",($zlabel)));   
        
      if(!empty($zid))
      {
        $label->setAttribute("id",$zid.'_l');
        $label->setAttribute("type","button");
        $label->setAttribute("tabindex","-1");
      }
//       if(!empty($ztitle)){$element->setAttribute("title",$ztitle);}
      if(!empty($zlabel)){$label->setAttribute("value",($zlabel));}
      if(!empty($zstyle1)){$label->setAttribute("style",$zstyle1);}
      if(!empty($zclass1)){$label->setAttribute("class",$zclass1);}
      if(!empty($zdefa)){$label->setAttribute("defa",$zdefa);}
      if(!empty($zonclick)){$label->setAttribute("onclick",$zonclick);}
      if(!empty($zondblclick)){$label->setAttribute("ondblclick",$zondblclick);}
      if($ztype=='file' and $zobj==2){$label->setAttribute("hide","");}     
   }

}


if($ztcell>=2)
{
  $element=$elem_i->appendChild($domd_i->createElement("td"));
  $element->setAttribute("colspan",$ztcell);
  $element->setAttribute("valign","top");
}

    //android
//    if($zobj==4 or ($zobj==6 and $getplat=='Android'))
   if($zobj==4 or ($zobj==6 ))
   {
     $zclass1='input-label';
     $label=$element->appendChild($domd_i->createElement("label",($zlabel)));   
     if(!empty($zid)){$label->setAttribute("id",$zid.'_l');}
     if(!empty($zid)){$label->setAttribute("for",$zid);}
     if(!empty($zstyle1)){$label->setAttribute("style",$zstyle1);}
     if(!empty($zclass1)){$label->setAttribute("class",$zclass1);}
     if($ztype=='checkbox'){$label->setAttribute("align-c",'');}
     if(!empty($zondblclick))
     {$label->setAttribute("onclick",$zondblclick);}
        
     
   }

   $div_ele=$element->appendChild($domd_i->createElement("span",""));
//      $div_ele->setAttribute("class","mb-3");

     if(mb_stristr($zwidth,'%'))
     {$div_ele->setAttribute("style","width:".$zwidth."");}

//      if(empty($zreado) and !empty($zclear))
     if($zclear==1)
     {$div_ele->setAttribute("class","clearable-input");}

     if($ztype=='password')
     {
          $xclass ='clearable-input ';
          $xclass.='password-input';
          $div_ele->setAttribute("class",$xclass);
     }

//      if($zclear)
     if($zclear==1)
     {
          $span=$div_ele->appendChild($domd_i->createElement("span","×"));   
          $span->setAttribute("id",$zid."_x");
          $span->setAttribute("data-clear-input","");
          $style_x='font-size:'.($zsize+1).'em;';
          if(!empty($zreado)){$style_x.='display:none;';}
          if(!empty($zsize)){$span->setAttribute("style",$style_x);}
          
//▲▼↑↓               
          if(!empty($zlist))
          {
//                $span=$div_ele->appendChild($domd_i->createElement("span","▼"));   
//                $span->setAttribute("myarrow","");
//                if(!empty($zsize)){$span->setAttribute("style",'font-size:'.($zsize).'em;');}
          }
          
          
     }


     
   if($inputtag=='textarea' and !empty($zvalue))
   {$input=$div_ele->appendChild($domd_i->createElement($inputtag,htmlspecialchars($zvalue))); }
   else
   {$input=$div_ele->appendChild($domd_i->createElement($inputtag,"")); }

     if(!empty($zmulti))
     {$input->setAttribute("multiple"," ");}
     if(!empty($zaccept) and $ztype=='file')
     {$input->setAttribute("accept",$zaccept);}
     if(!empty($zcapture) and $ztype=='file')
     {
          if((int)$zcapture>0)
          {$input->setAttribute("capture","");}
          else
          {$input->setAttribute("capture",$zcapture);}
     }


     if(!empty($zakey) )
     {$input->setAttribute("accesskey",$zakey);}

//      if(empty($zreado) and $ztype=='checkbox')
//      {$input->setAttribute("onchange",'{ele_input_onkey(event,this.id);}');}

     if(empty($zreado) and $ztype!='checkbox')
     {$input->setAttribute("onKeyDown",'{ele_input_onkey(event,this.id);}');}

     if(empty($zreado) and $ztype!='radio')
     {$input->setAttribute("onKeyDown",'{ele_input_onkey(event,this.id);}');}

// if($ztype=='checkbox')
// echo '==='.$zautoc;

     if(!empty($zid)){$input->setAttribute("id",$zid);}
     if(!empty($zvalue)){$input->setAttribute("value",$zvalue);}
     if(!empty($zautoc)){$input->setAttribute("autocomplete",$zautoc);}
//      if(!empty($zautoc) and $zautoc!='off'){$input->setAttribute("autocomplete",$zautoc);}
     if(!empty($ztype)){$input->setAttribute("type",$ztype);}
     if(!empty($zname)){$input->setAttribute("name",$zname);}
     if(!empty($zclass)){$input->setAttribute("class",$zclass);}
     if(!empty($zplace)){$input->setAttribute("placeholder",$zplace);}
     if(!empty($zreado)){$input->setAttribute("disabled","");}
     if(!empty($zreado)){$input->setAttribute("bold","");}
//      if(!empty($zblank))
     if($ztype!='checkbox')
     {$input->setAttribute("blank",$zblank);}
//      if(!empty($zreado)){$input->setAttribute("f-black"," ");}
     if(empty($zfontcolor))
     {if(!empty($zreado)){$zstyle.='color:black;';}}

//      if($zreado==1){$input->setAttribute("bold","");}
     if(!empty($zmax)){$input->setAttribute("max",$zmax);}
     if(!empty($zmax)){$input->setAttribute("min",$zmin);}
     if(!empty($zstep)){$input->setAttribute("step",$zstep);}
     if(!empty($zrows)){$input->setAttribute("rows",$zrows);}
     if(!empty($zoninput)){$input->setAttribute("oninput",$zoninput);}
     if(!empty($zonenter)){$input->setAttribute("onenter",$zonenter);}
     if(!empty($zonblur)){$input->setAttribute("onblur",$zonblur);}
     if(!empty($zonchange)){$input->setAttribute("onchange",$zonchange);}
     if(!empty($zonkeyup)){$input->setAttribute("onkeyup",$zonkeyup);}
     if(!empty($zondblclick2)){$input->setAttribute("ondblclick",$zondblclick2);}

//      if(!empty($zvalue)){$input->setAttribute("value",$zvalue);}
     if(!empty($zdefa)){$input->setAttribute("defa",$zdefa);}
//      if(!empty($zvalue) and $ztype=='checkbox'){$input->setAttribute("checked","");}
     if(!empty($zmaxlen)){$input->setAttribute("maxlength",$zmaxlen);}

// echo '<br> ==== '.$zstyle;
// echo '<br> ==== '.$zstyle1;
// echo '<br> ==== '.$zstyle2;
// echo '<br> ==== '.$zstyle3;
     if(!empty($zstyle)){$input->setAttribute("style",$zstyle);}


//      if(!empty($zreado))
     if(date('Y-m-d')>'2024-07-31')
     {
          if($ztxt==1){$input->setAttribute("txt-lower","");}
          if($ztxt==2){$input->setAttribute("txt-upper","");}
     }

//      if($ztxt==2){$input->setAttribute("txt-capital","");}
//      if(mb_stristr($zid,'mail')){$input->setAttribute("txt-lower","");}
//     if(!empty($zondblclick)){$input->setAttribute("ondblclick",$zondblclick);}


     if(($zvalue==1 or $zvalue=='true') and $ztype=='checkbox'){$input->setAttribute("checked","");}
//      if(($zvalue==1 or $zvalue=='true') and $ztype=='radio'){$input->setAttribute("checked","");}
     if(!empty($zsave))
     {
          $input->setAttribute("savet",$zsavet);
          if(!empty($zsavec))
          {$input->setAttribute("savec",$zsavec);}
          else
          {
          $input->setAttribute("savei",$zsavei);
          if(!empty($zsaved)){$input->setAttribute("saved",$zsaved);}
          }
          $input->setAttribute("savef",$zsavef);
     }

     if(!empty($zopen))
     {$input->setAttribute("open",$zopen);}

     if(!empty($ztabla))
     {
          $input->setAttribute("list",$zlist);
          $input->setAttribute("list1",$zlist);
          $input->setAttribute("list2",$zlist2);
          if(!empty($zexact))
          {$input->setAttribute("exact",$zmaxlen);}
     }

     if(!empty($zlist)){$input->setAttribute("list",$zlist);}



     if($ztype=='time' and $zdefa=='now')
     {
//           $input->setAttribute("onclick","{document.getElementById('".$zid."').value=new Date().getHours()+':'+new Date().getMinutes();}");          
     }

     if($ztype=='file')
     {
          if($zobj==2)
          {}
          
          $input->setAttribute("hide","");
          $input->setAttribute("onchange","{document.getElementById('sf".$zid."').value=this.files.length+' archivo(s)';}");
          if($zobj==1)
          {$input->setAttribute("onchange","{document.getElementById('sf".$zid."').value=this.files.length;}");}
          
          $input=$div_ele->appendChild($domd_i->createElement("input"," "));  
          $input->setAttribute("id","sf".$zid);
          $input->setAttribute("readonly","");
          $input->setAttribute("sel-file","");
          $input->setAttribute("onclick","{document.getElementById('".$zid."').click();}");
          $input->setAttribute("title",'Seleccionar Archivos');
          $input->setAttribute("placeholder",'Seleccionar Archivos');
//           $input->setAttribute("onmouseover","{this.value=document.getElementById('".$zid."').files.length+' archivo(s)';}");
          $style_f="height:1.8em; ";
          if(!empty($zsize))
          {$style_f.='font-size:'.$zsize.'em; ';}
          
          if($zobj==1)
          {
//                $input->setAttribute("hide","");
               $style_f.="width:2em;";
          }
          $input->setAttribute("style",$style_f);
          
     }
          
     if(!empty($zonclick2))
     {
          $button=$element->appendChild($domd_i->createElement("button",$zlabel2));                         
               $button->setAttribute("id",$zid.'_btn2');
               $button->setAttribute("title",'Subir Archivos');
               if($ztype=='file')
               {
                    $button->setAttribute("btn-file","");
                    if($zobj==1)
                    {$zonclick2='{if(document.getElementById("'.$zid.'").value===""){document.getElementById("'.$zid.'").click();}else{'.$zonclick2.'}}';}
//                     {$zonclick2='{if(document.getElementById("'.$zid.'").value===""){document.getElementById("'.$zid.'").click();'.$zonclick2.'}else{}}';}
               }
               $button->setAttribute("onclick",$zonclick2);
     }





//      if(!empty($zsave))
     if(!empty($zsave) and $ztype!='checkbox')
     {
//           $button=$div_ele->appendChild($domd_i->createElement("button","Grabar"));
//           if($zsave<3)
//           {$button->setAttribute("hide","");}
//           $button->setAttribute("onclick","{save_data(event,'".$zid."');}");
     }

     if($ztype=='password')
     {

//           $icon_eye='&#128065;';
          $icon_eye='👁️';
          if($user0['user_hide_wsapp']==1 and $zid=='wsapp'){$icon_eye='';}
          
          $span=$div_ele->appendChild($domd_i->createElement("span",$icon_eye));   
          $span->setAttribute("password-input","");
          if(!empty($zsize)){$span->setAttribute("style",'font-size:'.($zsize).'em;');}
     }

//      if($ztype=='checkbox' and $zobj!=1)
     if($ztype=='checkbox' and $zobj==5)
     {
          $zclass1='input-label';
          $label=$element->appendChild($domd_i->createElement("span",htmlspecialchars($zlabel)));   
          $label->setAttribute("onclick","{document.getElementById(\"".$zid."\").click();}");
          if(!empty($zid)){$label->setAttribute("id",$zid.'_l');}
//           if(!empty($zid)){$label->setAttribute("for",$zid);}
//           if(!empty($zstyle1)){$label->setAttribute("style",$zstyle1);}
          if(!empty($zstyle1)){$label->setAttribute("style","vertical-align:middle;");}
          if(!empty($zclass1)){$label->setAttribute("class",$zclass1);}
     }

     if($ztype=='radio' and $zobj!=1)
     {
          $zclass1='input-label';
          $label=$element->appendChild($domd_i->createElement("span",($zlabel)));   
          $label->setAttribute("onclick","{document.getElementById(\"".$zid."\").click();}");
          if(!empty($zid)){$label->setAttribute("id",$zid.'_l');}
//           if(!empty($zid)){$label->setAttribute("for",$zid);}
//           if(!empty($zstyle1)){$label->setAttribute("style",$zstyle1);}
//           if(!empty($zstyle1)){$label->setAttribute("style","vertical-align:middle;");}
          if(!empty($zstyle1)){$label->setAttribute("valign-b","");}
          if(!empty($zclass1)){$label->setAttribute("class",$zclass1);}
     }

     if(!empty($zonenter) and $zobj==6 and 1==2)
     {
          $zclass1='';
          $btnenter=$element->appendChild($domd_i->createElement("button",htmlspecialchars("◄╝")));   
          $btnenter->setAttribute("onclick",$zonenter);
          if(!empty($zid)){$btnenter->setAttribute("id",$zid.'_enter');}
          if(!empty($zstyle1)){$btnenter->setAttribute("style",$zstyle1);}
          if(!empty($zclass1)){$btnenter->setAttribute("class",$zclass1);}
     }

     if(!empty($ztabla))
     {
          $dlist=$element->appendChild($domd_i->createElement("datalist"," "));   
          $dlist->setAttribute("id",$zid.'_dl');
     }


     $icon_edit='&#128221;';
     $icon_edit='&#9997;';

     

//      if(!empty($ztabla) and empty($zreado))
//      {
//           $btn_edit=$element->appendChild($domd_i->createElement($ele_r,$icon_edit));
//           $xonclick='{data_maes("'.$ztabla.'",this.value,"'.$ztabla.'_descri","'.$zid.'_r","'.$zexact.'")}';
//           $xondblclick='{regi_maes("'.$ztabla.'",document.getElementById("'.$zid.'").value);}';
//           $xonclick='{regi_maes("'.$ztabla.'",document.getElementById("'.$zid.'").value);}';
//           $btn_edit->setAttribute("onclick",$xonclick);
// //           $btn_edit->setAttribute("size140"," ");
// //           $btn_edit->setAttribute("ondblclick",$xondblclick);
//      }


//      if(empty($zreado))
     if(!empty($ztabla))
     {$ele_r='a';}
     else{$ele_r='span';}

     if($zobj==4){$ele_r='div';}


     if(mb_stristr('.date.',$ztype))
     {
          $r_descrip=strftime2('%A',strtotime($zvalue));
          $r_descrip=substr($r_descrip,0,3);
          $r_descrip='';
          $tab_desc=$element->appendChild($domd_i->createElement($ele_r," ".htmlspecialchars($r_descrip)));
          $tab_desc->setAttribute("id",$zid.'_r');
     }


     if(!empty($ztabla))
     {
          $tab_desc=$element->appendChild($domd_i->createElement($ele_r," ".htmlspecialchars($r_descrip)));
          $tab_desc->setAttribute("id",$zid.'_r');
//           echo '*/*/*'.$zid.$zobj.$zstyle3;
          if($zobj==1 or $zobj==2 or $zobj==6)
          {$tab_desc->setAttribute("hide","");}

          $xonclick='{regi_maes("'.$ztabla.'",document.getElementById("'.$zid.'").value);}';
          if(!empty($user0['user_codigo']))
          {$tab_desc->setAttribute("onclick",$xonclick);}
//           {$xonclick='';}
          if(!empty($zstyle3)){$tab_desc->setAttribute("style",$zstyle3);}
     }


// if($ztype=='checkbox'){echo '=='.$zobj;}

// if(empty($zdom) and empty($zdomX))
if(empty($zdom))
{
     if($zxml==1){$zxml=$domd_i->saveHTML();}
     else{echo $domd_i->saveHTML();}
}     


// if(empty($znoreset))
{include ('ele_reset.php');}



?>