<?php
declare(strict_types=0);
foreach($_GET  as $key => $value){${$key}=trim($value);$_PARAMS[$key]=${$key};}  
foreach($_POST as $key => $value){${$key}=trim($value);$_PARAMS[$key]=${$key};}
// echo '<meta http-equiv="refresh" content="10">';

include_once('lib_main.php');

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

$pgsize=strtoupper($pgsize);
$tkwidth=0;
if(empty($pgsize)){$pgsize='A4-V';}
if(substr($pgsize,0,1)=='P'){$tkwidth=(int)substr($pgsize,-2,2); $pgsize='POST'; $post=1;   }

if(substr($pgsize,0,1)=='T')
{
     $tkwidth=(int)(substr($pgsize,-2,2));     
     $pgsize='TCKT'; $post=1; $tckt=1;
}

if(!empty($empr)){$link_data=msql_connect('','','',$empr); $cfg_empr=$empr;}
$user_codigo=$_SESSION['user_codigo'];
if(mb_stristr('MMAE.',$info))
{
     $docu='VM3';
     $sql_jwib='select *, ';
     $sql_jwib.='date_format(fechar,"%d / %M / %Y") as fechadmy,';   
     $sql_jwib.='date_format(fecha,"%x-%v") as fsema,';   
     $sql_jwib.='status as st1 ';
     $sql_jwib.='from jwib1 ';
     $sql_jwib.='left join docu0 on docu=docu_codigo ';
     $sql_jwib.='left join orat0 on orat=orat_codigo ';
     $sql_jwib.='left join jwol0 on(fecha=jwol_fecha) ';
     // $sql_jwib=calc_fields('jwib',$sql_jwib);
     $sql_jwib.='where ifnull(status,"-") not in ("O","X") ';
     if(empty($idnum))
     {
          $sql_jwib.='and cong="'.$cong_codigo.'" ';
          $sql_jwib.='and docu like "'.$docu.'%" ';
          if(!empty($ames))
          {$sql_jwib.='and date_format(fecha,"%x-%m")="'.$ames.'"';}
          if(!empty($sema))
          {$sql_jwib.='and date_format(fecha,"%x-%v")="'.$sema.'"';}
          if(!empty($sala))
          {$sql_jwib.='and sala = "'.$sala.'" ';}
     }
     if(!empty($idnum))
     {$sql_jwib.='and idnum1= "'.$idnum.'" ';}
     $res_jwib=msql_query($sql_jwib,$link_data);
     
//      echo $sql_jwib;
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {

          $jwol_smm='';
          if($aso_jwib['docu']=='VM30'){$jwol_smm=$aso_jwib['jwol_smm0'];}
          if($aso_jwib['docu']=='VM31'){$jwol_smm=$aso_jwib['jwol_smm1'];}
          if($aso_jwib['docu']=='VM32'){$jwol_smm=$aso_jwib['jwol_smm2'];}
          if($aso_jwib['docu']=='VM33'){$jwol_smm=$aso_jwib['jwol_smm3'];}
          if($aso_jwib['docu']=='VM34'){$jwol_smm=$aso_jwib['jwol_smm4'];}
          $jwol_smm=trim($jwol_smm);

          $jwol_array=explode('<br>',$jwol_smm);
          if(count($jwol_array)<=3)
          {$jwol_smm=$jwol_array[0].' '.$jwol_array[1].' '.$jwol_array[2].' '.$jwol_array[3].' '.$jwol_array[4];}
          else
          {$jwol_smm=$jwol_array[0].' '.$jwol_array[1].'<br>'.$jwol_array[2].' '.$jwol_array[3].' '.$jwol_array[4];}

          if(!empty($jwol_smm))
          {
               $xmins=$jwol_smm;

               if(mb_stristr($xmins,'mins.)'))
               {
                    $xmins=substr($xmins,0,strpos($xmins,'mins.)')+6);
                    $xmins=substr($xmins,strrpos($xmins,'('));
               }

               if(mb_stristr($xmins,'min.)'))
               {
                    $xmins=$jwol_smm;
                    $xmins=substr($xmins,0,strpos($xmins,'min.)')+5);
                    $xmins=substr($xmins,strrpos($xmins,'('));
               }

               $jwol_smm=str_replace('<div','<span',$jwol_smm);
               $jwol_smm=str_replace('</div>','</span>',$jwol_smm);
               $jwol_smm=str_replace($xmins,'',$jwol_smm);
               $jwol_smm=str_replace('<p','<span> '.$xmins.'</span>'.'<p',$jwol_smm);

               $jwol_smm=str_replace('http://wol.jw.orghttps:','https:',$jwol_smm);
               $jwol_smm=str_replace('<br>.','.<br>',$jwol_smm);
               $jwol_smm=str_replace('<br>)',')',$jwol_smm);
               $jwol_smm=str_replace('<br>','<div></div>',$jwol_smm);

               $jwol=$jwol_smm;

//                📖📒📚🗣️💬🎞️✋📓
               if(mb_stristr($jwol_smm,'LECTURA')){$jwol_smm='📖 '.$jwol_smm;}
               if(mb_stristr($jwol_smm,'CONVERSA')){$jwol_smm='👫 '.$jwol_smm;}
               if(mb_stristr($jwol_smm,'REVISITA')){$jwol_smm='📒 '.$jwol_smm;}
               if(mb_stristr($jwol_smm,'ESTUDIO')){$jwol_smm='📚 '.$jwol_smm;}
               if(mb_stristr($jwol_smm,'HAGA D')){$jwol_smm='📚 '.$jwol_smm;}
               if(mb_stristr($jwol_smm,'DISCURSO')){$jwol_smm='🗣️ '.$jwol_smm;}
               if(mb_stristr($jwol_smm,'VIDEO')){$jwol_smm='🎞️ '.$jwol_smm;}
               if(mb_stristr($jwol_smm,'AUDITORIO')){$jwol_smm='✋ '.$jwol_smm;}

          }



          $zdocu=$aso_jwib['docu'];
          $zidnum=$aso_jwib['idnum1'];
          $zfecha=ucwords($aso_jwib['fechadmy']);
          $znombre1=strtoupper($aso_jwib['nombre1']);
          $znombre2=ucwords2($aso_jwib['nombre2']);
     //      $zorat=$aso_jwib['orat'].' - '.$aso_jwib['orat_descri'];
          $zdiscurso=$jwol_smm;
          $zsala=$aso_jwib['sala'];
          include('ele_asigjw.php');

     }
     
     
}


