<?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($format=='' and getPlatform()=='Android'){$format=1;}


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_salas'];
if(empty($salas)){$salas=1;}

if(empty($docu)){$docu='ASEM';}     

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

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

// if(mb_stristr('DPU1.DPU2',$docu))
// {$fecha2=date('Y-m-t',strtotime($fecha1.' +3 month'));}

$semana1=date('Y-W',strtotime($fecha1));
$semana2=date('Y-W',strtotime($fecha2));


if($docu=='ASEM')
{
	$modif=$modif*$masem;
     
	$sql_jwib='select *, ';
     if($format==0)
	for($cas10=11; $cas10<=19; $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.='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 "AS%" ';
	$sql_jwib.='and date_format(fecha,"%x-%v")>="'.$semana1.'" ';
	$sql_jwib.='and date_format(fecha,"%x-%v")<="'.$semana2.'" ';
     // desactivar para modificar
	$sql_jwib.='and (nombre1 is not null or nombre2 is not null or nombre3 is not null or nombre4 is not null)';
	$sql_jwib.='and (length(trim(nombre1))>5 or length(trim(nombre2))>5 or length(trim(nombre3))>5 or length(trim(nombre4))>5 )';

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

if($docu=='MMAE')
{
	$modif=$modif*$mmae;
	
	$sql_jwib='select *, ';
//      if($format==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.='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 date_format(fecha,"%x-%v")>="'.$semana1.'" ';
	$sql_jwib.='and date_format(fecha,"%x-%v")<="'.$semana2.'" ';
     // desactivar para modificar
	$sql_jwib.='and (nombre1 is not null or nombre2 is not null or nombre3 is not null or nombre4 is not null)';
	$sql_jwib.='and (length(trim(nombre1))>5 or length(trim(nombre2))>5 or length(trim(nombre3))>5 or length(trim(nombre4))>5 )';

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

if($docu=='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.='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")>="'.$semana1.'" ';
	$sql_jwib.='and date_format(fecha,"%x-%v")<="'.$semana2.'" ';
     // desactivar para modificar
	$sql_jwib.='and (nombre1 is not null or nombre2 is not null or nombre3 is not null or nombre4 is not null)';
	$sql_jwib.='and (length(trim(nombre1))>5 or length(trim(nombre2))>5 or length(trim(nombre3))>5 or length(trim(nombre4))>5 )';
	

     $xgroupby='group by fsema ';
     $xorderby='order by fecha,fechar,docu ';
     
     if($format==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($docu=='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 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 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")>="'.$semana1.'" ';
	$sql_jwib.='and date_format(fecha,"%x-%v")<="'.$semana2.'" ';
     // desactivar para modificar
	$sql_jwib.='and (nombre1 is not null or nombre2 is not null or nombre3 is not null or nombre4 is not null)';
	$sql_jwib.='and (length(trim(nombre1))>5 or length(trim(nombre2))>5 or length(trim(nombre3))>5 or length(trim(nombre4))>5 )';
	

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

if(mb_stristr('DPU1.DPU2',$docu))
{
	$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($docu=='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)';
          $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 ="'.$docu.'" ';
	$sql_jwib.='and date_format(fecha,"%x-%v")>="'.$semana1.'" ';
	$sql_jwib.='and date_format(fecha,"%x-%v")<="'.$semana2.'" ';
     // desactivar para modificar
// 	$sql_jwib.='and (nombre1 is not null or nombre2 is not null or nombre3 is not null or nombre4 is not null)';
// 	$sql_jwib.='and (length(trim(nombre1))>5 or length(trim(nombre2))>5 or length(trim(nombre3))>5 or length(trim(nombre4))>5 )';
	$sql_jwib.='and (nombre1 is not null) ';
	$sql_jwib.='and (length(trim(nombre1))>5) ';

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

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

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




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



// $ptabla='item';
// $pcolu='nombre1';
// include('ele_datalist.php');


echo '<div id="filtros" noprint >';     
{
// OCULTOS
echo '<input id="cong" hide value="'.$_SESSION['cong_codigo'].'">';
     
$ptitulo='Tablero de Anuncios';     
include('ele_title.php');

$pobj=1;
include('ele_break.php');
     
$pid='docu';
$plabel='Asignaciones';
// $pobj=1;
// $ponblur='{sele_cong(event);}';
$pvalue=$docu;
$ponchange='{jwib_asig(event);}';
$poptions='';
$poptions.='ASEM,Asig.Semanales;';
$poptions.='MMAE,Mejores Maestros;';
$poptions.='VIDA,Vida Cristiana;';
$poptions.='ESTU,Estudios;';
$poptions.='DPU1,Reunión Pública;';
$poptions.='DPU2,Discursantes;';
include('ele_select.php');

// $pid='sema';
// $plabel='Semana';
// $pvalue=$sema;
// $ptype='week';
// include('ele_input.php');

$pid='mes';
$plabel='Mes';
$pvalue=$mes;
$ptype='month';
$ponchange='{jwib_asig(event);}';
include('ele_input.php');

// $pid='anio';
// $plabel='Año';
// $pvalue=$anio;
// $ptype='year';
// include('ele_input.php');

$pid='format';
$plabel='Formato';
$pvalue=$format;
if($format=='')     
{$pvalue=$_SESSION['screeno'];}
$ponchange='{jwib_asig(event);}';
$poptions='';
$poptions.='0,Horizontal;';
$poptions.='1,Vertical;';
include('ele_select.php');
     
     
$pid='btn_consultar'; 
$plabel='Consultar';
$palign='right';
// $psize=1.8;
$ponclick='{jwib_asig(event);}';
include('ele_button.php');


// $pid='xyzend';
// $phide=1;
// include('ele_input.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("bt-s1","");   
     $table->setAttribute("bb-s1","");   
//      if($format==1 or $_SESSION['screeno']==1)
//      if($format==1)
//      if($format==1 and empty($_SESSION['screeno']))
     if($format==1 and $_SESSION['screeno']!=1)
     {$table->setAttribute("width","50%");}

if($docu=='ASEM')
{
          
     $trow=$table->appendChild($domd->createElement("tr"));
          $trow->setAttribute("style","border-top:solid 2px;background-color: #A9F5F2;");

     if($format==0)
     {
          $tcell=$trow->appendChild($domd->createElement("th",strftime2('%B / %Y',strtotime($fecha1))));
          $tcell=$trow->appendChild($domd->createElement("th","ASIGNACIONES"));
     }

     if($format==1)
     {$tcell=$trow->appendChild($domd->createElement("th","ASIGNACIONES - ".strftime2('%B / %Y',strtotime($fecha1))));}

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


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

          for($cas10=11; $cas10<=19; $cas10++)
          {
               $colname=msql_result($res_jwib,0,'docud_'.$cas10);
               $tcell=$trow->appendChild($domd->createElement("th",$colname));
          }
     }

     $lfecha='';
     msql_data_seek($res_jwib,0);     

     if($format==0)
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {
          $trow=$table->appendChild($domd->createElement("tr"));
               $trow->setAttribute("bb-d1","");
               $trow->setAttribute("hoverbg","");
               $trow->setAttribute("align-c","");
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}

          
          
          $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",strftime2('%a / %d',strtotime($fechar1))));
          $tcell=$trow->appendChild($domd->createElement("td",""));
               $div=$tcell->appendChild($domd->createElement("div",strftime2('%a/%d',strtotime($fechar1)).' - '.strftime2('%a/%d',strtotime($fechar2))));
//                $div=$tcell->appendChild($domd->createElement("div",strftime2('%a / %d',strtotime($fechar2))));
               $tcell->setAttribute("nowrap","");
               for($cas10=11; $cas10<=19; $cas10++)
               {
                    $tcell=$trow->appendChild($domd->createElement("td",""));
                    $nombre1=ucwords2($aso_jwib['nom1_'.$cas10]);
                    $nombre3=ucwords2($aso_jwib['nom3_'.$cas10]);
                    $div=$tcell->appendChild($domd->createElement("div",$nombre1));
                    $div=$tcell->appendChild($domd->createElement("hr",""));
                    $div=$tcell->appendChild($domd->createElement("div",$nombre3));

                    // leer nombre
//                     $pid='nom1_';
//                     $pdom=$domd;
//                     $pele=$tcell;
//                     $plabel='NOMBRE 1';
//                     $pvalue=$nombre1;
//                     $pobj=1;
//                     include('ele_input.php');
                    
               }
     }

     $idxbrow=0;
     if($format==1)
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {
          if($lfecha!=$aso_jwib['fechar'])
          {
               $trow=$table->appendChild($domd->createElement("tr"));
               $trow->setAttribute("style","border-top:solid 2px;background-color: #A9F5F2;");
               $trow->setAttribute("align-c","");
//                if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("bold","");}
               
          $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",strftime2('%a / %d',strtotime($fechar1))));
          $tcell=$trow->appendChild($domd->createElement("td",""));
               $div=$tcell->appendChild($domd->createElement("div",strftime2('%A/%d',strtotime($fechar1)).' - '.strftime2('%A/%d',strtotime($fechar2))));
               
//                $tcell=$trow->appendChild($domd->createElement("td",strftime2('%A / %d',strtotime($aso_jwib['fechar']))));
               $tcell->setAttribute("colspan","3");
               $tcell->setAttribute("nowrap","");
               $idxbrow=0;
          }
          $lfecha=$aso_jwib['fechar'];

          $idxbrow++;
          $trow=$table->appendChild($domd->createElement("tr"));
               if($idxbrow%2==0)
               $trow->setAttribute("bb-d1","");          
               $trow->setAttribute("hoverbg","");
               $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'])));
          $nombre1=ucwords2($aso_jwib['nombre1']);
          $nombre2=ucwords2($aso_jwib['nombre2']);
          $nombre3=ucwords2($aso_jwib['nombre3']);
          $nombre4=ucwords2($aso_jwib['nombre4']);
          $tcell=$trow->appendChild($domd->createElement("td",""));
          $div=$tcell->appendChild($domd->createElement("div",$nombre1));
          $tcell=$trow->appendChild($domd->createElement("td",""));
          $div=$tcell->appendChild($domd->createElement("div",$nombre3));
     }     

}
     
if($docu=='MMAE')
{
     $trow=$table->appendChild($domd->createElement("tr"));
          $trow->setAttribute("style","border-top:solid 2px; border-color:black; background-color: #C18626;color:white;");
     if($format==0)
     {
          $tcell=$trow->appendChild($domd->createElement("th",strftime2('%B / %Y',strtotime($fecha1))));
          $tcell->setAttribute("width","30%");
          $tcell=$trow->appendChild($domd->createElement("th","MEJORES MAESTROS"));
     }
     if($format==1)
     {$tcell=$trow->appendChild($domd->createElement("th","MEJORES MAESTROS - ".strftime2('%B / %Y',strtotime($fecha1))));}
     
     $tcell->setAttribute("colspan","10");
     $tcell->setAttribute("style","height:2.5em;");

     $lfecha='';
     msql_data_seek($res_jwib,0);     
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {

     if($lfecha!=$aso_jwib['fechar'])
     {
          $trow=$table->appendChild($domd->createElement("tr"));
               $trow->setAttribute("style","border-top:solid 2px; border-color:black; background-color: #C18626; color:white;");
               if($format==1)
               $trow->setAttribute("style","border-top:solid 2px; border-color:black; background-color: #C18626; color:white;");
          $tcell=$trow->appendChild($domd->createElement("th",strftime2('%A / %d',strtotime($aso_jwib['fechar']))));
          $tcell->setAttribute("nowrap","");
          if($format==1)
          {$tcell->setAttribute("colspan",10);}

          if($format==0)
          for($cas10=0; $cas10<=$salas; $cas10++)
          {
               $colname='SALA '.$cas10;
               if($cas10==0)
               {$colname='PRINCIPAL';}
               $tcell=$trow->appendChild($domd->createElement("th",$colname));
          }

     }
          $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'];}
          $jwol_smm=trim($jwol_smm);
          $jwol_smm=substr($jwol_smm,strpos($jwol_smm,'<div'));
          $jwol_smm=substr($jwol_smm,0,strrpos($jwol_smm,'</div>')+6);

          $trow=$table->appendChild($domd->createElement("tr"));
               $trow->setAttribute("bb-d1","");
               $trow->setAttribute("hoverbg","");
               $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($format==1)
          {$tcell->setAttribute("style","border-top:solid 2px; border-color:black;");}
          if(!empty($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=$domd->createDocumentFragment();
               $jwol->appendXML($jwol_smm);               
               $tcell->appendChild($jwol);
          }

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

          if($format==1)
          {
               $trow=$table->appendChild($domd->createElement("tr"));
               $trow->setAttribute("hoverbg","");
               $trow->setAttribute("align-c","");
               $trow->setAttribute("align-t","");
          }

               for($cas10=0; $cas10<=$salas; $cas10++)
               {
                    $nombre1=($aso_jwib['nom1sala'.$cas10]);
                    $nombre2=ucwords2($aso_jwib['nom2sala'.$cas10]);
//                          $nombre3=ucwords2($aso_jwib['nom3sala'.$cas10]);
//                          $nombre4=ucwords2($aso_jwib['nom4sala'.$cas10]);
//                     if(!empty($nombre1))
                    {
                         $tcell=$trow->appendChild($domd->createElement("td"));
                         if($format==1)
                         {
                              $nomsala=" ".$cas10;
                              if($cas10==0){$nomsala=" PRINCIPAL";}
                              $div=$tcell->appendChild($domd->createElement("div",$nomsala));
                              $div->setAttribute("size80","");
                         }
                         $div=$tcell->appendChild($domd->createElement("div",$nombre1));
                         if(!empty($nombre2))
                         {
                              if($format==0)
                              $div=$tcell->appendChild($domd->createElement("br",""));
                              $div=$tcell->appendChild($domd->createElement("div",$nombre2));
                         }                              
                    }
               }
     }
}    

if($docu=='VIDA')
{
     $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; ");
     
     
     $trow=$table->appendChild($domd->createElement("tr"));
          $trow->setAttribute("style","background-color:darkblue;color:white;");
     
     $tcell=$trow->appendChild($domd->createElement("th","VIDA CRISTIANA - ".strftime2('%B / %Y',strtotime($fecha1))));
          $tcell->setAttribute("colspan","10");
          $tcell->setAttribute("style","height:2.5em;");

     if($format==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","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","FECHA"));
          $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;");
          
     }
     
     
     
     $lfecha='';
     msql_data_seek($res_jwib,0);     
     
     if($format==0)
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {
          $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","");
          $tcell=$trow->appendChild($domd->createElement("td",strftime2('%a / %d',strtotime($aso_jwib['fechar']))));          
               $tcell->setAttribute("nowrap","");
          $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom1vmc']));          
          $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom2vmc']));          
          $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom1ora']));          
          $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom2ora']));   
          
          $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom1tdb']));          
               $div=$tcell->appendChild($domd->createElement("div",""));          
               $div->setAttribute("size80","");
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_tdb1'];
               if(mb_stristr($jwol_smm,'<a'))
               $jwol_smm=trim($jwol_smm).'</a>';
               if(!empty($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=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
          $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom2tdb']));          
               $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('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=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
          $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom1nvc']));          
               $div=$tcell->appendChild($domd->createElement("div",""));          
               $div->setAttribute("size80","");
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_nvc1'];
               if(mb_stristr($jwol_smm,'<a'))
               $jwol_smm=trim($jwol_smm).'</a>';
//                $jwol_smm=substr($jwol_smm,strpos($jwol_smm,'<div'));
//                $jwol_smm=substr($jwol_smm,0,strrpos($jwol_smm,'</div>')+6);
               if(!empty($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=$domd->createDocumentFragment();
//                     echo '*/*/*/*'.$jwol_smm;
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
          $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom2nvc']));   
               $div=$tcell->appendChild($domd->createElement("div",""));          
               $div->setAttribute("size80","");
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_nvc2'];
               $jwol_smm=trim($jwol_smm).'</a>';
               if(!empty($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=$domd->createDocumentFragment();
//                     $jwol->appendXML($jwol_smm);               
//                     $div->appendChild($jwol);
               }
          
          
          
          
          
     }     
     
     if($format==1)
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {
          $table->setAttribute("align-c","");          
          if($lfecha!=$aso_jwib['fechar'])
          {
               $trow=$table->appendChild($domd->createElement("tr"));
               $tcell=$trow->appendChild($domd->createElement("td"));
                    $tcell->setAttribute("width","15%");
               $tcell=$trow->appendChild($domd->createElement("td"));
//                     $tcell->setAttribute("width","50%");
               $tcell=$trow->appendChild($domd->createElement("td"));
                    $tcell->setAttribute("width","30%");
               
               $trow=$table->appendChild($domd->createElement("tr"));
               $trow->setAttribute("style","background-color:darkblue;color:white;");
               $trow->setAttribute("align-c","");
//                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",$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",$aso_jwib['nom2vmc']));
          }
          if($aso_jwib['docu']=='VM19')
          {
//                $trow=$table->appendChild($domd->createElement("tr"));
//                $tcell=$trow->appendChild($domd->createElement("td","VMC"));
               $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",$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",$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(mb_stristr($jwol_smm,'<a'))
               $jwol_smm=trim($jwol_smm).'</a>';
               if(!empty($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=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
               $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('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=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
               $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",""));          
//                $div->setAttribute("size80","");
               $jwol_smm='';
               $jwol_smm=$aso_jwib['jwol_nvc1'];
               if(mb_stristr($jwol_smm,'<a'))
               $jwol_smm=trim($jwol_smm).'</a>';
//                $jwol_smm=substr($jwol_smm,strpos($jwol_smm,'<div'));
//                $jwol_smm=substr($jwol_smm,0,strrpos($jwol_smm,'</div>')+6);
               if(!empty($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=$domd->createDocumentFragment();
//                     echo '*/*/*/*'.$jwol_smm;
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
               $tcell=$trow->appendChild($domd->createElement("td",$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",""));
               $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom2nvc']));
          }
          
          
          
     }     
     
     
     
}     

     
if($docu=='ESTU')
{
     $tcolg=$table->appendChild($domd->createElement("colgroup"));
     if($format==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($format==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; ");
     }
     
     
     $trow=$table->appendChild($domd->createElement("tr"));
          $trow->setAttribute("style","border-top:solid 2px;background-color:darkblue;color:white;");
     
     $tcell=$trow->appendChild($domd->createElement("th","ESTUDIOS - ".strftime2('%B / %Y',strtotime($fecha1))));
          $tcell->setAttribute("style","height:2.5em;");
          $tcell->setAttribute("colspan","10");

     if($format==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->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->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;");
          
     }
     
     if($format==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;");
          
     }
     
     
     
     $lfecha='';
     msql_data_seek($res_jwib,0);     
     $idxbrow=0;
     if($format==0)
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {
          $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("style","height:2em;     ");
          $tcell=$trow->appendChild($domd->createElement("td",date('W',strtotime($aso_jwib['fecha']))));          
          $tcell=$trow->appendChild($domd->createElement("td",strftime2('%a / %d',strtotime($aso_jwib['fecha_lib']))));          
               $tcell->setAttribute("nowrap","");
          $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom1_lib']));          
               $div=$tcell->appendChild($domd->createElement("div",""));          
               $div->setAttribute("size80","");
               $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('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=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
          $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->setAttribute("nowrap","");
          $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('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=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
          
          $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom2_ata']));          
          
//           $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom1tdb']));          
//                $div=$tcell->appendChild($domd->createElement("div",""));          
//                $div->setAttribute("size80","");
//                $jwol_smm='';
//                $jwol_smm=$aso_jwib['jwol_tdb1'];
//                if(mb_stristr($jwol_smm,'<a'))
//                $jwol_smm=trim($jwol_smm).'</a>';
//                if(!empty($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=$domd->createDocumentFragment();
//                     $jwol->appendXML($jwol_smm);               
//                     $div->appendChild($jwol);
//                }
//           $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom2tdb']));          
//                $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('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=$domd->createDocumentFragment();
//                     $jwol->appendXML($jwol_smm);               
//                     $div->appendChild($jwol);
//                }
//           $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom1nvc']));          
//                $div=$tcell->appendChild($domd->createElement("div",""));          
//                $div->setAttribute("size80","");
//                $jwol_smm='';
//                $jwol_smm=$aso_jwib['jwol_nvc1'];
//                if(mb_stristr($jwol_smm,'<a'))
//                $jwol_smm=trim($jwol_smm).'</a>';
// //                $jwol_smm=substr($jwol_smm,strpos($jwol_smm,'<div'));
// //                $jwol_smm=substr($jwol_smm,0,strrpos($jwol_smm,'</div>')+6);
//                if(!empty($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=$domd->createDocumentFragment();
// //                     echo '*/*/*/*'.$jwol_smm;
//                     $jwol->appendXML($jwol_smm);               
//                     $div->appendChild($jwol);
//                }
//           $tcell=$trow->appendChild($domd->createElement("td",$aso_jwib['nom2nvc']));   
//                $div=$tcell->appendChild($domd->createElement("div",""));          
//                $div->setAttribute("size80","");
//                $jwol_smm='';
//                $jwol_smm=$aso_jwib['jwol_nvc2'];
//                $jwol_smm=trim($jwol_smm).'</a>';
//                if(!empty($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=$domd->createDocumentFragment();
// //                     $jwol->appendXML($jwol_smm);               
// //                     $div->appendChild($jwol);
//                }
          
          
          
          
          
     }     
     
     if($format==1)
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {
          $idxbrow++;
          $trow=$table->appendChild($domd->createElement("tr"));
               if(date('Y-W')==$aso_jwib['fsema'])
               {$trow->setAttribute("boldsc","");}
//                if($idxbrow%2==0)
//                {$trow->setAttribute("bb-s1","");}
               $trow->setAttribute("align-c","");
               $trow->setAttribute("align-t","");
               $trow->setAttribute("hoverbg","");
//                $trow->setAttribute("style","height:2em;     ");
          
          $tcell=$trow->appendChild($domd->createElement("td"));          
               $div=$tcell->appendChild($domd->createElement("div",strftime2('%a / %d',strtotime($aso_jwib['fecha_lib']))));          
               $div=$tcell->appendChild($domd->createElement("div",$aso_jwib['nom1_lib']));          
               $div=$tcell->appendChild($domd->createElement("div",""));          
               $div->setAttribute("size80","");
               $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('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=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
          
               $div=$tcell->appendChild($domd->createElement("div",ucwords2($aso_jwib['nom2_lib'])));          
               $div=$tcell->appendChild($domd->createElement("br"));          
          
          $tcell=$trow->appendChild($domd->createElement("td"));          
               $div=$tcell->appendChild($domd->createElement("div",strftime2('%a / %d',strtotime($aso_jwib['fecha_ata']))));          
               $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(mb_stristr($jwol_smm,'<a'))
               $jwol_smm=trim($jwol_smm).'</a>';
               if(!empty($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=$domd->createDocumentFragment();
                    $jwol->appendXML($jwol_smm);               
                    $div->appendChild($jwol);
               }
          
               $div=$tcell->appendChild($domd->createElement("div",ucwords2($aso_jwib['nom2_ata'])));          
               $div=$tcell->appendChild($domd->createElement("br"));          
          
          
          
          
          
          
     }     
     
     
     
}     

     

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

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

               if($docu=='DPU1')
               {$tcell=$trow->appendChild($domd->createElement("th",'REUNION PUBLICA - '.strftime2('%B / %Y',strtotime($aso_jwib['fecha']))));}
               if($docu=='DPU2')
               {$tcell=$trow->appendChild($domd->createElement("th",'DISCURSANTES - '.strftime2('%B / %Y',strtotime($aso_jwib['fecha']))));}
                    $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($docu=='DPU1')
                    {$tcell=$trow->appendChild($domd->createElement("th","VIENEN : ".$aso_jwib['cong2_descri']));}
                    if($docu=='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['fecha'],0,7);

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

//           if($docu=='DPU1')
          {$tcell=$trow->appendChild($domd->createElement("td",strftime2('%a / %d',strtotime($aso_jwib['fechar']))));}
//           if($docu=='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));
          $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($format==1)
     while($aso_jwib=msql_fetch_assoc($res_jwib))
     {
//           if($lfecha!=date('Y-m',strtotime($aso_jwib['fechar'])))
          if($lfecha!=substr($aso_jwib['fecha'],0,7))
          {
               $trow=$table->appendChild($domd->createElement("tr"));
                    $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($docu=='DPU1')
               {$tcell=$trow->appendChild($domd->createElement("th",'REUNION PUBLICA - '.strftime2('%B / %Y',strtotime($aso_jwib['fecha']))));}
               if($docu=='DPU2')
               {$tcell=$trow->appendChild($domd->createElement("th",'DISCURSANTES - '.strftime2('%B / %Y',strtotime($aso_jwib['fecha']))));}
                    $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($docu=='DPU1')
                    {$tcell=$trow->appendChild($domd->createElement("th","VIENEN : ".$aso_jwib['cong2_descri']));}
                    if($docu=='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['fecha'],0,7);

          $idxbrow++;
          
          $trow=$table->appendChild($domd->createElement("tr"));
               $trow->setAttribute("bb-d1","");
               $trow->setAttribute("hoverbg","");
               $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']))));
//           $tcell=$trow->appendChild($domd->createElement("td",($aso_jwib['fechar'])));
//                $tcell->setAttribute("nowrap","");
//           $tcell=$trow->appendChild($domd->createElement("td",$lfecha));
//           $div=$tcell->appendChild($domd->createElement("div",$aso_jwib['bsqj']));
          $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("bold","");
//                $div->setAttribute("italic","");
               $div->setAttribute("size120","");
     }     
     
     
}
     
     
     
echo $domd->saveXML();     
     

echo '<a href="jwib.vcrxol.com" >jwib.vcrxol.com</a>';     
     
     
echo '</div>';     
     
}




?>

<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+dataget;
          document.getElementById("main2").innerHTML='Espere...';
          location.href=xhref;          
     }
}
</script>


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


