<?php 
session_start();
foreach($_GET as $campo => $valor){${$campo}=trim($valor);} 
foreach($_POST as $campo => $valor){${$campo}=trim($valor);} 

$cong_codigo=$_SESSION['cong_codigo'];
if(!empty($cong)){$cong_codigo=$cong;}
$_SESSION['cong_codigo']=$cong_codigo;



if($vista2=='' and getPlatform()=='Android'){$vista2=1;}
if($vista2=='' and getPlatform()=='Linux'){$vista2=1;}

$psize='A4 ';
if($vista2==1){$psize.='portrait';}
if($vista2==0){$psize.='landscape';}
if($info=='PROG'){$psize='A4';}
if($info=='MMAE'){$psize='A4';}

include_once('lib_main.php');
if(!empty($empr)){$link_data=msql_connect('','','',$empr); $cfg_empr=$empr;}
$user_codigo=$_SESSION['user_codigo'];
$user0=data_maes('user',$user_codigo);

$cong0=data_maes('cong',$cong_codigo);
$salas=$cong0['cong_sala'];

if(empty($tipo)){$tipo='mes';}     
if($info=='PROG'){$tipo='sema';}
if($info!='PROG'){$tipo='mes'; $sema='';}

if($suge==1){$vista2=1;}


$editdate=date('Y-m-d');
$editweek=date('Y-W');
// $editdate=date('Y-01-01');
// $editweek=date('Y-01');

$group_class=array();
$idx_gc=0;

$xacce=$user0['user_'.strtolower($info)];
if(substr($info,0,3)=='DPU'){$xacce=$user0['user_dpub'];}

// if($xacce!=1){$edit='';$docu='';}
// if($user0['user_cong']!=$cong0['cong_codigo']){$edit='';$docu='';}

if($xacce!=1){$edit='';$Xdocu='';}
if($user0['user_cong']!=$cong0['cong_codigo']){$edit='';$Xdocu='';}



$sql_updt ='update docu0 set docu_tipo=case ';
$sql_updt.='when docu_codigo like "AS1%" then "ASEM" ';
$sql_updt.='when docu_codigo like "VM1%" then "VIDA" ';
$sql_updt.='when docu_codigo like "VM2%" then "VIDA"';
$sql_updt.='when docu_codigo like "VM3%" then "MMAE" ';
$sql_updt.='when docu_codigo like "VM4%" then "VIDA" ';
$sql_updt.='when docu_codigo like "EATA" then "ESTU" ';
$sql_updt.='when docu_codigo like "ELIB" then "ESTU" ';
$sql_updt.='when docu_codigo like "DPU%" then docu_codigo ';
$sql_updt.='else docu_tipo end ';
$res_updt=msql_query($sql_updt,$link_data);


// $sql_updt ='update jwib1 set fechar=case ';
// $sql_updt.='when docu not like "DP%"  and docu not like "EA%" then adddate(fecha,'.($cong0['cong_reu1']-1).') ';
// $sql_updt.='when docu like "DP%" or docu like "EA%" then adddate(fecha,'.($cong0['cong_reu2']-1).') ';
// $sql_updt.='else fecha end ';
// $sql_updt.='where fecha>"'.date('Y-m-d',strtotime('last monday')).'"';
// $res_updt=msql_query($sql_updt,$link_data);

$sql_updt ='update jwib1 ';
$sql_updt.='left join cong0 on cong=cong_codigo ';
$sql_updt.='set fechar=case ';
$sql_updt.='when docu not like "DP%"  and docu not like "EA%" then adddate(fecha,cong_reu1-1) ';
$sql_updt.='when docu like "DP%" or docu like "EA%" then adddate(fecha,cong_reu2-1) ';
$sql_updt.='else fecha end ';
$sql_updt.='where fecha>="'.date('Y-m-d',strtotime('last monday')).'"';
$sql_updt.='and fecha>="'.date('Y-m-01',strtotime('+1 month')).'"';
$res_updt=msql_query($sql_updt,$link_data);

// echo '*/*/*/'.$sql_updt;


$sql_updt ='update jwib1 set nombre3=nombre1 ';
$sql_updt.='where docu="AS19" ';
$sql_updt.='and ifnull(nombre3,"")=""';
$sql_updt.='and fecha>"'.date('Y-m-d').'" ';
$res_updt=msql_query($sql_updt,$link_data);





if($info=='ESTU')
{
     
     $fecha1a=date('Y-m-d',strtotime('-5 weeks'));     
     $fecha2a=date('Y-m-j');     
     $sql_eata='select max(fecha) as fecha, nombre1, count(nombre1) as conta ';
     $sql_eata.='from jwib1 ';
     $sql_eata.='where cong="'.$cong0['cong_codigo'].'" ';
     $sql_eata.='and docu="EATA" ';
     $sql_eata.='and ifnull(nombre1,"")!="" ';
     $sql_eata.='and fecha>="'.$fecha1a.'" ';
     $sql_eata.='and fecha<="'.$fecha2a.'" ';
     $sql_eata.='group by nombre1 ';
     $sql_eata.='order by conta desc ';
     $res_eata=msql_query($sql_eata,$link_data);
     $nombre_ata=msql_result($res_eata,0,'nombre1');


     $fecha1a=date('Y-m-d');
     $fecha2a=date('Y-m-j',strtotime('+1 month'));
     $sql_eata='update jwib1 ';
     $sql_eata.='set nombre1="'.$nombre_ata.'"';
     $sql_eata.='where cong="'.$cong0['cong_codigo'].'" ';
     $sql_eata.='and docu="EATA" ';
     $sql_eata.='and ifnull(nombre1,"")="" ';
     $sql_eata.='and fecha>="'.$fecha1a.'" ';
     $sql_eata.='and fecha<="'.$fecha2a.'" ';
     $res_eata=msql_query($sql_eata,$link_data);
     
}



if(empty($info)){$info='ASEM';}     
if($info=='PROG'){$xtitulo='Programa';}
if($info=='ASEM'){$xtitulo='Semanales';}
if($info=='MMAE'){$xtitulo='Mejores Maestros';}
if($info=='VIDA'){$xtitulo='Vida Cristiana';}
if($info=='ESTU'){$xtitulo='Estudios';}
if($info=='DPU1'){$xtitulo='Reunión Pública';}
if($info=='DPU2'){$xtitulo='Discursantes';}

if(empty($mes)){$mes=date('Y-m');}
$fecha1=$mes.'-01';
$fecha2=date('Y-m-t',strtotime($fecha1));


if( empty($prnt)){$fecha2=date('Y-m-t',strtotime('+4 month'));}
if(!empty($prnt)){$fecha2=date('Y-m-t',strtotime($fecha1));}



if(empty($sema)){$sema=date('Y-\WW');}
{$sema1=str_replace('W','',$sema);}

// $sema1=date('Y-W',strtotime($fecha1));
$sema2=date('Y-W',strtotime($fecha2));

if($sema1>$sema2)
{$sema1=date('Y-01',strtotime($fecha1));}


if($info=='PROG')
{
	$sql_jwib='select *, ';

	$sql_jwib.='max(case when sala=0 then idnum1 end) as idn_sala0,';
	$sql_jwib.='max(case when sala=0 then nombre1 end) as nom1sala0,';
	$sql_jwib.='max(case when sala=0 then nombre2 end) as nom2sala0,';
	$sql_jwib.='max(case when sala=0 then orat end) as oratsala0,';
	
	$sql_jwib.='max(case when sala=1 then idnum1 end) as idn_sala1,';
	$sql_jwib.='max(case when sala=1 then nombre1 end) as nom1sala1,';
	$sql_jwib.='max(case when sala=1 then nombre2 end) as nom2sala1,';
	$sql_jwib.='max(case when sala=1 then orat end) as oratsala1,';
	
	$sql_jwib.='max(case when sala=2 then idnum1 end) as idn_sala2,';
	$sql_jwib.='max(case when sala=2 then nombre1 end) as nom1sala2,';
	$sql_jwib.='max(case when sala=2 then nombre2 end) as nom2sala2,';
	$sql_jwib.='max(case when sala=2 then orat end) as oratsala2,';
	
	$sql_jwib.='max(case when sala=3 then idnum1 end) as idn_sala3,';
	$sql_jwib.='max(case when sala=3 then nombre1 end) as nom1sala3,';
	$sql_jwib.='max(case when sala=3 then nombre2 end) as nom2sala3,';
	$sql_jwib.='max(case when sala=3 then orat end) as oratsala3,';
	
     $sql_jwib.='case ';   
//      $sql_jwib.='when docu like "AS11" then 1 ';   
//      $sql_jwib.='when docu like "AS11" then 1 ';   
     $sql_jwib.='when docu like "VM11" then 1 ';   
     $sql_jwib.='when docu like "VM19" then 1 ';   
     $sql_jwib.='when docu like "VM%" then 3 ';   
     $sql_jwib.='when docu like "EL%" then 5 ';   
     $sql_jwib.='when docu like "DP%" then 7 ';   
     $sql_jwib.='when docu like "EA%" then 7 ';   
     $sql_jwib.='when docu like "AS%" then 8 ';   
     $sql_jwib.='else 9 ';   
     $sql_jwib.='end as orden, ';   
     
     $sql_jwib.='date_format(fecha,"%x-%v") as fsema,';   
     $sql_jwib.='date_format(fecha,"%x-%m") as fames,';   
	$sql_jwib.='status as st1 ';
 	$sql_jwib.='from jwib1 ';
 	$sql_jwib.='left join docu0 on docu=docu_codigo ';
     $sql_jwib.='left join jwol0 on fecha=jwol_fecha ';
	$sql_jwib.='where status not in ("O","X") ';
	$sql_jwib.='and cong="'.$cong_codigo.'" ';
// 	$sql_jwib.='and docu like "VM3%" ';
	$sql_jwib.='and ifnull(jwol_tdb1,"")!="" ';
	$sql_jwib.='and date_format(fecha,"%x-%v")>="'.$sema1.'" ';
	$sql_jwib.='and date_format(fecha,"%x-%v")<="'.$sema2.'" ';
     if($prnt==1)
     {$sql_jwib.='and date_format(fecha,"%x-%v")<="'.$sema1.'" ';}
// 	$sql_jwib.='and fechar>="'.$fecha1.'" ';
// 	$sql_jwib.='and fechar<="'.$fecha2.'" ';

//      if($edit!=1)
     {$sql_jwib.='and (length(concat(ifnull(nombre1,""),ifnull(nombre2,""),ifnull(nombre3,""),ifnull(nombre4,"")))>5)';}

     $xgroupby='group by fecha,fechar,docu ';
     $xorderby='order by fecha,fechar,orden,docu ';
	$sql_jwib.=$xgroupby;
	$sql_jwib.=$xorderby;
     
     
     
}

if($info=='ASEM')
{

	$modif=$modif*$masem;
     
	$sql_jwib='select *, ';
     if($vista2==0)
	for($cas10=11; $cas10<=19; $cas10++)
	{
//           if(msql_num_rows($res_vali)!=0)
          {
// 	$sql_jwib.='max(case when sala=0 then idnum1 end) as idn_sala0,';
//                echo '==='.$cas10;
          $sql_jwib.='max(case when docu="AS'.$cas10.'" then idnum1 end) as idn_'.$cas10.',';
          $sql_jwib.='max(case when docu="AS'.$cas10.'" then docu end) as docuc_'.$cas10.',';
          $sql_jwib.='max(case when docu="AS'.$cas10.'" then docu_descri end) as docud_'.$cas10.',';
          $sql_jwib.='max(case when docu="AS'.$cas10.'" then nombre1 end) as nom1_'.$cas10.',';
          $sql_jwib.='max(case when docu="AS'.$cas10.'" then nombre2 end) as nom2_'.$cas10.',';
          $sql_jwib.='max(case when docu="AS'.$cas10.'" then nombre3 end) as nom3_'.$cas10.',';
          $sql_jwib.='max(case when docu="AS'.$cas10.'" then nombre4 end) as nom4_'.$cas10.',';
          $sql_jwib.='max(case when docu="AS'.$cas10.'" then fechar end) as fecha_'.$cas10.',';
          $sql_jwib.='max(case when docu="AS'.$cas10.'" then date_format(fechar,"%a/%d") end) as fec_'.$cas10.',';
          }
	}
     $sql_jwib.='date_format(fecha,"%x-%v") as fsema,';   
     $sql_jwib.='date_format(fecha,"%M") as famesnom,';   
     $sql_jwib.='date_format(fecha,"%x-%m") as fames,';   
	$sql_jwib.='status as st1 ';
 	$sql_jwib.='from jwib1 ';
 	$sql_jwib.='left join docu0 on docu=docu_codigo ';
	$sql_jwib.='where status not in ("O","X")';
	$sql_jwib.='and cong="'.$cong_codigo.'" ';
	$sql_jwib.='and docu like "AS1%" ';
     $sql_jwib.='and docu != "AS10" ';
//      $sql_jwib.='and date_format(fecha,"%x-%v")>="'.$sema1.'" ';
// 	$sql_jwib.='and date_format(fecha,"%x-%v")<="'.$sema2.'" ';
	$sql_jwib.='and fechar>="'.$fecha1.'" ';
	$sql_jwib.='and fechar<="'.$fecha2.'" ';
     if(!empty($docu))
     {$sql_jwib.='and docu = "'.$docu.'" ';}
//      if($edit!=1)
//      {$sql_jwib.='and (length(concat(ifnull(nombre1,""),ifnull(nombre2,""),ifnull(nombre3,""),ifnull(nombre4,"")))>1)';}


     $xgroupby='group by fsema ';
     $xorderby='order by fecha,docu,fechar ';
     if($vista2==1){$xgroupby='';}
	$sql_jwib.=$xgroupby;
	$sql_jwib.=$xorderby;
//      echo '*/*/*'.$sql_jwib;
}

if($info=='MMAE')
{
	$modif=$modif*$mmae;
	
	$sql_jwib='select *, ';
//      if($vista2==0)
	$sql_jwib.='max(case when sala=0 then idnum1 end) as idn_sala0,';
	$sql_jwib.='max(case when sala=0 then nombre1 end) as nom1sala0,';
	$sql_jwib.='max(case when sala=0 then nombre2 end) as nom2sala0,';
	$sql_jwib.='max(case when sala=0 then orat end) as oratsala0,';
	
	$sql_jwib.='max(case when sala=1 then idnum1 end) as idn_sala1,';
	$sql_jwib.='max(case when sala=1 then nombre1 end) as nom1sala1,';
	$sql_jwib.='max(case when sala=1 then nombre2 end) as nom2sala1,';
	$sql_jwib.='max(case when sala=1 then orat end) as oratsala1,';
	
	$sql_jwib.='max(case when sala=2 then idnum1 end) as idn_sala2,';
	$sql_jwib.='max(case when sala=2 then nombre1 end) as nom1sala2,';
	$sql_jwib.='max(case when sala=2 then nombre2 end) as nom2sala2,';
	$sql_jwib.='max(case when sala=2 then orat end) as oratsala2,';
	
	$sql_jwib.='max(case when sala=3 then idnum1 end) as idn_sala3,';
	$sql_jwib.='max(case when sala=3 then nombre1 end) as nom1sala3,';
	$sql_jwib.='max(case when sala=3 then nombre2 end) as nom2sala3,';
	$sql_jwib.='max(case when sala=3 then orat end) as oratsala3,';
	
     $sql_jwib.='date_format(fecha,"%x-%v") as fsema,';   
     $sql_jwib.='date_format(fecha,"%x-%m") as fames,';   
	$sql_jwib.='status as st1 ';
 	$sql_jwib.='from jwib1 ';
 	$sql_jwib.='left join docu0 on docu=docu_codigo ';
     $sql_jwib.='left join jwol0 on fecha=jwol_fecha ';
	$sql_jwib.='where status not in ("O","X") ';
	$sql_jwib.='and cong="'.$cong_codigo.'" ';
	$sql_jwib.='and docu like "VM3%" ';
	$sql_jwib.='and ifnull(jwol_tdb1,"")!="" ';
// 	$sql_jwib.='and date_format(fecha,"%x-%v")>="'.$sema1.'" ';
// 	$sql_jwib.='and date_format(fecha,"%x-%v")<="'.$sema2.'" ';
	$sql_jwib.='and fechar>="'.$fecha1.'" ';
	$sql_jwib.='and fechar<="'.$fecha2.'" ';
     
     if(!empty($docu))
     {
//           if($edit==1 and $suge==1)
          if($edit==1)
          {
               if($docu=='VM30')
               {$sql_jwib.='and docu like "'.$docu.'" ';}

               if($docu!='VM30')
               {
                    $sql_jwib.='and docu not like "VM30" ';
                    $sql_jwib.='and docu like "'.substr($docu,0,3).'%" ';
               }
          }
          else
          {$sql_jwib.='and docu like "'.$docu.'" ';}          
          
          
     }
     
     if($edit!=1)
     {$sql_jwib.='and (length(concat(ifnull(nombre1,""),ifnull(nombre2,""),ifnull(nombre3,""),ifnull(nombre4,"")))>5)';}

     $xgroupby='group by fsema,docu ';
     $xorderby='order by fecha,docu,fechar ';
	$sql_jwib.=$xgroupby;
	$sql_jwib.=$xorderby;
     
}

if($info=='VIDA')
{
     
	$modif=$modif*$vida;

	$sql_jwib='select *, ';
	$sql_jwib.='max(case when docu="VM11" then idnum1 end) as idn_vmc,';
	$sql_jwib.='max(case when docu="VM11" then nombre1 end) as nom1vmc,';
	$sql_jwib.='max(case when docu="VM11" then nombre2 end) as nom2vmc,';
	$sql_jwib.='max(case when docu="VM19" then idnum1 end) as idn_ora,';
	$sql_jwib.='max(case when docu="VM19" then nombre1 end) as nom1ora,';
	$sql_jwib.='max(case when docu="VM19" then nombre2 end) as nom2ora,';
	$sql_jwib.='max(case when docu="VM21" then idnum1 end) as idn_tdb,';
	$sql_jwib.='max(case when docu="VM21" then nombre1 end) as nom1tdb,';
	$sql_jwib.='max(case when docu="VM21" then nombre2 end) as nom2tdb,';
	$sql_jwib.='max(case when docu="VM41" then idnum1 end) as idn_nvc,';
	$sql_jwib.='max(case when docu="VM41" then nombre1 end) as nom1nvc,';
	$sql_jwib.='max(case when docu="VM41" then nombre2 end) as nom2nvc,';
// 	$sql_jwib.='max(case when docu="VM41" then jwol_nvc1 end) as nom1nvc,';
// 	$sql_jwib.='max(case when docu="VM41" then jwol_nvc2 end) as nom2nvc,';
     $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 jwol0 on(fecha=jwol_fecha) ';
	$sql_jwib.='where status not in ("O","X") ';
	$sql_jwib.='and cong="'.$cong_codigo.'" ';
	$sql_jwib.='and docu like "VM%" ';
	$sql_jwib.='and docu not like "VM3%" ';
// 	$sql_jwib.='and date_format(fecha,"%x-%v")>="'.$sema1.'" ';
// 	$sql_jwib.='and date_format(fecha,"%x-%v")<="'.$sema2.'" ';
	$sql_jwib.='and fechar>="'.$fecha1.'" ';
	$sql_jwib.='and fechar<="'.$fecha2.'" ';
//      echo '*/*/*'.$docu;
     if(!empty($docu))
     {$sql_jwib.='and docu = "'.$docu.'"';}
     if($edit!=1)
     {$sql_jwib.='and (length(concat(ifnull(nombre1,""),ifnull(nombre2,""),ifnull(nombre3,""),ifnull(nombre4,"")))>5)';}
     
	

     $xgroupby='group by fsema ';
     $xorderby='order by fecha,fechar,docu ';
     
     if($vista2==1)
     {$xgroupby='group by fsema,docu ';}
     
	$sql_jwib.=$xgroupby;
	$sql_jwib.=$xorderby;
     
// 	$sql_jwib.=' group by fanio,fsema ';
// 	$sql_jwib.=' order by fecha,fechar ';
// 	echo $sql_jwib;
}


