<?php 
declare(strict_types=0);
// session_start();
// https://aplicaciones.controlsanitario.gob.ec/publico/consultas/lista?str_consultar=881-MEN-0616
//      echo '<br>TIME A = '.date('H:i:s');

foreach($_GET  as $key => $value){${$key}=trim($value);} 
foreach($_POST as $key => $value){${$key}=trim($value);} 
include_once('lib_main.php');

$user_codigo=$_SESSION['user_codigo'];



if($modu=='trty')
{if(!is_dir('imgt')){mkdir('imgt');}}

// vali_maes('pk12');

// echo '====='.$modu;
$modu=strtolower($modu);
if($modu=='empr'){vali_maes('pk12');}
vali_maes($modu);

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;}

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

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

if($modu=='empr'){$codigo=$empr0['empr_codigo'];}


if($modu=='user' and !mb_stristr2('sist.supe',$user0['user_tipo']))
{$codigo=$user_codigo;}


$cant=0;
$puni=0;

// 1 ver
// 2 modi
// 3 crear
// 4 elim     

$acce=[];

$acce['codi']=0;
$acce['prec']=0;
$acce['cupo']=0;


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 docu,numero, ';
     $sql_acce.='case when docum="COST" and info=1 then 1 else 0 end as cost, ';
     $sql_acce.='case when docum="PREC" and info=1 then 1 else 0 end as prec, ';
     $sql_acce.='status ';
     $sql_acce.='from acce1 left join acce2 on idnum1=idnum2 ';
     $sql_acce.='where numero='.$user_codigo.' ';
     $sql_acce.='group by idnum1';
     $res_acce=msql_query($sql_acce,$link_data);
     if(empty(msql_result($res_acce,0,'cost'))){$acce['cost']=0;}
     if(empty(msql_result($res_acce,0,'prec'))){$acce['prec']=0;}
}


if(mb_stristr2('sist.supe',$user0['user_tipo']))
{foreach($acce as $key => $value){$acce[$key]=1;}}


// var_dump2($user0);
// var_dump2($acce);


if(empty($codigo) and !empty($descri))
{
     $sql_descri='select * from '.$modu.'0 where trim('.$modu.'_descri) = "'.trim($descri).'" order by '.$modu.'_idate desc limit 1';
     $res_descri=msql_query($sql_descri,$link_data);
     $codigo=msql_result($res_descri,0,$modu.'_codigo');
//      echo '*/*/*/*'.$sql_descri;
//      echo '*/*/*/*'.$codigo;
} 


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

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

echo $dom->saveXML();


// echo '*/*/*/'.$modu;
$codi0=data_maes($modu,$codigo);
$enti0=data_maes('enti',$enti);
$item0=data_maes('item',$item);
$ctas0=data_maes('ctas',$ctas);
$lsub0=data_maes('lsub',$lsub);
$ptov0=data_maes('ptov',$ptov);
// $csub0=data_maes('csub',$csub);
$lote0=data_maes('lote',$lote);

$codi_descri=$codi0[$modu.'_descri'];
// $acce['prec']=0;


$modu=strtolower($modu);
$info='mt'.$modu;

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

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

if(!empty($modu)){$xtitle=strtoupper($modu);}
if(!empty($modu)){$xtopcenter=strtoupper($modu_descri).' (Registro)';}
$xtitle.=' /'.$modu_descri.' /Reg.';

if(!empty($codigo))
{$xtitle=strtoupper($modu).' /'.$codigo.' -'.$codi_descri; }



if(!mb_stristr2('sist.supe.admi.oper',$user0['user_tipo']) and mb_stristr2('user.usrt.adrs',$modu))
{
     $enti=$user0['user_enti'];
     $iuser=$user0['user_codigo'];
}

if(!mb_stristr2('sist.supe.admi.oper',$user0['user_tipo']) and mb_stristr2('user.usrt',$modu))
{
     $info='';
}

if(empty($codigo) and mb_stristr2('user.usrt',$modu))
{
     $codigo=$user0['user_codigo'];
     $info='';
}


if(empty($format)){$format=1;}


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

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

// $codi0=data_maes($modu,$codigo);
// $enti0=data_maes('enti',$enti);
// $item0=data_maes('item',$item);
// $ctas0=data_maes('ctas',$ctas);
// $lsub0=data_maes('lsub',$lsub);
// $ptov0=data_maes('ptov',$ptov);
// // $csub0=data_maes('csub',$csub);
// $lote0=data_maes('lote',$lote);


// $sql_tbod='select distinct ptov_tipo from ptov0 where ptov_status not in("I","X") and ptov_tipo!="" and ptov_tipo is not null';
// $res_tbod=msql_query($sql_tbod,$link_data);
// if(msql_num_rows($res_tbod)>1){$tbod_ok=1;}

$sql_imgi='select * from item0 left join imgi0 on item_codigo=imgi_item where ifnull(item_status,"-") not in ("I","X") and ifnull(imgi_status,"-") not in("I","X") limit 1';
$res_imgi=msql_query($sql_imgi,$link_data);
if(msql_num_rows($res_imgi)!=0){$imgi_ok=1;}

$sql_mrca='select * from mrca0 where ifnull(mrca_status,"-") not in("I","X") limit 1';
$res_mrca=msql_query($sql_mrca,$link_data);
if(msql_num_rows($res_mrca)!=0){$mrca_ok=1;}

if($empr0['empr_farmacia']==1)
{
// $sql_rgsn='select * from rgsn0 where ifnull(rgsn_status,"-") not in("I","X") limit 1';
// $res_rgsn=msql_query($sql_rgsn,$link_data);
// if(msql_num_rows($res_rgsn)!=0){$rgsn_ok=1;}
$rgsn_ok=rgsn_ok();     
}

  

// echo '<br>*/*/*/*'.$docu0['docu_codigo'];
// echo '<br>*/*/*/*'.$docu0['docu_descri'];
// echo '<br>*/*/*/*'.$docu0['docu_tabla'];

// $maes=strtolower($maes);



$modu=strtolower($modu);
$tabla=$docu0['docu_tabla'];
$tabla0=$tabla.'0';


// echo '===.'.$codigo;
if(!empty($codigo))
{
     $codigoo=$codigo;
     $maes0=data_maes($tabla,$codigo);

//      var_dump2($maes0);
     
     foreach($maes0 as $key => $value)
     {if(mb_stristr2($modu.$tabla,substr($key,0,4))){${substr($key,5)}=trim($value);}else{${$key}=trim($value);}}
     
     $codigo=$maes0[$tabla.'_codigo'];
     $codigo=$codigoo;
} 
// echo '===.'.$codigo;



//$fecha0=fecha0($modu);
$fecha0='2000-01-01';
if(empty($fecha)){$fecha=date('Y-m-d');}


$fecha_min=date('Y-m-d',strtotime('-7 days'));
if(empty($fecha1))
{$fecha1=date('Y-m-d',strtotime('-7 days'));}
if(empty($fecha2))
{$fecha2=date('Y-m-d');}

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



// echo '*/*/*/*/';
// echo sal_item2('20109837');
     
//  SELECT DB
//if(!empty($modu))
//{include('sele_info.php');}
//echo '***'.$sql_info;
if(!empty($codigo))
{
//      $info='mt'.$tabla;
//      include('sele_info.php');
}

if(!empty($sql_info))
{
     $res_info=msql_query($sql_info,$link_data);
     if(msql_num_rows($res_info)==0)
     {
     }
//      $msgres=number_format(msql_num_rows($res_info)).' Resultado(s)...';
}



// DATALIST
{
$ztabla='stat';
include('ele_datalist.php');

$zid='dl_tipo';
$ztabla=$modu;
$zcolu=$modu.'_tipo';
include('ele_datalist.php');
     
     
     $ztabla='ctas';
     include('ele_datalist.php');
     
if($tabla=='empr')
{
     $ztabla='enti';
//      $zwhere='(length(trim(enti_codigo))=10)';
     include('ele_datalist.php');
}     

     
     
if($tabla=='zsub') 
{

     $ztabla='vndd';
//      $zwhere='(vndd_codigo in(select distinct vndd from '.$modu.'1))';     
     include('ele_datalist.php');

     $ztabla='rcdd';
//      $zwhere='(rcdd_codigo in(select distinct rcdd from '.$modu.'1))';     
     include('ele_datalist.php');
}
     
     
if($tabla=='rpis')
{
     $ztabla='enti';
     $zwhere='(length(trim(enti_codigo))=10)';
     include('ele_datalist.php');
}     

if($tabla=='ctas')
{
     $ztabla='ctag';
     include('ele_datalist.php');
}     

if($tabla=='cair' or $tabla=='civa')
{
     $zid='ctas1';
     $ztabla='ctas';
     $zwhere='(ctas_codigo like "1%")';
     include('ele_datalist.php');
     
     $zid='ctas2';
     $ztabla='ctas';
     $zwhere='(ctas_codigo like "2%")';
     include('ele_datalist.php');
     
     $zid='ctas4';
     $ztabla='ctas';
     $zwhere='(ctas_codigo like "4%")';
     include('ele_datalist.php');
     
     $zid='ctas5';
     $ztabla='ctas';
     $zwhere='(ctas_codigo like "1%" or ctas_codigo like "5%"  or ctas_codigo like "6%")';
     include('ele_datalist.php');
}     

if($tabla=='caja')
{
     $ztabla='ctas';
     $zwhere='(ctas_codigo like "1%" and ctas_descri like "%CAJA%")';
     include('ele_datalist.php');
}     
     
if($tabla=='ctab')
{
     $ztabla='ctas';
     $zwhere='(ctas_codigo like "1%" and ctas_descri like "%BANCO%")';
     include('ele_datalist.php');
}     
     

if($tabla=='bode')
{
     $ztabla='ctas';
     $zwhere='(ctas_codigo like "1%" and ctas_descri like "%INVENT%")';
     include('ele_datalist.php');
}     
     

if($tabla=='nrol')
{
     $ztabla='enti';
     include('ele_datalist.php');

     $ztabla='psco';
     include('ele_datalist.php');

     
//      $a_psco=date('Y');
     $ztabla='curs';
     $zwhere='(curs_psco>='.date('Y').')';
     include('ele_datalist.php');
}
     
if($tabla=='ppdd' )
{
     $ztabla='enti';
     include('ele_datalist.php');

     if(1==2)
     if($empr0['empr_inmobil']==1)
     {
          $zid='dl_ciudad';
          $ztabla='ppdd';
          $zcolu='ppdd_ciudad';
          $zcolu2='ppdd_ciudad';
          include('ele_datalist.php');
     }
     
}     
 
if($tabla=='bbii' )
{
     $ztabla='enti';
     include('ele_datalist.php');
     
//      if($empr0['empr_inmobil']==1)
     {
          $zid='dl_ciudad';
          $ztabla='bbii';
          $zcolu='bbii_ciudad';
          $zcolu2='bbii_ciudad';
          include('ele_datalist.php');
     }
     
}     
 
     
     
if($tabla=='trty' )
{
     $zid='dl_sector';
     $ztabla='trty';
     $zcolu='trty_sector';
     $zcolu2='trty_sector';
     $zwhere='(trty_cong="'.$_SESSION['cong_codigo'].'")';
     include('ele_datalist.php');
     
}     
 
     
     
     
     
if($tabla=='enti' or $tabla=='adrs')
{
     $ztabla='enti';
     include('ele_datalist.php');
     
     $ztabla='zsub';
     include('ele_datalist.php');
     
     $ztabla='tpro';
     include('ele_datalist.php');
     
//      $zid='dl_pais';
//      $ztabla='adrs';
//      $zcolu='adrs_pais';
//      include('ele_datalist.php');
     
     $zid='dl_provincia';
     $ztabla='adrs';
     $zcolu='adrs_provincia';
     include('ele_datalist.php');
     
     $zid='dl_ciudad';
     $ztabla='adrs';
     $zcolu='adrs_ciudad';
     include('ele_datalist.php');
     
}
     
if($tabla=='adrs')
{
}

if($modu=='ppdd')
{
     $zid='dl_calle2';
     $ztabla=$modu;
//      $zwhere='(ppdd_codigo like "99%" and length(trim(ppdd_ape1))<=5)';
//      $zcolu=$modu.'_ape1';
     include('ele_datalist.php');
}
     
     
if($modu=='pcnt' and $empr0['empr_veterinaria']==1)
{
     $zid='dl_especie';
     $ztabla='enti';
     $zcolu='enti_especie';
     include('ele_datalist.php');
     
     $zid='dl_raza';
     $ztabla='enti';
     $zcolu='enti_raza';
     include('ele_datalist.php');
     
     $zid='dl_color';
     $ztabla='enti';
     $zcolu='enti_color';
     include('ele_datalist.php');
}
     
if(mb_stristr2('item.iinv.ivta.igas.lote.seri',$tabla))
{
     $ztabla='item';
     $zwhere='(item_codigo in (select item from inve1 left join inve2 on idnum1=idnum2 where docu like "IB%"))';
     
     if($tabla=='lote')
     {$zwhere='(item_codigo in (select item from inve1 left join inve2 on idnum1=idnum2 where docu like "IB%"))';}
     
     if($tabla=='seri')
     {$zwhere='(item_codigo in (select item from inve1 left join inve2 on idnum1=idnum2 where docu like "IB%"))';}
     
     include('ele_datalist.php');
}
     

//           echo '<br>TIME A.1 = '.date('H:i:s');

     
// if($tabla=='item')
if(mb_stristr2('item.iinv.ibod.ivta.igas',$tabla))
{
     $sql_updt='update item0, mrca0 set item_marca=mrca_descri where item_mrca=mrca_codigo';
     $res_updt=msql_query($sql_updt,$link_data);
     
     $ztabla='lsub';
     include('ele_datalist.php');

     $ztabla='mrca';
     include('ele_datalist.php');

     $ztabla='umdd';
     include('ele_datalist.php');
     
     $zid='dl_marca';
     $ztabla='item';
     $zcolu='item_marca';
     include('ele_datalist.php');

     $zid='dl_iva';
     $ztabla='item';
     $zcolu='item_iva';
     include('ele_datalist.php');
     
     
//      $ztabla='lote';
//      include('ele_datalist.php');


     if($rgsn_ok>0)
     if($empr0['empr_farmacia']==1)
     {
          $ztabla='rgsn';
          include('ele_datalist.php');
     }
     
     
}     

               // echo '<br>TIME A.2 = '.date('H:i:s');

if($tabla=='mtch')
{
//      $sql_updt='update item0, mrca0 set item_marca=mrca_descri where item_mrca=mrca_codigo';
//      $res_updt=msql_query($sql_updt,$link_data);
     
     $ztabla='team';
     include('ele_datalist.php');
     
     $ztabla='liga';
     include('ele_datalist.php');

     $ztabla='torn';
     include('ele_datalist.php');

}     

     
     
if(!empty($modu))
{
$ztabla=$modu;
include('ele_datalist.php');
}


if(mb_stristr2('enti.clie.prov.adrs.mdvh.vinn.plvh.item',$tabla))
{
     $ztabla='pais';
     include('ele_datalist.php');
}
     
     
     
}

          // echo '<br>TIME A.99 = '.date('H:i:s');


