
<?php
include_once('../vfoto/class/class.mysql.php');
include_once('../vfoto/evento/class.evento.php');
//$evento = new Evento();
include_once('../vfoto/feriado/class.feriado.php');
$feriado = new Feriado();
include_once('../vfoto/include/utilitarios.php');
$mysqlCom = $mysqlCom = new MysqlConnect();


if(empty($_GET['data'])){//navegaçao entre os meses
    $dia = date('d');
    $month =ltrim(date('m'),"0");
    $ano = date('Y');
}else{
    $data = explode('/',$_GET['data']);//nova data
    $dia = $data[0];
    $month = $data[1];
    $ano = $data[2];
}


if($month==1){//mês anterior se janeiro mudar valor
    $mes_ant = 12;
    $ano_ant = $ano - 1;
}else{
    $mes_ant = $month - 1;
    $ano_ant = $ano;
}


if($month==12){//proximo mês se dezembro tem que mudar
    $mes_prox = 1;
    $ano_prox = $ano + 1;
}else{
    $mes_prox = $month + 1;
    $ano_prox = $ano;
}

$n = '';

$hoje = date('j');//função importante pego o dia corrente

switch($month.$n){/*notem duas variaveis para o switch para identificar dia e limitar numero de dias*/
    case 1: $mes = "JANEIRO";
            $n = 31;
    break;
    case 2: $mes = "FEVEREIRO";// todo ano bixesto fev tem 29 dias
            $bi = $ano % 4;//anos multiplos de 4 são bixestos
            if($bi == 0){
                $n = 29;
            }else{
                $n = 28;
            }
    break;
    case 3: $mes = "MAR&Ccedil;O";
            $n = 31;
    break;
    case 4: $mes = "ABRIL";
            $n = 30;
    break;
    case 5: $mes = "MAIO";
            $n = 31;
    break;
    case 6: $mes = "JUNHO";
            $n = 30;
    break;
    case 7: $mes = "JULHO";
            $n = 31;
    break;
    case 8: $mes = "AGOSTO";
            $n = 31;
    break;
    case 9: $mes = "SETEMBRO";
            $n = 30;
    break;
    case 10: $mes = "OUTUBRO";
            $n = 31;
    break;
    case 11: $mes = "NOVEMBRO";
            $n = 30;
    break;
    case 12: $mes = "DEZEMBRO";
            $n = 31;
	break;

}



$pdianu = mktime(0,0,0,$month,1,$ano);//primeiros dias do mes
$dialet = date('D', $pdianu);//escolhe pelo dia da semana
switch($dialet){//verifica que dia cai
    case "Sun": $branco = 0; break;
    case "Mon": $branco = 1; break;
    case "Tue": $branco = 2; break;
    case "Wed": $branco = 3; break;
    case "Thu": $branco = 4; break;
    case "Fri": $branco = 5; break;
    case "Sat": $branco = 6; break;
}            

 $diaSemana = array('Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado');
?>


<!DOCTYPE html>
<!--[if lt IE 7 ]><html class="ie ie6" lang="pt"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="pt"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="pt"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><html lang="pt"> <!--<![endif]-->
<head>

	<!-- Basic Page Needs
  ================================================== -->
	<meta charset="utf-8">
	<title>Your Page Title Here :)</title>
	<meta name="description" content="">
	<meta name="author" content="">

	<!-- Mobile Specific Metas
  ================================================== -->
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

	<!-- CSS
  ================================================== -->
	<link rel="stylesheet" href="calendario/skeleton.css">
	
	<!--[if lt IE 9]>
		<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->

	<!-- Favicons
	================================================== -->
	<link rel="shortcut icon" href="images/favicon.ico">
	<link rel="apple-touch-icon" href="images/apple-touch-icon.png">
	<link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
	<link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">

</head>
<body>
	<!-- Primary Page Layout
	================================================== -->

	<!-- Delete everything in this .container and get started on your own site! -->

	<div class="container">
		<div class="sixteen.columns">
                <div id="dvPrincipal">
<div class="two columns omega semana divDia">Domingo</div>
<div class="two columns omega semana divDia">seg</div>
<div class="two columns omega semana divDia">ter</div>
<div class="two columns omega semana divDia">qua</div>
<div class="two columns omega semana divDia">qui</div>
<div class="two columns omega semana divDia">sex</div>
<div class="two columns omega semana divDia">sab</div>


<?php
$calendario = new Calendario();
	
		if($branco > 0){
        for($x = 0; $x < $branco; $x++){
             echo '<div class="two columns omega semana" style="border:solid 1px #FFF">&nbsp;</div>';/*preenche os espaços em branco*/
            $dt++;
        }
    }
	
	$aSemana= 1;
	for ($i = 1; $i <= $n; $i++) {
		if($dt > 6){ $aSemana++; $dt = 1; } $dt++;
		
		
   	   echo '<div class="two columns omega divDia pnDia sm'.$aSemana . $calendario->ImagemDaSemana($i,$month,$ano).'">';
	    $calendario->ListaNumDia_BtnNovoEvento($i,$month,$ano);
	    $calendario->ListaEventos($i,$month,$ano);
	   	   
	   echo '</div>';
	   
 
  }


