<?php 
declare(strict_types=0);
// session_start();
foreach($_GET as $campo => $valor){${$campo}=trim($valor);} 
foreach($_POST as $campo => $valor){${$campo}=trim($valor);} 
include_once('lib_main.php');

if(!empty($empr)){$link_data=msql_connect('','','',$empr); $cfg_empr=$empr;}


if(empty($publicador)){$publicador=$_COOKIE['publicador'];}
if(empty($trty)){$trty=$_COOKIE['trty'];}
if(empty($bloq)){$bloq=$_COOKIE['bloq'];}




$user_codigo=$_SESSION['user_codigo'];
$user0=data_maes('user',$user_codigo);
// $cong0=data_maes('cong',$_SESSION['user_cong']);
$cong0=data_maes('cong',$cong);

if(!empty($cong) and !empty($trty) and !empty($rtrt))
{
     $sql_jwrt ='select *, adddate(fecha,ifnull(plazo,0)) as vence  ';
     $sql_jwrt.='from jwrt1 ';
     $sql_jwrt.='where ifnull(status,"")not in("O","X") ';
     $sql_jwrt.='and cong="'.$cong.'" ';
     $sql_jwrt.='and trty="'.$trty.'" ';
     $sql_jwrt.='and idnum1="'.$rtrt.'" ';
     $res_jwrt=msql_query($sql_jwrt,$link_data);
     $aso_jwrt=msql_fetch_assoc($res_jwrt);
     if($aso_jwrt['vence']>=date('Y-m-d')){$user_codigo=1;}
     else{echo '**** TERRITORIO VENCIDO ****'; die();}
}

// if($login_pass==0)
if(empty($rtrt))
if(empty($user_codigo)){include('user_login0.php');return;}

$modu='jwrv';
$info='rvblog';
$info_descri='REG.VISITAS';

// if($cfg_empr=='tfle'){$tpos=2;}


$modu=strtolower($modu);
// $docu=strtoupper($docu);
$tabla=$modu;

if($info=='rvblog'){$info_descri='REG.VISITAS';}


if(!mb_stristr('sist.supe',$user0['user_tipo']))
{$enti=$user0['user_cedula'];}

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

$docu0=data_maes('docu',$docu);
$enti0=data_maes('enti',$enti);
// $asub0=data_maes('asub',$asub);


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


$xtitulo='REG.VISITAS';
if($modu=='jwrv'){$xtitulo='REG.VISITAS';}

$xtitle=''.$xtitulo;
$xtopcenter=$xtitle;

// $fecha0=fecha0($modu);
$fecha0=date('Y-m-01',strtotime('-12 month'));

if(empty($fecha)){$fecha=date('Y-m-d');}

$fecha_min=date('Y-m-d',strtotime('-7 days'));
$fecha_max=date('Y-m-d');

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


// if($fecha==date('Y-m-d'))
// {
// $fecha1=date('Y-m-d');
// $fecha2=date('Y-m-d');
// }
$fecha1=$fecha;
$fecha2=$fecha;


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

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



// echo '*/*/*/*/';
// echo sal_item2('20109837');


//  SELECT DB
if(!empty($publicador))
{include('sele_info.php');}

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