if(!empty($codigo))
{include('sele_info.php');}
elseif(!empty($grupo))
{include('sele_info.php');}
elseif($modu=='seri' and !empty($item))
{include('sele_info.php');}
// echo '*/*/*'.$sql_info;

if(!empty($sql_info))
{
     $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.=$date1.$date2;
//      echo '<br>*/*/'.$msgres;
}




// PANTALLA FILTROS
echo '<div id="filtros" noprint >';
{
// OCULTOS
// echo '<input id="format" hide value="'.$format.'">';
     
$zobj=2;     
include('ele_break.php');

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

$zid='btn_nuevo'; 
$zlabel='Nuevo';
$zalign='right';
$zonclick='{fn_nuevo();}';
$zsize=1.2;     
include('ele_button.php');
     
     
     
// echo '<br>';
// echo '<br>*/*/*/*'.$docu0['docu_codigo'];
// echo '<br>*/*/*/*'.$docu0['docu_descri'];
// echo '<br>*/*/*/*'.$docu0['docu_tabla'];
// echo '<br>*/*/*/*'.$tabla;
// echo '<br>*/*/*/*'.$codigo;
     
     
     
     $zid='codigo';
     $ztabla=$tabla;
     $ztabla=$docu0['docu_tabla'];
     $zlabel='Código';
     $zvalue=$codigo; 
     $zonblur='{fn_consulta();}';
     
     $zondblclick='{document.getElementById("codigo").removeAttribute("disabled");}';     
     $zreado=2;
     if($modu=='user'){if(!mb_stristr2('sist.supe',$user0['user_tipo'])){$zreado=1;}}
     if(mb_stristr2('.enti.item.user.usrt',$tabla)){$zplace='AUTOMATICO';$zreado=1;}
     if($zreado==1){$zondblclick='';}
     
     include('ele_input.php');
     
     

     $zid='status';
     $ztabla='stat';
     $zlabel='Status';
     $zvalue=$status; 
     $zalign='right';
     $zoptions='-,Nuevo;A,Activo;I,Inactivo;';
     $zexact=1;
     include('ele_select.php');
     
     $zid='tipo';
     $zlabel='Tipo';
     $zvalue=$tipo; 
     $zalign='right';
     $zwidth=6;
     $zlist='dl_tipo';
     $zreado=1;
     if(mb_stristr2('sist.supe',$user0['user_tipo']))
     {$zreado=2;}
     if(empty($tipo)){$zreado=2;}
     $zexact=1;
     if($modu=='empr')
     {$zoptions='pyme,PYME;pnat,P.Natural;cele,Comp.Elect.;vari,Varios;';}
     if($modu=='caja')
     {$zoptions='RCDD,Recaudación;PAGO,Pagos;CHQU,Cheques;';}
     if($modu=='ctab')
     {$zoptions='CAHO,Ahorros;CCTE,Corriente;TCRE,Tarjeta Crédito;';}
//      if($modu=='user')
//      {$zlist='dl_tipo';}
     if(empty($zoptions)){include('ele_input.php');}
     if(!empty($zoptions)){include('ele_select.php');}
     
     
//      $zid='tipo';
//      $zlabel='Tipo';
//      $zvalue=$tipo; 
//      $zalign='right';
// //      $zwidth=4;
// //      $zlist='dl_tipo';
//      $ztabla=$modu;
//      $zcolu2=$modu.'_tipo';
     
//      include('ele_select.php');
     
     
     
     
}

     

     $zobj=2;     
     include('ele_break.php');
     
$zid='btn_grabar'; 
$zlabel='Grabar';
$zalign='right';
$zonclick='{save_maes(event);}';
if($modu=='empr')     
{$zonclick='{if(document.getElementById("p12file").value!==""){document.getElementById("p12file_btn2").onclick();} save_maes(event);}';}
// {$zonclick='async function savem{if(document.getElementById("p12file").value!==""){await document.getElementById("p12file_btn2").onclick();} save_maes(event);}';}
$zsize=1.5;
$zalign='right';     
// if(!empty($codigo) and empty($edit)){$zhide=1;}       
include('ele_button.php');

$getplat=getPlatform();
if($getplat=='Android')
{
     $zobj=1;     
     include('ele_break.php');
}

     
$sql_stru='describe '.$tabla0;
$res_stru=msql_query($sql_stru,$link_data);

$codi_type=msql_result($res_stru,0,'Type');
     
// echo '<br>===='.$codi_type;     
if($codi_type=='char(2)' or $codi_type=='char(4)' or $codi_type=='char(6)' or $codi_type=='char(8)'  or $codi_type=='char(9)' )
{$descri_ok=1;}

if(substr($codi_type,0,3)=='int'){$descri_ok=1;}     

     
if(mb_stristr2('.psco.curs',$modu))
{
     $zid='descri';
     $zlabel='Nombre';
     $zvalue=$descri;
     $zwidth=25;
     include('ele_input.php');
     
     if(mb_stristr2('.curs',$modu))
     {
          $zobj=1;     
          include('ele_break.php');
          
          $zid='psco';
          $zlabel='Período';
          $zvalue=$psco;
          $ztabla='psco';
          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');
     }
     
     
     $zobj=1;     
     include('ele_break.php');
}


if(mb_stristr2('.nrol',$modu))
{
     
//      $zobj=1;     
//      include('ele_break.php');

     $zid='enti';
     $zlabel='Estudiante';
     $zvalue=$enti;
     $ztabla='enti';
//      $zwidth=25;
     include('ele_input.php');
   
//      $zid='psco';
//      $zlabel='Período';
//      $zvalue=$psco;
//      $ztabla='psco';
// //      $zwidth=25;
//      include('ele_input.php');
   
     
//      if(mb_stristr2('.curs',$modu))
     {
//      $zobj=1;     
//      include('ele_break.php');
          
     $zid='curs';
     $zlabel='Curso';
     $zvalue=$curs;
     $ztabla='curs';
     $zwidth=3;
     include('ele_input.php');
          
//      $zid='seccion';
//      $zlabel='Sección';
//      $zvalue=$seccion;
//      $zwidth=2;
//      include('ele_input.php');
     }
     
     
     $zobj=1;     
     include('ele_break.php');
}

     
if(mb_stristr2('.empr',$modu))
{
     $zid='ruc';
     $zlabel='RUC';
     $ztabla='enti';
     $zexact=1;
     $zvalue=$ruc;
     if(!empty($ruc))
     {$zreado=2;}
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');


     $zid='descri';
     $zlabel='Nombre';
     $zvalue=$descri;
     $zwidth=25;
     include('ele_input.php');

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

     
     
}

     
     
if(mb_stristr2('.rpis',$modu))
{
     $zid='fecha';
     $zlabel='Fecha';
     $zvalue=$fecha;
     $zmin=date('Y-m-d',strtotime('-8 month'));
//      $zmax=date('Y-m-d');
     $ztype='date';
     include('ele_input.php');
     
     $zid='cedula';
     $zlabel='Cédula';
     $zvalue=$cedula;
     $ztabla='enti';
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');
     
}     
     

if(mb_stristr2('.ppdd',$modu))
{
     $zid='calle2';
     $zlabel='Mz.';
     if($_SESSION['empr_edificio']==1){$zlabel='Piso';}
     $zlist='dl_calle2';
     $zvalue=$calle2;
     $zwidth=5;
     include('ele_input.php');
     
     $zid='callen';
     $zlabel='Villa';
     if($_SESSION['empr_edificio']==1){$zlabel='Dpto.';}
     $zvalue=$callen;
     $zclass='numeric-int';
     $zmin=1;
     $zmax=9999;
     include('ele_input.php');

     if($user0['user_tipo']=='sist')
     {
          $zid='calle2h';
          $zlabel='Hasta Piso/MZ ';
          $zvalue=0;
          $zclass='numeric-int';
          $zmin=0;
          $zmax=999;
          include('ele_input.php');
          
          $zid='callenh';
          $zlabel='Hasta Dep/Villa';
          $zvalue=0;
          $zclass='numeric-int';
          $zmin=0;
          $zmax=999;
          include('ele_input.php');
     }

     
     $zobj=2;
     $zsize=1;
     include('ele_break.php');
     
     
     $zobj=4;
     $zid='pptario1';
     $zlabel='Propietario 1';
     $zvalue=$pptario1;
     $ztabla='enti';     
     include('ele_input.php');

     $zobj=4;
     $zid='wsapp1';
     $zlabel='WsApp';
     $zvalue=$wsapp1;
     $ztype='number';
     include('ele_input.php');
     
     
     $zobj=4;
     $zid='pptario2';
     $zlabel='Propietario 2';
     $zvalue=$pptario2;
     $ztabla='enti';     
     include('ele_input.php');
     
     $zobj=4;
     $zid='wsapp2';
     $zlabel='WsApp';
     $zvalue=$wsapp2;
     $ztype='number';
     include('ele_input.php');

     $zobj=2;
     $zsize=1;
     include('ele_break.php');
     
     
     $zobj=4;
     $zid='rsdente1';
     $zlabel='Residente 1';
     $zvalue=$rsdente1;
     $ztabla='enti';     
     include('ele_input.php');

     $zobj=4;
     $zid='wsappr1';
     $zlabel='WsApp';
     $zvalue=$wsappr1;
     $ztype='number';
     include('ele_input.php');
     
//      $zobj=2;
//      $zsize=1;
//      include('ele_break.php');
     
     $zobj=4;
     $zid='rsdente2';
     $zlabel='Residente 2';
     $zvalue=$rsdente2;
     $ztabla='enti';     
     include('ele_input.php');
     
     $zobj=4;
     $zid='wsappr2';
     $zlabel='WsApp';
     $zvalue=$wsappr2;
     $ztype='number';
     include('ele_input.php');
     
     
     $zobj=2;
     $zsize=1;
     include('ele_break.php');
     
     // echo '<br>TIME B = '.date('H:i:s');
     
     $zid='factura';
     $zlabel='Facturar';
     $zvalue=$factura;
     $ztabla='enti';     
     include('ele_input.php');
     
     
     
     $zobj=1;
     include('ele_break.php');
     
     $zid='alicuota';
     $zlabel='Alicuota';
     $zvalue=0;
     $zclass='numeric-int';
     $zmin=5;
     $zmax=9999;
     include('ele_input.php');

     
     
     

     
     
     
}
     

     
     
if(mb_stristr2('.bbii',$modu))
{
//      $zid='calle2';
//      $zlabel='Mz.';
//      if($_SESSION['empr_edificio']==1){$zlabel='Piso';}
//      $zlist='dl_calle2';
//      $zvalue=$calle2;
//      $zwidth=5;
//      include('ele_input.php');
     
//      $zid='callen';
//      $zlabel='Villa';
//      if($_SESSION['empr_edificio']==1){$zlabel='Dpto.';}
//      $zvalue=$callen;
//      $zclass='numeric-int';
//      $zmin=1;
//      $zmax=9999;
//      include('ele_input.php');

//      if($user0['user_tipo']=='sist')
//      {
//           $zid='calle2h';
//           $zlabel='Hasta Piso/MZ ';
//           $zvalue=0;
//           $zclass='numeric-int';
//           $zmin=0;
//           $zmax=999;
//           include('ele_input.php');
          
//           $zid='callenh';
//           $zlabel='Hasta Dep/Villa';
//           $zvalue=0;
//           $zclass='numeric-int';
//           $zmin=0;
//           $zmax=999;
//           include('ele_input.php');
//      }

     
//      $zobj=2;
//      $zsize=1;
//      include('ele_break.php');
     
     
//      $zobj=4;
     $zid='pptario';
     $zlabel='Propietario';
     $zvalue=$pptario;
     $ztabla='enti';     
     include('ele_input.php');

//      $zobj=4;
     $zid='wsapp';
     $zlabel='WsApp';
     $zvalue=$wsapp;
     $ztype='number';
     include('ele_input.php');
     
     
//      $zobj=4;
//      $zid='pptario2';
//      $zlabel='Propietario 2';
//      $zvalue=$pptario2;
//      $ztabla='enti';     
//      include('ele_input.php');
     
//      $zobj=4;
//      $zid='wsapp2';
//      $zlabel='WsApp';
//      $zvalue=$wsapp2;
//      $ztype='number';
//      include('ele_input.php');

//      $zobj=2;
//      $zsize=1;
//      include('ele_break.php');
     
     
//      $zobj=4;
//      $zid='rsdente1';
//      $zlabel='Residente 1';
//      $zvalue=$rsdente1;
//      $ztabla='enti';     
//      include('ele_input.php');

//      $zobj=4;
//      $zid='wsappr1';
//      $zlabel='WsApp';
//      $zvalue=$wsappr1;
//      $ztype='number';
//      include('ele_input.php');
     
//      $zobj=2;
//      $zsize=1;
//      include('ele_break.php');
     
//      $zobj=4;
//      $zid='rsdente2';
//      $zlabel='Residente 2';
//      $zvalue=$rsdente2;
//      $ztabla='enti';     
//      include('ele_input.php');
     
//      $zobj=4;
//      $zid='wsappr2';
//      $zlabel='WsApp';
//      $zvalue=$wsappr2;
//      $ztype='number';
//      include('ele_input.php');
     
     
//      $zobj=2;
//      $zsize=1;
//      include('ele_break.php');
     
     
     
//      $zid='factura';
//      $zlabel='Facturar';
//      $zvalue=$factura;
//      $ztabla='enti';     
//      include('ele_input.php');
     
     
     
//      $zobj=1;
//      include('ele_break.php');
     
//      $zid='alicuota';
//      $zlabel='Alicuota';
//      $zvalue=0;
//      $zclass='numeric-int';
//      $zmin=5;
//      $zmax=9999;
//      include('ele_input.php');

     
     
     

     
     
     
}
     
     
     
     