if($info=='ESTU')
{
	$modif=$modif*$estu;
	
	$sql_jwib='select *, ';
	$sql_jwib.='max(case when docu="ELIB" then idnum1 end) as idn_lib,';
	$sql_jwib.='max(case when docu="ELIB" then nombre1 end) as nom1_lib,';
	$sql_jwib.='max(case when docu="ELIB" then nombre2 end) as nom2_lib,';
// 	$sql_jwib.='max(case when docu="ELIB" then fechar else fecha end) as fecha_lib,';
	$sql_jwib.='max(case when docu="ELIB" then fechar else adddate(fecha,'.($cong0['cong_reu1']-1).') end) as fecha_lib,';
// 	$sql_jwib.='max(case when docu="ELIB" then concat(fdianr," /",fdiar) end) as fec_lib,';
     
	$sql_jwib.='max(case when docu="EATA" then idnum1 end) as idn_ata,';
	$sql_jwib.='max(case when docu="EATA" then nombre1 end) as nom1_ata,';
	$sql_jwib.='max(case when docu="EATA" then nombre2 end) as nom2_ata,';
// 	$sql_jwib.='max(case when docu="EATA" then fechar else fecha end) as fecha_ata,';
	$sql_jwib.='max(case when docu="EATA" then fechar else adddate(fecha,'.($cong0['cong_reu2']-1).') end) as fecha_ata,';
// 	$sql_jwib.='max(case when docu="EATA" then concat(fdianr," /",fdiar) end) as fec_ata,';
     $sql_jwib.='date_format(fecha,"%x-%v") as fsema,';   
	$sql_jwib.='status as st1 ';
// 	$sql_jwib.='from jwib1 where docu in ("ELIB","EATA") and cong="'.$cong_codigo.'" ';

 	$sql_jwib.='from jwib1 ';
 	$sql_jwib.='left join docu0 on docu=docu_codigo ';
     $sql_jwib.='left join jwol0 on(fecha=jwol_fecha) ';
	$sql_jwib.='where status not in ("O","X") ';
	$sql_jwib.='and cong="'.$cong_codigo.'" ';
	$sql_jwib.='and docu in("ELIB","EATA") ';
	$sql_jwib.='and date_format(fecha,"%x-%v")>="'.$sema1.'" ';
	$sql_jwib.='and date_format(fecha,"%x-%v")<="'.$sema2.'" ';
// 	$sql_jwib.='and fechar>="'.$fecha1.'" ';
// 	$sql_jwib.='and fechar<="'.$fecha2.'" ';
     if($edit!=1)
     {$sql_jwib.='and (length(concat(ifnull(nombre1,""),ifnull(nombre2,""),ifnull(nombre3,""),ifnull(nombre4,"")))>5)';}
	

     $xgroupby='group by fsema ';
     $xorderby='order by fecha,fechar,docu ';
     
//      if($vista2==1)
//      {$xgroupby='group by fsema,docu ';}
     
	$sql_jwib.=$xgroupby;
	$sql_jwib.=$xorderby;
// 	echo $sql_jwib;
}

if(mb_stristr('DPU1.DPU2',$info))
{
	$modif=$modif*$dpub;
     
     $sql_updt='update jwib1 set cong2_descri=null where cong2_descri like "undefined%"';
     $res_updt=msql_query($sql_updt,$link_data);

     if($info=='DPU2')
     {
//           $sql_updt='update jwib1, cong0 set fechar=adddate(fecha,5) where cong="'.$cong_codigo.'" and docu="DPU2" and (cong2_dpud="" or cong2_dpud is null)';
          $sql_updt='update jwib1, cong0 set fechar=adddate(fecha,5) where cong="'.$cong_codigo.'" and docu="DPU2" and (ifnull(cong2_dpud,"")="")';
          $res_updt=msql_query($sql_updt,$link_data);

          $sql_updt='update jwib1, cong0 set fechar=adddate(fecha,6) where cong="'.$cong_codigo.'" and docu="DPU2" and fecha>="'.$fecha.'" and (left(cong2_dpud,1)="6" or left(cong2_dpud,1)="S")';
          $res_updt=msql_query($sql_updt,$link_data);
          
          $sql_updt='update jwib1, cong0 set fechar=adddate(fecha,6) where cong="'.$cong_codigo.'" and docu="DPU2" and fecha>="'.$fecha.'" and (left(cong2_dpud,1)="7" or left(cong2_dpud,1)="D")';
          $res_updt=msql_query($sql_updt,$link_data);
     }
     
     
	$sql_jwib='select *, ';
     $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 jwol0 on(fecha=jwol_fecha) ';
     $sql_jwib.='left join bsqj0 on(bsqj=bsqj_codigo) ';
	$sql_jwib.='where status not in ("O","X") ';
	$sql_jwib.='and cong="'.$cong_codigo.'" ';
	$sql_jwib.='and docu ="'.$info.'" ';
	$sql_jwib.='and date_format(fecha,"%x-%v")>="'.$sema1.'" ';
	$sql_jwib.='and date_format(fecha,"%x-%v")<="'.$sema2.'" ';
// 	$sql_jwib.='and fechar>="'.$fecha1.'" ';
// 	$sql_jwib.='and fechar<="'.$fecha2.'" ';
     if($edit!=1)
     {$sql_jwib.='and ifnull(nombre1,"")!="" ';}

     $xgroupby='group by fsema ';
     $xorderby='order by fecha,fechar,docu ';
     
//      if($vista2==1)
//      {$xgroupby='group by fsema,docu ';}

// 	if($info=='DPU1')
// 	{$xorderby='order by fecha ';}

// 	if($info=='DPU2')
// 	{$xorderby='order by fanior,famesr,cong2_descri,fecha ';}
     
	$sql_jwib.=$xgroupby;
	$sql_jwib.=$xorderby;
     
     
     
	
}

//      echo '*/*/*/*'.$sql_jwib;

$res_jwib=msql_query($sql_jwib,$link_data);

// while($aso_jwib=msql_fetch_assoc($res_jwib))
// {
//      echo '<br>';
// //      echo '<br>';
//      echo $aso_jwib['fecha'].' ';
//      echo $aso_jwib['fechar'].' ';
//      echo $aso_jwib['docu'].' ';
//      echo $aso_jwib['docu_descri'].' ';
//      echo $aso_jwib['nombre1'].' ';
//      echo $aso_jwib['nombre2'].' ';
//      echo $aso_jwib['nombre3'].' ';
//      echo $aso_jwib['nombre4'].' ';
//      echo $aso_jwib['jwol_descri'].' ';
// }


set_nombres();

// echo '===='.$info;
// echo '===='.$edit;

// if($info=='MMAE' and empty($edit))
if($info=='MMAE' and $edit!=1)
{
     $sql_sala=$sql_jwib;
     $sql_sala=substr($sql_sala,0,strpos($sql_sala,'group'));
     $sql_sala.='group by sala order by sala desc';
     $res_sala=msql_query($sql_sala,$link_data);
     $salas=msql_result($res_sala,0,'sala');
     
     
//      $sql_sala='select max(sala) as sala from ('.$sql_jwib.')as qmmae';
//      $res_sala=msql_query($sql_sala,$link_data);
//      $salas=msql_result($res_sala,0,'sala');
//      echo '<br>===='.$sql_sala;
//      echo '<br>===='.$salas;
     
}


if($edit==1)
{
     $fecha0=date('Y-m-01',strtotime('-12 month'));
//      $fecha2=date('Y-m-01',strtotime('+3 month'));

     $sql_nomb='drop view pre_vm';
     $res_nomb=msql_query($sql_nomb,$link_data);
     $sql_nomb='drop view pre_as';
     $res_nomb=msql_query($sql_nomb,$link_data);
          
     $sql_view ='create view pre_vm as ';
     $sql_view.='select * from jwib1 where docu="VM11"'; 
     $res_view=msql_query($sql_view,$link_data);
     
     $sql_view ='create view pre_as as ';
     $sql_view.='select * from jwib1 where docu="AS11"'; 
     $res_view=msql_query($sql_view,$link_data);
     
     $sql_updt ='update jwib1, pre_vm  ';
     $sql_updt.='set jwib1.nombre1=pre_vm.nombre1 ';
     $sql_updt.='where jwib1.docu="AS11" ';
     $sql_updt.='and jwib1.cong=pre_vm.cong ';
     $sql_updt.='and jwib1.fecha=pre_vm.fecha ';
     $sql_updt.='and ifnull(jwib1.nombre1,"")="" ';
     $sql_updt.='and jwib1.fecha>="'.date('Y-m-d').'" ';
     $res_updt=msql_query($sql_updt,$link_data);
     
     crea_nomb0();
     
     $zid='nomb_info';
     $ztabla='nomb';
     $zcolu='nomb_nombre';
     $zwhere='(';
     $zwhere.='nomb_cong="'.$_SESSION['cong_codigo'].'" and nomb_lused>="'.$fecha0.'" ';
     if(!empty($docu))
     {$zwhere.='and nomb_docu  like "'.$docu.'%" ';}
     $zwhere.='and nomb_tipo="'.$info.'" ';
     $zwhere.='and nomb_nombre not like "%.%" ';
     $zwhere.=')';
     include('ele_datalist.php');
     
     
     $zid='nomb_varon';
     $ztabla='nomb';
     $zcolu='nomb_nombre';
     $zwhere='(';
     $zwhere.='nomb_cong="'.$_SESSION['cong_codigo'].'" and nomb_lused>="'.$fecha0.'" ';
     $zwhere.='and nomb_varon=1 ';
     if(!empty($docu))
     {$zwhere.='and nomb_docu  like "'.$docu.'%" ';}
     $zwhere.='and nomb_tipo="'.$info.'" ';
     $zwhere.='and nomb_nombre not like "%.%" ';
     $zwhere.=')';
     include('ele_datalist.php');
     
     
     

     $sql_docu='select * from docu0 where docu_tabla="jwib" order by docu_codigo';
     $res_docu=msql_query($sql_docu,$link_data);
     while($aso_docu=msql_fetch_assoc($res_docu))
     {
//           $zid='nomb_info';
//           $ztabla='nomb';
//           $zcolu='nomb_nombre';
//           $zwhere='(';
//           $zwhere.='nomb_cong="'.$_SESSION['cong_codigo'].'" and nomb_lused>="'.$fecha0.'" ';
//           if(!empty($docu))
//           {$zwhere.='and nomb_docu  like "'.$docu.'%" ';}
//           $zwhere.='and nomb_tipo="'.$info.'" ';
//           $zwhere.='and nomb_nombre not like "%.%" ';
//           $zwhere.=')';
//           include('ele_datalist.php');
     }
     
          
     
     
     
     
     $ztabla='bsqj';
     include('ele_datalist.php');
     
     
     
     
     
}



