#!/usr/bin/perl
use strict;
$ENV{DOCUMENT_ROOT}.='/' if $ENV{DOCUMENT_ROOT};
use Time::Local 'timelocal';
my $html;
my $linea;
my $check;
require $ENV{DOCUMENT_ROOT}.'_adm/incs/Generales.pm';
require $ENV{DOCUMENT_ROOT}.'_adm/incs/Destacados.pm';
require $ENV{DOCUMENT_ROOT}.'_adm/incs/clBase.pm';
my $ref=Generales::Entrada();
my %para=%$ref;
my $idTapa_sec;
my $nombreTapa_sec;
my @Notas;
my $hoy = time;
my $oEvento;
my $Puntero;
my $oBase = clBase->new();
######################################################################
my @Row ;
if (!$para{mes}) {
$para{mes}=-1;
}
my $anio=(localtime($hoy))[5] + 1900;
my $mes=((localtime($hoy))[4])+$para{mes};
if ($mes>11) {
$mes=0;
}
if ($mes==1) {
$anio-=1;
$mes=11;
$para{mes}-=2;
}
if ($mes==0) {
$anio+=1;
$mes=3;
$para{mes}+=2;
}
if ($mes<0) {
my $cantidad=int($mes/12)*-1+1;
$anio-=$cantidad;
$mes=12*$cantidad+$mes;
}
my $mesPasado=(timelocal 0,0,0,1,$mes,$anio);
my $cantDiasMes=Generales::DiasMes($mes);
my $mesSguiente=(timelocal 0,0,0,1,$mes,$anio)+60*60*24*$cantDiasMes;
open (ARCHI, $ENV{DOCUMENT_ROOT}.'calendario/tpl/pasadas.htm')||print $!."- calendario.pl \n";
while ($linea = ){
$html .= $linea;
}
close ARCHI;
$html =Generales::sacaLineas($html);
#Generales::Debug($mes." ".$anio);
if (($mes<4&&$anio==2004)||$anio<2004) {
$html=~s/()(.*)()//gi;
}
my $mesCambio=$para{mes}-1;
my $mesCambioP=$para{mes}+1;
if ($mesCambioP==0) {
$html=~s/()(.*)()//gi;
}
$html=~s//$mesCambio/gi;
$html=~s//$mesCambioP/gi;
my $unasemana=$hoy+60*60*24*7;
my @Actividades = $oBase->Seleccionar(qq~SELECT tnota.idNota from
((((tnota INNER JOIN tnotahorario on tnotahorario.idNota = tnota.idNota)
INNER JOIN thorario on thorario.idHorario = tnotahorario.idHorario)
LEFT JOIN tnotasala on tnotasala.idNota = tnota.idNota)
LEFT JOIN tsala on tsala.idSala = tnotasala.idSala)
WHERE thorario.cFechaOut>$mesPasado AND thorario.cFechaIn<$mesSguiente
AND tnota.isPub=2
GROUP BY tnota.idNota
ORDER BY thorario.cFechaIn ASC, tsala.cOrden ASC
~);
my $contador=0;
my @TipoEvento;
foreach $Puntero (@Actividades){
my $nota=$$Puntero[0];
my $tipo;
($html, $tipo) = Destacados::New($html, $nota);
$TipoEvento[$tipo]=1;
}
$html=~ s/.*//gi if !$TipoEvento[2];
$html=~ s/.*//gi if !$TipoEvento[1];
$html=~ s/.*//gi if !$TipoEvento[3];
$html=~ s/.*//;
$html=~ s/.*//;
$html=~ s/.*//;
#my $mes = ('Enero','Febrero','Marzo','Abril','Mayo', 'Junio','Julio','Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre')[(localtime($ahora))[4]];~
my $ahora=time;
my $mes = (localtime($ahora))[4]+1;
my $anio = (localtime($ahora))[5] + 1900;
my $flagLoop=0;
my $mesAtras=0;
my $opciones;
while(!$flagLoop){
$mesAtras--;
$mes--;
if ($mes<3) {
$mes=12;
$anio--;
$mesAtras--;
$mesAtras--;
}
if ($anio==2004&&$mes==4) {
$flagLoop=1;
}
my $nombreMes=('','Enero','Febrero','Marzo','Abril','Mayo', 'Junio','Julio','Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre')[$mes];
$opciones.=qq~
~;
}
$html=~s//$opciones/gi;
########################## IMPRIMISION ############################################
$html =Generales::procesarDinamico($html, $para{mes});
$html =Generales::poneLineas($html);
Generales::imprimir($html);
#############################################################################################