// PANTALLA FILTROS
echo '<div id="filtros" style="font-size:; zoom:125%;" >';
{
     
// OCULTOS
echo '<div hide>';   
{
echo '<input id="idnum" value="'.$idnum.'">';
echo '<input id="rtrt" value="'.$rtrt.'">';
echo '<input id="lock" value="'.$lock.'">';
echo '<input id="prnt" value="'.$prnt.'">';
// echo '<input id="cong" value="'.$cong0['cong_codigo'].'">';
}     
     
echo '</div>';     
     
// {$ztitulo='FILTROS'; include('ele_title.php');}
// {$ztitulo='INVENTARIOS'; include('ele_title.php');}


$docu='RVST';     
     
$ztabla='docu';
$zwhere='(docu_codigo="XXXX")';
$zid='dl_plan';     
include('ele_datalist.php');
     
     
$ztabla='cong';
include('ele_datalist.php');

// echo '==='.$cong0['cong_codigo'];
     
$ztabla='trty';
if(!empty($cong))    
{$zwhere='(trty_cong="'.$cong.'")';}
// $zwhere='(trty_cong="'.$cong0['cong_codigo'].'")';
include('ele_datalist.php');

     
$zid='dlbloq';
$zdocu=$docu;
$zwhere='(cong="'.$cong0['cong_codigo'].'")';     
$zcolu='bloq';   
include('ele_datalist.php');
     
$zid='dlndpto';
$zdocu=$docu;
$zwhere='(cong="'.$cong0['cong_codigo'].'" and trty="'.$trty.'")';     
$zcolu='ndpto';   
include('ele_datalist.php');
     
$zid='dltema';
$zdocu=$docu;
// $zwhere='(cong="'.$cong0['cong_codigo'].'" and trty="'.$trty.'")';     
$zcolu='tema';   
include('ele_datalist.php');
     
$zid='dltexto';
$zdocu=$docu;
// $zwhere='(cong="'.$cong0['cong_codigo'].'" and trty="'.$trty.'")';     
$zcolu='texto';   
include('ele_datalist.php');
     
$zid='dlpreg';
$zdocu=$docu;
// $zwhere='(cong="'.$cong0['cong_codigo'].'" and trty="'.$trty.'")';     
$zcolu='tema';   
include('ele_datalist.php');
     
     
// $ztabla='clie';
// $zwhere='(left(clie_codigo,10) in(select distinct left(enti,10) from plan1))';
// $zmaintag='datalist';     
// include('ele_select.php');
     
     
     
// $ztabla='asub';
// include('ele_datalist.php');
     
// $ztabla='lote';
// include('ele_datalist.php');
     
$ztabla='docu';
$zwhere='(docu_tabla="jwrv")';
include('ele_datalist.php');

     
$zid='nomb_info';
$ztabla='nomb';
$zcolu='nomb_nombre';
$zwhere='(';
$zwhere.='nomb_cong="'.$cong0['cong_codigo'].'"  ';
$zwhere.='and nomb_lused>="'.$fecha0.'" ';
// $zwhere.='and nomb_cant>=3 ';     
$zwhere.='and nomb_nombre not like "%.%" ';
$zwhere.=')';
include('ele_datalist.php');
     
     
     
     
// $zobj=2;     
// include('ele_break.php');

// view_maes('enti','clie');     

$zid='docu';
$ztabla='docu';
$zlabel='Documento';
$zvalue=$docu;
$zreado=1;     
$zhide=1;     
include('ele_select.php');
          
// $ptoe='001001';     
// $zid='ptoe';
// $ztabla='ptoe';
// $zlabel='Pto.Emi.';
// $zvalue=$ptoe; 
// $zhide=1;     
// include('ele_select.php');
          
     
         
// $zid='enti';
// $ztabla='enti';
// $zlabel='Usuario';
// $zvalue=$enti; 
// $zmaxwidth=20;     
// if(!empty($enti)){$zreado=2;}
// $zwhere='((enti_codigo) in(select left(user_cedula,10) from user0 where user_tipo in ("sist","supe","admi") and user_status not in("I","X")))';     
// $zonblur='{location.href="?scri='.basename(__FILE__,'.php').'&enti="+document.getElementById("enti").value;}';
// $zonchange=$zonblur;
// include('ele_select.php');


// $zobj=1;     
$zid='cong';
$zlabel='Cong.';
$zvalue=$cong0['cong_codigo'];
$ztabla='cong';     
$zreado=1;     
$zhide=1;     
include('ele_input.php');  


     
// $zobj=1;
// include('ele_break.php');
     
// 🏘
//      📌
// echo '===='.$cong;     
$zid='trty';
$zlabel='🗺️ Territorio';
$zvalue=(int)$trty;
$zvalue=$trty;     
$ztabla='trty';
$zsize=0.8;
// if(!empty($zvalue)){$zreado=2;}     
if(!empty($zvalue) and $prnt==1){$zreado=2;}     
$zexact=1;     
if(!empty($cong))     
{$zwhere='(trty_cong="'.$cong.'")';}
// $zwhere='(trty_cong="'.$cong0['cong_codigo'].'")';
include('ele_select.php');

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

     
     
// if($linux==1 or $android==1)     
// {$zobj=1;}
$zid='fecha';
$ztype='date';
$zlabel='Fecha';
$zvalue=$fecha;
$zmin=$fecha_min;     
$zmax=$fecha_max;
$zreado=2;     
if($lock==1)
{
     $zobj=1;
     $zreado=1;
     $ztype='';
}
include('ele_input.php');  

// $zid='hora';
// $ztype='time';
// $zlabel='Hora';
// $zvalue=date('H:00');
// $zmin='07:00';     
// $zmax='20:00';
// $zstep=5;     
// // $zreado=2; 
// include('ele_input.php');  

$uniclock=uni_clock(date('H:i'));     

// if($linux==1 or $android==1)     
// {$zobj=1;}
$zid='hora';
$zlabel=$uniclock.'Horario';
$zoptions='';
$zoptions.='1,🌞Mañana;';     
$zoptions.='2,🌇Tarde;';     
$zoptions.='3,🌙Noche';     
$zvalue=$hora;
if($lock==1)
{
     $zobj=1;
     $zreado=1;
}
if(empty($zvalue))
{
     $zvalue='1';
     if(date('H')>12){$zvalue='2';}     
     if(date('H')>18){$zvalue='3';}     
}     
$zexact=1;
     
// echo '======='.$_SESSION['orient'];     
include('ele_select.php');
     
     

$zobj=1;
include('ele_break.php');
     
// $zobj=1;
$zid='publicador';
$zvalue=$publicador;
$zlabel='Publicador';     
$zlist='nomb_info';
$zopen=1; 
$zwidth='auto';
// if(!empty($zvalue)){$zreado=2;}     
if($lock==1)
{
     $zobj=1;
     $zreado=1;
     $zlist='';
}
include('ele_input.php');

     
$zobj=1;
include('ele_break.php');
     
//           $zalign='right';
          $zobj=3;
          $zid='campana';
          $zvalue=$_COOKIE[$zid];
          $zlabel='Campaña';
//           $zwidth=20;
          $zoptions='';
          if(in_array(date('n'),[3,4]))
          {$zoptions.='🍷 Conmemoración;';}
          if(in_array(date('n'),[6,7,8]))
          {$zoptions.='🛐 Asamblea;';}
          $zoptions.='🔭 Atalaya;';
          $zoptions.='‼️ Despertad;'; //❗
          $zoptions.='📚 Folleto;';
//           $zexact=1;
if($lock==1)
{
     $zobj=1;
     $zreado=1;
}
          include('ele_select.php');


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

     
// $zobj=1;
// include('ele_break.php');
     
     
$zid='bloq';
$zlabel='🏘️Mz.Bloq.';
$zvalue=$bloq;
$zwidth=4;
$zonchange='{fn_consulta(event);}';
$zonblur='{fn_consulta(event);}';
$zlist='dlbloq';
$zsize=1.5;     
$zclass='numeric';     
if($lock==1)
{
     $zobj=1;
     $zreado=1;
     $zlist='';
     $zsize=1;
}
include('ele_input.php');
     
// $zobj=1;
// include('ele_break.php');
     
$zid='ndpto';
$zlabel='🏠№ Dpto.';
$zvalue=$ndpto;
$zwidth=4; 
$zlist='dlndpto';     
$zonblur='{fn_histov();}';
$zsize=1.4; 
$zmin=1.0;     
$zmax=999.9;     
$zclass='numeric-dec';     
if($lock==1)
{
     $zobj=1;
//      $zreado=1;
     $zlist='';
     $zsize=1;
     $zmin=$ndpto;
     $zmax=$ndpto+(0.9);
     $zstep=0.1;
}
include('ele_input.php');


$zobj=1;     
include('ele_break.php');
     
     
//      ❌⛔🛑🫥😠🚪🏚️😀😤😬😡😶🤬🤐🫥🕸️

     
$zid='visita';
$zlabel='Tipo';
$zoptions='';
// $zoptions.='a,❌⛔🛑🫥😠🚪🏚️😀😤😬😡😶🤬;';  🆗   ❎✖️
$zoptions.='PV,⏳ Pendiente;';          
$zoptions.='NC,✖️ Nadie en Casa;';     
$zoptions.='OC,🤐 Ocupado;';     
$zoptions.='OK,🆗 Visita OK;';     
$zoptions.='NT,😡 No Tocar;';     
$zoptions.='DH,🕸️ Deshabitada;';
     
$zvalue=$visita;
if(empty($zvalue)){$zvalue='PV';}
     
$zexact=1;
$ztype='radio';
// $zorient=2;     
include('ele_select.php');
     

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

$zid='btn_grabar'; 
$zlabel='Grabar';
$zalign='right';
$zvalign='bottom';
$zsize=1.3;
$zonclick='{save_docu(event);}';
include('ele_button.php');
     
     
     
     
     
     
     
     
if(1==1)
{
   
     
$zobj=2;
include('ele_break.php');
// $zobj=1;
// include('ele_break.php');


// $zobj=1;
$zid='persona';
$zvalue='';
$zlabel='Nombre';     
$zwidth='auto';
include('ele_input.php');

     
     
$zobj=1;
$zid='sexo';
$zlabel='Sexo';
$zoptions='';
// $zoptions.='0,⚤ Sexo;';
$zoptions.='1,♂️ Hombre;';
$zoptions.='2,♀️ Mujer;';
$zvalue=$zsexo;   
$zexact=1;
// $zhide=1;     
$ztype='radio';
$zorient=2;
include('ele_select.php');
     
// $zobj=1;
// include('ele_break.php');
     
     
     

// &#128523;  &#128526;     &#128528;  &#129299;
     
$zid='etario';
$zlabel='Etario';
$zoptions='';
$zoptions.='Adulto,😐 Adulto;';
$zoptions.='Mayor,🤓 Mayor;';
$zoptions.='Joven,😎 Joven;';
$zoptions.='Infante,😋 Infante;';
// $zoptions.='Adolescente;';
// $zoptions.='N/A;';
$zdefa='N';     
$zvalue=$zedad;   
$zexact=1;
$ztype='radio';
$zdefa='A';     
include('ele_select.php');
     
     
// $zobj=1;
     
}     

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


$zid='texto';
$zlabel='📖 T. Bíblico';
$zoptions='';
// $zvalue=$tema;
$zlist='dltexto';     
$zwidth=10;
include('ele_input.php');

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

     
     
$zid='public';
$zlabel='Publicación';
$zoptions='';
$zoptions.='No Aplica;';     
$zoptions.='Tratado;';     
$zoptions.='Revista;';     
$zoptions.='Folleto;';     
$zoptions.='Libro;';     
$zoptions.='Video;';     
$zvalue='';     
$zexact=1;
// $ztype='radio';     
include('ele_select.php');

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

     
     
$zid='objecion';
$zlabel='Objeción';
$zoptions='';
$zoptions.='No Aplica;';     
$zoptions.='Estoy Ocupado;';     
$zoptions.='Ya Tengo Religión;';     
$zoptions.='Ateo;';     
$zoptions.='Muy Enojado;';     
$zvalue='N';     
$zexact=1;
$zhide=1;     
include('ele_select.php');

     
     
if(1==1)
{     
     
$zobj=2;     
include('ele_break.php');
     
$zid='tema';
$zlabel='Tema Conv.';
$zoptions='';
// $zvalue=$tema;
$zlist='dltema';     
$zwidth='90%';
// $zrows=2;
include('ele_input.php');

     
$zobj=1;     
include('ele_break.php');
     
$zid='pregunta';
$zlabel='Preg.Pendt.';
$zoptions='';
// $zvalue=$tema;
$zlist='dlpreg';     
// $zwidth=20;
$zwidth='90%';
// $zrows=2;
include('ele_input.php');
     

     
}     
     
     
     
     
     
$zobj=2;
include('ele_break.php');
     
$zid='observacion';
$zvalue='';
$zlabel='Observación';
$zwidth=20;
$zrows=2;     
include('ele_input.php');
     

     
     
     
// if(!empty($enti))
{
     
$zid='btn_consul'; 
$zlabel='Consultar';
$zalign='right';
// $zonclick='{fn_consulta(event);}';
$zonclick='{document.getElementById("fecha1").value="";document.getElementById("fecha2").value="";fn_consulta(event);}';
$zhide=1;     
include('ele_button.php');

// echo '<span style="float:right; white-space:nowrap;">';     
// echo $msgres;
// echo '</span>';     
     
     
// $zobj=2;     
// include('ele_break.php');
     

// $zid='detalle';
// $zlabel='Notas';
// $zwidth=25; 
// $ztype='area';     
// $zvalue=$detalle;
// // $zrows=4;     
// include('ele_input.php');
     

     

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

     

}     
// include('ele_break.php');


// RESULTADO
$sty_resu='float:right;';
$sty_resu='margin:0 auto;';

echo '<span id="main2" style="'.$sty_resu.'"  >';

$sql_idx=1;

// 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='3';
          $zblockidnum=1;
          $zhidebtns=1;
//           $zwidthtable='100%';
          $znolin=1;
          include('ele_grid.php');     
          

     }
}     