// if(empty($prnt))
{
// echo '<div id="filtros" noprint sticky style="top:100px;">';
echo '<div id="filtros" noprint ">';
// OCULTOS
echo '<div hide>';     
//      echo '<input id="ipip" value="'.$ipip.'">';
//      echo '<input id="format" value="'.$format.'">';
//      // echo '<input id="limit" hide value="'.$limit.'">';
//      echo '<input id="modu" value="'.$modu.'">';
//      echo '<input id="info" value="'.$info.'">';
//      echo '<input id="idnum1" value="'.$idnum1.'">';
//      echo '<input id="fecha1" value="'.$fecha1.'">';
//      echo '<input id="fecha2" value="'.$fecha2.'">';
     echo '<input id="tipo" value="'.$tipo.'">';
     echo '<input id="cong" value="'.$_SESSION['cong_codigo'].'">';
//      echo '<input id="cong" value="'.$cong0['cong_codigo].'">';
echo '</div>';     







     
// $ztitulo='Tablero de Anuncios';     
// include('ele_title.php');


if($tipo=='mes')
{
     $zid='mes';
     $zlabel='Mes';
     $zvalue=$mes;
     $ztype='month';
     $zonchange='{jwib_asig(event);}';
     $zmin=date('Y-m',strtotime('-12 month'));     
     $zmax=date('Y-m',strtotime('+4 month'));     
     include('ele_input.php');


     $zid='btn_prev'; 
     $zlabel='◄';
     $zonclick='{document.getElementById("mes").stepDown();document.getElementById("mes").onchange();}';
     $zstyle='width:2.5em;';
     include('ele_button.php');

     $zid='btn_next'; 
     $zlabel='►';
     $zonclick='{document.getElementById("mes").stepUp();document.getElementById("mes").onchange();}';
     $zstyle='width:2.5em;';
     include('ele_button.php');
     
}

     
if($tipo=='sema')
{
     $zid='sema';
     $zlabel='Semana';
     $zvalue=$sema;
     $ztype='week';
     $zonchange='{jwib_asig(event);}';
     $zmin=date('Y-m',strtotime('-11 month'));     
     $zmax=date('Y-m',strtotime('+4 month'));     
     include('ele_input.php');


     $zid='btn_prev'; 
     $zlabel='◄';
     $zonclick='{document.getElementById("sema").stepDown();document.getElementById("sema").onchange();}';
     $zstyle='width:2.5em;';
     include('ele_button.php');

     $zid='btn_next'; 
     $zlabel='►';
     $zonclick='{document.getElementById("sema").stepUp();document.getElementById("sema").onchange();}';
     $zstyle='width:2.5em;';
     include('ele_button.php');
     
     
     $info='PROG';
}

     
     
     
     
     

     
$zid='prnt_'.$info; 
$zlabel='Impri';
$zalign='right';
$zonclick='{nwo=window.open(xhref+"&prnt=1","_blank");nwo.print();}';
$zhref=' ';
$znoprint=1;
$zsize=0.8;
include('ele_button.php');
     
     

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

     
$zid='info';
$zlabel='Asignaciones';
$zvalue=$info;
// $zonchange='{jwib_asig(event);}';
$zonchange='{document.getElementById("docu").value=""; jwib_asig(event);}';
$zoptions='';
$zoptions.='PROG,Programa;';
$zoptions.='ASEM,Semanales;';
$zoptions.='MMAE,Mejores Maestros;';
$zoptions.='VIDA,Vida Cristiana;';
$zoptions.='ESTU,Estudios;';
$zoptions.='DPU1,Reunión Pública;';
$zoptions.='DPU2,Discursantes;';
if($tipo=='sema')
{
//      $zvalue='PROG';
//      $zoptions='PROG,Programa;';
//      $zhide=1;
}
$zexact=1;     
include('ele_select.php');

     
// $ztabla='docu';
// include('ele_datalist.php');
     
     
// $zobj=1;     
$zid='vista2';
$zlabel='Vista';
$zvalue=$vista2;
$zdefa=0;     
if($vista2=='')     
{$zvalue=$_SESSION['screeno'];}
$zonchange='{jwib_asig(event);}';
$zoptions='';
$zoptions.='0,Horizontal;';
$zoptions.='1,Vertical;';
$zalign='right';
$zexact=1;     
if($tipo=='sema'){$zhide=1;}     
include('ele_select.php');
     
     
     
$zid='docu';
$zlabel='Tipo';
$zvalue=$docu;
$zonchange='{jwib_asig(event);}';
$ztabla='docu';
$ztodo=1;     
$zwhere='(docu_tipo="'.$info.'" and docu_codigo!="AS10")';     
if(empty($user_codigo))     
{$zhide=1;}
include('ele_select.php');

// $zid='edit';
// $zlabel='Editar';
// $zvalue=$edit;
// $ztype='check';     
// if(empty($user_codigo))     
// {$zhide=1;}
// include('ele_input.php');

$zid='edit';
$zlabel='Editar';
$zdefa=2;     
$zonchange='{jwib_asig(event);}';
if(empty($user_codigo)){$zhide=1;}
$zbool=1;     
$zexact=1;     
include('ele_select.php');

$zid='suge';
$zlabel='Sugerir';
$zvalue=$suge;
$zdefa=2;     
$zonchange='{jwib_asig(event);}';
if(empty($user_codigo)){$zhide=1;}
$zbool=1;     
$zexact=1;     
include('ele_select.php');


$zid='btn_consultar'; 
// $zlabel='Consultar';
$zlabel='🔎';     
$zalign='right';
$zsize=1.1;
$zonclick='{jwib_asig(event);}';
$zhide=1;     
include('ele_button.php');

     
     

// echo '*/*/*/'.$_SESSION['oscreen'];

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

// echo $sql_jwib;


{    


echo '<div id="main2">';    
     
     
$domd = new DOMDocument();
     $domd->encoding = 'utf-8';
     $domd->xmlVersion = '1.0';
     $domd->formatOutput = true;

$table=$domd->appendChild($domd->createElement("table"));
     $table->setAttribute("border","1");
//      $table->setAttribute("width","100%");   
     $table->setAttribute("width","99%");   
    //  $table->setAttribute("style","page-break-inside: avoid; break-inside: avoid;");   
//      $table->setAttribute('style','page-break-inside: auto;');
     if($edit!=1)
     {
     $table->setAttribute("bt-s1","");   
     $table->setAttribute("bb-s1","");   
     }
     
//      if($vista2==1 and $_SESSION['screeno']!=1)
//      {$table->setAttribute("width","50%");}

     if($vista2==1 and $_SESSION['screeno']!=1)
     {$table->setAttribute("width",(int)($_SESSION['screenw']*(0.5)).'px');}

     
     
if($info=='PROG')
{
     
     if($suge==1)
     {
          $res_vm300=get_suge('VM30','0');
          $res_vm301=get_suge('VM30','1');
          $res_vm302=get_suge('VM30','2');
          
          $res_vm340=get_suge('VM34','0');
          $res_vm341=get_suge('VM34','1');
          $res_vm342=get_suge('VM34','2');
          
          $res_vm350=get_suge('VM35','0');
          $res_vm351=get_suge('VM35','1');
          $res_vm352=get_suge('VM35','2');
          
          $res_vm360=get_suge('VM36','0');
//           $res_vm361=get_suge('VM36','1');
//           $res_vm362=get_suge('VM36','2');
          
          $res_vm390=get_suge('VM39','0');
          $res_vm391=get_suge('VM39','1');
          $res_vm392=get_suge('VM39','2');
          
     }
     
     $row_smm=1;

     $lfecha='';
     $lmonth='';
     $lweek='';
//      $smmblock=1;
     
     msql_data_seek($res_jwib,0);     
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {
//           gen_icsjw($aso_jwib['idnum1']);
          $videoprimera=0;
          $videorevisita=0;
          
          $auditorio=0;
          $discurso=0;
          
//           if($lmonth!=substr($aso_jwib['fechar'],0,7))
          if($lweek!=$aso_jwib['fsema'])
          {
               
               
               
     // TABLA
     {
          $smmblock=1;
          $brktab=$domd->appendChild($domd->createElement("p"));
          $table=$domd->appendChild($domd->createElement("table"));
               $table->setAttribute("border","1");
//                $table->setAttribute("width","100%");   
               $table->setAttribute("width","99%");   
               $table->setAttribute("style","page-break-inside: avoid; break-inside: avoid;");   
               if($edit!=1)
               {
               $table->setAttribute("bt-s1","");   
               $table->setAttribute("bb-s1","");   
               }

          //      if($vista2==1 and $_SESSION['screeno']!=1)
          //      {$table->setAttribute("width","50%");}

               if($vista2==1 and $_SESSION['screeno']!=1)
               {$table->setAttribute("width",(int)($_SESSION['screenw']*(0.5)).'px');}

          
     }
     
               
               
               
               
               
               
               $trow=$table->appendChild($domd->createElement("tr"));
                    $xstyle="border-top:solid 2px; border-color:black; background-color:#4B2674; color:white; top:100px;";
                    // $xstyle.="page-break-inside: avoid; break-inside: avoid;";
                    $trow->setAttribute("style",$xstyle);
                    $table->setAttribute("style",);   
                    $trow->setAttribute("sticky","");
               
               
               $mesanio=strftime2('%B / %Y',strtotime($aso_jwib['fechar']));
               $mesanio=strtoupper($mesanio);
               if($vista2==0)
               {
//                     $tcell=$trow->appendChild($domd->createElement("th",''));
//                     $tcell2=$tcell->appendChild($domd->createElement("span",''));
//                     $tcell->setAttribute("width","10%");
//                     if($salas==0){$tcell->setAttribute("width","50%");}
//                     $tcell=$trow->appendChild($domd->createElement("th","PROGRAMA"));
                    $tcell=$trow->appendChild($domd->createElement("th",$mesanio));
                    $tcell2=$tcell->appendChild($domd->createElement("span",''));
//                     $tcell->setAttribute("width","30%");
               }
               if($vista2==1)
               {
                    $tcell=$trow->appendChild($domd->createElement("th",$mesanio));
                    $tcell2=$tcell->appendChild($domd->createElement("span",''));
               }

               $tcell->setAttribute("colspan","10");
               $tcell->setAttribute("style","height:2.5em; ");

               
               $colname=$mesaniox;
               if($aso_jwib['fsema']<date('Y-W'))
               {$ref=$tcell2->appendChild($domd->createElement('span',$colname));} 

               if($aso_jwib['fsema']>=date('Y-W'))
               {
                    $ref=$tcell2->appendChild($domd->createElement('a',$colname));                           
                    $ref->setAttribute('style','color:white !important;');
                    $href='';
                    $href.='https://jwib.vcrxol.com/?scri=jwib_asig4&prnt=1';
                    $href.='&info=MMAE';
                    $href.='&cong='.$cong_codigo;
                    $href.='&ames='.substr($aso_jwib['fecha'],0,7);
                    $ref->setAttribute('tabindex','-1');
                    $ref->setAttribute('href',$href);
                    $ref->setAttribute('target','_blank');

               }
               
//                $lmonth=substr($aso_jwib['fechar'],0,7);
               $lweek=$aso_jwib['fsema'];
     //           $lmonth=$aso_jwib['fames'];
          }

          
          
//  color morado          #4B2674
//  color celeste          #5A7EB3

          if($lfecha!=$aso_jwib['fechar'])
          {
               $trow=$table->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("style","border-top:solid 2px; border-color:black; background-color: #4B2674; color:white; ");
                    if($vista2==1)
                    $trow->setAttribute("style","border-top:solid 2px; border-color:black; background-color: #4B2674; color:white; ");

//                if($edit==1)
//                {$tcell=$trow->appendChild($domd->createElement("th",strftime2('%A %d/%B',strtotime($aso_jwib['fechar']))));}
//                else
//                {$tcell=$trow->appendChild($domd->createElement("th",strftime2('%A / %d',strtotime($aso_jwib['fechar']))));}
               
               {$tcell=$trow->appendChild($domd->createElement("th",''));}
               $trow->setAttribute("sticky-t140","");

               
               if($edit==1)
               {
                    $colname= strftime2('%A %d/%B',strtotime($aso_jwib['fechar']));
//                     if($vista2==1)
//                     {$colname= strftime2('%a %d/%B',strtotime($aso_jwib['fechar']));}
               }
               else
               {
                    $colname= strftime2('%A / %d',strtotime($aso_jwib['fechar']));
//                     if($vista2==1)
//                     {$colname= strftime2('%a / %d',strtotime($aso_jwib['fechar']));}
               }
               
               if($aso_jwib['fsema']<date('Y-W'))
               {$ref=$tcell->appendChild($domd->createElement('span',$colname));} 

               
               if($aso_jwib['fsema']>=date('Y-W'))
               {
                    $ref=$tcell->appendChild($domd->createElement('a',$colname));                           
                    $ref->setAttribute('style','color:white !important;');
                    $href='';
                    $href.='https://jwib.vcrxol.com/?scri=jwib_asig4&prnt=1';
                    $href.='&info=MMAE';
                    $href.='&cong='.$cong_codigo;
                    $href.='&sema='.$aso_jwib['fsema'];
//                          $href.='&sala='.$cas10;
                    $ref->setAttribute('tabindex','-1');
                    $ref->setAttribute('href',$href);
                    $ref->setAttribute('target','_blank');

               }
               
//                $tcell->setAttribute("style","max-width:20%;");

//                echo '<br>==='.$aso_jwib['fsema'];
//                echo '==='.date('Y-W',strtotime('today'));
//                echo '===='.date('Y-W',strtotime($aso_jwib['fechar'].' -1 week'));
               
//                if($aso_jwib['fsema']==date('Y-W',strtotime($aso_jwib['fechar'].' -1 week')))
//                if($aso_jwib['fsema']==date('Y-W',strtotime('next friday')))

//                if(date('Y-m')==$mes)
//                if(date('Y-W')==$aso_jwib['fsema'])
//                {$trow->setAttribute("id","scrollhere");}
               
               
               $tcell->setAttribute("nowrap","");
               if($vista2==1)
               {$tcell->setAttribute("colspan",10);}

               
//                echo '<br>====='.$salas;
               
               if($vista2==0)
               for($cas10=0; $cas10<=$salas; $cas10++)
               {
//                     $colname='SALA '.$cas10;
                    $colname='NOMBRE';
                    if($cas10==0)
                    {$colname='ASIGNACION';}
                    $tcella=$trow->appendChild($domd->createElement("th",''));
//                     if($salas==0)
                    {$tcella->setAttribute('width','45%');}
//                     if($salas!=0)
//                     {$tcell->setAttribute('width','30%');}

                    if($aso_jwib['fsema']<date('Y-W'))
                    {$ref=$tcella->appendChild($domd->createElement('span',$colname));} 
                    
                    if($aso_jwib['fsema']>=date('Y-W'))
                    {
                         $ref=$tcella->appendChild($domd->createElement('a',$colname));                           
                         $ref->setAttribute('style','color:white !important;');
                         $href='';
                         $href.='https://jwib.vcrxol.com/?scri=jwib_asig4&prnt=1';
                         $href.='&info=MMAE';
                         $href.='&cong='.$cong_codigo;
                         $href.='&sema='.$aso_jwib['fsema'];
                         $href.='&sala='.$cas10;
                         $ref->setAttribute('tabindex','-1');
                         $ref->setAttribute('href',$href);
                         $ref->setAttribute('target','_blank');
                    }
                    
//                     echo '=='.$cas10;
                    if($cas10==1 and !empty($colname))
                    {$tcella->setAttribute('width','30%');}
                    
                    
                    
                    
               }

          }
          $lfecha=$aso_jwib['fechar'];

          $jwol_smm='';
          
          $jwol_smm='<div><strong>'.$aso_jwib['docu_descri'].'</strong></div>';
//           echo '===='.$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);
          
          
//           echo ' == '.$jwol_smm;
          
          if($fechar<="2024-01-01")
          if(mb_stristr($jwol_smm,'<div'))
          {
//                $jwol_smm=substr($jwol_smm,strpos($jwol_smm,'<div'));
//                $jwol_smm=substr($jwol_smm,0,strrpos($jwol_smm,'</div>')+6);
          }

          
          if($vista2==1)
          {
               $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($aso_jwib['docu']=='VM32'){echo '<br>===>'.$jwol_smm;}

//           $trow=$table->appendChild($domd->createElement("tr"));
//                $trow->setAttribute("bb-d1","");
//                $trow->setAttribute("hoverbg","");
//                $trow->setAttribute("brk-inside","");
//                $trow->setAttribute("align-c","");
//                $trow->setAttribute("align-t","");
//                if(date('Y-W')==$aso_jwib['fsema']){$trow->setAttribute("boldsc","");}
//                $trow->setAttribute("style","border-top:solid 1px; ");

          
//           $tcell=$trow->appendChild($domd->createElement("td"," "));
//           $tcell->setAttribute("size80","");
//           if($vista2==1)
//           {$tcell->setAttribute("style","border-top:solid 2px; border-color:black; text-align:left;");}
          
          
//           if(!empty($jwol_smm))
          
          
          
          if($aso_jwib['docu']=='VM11')
          {
               $trow=$table->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("bb-d1","");
                    $trow->setAttribute("hoverbg","");
                    $trow->setAttribute("brk-inside","");
                    $trow->setAttribute("align-c","");
                    $trow->setAttribute("align-m","");
                    if(date('Y-W')==$aso_jwib['fsema']){$trow->setAttribute("boldsc","");}
                    $trow->setAttribute("style","border-top:solid 1px; ");


               
//                $trow=$table->appendChild($domd->createElement("tr"));
//                     $trow->setAttribute("style","border-top:solid 1px;");
//                     $trow->setAttribute("align-c"," ");
//                if(date('Y-W')==$aso_jwib['fsema'])
//                {$trow->setAttribute("boldsc","");}
               
               
               
               $tcell=$trow->appendChild($domd->createElement("td","VMC"));
                    $tcell->setAttribute("rowspan","4");
//                     $tcell->setAttribute("rowspan","5");
                    $tcell->setAttribute("bold","");
                    $tcell->setAttribute("style","border-color:black; background-color:#799FCC; color:white;");
               $tcell=$trow->appendChild($domd->createElement("td","Presidente"));
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n1_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nombre1'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_vmc'];
                    $zsavef='nombre1';
                    $zopen=1; $zwidth='auto';
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",$aso_jwib['nombre1'].' '));}
               
               
               $trow=$table->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("bb-d1","");
                    $trow->setAttribute("align-c"," ");
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}
               $tcell=$trow->appendChild($domd->createElement("td","S.Auxiliar"));
               $tcell=$trow->appendChild($domd->createElement("td",""));
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n2_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nom2vmc'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_vmc'];
                    $zsavef='nombre2';
                    $zopen=1; $zwidth='auto';
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",$aso_jwib['nombre2'].' '));}
          }
          
          if($aso_jwib['docu']=='VM19')
          {
//                $trow=$table->appendChild($domd->createElement("tr"));
//                if(date('Y-W')==$aso_jwib['fsema'])
//                {$trow->setAttribute("boldsc","");}
//                $trow->setAttribute("align-c"," ");

               
               $trow=$table->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("bb-d1","");
                    $trow->setAttribute("hoverbg","");
                    $trow->setAttribute("brk-inside","");
                    $trow->setAttribute("align-c","");
                    $trow->setAttribute("align-m","");
                    if(date('Y-W')==$aso_jwib['fsema']){$trow->setAttribute("boldsc","");}
                    $trow->setAttribute("style","border-top:solid 1px; ");
               
               
               
               $tcell=$trow->appendChild($domd->createElement("td","Oración Inicial"));
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n1_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nombre1'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_ora'];
                    $zsavef='nombre1';
                    $zopen=1; $zwidth='auto';
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",$aso_jwib['nombre1'].' '));}
               
               $trow=$table->appendChild($domd->createElement("tr"));
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}
               $trow->setAttribute("align-c"," ");
               $tcell=$trow->appendChild($domd->createElement("td","Oración Final"));
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n2_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nombre2'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_ora'];
                    $zsavef='nombre2';
                    $zopen=1; $zwidth='auto';
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",$aso_jwib['nombre2'].' '));}
               
          }
          
          if($aso_jwib['docu']=='VM21')
          {
               $trow=$table->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("bb-d1","");
                    $trow->setAttribute("hoverbg","");
                    $trow->setAttribute("brk-inside","");
                    $trow->setAttribute("align-c","");
                    $trow->setAttribute("align-m","");
                    if(date('Y-W')==$aso_jwib['fsema']){$trow->setAttribute("boldsc","");}
                    $trow->setAttribute("style","border-top:solid 1px; ");
               
               
               $tcell=$trow->appendChild($domd->createElement("td","TDB"));
                    $tcell->setAttribute("rowspan","2");
                    $tcell->setAttribute("bold","");
                    $tcell->setAttribute("style","border-color:black;background-color:#5A6A70; color:white;");
               $tcell=$trow->appendChild($domd->createElement("td",""));
               $div=$tcell->appendChild($domd->createElement("div",""));          
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_tdb1'];
               if(!empty($jwol_smm))
               {
//                     $jwol_smm=str_replace('<a','<a tabindex="-1"',$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_smm=str_replace('<p ','<div ',$jwol_smm);
               $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
               if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}
                    
                    $jwol=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n1_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nombre1'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_tdb'];
                    $zsavef='nombre1';
                    $zopen=1; $zwidth='auto';
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",$aso_jwib['nombre1']));
//                     $nombre1=$aso_jwib['nombre1'];
//                                         $href='';
//                                         $href.='https://jwib.vcrxol.com/?scri=jwib_asig4&prnt=1';
//                                         $href.='&info=MMAE';
//                                         $href.='&cong='.$cong_codigo;
//                                         $href.='&idnum='.$aso_jwib['idnum1'];
//                     $ahref=$tcell->appendChild($domd->createElement("a",$nombre1));
//                                         $ahref->setAttribute("href",$href);
//                                         $ahref->setAttribute("target","_blank");
                    

                
               }
               
//                $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom1tdb']));
               
               $trow=$table->appendChild($domd->createElement("tr"));
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}
               $trow->setAttribute("align-c"," ");
               $tcell=$trow->appendChild($domd->createElement("td",""));
               $div=$tcell->appendChild($domd->createElement("div",""));          
//                $div->setAttribute("size80","");
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_tdb2'];
//                if(mb_stristr($jwol_smm,'<a'))
//                $jwol_smm=trim($jwol_smm).'</a>';
               if(!empty($jwol_smm))
               {
//                     $jwol_smm=str_replace('<a','<a tabindex="-1"',$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_smm=str_replace('<p ','<div ',$jwol_smm);
               $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
               if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}
                    
                    $jwol=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n2_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nombre2'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_tdb'];
                    $zsavef='nombre2';
                    $zopen=1; $zwidth='auto';
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",$aso_jwib['nombre2']));}
               
//                $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom2tdb']));
          }
          
          if($aso_jwib['docu']=='VM41')
          {
//                $trow=$table->appendChild($domd->createElement("tr"));
//                if(date('Y-W')==$aso_jwib['fsema'])
//                {$trow->setAttribute("boldsc","");}
//                $trow->setAttribute("align-c","");
//                     $trow->setAttribute("style","border-top:solid 1px;");
               
               
               $trow=$table->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("bb-d1","");
                    $trow->setAttribute("hoverbg","");
                    $trow->setAttribute("brk-inside","");
                    $trow->setAttribute("align-c","");
                    $trow->setAttribute("align-m","");
                    if(date('Y-W')==$aso_jwib['fsema']){$trow->setAttribute("boldsc","");}
                    $trow->setAttribute("style","border-top:solid 1px; ");
               
               
               $tcell=$trow->appendChild($domd->createElement("td","NVC"));
                    $tcell->setAttribute("rowspan","2");
                    $tcell->setAttribute("bold","");
                    $tcell->setAttribute("style","background-color:#961526; color:white;");
               $tcell=$trow->appendChild($domd->createElement("td",""));
               $div=$tcell->appendChild($domd->createElement("div",""));          
               
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_nvc1'];
               if(!empty($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_smm=str_replace('<p ','<div ',$jwol_smm);
               $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
               if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}
                    
                    $jwol=$domd->createDocumentFragment();
//                     echo '*/*/*/*'.$jwol_smm;
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n1_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nombre1'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_nvc'];
                    $zsavef='nombre1';
                    $zopen=1; $zwidth='auto';
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",$aso_jwib['nombre1']));}
               
               
               $trow=$table->appendChild($domd->createElement("tr"));
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}
               $trow->setAttribute("align-c","");
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               $div=$tcell->appendChild($domd->createElement("div",""));          
               
               // NECESIDADES LOCALES
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_nvc2'];
               if(!empty($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_smm=str_replace('<p ','<div ',$jwol_smm);
               $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
               if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}
                    
                    $jwol=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
               
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n2_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nombre2'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_nvc'];
                    $zsavef='nombre2';
                    $zopen=1; $zwidth='auto';
                    if(empty($jwol_smm)){$zhide=1;}
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",$aso_jwib['nombre2']));}
               
//                $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom2nvc']));
          }

          
          if($aso_jwib['docu']=='ELIB')
          {
//                $trow=$table->appendChild($domd->createElement("tr"));
//                if(date('Y-W')==$aso_jwib['fsema'])
//                {$trow->setAttribute("boldsc","");}
//                $trow->setAttribute("align-c","");
//                     $trow->setAttribute("style","border-top:solid 1px;");
               
               
               $trow=$table->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("bb-d1","");
                    $trow->setAttribute("hoverbg","");
                    $trow->setAttribute("brk-inside","");
                    $trow->setAttribute("align-c","");
                    $trow->setAttribute("align-m","");
                    if(date('Y-W')==$aso_jwib['fsema']){$trow->setAttribute("boldsc","");}
                    $trow->setAttribute("style","border-top:solid 1px; ");
               
               
               $estudio='LIBRO';
               if($vista2==1)
               {$estudio='LIB';}
               $tcell=$trow->appendChild($domd->createElement("td",$estudio));
                    $tcell->setAttribute("rowspan","2");
                    $tcell->setAttribute("bold","");
                    $tcell->setAttribute("style","background-color:#5A7EB3; color:white;");
               $tcell=$trow->appendChild($domd->createElement("td",""));
               $div=$tcell->appendChild($domd->createElement("div",""));          
               
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_lib1'];
               if(!empty($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_smm=str_replace('<p ','<div ',$jwol_smm);
               $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
               if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}
                    
                    $jwol=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
               
               
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n1_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nombre1'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_nvc'];
                    $zsavef='nombre1';
                    $zopen=1; $zwidth='auto';
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",$aso_jwib['nombre1']));}
               
               
               $trow=$table->appendChild($domd->createElement("tr"));
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}
               $trow->setAttribute("align-c","");
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               $div=$tcell->appendChild($domd->createElement("div","Lector"));          
               
               
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n2_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nombre2'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_nvc'];
                    $zsavef='nombre2';
                    $zopen=1; $zwidth='auto';
                    if(empty($jwol_smm)){$zhide=1;}
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",ucwords2($aso_jwib['nombre2']) ));}
               
//                $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom2nvc']));
          }

          if($aso_jwib['docu']=='EATA')
          {
//                $trow=$table->appendChild($domd->createElement("tr"));
//                if(date('Y-W')==$aso_jwib['fsema'])
//                {$trow->setAttribute("boldsc","");}
//                $trow->setAttribute("align-c","");
//                     $trow->setAttribute("style","border-top:solid 1px;");
               
               
               $trow=$table->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("bb-d1","");
                    $trow->setAttribute("hoverbg","");
                    $trow->setAttribute("brk-inside","");
                    $trow->setAttribute("align-c","");
                    $trow->setAttribute("align-m","");
                    if(date('Y-W')==$aso_jwib['fsema']){$trow->setAttribute("boldsc","");}
                    $trow->setAttribute("style","border-top:solid 1px; ");
               
               
               $estudio='ATALAYA';
               if($vista2==1)
               {$estudio='ATA';}
               $tcell=$trow->appendChild($domd->createElement("td",$estudio));
                    $tcell->setAttribute("rowspan","2");
                    $tcell->setAttribute("bold","");
                    $tcell->setAttribute("style","background-color:#5A7EB3; color:white;");
               $tcell=$trow->appendChild($domd->createElement("td",""));
               $div=$tcell->appendChild($domd->createElement("div"," "));          
               
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_ata1'];
               if(!empty($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_smm=str_replace('<p ','<div ',$jwol_smm);
               $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
               if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}
                    
                    $jwol=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
               
               
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n1_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nombre1'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_nvc'];
                    $zsavef='nombre1';
                    $zopen=1; $zwidth='auto';
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",$aso_jwib['nombre1']));}
               
               
               $trow=$table->appendChild($domd->createElement("tr"));
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}
               $trow->setAttribute("align-c","");
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               $div=$tcell->appendChild($domd->createElement("div","Lector"));          
               
               // NECESIDADES LOCALES
//                $jwol_smm='';
//                $jwol_smm=$aso_jwib['jwol_nvc2'];
//                if(!empty($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=$domd->createDocumentFragment();
//                     $jwol->appendXML($jwol_smm);               
//                     $div->appendChild($jwol);
//                }
               
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n2_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nombre2'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_nvc'];
                    $zsavef='nombre2';
                    $zopen=1; $zwidth='auto';
                    if(empty($jwol_smm)){$zhide=1;}
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",ucwords2($aso_jwib['nombre2'])));}
               