// if(mb_stristr2('.lsub.csub.stat.ptov.ptoe',$modu))
if($descri_ok==1 or mb_stristr2('.stat',$modu))
{
     $zid='descri';
     $zlabel='Descripción';
     $zvalue=$descri;
     $zwidth=40;
     $zrows=2;
     include('ele_input.php');
}

if(mb_stristr2('.docu',$modu))
{
     $zobj=1;     
     include('ele_break.php');
     
     $zid='contcabe';
     $zlabel='Contab.Cabecera';
     $zvalue=$contcabe;
     $zoptions.='R,Resumido;D,Detallado;';
     include('ele_options.php');
     
     $zobj=1;     
     include('ele_break.php');
     
     $zid='contdeta';
     $zlabel='Contab.Detalle';
     $zvalue=$contdeta;
     $zoptions.='R,Resumido;D,Detallado;';
     include('ele_options.php');
     
}     
     
     
     
     
if(mb_stristr2('.lsub',$modu))
{
   
     $zobj=1;     
     include('ele_break.php');
     $zid='ctainve';
     $zlabel='Cta. Invent.';
     $zvalue=$ctainve;
     $ztabla='ctas';
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');
     
     $zid='ctavtas';
     $zlabel='Cta. Ventas';
     $zvalue=$ctavtas;
     $ztabla='ctas';
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');
     
     $zid='ctacvta';
     $zlabel='Cta. Cost.V.';
     $zvalue=$ctacvta;
     $ztabla='ctas';
     include('ele_input.php');
     
     
     
}

if(mb_stristr2('.lote',$modu))
{
     $zid='fabric';
     $zlabel='Fec.Fabrica';
     $zvalue=$fabric;
     $zmin=date('Y-m-01',strtotime('-12 month'));
     $zmax=date('Y-m-d',strtotime('+1 week'));
     $ztype='date';
     include('ele_input.php');
     
     $zid='caduca';
     $zlabel='Fec.Caduca';
     $zvalue=$caduca;
     $zmin=date('Y-m-d',strtotime('0 days'));
     $zmax=date('Y-m-j',strtotime('+3650 days'));
     $ztype='date';
     include('ele_input.php');
}

if(mb_stristr2('.cong',$modu))
{
     $zid='sala';
     $zlabel='Salas Auxiliares';
     $zvalue=$sala;
     $zmin=0;
     $zmax=2;
     $zclass='numeric-int';
     include('ele_input.php');
     
     $zid='reu1';
     $zlabel='Reunión 1';
     $zvalue=$reu1;
     $zdia=5;
     include('ele_options.php');
     
     $zid='reu2';
     $zlabel='Reunión 2';
     $zvalue=$reu2;
     $zdia=2;
     include('ele_options.php');
     
}

if(mb_stristr2('.lreu',$modu))
{
     $zid='cong';
     $zlabel='Congregación';
     $zvalue=$cong;
     $ztabla='cong';
     $zreado=1;
     $zhide=1;
     include('ele_input.php');

     $zobj=1;     
     include('ele_break.php');
     
     $zid='direccion';
     $zlabel='Dirección';
     $zvalue=$direccion;
     $zwidth=40;
     include('ele_input.php');

     
}

if(mb_stristr2('.trty',$modu))
{
     $zid='cong';
     $zlabel='Congregación';
     $zvalue=$cong;
     $ztabla='cong';
     $zreado=1;
     $zhide=1;
     include('ele_input.php');

     $zobj=1;     
     include('ele_break.php');
     
     $zid='grupo';
     $zlabel='# Grupo';
     $zvalue=$grupo;
     $zmin=0;
     $zmax=10;
     $zclass='numeric-int';
     include('ele_input.php');

     
     $zid='sector';
     $zlabel='Sector';
     $zvalue=$sector;
     $zwidth=10;
     $zmaxlen=10;
     $zlist='dl_sector';
     include('ele_input.php');

     
     
     $zid='numero';
     $zlabel='# Territorio';
     $zvalue=$numero;
     $zmin=0;
     $zmax=99;
     $zclass='numeric-int';
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');
     
     
     $zid='bloques';
     $zlabel='Mz.Bloq.';
     $zvalue=$bloques;
     $zwidth=15;
     include('ele_input.php');


     
     
     $zid='referencia';
     $zlabel='Referencia';
     $zvalue=$referencia;
     $ztxt=2;
     $zwidth=15;
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');
     
     
     
     
     $zid='color';
     $zlabel='Color';
     $zvalue=$color;
//      $zlist='dl_color';
     $ztype='color';
     $zdefa="#FFFFFF";
     include('ele_input.php');
     
     
//      $zobj=1;     
//      include('ele_break.php');
     
//      $zid='imgtfile';
//      $zlabel='Mapa';
//      $zvalue=$imgt;
//      $ztype='file';
//      $zaccept='.png, .jpg, .jpeg';
//      $zonclick2="upld_image('imgt',document.getElementById('codigo').value,'imgtfile')";
//      $zlabel2='';
//      include('ele_input.php');
     
     
     
}
     

if($modu=='user')
{
//           $zid='caduca';
//           $zlabel='Caduca';
//           $zvalue=$caduca;
//           $zmin=date('Y-m-d',strtotime('-1 day'));
//           $zmax=date('Y-m-d',strtotime('+24 month'));
//           $zdefa=$zmin;
//           $ztype='date';
//           include('ele_input.php');
     
}

     
if($modu=='empr')
{
          $zsize=2;
          include('ele_break.php');
          
          $zid='ruclegal';
          $zlabel='Rep.Legal';
          $zvalue=$ruclegal;
          $ztabla='enti';
          include('ele_input.php');

          $zsize=2;
          include('ele_break.php');
          
          $zid='rucconta';
          $zlabel='🧑‍💼 RUC Contador';
          $zvalue=$rucconta;
          $ztabla='enti';
          include('ele_input.php');

          $zsize=2;
          include('ele_break.php');
          
          $zid='regconta';
          $zlabel='Reg.Contador';
          $zvalue=$regconta;
          $zclass='numeric-int';
          include('ele_input.php');

          $zsize=2;
          include('ele_break.php');
          
          $zid='sriiva';
          $zlabel='I.V.A.';
          $zvalue=$empr0['empr_sriiva'];
//           $zexact=1;
//           $zoptions='1,Mensual;3,Trimestral;6,Semestral;';
          $zoptions='0,N/A;1,Mensual;3,Trimestral;6,Semestral;';
          include('ele_options.php');

          $zid='sriats';
          $zlabel='A.T.S.';
          $zvalue=$empr0['empr_sriats'];
          $zoptions='0,N/A;1,Mensual;3,Trimestral;6,Semestral;';
          include('ele_options.php');

          $zid='defa332';
          $zlabel='Defa332';
          $zvalue=$empr0['empr_defa332'];
          $zoptions='0,NO;1,SI;';
          include('ele_options.php');

          
     $zid='rimpe';
     $zlabel='Régimen';
     $zvalue=$rimpe;
     $zoptions='0,N/A;1,Emprendedor;2,Negocio Popular;3,General';
     include('ele_options.php');
          
          $zsize=2;
          include('ele_break.php');

     
//      if(1==2)
     {
          
     $emti0=data_maes('enti',$empr0['empr_ruc']);
          
     $zid='rimpe0';
     $zlabel='Régimen';
     $zvalue=$emti0['enti_rimpe'];
     $zoptions='0,N/A;1,Emprendedor;2,Negocio Popular;3,General';
     $zsave=1;     
     $zsavet='enti';     
     $zsavef='rimpe';     
     $zsavec=$emti0['enti_codigo'];     
     include('ele_options.php');
          
          
     $zid='obcon0';
     $zlabel='Obli.Contab.';
     $zvalue=$emti0['enti_obcon'];
     $zoptions='0,NO;1,SI;';
     $zsave=1;     
     $zsavet='enti';     
     $zsavef='obcon';     
     $zsavec=$emti0['enti_codigo'];     
     include('ele_options.php');
          
     $zid='agret0';
     $zlabel='Ag.Reten.';
     $zvalue=$emti0['enti_agret'];
     $zoptions='0,NO;1,SI;';
     $zsave=1;     
     $zsavet='enti';     
     $zsavef='agret';     
     $zsavec=$emti0['enti_codigo'];     
     include('ele_options.php');
          
          
     $zid='coesp0';
     $zlabel='C.Especial';
     if(strlen($codigo)==10){$zvalue=0;$zreado=1;}
     $zvalue=$emti0['enti_coesp'];
     $zoptions='0,NO;1,SI;';
     $zsave=1;     
     $zsavet='enti';     
     $zsavef='coesp';     
     $zsavec=$emti0['enti_codigo'];     
     include('ele_options.php');

     }
     
          $zsize=2;
          include('ele_break.php');

     
     
          if(empty($color1)){$color1='#000000';}
          if(empty($color2)){$color2='#FFFFFF';}
     
          $zid='color1x';
          $zlabel='Color 1';
          $zvalue=$color1;
          $ztype='color';
          include('ele_input.php');
          
          $zid='color2x';
          $zlabel='Color 2';
          $zvalue=$color2;
//           $zdefa='gray';
          $ztype='color';
          include('ele_input.php');
          
          $zsize=2;
          include('ele_break.php');
          
          $zid='p12file';
          $zlabel='🖊️ Firma P12';
          $zvalue=$p12file;
          $ztype='file';
          $zaccept='.p12';
          $zonclick2="upld_pk12('pk12',document.getElementById('ruc').value,'p12file',document.getElementById('p12pass').value)";
          $zlabel2='';
          include('ele_input.php');
     
     
          
          $zid='p12pass';
          $zlabel='🔑 Clave P12';
          $zvalue=$p12pass;
          $zwidth=20;
          $ztype='pass';
          include('ele_input.php');
     
     

//           $zobj=3;
          $zid='p12caduca';
          $zlabel='Caduca P12';
          $zvalue=$p12caduca;
          $zmin=date('Y-m-d',strtotime('+1 day'));
          $zmax=date('Y-m-d',strtotime('+60 month'));
          $zdefa=$zmin;
          $ztype='date';
          $zreado=1;
          if(date('Y-m-d')>=date('Y-m-d',strtotime($p12caduca.'-1 month')))
          {$zbackcolor='gold';}
          if(date('Y-m-d')>=date('Y-m-d',strtotime($p12caduca.'-1 week')))
          {$zbackcolor='orange';}
          if(date('Y-m-d')>=date('Y-m-d',strtotime($p12caduca)))
          {$zbackcolor='darkred'; $zfontcolor='white';}
     
          include('ele_input.php');
     
     
}
     
     
if($user0['user_tipo']=='sist' and $modu=='empr')
{
     $zobj=3;     
     include('ele_break.php');
     
     $zid='pyme';
     $zlabel='Ventas & Compras';
     $zvalue=$pyme;
     $zvalue=1;
     $ztype='check';
     $zhide=1;
     include('ele_input.php');
     
     $zid='vtas';
     $zlabel='Ventas';
     $zvalue=$vtas;
     $ztype='check';
     include('ele_input.php');
     
     $zid='comp';
     $zlabel='Compras';
     $zvalue=$comp;
     $ztype='check';
     include('ele_input.php');

     
     
     $zid='caja';
     $zlabel='Caja';
     $zvalue=$caja;
     $ztype='check';
     include('ele_input.php');
     
     $zid='bcos';
     $zlabel='Bancos';
     $zvalue=$bcos;
     $ztype='check';
     include('ele_input.php');
     
     $zid='rete';
     $zlabel='Retenciones';
     $zvalue=$rete;
     $ztype='check';
     include('ele_input.php');

     
     $zid='inve';
     $zlabel='Inventario';
     $zvalue=$inve;
     $ztype='check';
     include('ele_input.php');
     
     
     
     $zid='cont';
     $zlabel='Contabilidad';
     $zvalue=$cont;
     $ztype='check';
     include('ele_input.php');
     
     
     
     $zobj=3;     
     include('ele_break.php');

     
     $zid='cxco';
     $zlabel='CXCob.';
     $zvalue=$cxco;
     $ztype='check';
     include('ele_input.php');
     
     $zid='cxpa';
     $zlabel='CXPag.';
     $zvalue=$cxpa;
     $ztype='check';
     include('ele_input.php');
     
     
     
     $zid='clie';
     $zlabel='Clientes';
     $zvalue=$clie;
     $ztype='check';
     include('ele_input.php');
     
     $zid='prov';
     $zlabel='Proveedores';
     $zvalue=$prov;
     $ztype='check';
     include('ele_input.php');
     

     $zid='guia';
     $zlabel='Guías Rem.';
     $zvalue=$guia;
     $ztype='check';
     include('ele_input.php');
     
     

     
     $zid='ctlg';
     $zlabel='Catálogo';
     $zvalue=$ctlg;
     $ztype='check';
     include('ele_input.php');
     
     $zid='carr';
     $zlabel='Carrito';
     $zvalue=$carr;
     $ztype='check';
     include('ele_input.php');
     
     
     
     $zsize=2;
     include('ele_break.php');

     
     $zid='nomi';
     $zlabel='Nómina';
     $zvalue=$nomi;
     $ztype='check';
     include('ele_input.php');

     
     $zid='prod';
     $zlabel='Producción';
     $zvalue=$prod;
     $ztype='check';
     include('ele_input.php');
     
     

     $zid='impo';
     $zlabel='Importador';
     $zvalue=$impo;
     $ztype='check';
     include('ele_input.php');

     $zid='expo';
     $zlabel='Exportador';
     $zvalue=$expo;
     $ztype='check';
     include('ele_input.php');
     
     
     
     $zsize=2;
     include('ele_break.php');

     
//      $zid='clie';
//      $zlabel='Pedidos & Ordenes';
//      $zvalue=$clie;
//      $ztype='check';
// //      $zhide=1;
//      include('ele_input.php');
     
//      $zid='prod';
//      $zlabel='Producción';
//      $zvalue=$prod;
//      $ztype='check';
//      include('ele_input.php');
     
     
     
     

     $zid='bitacora';
     $zlabel='Bitácora';
     $zvalue=$bitacora;
     $ztype='check';
     include('ele_input.php');

//      $zid='edificio';
//      $zlabel='Edificio';
//      $zvalue=$edificio;
//      $ztype='check';
//      include('ele_input.php');

//      $zid='ciudadela';
//      $zlabel='Ciudadela';
//      $zvalue=$ciudadela;
//      $ztype='check';
//      include('ele_input.php');

     
     $zid='taxi';
     $zlabel='Taxi';
     $zvalue=$taxi;
     $ztype='check';
     include('ele_input.php');

     
     
     
     $zid='proyectos';
     $zlabel='Proyectos';
     $zvalue=$proyectos;
     $ztype='check';
     include('ele_input.php');

     $zid='refers';
     $zlabel='Referidos';
     $zvalue=$refers;
     $ztype='check';
     include('ele_input.php');

//      $zid='bitacora';
//      $zlabel='Bitácora';
//      $zvalue=$bitacora;
//      $ztype='check';
//      include('ele_input.php');
     $zid='inmobil';
     $zlabel='Inmobiliaria';
     $zvalue=$inmobil;
     $ztype='check';
     include('ele_input.php');



     $zsize=2;
     include('ele_break.php');
     
     $zid='medico';
     $zlabel='Médico';
     $zvalue=$medico;
     $ztype='check';
     include('ele_input.php');

     $zid='farmacia';
     $zlabel='Farmacia';
     $zvalue=$farmacia;
     $ztype='check';
     include('ele_input.php');

     $zid='clinica';
     $zlabel='Clínica';
     $zvalue=$clinica;
     $ztype='check';
     include('ele_input.php');

     $zid='veterinaria';
     $zlabel='Veterinaria';
     $zvalue=$veterinaria;
     $ztype='check';
     include('ele_input.php');

     $zid='restaurant';
     $zlabel='Restaurante';
     $zvalue=$restaurant;
     $ztype='check';
     include('ele_input.php');

     $zsize=2;
     include('ele_break.php');
     
     $zid='taller';
     $zlabel='Taller';
     $zvalue=$taller;
     $ztype='check';
     include('ele_input.php');

     $zid='automotriz';
     $zlabel='Automotriz';
     $zvalue=$automotriz;
     $ztype='check';
     include('ele_input.php');

     $zid='garage';
     $zlabel='Garage';
     $zvalue=$garage;
     $ztype='check';
     include('ele_input.php');

     $zsize=2;
     include('ele_break.php');
     
     
     
     $zid='eduk';
     $zlabel='EduK';
     $zvalue=$eduk;
     $ztype='check';
     include('ele_input.php');

     $zsize=2;
     include('ele_break.php');
     
     
     $zid='mice';
     $zlabel='CE Propios';
     $zvalue=$mice;
     $ztype='check';
     include('ele_input.php');

     
     $zid='ceuser';
     $zlabel='CE X Usuario';
     $zvalue=$ceuser;
     $ztype='check';
     include('ele_input.php');

     
     
}
     
     
if($modu=='ptoe')
{
     $zobj=1;     
     include('ele_break.php');
     
     
     $zid='ambice';
     $zlabel='Ambiente CE';
     $zvalue=$ambice;
          $zdefa=1;
          $zexact=1;
     $zoptions='1,Pruebas;2,Producción;';
     include('ele_select.php');

}
     
     
if($modu=='ptov')
{
     $zobj=1;     
     include('ele_break.php');
     
     $zid='direccion';
     $zlabel='Dirección';
     $zvalue=$direccion;
     $zwidth=40;
     include('ele_input.php');

     $zobj=1;     
     include('ele_break.php');
     
     $ztabla='ptoe';
     include('ele_datalist.php');
     
     $zid='ptoe';
     $zlabel='Pto.Emisión';
     $zvalue=$ptoe;
     $zdefa='001001';
     $ztabla='ptoe';
     include('ele_input.php');

     $ztabla='bode';
     include('ele_datalist.php');
     
     $zid='bode';
     $zlabel='Bodega';
     $zvalue=$bode;
     $zdefa='';
     $ztabla='bode';
     include('ele_input.php');

     $zobj=1;     
     include('ele_break.php');
     
     
     $zid='ambice';
     $zlabel='Ambiente CE';
     $zvalue=$ambice;
          $zdefa=1;
          $zexact=1;
     $zoptions='1,Pruebas;2,Producción;';
     include('ele_select.php');


     
     $zid='pngfile';
     $zlabel='Logo';
     $zvalue=$pngfile;
     $ztype='file';
     $zaccept='.png,.jpg,.jpeg';
     $zonclick2="upld_logo('logo','".$empr0['empr_ruc']."','pngfile','ptov',document.getElementById('codigo').value)";
     $zlabel2='';
     include('ele_input.php');

     
     
     
     
     
}     


     
if($modu=='ctab')
{
     $zobj=1;     
     include('ele_break.php');

     $ztabla='bcos';
     include('ele_datalist.php');
     
     $ztabla='ptoe';
     include('ele_datalist.php');
     
     
     $zid='ptoe';
     $zlabel='Pto.Emi';
     $zvalue=$ptoe;
     $ztabla='ptoe';
     include('ele_input.php');

     $zobj=1;     
     include('ele_break.php');
     
     
     $zid='bcos';
     $zlabel='Banco';
     $zvalue=$bcos;
     $ztabla='bcos';
     include('ele_input.php');
     
}     

     // echo '<br>TIME C = '.date('H:i:s');