class Calendario{
	public $pdianu;//primeiros dias do mes
	public $dialet;//escolhe pelo dia da semana
	public $evento;
	public $dtevento;
	public $data_dia;
	public $data_invirtida;
	
	
	public function __construct(){	
	 $this->evento = new Evento;
	}
	
	
	function ImagemDaSemana($dia, $mes, $ano){
		
	 $this->pdianu = mktime(0,0,0,$mes,$dia,$ano);//primeiros dias do mes
	 $this->dialet = date('D', $this->pdianu);//escolhe pelo dia da semana
		switch($dialet){//verifica que dia cai
			case "Sun": $imgDia = 'dom'; break;
			case "Mon": $imgDia = 'seg'; break;
			case "Tue": $imgDia = 'ter'; break;
			case "Wed": $imgDia = 'qua'; break;
			case "Thu": $imgDia = 'qui'; break;
			case "Fri": $imgDia = 'sex'; break;
			case "Sat": $imgDia = 'sab'; break;
		} 
		return $imgDia;
		//return '<img class="img_semana" src="'.$imgDia.'"/>';	
	}	
	
	

	function ListaNumDia_BtnNovoEvento($dia, $mes, $ano){
	$this->dtevento = $dia."-".$mes."-".$ano;
	$this->data_dia = $dia."/".$mes."/".$ano;
	$this->data_invirtida = $ano.'/'.$mes.'/'.$dia;
	 
		
		$this->evento->ListaEvento($this->data_invirtida); 
		$qtoEvento =  mysqli_num_rows($this->evento->qry); //$evento->QuantidadeEvento($ano.'/'.$month.'/'.$i);
		
		//Lista dia
		echo $qtoEvento > 0 ? '<a href="'.$this->data_invirtida.'" class="btnLista" title=" Listar Eventos">' .$dia .
							  ' <span style="font-size:10;">Evento '. $qtoEvento .'</span></a>' : $dia;
		//BtnNovo Evento
		echo "<a class='btnNovoEvento' data='$data_dia' href='?p=evento/novo_evento&d=$dia&m=$mes&a=$ano' title='Novo Evento'><div class='botao' ></div></a>";	
		
		
		}
		
	

		function ListaEventos($dia, $mes, $ano){
			$this->dtevento = $dia."-".$mes."-".$ano;
			$this->data_dia = $dia."/".$mes."/".$ano;
			$this->data_invirtida = $ano.'/'.$mes.'/'.$dia;
	 			
			$this->evento->ListaEvento($this->data_invirtida);
			while($row = mysqli_fetch_object($this->evento->qry)){
				$classEvento = 'alert alert-info';
					   switch ($row->abreviacao) {
						case "CA":
							$classEvento = 'alert alert-error';
							break;
						case "CR":
							$classEvento = 'alert alert-error';
							break;
						case "SP":
							$classEvento = 'alert alert-success';
							break;
						case "SF":
							$classEvento = 'alert alert-success';
							break;
						case "BP":
							$classEvento = 'alert alert-error';
							break;
						case "BS":
							$classEvento = 'alert alert-error';
							break;
						case "ES":
							$classEvento = 'alert alert-error';
							break;
						case "AN":
							$classEvento = 'alert alert-error';
							break;
					}
					$Cancelado =  $row->cancelado == 'S' ? 'evtCancelado' : '';
					$CanceladoTitulo  = $row->cancelado == 'S' ? 'Evento Cancelado' : '';
				
				
				 
				echo "<div class='$classEvento $Cancelado' align='left' >
				<a href='?p=evento/principal&id_evento=$row->id_evento' 
				title='$CanceladoTitulo  $row->tipo_evento - $row->nome - hs.: $row->hora'>";
							   echo $row->abreviacao;
							   echo '-';
							   echo substr($CanceladoTitulo . $row->nome,0,14);
							   echo "</a> </div>";
			}
		
		
		}
		
}



?>
</div>
<div style="clear:both"></div>
<script>$('#dvPrincipal .sm1').css('height','120px');</script>		
		
        </div>

        
        <div class="sixteen.columns">
			<h1 class="remove-bottom" style="margin-top: 40px; ">Skeleton</h1>
			<h5>Version 1.2</h5>
			<hr />
		</div>
		<div class="one-third column">
			<h3>About Skeleton?</h3>
			<p>Skeleton is a small collection of well-organized CSS files that can help you rapidly develop sites that look beautiful at any size, be it a 17" laptop screen or an iPhone. It's based on a responsive grid, but also provides very basic CSS for typography, buttons, forms and media queries. Go ahead, resize this super basic page to see the grid in action.</p>
		</div>
		<div class="one-third column">
			<h3>Three Core Principles</h3>
			<p>Skeleton is built on three core principles:</p>
			<ul class="square">
				<li><strong>A Responsive Grid Down To Mobile</strong>: Elegant scaling from a browser to tablets to mobile.</li>
				<li><strong>Fast to Start</strong>: It's a tool for rapid development with best practices</li>
				<li><strong>Style Agnostic</strong>: It provides the most basic, beautiful styles, but is meant to be overwritten.</li>
			</ul>
		</div>
		<div class="one-third column">
			<h3>Docs &amp; Support</h3>
			<p>The easiest way to really get started with Skeleton is to check out the full docs and info at <a href="http://www.getskeleton.com">www.getskeleton.com.</a>. Skeleton is also open-source and has a <a href="https://github.com/dhgamache/skeleton">project on git</a>, so check that out if you want to report bugs or create a pull request. If you have any questions, thoughts, concerns or feedback, please don't hesitate to email me at <a href="mailto:hi@getskeleton.com">hi@getskeleton.com</a>.</p>
		</div>

	</div><!-- container -->


<!-- End Document
================================================== -->
</body>
</html>