//                $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom2nvc']));
          }

          
          if(substr($aso_jwib['docu'],0,3)=='VM3')
          {
               $trow=$table->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("bb-d1","");
                    $trow->setAttribute("hoverbg","");
                    $trow->setAttribute("brk-inside","");
                    $trow->setAttribute("align-c","");
                    $trow->setAttribute("align-t","");
                    if(date('Y-W')==$aso_jwib['fsema']){$trow->setAttribute("boldsc","");}
                    $trow->setAttribute("style","border-top:solid 1px; ");
               
               if($smmblock==1)
               {
                    $nomblock='';
                    if($smmblock==2){$nomblock='SMM';}
                    $smmblock++;
                    $nomblock='SMM';
                    $tcell=$trow->appendChild($domd->createElement("td",$nomblock));
//                          $tcell->setAttribute("rowspan","9");
                         $tcell_smm=$tcell;
                         $tcell->setAttribute("bold","");
                         $tcell->setAttribute("align-m","");
                         $tcell->setAttribute("style","border-color:; background-color:#C18626; color:white;");
                    $smmblock=0;
                         if(!empty($aso_jwib['jwol_smm1'])){$row_smm=2;}
                         if(!empty($aso_jwib['jwol_smm2'])){$row_smm=3;}
                         if(!empty($aso_jwib['jwol_smm3'])){$row_smm=4;}
                         if(!empty($aso_jwib['jwol_smm4'])){$row_smm=5;}
                         $tcell_smm->setAttribute("rowspan",$row_smm);
               }
               
                         
               
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               $tcell->setAttribute("size80","");
               if($vista2==1)
               {$tcell->setAttribute("style","border-top:solid 2px; border-color:black; text-align:left;");}
               

               
               
               $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_smm=str_replace('<p ','<div ',$jwol_smm);
               $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
               if(!empty($jwol_smm)){if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}}
               
               $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;}
               
               {
               $jwol='';
               $jwol=$domd->createDocumentFragment();
//                $aa=$jwol->appendXML($jwol_smm);               
                    $jwol->appendXML($jwol_smm);               
               }
               $tcell->appendChild($jwol);
               if($edit==1)
               {$tcell->setAttribute('bold','');}
               
               
//           if($vista2==1)
//           {$tcell->setAttribute("colspan",10);}

               if($vista2==1)
               {
     //                $trow=$table->appendChild($domd->createElement("tr"));
     //                $trow->setAttribute("hoverbg","");
     //                $trow->setAttribute("brk-inside","");
     //                $trow->setAttribute("align-c","");
     //                $trow->setAttribute("align-t","");
               }
          
//                $cas10=0;    
               if(empty($jwol_smm)){$trow->setAttribute('hide',' ');}
                    
//                if(!empty($jwol_smm))
               for($cas10=0; $cas10<=$salas; $cas10++)
               {
                    $discurso=0;
                    $auditorio=0;
                    
                    $id_sala=$aso_jwib['idn_sala'.$cas10];
                    gen_icsjw($id_sala);
                    $nombre1=strtoupper2($aso_jwib['nom1sala'.$cas10]);
                    $nombre2=ucwords2($aso_jwib['nom2sala'.$cas10]);
                    
//                     if(!empty($jwol_smm))
                    if(substr($aso_jwib['docu'],0,3)=='VM3')
                    {
                         $tcell=$trow->appendChild($domd->createElement("td"," "));
                         if($vista2==1)
                         {
                              $nomsala=" ";
                              if($edit==1){$nomsala='SALA ';}
                              $nomsala.=$cas10;
                              if($cas10==0){$nomsala="PRINCIPAL";}
                              $div=$tcell->appendChild($domd->createElement("div",''));
//                               $div->setAttribute('style','float:left;');
                              $div->setAttribute("size80","");
                              
                              if($aso_jwib['fsema']>=date('Y-W'))
                              {$div->setAttribute("bold","");}
                              
                              $ref=$tcell->appendChild($domd->createElement('a',$nomsala));                           
                              $ref->setAttribute('style','color:black !important;');
                              $href='';
                              if($aso_jwib['fsema']>=date('Y-W'))
                              {
                                   $href.='https://jwib.vcrxol.com/?scri=jwib_asig4&prnt=1';
                                   $href.='&info=MMAE';
                                   $href.='&cong='.$cong_codigo;
                                   $href.='&sema='.$aso_jwib['fsema'];
                                   $href.='&sala='.$cas10;
                                   $ref->setAttribute('href',$href);
                                   $ref->setAttribute('target','_blank');
                              }
                              
                         }
                         
                         if(mb_stristr($jwol_smm,'Video de la primera')){$videoprimera=1;}
                         if(mb_stristr($jwol_smm,'Video de la revisita')){$videorevisita=1;}
                         if(mb_stristr($jwol_smm,' Discurso')){$discurso=1;}
                         if(mb_stristr($jwol_smm,'con el auditorio')){$auditorio=1;}
                         
                         $div=$tcell->appendChild($domd->createElement("div"," "));
                              if($edit==1 and $aso_jwib['fechar']>=$editdate and $videoprimera==0 and $videorevisita==0)
                              {
                                   $zdom=$domd;
                                   $zele=$div;
                                   $zid='n1_'.$id_sala;
                                   $zobj=1;
                                   $zvalue=$nombre1;
                                   $zlist='nomb_info';
                                   if($aso_jwib['docu']=='VM30'){$zlist='nomb_varon';}
                                   if($discurso==1){$zlist='nomb_varon';}
                                   if($auditorio==1){$zlist='nomb_varon';}
                                   $zsave=1;
                                   $zsavet='jwib';
                                   $zsavei=$id_sala;
                                   $zsavef='nombre1';
                                   $zopen=1; $zwidth='auto';
                                   include('ele_input.php');
                                   
                                   $zdom=$domd;
                                   $zele=$div;
                                   $zid='n2_'.$id_sala;
                                   $zobj=1;
                                   $zvalue=$nombre2;
                                   $zlist='nomb_info';
                                   $zsave=1;
                                   $zsavet='jwib';
                                   $zsavei=$id_sala;
                                   $zsavef='nombre2';
                                   $zopen=1; $zwidth='auto';
                                   if($aso_jwib['docu']=='VM30'){$zhide=1;}
                                   if($discurso==1){$zhide=1;}
                                   if($auditorio==1){$zhide=1;}
                                   include('ele_input.php');
                                   
                              }
                              else
                              {
                                   if($aso_jwib['fsema']>=date('Y-W'))
                                   {
                                        $href='';
                                        $href.='https://jwib.vcrxol.com/?scri=jwib_asig4&prnt=1';
                                        $href.='&info=MMAE';
                                        $href.='&cong='.$cong_codigo;
                                        $href.='&idnum='.$aso_jwib['idn_sala'.$cas10];
                                       
                                        $ahref=$div->appendChild($domd->createElement("a",$nombre1." "));
                                        $ahref->setAttribute("href",$href);
                                        $ahref->setAttribute("target","_blank");
                                        
                                        
                                   }
                                   else
                                   {$ahref=$div->appendChild($domd->createElement("span",$nombre1));}
                                   
                                   if(!empty($nombre2))
                                   {
                                        if($vista2==0)
                                        {$div=$tcell->appendChild($domd->createElement("p",""));}
                                        $div=$tcell->appendChild($domd->createElement("div"," "));
                                             $ahref=$div->appendChild($domd->createElement("span",$nombre2));
                                   }                              
                                        if($vista2==0)
                                        {$div=$tcell->appendChild($domd->createElement("p",""));}
                                   
                              }
                         
                         
                              if($edit==1 and $aso_jwib['fechar']>=$editdate and $videoprimera==0 and $videorevisita==0 and $suge==1)
                              {

                                   $tcell=$trow->appendChild($domd->createElement("td"," "));
                                   $div=$tcell->appendChild($domd->createElement("div"," "));
                                   $nomb_value='-';
                                   
                                   if($aso_jwib['docu']=='VM30')     
                                   if(empty($nombre1))
                                   {
                                        $nomb_suge1=msql_result(${'res_vm30'.$cas10},${'cont_vm30'.$cas10},'nombre1');
                                        $nomb_value='';
                                        $nomb_value.=substr(msql_result(${'res_vm30'.$cas10},${'cont_vm30'.$cas10},'fecha'),0,7);
                                        $nomb_value.=' : ';
                                        $nomb_value.=$nomb_suge1;
                                        ${'cont_vm30'.$cas10}++;
                                   }
                                   
                                   if($aso_jwib['docu']=='VM31')     
                                   if(empty($nombre1))
                                   {
                                        $nomb_suge1=msql_result(${'res_vm39'.$cas10},${'cont_vm39'.$cas10},'nombre1');
                                        $nomb_value='';
                                        $nomb_value.=substr(msql_result(${'res_vm39'.$cas10},${'cont_vm39'.$cas10},'fecha'),0,7);
                                        $nomb_value.=' : ';
                                        $nomb_value.=$nomb_suge1;
                                        ${'cont_vm39'.$cas10}++;
                                   }
                                   
//                                         echo '<br>===='.$aso_jwib['jwol_smm1'];
//                                         echo '<br>===='.$aso_jwib['jwol_smm2'];
//                                         echo '<br>===='.$aso_jwib['jwol_smm3'];
//                                         echo '<br>===='.$aso_jwib['jwol_smm4'];
                                             
                                   
                                   if(mb_stristr($aso_jwib['jwol_smm1'].$aso_jwib['jwol_smm2'].$aso_jwib['jwol_smm3'].$aso_jwib['jwol_smm4'],'. Discurso'))
                                   if(empty($nombre1))
                                   {
                                        $nomb_suge1=msql_result(${'res_vm35'.$cas10},${'cont_vm35'.$cas10},'nombre1');
                                        $nomb_value='';
                                        $nomb_value.=substr(msql_result(${'res_vm35'.$cas10},${'cont_vm35'.$cas10},'fecha'),0,7);
                                        $nomb_value.=' : ';
                                        $nomb_value.=$nomb_suge1;
                                        ${'cont_vm35'.$cas10}++;
                                   }
                                   
                                   
                                   if(
                                        !mb_stristr($aso_jwib['jwol_smm1'].$aso_jwib['jwol_smm2'].$aso_jwib['jwol_smm3'].$aso_jwib['jwol_smm4'],'. Empiece')
                                        and !mb_stristr($aso_jwib['jwol_smm1'].$aso_jwib['jwol_smm2'].$aso_jwib['jwol_smm3'].$aso_jwib['jwol_smm4'],'. Haga')
                                        and !mb_stristr($aso_jwib['jwol_smm1'].$aso_jwib['jwol_smm2'].$aso_jwib['jwol_smm3'].$aso_jwib['jwol_smm4'],'. Explique')
                                        and !mb_stristr($aso_jwib['jwol_smm1'].$aso_jwib['jwol_smm2'].$aso_jwib['jwol_smm3'].$aso_jwib['jwol_smm4'],'. Discurso')
                                   )
                                   if(empty($nombre1))
                                   {
                                        $nomb_suge1=msql_result(${'res_vm36'.$cas10},${'cont_vm36'.$cas10},'nombre1');
                                        $nomb_value='';
                                        $nomb_value.=substr(msql_result(${'res_vm36'.$cas10},${'cont_vm36'.$cas10},'fecha'),0,7);
                                        $nomb_value.=' : ';
                                        $nomb_value.=$nomb_suge1;
                                        ${'cont_vm36'.$cas10}++;
                                   }
                                   
                                   
                                   
                                   $xid='n1_'.$id_sala;
                                   $ondblclick='';
                                   $ondblclick.='{if(document.getElementById("'.$xid.'").value=="'.$nomb_suge1.'"){document.getElementById("'.$xid.'").value=".";}';
                                   $ondblclick.='else{document.getElementById("'.$xid.'").value="'.$nomb_suge1.'";};}';
                                   $ondblclick.='{document.getElementById("'.$xid.'").onblur();}';
                                   $tcell->setAttribute('onclick',$ondblclick);
                                   $span=$div->appendChild($domd->createElement('span',$nomb_value));    
                                   
                              }
     
                    }
                    
                    if($videoprimera==1){break;}
                    if($videorevisita==1){break;}
//                     echo '==='.$auditorio;
                    if($auditorio==1){break;}
                    
                    
               }
               
               
               
               
          }

     }
}    

     
     
if($info=='ASEM')
{

     if($vista2==1)
     {
//           $trow=$table->appendChild($domd->createElement("tr"));
//           {$trow->setAttribute("style","border-top:solid 2px;background-color: #A9F5F2;");}
//           $tcell=$trow->appendChild($domd->createElement("th","ASIGNACIONES - ".strftime2('%B / %Y',strtotime($fecha1))));
//           $tcell->setAttribute("colspan","10");
//           $tcell->setAttribute("style","height:2.5em;");
     }

     $lfecha='';
     $lmonth='';
     msql_data_seek($res_jwib,0);     
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {for($cas10=11; $cas10<=19; $cas10++){gen_icsjw($aso_jwib['idn_'.$cas10]);}}

     msql_data_seek($res_jwib,0);     
     if($vista2==0)
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {
          if(substr($aso_jwib['fechar'],0,7)!=$lmonth)
          {
               $crow=0;


               // TABLA
               {
                    $smmblock=1;
                    $table=$domd->appendChild($domd->createElement("table"));
                    $brktab=$domd->appendChild($domd->createElement("p"));
                         $table->setAttribute("border","1");
          //                $table->setAttribute("width","100%");   
                         $table->setAttribute("width","99%");   
                         $table->setAttribute("style","page-break-inside: avoid; break-inside: avoid;");   
                         if($edit!=1)
                         {
                         $table->setAttribute("bt-s1","");   
                         $table->setAttribute("bb-s1","");   
                         }

                         if($vista2==1 and $_SESSION['screeno']!=1)
                         {$table->setAttribute("width",(int)($_SESSION['screenw']*(0.5)).'px');}


               }

               $trow=$table->appendChild($domd->createElement("tr"));
               $trow->setAttribute("sticky","");
               $trow->setAttribute("style","border-top:solid 2px;background-color: #A9F5F2; top:100px;");
               
               $tcell=$trow->appendChild($domd->createElement("th","SEMANALES - ".strftime2('%B / %Y',strtotime($aso_jwib['fechar']))));
               
               $tcell->setAttribute("colspan","20");
               $tcell->setAttribute("style","height:2.5em;");

               $trow=$table->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("sticky","");
                    $trow->setAttribute("style","border-top:solid 2px;background-color: #A9F5F2; top:140px;");
               $tcell=$trow->appendChild($domd->createElement("th","Fecha"));
                    if($edit!=1)
                    {$trow->setAttribute("bb-s1","");}

               for($cas10=11; $cas10<=19; $cas10++)
               {
//                     $colname=msql_result($res_jwib,0,'docud_'.$cas10);
                    $colname=$aso_jwib['docud_'.$cas10];
                    $tcell=$trow->appendChild($domd->createElement("th",$colname));
               }
               
               $lmonth=substr($aso_jwib['fechar'],0,7);
          }
          
          
          $crow++;
          $trow=$table->appendChild($domd->createElement("tr"));
               $trow->setAttribute("bb-d1","");
               $trow->setAttribute("hoverbg","");
               $trow->setAttribute("brk-inside","");
               $trow->setAttribute("align-c","");
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}
               $xstyle="border-bottom:1px solid;";
//           if(($crow % 2)==0){$xstyle.='background-color:#eaecee;';}
               if(($crow % 2)==0){$xstyle.='background-color:#f5f5f5;';}
               $trow->setAttribute("style",$xstyle);
          
          $fechar1=$aso_jwib['fechar'];
          $sql_dpu1='select * from jwib1 where docu="DPU1" and cong="'.$cong_codigo.'" and fecha="'.$aso_jwib['fecha'].'"';
          $res_dpu1=msql_query($sql_dpu1,$link_data);
          $fechar2=msql_result($res_dpu1,0,'fechar');
          
          
          $tcell=$trow->appendChild($domd->createElement("td",""));
               if($edit==1)
               {
                    $tcell->setAttribute("sticky-left","");
                    $div=$tcell->appendChild($domd->createElement("div",strftime2('%a %d/%b',strtotime($fechar1))));
                    $div=$tcell->appendChild($domd->createElement("br",));
                    $div=$tcell->appendChild($domd->createElement("div",strftime2('%a %d/%b',strtotime($fechar2))));
               }
               else
               {
//                     $div=$tcell->appendChild($domd->createElement("div",strftime2('%a-%d',strtotime($fechar1)).'  '.strftime2('%a-%d',strtotime($fechar2))));
                    $tcell->setAttribute("sticky-left","");
                    $div=$tcell->appendChild($domd->createElement("div",strftime2('%a/%d',strtotime($fechar1))));
                    $div=$tcell->appendChild($domd->createElement("br",));
                    $div=$tcell->appendChild($domd->createElement("div",strftime2('%a/%d',strtotime($fechar2))));
//                     $tcell->setAttribute("nowrap","");
               }
          
               for($cas10=11; $cas10<=19; $cas10++)
               {
                    $id_sala=$aso_jwib['idn_'.$cas10];
                    $colname=trim($aso_jwib['docud_'.$cas10]);
//                     echo '<br>*/*/*'.$colname;
                    
//                     if(!empty($colname))
                    {
                    $nombre1=ucwords2($aso_jwib['nom1_'.$cas10]);
                    $nombre2=ucwords2($aso_jwib['nom2_'.$cas10]);
                    $nombre3=ucwords2($aso_jwib['nom3_'.$cas10]);
                    $nombre4=ucwords2($aso_jwib['nom4_'.$cas10]);
                    $tcell=$trow->appendChild($domd->createElement("td",""));
//                     if(empty($colname))
//                     {$tcell->setAttribute("style","display:none;");}

//                     if($edit==1)
                    if($edit==1 and $aso_jwib['fsema']>=$editweek)
                    {
//                          $tcell->setAttribute("valign","top");
                         $zdom=$domd;
                         $zele=$tcell;
                         $zid='n1_'.$id_sala;
                         $zobj=1;
                         $zvalue=$nombre1;
                         // $ztabla='nomb';
                         $zlist='nomb_info';
                         $zsave=1;
                         $zsavet='jwib';
                         $zsavei=$id_sala;
                         $zsavef='nombre1';
                         $zopen=1; $zwidth='auto';
                         if($aso_jwib['docuc_'.$cas10]=='AS11'){$zreado=1;}
                         include('ele_input.php');
                         
                         $zdom=$domd;
                         $zele=$tcell;
                         $zid='n2_'.$id_sala;
                         $zobj=1;
                         $zvalue=$nombre2;
                         // $ztabla='nomb';
                         $zlist='nomb_info';
                         $zsave=1;
                         $zsavet='jwib';
                         $zsavei=$id_sala;
                         $zsavef='nombre2';
                         $zopen=1; $zwidth='auto';
                         if($aso_jwib['docuc_'.$cas10]=='AS11'){$zhide=1;}
                         if($aso_jwib['docuc_'.$cas10]=='AS12'){$zhide=1;}
                         if($aso_jwib['docuc_'.$cas10]=='AS19'){$zhide=1;}
                         include('ele_input.php');
                         
                         $div=$tcell->appendChild($domd->createElement("hr",""));
                         
                         $zdom=$domd;
                         $zele=$tcell;
                         $zid='n3_'.$id_sala;
                         $zobj=1;
                         $zvalue=$nombre3;
                         // $ztabla='nomb';
                         $zlist='nomb_info';
                         $zsave=1;
                         $zsavet='jwib';
                         $zsavei=$id_sala;
                         $zsavef='nombre3';
                         $zopen=1; $zwidth='auto';
                         include('ele_input.php');
                         
                         $zdom=$domd;
                         $zele=$tcell;
                         $zid='n4_'.$id_sala;
                         $zobj=1;
                         $zvalue=$nombre4;
                         // $ztabla='nomb';
                         $zlist='nomb_info';
                         $zsave=1;
                         $zsavet='jwib';
                         $zsavei=$id_sala;
                         $zsavef='nombre4';
                         $zopen=1; $zwidth='auto';
                         if($aso_jwib['docuc_'.$cas10]=='AS11'){$zhide=1;}
                         if($aso_jwib['docuc_'.$cas10]=='AS12'){$zhide=1;}
                         if($aso_jwib['docuc_'.$cas10]=='AS19'){$zhide=1;}
                         include('ele_input.php');
                         
                         
                    }
                    else
                    {
                         $div=$tcell->appendChild($domd->createElement("div",$nombre1));
//                          $div=$tcell->appendChild($domd->createElement("hr",""));
                         $div=$tcell->appendChild($domd->createElement("div",$nombre2));
                         
                         if(!empty($nombre3.$nombre4))
                         {
                         $div=$tcell->appendChild($domd->createElement("hr",""));
                         $div=$tcell->appendChild($domd->createElement("div",$nombre3));
                         $div=$tcell->appendChild($domd->createElement("div",$nombre4));
                         }
                    }
                         
                    }
                         
               }
     }

     $lfecha='';
     $lmonth='';
     $idxbrow=0;
     if($vista2==1)
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {
          if(substr($aso_jwib['fechar'],0,7)!=$lmonth)
          {
//                echo '*/*/*'.$lmonth;
               $trow=$table->appendChild($domd->createElement("tr"));
               
               $trow->setAttribute("sticky","");
               $trow->setAttribute("style","border-top:solid 2px;background-color: #A9F5F2; top:100px;");
               
               $tcell=$trow->appendChild($domd->createElement("th","SEMANALES - ".strftime2('%B / %Y',strtotime($aso_jwib['fechar']))));
//                $tcell=$trow->appendChild($domd->createElement("th"," ".strftime2('%B / %Y',strtotime($aso_jwib['fechar']))));
               $tcell->setAttribute("colspan","10");
               $tcell->setAttribute("style","height:2.5em;");
               $lmonth=substr($aso_jwib['fechar'],0,7);
          }
          
          
          if($lfecha!=$aso_jwib['fechar'])
          {
               $trow=$table->appendChild($domd->createElement("tr"));
               $trow->setAttribute("sticky-t140","");
               $trow->setAttribute("style","border-top:solid 2px;background-color: #A9F5F2;");
               $trow->setAttribute("align-c","");
               {$trow->setAttribute("bold","");}

//                if(date('Y-m')==$mes)
//                if(date('Y-W')==date('Y-W',strtotime($aso_jwib['fechar'].' -1 week')))
//                {$trow->setAttribute("id","scrollhere");}
               
               $fechar=$aso_jwib['fecha'];
               $fechar1=$aso_jwib['fechar'];
               $sql_dpu1='select * from jwib1 where docu="DPU1" and cong="'.$cong_codigo.'" and fecha="'.$aso_jwib['fecha'].'"';
               $res_dpu1=msql_query($sql_dpu1,$link_data);
               $fechar2=msql_result($res_dpu1,0,'fechar');
               
          $tcell=$trow->appendChild($domd->createElement("td"," "));
               
               if($edit==1)
               {$div=$tcell->appendChild($domd->createElement("div",strftime2('%B',strtotime($fechar1))));}
          $tcell=$trow->appendChild($domd->createElement("td",""));
               {$div=$tcell->appendChild($domd->createElement("div",strftime2('%a /%d',strtotime($fechar1))));}
          $tcell=$trow->appendChild($domd->createElement("td",""));
               {$div=$tcell->appendChild($domd->createElement("div",strftime2('%a /%d',strtotime($fechar2))));}
               
               
               $idxbrow=0;
          }
          $lfecha=$aso_jwib['fechar'];

          $idxbrow++;
          $trow=$table->appendChild($domd->createElement("tr"));
               if($edit!=1)
               {
                    if($idxbrow%2==0)
                    {$trow->setAttribute("bb-d1","");}
               }
               $trow->setAttribute("hoverbg","");
               $trow->setAttribute("brk-inside","");
               $trow->setAttribute("align-c","");
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}

          $tcell=$trow->appendChild($domd->createElement("td",ucwords2($aso_jwib['docu_descri'])));
               $tcell->setAttribute("width","20%");
          
          $id_sala=$aso_jwib['idnum1'];
