month = $month_int;
$this->year = $year_int;
}
/**
*
* set a Period for a specified item
*
* setting a period for an element means to define
* a fromDate and and a toDate together with the
* item itself. This will store a timeframe associated
* with an item for later usage
*
* @param string item for the timeframe
* @param date fromdate in format yyyymmdd
* @param date todate in format yyyymmdd
*
* @return boolean false if item cannot be saved
* otherwise true
*/
function setPeriod ($item, $fromdate, $todate, $color="#990033")
{
$fyear = substr($fromdate,0,4);
$fmonth = substr($fromdate,4,2);
$fday = substr($fromdate,6,2);
$tyear = substr($todate,0,4);
$tmonth = substr($todate,4,2);
$tday = substr($todate,6,2);
if(mktime(0,0,0, $tmonth, $tday, $tyear) < mktime(0,0,0, $this->month+1,0,$this->year))
$this->day = $tday;
else
{
$dinfo = getdate(mktime(0,0,0, $this->month+1,0,$this->year));
$this->day = $dinfo[mday];
}
$go = 1;
$i = 0;
$z = 0;
while($go==1)
{
// calculates fromdate
// echo date("d/m/Y", mktime(0,0,0, $fmonth, $fday+$i, $fyear)); echo "
";
$datinfo = getdate(mktime(0,0,0, $fmonth, $fday+$i, $fyear));
if($datinfo["mon"]==$this->month
&& $datinfo["year"]==$this->year
&& $datinfo["mday"]<=$this->day)
{
$t = $datinfo["mday"];
$this->items_content[$this->items_count][$t] = "x";
}
if (mktime(0,0,0, $fmonth, $fday+$i, $fyear) >=
mktime(0,0,0, $this->month+1, 0, $this->year)
||
mktime(0,0,0, $fmonth, $fday+$i, $fyear) >=
mktime(0,0,0, $tmonth, $tday, $tyear)) $go = 0
;
$i++;
}
$this->items_content[$this->items_count][0] = "$item;$color";
// increase number of items in two-dimensional array
$this->items_count++;
}
/**
*
* sets the color for empty dayfields
*
* @param string color in hexadecimal (ex. "#336699")
*/
function setEmptyFieldColor ($color)
{
$this->color_emptyfield=$color;
}
/**
*
* sets the color for calendar day fields
*
* @param string color in hexadecimal (ex. "#336699")
*/
function setHeaderFieldColor ($color)
{
$this->color_headerfield=$color;
}
/**
*
* sets a new path for 1pixel (pix.gif) gif needed for the table
* default is set actual script dir + /images
*
* @param string path and name to 1pixel gif
*/
function set1PixelGif ($filepath)
{
$this->image1pix=$filepath;
}
/**
*
* disable selection of new timeframe
*
*/
function diableSelection ()
{
$this->selection=0;
}
/**
*
* return the html code for the matrix
*
* will return the complete html code for the matrix.
* In the calling program you can do some other
* operations on it, because it wont be echoed directly
*
* @return string html code for the matrix
*/
function out ()
{
// get days of desired month (month submitted in constructor)
$in = getdate(mktime(0,0,0, $this->month+1,0,$this->year));
$this->sumdays = $in[mday];
$this->monthname = $in[month];
$this->out_monthyear();
echo "
" . $itemname . " | \n"; // loop through days of desired month for($r=1;$r<$this->sumdays+1;$r++) { if($this->items_content[$z][$r]=="x") $color = $itemcolor; else $color = $this->color_emptyfield; echo "\n"; } echo " |