if($modu=='caja' or $modu=='ctab')
{
     $zobj=1;     
     include('ele_break.php'); 
     
     $zid='ctacont';
     $zlabel='Cta.Contable';
     $zvalue=$ctacont;
     $ztabla='ctas';
     include('ele_input.php');

//      $zid='color';
//      $zlabel='Color';
//      $zvalue=$color;
//      $ztype='color';
//      include('ele_input.php');
          
     
     
     
//      $zobj=1;     
//      include('ele_break.php');
     
//      $zid='direccion';
//      $zlabel='Dirección';
//      $zvalue=$direccion;
//      $zwidth=25;    
//      $zrows=2;     
//      include('ele_input.php');
     
}     
          
if($modu=='bode')
{
     $zobj=1;     
     include('ele_break.php');
     
     $zid='ctacont';
     $zlabel='Cuenta';
     $zvalue=$ctacont;
     $ztabla='ctas';
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');
     
     $zid='direccion';
     $zlabel='Dirección';
     $zvalue=$direccion;
     $zwidth=25;    
     $zrows=2;     
     include('ele_input.php');
     
}     

if($modu=='seri')
{
     $zobj=1;     
     include('ele_break.php');
     
     $zid='item';
     $zlabel='Item';
     $zvalue=$item;
     $ztabla='item';
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');
     
     $zid='serial';
     $zlabel='Series';
     $zvalue=$serial;
     $zwidth=25;    
     $zrows=2;     
//      $zmulti=1;
     include('ele_input.php');
     
}     

     
if($modu=='zona')
{
     $zobj=1;     
     include('ele_break.php');
     
     $zid='ctaxcob';
     $zlabel='Cta.X Cobrar';
     $zvalue=$ctaxcob;
     $ztabla='ctas';
     include('ele_input.php');
     
}     
     
if($modu=='tpro')
{
     $zobj=1;     
     include('ele_break.php');
     
     $zid='ctaxpag';
     $zlabel='Cta.X Pagar';
     $zvalue=$ctaxpag;
     $ztabla='ctas';
     include('ele_input.php');
     
//      $zobj=1;     
//      include('ele_break.php');
     
//      $zid='direccion';
//      $zlabel='Dirección';
//      $zvalue=$direccion;
//      $zwidth=25;    
//      $zrows=2;     
//      include('ele_input.php');
     
}     
     
     
     