//           $id_sala=$aso_jwib['idn_'.$cas10];
          
          $nombre1=ucwords2($aso_jwib['nombre1']);
          $nombre2=ucwords2($aso_jwib['nombre2']);
          $nombre3=ucwords2($aso_jwib['nombre3']);
          $nombre4=ucwords2($aso_jwib['nombre4']);
          
          $nombres=$nombre1;
          if(!empty($nombre2)){$nombres.=' - '.$nombre2;}
          if(!empty($nombre3)){$nombres.=' - '.$nombre3;}
          if(!empty($nombre4)){$nombres.=' - '.$nombre4;}
          
          $tcell=$trow->appendChild($domd->createElement("td",""));
               $tcell->setAttribute("width","40%");

               if($edit==0)
               if($aso_jwib['fechar']>=date('Y-m-d'))
               {
                    $href='https://vcrxol.com/jwib/';
                    $href.="_doc/".$aso_jwib['docu'].'_'.str_pad($aso_jwib['idnum1'],9,'0',STR_PAD_LEFT).".ics";
     //                $tcell->setAttribute('onclick','{window.open("'.$href.'")}');
                    $tcell->setAttribute('onclick','{down_ics_jw("'.$href.'","'.$aso_jwib['docu_descri'].'","'.$nombres.'")}');
               }
          
          
          
//           if($edit==1 and $aso_jwib['fechar']>=date('Y-m-d'))
          if($edit==1 and $aso_jwib['fsema']>=$editweek)
          {
               $zdom=$domd;
               $zele=$tcell;
               $zid='n1_'.$id_sala;
               $zobj=1;
               $zvalue=$nombre1;
               // $ztabla='nomb';
               $zlist='nomb_info';
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$id_sala;
               $zsavef='nombre1';
               $zopen=1; $zwidth='auto';
//                if($aso_jwib['docuc_'.$cas10]=='AS11'){$zreado=1;}
               if($aso_jwib['docu']=='AS11'){$zreado=1;}
               include('ele_input.php');

               $zdom=$domd;
               $zele=$tcell;
               $zid='n2_'.$id_sala;
               $zobj=1;
               $zvalue=$nombre2;
               // $ztabla='nomb';
               $zlist='nomb_info';
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$id_sala;
               $zsavef='nombre2';
               $zopen=1; $zwidth='auto';
               if($aso_jwib['docu']=='AS11'){$zhide=1;}
               if($aso_jwib['docu']=='AS12'){$zhide=1;}
               if($aso_jwib['docu']=='AS19'){$zhide=1;}
//                if($aso_jwib['docuc_'.$cas10]=='AS11'){$zhide=1;}
//                if($aso_jwib['docuc_'.$cas10]=='AS12'){$zhide=1;}
//                if($aso_jwib['docuc_'.$cas10]=='AS19'){$zhide=1;}
               include('ele_input.php');

//                $div=$tcell->appendChild($domd->createElement("hr",""));
               $tcell=$trow->appendChild($domd->createElement("td",""));
                    $tcell->setAttribute("width","40%");

               $zdom=$domd;
               $zele=$tcell;
               $zid='n3_'.$id_sala;
               $zobj=1;
               $zvalue=$nombre3;
               // $ztabla='nomb';
               $zlist='nomb_info';
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$id_sala;
               $zsavef='nombre3';
               $zopen=1; $zwidth='auto';
               include('ele_input.php');

               $zdom=$domd;
               $zele=$tcell;
               $zid='n4_'.$id_sala;
               $zobj=1;
               $zvalue=$nombre4;
               // $ztabla='nomb';
               $zlist='nomb_info';
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$id_sala;
               $zsavef='nombre4';
               $zopen=1; $zwidth='auto';
               if($aso_jwib['docu']=='AS11'){$zhide=1;}
               if($aso_jwib['docu']=='AS12'){$zhide=1;}
               if($aso_jwib['docu']=='AS19'){$zhide=1;}
//                if($aso_jwib['docuc_'.$cas10]=='AS11'){$zhide=1;}
//                if($aso_jwib['docuc_'.$cas10]=='AS12'){$zhide=1;}
//                if($aso_jwib['docuc_'.$cas10]=='AS19'){$zhide=1;}
               include('ele_input.php');


          }
          else
          {
               $div=$tcell->appendChild($domd->createElement("div",$nombre1));
               $div=$tcell->appendChild($domd->createElement("div",$nombre2));
               $tcell=$trow->appendChild($domd->createElement("td",""));
                    $tcell->setAttribute("width","40%");
               $div=$tcell->appendChild($domd->createElement("div",$nombre3));
               $div=$tcell->appendChild($domd->createElement("div",$nombre4));
               
          }          
     }     

}
     
     
if($info=='MMAE')
{
     
     if($suge==1)
     {
          $res_vm300=get_suge('VM30','0');
          $res_vm301=get_suge('VM30','1');
          $res_vm302=get_suge('VM30','2');
          
          $res_vm340=get_suge('VM34','0');
          $res_vm341=get_suge('VM34','1');
          $res_vm342=get_suge('VM34','2');
          
          $res_vm350=get_suge('VM35','0');
          $res_vm351=get_suge('VM35','1');
          $res_vm352=get_suge('VM35','2');
          
          $res_vm360=get_suge('VM36','0');
//           $res_vm361=get_suge('VM36','1');
//           $res_vm362=get_suge('VM36','2');
          
          $res_vm390=get_suge('VM39','0');
          $res_vm391=get_suge('VM39','1');
          $res_vm392=get_suge('VM39','2');
          
     }
     
     $lfecha='';
     $lmonth='';
     msql_data_seek($res_jwib,0);     
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {
//           gen_icsjw($aso_jwib['idnum1']);
          $videoprimera=0;
          $videorevisita=0;
          
          $auditorio=0;
          $discurso=0;
          
          if($lmonth!=substr($aso_jwib['fechar'],0,7))
          {
               
     // TABLA
     {
          $smmblock=1;
          $table=$domd->appendChild($domd->createElement("table"));
          $brktab=$domd->appendChild($domd->createElement("p"));
               $table->setAttribute("border","1");
//                $table->setAttribute("width","100%");   
               $table->setAttribute("width","99%");   
//                $table->setAttribute("style","page-break-inside: auto; break-inside: ;");   
               if($edit!=1)
               {
               $table->setAttribute("bt-s1","");   
               $table->setAttribute("bb-s1","");   
               }

               if($vista2==1 and $_SESSION['screeno']!=1)
               {$table->setAttribute("width",(int)($_SESSION['screenw']*(0.5)).'px');}

          
     }
               $thead=$table->appendChild($domd->createElement("thead"));
               $thead->setAttribute("style","display: table-header-group;");
               
               $trow=$thead->appendChild($domd->createElement("tr"));
                    $xstyle="border-top:solid 2px; border-color:black; background-color:#C18626;color:white; top:100px;";
                    // $xstyle.="page-break-inside: avoid; break-inside: avoid;";
                    $trow->setAttribute("style",$xstyle);
                    $table->setAttribute("style",);   
                    $trow->setAttribute("sticky","");
               
               $mesanio=strftime2('%B / %Y',strtotime($aso_jwib['fechar']));
               if($vista2==0)
               {
                    $tcell=$trow->appendChild($domd->createElement("th",''));
                    $tcell2=$tcell->appendChild($domd->createElement("span",''));
                    $tcell->setAttribute("width","30%");
                    if($salas==0){$tcell->setAttribute("width","50%");}
                    $tcell=$trow->appendChild($domd->createElement("th","MEJORES MAESTROS"));
               }
               if($vista2==1)
               {
                    $tcell=$trow->appendChild($domd->createElement("th","MEJORES MAESTROS - ".$mesaniox));
                    $tcell2=$tcell->appendChild($domd->createElement("span",''));
               }

               $tcell->setAttribute("colspan","10");
               $tcell->setAttribute("style","height:2.5em; ");

               $colname=$mesanio;
               if($aso_jwib['fsema']<date('Y-W'))
               {$ref=$tcell2->appendChild($domd->createElement('span',$colname));} 

               if($aso_jwib['fsema']>=date('Y-W'))
               {
                    $ref=$tcell2->appendChild($domd->createElement('a',$colname));                           
                    $ref->setAttribute('style','color:white !important;');
                    $href='';
                    $href.='https://jwib.vcrxol.com/?scri=jwib_asig4&prnt=1';
                    $href.='&info=MMAE';
                    $href.='&cong='.$cong_codigo;
                    $href.='&ames='.substr($aso_jwib['fecha'],0,7);
                    $ref->setAttribute('tabindex','-1');
                    $ref->setAttribute('href',$href);
                    $ref->setAttribute('target','_blank');

               }
               
               $lmonth=substr($aso_jwib['fechar'],0,7);
          }


          if($lfecha!=$aso_jwib['fechar'])
          {
//                $idx_gc++;
//                $group_class[$idx_gc]='GC_'.$aso_jwib['fechar'];
//                $group_class[$idx_gc]=str_replace('-','',$group_class[$idx_gc]);
               
//                
//                $thead=$table->appendChild($domd->createElement("thead"));
//                $thead->setAttribute("style","display: table-header-group; page-break-inside: avoid;");
//                $thead->setAttribute("class",$group_class[$idx_gc]);

               $tbody=$table->appendChild($domd->createElement("tbody"));
               $tbody->setAttribute("style","display: table-row-group; page-break-inside: avoid;");
               $tbody->setAttribute("class",$group_class[$idx_gc]);
               
               
//                $trow=$table->appendChild($domd->createElement("tr"));
               $trow=$tbody->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("style","border-top:solid 2px; border-color:black; background-color: #C18626; color:white; ");
                    if($vista2==1)
                    $trow->setAttribute("style","border-top:solid 2px; border-color:black; background-color: #C18626; color:white; ");
                    $trow->setAttribute("sticky-t140","");
               
               $tcell=$trow->appendChild($domd->createElement("th",''));
//                $tcell->setAttribute("style","display: table-header-group;");
               
               if($edit==1)
               {$colname= strftime2('%A %d/%B',strtotime($aso_jwib['fechar']));}
               else
               {$colname= strftime2('%A / %d',strtotime($aso_jwib['fechar']));}
               
               
               if($aso_jwib['fsema']<date('Y-W'))
               {$ref=$tcell->appendChild($domd->createElement('span',$colname));} 

               if($aso_jwib['fsema']>=date('Y-W'))
               {
                    $ref=$tcell->appendChild($domd->createElement('a',$colname));                           
                    $ref->setAttribute('style','color:white !important;');
                    $href='';
                    $href.='https://jwib.vcrxol.com/?scri=jwib_asig4&prnt=1';
                    $href.='&info=MMAE';
                    $href.='&cong='.$cong_codigo;
                    $href.='&sema='.$aso_jwib['fsema'];
//                          $href.='&sala='.$cas10;
                    $ref->setAttribute('tabindex','-1');
                    $ref->setAttribute('href',$href);
                    $ref->setAttribute('target','_blank');

               }
               

//                if(date('Y-m')==$mes)
//                if(date('Y-W')==$aso_jwib['fsema'])
//                {$trow->setAttribute("id","scrollhere");}
               
               
               $tcell->setAttribute("nowrap","");
               if($vista2==1)
               {$tcell->setAttribute("colspan",10);}

               if($edit!=1)
               {
               $sql_salas='select * from jwib1 ';
               $sql_salas.='where cong="'.$cong_codigo.'" ';
               $sql_salas.='and fecha="'.$aso_jwib['fecha'].'" ';
               $sql_salas.='and ifnull(nombre1,"")!="" ';
               $sql_salas.='order by sala desc ';
               $res_salas=msql_query($sql_salas,$link_data);
               $salas=msql_result($res_salas,0,'sala');
               }
               
               if($vista2==0)
               for($cas10=0; $cas10<=$salas; $cas10++)
               {
                    $colname='SALA '.$cas10;
                    if($cas10==0)
                    {$colname='PRINCIPAL';}
                    $tcell=$trow->appendChild($domd->createElement("th",''));

//                     if($aso_jwib['fsema']<date('Y-W'))
//                     {$ref=$tcell->appendChild($domd->createElement('span',$colname));} 
                    
//                     if($aso_jwib['fsema']>=date('Y-W'))
                    {
                         $ref=$tcell->appendChild($domd->createElement('a',$colname));                           
                         $ref->setAttribute('style','color:white !important;');
                         $href='';
                         $href.='https://jwib.vcrxol.com/?scri=jwib_asig4&prnt=1';
                         $href.='&info=MMAE';
                         $href.='&cong='.$cong_codigo;
                         $href.='&sema='.$aso_jwib['fsema'];
                         $href.='&sala='.$cas10;
                         $ref->setAttribute('tabindex','-1');
                         $ref->setAttribute('href',$href);
                         $ref->setAttribute('target','_blank');
                         
                    }
                    
               }

          }
          $lfecha=$aso_jwib['fechar'];

          $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);
          
          if($fechar<="2024-01-01")
          if(mb_stristr($jwol_smm,'<div'))
          {
//                $jwol_smm=substr($jwol_smm,strpos($jwol_smm,'<div'));
//                $jwol_smm=substr($jwol_smm,0,strrpos($jwol_smm,'</div>')+6);
          }

          
          if($vista2==1)
          {
               $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($aso_jwib['docu']=='VM32'){echo '<br>===>'.$jwol_smm;}
          

//           $trow=$table->appendChild($domd->createElement("tr"));
//           if($vista2==0)
          {$trow=$tbody->appendChild($domd->createElement("tr"));}
//           if($vista2==1)
//           {$trow=$table->appendChild($domd->createElement("tr"));}
          
               $trow->setAttribute("bb-d1","");
               $trow->setAttribute("hoverbg","");
               $trow->setAttribute("brk-inside","");
               $trow->setAttribute("align-c","");
               $trow->setAttribute("align-t","");

               if(date('Y-W')==$aso_jwib['fsema'])
               {
                    $trow->setAttribute("boldsc","");
               }
          
          $tcell=$trow->appendChild($domd->createElement("td"));
          $tcell->setAttribute("size80","");
          if($vista2==1)
          {$tcell->setAttribute("style","border-top:solid 2px; border-color:black; text-align:left;");}
          
          
          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_smm=str_replace('<p ','<div ',$jwol_smm);
               $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
               if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}
               
               $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;}
               
               {
               $jwol='';
               $jwol=$domd->createDocumentFragment();
//                $aa=$jwol->appendXML($jwol_smm);               
                    $jwol->appendXML($jwol_smm);               
               }
               $tcell->appendChild($jwol);
               if($edit==1)
               {$tcell->setAttribute('bold','');}
          }
          
          

          if($vista2==1)
          {$tcell->setAttribute("colspan",10);}

          if($vista2==1)
          {
//                $trow=$table->appendChild($domd->createElement("tr"));
               $trow=$tbody->appendChild($domd->createElement("tr"));
               $trow->setAttribute("hoverbg","");
               $trow->setAttribute("brk-inside","");
               $trow->setAttribute("align-c","");
               $trow->setAttribute("align-t","");
          }
          
               for($cas10=0; $cas10<=$salas; $cas10++)
               {
                    $discurso=0;
                    $auditorio=0;
                    
                    $id_sala=$aso_jwib['idn_sala'.$cas10];
                    gen_icsjw($id_sala);
                    $nombre1=strtoupper2($aso_jwib['nom1sala'.$cas10]);
                    $nombre2=ucwords2($aso_jwib['nom2sala'.$cas10]);
                    
                    if(!empty($jwol_smm))
                    {
                         if($edit==1 and $vista2==1)
                         {$trow=$trow->appendChild($domd->createElement("tr"));}
                              
                         $tcell=$trow->appendChild($domd->createElement("td"));
                         if($vista2==1)
                         {
                              $nomsala=" ";
                              if($edit==1){$nomsala='SALA ';}
                              $nomsala.=$cas10;
                              if($cas10==0){$nomsala="PRINCIPAL";}
                              $div=$tcell->appendChild($domd->createElement("div",''));
//                               $div->setAttribute('style','float:left;');
                              $div->setAttribute("size80","");
                              
                              if($aso_jwib['fsema']>=date('Y-W'))
                              {$div->setAttribute("bold","");}
                              
                              $ref=$tcell->appendChild($domd->createElement('a',$nomsala));                           
                              $ref->setAttribute('style','color:black !important;');
                              $href='';
                              if($aso_jwib['fsema']>=date('Y-W'))
                              {
                                   $href.='https://jwib.vcrxol.com/?scri=jwib_asig4&prnt=1';
                                   $href.='&info=MMAE';
                                   $href.='&cong='.$cong_codigo;
                                   $href.='&sema='.$aso_jwib['fsema'];
                                   $href.='&sala='.$cas10;
                                   $ref->setAttribute('href',$href);
                                   $ref->setAttribute('target','_blank');
                              }
                              
                         }
                         
                         if(mb_stristr($jwol_smm,'Video de la primera')){$videoprimera=1;}
                         if(mb_stristr($jwol_smm,'Video de la revisita')){$videorevisita=1;}
                         if(mb_stristr($jwol_smm,' Discurso')){$discurso=1;}
                         if(mb_stristr($jwol_smm,'con el auditorio')){$auditorio=1;}
                         
                         $div=$tcell->appendChild($domd->createElement("div"," "));
                              if($edit==1 and $aso_jwib['fechar']>=$editdate and $videoprimera==0 and $videorevisita==0)
                              {
                                   $zdom=$domd;
                                   $zele=$div;
                                   $zid='n1_'.$id_sala;
                                   $zobj=1;
                                   $zvalue=$nombre1;
                                   $zlist='nomb_info';
                                   if($aso_jwib['docu']=='VM30'){$zlist='nomb_varon';}
                                   if($discurso==1){$zlist='nomb_varon';}
                                   if($auditorio==1){$zlist='nomb_varon';}
                                   $zsave=1;
                                   $zsavet='jwib';
                                   $zsavei=$id_sala;
                                   $zsavef='nombre1';
                                   $zopen=1; $zwidth='auto';
                                   include('ele_input.php');
                                   
                                   $zdom=$domd;
                                   $zele=$div;
                                   $zid='n2_'.$id_sala;
                                   $zobj=1;
                                   $zvalue=$nombre2;
                                   $zlist='nomb_info';
                                   $zsave=1;
                                   $zsavet='jwib';
                                   $zsavei=$id_sala;
                                   $zsavef='nombre2';
                                   $zopen=1; $zwidth='auto';
                                   if($aso_jwib['docu']=='VM30'){$zhide=1;}
                                   if($discurso==1){$zhide=1;}
                                   if($auditorio==1){$zhide=1;}
                                   include('ele_input.php');
                                   
                              }
                              else
                              {
//                                    if($aso_jwib['fechar']>date('Y-m-d'))
                                   if($aso_jwib['fsema']>=date('Y-W'))
                                   {
                                        $href='';
                                        $href.='https://jwib.vcrxol.com/?scri=jwib_asig4&prnt=1';
                                        $href.='&info=MMAE';
                                        $href.='&cong='.$cong_codigo;
//                                         $href.='&sema='.$aso_jwib['fsema'];
//                                         $href.='&sala='.$cas10;
                                        $href.='&idnum='.$aso_jwib['idn_sala'.$cas10];
                                       
                                        $ahref=$div->appendChild($domd->createElement("a",$nombre1." "));
//                                         $ahref->setAttribute("href","_doc/".$aso_jwib['docu'].'_'.str_pad($id_sala,9,'0',STR_PAD_LEFT).".ics");
                                        $ahref->setAttribute("href",$href);
                                        $ahref->setAttribute("target","_blank");
                                        
                                        
                                   }
                                   else
                                   {$ahref=$div->appendChild($domd->createElement("span",$nombre1));}
                                   
                                   if(!empty($nombre2))
                                   {
                                        if($vista2==0)
                                        {$div=$tcell->appendChild($domd->createElement("p",""));}
                                        $div=$tcell->appendChild($domd->createElement("div"," "));
                                             $ahref=$div->appendChild($domd->createElement("span",$nombre2));
                                   }                              
                                        if($vista2==0)
                                        {$div=$tcell->appendChild($domd->createElement("p",""));}
                                   
                              }
                         
                         
                              if($edit==1 and $aso_jwib['fechar']>=$editdate and $videoprimera==0 and $videorevisita==0 and $suge==1)
                              {
                                   $tcell=$trow->appendChild($domd->createElement("td"," "));
                                   $div=$tcell->appendChild($domd->createElement("div"," "));
                                   $nomb_value='-';
                                   
                                   if($aso_jwib['docu']=='VM30')     
                                   if(empty($nombre1))
                                   {
                                        $nomb_suge1=msql_result(${'res_vm30'.$cas10},${'cont_vm30'.$cas10},'nombre1');
                                        $nomb_value='';
                                        $nomb_value.=substr(msql_result(${'res_vm30'.$cas10},${'cont_vm30'.$cas10},'fecha'),0,7);
                                        $nomb_value.=' : ';
                                        $nomb_value.=$nomb_suge1;
                                        ${'cont_vm30'.$cas10}++;
                                   }
                                   
                                   if($aso_jwib['docu']=='VM31')     
                                   if(empty($nombre1))
                                   {
                                        $nomb_suge1=msql_result(${'res_vm39'.$cas10},${'cont_vm39'.$cas10},'nombre1');
                                        $nomb_value='';
                                        $nomb_value.=substr(msql_result(${'res_vm39'.$cas10},${'cont_vm39'.$cas10},'fecha'),0,7);
                                        $nomb_value.=' : ';
                                        $nomb_value.=$nomb_suge1;
                                        ${'cont_vm39'.$cas10}++;
                                   }
                                   
//                                         echo '<br>===='.$aso_jwib['jwol_smm1'];
//                                         echo '<br>===='.$aso_jwib['jwol_smm2'];
//                                         echo '<br>===='.$aso_jwib['jwol_smm3'];
//                                         echo '<br>===='.$aso_jwib['jwol_smm4'];
                                             
                                   
                                   if(mb_stristr($aso_jwib['jwol_smm1'].$aso_jwib['jwol_smm2'].$aso_jwib['jwol_smm3'].$aso_jwib['jwol_smm4'],'. Discurso'))
                                   if(empty($nombre1))
                                   {
                                        $nomb_suge1=msql_result(${'res_vm35'.$cas10},${'cont_vm35'.$cas10},'nombre1');
                                        $nomb_value='';
                                        $nomb_value.=substr(msql_result(${'res_vm35'.$cas10},${'cont_vm35'.$cas10},'fecha'),0,7);
                                        $nomb_value.=' : ';
                                        $nomb_value.=$nomb_suge1;
                                        ${'cont_vm35'.$cas10}++;
                                   }
                                   
                                   
                                   if(
                                        !mb_stristr($aso_jwib['jwol_smm1'].$aso_jwib['jwol_smm2'].$aso_jwib['jwol_smm3'].$aso_jwib['jwol_smm4'],'. Empiece')
                                        and !mb_stristr($aso_jwib['jwol_smm1'].$aso_jwib['jwol_smm2'].$aso_jwib['jwol_smm3'].$aso_jwib['jwol_smm4'],'. Haga')
                                        and !mb_stristr($aso_jwib['jwol_smm1'].$aso_jwib['jwol_smm2'].$aso_jwib['jwol_smm3'].$aso_jwib['jwol_smm4'],'. Explique')
                                        and !mb_stristr($aso_jwib['jwol_smm1'].$aso_jwib['jwol_smm2'].$aso_jwib['jwol_smm3'].$aso_jwib['jwol_smm4'],'. Discurso')
                                   )
                                   if(empty($nombre1))
                                   {
                                        $nomb_suge1=msql_result(${'res_vm36'.$cas10},${'cont_vm36'.$cas10},'nombre1');
                                        $nomb_value='';
                                        $nomb_value.=substr(msql_result(${'res_vm36'.$cas10},${'cont_vm36'.$cas10},'fecha'),0,7);
                                        $nomb_value.=' : ';
                                        $nomb_value.=$nomb_suge1;
                                        ${'cont_vm36'.$cas10}++;
                                   }
                                   
                                   
                                   
                                   $xid='n1_'.$id_sala;
                                   $ondblclick='';
                                   $ondblclick.='{if(document.getElementById("'.$xid.'").value=="'.$nomb_suge1.'"){document.getElementById("'.$xid.'").value=".";}';
                                   $ondblclick.='else{document.getElementById("'.$xid.'").value="'.$nomb_suge1.'";};}';
                                   $ondblclick.='{document.getElementById("'.$xid.'").onblur();}';
                                   $tcell->setAttribute('onclick',$ondblclick);
                                   $span=$div->appendChild($domd->createElement('span',$nomb_value));    
                                   
                              }
     
                    }
                    
                    if($videoprimera==1){break;}
                    if($videorevisita==1){break;}
//                     echo '==='.$auditorio;
                    if($auditorio==1){break;}
                    
                    
               }
     }
}    

