************************************************
* calendario.css *
************************************************
/* CSS Document */
.calendario_tabela{
font-family:monospace;
font-size:10px;
border:1px solid #999999;
background:#F5F5F5;
}
.calendario_dias{
background:#FFFFFF;
padding:2px;
}
.calendario_dias_hoje{
background:#C0C0C0;
padding:2px;
}
.calendario_semana{
background:#999999;
color:#FFFFFF;
text-align:center;
font-weight:bold;
}
.calendario_hoje{
font-weight:bold;
}
.calendario_mes_ano{
text-align:center;
font-weight:bold;
color:#666666;
}
.calendario_links{
color:#000000;
display:block;
text-decoration:none;
}
.calendario_links:hover{
text-decoration:none;
background:#999999;
color:#FFFFFF;
}
.calendario_links_hoje{
color:#FF0000;
display:block;
text-decoration:none;
}
.calendario_links_hoje:hover{
text-decoration:none;
background:#F0F0F0;
color:#FFFFFF;
}
a:link {
font-family: monospace;
font-size: 12px;
text-decoration: none;
color: #000000;
}
a:visited {
font-family: monospace;
font-size: 12px;
text-decoration: none;
color: #000000;
}
a:hover {
font-family: monospace;
font-size: 12px;
text-decoration: underline;
color: #000000;
}
a:active {
font-family: monospace;
font-size: 12px;
text-decoration: none;
color: #0000000;
}
************************************************
* calendario.php *
************************************************
class calendario{
var $mes = array(
'01' => 'JANEIRO',
'02' => 'FEVEREIRO',
'03' => 'MARÇO',
'04' => 'ABRIL',
'05' => 'MAIO',
'06' => 'JUNHO',
'07' => 'JULHO',
'08' => 'AGOSTO',
'09' => 'SETEMBRO',
'10' => 'OUTUBRO',
'11' => 'NOVEMBRO',
'12' => 'DEZEMBRO'
);
function mes_anterior($dia,$mes,$ano){
if($mes == 1){
$man = 12;
$aan = $ano - 1;
} else {
$man = $mes - 1;
$aan = $ano;
}
$val = checkdate($man,$dia,$aan);
if($val == 0){
$dia = 1;
}
echo '«';
}
function mes_proximo($dia,$mes,$ano){
if($mes == 12){
$mpr = 1;
$apr = $ano + 1;
} else {
$mpr = $mes + 1;
$apr = $ano;
}
$val = checkdate($mpr,$dia,$apr);
if($val == 0){
$dia = 1;
}
echo '»';
}
function ano_anterior($dia,$mes,$ano){
$aan = $ano - 1;
echo '«';
}
function ano_proximo($dia,$mes,$ano){
$apr = $ano + 1;
echo '»';
}
function cria($data){
$arr = explode("/",$data);
$dia = $arr[0];
$mes = $arr[1];
$ano = $arr[2];
if(($dia == '') OR ($mes = '') OR ($ano = '')){
$data = date("d/m/Y");
$arr = explode("/",$data);
$dia = $arr[0];
$mes = $arr[1];
$ano = $arr[2];
}
$arr = explode("/",$data);
$dia = $arr[0];
$mes = $arr[1];
$ano = $arr[2];
$val = checkdate($mes,$dia,$ano); // Verifica se a data é válida
if($val == 1){
$ver = date('d/m/Y', mktime(0,0,0,$mes,$dia,$ano));
} else {
$ver = date('d/m/Y', mktime(0,0,0,date(m),date(d),date(Y)));
}
$arr = explode("/",$ver);
$dia = $arr[0];
$mes = $arr[1];
$ano = $arr[2];
$ult = date("d", mktime(0,0,0,$mes+1,0,$ano));
$dse = date("w", mktime(0,0,0,$mes,1,$ano));
$tot = $ult+$dse;
if($tot != 0){
$tot = $tot+7-($tot%7);
}
for($i=0;$i<$tot;$i++){
$dat = $i-$dse+1;
if(($i >= $dse) AND ($i < ($dse+$ult))){
$aux[$i] = '
'.$dat.'
|
';
} else {
$aux[$i] = '
|
';
}
if(($i%7) == 0){
$aux[$i] = ''.$aux[$i];
}
if(($i%7) == 6){
$aux[$i] .= '
';
}
}
echo '
';
$this->mes_anterior($dia,$mes,$ano);
echo '
|
'.$this->mes[$mes].' |
';
$this->mes_proximo($dia,$mes,$ano);
echo '
|
';
$this->ano_anterior($dia,$mes,$ano);
echo '
|
'.$ano.' |
';
$this->ano_proximo($dia,$mes,$ano);
echo '
|
D |
S |
T |
Q |
Q |
S |
S |
';
echo implode(' ',$aux);
if(count($aux) == 35){
echo '
|
';
};
echo '
[ Hoje ] |
|
';
}
}
$teste = new calendario;
$teste->cria($_GET["data"]);
?>