if(mb_stristr2('.ctas',$modu))
{
     $zid='grupo';
     $zlabel='Grupo';
     $zvalue=$grupo;
     if(empty($zvalue))
     {
          $zvalue=$codigo;
          if(strlen($zvalue)>=3){$zvalue=substr($zvalue,0,-2); $zreado=1;}
     }
     $zlist='dl_ctag';
     $ztabla='ctas';
     $zonblur='{location.href="?scri='.basename(__FILE__,'.php').'&modu="+document.getElementById("modu").value+"&grupo="+document.getElementById("grupo").value;}';
     $zonchange=$zonblur;
     if(!empty($codigo)){$zreado=1;}
     include('ele_input.php');

     $zid='sri101';
     $zlabel='SRI 101';
     $zvalue=$sri101;
     $zclass='numeric-int';
     $zdefa=300;
     $zmin=300;
     $zmax=700;
     if(substr($codigo,0,1)>=4)
     {
          $zdega=6000;
          $zmin=6000;
          $zmax=8000;
     }
     include('ele_input.php');
     
     
     $zobj=1;     
     include('ele_break.php');
     

     $zid='cuenta';
     $zlabel='Cuenta';
     $zvalue=$cuenta;
     if(!empty($codigo) and strlen($codigo)<=6){$zreado=1;}
     if(!empty($codigo)){$zhide=1;}
     include('ele_input.php');

     
     $zobj=1;     
     include('ele_break.php');
     
     
     $zid='descri';
     $zlabel='Descripción';
     $zvalue=$descri;
     $zwidth=45;
     if(!empty($codigo) and strlen($codigo)<=6){$zreado=1;}
     if($codi0['ctas_super']==1){$zreado=1;}
     include('ele_input.php');
     
}

    
if(mb_stristr2('.user',$modu))
{
     $zobj=1;     
     include('ele_break.php');

     
     $zid='cedula';
     $zlabel='Cédula';
     $zvalue=$cedula;
     $ztabla='enti';
     if(strlen($cedula)==10){$zreado=1;}
     if(substr($cedula,0,4)=='9999'){$zreado=0;}
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');
     
     
     $zid='email';
     $zlabel='e-mail';
     $zvalue=$email;
     $zreado=1;
     include('ele_input.php');
     
     $zid='wsapp';
     $zlabel='Wsapp';
     $zvalue=$wsapp;
     if(strlen($wsapp)==10){$zreado=2;}
     include('ele_input.php');
     

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

     $zid='descri';
     $zlabel='Nombre';
     $zvalue=$descri;
     include('ele_input.php');
          
     $zid='nickname';
     $zlabel='Seudónimo';
     $zvalue=$nickname;
     include('ele_input.php');

     
     if($empr0['empr_refer']==1)
     {
          $refe0=data_maes('user', $referx);
          
          $zid='referx';
          $zlabel='Referido X';
          $zvalue=$referx;
          $ztabla='user';
          $zreado=1;
          $zwidth=5;
          include('ele_input.php');
          
//           $zobj=1;
//           $zid='referx_nombre';
// //           $zlabel='Referido X';
//           $zvalue=$refe0['user_descri'];
//           $zreado=1;
//           include('ele_input.php');
     }
          
//      $zid='alias';
//      $zlabel='Alias';
//      $zvalue=$alias;
//      include('ele_input.php');
          
     $zobj=1;     
     include('ele_break.php');
     
//      $ztabla='pais';
//      include('ele_datalist.php');
     
     $zid='pais';
     $zlabel='País';
     $ztabla='pais';
     $zvalue=$pais;
     $zdefa='ECUA';
     include('ele_input.php');
     
     $zid='provincia';
     $zlabel='Provincia';
     $zvalue=$provincia;
     include('ele_input.php');
     
     $zid='ciudad';
     $zlabel='ciudad';
     $zvalue=$ciudad;
     $zlist='dl_ciudad';
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');
     
     $zid='calle1';
     $zlabel='Calle 1 /Cdla.';
     $zvalue=$calle1;
     include('ele_input.php');
     
     $zid='calle2';
     $zlabel='Calle 2 /Mz.';
     $zvalue=$calle2;
     include('ele_input.php');
     
     $zid='callen';
     $zlabel='No. /Villa';
     $zvalue=$callen;
     $zwidth=4;
     include('ele_input.php');

     
     
     
     $zid='calle3';
     $zlabel='Referencia';
     $zvalue=$calle3;
     include('ele_input.php');
     

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


     $zid='contacto';
     $zlabel='contacto';
     $zvalue=$contacto;
//      $zoptions='0,N/A;1,Masculino;2,Femenino';
     include('ele_input.php');

     
     $zid='telefono';
     $zlabel='teléfono';
     $zvalue=$telefono;
//      $zoptions='0,N/A;1,Masculino;2,Femenino';
     include('ele_input.php');

     
//      $zid='wsapp';
//      $zlabel='wsapp';
//      $zvalue=$wsapp;
//      $ztype='number';
//      $zsize=0.9;
//      include('ele_input.php');
     
     $zid='email';
     $zlabel='e-mail';
     $zvalue=$email;
     $zwidth=15;
     include('ele_input.php');
     
//      $zid='emailce';
//      $zlabel='e-mail CE';
//      $zvalue=$emailce;
//      $zwidth=15;
//      include('ele_input.php');

     $zobj=1;     
     include('ele_break.php');
     
     
     $zid='caduca';
     $zlabel='Caduca';
     $zvalue=$caduca;
     $ztype='date';
     $zmin=date('Y-m-d',strtotime('-1 day'));
     $zmin='2020-01-01';
     $zmax=date('Y-m-d',strtotime('+24 month'));
     $zreado=1;
     if($user0['user_tipo']=='sist'){$zreado=2;}
     include('ele_input.php');
     
     if($empr0['empr_medico']==1)
     {
          $zobj=2;
          include('ele_break.php');
          
          $zid='especial';
          $zlabel='Especialidad';
          $zvalue=$especial;
//           $zdefa='001101';
//           $zclass='numeric';
          $zwidth=20;
          include('ele_input.php');
          
          $zid='registro';
          $zlabel='Regsitro';
          $zvalue=$registro;
          $zwidth=20;
          $zhide=1;
          include('ele_input.php');
          
          $zid='senescyt';
          $zlabel='Senescyt';
          $zvalue=$senescyt;
//           $zdefa='001101';
//           $zclass='numeric';
          $zwidth=20;
          include('ele_input.php');
          
     }
     
//           echo '*/*/*/*'.$empr0['empr_ceuser'];
     
     if($empr0['empr_ceuser']==1)
     {
          $zobj=2;
          include('ele_break.php');

     $emti0=data_maes('enti',$user0['user_cedula'].'001');
          
     $zid='rimpe0';
     $zlabel='Régimen';
     $zvalue=$emti0['enti_rimpe'];
     $zoptions='0,N/A;1,Emprendedor;2,Negocio Popular;3,General';
     $zsave=1;     
     $zsavet='enti';     
     $zsavef='rimpe';     
     $zsavec=$emti0['enti_codigo'];     
     include('ele_options.php');
          
          
     $zid='obcon0';
     $zlabel='Obli.Contab.';
     $zvalue=$emti0['enti_obcon'];
     $zoptions='0,NO;1,SI;';
     $zsave=1;     
     $zsavet='enti';     
     $zsavef='obcon';     
     $zsavec=$emti0['enti_codigo'];     
     include('ele_options.php');
          
          $zobj=1;
          include('ele_break.php');
          
          
          $zid='contador';
          $zlabel='🧑‍💼 Contador';
          $zvalue=$contador;
          $zdefa=$user0['user_cedula'].'001';
          $ztabla='enti';
          $zexact=1;
          include('ele_input.php');
          
          $zobj=1;
          include('ele_break.php');
          
          
          

          $zid='ptov';
          $zlabel='Pto.Venta';
          $zvalue=$ptov;
          $zdefa='001101';
          $zclass='numeric';
          $zwidth=7;
          include('ele_input.php');
          
          
          $zid='ambice';
          $zlabel='Ambiente';
          $zvalue=$ambice;
          $zdefa=1;
          $zexact=1;
          $zoptions='1,Pruebas;2,Producción;';
          include('ele_select.php');
          
//           $zid='rimpe';
//           $zlabel='RIMPE';
//           $zvalue=$rimpe;
//           $zoptions='0,N/A;1,Emprendedor;2,Negocio Popular;';
//           include('ele_options.php');

          
          $zid='pngfile';
          $zlabel='Logo';
          $zvalue=$pngfile;
          $ztype='file';
          $zaccept='.png,.jpg,.jpeg';
//           $zonclick2="upld_logo('logo','".$empr0['empr_ruc']."','pngfile','ptov',document.getElementById('ptov').value,)";
          $zonclick2="upld_logo('logo','".$user0['user_cedula']."','pngfile','ptov',document.getElementById('ptov').value,)";
          $zlabel2='';
          include('ele_input.php');

          if($empr0['empr_ceuser']==1)
          {
               $zsize=2;
               include('ele_break.php');

               $zid='p12file';
               $zlabel='🖊️ Firma P12';
               $zvalue=$p12file;
               $ztype='file';
               $zaccept='.p12';
               $zonclick2="{upld_pk12('pk12',document.getElementById('cedula').value,'p12file',document.getElementById('p12pass').value)}";
//                $zonclick2="upld_pk12('pk12',document.getElementById('ruc').value,   'p12file',document.getElementById('p12pass').value)";
               $zlabel2='';
               include('ele_input.php');

               $zid='p12pass';
               $zlabel='🔑 Clave P12';
               $zvalue=$p12pass;
               $zwidth=20;
               $ztype='pass';
               include('ele_input.php');

               $zid='p12caduca';
               $zlabel='Caduca P12';
               $zvalue=$p12caduca;
               $zmin=date('Y-m-d',strtotime('+1 day'));
               $zmax=date('Y-m-d',strtotime('+60 month'));
               $zdefa=$zmin;
               $ztype='date';
               $zreado=1;
               if(date('Y-m-d')>=date('Y-m-d',strtotime($p12caduca.'-1 week')))
               {$zbackcolor='gold';}

               if(date('Y-m-d')>=date('Y-m-d',strtotime($p12caduca)))
               {$zfontcolor='darkred';}
     
               
               
               include('ele_input.php');
          }
          
     }

     
     if($empr0['empr_codigo']=='jwib')
     {
          $zobj=2;
          include('ele_break.php');

          $ztabla='cong';
          include('ele_datalist.php');
          
          $zid='cong';
          $zlabel='Congregación';
          $zvalue=$cong;
          $ztabla='cong';
          include('ele_input.php');
          
          $zobj=1;
          include('ele_break.php');
          
          $zid='asem';
          $zlabel='Semanales';
          $zvalue=$asem;
          $zdefa=2;
          $zbool=1;
          $zexact=1;
          include('ele_select.php');
          
          $zid='mmae';
          $zlabel='Mej.Maest.';
          $zvalue=$mmae;
          $zdefa=2;
          $zbool=1;
          $zexact=1;
          include('ele_select.php');
          
          $zid='vida';
          $zlabel='Vida & Min.';
          $zvalue=$vida;
          $zdefa=2;
          $zbool=1;
          $zexact=1;
          include('ele_select.php');
          
          $zid='estu';
          $zlabel='Estudios';
          $zvalue=$estu;
          $zdefa=2;
          $zbool=1;
          $zexact=1;
          include('ele_select.php');
          
          $zid='dpub';
          $zlabel='Discursantes';
          $zvalue=$dpub;
          $zdefa=2;
          $zbool=1;
          $zexact=1;
          include('ele_select.php');
          
          
     }
     
     if($empr0['empr_ceuser']!=1)
     {
          $zobj=2;
          include('ele_break.php');

          $zid='ptov';
          $zlabel='Pto.Vta.';
          $zvalue=$ptov;
          $zdefa='001101';
          $ztabla='ptov';
          include('ele_select.php');
          
          $zid='caja';
          $zlabel='Caja';
          $zvalue=$caja;
          $zdefa='001101';
          $ztabla='caja';
          include('ele_select.php');
          
          
          $zid='bode';
          $zlabel='Bodega';
          $zvalue=$bode;
          $zdefa='001101';
          $ztabla='bode';
          include('ele_select.php');
          
          
          
     }
     
     
     
}
     
if(mb_stristr2('.adrs',$modu))
{
     
     $zid='enti';
     $zlabel='Entidad';
     $zvalue=$enti;
     $ztabla='enti';
     $zlist='dl_enti';
     if(!empty($enti)){$zreado=1;}
     $zondblclick='{document.getElementById("enti").removeAttribute("disabled");}';     
     $zonblur='{location.href="?scri='.basename(__FILE__,'.php').'&modu="+document.getElementById("modu").value+"&enti="+document.getElementById("enti").value;}';
     $zonchange=$zonblur;
     if(!mb_stristr2('sist.supe.admi',$user0['user_tipo']))
     {$zhide=1;}
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');

//      $ztabla='pais';
//      include('ele_datalist.php');
     
     $zid='pais';
     $zlabel='País';
     $zvalue=$pais;
     include('ele_input.php');
     
     $zid='provincia';
     $zlabel='Provincia';
     $zvalue=$provincia;
     include('ele_input.php');
     
     $zid='ciudad';
     $zlabel='ciudad';
     $zvalue=$ciudad;
     $zlist='dl_ciudad';
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');
     
     $zid='calle1';
     $zlabel='Calle 1 /Cdla.';
     $zvalue=$calle1;
     include('ele_input.php');
     
     $zid='calle2';
     $zlabel='Calle 2 /Mz.';
     $zvalue=$calle2;
     include('ele_input.php');
     
     $zid='callen';
     $zlabel='No. /Villa';
     $zvalue=$callen;
     include('ele_input.php');
     
     $zid='calle3';
     $zlabel='Referencia';
     $zvalue=$calle3;
     include('ele_input.php');
     

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


     $zid='contacto';
     $zlabel='contacto';
     $zvalue=$contacto;
//      $zoptions='0,N/A;1,Masculino;2,Femenino';
     include('ele_input.php');

     
     $zid='telefono';
     $zlabel='teléfono';
     $zvalue=$telefono;
//      $zoptions='0,N/A;1,Masculino;2,Femenino';
     include('ele_input.php');

     
     $zid='wsapp';
     $zlabel='wsapp';
     $zvalue=$wsapp;
     $ztype='number';
     $zsize=0.9;
     include('ele_input.php');
     
     $zid='email';
     $zlabel='e-mail';
     $zvalue=$email;
     $zwidth=15;
     include('ele_input.php');
     
//      $zid='emailce';
//      $zlabel='e-mail CE';
//      $zvalue=$emailce;
//      $zwidth=15;
//      include('ele_input.php');
     
}

if(mb_stristr2('.zsub',$modu))
{
$zobj=2;     
include('ele_break.php');
     
     $zid='vndd';
     $zlabel='Vendedor';
     $zvalue=$vndd;
     $ztabla='enti';     
     include('ele_input.php');

$zobj=1;     
include('ele_break.php');
     
     $zid='rcdd';
     $zlabel='Recaudador';
     $zvalue=$rcdd;
     $ztabla='enti';     
     include('ele_input.php');

     
}     

     
if(mb_stristr2('.cair',$modu))
{
     $zid='ctacont1';
     $zlabel='Cta.Clientes';
     $zvalue=$ctacont1;
     $ztabla='ctas';
     $zlist='ctas1';
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');
     
     $zid='ctacont2';
     $zlabel='Cta.Proveed';
     $zvalue=$ctacont2;
     $ztabla='ctas';
     $zlist='ctas2';
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');
     
     $zid='ctacont5';
     $zlabel='Cta.Compras';
     $zvalue=$ctacont5;
     $ztabla='ctas';
     $zlist='ctas5';
     include('ele_input.php');
     
}
     
if(mb_stristr2('.civa',$modu))
{
     $zobj=1;     
     include('ele_break.php');
     
     $zid='ctavtas';
     $zlabel='Cta.IVA Ventas';
     $zvalue=$ctavtas;
     $ztabla='ctas';
     $zlist='ctas1';
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');
     
     $zid='ctacomp';
     $zlabel='Cta.IVA Compras';
     $zvalue=$ctacomp;
     $ztabla='ctas';
     $zlist='ctas2';
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');
     
     $zid='ctaretc';
     $zlabel='Cta.Ret.IVA Clie';
     $zvalue=$ctaretc;
     $ztabla='ctas';
     $zlist='ctas1';
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');
     
     $zid='ctaretp';
     $zlabel='Cta.Ret.IVA Prov';
     $zvalue=$ctaretp;
     $ztabla='ctas';
     $zlist='ctas2';
     include('ele_input.php');
     
}