if($info=='VIDA')
{
     //if($edit==1){$vista2=1;}
     
     $tcolg=$table->appendChild($domd->createElement("colgroup"));
          $tcol=$tcolg->appendChild($domd->createElement("col"));
          $tcol->setAttribute("style","border-left:solid 1px; border-right :solid 1px;");
          $tcol=$tcolg->appendChild($domd->createElement("col"));
          $tcol=$tcolg->appendChild($domd->createElement("col"));
          $tcol->setAttribute("style","border-right:solid 1px; ");
          $tcol=$tcolg->appendChild($domd->createElement("col"));
          $tcol=$tcolg->appendChild($domd->createElement("col"));
          $tcol->setAttribute("style","border-right:solid 1px; ");
          $tcol=$tcolg->appendChild($domd->createElement("col"));
          $tcol=$tcolg->appendChild($domd->createElement("col"));
          $tcol->setAttribute("style","border-right:solid 1px; ");
          $tcol=$tcolg->appendChild($domd->createElement("col"));
          $tcol=$tcolg->appendChild($domd->createElement("col"));
          $tcol->setAttribute("style","border-right:solid 1px; ");
     
     

     
     
     
     $lfecha='';
     $lmonth='';
     msql_data_seek($res_jwib,0);     
     if($vista2==0)
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {
          
          if($lmonth!=substr($aso_jwib['fechar'],0,7))
          {
//                if($vista2==0)
               $trow=$table->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("style","background-color:darkblue;color:white; top:100px;");
                    $trow->setAttribute("sticky","");

               $tcell=$trow->appendChild($domd->createElement("th","VIDA CRISTIANA - ".strftime2('%B / %Y',strtotime($aso_jwib['fechar']))));
                    $tcell->setAttribute("colspan","10");
                    $tcell->setAttribute("style","height:2.5em;");
               
               
               {
                    $trow=$table->appendChild($domd->createElement("tr"));
                         $trow->setAttribute("style","color:white;");
                    $tcell=$trow->appendChild($domd->createElement("th",""));
                         $tcell->setAttribute("style","background-color:darkblue;");
                    $tcell=$trow->appendChild($domd->createElement("th","VIDA Y MINISTERIO"));
                         $tcell->setAttribute("colspan","2");
                         $tcell->setAttribute("style","background-color:#799FCC;");
                    $tcell=$trow->appendChild($domd->createElement("th","ORACION"));
                         $tcell->setAttribute("colspan","2");
                         $tcell->setAttribute("style","background-color:#799FCC;");
                    $tcell=$trow->appendChild($domd->createElement("th","TESOROS"));
                         $tcell->setAttribute("colspan","2");
                         $tcell->setAttribute("style","background-color:#5A6A70;");
                    $tcell=$trow->appendChild($domd->createElement("th","VIDA CRISTIANA"));
                         $tcell->setAttribute("colspan","2");
                         $tcell->setAttribute("style","background-color:#961526;");

                    $trow=$table->appendChild($domd->createElement("tr"));
                         $trow->setAttribute("style","color:white;");
                    $tcell=$trow->appendChild($domd->createElement("th",strftime2('%A',strtotime($aso_jwib['fechar']))    ));
                         $tcell->setAttribute("width","6%");
                         $tcell->setAttribute("style","background-color:darkblue;");
                    $tcell=$trow->appendChild($domd->createElement("th","PRESIDENTE"));
                         $tcell->setAttribute("width","10%");
                         $tcell->setAttribute("style","background-color:#799FCC;");
                    $tcell=$trow->appendChild($domd->createElement("th","S.AUXILIAR"));
                         $tcell->setAttribute("width","10%");
                         $tcell->setAttribute("style","background-color:#799FCC;");
                    $tcell=$trow->appendChild($domd->createElement("th","INICIAL"));
                         $tcell->setAttribute("width","10%");
                         $tcell->setAttribute("style","background-color:#799FCC;");
                    $tcell=$trow->appendChild($domd->createElement("th","FINAL"));
                         $tcell->setAttribute("width","10%");
                         $tcell->setAttribute("style","background-color:#799FCC;");
                    $tcell=$trow->appendChild($domd->createElement("th","DISCURSO 1"));
               //           $tcell->setAttribute("width","12%");
                         $tcell->setAttribute("style","background-color:#5A6A70;");
                    $tcell=$trow->appendChild($domd->createElement("th","PERLAS ESCONDIDAS"));
                         $tcell->setAttribute("width","10%");
                         $tcell->setAttribute("style","background-color:#5A6A70;");
                    $tcell=$trow->appendChild($domd->createElement("th","ASIGNACION 1"));
               //           $tcell->setAttribute("width","12%");
                         $tcell->setAttribute("style","background-color:#961526;");
                    $tcell=$trow->appendChild($domd->createElement("th","ASIGNACION 2"));
                         $tcell->setAttribute("width","10%");
                         $tcell->setAttribute("style","background-color:#961526;");

               }

               $lmonth=substr($aso_jwib['fechar'],0,7);
          }
          
          $trow=$table->appendChild($domd->createElement("tr"));
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}
               $trow->setAttribute("bb-d1","");
               $trow->setAttribute("align-c","");
               $trow->setAttribute("align-t","");
               $trow->setAttribute("hoverbg","");
               $trow->setAttribute("brk-inside","");
          
               if(substr($aso_jwib['fecha'],-2)>=8 and substr($aso_jwib['fecha'],-2)<=14)
               {$trow->setAttribute("style","border-top:solid 1px;");}
          
               if(substr($aso_jwib['fecha'],-2)>=22 and substr($aso_jwib['fecha'],-2)<=28)
               {$trow->setAttribute("style","border-top:solid 1px;");}
          
//           $tcell=$trow->appendChild($domd->createElement("td",strftime2('%a / %d',strtotime($aso_jwib['fechar']))));          
          $tcell=$trow->appendChild($domd->createElement("td",strftime2('%d/%b',strtotime($aso_jwib['fechar']))));          
               $tcell->setAttribute("sticky-left","");
               $tcell->setAttribute("nowrap","");
          
          if($edit==1 and $aso_jwib['fechar']>=$editdate)
          {
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if(!empty($aso_jwib['idn_vmc']))
               {
               $zdom=$domd;
               $zele=$tcell;
               $zid='n1_'.$aso_jwib['idn_vmc'];
               $zobj=1;
               $zvalue=$aso_jwib['nom1vmc'];
//                $zvalue=ucwords2($zvalue);
               // $ztabla='nomb';
               $zlist='nomb_info';                    
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$aso_jwib['idn_vmc'];
               $zsavef='nombre1';
               $zopen=1; $zwidth='auto';
//                $zwidth='100%';
               include('ele_input.php');
               }                    
               
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if(!empty($aso_jwib['idn_vmc']))
               {
               $zdom=$domd;
               $zele=$tcell;
               $zid='n2_'.$aso_jwib['idn_vmc'];
               $zobj=1;
               $zvalue=$aso_jwib['nom2vmc'];
//                $zvalue=ucwords2($zvalue);
               // $ztabla='nomb';
               $zlist='nomb_info';
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$aso_jwib['idn_vmc'];
               $zsavef='nombre2';
               $zopen=1; $zwidth='auto';
               include('ele_input.php');
               }
               
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if(!empty($aso_jwib['idn_ora']))
               {
               $zdom=$domd;
               $zele=$tcell;
               $zid='n1_'.$aso_jwib['idn_ora'];
               $zobj=1;
               $zvalue=$aso_jwib['nom1ora'];
               // $ztabla='nomb';
               $zlist='nomb_info';
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$aso_jwib['idn_ora'];
               $zsavef='nombre1';
               $zopen=1; $zwidth='auto';
               include('ele_input.php');
               }
               
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if(!empty($aso_jwib['idn_ora']))
               {
               $zdom=$domd;
               $zele=$tcell;
               $zid='n2_'.$aso_jwib['idn_ora'];
               $zobj=1;
               $zvalue=$aso_jwib['nom2ora'];
               // $ztabla='nomb';
               $zlist='nomb_info';
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$aso_jwib['idn_ora'];
               $zsavef='nombre2';
               $zopen=1; $zwidth='auto';
               include('ele_input.php');
               }
               
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if(!empty($aso_jwib['idn_tdb']))
               {
               $zdom=$domd;
               $zele=$tcell;
               $zid='n1_'.$aso_jwib['idn_tdb'];
               $zobj=1;
               $zvalue=$aso_jwib['nom1tdb'];
               // $ztabla='nomb';
               $zlist='nomb_info';
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$aso_jwib['idn_tdb'];
               $zsavef='nombre1';
               $zopen=1; $zwidth='auto';
               include('ele_input.php');
               }
               
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if(!empty($aso_jwib['idn_tdb']))
               {
               $zdom=$domd;
               $zele=$tcell;
               $zid='n2_'.$aso_jwib['idn_tdb'];
               $zobj=1;
               $zvalue=$aso_jwib['nom2tdb'];
               // $ztabla='nomb';
               $zlist='nomb_info';
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$aso_jwib['idn_tdb'];
               $zsavef='nombre2';
               $zopen=1; $zwidth='auto';
               include('ele_input.php');
               }
               
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if(!empty($aso_jwib['idn_nvc']))
               {
               $zdom=$domd;
               $zele=$tcell;
               $zid='n1_'.$aso_jwib['idn_nvc'];
               $zobj=1;
               $zvalue=$aso_jwib['nom1nvc'];
//                $zvalue=ucwords2($zvalue).'*******';
               // $ztabla='nomb';
               $zlist='nomb_info';
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$aso_jwib['idn_nvc'];
               $zsavef='nombre1';
               $zopen=1; $zwidth='auto';
               include('ele_input.php');
               }
               
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if(!empty($aso_jwib['idn_nvc']))
               {
               $zdom=$domd;
               $zele=$tcell;
               $zid='n2_'.$aso_jwib['idn_nvc'];
               $zobj=1;
               $zvalue=$aso_jwib['nom2nvc'];
               // $ztabla='nomb';
               $zlist='nomb_info';
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$aso_jwib['idn_nvc'];
               $zsavef='nombre2';
               $zopen=1; $zwidth='auto';
               include('ele_input.php');
               }               
               
          }
          else
          {
          
          
          $xstyle_pb='padding-bottom:1.5em;';
          if(!empty($prnt) and 1==2)
          {
               $tcell=$trow->appendChild($domd->createElement("td",ucwords2($aso_jwib['nom1vmc'].' ')));
                    $tcell->setAttribute('style',$xstyle_pb);
               $tcell=$trow->appendChild($domd->createElement("td",ucwords2($aso_jwib['nom2vmc'].' ')));          
                    $tcell->setAttribute('style',$xstyle_pb);
               $tcell=$trow->appendChild($domd->createElement("td",ucwords2($aso_jwib['nom1ora'].' ')));
                    $tcell->setAttribute('style',$xstyle_pb);
               
               $tcell=$trow->appendChild($domd->createElement("td",ucwords2($aso_jwib['nom2ora'].' ')));   
                    $tcell->setAttribute('style',$xstyle_pb);

               $tcell=$trow->appendChild($domd->createElement("td",ucwords2($aso_jwib['nom1tdb'])));          
                    $tcell->setAttribute('style',$xstyle_pb);
               $tcell=$trow->appendChild($domd->createElement("td",ucwords2($aso_jwib['nom2tdb'])));          
                    $tcell->setAttribute('style',$xstyle_pb);

               $tcell=$trow->appendChild($domd->createElement("td",ucwords2($aso_jwib['nom1nvc'])));          
                    $tcell->setAttribute('style',$xstyle_pb);
               $tcell=$trow->appendChild($domd->createElement("td",ucwords2($aso_jwib['nom2nvc'])));          
                    $tcell->setAttribute('style',$xstyle_pb);
               
          }
               
//           if(empty($prnt))
          {
          $tcell=$trow->appendChild($domd->createElement("td",ucwords2($aso_jwib['nom1vmc'].' ')));
                    $tcell->setAttribute('style',$xstyle_pb);

          $tcell=$trow->appendChild($domd->createElement("td",ucwords2($aso_jwib['nom2vmc'].' ')));          
                    $tcell->setAttribute('style',$xstyle_pb);
          $tcell=$trow->appendChild($domd->createElement("td",ucwords2($aso_jwib['nom1ora'].' ')));          
                    $tcell->setAttribute('style',$xstyle_pb);
          $tcell=$trow->appendChild($domd->createElement("td",ucwords2($aso_jwib['nom2ora'].' ')));   
                    $tcell->setAttribute('style',$xstyle_pb);
          
          $tcell=$trow->appendChild($domd->createElement("td",ucwords2($aso_jwib['nom1tdb'])));          
                    $tcell->setAttribute('style',$xstyle_pb);
               $div=$tcell->appendChild($domd->createElement("div",""));          
               $div->setAttribute("size80","");
               $div->setAttribute("noprint","");
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_tdb1'];
               if(!empty($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_smm=str_replace('<p ','<div ',$jwol_smm);
               $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
//                if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}
                    
                    $jwol=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
          $tcell=$trow->appendChild($domd->createElement("td",ucwords2($aso_jwib['nom2tdb'])));          
                    $tcell->setAttribute('style',$xstyle_pb);
               $div=$tcell->appendChild($domd->createElement("div",""));          
               $div->setAttribute("size60","");
               $div->setAttribute("noprint","");
               $jwol_smm='';
//                $jwol_smm=$aso_jwib['jwol_tdb2'];
               if(!empty($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_smm=str_replace('<p ','<div ',$jwol_smm);
               $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
//                if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}
                    
                    $jwol=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
          $tcell=$trow->appendChild($domd->createElement("td",ucwords2($aso_jwib['nom1nvc'])));          
                    $tcell->setAttribute('style',$xstyle_pb);
               $div=$tcell->appendChild($domd->createElement("div",""));          
//                $div->setAttribute("size80","");
               $div->setAttribute("size60","");
               $div->setAttribute("noprint","");
               
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_nvc1'];
               if(!empty($jwol_smm))
               {
                    
//                     $jwol_smm=str_replace('<a','<a tabindex="-1"',$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_smm=str_replace('<p ','<div ',$jwol_smm);
               $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
//                if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}
                    
                    $jwol=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);
                    $div->appendChild($jwol);

               }
               
          $tcell=$trow->appendChild($domd->createElement("td",ucwords2($aso_jwib['nom2nvc'])));   
                    $tcell->setAttribute('style',$xstyle_pb);
               $div=$tcell->appendChild($domd->createElement("div",""));          
               $div->setAttribute("size60","");
               $div->setAttribute("noprint","");
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_nvc2'];
               if(!empty($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_smm=str_replace('<p ','<div ',$jwol_smm);
               $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
//                if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}
                    
                    $jwol=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);
                    $div->appendChild($jwol);
                    
               }
          }
          
               
          }
          
          
          
          
     }     
     
     $lfecha='';
     $lmonth='';
     msql_data_seek($res_jwib,0);     
     if($vista2==1)
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {
          
           if($lmonth!=substr($aso_jwib['fechar'],0,7))
          {
//                if($vista2==0)
                
               $trow=$table->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("border-none","");
                
               $tcell=$trow->appendChild($domd->createElement("td"));
                    $tcell->setAttribute("width","12%");
                    $tcell->setAttribute("border-none","");
               $tcell=$trow->appendChild($domd->createElement("td"));
                    $tcell->setAttribute("width","48%");
                    $tcell->setAttribute("border-none","");
               $tcell=$trow->appendChild($domd->createElement("td"));
                    $tcell->setAttribute("width","40%");
                    $tcell->setAttribute("border-none","");
                
               $trow=$table->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("sticky","");                
                    $trow->setAttribute("style","background-color:darkblue;color:white; top:100px;");

               $tcell=$trow->appendChild($domd->createElement("th","VIDA CRISTIANA - ".strftime2('%B / %Y',strtotime($aso_jwib['fechar']))));
                    
                    $tcell->setAttribute("colspan","10");
                    $tcell->setAttribute("style","height:2.5em; ");
               
               $lmonth=substr($aso_jwib['fechar'],0,7);
          }
         
          
          
//           $id_sala=$aso_jwib['idnum1'];
          $id_nume=$aso_jwib['idnum1'];
          $table->setAttribute("align-c","");          
          if($lfecha!=$aso_jwib['fechar'])
          {
               $trow=$table->appendChild($domd->createElement("tr"));
               $trow->setAttribute("style","background-color:darkblue;color:white;top:140px;");
               $trow->setAttribute("align-c","");
               $trow->setAttribute ("sticky","");
//                 if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("bold","");}
               $tcell=$trow->appendChild($domd->createElement("td",strftime2('%A / %d',strtotime($aso_jwib['fechar']))));
               $tcell->setAttribute("colspan","10");
               $tcell->setAttribute("nowrap","");
          }
          $lfecha=$aso_jwib['fechar'];
          
          if($aso_jwib['docu']=='VM11')
          {
               $trow=$table->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("style","border-top:solid 1px;");
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}
               $tcell=$trow->appendChild($domd->createElement("td","VMC"));
                    $tcell->setAttribute("rowspan","4");
                    $tcell->setAttribute("bold","");
                    $tcell->setAttribute("style","background-color:#799FCC; color:white;");
               $tcell=$trow->appendChild($domd->createElement("td","Presidente"));
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n1_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nom1vmc'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_vmc'];
                    $zsavef='nombre1';
                    $zopen=1; $zwidth='auto';
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",$aso_jwib['nom1vmc'].' '));}
               
               
               $trow=$table->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("bb-d1","");
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}
               $tcell=$trow->appendChild($domd->createElement("td","S.Auxiliar"));
               $tcell=$trow->appendChild($domd->createElement("td",""));
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n2_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nom2vmc'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_vmc'];
                    $zsavef='nombre2';
                    $zopen=1; $zwidth='auto';
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",$aso_jwib['nom2vmc'].' '));}
          }
          
          if($aso_jwib['docu']=='VM19')
          {
               $trow=$table->appendChild($domd->createElement("tr"));
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}
               $tcell=$trow->appendChild($domd->createElement("td","Oración Inicial"));
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n1_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nom1ora'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_ora'];
                    $zsavef='nombre1';
                    $zopen=1; $zwidth='auto';
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",$aso_jwib['nom1ora'].' '));}
               
               $trow=$table->appendChild($domd->createElement("tr"));
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}
               $tcell=$trow->appendChild($domd->createElement("td","Oración Final"));
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n2_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nom2ora'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_ora'];
                    $zsavef='nombre2';
                    $zopen=1; $zwidth='auto';
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",$aso_jwib['nom2ora'].' '));}
               
          }
          
          if($aso_jwib['docu']=='VM21')
          {
               $trow=$table->appendChild($domd->createElement("tr"));
                    if(date('Y-W')==$aso_jwib['fsema'])
                    {$trow->setAttribute("boldsc","");}
                    $trow->setAttribute("style","border-top:solid 1px;");
               $tcell=$trow->appendChild($domd->createElement("td","TDB"));
                    $tcell->setAttribute("rowspan","2");
                    $tcell->setAttribute("bold","");
                    $tcell->setAttribute("style","background-color:#5A6A70; color:white;");
               $tcell=$trow->appendChild($domd->createElement("td",""));
               $div=$tcell->appendChild($domd->createElement("div",""));          
//                $div->setAttribute("size80","");
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_tdb1'];
               if(!empty($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_smm=str_replace('<p ','<div ',$jwol_smm);
                    $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
                    if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}
                    
                    
                    
                    $jwol=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n1_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nom1tdb'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_tdb'];
                    $zsavef='nombre1';
                    $zopen=1; $zwidth='auto';
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",$aso_jwib['nom1tdb']));}
               
//                $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom1tdb']));
               
               $trow=$table->appendChild($domd->createElement("tr"));
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}
               $tcell=$trow->appendChild($domd->createElement("td",""));
               $div=$tcell->appendChild($domd->createElement("div",""));          