if(mb_stristr('RTRT.',$info))
{
     $docu='RTRT';
     $sql_jwib='select *, ';
     $sql_jwib.='date_format(fecha,"%d / %M / %Y") as fechadmy,';   
// SELECT DATE_ADD('2025-08-20', INTERVAL 10 DAY) AS nueva_fecha;     
     $sql_jwib.='adddate(fecha,ifnull(plazo,0)-1) as vence, ';
     $sql_jwib.='date_format(adddate(fecha,ifnull(plazo,0)-1),"%d / %M / %Y") as vencedmy, ';
     $sql_jwib.='status as st1 ';
     $sql_jwib.='from jwrt1 ';
     $sql_jwib.='left join docu0 on docu=docu_codigo ';
     $sql_jwib.='left join trty0 on trty=trty_codigo ';
     $sql_jwib.='where ifnull(status,"-") not in ("O","X") ';
     if(empty($idnum))
     {
     $sql_jwib.='and cong="'.$cong_codigo.'" ';
     $sql_jwib.='and docu like "'.$docu.'%" ';
     }
     if(!empty($idnum))
     {$sql_jwib.='and idnum1= "'.$idnum.'" ';}
     $res_jwib=msql_query($sql_jwib,$link_data);
     
//      echo '===='.$sql_jwib;
     
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {

//           echo '===='.$aso_jwib['vence'];
          $zdocu=$aso_jwib['docu'];
          $ztrty=$aso_jwib['trty'];
          $ztrty_descri=ucwords2($aso_jwib['trty_descri']);
          $zidnum=$aso_jwib['idnum1'];
          $zfecha=ucwords($aso_jwib['fechadmy']);
          $zvence=ucwords($aso_jwib['vencedmy']);
//           $zplazo=ucwords($aso_jwib['vence']);
          $znombre1=strtoupper($aso_jwib['asignado']);
          include('ele_asigjw.php');

     }
     
     
}







?>