if(mb_stristr2('.pais',$modu))
{
     $zobj=1;     
     include('ele_break.php');
     
     $zid='ats';
     $zlabel='Cod.ATS';
     $zvalue=$ats;
     $zmin=0;
     $zmax=9999;
     $zclass='numeric-int';
     include('ele_input.php');
     
     
}     
     
     
if(mb_stristr2('.enti.clie.prov.pers.pjur.pcnt.vndd.rcdd',$modu))
{
     
//      if(!mb_stristr2('.pcnt',$modu))
     if(mb_stristr2('.enti.clie.prov.pjur.',$modu))
     if(strlen(trim($codigo))==13 or substr($codigo,0,2)=='99' or empty($codigo))
     {
          
          
     $zid='razsoc';
     $zlabel='Razón Social';
     $zvalue=$razsoc;
     if(empty($razsoc)){$zvalue=$descri;}
     $zwidth=30;
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');

     $zid='nomcom';
     $zlabel='Nom.Comer. ';
     $zvalue=$nomcom;
     $zwidth=30;
     include('ele_input.php');
     
     $zsize=2;
     include('ele_break.php');
     
          
//      if(mb_stristr2('.enti.clie.prov.pjur.',$modu))
     {

     $zid='rimpe';
     $zlabel='Régimen';
     $zvalue=$rimpe;
     $zoptions='0,N/A;1,Emprendedor;2,Negocio Popular;3,General';
     include('ele_options.php');
          
          
     $zid='obcon';
     $zlabel='Obli.Contab.';
     $zvalue=$obcon;
     $zoptions='0,NO;1,SI;';
//      $ztype='check';
     include('ele_options.php');
          
     $zid='agret';
     $zlabel='Ag.Reten.';
     $zvalue=$agret;
     $zoptions='0,NO;1,SI;';
//      $ztype='check';
     include('ele_options.php');
          
          
     $zid='coesp';
     $zlabel='C.Especial';
     if(strlen($codigo)==10){$zvalue=0;$zreado=1;}
     $zvalue=$coesp;
     $zoptions='0,NO;1,SI;';
//      $ztype='check';
     include('ele_options.php');
     
          
     $zid='exiva';
     $zlabel='Exento IVA';
     $zvalue=$exiva;
     $zoptions='0,NO;1,SI;';
     include('ele_options.php');
          
     }
     
//      $zobj=1;     
     include('ele_break.php');
     
     }
     
     $zid='nom1';
     $zlabel='Nombre 1';
     $zvalue=$nom1;
     include('ele_input.php');
     
//      if($modu=='enti')
     if(mb_stristr2('enti.clie',$modu))
     {
     $zid='nom2';
     $zlabel='Nombre 2';
     $zvalue=$nom2;
     include('ele_input.php');
     }
     
$zobj=1;     
include('ele_break.php');
     
     $zid='ape1';
     $zlabel='Apellido 1';
     $zvalue=$ape1;
     include('ele_input.php');
     
     $zid='ape2';
     $zlabel='Apellido 2';
     $zvalue=$ape2;
     include('ele_input.php');

     
     $zobj=2; 
     $zsize=1;
     include('ele_break.php');
     
     if(mb_stristr2('.enti.clie.prov.pers.pjur.pcnt',$modu))
     {
          $zid='pasaporte';
          $zlabel='Pasaporte';
          $zvalue=$pasaporte; 
          if($modu=='pcnt' and $empr0['empr_veterinaria']==1){$zhide=1;}
          include('ele_input.php');
          
          $zid='idexterior';
          $zlabel='ID.Exterior';
          $zvalue=$idexterior; 
          if($modu=='pcnt' and $empr0['empr_veterinaria']==1){$zhide=1;}
          include('ele_input.php');
     }
     
     

if(strlen($codigo)==10)
{
$zobj=2;     
$zsize=3;
include('ele_break.php');
     
     $zid='fechanac';
     $zlabel='Nacimiento';
     $zvalue=$fechanac;
     if(empty($fechanac)){$zvalue='2000-01-01';}
//      if(!empty($fechanac)){$zreado=2;}
     $ztype='date';
     $zmax=date('Y-m-d');
     $zmin=date('Y-01-01',strtotime('-99 year'));
     include('ele_input.php');

     $edad=$codi0[$modu.'_edad1'].':'.$codi0[$modu.'_edad2'];
     $zid='edad';
     $zlabel='Edad';
     $zvalue=$edad;
     $zreado=1;
     $zwidth=4;
     include('ele_input.php');

     $zid='sexo';
     $zlabel='Sexo';
     $zvalue=$sexo;
     $zoptions='0,N/A;1,Masculino;2,Femenino';
//      if(!empty($zvalue)){$zreado=2;}
     include('ele_select.php');

     $zid='sangre';
     $zlabel='Sangre';
     $zvalue=$sangre;
     $zoptions='O-;O+;A-;A+;B-;B+;AB-;AB+';
//      if(!empty($zvalue)){$zreado=2;}
     include('ele_select.php');
}     

     

if($modu=='pcnt' and $empr0['empr_veterinaria']==1)
{
     $zid='esteril';
     $zlabel='Esteril';
     $zvalue=$esteril;
     $ztriv=1;
//      if(!empty($zvalue)){$zreado=2;}
     include('ele_select.php');
     
     $zid='veneno';
     $zlabel='Veneno';
     $zvalue=$veneno;
     $ztriv=1;
//      if(!empty($zvalue)){$zreado=2;}
     include('ele_select.php');
     
     $zobj=1;     
     include('ele_break.php');
     
     
     $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');
     
     $zid='color';
     $zlabel='Color';
     $zvalue=$color;
     $zlist='dl_color';
     include('ele_input.php');
     
}

     

$zobj=2;     
include('ele_break.php');
          // echo '<br>TIME D = '.date('H:i:s');

if(mb_stristr2('enti.clie.prov',$modu))
{
//      $ztabla='pais';
//      include('ele_datalist.php');
     
     $zid='pais';
     $zlabel='País';
     $zvalue=$pais;
     $ztabla='pais';
     $zdefa='ECUA';
     include('ele_input.php');
     
     $zid='prvc';
     $zlabel='Provincia';
     $zvalue=$prvc;
     $ztabla='prvc';
//      $zdefa='GUA';
     include('ele_input.php');
     
     $zid='zsub';
     $zlabel='Zona';
     $zvalue=$zsub;
     $ztabla='zsub';
//      $zdefa='GUA';
     include('ele_input.php');
     
     $zid='tpro';
     $zlabel='T.Provee.';
     $zvalue=$tpro;
     $ztabla='tpro';
//      $zdefa='GUA';
     include('ele_input.php');
     
     
     
$zobj=1;     
include('ele_break.php');
}     
     
     if(strlen(trim($codigo))==13)
     {
     $zid='matriz';
     $zlabel='Matriz';
     $zvalue=$matriz;
     $zwidth=25;    
     $zrows=2;
     if(strlen($matriz)>=5)
     {$zreado=2;}
     include('ele_input.php');
     }

     $zid='direccion';
     $zlabel='Dirección';
     $zvalue=$direccion;
     $zwidth=25;    
     $zrows=2;     
     include('ele_input.php');

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

     $zid='telefono';
     $zlabel='teléfono';
     $zvalue=$telefono;
     include('ele_input.php');

     
     $zid='wsapp';
     $zlabel='wsapp';
     $zvalue=$wsapp;
     $ztype='number';
     $zsize=0.9;
     include('ele_input.php');
     
     
     $zid='email';
     $zlabel='e-mail';
     $zvalue=$email;
     $zwidth=20;
     $zrows=2;
     include('ele_input.php');
     
     $zid='emailce';
     $zlabel='e-mail CE';
     $zvalue=$emailce;
     $zwidth=20;
     $zrows=2;
//      $zmulti=1;
     include('ele_input.php');
     

     
     
if(mb_stristr2('enti.clie',$modu))
{
     
$zobj=2;     
include('ele_break.php');
     
     $zid='vndd';
     $zlabel='Vendedor';
     $zvalue=$vndd;
     $ztabla='enti';     
     include('ele_input.php');

     $zid='rcdd';
     $zlabel='Recaudador';
     $zvalue=$rcdd;
     $ztabla='enti';     
     include('ele_input.php');

     $zid='plazo';
     $zlabel='Plazo';
     $zvalue=$plazo;
//      $ztabla='enti';
     $zclass='numeric-int';
     $zmin=0;
     $zmax=90;
     include('ele_input.php');

}
     
$zobj=2;     
include('ele_break.php');
     
     $zid='factura';
     $zlabel='Facturar';
     $zvalue=$factura;
     $ztabla='enti';     
     include('ele_input.php');
     
     $zid='pasaporte';
     $zlabel='Pasaporte';
     $zvalue=$pasaporte;
//      $ztabla='enti';     
     include('ele_input.php');
     
     
     
}
     
if(mb_stristr2('.item.bien.serv.iinv.ibod.ivta.igas',$modu))
{
     $zid='descri';
     $zlabel='Descripción';
     $zvalue=$descri;
     $zwidth=40;
     $zrows=2;
     include('ele_input.php');
     
$zobj=1;     
include('ele_break.php');
     
     $zid='descri2';
     $zlabel='Info.Adic.';
     $zvalue=$descri2;
     $zwidth=40;
     $zrows=2;
     include('ele_input.php');
     
     
$zobj=2;     
include('ele_break.php');

     if($rgsn_ok==1) 
     {
          $zid='rgsn';
          $ztabla='rgsn';
          $zlabel='Reg.Sanit.';
          $zvalue=$rgsn;
          $zlist='dl_rgsn';
          include('ele_input.php');
          
$zobj=1;     
include('ele_break.php');
          
     }
     
     
     
     $zid='marca';
     $zlabel='Marca';
     $zvalue=$marca;
//      $zvalue=$mrca;
//      $zdefa='GENERICO';
//      if(empty($zvalue)){$zvalue='GENERICO';}
     $zlist='dl_marca';
     include('ele_input.php');

     
     $zid='modelo';
     $zlabel='Modelo';
     $zvalue=$modelo;
     $zwidth=15;
     include('ele_input.php');

     $zid='lsub';
     $zlabel='Linea-Sub';
     $zvalue=$lsub;
     $zlist='dl_lsub';
     $ztabla='lsub';
     include('ele_select.php');

     
     
$zobj=1;     
include('ele_break.php');
     
     $zid='ean';
     $zlabel='Cod.EAN';
     $zvalue=$ean;
//      $ztabla='item';
     $zclass='numeric-int';
     $zlist='nolist';
     include('ele_input.php');
     
     $zid='numpart';
     $zlabel='#Parte';
     $zvalue=$numpart;
     include('ele_input.php');

     
     
     $zid='codigov';
     $zlabel='Cod.Venta';
     $zvalue=$codigov;
     include('ele_input.php');
     
     
$zobj=1;     
include('ele_break.php');

     $zid='umdd';
     $zlabel='U.Medida';
     $zvalue=$umdd;
     $ztabla='umdd';
     $zlist='dl_umdd';
     include('ele_select.php');
     
     $zid='duni';
     $zlabel='Dec.Unid.';
     $zvalue=$duni;
     $zmin=0;
     $zmax=8;
     $zclass='numeric-dec';
     include('ele_input.php');
     
     $zid='dcos';
     $zlabel='Dec.Costo';
     $zvalue=$dcos;
     $zmin=0;
     $zmax=8;
     $zclass='numeric-dec';
     include('ele_input.php');

     
     $zid='dpre';
     $zlabel='Dec.Precio';
     $zvalue=$dpre;
     $zmin=0;
     $zmax=8;
     $zclass='numeric-dec';
     include('ele_input.php');

     
     $zid='dval';
     $zlabel='Dec.Valor';
     $zvalue=$dval;
     $zmin=0;
     $zmax=8;
     $zclass='numeric-dec';
//      $zhide=1;
     include('ele_input.php');
     


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

     $zid='medidas';
//      $zlabel='LxAxA cm';
     $zlabel='LxWxH mm';
     $zvalue=$medidas;
     $zwidth=15;
     include('ele_input.php');
     
     
     
     
$zobj=2;     
include('ele_break.php');

     $zid='ttrf';
     $zlabel='Tarifa';
     $zvalue=$ttrf;
     $zvalue=$codi0[$modu.'_ttrf'];
     if(empty($zvalue)){$zvalue='Abierta';}
     $zoptions='';
//      $zoptions.='Lista;';
     $zoptions.='Abierta;';
     $zoptions.='Fija;';
     if($empr0['empr_taller']==1)
     {
          $zoptions.='Clase;';
          $zoptions.='Tempario;';
          $zoptions.='Diagnóstico;';
     }
     
     $zexact=1;
     $zonblur='{document.querySelectorAll(".ttrf").forEach(el => {el.style.display = "none";});}';
     $zonblur.='{document.getElementById("ttrf_"+this.value).style.display="";}';
     $zonchange=$zonblur;
     include('ele_select.php');

     
// echo '====='.$ttrf;     
     
     
     $zid='iva';
     $zlabel='I.V.A.';
     $zvalue=$iva;
     $zmin=0;
     $zmax=999;
     $zoptions='0;12;15';
     $zonchange='calc_precio(event,this.id);';
     $zonblur='calc_precio(event,this.id);';
     include('ele_select.php');
     
     $zid='ice';
     $zlabel='I.C.E.';
     $zvalue=$icec;
     $zmin=0;
     $zmax=99.99;
     $zclass='numeric-dec';
     $zonchange='calc_precio(event,this.id);';
     $zonblur='calc_precio(event,this.id);';
     include('ele_input.php');
     
     
$zobj=2;
// $zsize=1;     
include('ele_break.php');

// echo '====='.$ttrf;     
$ttrf=$codi0[$modu.'_ttrf'];
$ttrf=substr($ttrf,0,1);
$ttrf=strtoupper($ttrf); 

     
$ttrf_display='none';     
if(empty($ttrf) or mb_stristr2('A.L.F.',$ttrf)){$ttrf_display='';}     
echo '<div class="ttrf" id="ttrf_Fija" style="display:'.$ttrf_display.';"> ';
{
     if($acce['prec']==1)
     for($idx=1; $idx<=5; $idx++)
     {
          $zobj=1;     
          include('ele_break.php');

          $zid='puni'.$idx;
          $zlabel='P.Unit.'.$idx;
          $zvalue=${'puni'.$idx};
          $zmin=0;
          $zmax=9999.99;
          if($empr0['empr_inmobil']==1)
          {$zmax=9999999.99;}
          $zclass='numeric-dec';
          $zonchange='calc_precio(event,this.id);';
          $zonblur='calc_precio(event,this.id);';
          include('ele_input.php');

          $zid='dcto'.$idx;
          $zlabel='Dcto.'.$idx;
          $zvalue=${'dcto'.$idx};
          $zmin=0;
          $zmax=999.99;
          $zclass='numeric-dec';
          $zonchange='calc_precio(event,this.id);';
          $zonblur='calc_precio(event,this.id);';
          include('ele_input.php');

          $zid='pvp'.$idx;
          $zlabel='P.V.P. '.$idx;
          $zvalue=${'pvp'.$idx};
          $zmin=0;
          $zmax=9999.99;
          if($empr0['empr_inmobil']==1)
          {$zmax=9999999.99;}
          $zclass='numeric-dec';
          $zonchange='calc_precio(event,this.id);';
          $zonblur='calc_precio(event,this.id);';
          include('ele_input.php');


     }
}
echo '</div>';
     
$ttrf_display='none';     
if($ttrf=='C'){$ttrf_display='';}
echo '<div class="ttrf" id="ttrf_Clase" style="display:'.$ttrf_display.';"> ';
{
     set_tcvh0($codigo);
     
     $zobj=1;     
     include('ele_break.php');
     
     $sql_tcvh='select * from tcvh0 left join clvh0 on tcvh_clvh=clvh_codigo where tcvh_item="'.$codigo.'" order by tcvh_clvh ';
     $res_tcvh=msql_query($sql_tcvh,$link_data);

     $domd_t = new DOMDocument();
          $domd_t->encoding = 'utf-8';
          $domd_t->xmlVersion = '1.0';
          $domd_t->formatOutput = true;
     $elem_t=$domd_t;
     
     $table=$elem_t->appendChild($domd_t->createElement("table"," "));
          $table->setAttribute('border','0');
     $thead=$table->appendChild($domd_t->createElement("thead"," "));
     $trow=$thead->appendChild($domd_t->createElement("tr"," "));
     $tcol=$trow->appendChild($domd_t->createElement("th","CLASE"));
     $tcol=$trow->appendChild($domd_t->createElement("th","P.Unit."));
     $tcol=$trow->appendChild($domd_t->createElement("th","P.V.P."));
     
//      if(1==2)
     while($aso_tcvh=msql_fetch_assoc($res_tcvh))
     {
          $trow=$table->appendChild($domd_t->createElement("tr"," "));
          $tcol=$trow->appendChild($domd_t->createElement('td',''));       
          $zdom=$domd_t;
          $zele=$tcol;
          $zid=$aso_tcvh['clvh_codigo'];
          $zlabel=$aso_tcvh['clvh_descri'];
          $zalign='right';
          include('ele_button.php');
          
          
          $tcol=$trow->appendChild($domd_t->createElement('td',''));       
          $zdom=$domd_t;
          $zele=$tcol;
          $zobj=1;
          $zid='puni_'.$aso_tcvh['tcvh_codigo'];
          $zvalue=$aso_tcvh['tcvh_puni'];
          $zmin=0;
          $zmax=999.99;
          $zclass='numeric-dec';
          $zsave=1;
          $zsavet='tcvh' ;
          $zsavef='puni';
          $zsavec=$aso_tcvh['tcvh_codigo'];
          $zonchange='{document.getElementById("'.'pvp_'.$aso_tcvh['tcvh_codigo'].'").value= (this.value*(1+('.($codi0['item_iva']/100).'))).toFixed(2);}';
          include('ele_input.php');
          
          $tcol=$trow->appendChild($domd_t->createElement('td',''));       
          $zdom=$domd_t;
          $zele=$tcol;
          $zobj=1;
          $zid='pvp_'.$aso_tcvh['tcvh_codigo'];
          $zvalue=$aso_tcvh['tcvh_pvp'];
          $zmin=0;
          $zmax=999.99;
          $zclass='numeric-dec';
          $zsave=1;
          $zsavet='tcvh' ;
          $zsavef='pvp';
          $zsavec=$aso_tcvh['tcvh_codigo'];
          $zonchange='{document.getElementById("'.'puni_'.$aso_tcvh['tcvh_codigo'].'").value= (this.value/(1+('.($codi0['item_iva']/100).'))).toFixed(8);}';
          include('ele_input.php');
     }
     
     echo $domd_t->saveHTML();     
     
}     
echo '</div>';
     

// if($ttrf=='T'){set_tmpr0($codigo);}     

$ttrf_display='none';     
if($ttrf=='T'){$ttrf_display='';}
echo '<div class="ttrf" id="ttrf_Tempario" style="display:'.$ttrf_display.';"> ';
{
//      set_tcvh0($codigo);
     set_tmpr0($codigo);
     
     $zobj=1;     
     include('ele_break.php');
     $zid='horat';
     $zlabel='Horas';
     $zvalue=$horat;
     $zmin=0;
     $zmax=99;
     $zclass='numeric-dec';
//      $zoptions='0;12;15';
//      $zonchange='calc_precio(event,this.id);';
//      $zonblur='calc_precio(event,this.id);';
     include('ele_input.php');
     
     
}     
echo '</div>';
     
     
     
     
     if(strlen($codigo)==8)
     {
          $zobj=2;     
          include('ele_break.php');
          
          $zid='clor';
          $zlabel='Color';
          $ztabla='clor';
          $zdefa='';
          $zvalue=$clor;
          include('ele_select.php');
          
          $zobj=2;     
          include('ele_break.php');
          
          $sql_tlla='select * from tlla0 where ifnull(tlla_status,"")not in ("I","X") and ifnull(tlla_descri,"")!="" order by tlla_codigo';
          $res_tlla=msql_query($sql_tlla,$link_data);
          
          $l_digit='';
          while($aso_tlla=msql_fetch_assoc($res_tlla))
          {
            //   echo '=='.$aso_tlla['tlla_codigo'];
              $tlla_codigo=$aso_tlla['tlla_codigo'];
              if($l_digit!=substr($tlla_codigo,0,1))
              {
                  $zobj=1;     
                  include('ele_break.php');
                  $l_digit=substr($tlla_codigo,0,1);
              }
              
              
              $zid='tlla_'.$aso_tlla['tlla_codigo'];
              $zlabel=$aso_tlla['tlla_descri'];
            //   $zdefa='';
              $zvalue=${'tlla_'.$aso_tlla['tlla_codigo']};
              $ztype='check';
              include('ele_input.php');


    //  $zid='pyme';
    //  $zlabel='Ventas & Compras';
    //  $zvalue=$pyme;
    //  $zvalue=1;
    //  $ztype='check';
    //  $zhide=1;
    //  include('ele_input.php');

              
          }
          
     }
     
}