//                $div->setAttribute("size80","");
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_tdb2'];
//                if(mb_stristr($jwol_smm,'<a'))
//                $jwol_smm=trim($jwol_smm).'</a>';
               if(!empty($jwol_smm))
               {
//                     $jwol_smm=str_replace('<a','<a tabindex="-1"',$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_smm=str_replace('<p ','<div ',$jwol_smm);
               $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
               if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}
                    
                    $jwol=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n2_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nom2tdb'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_tdb'];
                    $zsavef='nombre2';
                    $zopen=1; $zwidth='auto';
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",$aso_jwib['nom2tdb']));}
               
//                $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom2tdb']));
          }
          
          if($aso_jwib['docu']=='VM41')
          {
               $trow=$table->appendChild($domd->createElement("tr"));
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}
                    $trow->setAttribute("style","border-top:solid 1px;");
               $tcell=$trow->appendChild($domd->createElement("td","NVC"));
                    $tcell->setAttribute("rowspan","2");
                    $tcell->setAttribute("bold","");
                    $tcell->setAttribute("style","background-color:#961526; color:white;");
               $tcell=$trow->appendChild($domd->createElement("td",""));
               $div=$tcell->appendChild($domd->createElement("div",""));          
               
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_nvc1'];
               if(!empty($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_smm=str_replace('<p ','<div ',$jwol_smm);
               $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
               if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}
                    
                    $jwol=$domd->createDocumentFragment();
//                     echo '*/*/*/*'.$jwol_smm;
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n1_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nom1nvc'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_nvc'];
                    $zsavef='nombre1';
                    $zopen=1; $zwidth='auto';
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",$aso_jwib['nom1nvc']));}
               
               
               $trow=$table->appendChild($domd->createElement("tr"));
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               $div=$tcell->appendChild($domd->createElement("div",""));          
               
               // NECESIDADES LOCALES
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_nvc2'];
               if(!empty($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_smm=str_replace('<p ','<div ',$jwol_smm);
               $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
               if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}
                    
                    $jwol=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
               
               $tcell=$trow->appendChild($domd->createElement("td"," "));
               
               if($edit==1 and $aso_jwib['fechar']>=$editdate)
               {
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='n2_'.$id_nume;
                    $zobj=1;
                    $zvalue=$aso_jwib['nom2nvc'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idn_nvc'];
                    $zsavef='nombre2';
                    $zopen=1; $zwidth='auto';
                    if(empty($jwol_smm)){$zhide=1;}
                    include('ele_input.php');
               }
               else
               {$span=$tcell->appendChild($domd->createElement("span",$aso_jwib['nom2nvc']));}
               
//                $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom2nvc']));
          }
          
          
          
     }     
     
     
     
}     
     
if($info=='ESTU')
{
     $tcolg=$table->appendChild($domd->createElement("colgroup"));
     if($vista2==0)
     {
          $tcol=$tcolg->appendChild($domd->createElement("col"));
          $tcol->setAttribute("style","border-left:solid 1px; border-right :solid 1px;");
          $tcol=$tcolg->appendChild($domd->createElement("col"));
          $tcol=$tcolg->appendChild($domd->createElement("col"));
          $tcol=$tcolg->appendChild($domd->createElement("col"));
          $tcol->setAttribute("style","border-right:solid 1px; ");
          $tcol=$tcolg->appendChild($domd->createElement("col"));
          $tcol=$tcolg->appendChild($domd->createElement("col"));
          $tcol=$tcolg->appendChild($domd->createElement("col"));
          $tcol->setAttribute("style","border-right:solid 1px; ");
     }
     if($vista2==1)
     {
          $tcol=$tcolg->appendChild($domd->createElement("col"));
          $tcol->setAttribute("style","border-left:solid 1px; border-right :solid 1px;");
          $tcol=$tcolg->appendChild($domd->createElement("col"));
          $tcol->setAttribute("style","border-right:solid 1px; ");
     }
     
     $lfecha='';
     $lmonth='';
     msql_data_seek($res_jwib,0);     
     $idxbrow=0;
     if($vista2==0)
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {
//           echo '*/*/*'.$aso_jwib['fecha_ata'];
          
          if(substr($aso_jwib['fecha'],0,7)!=$lmonth)
          {
               
               
     // TABLA
     {
          $smmblock=1;
          $table=$domd->appendChild($domd->createElement("table"));
          $brktab=$domd->appendChild($domd->createElement("p"));
               $table->setAttribute("border","1");
//                $table->setAttribute("width","100%");   
               $table->setAttribute("width","99%");   
               $table->setAttribute("style","page-break-inside: avoid; break-inside: avoid;");   
               if($edit!=1)
               {
               $table->setAttribute("bt-s1","");   
               $table->setAttribute("bb-s1","");   
               }

          //      if($vista2==1 and $_SESSION['screeno']!=1)
          //      {$table->setAttribute("width","50%");}

               if($vista2==1 and $_SESSION['screeno']!=1)
               {$table->setAttribute("width",(int)($_SESSION['screenw']*(0.5)).'px');}

          
     }
     
               
               
               
               
               
     $trow=$table->appendChild($domd->createElement("tr"));
          $trow->setAttribute("sticky-t100","");
          $trow->setAttribute("style","border-top:solid 2px;background-color:darkblue;color:white;");

     $tcell=$trow->appendChild($domd->createElement("th","ESTUDIOS - ".strftime2('%B / %Y',strtotime($aso_jwib['fecha']))));
          $tcell->setAttribute("style","height:2.5em;");
          $tcell->setAttribute("colspan","10");

     if($vista2==0)
     {
     $trow=$table->appendChild($domd->createElement("tr"));
          $trow->setAttribute("style","color:white;");
     $tcell=$trow->appendChild($domd->createElement("th",""));
          $tcell->setAttribute("style","background-color:darkblue;");
     $tcell=$trow->appendChild($domd->createElement("th","LIBRO DE CONGREGACION"));
          $tcell->setAttribute("colspan","3");
          $tcell->setAttribute("style","background-color:grey;");
     $tcell=$trow->appendChild($domd->createElement("th","REVISTA LA ATALAYA"));
          $tcell->setAttribute("colspan","3");
          $tcell->setAttribute("style","background-color:grey;");

          
     $trow=$table->appendChild($domd->createElement("tr"));
          $trow->setAttribute("style","color:white;");
     $tcell=$trow->appendChild($domd->createElement("th","SEMANA"));
          $tcell->setAttribute("width","6%");
          $tcell->setAttribute("style","background-color:darkblue;");
//      $tcell=$trow->appendChild($domd->createElement("th","FECHA"));
     $tcell=$trow->appendChild($domd->createElement("th",strftime2('%A',strtotime($aso_jwib['fecha_lib']))    ));          
          $tcell->setAttribute("width","6%");
          $tcell->setAttribute("style","background-color:grey;");
     $tcell=$trow->appendChild($domd->createElement("th","CONDUCTOR"));
          $tcell->setAttribute("width","18%");
          $tcell->setAttribute("style","background-color:grey;");
     $tcell=$trow->appendChild($domd->createElement("th","LECTOR"));
          $tcell->setAttribute("width","18%");
          $tcell->setAttribute("style","background-color:grey;");
//      $tcell=$trow->appendChild($domd->createElement("th","FECHA"));
     $tcell=$trow->appendChild($domd->createElement("th",strftime2('%A',strtotime($aso_jwib['fecha_ata']))    ));          
          $tcell->setAttribute("width","6%");
          $tcell->setAttribute("style","background-color:grey;");
     $tcell=$trow->appendChild($domd->createElement("th","CONDUCTOR"));
          $tcell->setAttribute("width","18%");
          $tcell->setAttribute("style","background-color:grey;");
     $tcell=$trow->appendChild($domd->createElement("th","LECTOR"));
          $tcell->setAttribute("width","18%");
          $tcell->setAttribute("style","background-color:grey;");
          
     }
               
               
               
               $lmonth=substr($aso_jwib['fecha'],0,7);
          }
          
          
          
          $idxbrow++;
          $trow=$table->appendChild($domd->createElement("tr"));
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}
               if($idxbrow%2==0)
               {$trow->setAttribute("bb-d1","");}
               $trow->setAttribute("align-c","");
               $trow->setAttribute("align-m","");
               $trow->setAttribute("hoverbg","");
               $trow->setAttribute("brk-inside","");
               $trow->setAttribute("style","height:2em;");
               $trow->setAttribute("style","border-top:solid 1px");
          
          $tcell=$trow->appendChild($domd->createElement("td",date('W',strtotime($aso_jwib['fecha']))));
//           echo '*/*/'.$aso_jwib['fecha_lib'];
//           $tcell=$trow->appendChild($domd->createElement("td",strftime2('%a / %d',strtotime($aso_jwib['fecha_lib']))));          
          $tcell=$trow->appendChild($domd->createElement("td",strftime2('%d/%b',strtotime($aso_jwib['fecha_lib']))));          
               $tcell->setAttribute("nowrap","");
          
          $tcell=$trow->appendChild($domd->createElement("td",""));
          
          $nombre1=strtoupper2($aso_jwib['nom1_lib']);
          $nombre2=strtoupper2($aso_jwib['nom2_lib']);
          $idn_lib=$aso_jwib['idn_lib'];
//           echo '*/*/*'.$aso_jwib['idnum1'];
          
//           echo '<br>'.$aso_jwib['fsema'].' :::'. date('Y-W');
          
          if($edit==1 and $aso_jwib['fsema']>=date('Y-W'))
          {
               $tcell->setAttribute("valign","top");
               $zdom=$domd;
               $zele=$tcell;
               $zid='nom1_lib'.$idn_lib;
               $zobj=1;
               $zvalue=$nombre1;
               // $ztabla='nomb';
               $zlist='nomb_info';
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$aso_jwib['idn_lib'];
               $zsavef='nombre1';
               $zopen=1; $zwidth='auto';
//                if($aso_jwib['docu']=='AS11'){$zreado=1;}
               include('ele_input.php');
          }
          else
          {$tcell=$tcell->appendChild($domd->createElement("div",$nombre1));}     
          
               $div=$tcell->appendChild($domd->createElement("div",""));          
               $div->setAttribute("size80","");
//                $div->setAttribute("tabindex","-1");
          
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_lib1'];
//                if(mb_stristr($jwol_smm,'<a'))
//                $jwol_smm=trim($jwol_smm).'</a>';
               if(!empty($jwol_smm))
               {
//                     $jwol_smm=str_replace('<a','<a tabindex="-1"',$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_smm=str_replace('<p ','<div ',$jwol_smm);
               $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
               if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}
                    
//                     echo '<br>'.$jwol_smm;
                    $jwol=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
          
          
          $tcell=$trow->appendChild($domd->createElement("td",""));
          if($edit==1 and $aso_jwib['fsema']>=date('Y-W'))
          {
               $tcell->setAttribute("valign","top");
               $zdom=$domd;
               $zele=$tcell;
               $zid='nom2_lib'.$idn_lib;
               $zobj=1;
               $zvalue=$nombre2;
               // $ztabla='nomb';
               $zlist='nomb_info';
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$aso_jwib['idn_lib'];
               $zsavef='nombre2';
               $zopen=1; $zwidth='auto';
//                if($aso_jwib['docu']=='AS11'){$zreado=1;}
               include('ele_input.php');
          }
          else
          {$tcell=$tcell->appendChild($domd->createElement("div",$nombre2));}     
          
//           $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom2_lib']));          
//           $tcell=$trow->appendChild($domd->createElement("td",strftime2('%a / %d',strtotime($aso_jwib['fecha_ata']))));          
          $tcell=$trow->appendChild($domd->createElement("td",strftime2('%d/%b',strtotime($aso_jwib['fecha_ata']))));          
               $tcell->setAttribute("nowrap","");
          
          $nombre1=strtoupper2($aso_jwib['nom1_ata']);
          $nombre2=strtoupper2($aso_jwib['nom2_ata']);
          $idn_ata=$aso_jwib['idn_ata'];
          $tcell=$trow->appendChild($domd->createElement("td",""));
          if($edit==1 and $aso_jwib['fsema']>=date('Y-W'))
          {
               $tcell->setAttribute("valign","top");
               $zdom=$domd;
               $zele=$tcell;
               $zid='nom1_ata'.$idn_ata;
               $zobj=1;
               $zvalue=$nombre1;
               // $ztabla='nomb';
               $zlist='nomb_info';
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$aso_jwib['idn_ata'];
               $zsavef='nombre1';
               $zopen=1; $zwidth='auto';
//                if($aso_jwib['docu']=='AS11'){$zreado=1;}
               include('ele_input.php');
          }
          else
          {$tcell=$tcell->appendChild($domd->createElement("div",$nombre1));}     
          
          
//           $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom1_ata']));
               $div=$tcell->appendChild($domd->createElement("div",""));          
               $div->setAttribute("size80","");
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_ata1'];
//                if(mb_stristr($jwol_smm,'<a'))
//                $jwol_smm=trim($jwol_smm).'</a>';
               if(!empty($jwol_smm))
               {
//                     $jwol_smm=str_replace('<a','<a tabindex="-1"',$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_smm=str_replace('<p ','<div ',$jwol_smm);
               $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
               if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}
                    
                    $jwol=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
          $tcell=$trow->appendChild($domd->createElement("td",""));
          if($edit==1 and $aso_jwib['fsema']>=date('Y-W'))
          {
               $tcell->setAttribute("valign","top");
               $zdom=$domd;
               $zele=$tcell;
               $zid='nom2_ata'.$idn_ata.'';
               $zobj=1;
               $zvalue=$nombre2;
               // $ztabla='nomb';
               $zlist='nomb_info';
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$aso_jwib['idn_ata'];
               $zsavef='nombre2';
               $zopen=1; $zwidth='auto';
//                if($aso_jwib['docu']=='AS11'){$zreado=1;}
               include('ele_input.php');
          }
          else
          {$tcell=$tcell->appendChild($domd->createElement("div",$nombre2));}     
          
          
          
          
          
          
     }     
     
     if($vista2==1)
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {
          
          if(substr($aso_jwib['fecha'],0,7)!=$lmonth)
          {
     $trow=$table->appendChild($domd->createElement("tr"));
          $trow->setAttribute("sticky-t100","");
          $trow->setAttribute("style","border-top:solid 2px;background-color:darkblue;color:white;");
     
     $tcell=$trow->appendChild($domd->createElement("th","ESTUDIOS - ".strftime2('%B / %Y',strtotime($aso_jwib['fecha']))));
          $tcell->setAttribute("style","height:2.5em;");
          $tcell->setAttribute("colspan","10");
     
     if($vista2==1)
     {
     $trow=$table->appendChild($domd->createElement("tr"));
          $trow->setAttribute("style","color:white;");
     $tcell=$trow->appendChild($domd->createElement("th","LIBRO CONGREGACION"));
          $tcell->setAttribute("width","50%");
          $tcell->setAttribute("style","background-color:grey;");
     $tcell=$trow->appendChild($domd->createElement("th","REVISTA ATALAYA"));
          $tcell->setAttribute("width","50%");
          $tcell->setAttribute("style","background-color:grey;");
          
     }
               
               
               $lmonth=substr($aso_jwib['fecha'],0,7);
               
          }
          
          $idxbrow++;
          $trow=$table->appendChild($domd->createElement("tr"));
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}
               $trow->setAttribute("align-c","");
               $trow->setAttribute("align-t","");
               $trow->setAttribute("hoverbg","");
               $trow->setAttribute("brk-inside","");
               $trow->setAttribute("style","border-top:solid 1px");