echo '</span>';     

echo '</div>';

echo '<div style="height:1em;"></div>';     



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

     $div=$dom_div->appendChild($dom_div->createElement("div",""));
          $div->setAttribute("id","divextra1");
          $div->setAttribute("align","center");
          $div->setAttribute("height","auto");
          $div->setAttribute("unselectable","on");
          $div->setAttribute("onmousedown","return false;");
          $div->setAttribute("onselecstart","return false;");
          $div->setAttribute("style","margin-top:0em;");
echo $dom_div->saveHTML();


?>


<script>
function fn_histov(event)
{
//      return;
     var busca,xsrc='?';
     var cong,trty,bloq,ndpto;
//      busca=document.getElementById('cstock').value;
     
     cong=document.getElementById('cong').value;
     trty=document.getElementById('trty').value;
     bloq=document.getElementById('bloq').value;
     ndpto=document.getElementById('ndpto').value;
     
     document.getElementById('divextra1').innerHTML='';
//      if(busca.length>3)
     {
          var datapost,dato;
          datapost=new FormData();
          datapost.append('script','info_modu3');
          datapost.append('modu','jwrv');
          datapost.append('info','rvdeta');
//           datapost.append('prec','pvp');
          datapost.append('prnt','1');
          datapost.append('zhidebtns','1');
          datapost.append('zhidehead','1');
          
          datapost.append('fecha1','<?php echo date('Y-m-01',strtotime('-6 month'));?>');
          datapost.append('fecha2','<?php echo date('Y-m-d',strtotime('-1 day'));?>');
          
//           alert(cong);
          datapost.append('cong',cong);
          datapost.append('trty',trty);
          datapost.append('bloq',bloq);
          datapost.append('ndpto',ndpto);
          dato=exe_ajax(datapost,'divextra1','',true);
     
     }
     
}
</script>


<script>
function fn_consulta(event)
{
     var xhref='',dataget;
     xhref=xhref+'?scri=<?php echo basename(__FILE__,'.php');?>';
     
     dataget=new_FormData('filtros','get');
     xhref=xhref+dataget;
     
     document.getElementById("main2").innerHTML='Espere...';
     location.href=xhref;
     
}
</script>



<script>document.title="<?php echo $xtitle;?>"</script>
<script>
     if(document.getElementById('topcenter'))
     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> -->