if(mb_stristr2('.vinn',$modu))
{
//      $zid='dl_clase';
//      $ztabla='plvh';
//      $zcolu='plvh_clase';
//      include('ele_datalist.php');
     
//      $zid='dl_mrca';
//      $ztabla='plvh';
//      $zcolu='plvh_mrca';
//      include('ele_datalist.php');
}
     
     
     
if(mb_stristr2('.vinn',$modu))
{
     $zid='ramv';
     $zlabel='RAMV';
     $zvalue=$ramv;
     $zwidth=20;
     include('ele_input.php');
     
$zobj=1;     
include('ele_break.php');
     $zid='numotor';
     $zlabel='# Motor';
     $zvalue=$numotor;
     $zwidth=20;
     include('ele_input.php');
$zobj=1;     
include('ele_break.php');
     
}
     
if(mb_stristr2('.pmdo',$modu))
{
     $zobj=1;     
     include('ele_break.php');
     
     $ztabla='clvh';
     include('ele_datalist.php');

     $ztabla='mrca';
     include('ele_datalist.php');

     $zid='mrca';
     $zlabel='Marca';
     $ztabla='mrca';
     $zvalue=$mrca;
     include('ele_input.php');
     
     $zid='clvh';
     $zlabel='Clase VH';
     $ztabla='clvh';
     $zvalue=$clvh;
     include('ele_input.php');
     
//      $zobj=1;     
//      include('ele_break.php');
    
}     
     
if(mb_stristr2('.vinn',$modu))
{
     $ztabla='mdvh';
     include('ele_datalist.php');

     $zid='mdvh';
     $zlabel='Mod.Vehículo';
     $ztabla='mdvh';
     $zvalue=$mdvh;
     include('ele_input.php');
     
     
$zobj=1;     
include('ele_break.php');
     
     
}     
     

     
     

     
if(mb_stristr2('.mdvh.vinn',$modu))
{
     
     $ztabla='mrca';
     include('ele_datalist.php');
     
     $zid='dl_clase';
     $ztabla='mdvh';
     $zcolu='mdvh_clase';
     include('ele_datalist.php');
     
     $zid='mrca';
     $zlabel='Marca';
     $ztabla='mrca';
     $zvalue=$mrca;
     include('ele_input.php');

     $zid='modelo';
     $zlabel='Modelo';
     $zvalue=$modelo;
     include('ele_input.php');
     
     $zid='anio';
     $zlabel='Año';
     $zvalue=$anio;
     $ztype='year';
     $zmin='1960';
     $zmax=date('Y');
     include('ele_input.php');
     
//      $zid='carroceria';
//      $zlabel='Carrocería';
//      $zvalue=$carroceria;
//      include('ele_input.php');
     

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

     $zid='clase';
     $zlabel='Clase';
     $zvalue=$clase;
     $zlist='dl_clase';
     include('ele_input.php');


if(mb_stristr2('.mdvh.',$modu))
{
     
$zobj=1;     
include('ele_break.php');

     $zid='medidas';
     $zlabel='LxWxH mm';
     $zvalue=$medidas;
     $zwidth=15;
     include('ele_input.php');
     

$operacion=$medidas;     
$operacion = str_replace('x', '*', $operacion);
$operacion = str_replace('X', '*', $operacion);
$resultado = eval("return $operacion;");
// $conteo = substr_count($operacion, '*');
$volm3=$resultado;     
$volm3=$resultado/(1000*1000*1000);
// $volm3=$resultado/pow(1000,$conteo+1);
     
     $zid='volm3';
     $zlabel='Volumen m3';
     $zvalue=$volm3;
     $zvalue=number_format($zvalue,2);
     $zwidth=5;
     $zreado=1;
     include('ele_input.php');
     
//      $zid='volcm3';
//      $zlabel='Volumen cm3';
//      $zvalue=$volcm3;
//      $zvalue=number_format($zvalue,2);
//      $zwidth=5;
//      $zreado=1;
//      include('ele_input.php');
     
     
     
     $zobj=0;
     include('ele_break.php');
     
     $zid='dl_ant';
     $ztabla='mdvh';
     $zcolu='mdvh_ant';
     include('ele_datalist.php');

     
     $zid='ant';
     $zlabel='Homolog.ANT ';
     $zvalue=$ant;
     $zlist='dl_ant';
     $zwidth=20;
     include('ele_input.php');
    
}     
     
     
     
$zobj=0;     
include('ele_break.php');

     $zid='motor';
     $zlabel='Motor';
     $zvalue=$motor;
     $zoptions='';
     $zoptions.='Gasolina;';
     $zoptions.='Diesel;';
     $zoptions.='Eléctrico;';
     $zoptions.='Híbrido;';
     $zoptions=strtoupper2($zoptions);
     include('ele_select.php');
//      include('ele_input.php');
     
     $zid='cilindraje';
     $zlabel='Cilindraje CC';
     $zvalue=$cilindraje;
     $zclass='numeric-int';
     $zmin=100;
     $zmax=200000;
     include('ele_input.php');
     
     $zid='potencia';
     $zlabel='Potencia HP';
     $zvalue=$potencia;
     $zclass='numeric-int';
     $zmin=10;
     $zmax=1000;
     include('ele_input.php');
     
     $zid='torque';
     $zlabel='Torque NM';
     $zvalue=$torque;
     $zclass='numeric-int';
     $zmin=10;
     $zmax=1000;
     include('ele_input.php');

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

     $zid='ejes';
     $zlabel='# Ejes';
     $zvalue=$ejes;
     $zclass='numeric-int';
     $zmin=1;
     $zmax=10;
     include('ele_input.php');
     
     $zid='ruedas';
     $zlabel='# Ruedas';
     $zvalue=$ruedas;
     $zclass='numeric-int';
     $zmin=2;
     $zmax=20;
     include('ele_input.php');

     $zid='pax';
     $zlabel='Pasajeros';
     $zvalue=$pax;
     $zclass='numeric-int';
     $zmin=1;
     $zmax=50;
     include('ele_input.php');
     
     
     $zid='cargatn';
     $zlabel='Carga TN';
     $zvalue=$cargatn;
     $zclass='numeric-int';
     $zmin=1;
     $zmax=50;
     include('ele_input.php');
     

     
}


     
     
if(mb_stristr2('.plvh',$modu))
{

$ztabla='vinn';
include('ele_datalist.php');
     
     $zid='vinn';
     $zlabel='VIN';
     $zvalue=$vinn;
     $ztabla='vinn';
//      $ztriv=1;
     include('ele_input.php');
     
     
$zobj=1;     
include('ele_break.php');
     
     $zid='dl_mrca';
     $ztabla='plvh';
     $zcolu='plvh_mrca';
     include('ele_datalist.php');
     
     $zid='mrca';
     $zlabel='Marca';
     $zvalue=$mrca;
     $zlist='dl_mrca';
     include('ele_input.php');

     $zid='modelo';
     $zlabel='Modelo';
     $zvalue=$modelo;
//      $zlist='dl_mrca';
     include('ele_input.php');
     
     $zid='anio';
     $zlabel='Año';
     $zvalue=$anio;
     $ztype='year';
     $zmin='1960';
     $zmax=date('Y');
//      $zlist='dl_mrca';
     include('ele_input.php');

$zobj=2;
include('ele_break.php');
     
     
     $zid='dl_clase';
     $ztabla='plvh';
     $zcolu='plvh_clase';
     include('ele_datalist.php');
     
     $zid='clase';
     $zlabel='Clase';
     $zvalue=$clase;
     $zlist='dl_clase';
     include('ele_input.php');
     
     $zid='clor';
     $zlabel='Color';
//      $ztabla='clor';
     $zdefa='';
     $zvalue=$clor;
     include('ele_select.php');

     
     $zobj=2;
     include('ele_break.php');
     
     
     $zid='wsapp';
     $zlabel='Wsapp';
     $zvalue=$wsapp;
     if(strlen($wsapp)==10){$zreado=2;}
     include('ele_input.php');

     $zid='propietario';
     $zlabel='Propietario';
     $zdefa='';
     $zwidth=20;
     $zvalue=$propietario;
     include('ele_input.php');
     
}


     
     