//                $trow->setAttribute("style","height:2em;     ");

          
          // LIBRO
          $tcell=$trow->appendChild($domd->createElement("td"));          
               $div=$tcell->appendChild($domd->createElement("div",strftime2('%a / %d',strtotime($aso_jwib['fecha_lib']))));
          
          $nombre1=strtoupper2($aso_jwib['nom1_lib']);
          $nombre2=strtoupper2($aso_jwib['nom2_lib']);
          $idn_lib=$aso_jwib['idn_lib'];
//           $tcell=$trow->appendChild($domd->createElement("td",""));
          if($edit==1 and $aso_jwib['fsema']>=date('Y-W'))
          {
               $tcell->setAttribute("valign","top");
               $zdom=$domd;
               $zele=$tcell;
               $zid='nom1_lib'.$idn_lib;
               $zobj=1;
               $zvalue=$nombre1;
               // $ztabla='nomb';
               $zlist='nomb_info';
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$aso_jwib['idn_lib'];
               $zsavef='nombre1';
               $zopen=1; $zwidth='auto';
//                if($aso_jwib['docu']=='AS11'){$zreado=1;}
               include('ele_input.php');
          }
          else
          {
               $tcell=$tcell->appendChild($domd->createElement("div",$nombre1));
          }     
          
               $div=$tcell->appendChild($domd->createElement("div",""));          
               $div->setAttribute("size80","");
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_lib1'];
               if(!empty($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_smm=str_replace('<p ','<div ',$jwol_smm);
               $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
               if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}
                    
                    $jwol=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
          
          if($edit==1 and $aso_jwib['fsema']>=date('Y-W'))
          {
               $tcell->setAttribute("valign","top");
               $zdom=$domd;
               $zele=$tcell;
               $zid='nom2_lib'.$idn_lib;
               $zobj=1;
               $zvalue=$nombre2;
               // $ztabla='nomb';
               $zlist='nomb_info';
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$aso_jwib['idn_lib'];
               $zsavef='nombre2';
               $zopen=1; $zwidth='auto';
//                if($aso_jwib['docu']=='AS11'){$zreado=1;}
               include('ele_input.php');
          }
          else
          {
               $nombre2=ucwords2($nombre2);
               $tcell=$tcell->appendChild($domd->createElement("div",$nombre2));
          }     
          
//                $div=$tcell->appendChild($domd->createElement("div",ucwords2($aso_jwib['nom2_lib'])));          
               $div=$tcell->appendChild($domd->createElement("p"));          
          
          
          // ATALAYA
          
          $tcell=$trow->appendChild($domd->createElement("td"));          
               $div=$tcell->appendChild($domd->createElement("div",strftime2('%a / %d',strtotime($aso_jwib['fecha_ata']))));
   
          $nombre1=strtoupper2($aso_jwib['nom1_ata']);
          $nombre2=strtoupper2($aso_jwib['nom2_ata']);
          $idn_ata=$aso_jwib['idn_ata'];
//           $tcell=$trow->appendChild($domd->createElement("td",""));
          if($edit==1 and $aso_jwib['fsema']>=date('Y-W'))
          {
               $tcell->setAttribute("valign","top");
               $zdom=$domd;
               $zele=$tcell;
               $zid='nom1_ata'.$idn_ata;
               $zobj=1;
               $zvalue=$nombre1;
               // $ztabla='nomb';
               $zlist='nomb_info';
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$aso_jwib['idn_ata'];
               $zsavef='nombre1';
               $zopen=1; $zwidth='auto';
//                if($aso_jwib['docu']=='AS11'){$zreado=1;}
               include('ele_input.php');
          }
          else
          {$tcell=$tcell->appendChild($domd->createElement("div",$nombre1));}     
          
          
//                $div=$tcell->appendChild($domd->createElement("div",$aso_jwib['nom1_ata']));     
               $div=$tcell->appendChild($domd->createElement("div",""));          
               $div->setAttribute("size80","");
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_ata1'];
               if(!empty($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_smm=str_replace('<p ','<div ',$jwol_smm);
               $jwol_smm=str_replace('</p>','</div>',$jwol_smm);
               if(!empty($jwol_smm)){$jwol_smm.='<p></p>';}
                    
                    $jwol=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }

          if($edit==1 and $aso_jwib['fsema']>=date('Y-W'))
          {
               $tcell->setAttribute("valign","top");
               $zdom=$domd;
               $zele=$tcell;
               $zid='nom2_ata'.$idn_ata;
               $zobj=1;
               $zvalue=$nombre2;
               // $ztabla='nomb';
               $zlist='nomb_info';
               $zsave=1;
               $zsavet='jwib';
               $zsavei=$aso_jwib['idn_ata'];
               $zsavef='nombre2';
               $zopen=1; $zwidth='auto';
//                if($aso_jwib['docu']=='AS11'){$zreado=1;}
               include('ele_input.php');
          }
          else
          {
               $nombre2=ucwords2($nombre2);
               $tcell=$tcell->appendChild($domd->createElement("div",$nombre2));
          }  
          
//                $div=$tcell->appendChild($domd->createElement("div",ucwords2($aso_jwib['nom2_ata'])));          
               $div=$tcell->appendChild($domd->createElement("p"));    
          
//           $tcell='';
          
          
          
          
     }     
     
     
     
}     

if(mb_stristr('DPU1.DPU2',$info))
{
     $lfecha='';
     $idxbrow=0;
     msql_data_seek($res_jwib,0);     

     if($vista2==0)
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {
//           if($lfecha!=date('Y-m',strtotime($aso_jwib['fechar'])))
          if($lfecha!=substr($aso_jwib['fechar'],0,7))
          {
               $trow=$table->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("sticky-t100","");
                    $trow->setAttribute("style","border-top:solid 2px;background-color:royalblue;color:white;");

               if($info=='DPU1')
               {$tcell=$trow->appendChild($domd->createElement("th",'REUNION PUBLICA - '.strftime2('%B / %Y',strtotime($aso_jwib['fechar']))));}
               if($info=='DPU2')
               {$tcell=$trow->appendChild($domd->createElement("th",'DISCURSANTES - '.strftime2('%B / %Y',strtotime($aso_jwib['fechar']))));}
                    $tcell->setAttribute("style","height:2.5em;");
                    $tcell->setAttribute("colspan","10");

               $trow=$table->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("style","border-top:solid 2px;background-color:royalblue;color:white;");
                    $tcell=$trow->appendChild($domd->createElement("th","FECHA"));
                    $tcell->setAttribute("width","5%");
                    $tcell=$trow->appendChild($domd->createElement("th","No"));
                    $tcell->setAttribute("width","5%");
                    $tcell=$trow->appendChild($domd->createElement("th","BOSQUEJO"));
//                     $tcell->setAttribute("width","40%");
                    $tcell=$trow->appendChild($domd->createElement("th","TEMA"));
//                     $tcell->setAttribute("width","20%");
                    if($info=='DPU1')
                    {$tcell=$trow->appendChild($domd->createElement("th","VIENEN : ".$aso_jwib['cong2_descri']));}
                    if($info=='DPU2')
                    {$tcell=$trow->appendChild($domd->createElement("th","VAN A : ".$aso_jwib['cong2_descri']));}
//                     $tcell->setAttribute("width","30%");
               $idxbrow=0;
          }
//           $lfecha=date('Y-m',strtotime($aso_jwib['fechar']));
          $lfecha=substr($aso_jwib['fechar'],0,7);

          $idxbrow++;
          
          $trow=$table->appendChild($domd->createElement("tr"));
               $trow->setAttribute("bb-d1","");
               $trow->setAttribute("hoverbg","");
               $trow->setAttribute("brk-inside","");
               $trow->setAttribute("align-c","");
               $trow->setAttribute("style","height:2.5em;");
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}

//           if($info=='DPU1')
          {$tcell=$trow->appendChild($domd->createElement("td",strftime2('%a / %d',strtotime($aso_jwib['fechar']))));}
          
//           if($info=='DPU2')
//           {$tcell=$trow->appendChild($domd->createElement("td",($aso_jwib['cong2_dpud'])));}
//           $tcell=$trow->appendChild($domd->createElement("td",($aso_jwib['fechar'])));
               $tcell->setAttribute("nowrap","");
//           $tcell=$trow->appendChild($domd->createElement("td",$lfecha));
          
          if($edit==1 and $aso_jwib['fsema']>=date('Y-W'))
          {
               $tcell=$trow->appendChild($domd->createElement("td"));
                    $tcell->setAttribute('colspan',3);
                    $tcell->setAttribute("valign","top");
                    $tcell->setAttribute("align","left");
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='bsqj'.$aso_jwib['idnum1'];
                    $zobj=5;
                    $zvalue=$aso_jwib['bsqj'];
                    $ztabla='bsqj';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idnum1'];
                    $zsavef='bsqj';
                    include('ele_input.php');
               
               
               $tcell=$trow->appendChild($domd->createElement("td"));
                    $tcell->setAttribute("valign","top");
                    $zdom=$domd;
                    $zele=$tcell;
                    $zid='nombre1'.$aso_jwib['idnum1'];
                    $zobj=1;
                    $zvalue=$aso_jwib['nombre1'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idnum1'];
                    $zsavef='nombre1';
                    $zopen=1; $zwidth='auto';
     //                if($aso_jwib['docu']=='AS11'){$zreado=1;}
                    include('ele_input.php');
          }
          else
          {
//                $tcell=$tcell->appendChild($domd->createElement("div",$nombre1));
               $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['bsqj']));
               $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['bsqj_descri']));
               $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['bsqj_tema']));
               $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nombre1']));
          }     
     }     
     
     if($vista2==1)
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {
//           if($lfecha!=date('Y-m',strtotime($aso_jwib['fechar'])))
          if($lfecha!=substr($aso_jwib['fechar'],0,7))
          {
               $trow=$table->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("sticky-t100","");
                    $trow->setAttribute("style","border-top:solid 2px;background-color:royalblue;color:white;");

//                $tcell=$trow->appendChild($domd->createElement("th",'REUNION PUBLICA - '.strftime2('%B / %Y',strtotime($aso_jwib['fecha']))));
               if($info=='DPU1')
               {$tcell=$trow->appendChild($domd->createElement("th",'REUNION PUBLICA - '.strftime2('%B / %Y',strtotime($aso_jwib['fechar']))));}
               if($info=='DPU2')
               {$tcell=$trow->appendChild($domd->createElement("th",'DISCURSANTES - '.strftime2('%B / %Y',strtotime($aso_jwib['fechar']))));}
                    $tcell->setAttribute("style","height:2.5em;");
                    $tcell->setAttribute("colspan","10");

               $trow=$table->appendChild($domd->createElement("tr"));
                    $trow->setAttribute("style","border-top:solid 2px;background-color:royalblue;color:white;");
                    if($info=='DPU1')
                    {$tcell=$trow->appendChild($domd->createElement("th","VIENEN : ".$aso_jwib['cong2_descri']));}
                    if($info=='DPU2')
                    {$tcell=$trow->appendChild($domd->createElement("th","VAN A : ".$aso_jwib['cong2_descri']));}
//                     $tcell->setAttribute("width","30%");
               $idxbrow=0;
          }
//           $lfecha=date('Y-m',strtotime($aso_jwib['fechar']));
          $lfecha=substr($aso_jwib['fechar'],0,7);

          $idxbrow++;
          
          $trow=$table->appendChild($domd->createElement("tr"));
               $trow->setAttribute("bb-d1","");
               $trow->setAttribute("hoverbg","");
               $trow->setAttribute("brk-inside","");
               $trow->setAttribute("align-c","");
               $trow->setAttribute("style","height:8em;");
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}

          $tcell=$trow->appendChild($domd->createElement("td",));
          
          $div=$tcell->appendChild($domd->createElement("div",strftime2('%a / %d',strtotime($aso_jwib['fechar']))));
//           $div=$tcell->appendChild($domd->createElement("div",$aso_jwib['bsqj'].' - '.$aso_jwib['bsqj_descri']));
//                $div->setAttribute("size120","");
//                $div->setAttribute("bold","");
//           $div=$tcell->appendChild($domd->createElement("div",$aso_jwib['bsqj_tema']));
//                $div->setAttribute("italic","");
//           $div=$tcell->appendChild($domd->createElement("div",$aso_jwib['nombre1']));
//                $div->setAttribute("size120","");
          
          
          if($edit==1 and $aso_jwib['fsema']>=date('Y-W'))
          {
               $div=$tcell->appendChild($domd->createElement("div",""));
//                     $tcell->setAttribute('colspan',3);
//                     $tcell->setAttribute("valign","top");
                    $div->setAttribute("align","left");
                    $zdom=$domd;
                    $zele=$div;
                    $zid='bsqj'.$aso_jwib['idnum1'];
                    $zobj=5;
                    $zvalue=$aso_jwib['bsqj'];
                    $ztabla='bsqj';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idnum1'];
                    $zsavef='bsqj';
                    include('ele_input.php');
               
               
               $div=$tcell->appendChild($domd->createElement("div",""));
//                     $div->setAttribute("valign","top");
                    $div->setAttribute("align","left");
                    $zdom=$domd;
                    $zele=$div;
                    $zid='nombre1'.$aso_jwib['idnum1'];
                    $zobj=1;
                    $zvalue=$aso_jwib['nombre1'];
                    // $ztabla='nomb';
                    $zlist='nomb_info';
                    $zsave=1;
                    $zsavet='jwib';
                    $zsavei=$aso_jwib['idnum1'];
                    $zsavef='nombre1';
                    $zopen=1; $zwidth='auto';
     //                if($aso_jwib['docu']=='AS11'){$zreado=1;}
                    include('ele_input.php');
          }
          else
          {
               $div=$tcell->appendChild($domd->createElement("div",$aso_jwib['bsqj'].' - '.$aso_jwib['bsqj_descri']));
                    $div->setAttribute("size120","");
                    $div->setAttribute("bold","");
               $div=$tcell->appendChild($domd->createElement("div",$aso_jwib['bsqj_tema']));
                    $div->setAttribute("italic","");
               $div=$tcell->appendChild($domd->createElement("div",$aso_jwib['nombre1']));
                    $div->setAttribute("size120","");
          }     
          
          
          
          
          
          
     }     
     
     
}
     
echo $domd->saveXML();     


echo '<a href="https://jwib.vcrxol.com">jwib.vcrxol.com</a>';     
// echo '<a href="https://jwib.vcrxol.com">jwib.vcrxol.com?cong='.$cong_codigo.'</a>';     
     
     
echo '</div>';     
     
}

// echo '========='.$psize;
?>



<?php
// for($idx=1; $idx<=count($group_class); $idx++)
// {
//      echo '<style>' ; 
//      echo '.'.$group_class[$idx].'{page-break-inside: avoid; display:block; }';
//      echo '</style>' ;    
// }
?>






<style>
@page
{
size:<?php echo $psize; ?>;
margin: 50mm 100mm 50mm 50mm; /*	top right bottom left */
}  
@media print {a {text-decoration: none; color: inherit; }}
     
@media print
{
/*     body {transform: scale(.5);} */
/*     table {page-break-inside: avoid;} */
}     
     
     
     
@media print {
  thead {
    display: table-header-group; /* Asegura que los encabezados se repitan si la tabla se divide */
  }

  tr {
    page-break-inside: avoid; /* Evita que las filas se corten entre páginas */
  }

  table {
    page-break-inside: auto; /* Permite que la tabla se divida en varias páginas */
  }
}
     
/*      .no-break {page-break-inside: avoid;}                */
     
                     
     
     
</style>  





<script>
function jwib_asig(event)
{
//      if(event.type=='click' || event.keyCode==13)
     {
//           get_para();
          var xhref='',dataget;
          dataget=new_FormData('filtros','get');
//           xhref=xhref+'?scri=jwib_asig2';
          xhref=xhref+'?scri=<?php echo basename(__FILE__,'.php');?>';
          xhref=xhref+dataget;
          document.getElementById("main2").innerHTML='Espere...';
          location.href=xhref;          
     }
}
</script>


<script>document.title="<?php echo $xtitulo;?>"</script>

