<?php
declare(strict_types=0);
// graphemica.com

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

if(!empty($zdomX)){$domd_e=$zdomX;}
if(!empty($zeleX)){$elem_e=$zeleX;}



$sql_docu='select * from docu0 where docu_codigo like "'.$zevento.'%"';
$res_docu=msql_query($sql_docu,$link_data);
$tabla=msql_result($res_docu,0,'docu_tabla');
$tabla1=$tabla.'1';

$xhora1=$zhora;

$xhora2=$xhora1;
$xhora2=(substr($xhora2,0,2)*60) +substr($xhora2,2,2) +$zmin_fra;
$xhora2= intdiv($xhora2/60).':'.($xhora2 % 60);

if($zhora_inco==1){$xhora2=$xhora1.'1';}

if($tabla=='jwmc')
{
     $sql_evnt ='select * ';
     $sql_evnt.='from '.$tabla1.' ';
     $sql_evnt.='left join docu0 on docu=docu_codigo ';
     $sql_evnt.='left join trty0 on trty=trty_codigo ';
     $sql_evnt=calc_fields($tabla,$sql_evnt);
     $sql_evnt.='where ifnull(status,"") not in ("O","X") ';
     $sql_evnt.='and docu  like "'.$zevento.'%" ';
     $sql_evnt.='and fecha="'.$zfecha.'" ';
     $sql_evnt.='and hora >= "'.$xhora1.'" ';
     $sql_evnt.='and hora < "'.$xhora2.'" ';
     if(($edit!=1))
     {$sql_evnt.='and length(nombre1)>3 ';}
     $sql_evnt.='group by idnum1 ';
     $sql_evnt.='order by hora,trty_sector,lugar ';
     $res_evnt=msql_query($sql_evnt,$link_data);
     
//      echo '<br>=== '.$sql_evnt;
     
     while($aso_evnt=msql_fetch_assoc($res_evnt))
     {
//           if(!empty($aso_evnt['hora']))
          {

//           ☀️🌅🌄    🌇  🌆🌃🌙
          $hora_icon='🌅';     
          if((int)$aso_evnt['hora']>=9){$hora_icon='☀️';}
          if((int)$aso_evnt['hora']>=18){$hora_icon='🌇';}
          if((int)$aso_evnt['hora']>=19){$hora_icon='🌙';}
          $hora_icon=' ';               
                         
               
          $e_div=$elem_e->appendChild($domd_e->createElement("div"," "));
               $e_div->setAttribute("style","margin-top:0.1em; margin-bottom:0.1em; background-color:".$aso_evnt['trty_color'] .";");
               
          if($zhora_inco==1)
          {
               $e_hora=$e_div->appendChild($domd_e->createElement("div", uni_clock($aso_evnt['hora']).$aso_evnt['hora'] ));
               $e_hora->setAttribute('hide','');
               $e_docu=$e_div->appendChild($domd_e->createElement("div",$aso_evnt['docu_icon']));
          }
               
          if($zhora_inco!=1)
          {
               $e_hora=$e_div->appendChild($domd_e->createElement("div", uni_clock($aso_evnt['hora']).$aso_evnt['hora'] ));
                    $e_hora->setAttribute('float-l','');
               $e_docu=$e_div->appendChild($domd_e->createElement("div",$aso_evnt['docu_icon']));
                    $e_docu->setAttribute('float-r','');
               
               $e_divx=$e_div->appendChild($domd_e->createElement("div",$hora_icon));
                    $e_divx->setAttribute('style','height:1.5em;color:'.$aso_evnt['trty_color'].';');
          }
          $e_hora->setAttribute('size120','');
          $e_docu->setAttribute('size140','');
               
//           $e_lugar=$e_div->appendChild($domd_e->createElement("div", '🏠'.$aso_evnt['lugar']));
          $e_trty=$e_div->appendChild($domd_e->createElement("div", '🗺️ '.$aso_evnt['trty_sector']));
               $e_trty->setAttribute('bold','');
               
//           $e_divx=$e_div->appendChild($domd_e->createElement("div",'.'));
//                🧍

          if(($edit!=1))
          {
               $e_nombre1=$e_div->appendChild($domd_e->createElement("div", '🔹'.strtoupper($aso_evnt['nombre1'])));
               $e_nombre2=$e_div->appendChild($domd_e->createElement("div", '🔹'.strtoupper($aso_evnt['nombre2'])));
          }
          if($edit==1)
          {
               $zdom=$domd_e;
               $zele=$e_div;
               if(!empty($zdomX))
               {
//                $zdom=$zdomX;
//                $zele=$zeleX;
               }
               $zid='nombre1'.$aso_evnt['idnum1'];
               $zobj=1;
               $zvalue=$aso_evnt['nombre1'];
               $zsave=1;
               $zsavet=$tabla;
               $zsavef='nombre1';
               $zsavei=$aso_evnt['idnum1'];
               if($aso_evnt['docu']=='MDC5')
               {$zlist='nomb_mdc5';}
               $ztxt=2;
               include('ele_input.php');
               
               $zdom=$domd_e;
               $zele=$e_div;
               if(!empty($zdomX))
               {
//                $zdom=$zdomX;
//                $zele=$zeleX;
               }
               $zid='nombre2'.$aso_evnt['idnum1'];
               $zobj=1;
               $zvalue=$aso_evnt['nombre2'];
               $zsave=1;
               $zsavet=$tabla;
               $zsavef='nombre2';
               $zsavei=$aso_evnt['idnum1'];
               if($aso_evnt['docu']=='MDC5')
               {$zlist='nomb_mdc5';}
               $ztxt=2;
               include('ele_input.php');
               
               
          }
               
          
//           $e_hr=$e_div->appendChild($domd_e->createElement("hr",""));
//                $e_hr->setAttribute("color",$empr0['empr_color1']);
//                $e_hr->setAttribute("size","1");
//                $e_hr->setAttribute("width","100%");
          }
     }

     
     
     
}


if(empty($zdomX))
{
     if($zxml==1){$zxml=$domd_e->saveHTML();}
     else{echo $domd_e->saveHTML();}
}     
return;




?>