if(mb_stristr2('.bbii',$modu))
{
     
     $zobj=2;
     include('ele_break.php');
     
     $zid='lsub';
     $zlabel='Línea';
     $zvalue=$lsub;
     $ztabla='lsub';
//      $ztriv=1;
     include('ele_select.php');
     
     $zid='venta';
     $zlabel='Venta';
     $zvalue=$venta;
     $ztriv=1;
     include('ele_select.php');
     
     $zid='alqui';
     $zlabel='Alquiler';
     $zvalue=$alqui;
     $ztriv=1;
     include('ele_select.php');

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

     
     $ztabla='prvc';
     include('ele_datalist.php');
     
     $ztabla='cdad';
     include('ele_datalist.php');
     
     $zid='prvc';
     $zlabel='Provincia';
     $ztabla='prvc';
     $zvalue=$prvc;
     include('ele_input.php');
     
     $zid='ciudad';
     $zlabel='Ciudad';
//      $ztabla='cdad';
     $zvalue=$ciudad;
     $zlist='dl_ciudad';
     include('ele_input.php');
     
     $zid='direccion';
     $zlabel='Dirección';
     $zvalue=$direccion;
//      $ztriv=1;
     $zwidth=30;
     include('ele_input.php');
     
     
     $zobj=2;
     include('ele_break.php');

     $zid='puntos';
     $zlabel='Puntos';
     $zvalue=$puntos;
     $zclass='numeric-int';
     $zmin=0;
     $zmax=9999999;
     include('ele_input.php');
     
     $zid='avaluo';
     $zlabel='Avaluo';
     $zvalue=$avaluo;
     $zclass='numeric-int';
     $zmin=0;
     $zmax=999999;
     include('ele_input.php');
     
     $zid='pventa';
     $zlabel='P.Venta';
     $zvalue=$pventa;
     $zclass='numeric-int';
     $zmin=0;
     $zmax=9999999;
     include('ele_input.php');
     
     $zid='palqui';
     $zlabel='P.Alquiler';
     $zvalue=$palqui;
     $zclass='numeric-int';
     $zmin=0;
     $zmax=999999;
     include('ele_input.php');
     
     $zobj=2;
     include('ele_break.php');

     $zid='plantas';
     $zlabel='Plantas';
     $zvalue=$plantas;
//      $zdefa=1;
     $zclass='numeric-int';
     $zmin=1;
     $zmax=10;
     include('ele_input.php');
     
     $zid='frente';
     $zlabel='Frente';
     $zvalue=$frente;
     $zclass='numeric-dec';
     $zmin=0;
     $zmax=9999.99;
     include('ele_input.php');
     
     $zid='fondo';
     $zlabel='Fondo';
     $zvalue=$fondo;
     $zclass='numeric-dec';
     $zmin=0;
     $zmax=9999.99;
     include('ele_input.php');
     
     $zid='terreno';
     $zlabel='Terreno';
     $zvalue=$terreno;
     $zclass='numeric-dec';
     $zmin=0;
     $zmax=9999999.99;
     include('ele_input.php');
     
     $zid='constru';
     $zlabel='Construcción';
     $zvalue=$constru;
     $zclass='numeric-dec';
     $zmin=0;
     $zmax=999999.99;
     include('ele_input.php');
     
     $zobj=2;
     include('ele_break.php');

     $zid='sala';
     $zlabel='Sala';
     $zvalue=$sala;
     $ztriv=1;
     include('ele_select.php');
     
     $zid='estudio';
     $zlabel='Estudio';
     $zvalue=$estudio;
     $ztriv=1;
     include('ele_select.php');
     
     $zid='comedor';
     $zlabel='Comedor';
     $zvalue=$comedor;
     $ztriv=1;
     include('ele_select.php');
     
     $zid='cocina';
     $zlabel='Cocina';
     $zvalue=$cocina;
     $ztriv=1;
     include('ele_select.php');
     
     $zid='habitac';
     $zlabel='Habitaciones';
     $zvalue=$habitac;
     $zclass='numeric-int';
     $zmin=0;
     $zmax=10;
     include('ele_input.php');

     $zid='banio';
     $zlabel='Baños';
     $zvalue=$banio;
     $zclass='numeric-int';
     $zmin=0;
     $zmax=10;
     include('ele_input.php');

     $zid='banio2';
     $zlabel='Medio.Baños';
     $zvalue=$banio2;
     $zclass='numeric-int';
     $zmin=0;
     $zmax=10;
     include('ele_input.php');

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

     $zid='patio';
     $zlabel='Patio';
     $zvalue=$patio;
     $ztriv=1;
     include('ele_select.php');
     
     $zid='garage';
     $zlabel='Garage';
     $zvalue=$garage;
     $ztriv=1;
     include('ele_select.php');
     
     $zid='terra';
     $zlabel='Terraza';
     $zvalue=$terra;
     $ztriv=1;
     include('ele_select.php');
     
     $zid='vistamar';
     $zlabel='Vista Mar';
     $zvalue=$vistamar;
     $ztriv=1;
     include('ele_select.php');
     
     $zid='bbq';
     $zlabel='BBQ';
     $zvalue=$bbq;
     $ztriv=1;
     include('ele_select.php');
     
     $zid='piscina';
     $zlabel='Piscina';
     $zvalue=$piscina;
     $ztriv=1;
     include('ele_select.php');
     
     $zid='jacuzzi';
     $zlabel='Jacuzzi';
     $zvalue=$jacuzzi;
     $ztriv=1;
     include('ele_select.php');
     
     
     
}     
     
     
     
if(mb_stristr2('.liga.torn',$modu))
{
     $zid='descri';
     $zlabel='Descripción';
     $zvalue=$descri;
     $zwidth=40;
     $zrows=2;
     include('ele_input.php');
     
}
     
     // echo '<br>TIME E = '.date('H:i:s');
     
     
if(mb_stristr2('.mtch',$modu))
{

     $zid='liga';
     $zlabel='Liga';
     $zvalue=$liga;
//      $zlist='dl_liga';
     $ztabla='liga';
     $zonblur='{location.href="?scri='.basename(__FILE__,'.php').'&modu="+document.getElementById("modu").value+"&liga="+document.getElementById("liga").value;}';
     $zonchange=$zonblur;
//      include('ele_input.php');
     include('ele_select.php');


     $zid='torn';
     $zlabel='Torneo';
     $zvalue=$torn;
     $ztabla='torn';
//      $zlist='dl_torn';
     $zwhere='torn_liga="'.$liga.'"';
//      $ztodo=1;     
     $zonblur='{location.href="?scri='.basename(__FILE__,'.php').'&modu="+document.getElementById("modu").value+"&liga="+document.getElementById("liga").value+"&torn="+document.getElementById("torn").value;}';
     $zonchange=$zonblur;
     include('ele_select.php');

$zobj=1;     
include('ele_break.php');
     
     $zid='jornada';
     $zlabel='Jornada';
     $zvalue=$jornada; 
     $zdefa=1;
     $zoptn1=1;     
     $zoptn2=30;     
     include('ele_select.php');  
     
     
     
     $zid='fecha';
     $ztype='date';
     $zlabel='Fecha';
     $zmin=date('Y-m-d',strtotime('-7 days'));
     $zmax=date('Y-m-d',strtotime('+300 days'));
     $zvalue=$fecha;
     include('ele_input.php');  

     $zid='hora';
     $ztype='time';
     $zlabel='Hora';
     $zvalue=$hora;
     $zmin='06:00';
     $zmax='23:00';
     $zstep=300; 
     $zdefa='12:00';
     include('ele_input.php');  
     
if(!empty($torn))
{
     $zobj=1;     
     include('ele_break.php');
     
     $zid='team1';
     $zlabel='Home';
     $zvalue=$team1;
     $ztabla='team';
     $zwhere='(team_codigo!="'.$team2.'")';
     $zonchange='{fn_consulta(event);}';
     include('ele_select.php');
     
     $zid='team2';
     $zlabel='Guest';
     $zvalue=$team2;
     $ztabla='team';
     $zwhere='(team_codigo!="'.$team1.'")';
     $zonchange='{fn_consulta(event);}';
     include('ele_select.php');

  
//      if(!empty($team1) and !empty($team2))
//        {
//           if($team1==$team2)
//             {
//                $save_erro = "eqipos iguales..." ;
//             }
//        }

}
     

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

     
// echo '<span style="float:right; white-space:nowrap;">';     
// echo $msgres;
// echo '</span>';     
     
     
// TITULO     
     
     

}     
// include('ele_break.php');
echo '</div>';


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

echo '<div id="main2" >';

$sql_idx=1;

//if(1==2)     
for($idx=1; $idx<=$sql_idx; $idx++)
{
     if(gettype($res_info)!='NULL')
     {
          $zreso=$res_info;
          $zinfo=$info;
          $zname=$zname;
          $zhead=0;
          $zgfsize=0.9;
//           $zblockrows=3;
//           $zheightrow='1.5em;';
          $zheightrow='3em;';
          $zblockidnum=1;
          include('ele_grid.php');     
          
//           if($info=='vtblog')
//           {if($idx<msql_num_rows($res_krdx)){echo '<div id="pgbreak" style="height:2em;"></div>';}}
          

//           echo '======='.$modu;
          
          
          
          

     }
}     

echo '</div>';     


          if(!empty($codigo))
          if(mb_stristr2('item.bbii.plvh.trty.mdvh',$modu))
          {
               $zid=$codigo;
               $ztabla=$modu;
               $zcodigo=$codigo;
               {
                    $zcarr=0;
                    $zupld=1;
                    $zobj=2;
               }
               $zalign='center';
               include('ele_image.php');  
          }


     // echo '<br>TIME Z = '.date('H:i:s');


?>

<script>
function fn_nuevo(event)
{
     var enti;
     swal.fire({
          icon:'warning',
          title:'Nuevo Codigo',
          text:'Continuar ?',
          confirmButtonText:'Nuevo',
          confirmButtonColor:color1,
          focusCancel:true,
          showCancelButton:true,
          cancelButtonColor: 'darkred',
          timer:10000
     }).then((result) => 
          {
               if(result.isConfirmed)
               {
//                     fn_consulta();
                    var xhref='';
                    xhref=xhref+'?scri=<?php echo basename(__FILE__,'.php');?>';
                    xhref=xhref+'&modu=<?php echo $modu;?>';
                    xhref=xhref+'&grupo=<?php echo $grupo;?>';
//                document.getElementById("main2").innerHTML='Espere...';
                    location.href=xhref;
               }
          })
}     
     
</script>

<script>
function calc_precio(event,id='')
{
     var puni1,puni2,puni3,puni4,puni5;
     var pvp1,pvp2,pvp3,pvp4,pvp5;
     var dcto1,dcto2,dcto3,dcto4,dcto5;
     var puni,pvp,iva,ice,idx;
     var puni_0,puni_1,puni_2,puni_3,pvp_1,pvp_2,pvp_3;
     
     
     
     for (idx=2; idx<=5; idx++)
     {
          document.getElementById('puni'+idx).max=document.getElementById('puni'+(idx-1)).value;
          document.getElementById('pvp'+idx).max=document.getElementById('pvp'+(idx-1)).value;
     }     

     
     iva=document.getElementById('iva').value;
     ice=document.getElementById('ice').value;
//      if(document.getElementById(id))
     {
//           if(event.keyCode==13)
          {
               if(id.indexOf('puni')>=0)
               {
                    puni=document.getElementById(id).value;
                    pvp=puni*(1+iva/100);
                    pvp=pvp.toFixed(6);
                    document.getElementById('pvp'+id.substr(-1)).value=pvp;
               }
               if(id.indexOf('pvp')>=0)
               {
                    pvp=document.getElementById(id).value;
                    puni=pvp/(1+iva/100);
                    puni=puni.toFixed(6);
                    document.getElementById('puni'+id.substr(-1)).value=puni;
               }
               
               if(id.indexOf('iva')>=0)
               {
                    for(idx=1; idx<=5; idx++)
                    {
                    puni=document.getElementById('puni'+idx).value;
                    pvp=puni*(1+iva/100);
                    pvp=pvp.toFixed(6);
                    document.getElementById('pvp'+idx).value=pvp;
                    }
               }
               
          }
     }
     
     
     puni_0=document.getElementById('puni1').value;
     for (idx=2; idx<=4; idx++)
     {
          puni_1=document.getElementById('puni'+(idx-1)).value;
          puni_2=document.getElementById('puni'+(idx)).value;
          puni_3=document.getElementById('puni'+(idx+1)).value;
          if(puni_2>0)
          {
               if(puni_0==0)
               {
                    document.getElementById('puni'+(idx)).value=0;
                    Swal.fire({
                      title: 'Error en Precio 1',
                      text: 'Debe Especificar PRECIO 1',
                      icon: 'error',
                    })
                    document.getElementById('puni1').focus();
                    document.getElementById('puni1').value=puni_2;
                    return;
               }
               
               if(puni_2>=puni_1)
               {    
                    document.getElementById('puni'+(idx)).value=0;
                    if(puni_1>=(1/100))
                    {document.getElementById('puni'+(idx)).value=document.getElementById('puni'+(idx-1)).value-(1/100);}
                    
                    Swal.fire({
                      title: 'Error en formato',
                      text: 'El precio '+(idx)+' debe ser menor al precio '+(idx-1),
                      icon: 'error',
                    })
                    return;
               }
                    
          }
     }
     
     
     
}
     
</script>

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

     xhref=xhref+'&codigo='+document.getElementById('codigo').value;
     dataget=new_FormData('filtros','get');
     xhref=xhref+dataget;
     location.href=xhref;
}
</script>

<script>document.title="<?php echo $xtitle;?>"</script>
<script>document.getElementById('topcenter').innerHTML="<?php echo $xtopcenter;?>"</script>
<!-- <script>set_noback();</script> -->
<!-- <script>window.onbeforeunload = function(){return 'Are you sure you want to leave?';};</script> -->

<script>
function upld_pk12(tabla,codigo,idfile,p12pass)
{
     var color1=document.getElementById('color1').innerHTML;
     var color2=document.getElementById('color2').innerHTML;
     
     var xfile=document.getElementById(idfile);
     if(xfile.files.length==0)
     {
          document.getElementById(idfile).click();
          return;
     }
     
     if(p12pass=='')
     {
          Swal.fire({
            title: 'Falta Clave de Archivo',
            text: 'Asigne una Clave',
            icon: 'error',
//             focusCancel: true,
//             showCancelButton: true,
//             confirmButtonColor: color1,
//             cancelButtonColor: 'darkred',
//             confirmButtonText: 'SI, Subir!'
          })
          return;
     }
          
     Swal.fire({
       title: 'Subir Archivo ?',
       text: document.getElementById(idfile).files.length+' Firma',
       icon: 'warning',
       focusCancel: true,
       showCancelButton: true,
       confirmButtonColor: color1,
       cancelButtonColor: 'darkred',
       confirmButtonText: 'SI, Subir!'
     }).then((result) =>
     {
          if (result.isConfirmed){
               var data;
               for(var idx=0; idx<xfile.files.length; idx++)
               {
                    data=new FormData();
                    data.append('script','upld_pk12');
                    data.append('tabla',tabla);
                    data.append('codigo',codigo);
                    data.append('xfile',xfile.files[idx]);
                    data.append('p12pass',p12pass);
                    exe_ajax(data,'','',false);
               }
          }
     })
     
}
</script>

<script>
function upld_logo(tabla,enti,idfile,tipo,ptoe='001001')
{
     var color1=document.getElementById('color1').innerHTML;
     var color2=document.getElementById('color2').innerHTML;
     
     var xfile=document.getElementById(idfile);
     
//      alert(xfile);return;
     
     if(xfile.files.length==0)
     {
          document.getElementById(idfile).click();
          return;
     }
          
     
     
     Swal.fire({
       title: 'Subir Archivo ?',
       text: document.getElementById(idfile).files.length+' Imagen',
       icon: 'warning',
       focusCancel: true,
       showCancelButton: true,
       confirmButtonColor: color1,
       cancelButtonColor: 'darkred',
       confirmButtonText: 'SI, Subir!'
     }).then((result) =>
     {
          if (result.isConfirmed){
               var data;
               for(var idx=0; idx<xfile.files.length; idx++)
               {
                    data=new FormData();
                    data.append('script','upld_logo');
                    data.append('tabla',tabla);
                    data.append('enti',enti);
                    data.append('codigo',enti);
                    data.append('tipo',tipo);
                    data.append('ptoe',ptoe);
//                     data.append('codigo',codigo);
                    data.append('xfile',xfile.files[idx]);
                    exe_ajax(data,'','',false);
               }
          }
     })
     
}
     
</script>



