PHP Classes
elePHPant
Icontem

File: Example_1.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Ruben Crespo  >  Easy Weekly Calendar  >  Example_1.php  >  Download  
File: Example_1.php
Role: Example script
Content type: text/plain
Description: example file
Class: Easy Weekly Calendar
Show calendar of a given week
Author: By
Last change: Fixed the file name
Date: 5 years ago
Size: 3,618 bytes
 

Contents

Class file image Download
<html>
<head>
<title>Example of a weekly schedule</title>
<?
//I don't know the author of the Monthcalendar, but ... Thanks for the Code !! you can find it in http://foros.cristalab.com/formato-de-fecha-en-calendario-t76780
$anoInicial = '1900';
$anoFinal = '2100';
$funcionTratarFecha = 'document.location = "?dia="+dia+"&mes="+mes+"&ano="+ano;';
?><script>
function tratarFecha(dia,mes,ano){
  <?=$funcionTratarFecha?>
}
</script>

<style>
.m1 {
   font-family:MS Sans Serif;
   font-size:8pt
}
a {
   text-decoration:none;
   color:#000000;
}

td {
font-size:0.6em;
}
</style>

</head>

<body>
<!--CALENDARIO-->
<!--I don't know the author of the Monthcalendar, but ... Thanks for the Code !! you can find it in http://foros.cristalab.com/formato-de-fecha-en-calendario-t76780-->
<form>
<table border="0" cellpadding="5" cellspacing="0" bgcolor="#D4D0C8">
  <tr>
    <td width="100%">
<?
$fecha
= getdate(time());
if(isset(
$_GET["dia"]))$dia = $_GET["dia"];
else
$dia = $fecha['mday'];
if(isset(
$_GET["mes"]))$mes = $_GET["mes"];
else
$mes = $fecha['mon'];
if(isset(
$_GET["ano"]))$ano = $_GET["ano"];
else
$ano = $fecha['year'];
$fecha = mktime(0,0,0,$mes,$dia,$ano);
$fechaInicioMes = mktime(0,0,0,$mes,1,$ano);
$fechaInicioMes = date("w",$fechaInicioMes);
?>
<select size="1" name="mes" class="m1" onchange="document.location = '?dia=<?=$dia?>&mes=' + document.forms[0].mes.value + '&ano=<?=$ano?>';">
<?
$meses
= Array ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
for(
$i = 1; $i <= 12; $i++){
  echo
' <option ';
  if(
$mes == $i)echo 'selected ';
  echo
'value="'.$i.'">'.$meses[$i-1]."\n";
}
?>
</select>&nbsp;&nbsp;&nbsp;<select size="1" name="ano" class="m1" onchange="document.location = '?dia=<?=$dia?>&mes=<?=$mes?>&ano=' + document.forms[0].ano.value;">
<?
for ($i = $anoInicial; $i <= $anoFinal; $i++){
  echo
' <option ';
  if(
$ano == $i)echo 'selected ';
  echo
'value="'.$i.'">'.$i."\n";
}
?>
</select><br>
    <font size="1">&nbsp;</font><table border="0" cellpadding="2" cellspacing="0" width="100%" class="m1" bgcolor="#FFFFFF" height="100%">
<?
$diasSem
= Array ('L','M','M','J','V','S','D');
$ultimoDia = date('t',$fecha);
$numMes = 0;
for (
$fila = 0; $fila < 7; $fila++){
  echo
" <tr>\n";
  for (
$coln = 0; $coln < 7; $coln++){
   
$posicion = Array (1,2,3,4,5,6,0);
    echo
' <td width="14%" height="19"';
    if(
$fila == 0)echo ' bgcolor="#808080"';
    if(
$dia-1 == $numMes)echo ' bgcolor="#0A246A"';
    echo
" align=\"center\">\n";
    echo
' ';
    if(
$fila == 0)echo '<font color="#D4D0C8">'.$diasSem[$coln];
    elseif((
$numMes && $numMes < $ultimoDia) || (!$numMes && $posicion[$coln] == $fechaInicioMes)){
      echo
'<a href="#" onclick="tratarFecha('.(++$numMes).','.$mes.','.$ano.')">';
      if(
$dia == $numMes)echo '<font color="#FFFFFF">';
      echo (
$numMes).'</a>';
    }
    echo
"</td>\n";
  }
  echo
" </tr>\n";
}
?>
</table>
    </td>
  </tr>
</table>
</form>
<!--CALENDARIO-->


<h2>Example of a weekly schedule</h2>


<?php

if ($_GET["dia"] && $_GET["mes"] && $_GET["ano"]) {

$dia = $_GET["dia"];
$mes = $_GET["mes"];
$ano = $_GET["ano"];
} else {
$dia = date ("d");
$mes = date ("n");
$ano = date ("Y");
}


//include the WeeklyCalClass and create the object !!
include ("EasyWeeklyCalClass.php");
$calendar = new EasyWeeklyCalClass ($dia, $mes, $ano);
echo
$calendar->showCalendar ();


?>

</body>
</html>