Hello,
I have a perl script that generates a calendar layout something like the following:
----------------------------------October-2009-------------------------
Monday--Tuesday--Wednesday--Thursday--Friday--Saturday--Sunday
------------------------1--------2---------3-------4------40
------------------------------data----data-------data----data
--5--------6--------7----------8--------9--------10------11------41
-data-----data----data--------data----data-------data----data
--12-------13------14----------15------16---------17-----18------42
-data-----data----data--------data----data-------data----data
--19-------20------21----------22------23---------24-----25------43
-data-----data----data--------data----data-------data----data
--26-------27------28----------29------30---------31-------------43
-data-----data----data--------data----data-------data------------
I have been trying for hours (days actually) to add two additional table rows
under each row of data. I will be adding additional code to fetch more data but
each new cell should just print the day value for the cell it is under.
The first week (which doesn't have data in the first three days)should look like:
-----------------------October-2009-------------------------
Monday--Tuesday--Wednesday--Thursday--Friday--Saturday--Sunday
-------------------------------1--------2---------3-------4------40
------------------------------data----data-------data----data
-------------------------------1--------2---------3-------4------40
------------------------------data----data-------data----data
-------------------------------1--------2---------3-------4------40
with the following weeks having data/day numbers where day numbers are not blank.
I have tried inserting a new row in almost every part of the following subs but I just
can't get it to work.
Hopefully there is enough code included below for someone to show me how to do it and
where exactly to put the extra code.
Thanks.
I have a perl script that generates a calendar layout something like the following:
----------------------------------October-2009-------------------------
Monday--Tuesday--Wednesday--Thursday--Friday--Saturday--Sunday
------------------------1--------2---------3-------4------40
------------------------------data----data-------data----data
--5--------6--------7----------8--------9--------10------11------41
-data-----data----data--------data----data-------data----data
--12-------13------14----------15------16---------17-----18------42
-data-----data----data--------data----data-------data----data
--19-------20------21----------22------23---------24-----25------43
-data-----data----data--------data----data-------data----data
--26-------27------28----------29------30---------31-------------43
-data-----data----data--------data----data-------data------------
I have been trying for hours (days actually) to add two additional table rows
under each row of data. I will be adding additional code to fetch more data but
each new cell should just print the day value for the cell it is under.
The first week (which doesn't have data in the first three days)should look like:
-----------------------October-2009-------------------------
Monday--Tuesday--Wednesday--Thursday--Friday--Saturday--Sunday
-------------------------------1--------2---------3-------4------40
------------------------------data----data-------data----data
-------------------------------1--------2---------3-------4------40
------------------------------data----data-------data----data
-------------------------------1--------2---------3-------4------40
with the following weeks having data/day numbers where day numbers are not blank.
I have tried inserting a new row in almost every part of the following subs but I just
can't get it to work.
Hopefully there is enough code included below for someone to show me how to do it and
where exactly to put the extra code.
Thanks.
Code:
sub create {
$requested_calendar=$_[1];
$calendar_year=$_[2];
$calendar_month=$_[3];
my $this = shift;
my ($html, $i, $start, $stop, $title, $daycount, $inThisMonth);
my ($days, $weekNr, $ind, $class, $style, $content, $date);
my ($sec, $min, $hr, $curDay, $curMonth, $curYear, $wday, $yday, $stime) = localtime(time);
$curYear += 1900;
$curMonth += 1;
$this->{size} = ($this->{hFontSize} > $this->{dFontSize}) ? $this->{hFontSize} : $this->{dFontSize};
if($this->{wFontSize} > $this->{size}) { $this->{size} = $this->{wFontSize}; }
if($this->{year} < 1 || $this->{year} > 3999) { $html = '<b>' . $this->{error}[0] . '</b>'; }
elsif($this->{month} < 1 || $this->{month} > 12) { $html = '<b>' . $this->{error}[1] . '</b>'; }
else {
$this->{mDays}[1] = $this->leap_year($this->{year}) ? 29 : 28;
for($i = $days = 0; $i < $this->{month} - 1; $i++) { $days += $this->{mDays}[$i]; }
$start = $this->get_weekday($this->{year}, $days);
$stop = $this->{mDays}[$this->{month}-1];
$html = $this->set_styles();
#cell days border lines table
$html .= '<table border=0 cellspacing=0 cellpadding=0><tr>';
$html .= '<td' . ($this->{borderColor} ? ' bgcolor=' . $this->{borderColor} : '') . '>';
#cell days table
$html .= '<table border=0 cellspacing=1 cellpadding=3>';
#prints the month and year title
$title = $this->{months}[$this->{month}-1] . ' ' . $this->{year};
$html .= $this->table_head($title);
$daycount = 1;
if(($this->{year} == $curYear) && ($this->{month} == $curMonth)) { $inThisMonth = 1; }
else { $inThisMonth = 0; }
if($this->{weekNumbers}) { $weekNr = $this->get_week($this->{year}, $days); }
while($daycount <= $stop) {
$html .= '<tr>';
for($i = $wdays = 0; $i <= 6; $i++) {
$ind = ($i + $this->{offset}) % 7;
if($ind == 0) { $class = 'cssSaturdays'; }
elsif($ind == 1) { $class = 'cssSundays'; }
else { $class = 'cssDays'; }
$style = '';
$date = $this->{month} . '-' . $this->{month} . '-' . $daycount;
#prints blanks for days without numbers
if(($daycount == 1 && $i < $start) || $daycount > $stop) { $content = ' '; }
else {
#Go and get some info based on the table cell date
#determine the cell date
$cell_year=$display_year;
$cell_month=$display_month;
$cell_day=$daycount;
$get_data = get_data($calendar_year,$calendar_month,$cell_day);
$content = "$daycount<br>$get_data";
if($inThisMonth && $daycount == $curDay) {
$style = 'padding:0px;border:3px solid ' . $this->{tdBorderColor} . ';';
}
elsif($this->{year} == 1582 && $this->{month} == 10 && $daycount == 4) { $daycount = 14; }
$daycount++;
$wdays++;
}
$html .= $this->table_cell($content, $class . $cal_ID, $date, $style);
}
if($this->{weekNumbers}) {
if(!$weekNr) {
if($this->{year} == 1) { $content = ' '; }
elsif($this->{year} == 1583) { $content = 52; }
else { $content = $this->get_week($this->{year} - 1, 365); }
}
elsif($this->{month} == 12 && $weekNr >= 52 && $wdays < 4) { $content = 1; }
else { $content = $weekNr; }
$html .= $this->table_cell($content, 'cssWeeks' . $cal_ID);
$weekNr++;
}
$html .= '</tr>';
}
$html .= '</table></td></tr></table>';
}
return $html;
}
sub table_head {
my ($this, $content) = @_;
my ($html, $i, $ind, $wDay);
my $cols = $this->{weekNumbers} ? 8 : 7;
#this prints the month and year title row
$html = '<tr><td colspan=' . $cols . ' class="cssTitle' . $cal_ID . '" align=center><b>' .
$content . '</b></td></tr><tr>';
for($i = 0; $i < int @{$this->{weekdays}}; $i++) {
$ind = ($i + $this->{offset}) % 7;
$wDay = $this->{weekdays}[$ind];
#this prints the day names
$html .= $this->table_cell($wDay, 'cssHeading' . $cal_ID);
}
#if we are printing week numbers, this puts a blank cell at the top of the column
if($this->{weekNumbers}) { $html .= $this->table_cell(' ', 'cssHeading' . $cal_ID); }
$html .= '</tr>';
return $html;
}
sub table_cell {
my ($this, $content, $class, $date, $style) = @_;
my ($size, $html, $link);
$size = _round($this->{size} * 1.5);
$html = '<td align=center width=' . $size . ' class="' . $class . '"';
if($content ne ' ' && $class =~ m/day/i) {
$link = $this->{link};
if($this->{specDays}{$content}) {
if($this->{specDays}{$content}[0]) {
$style .= 'background-color:' . $this->{specDays}{$content}[0] . ';';
}
if($this->{specDays}{$content}[1]) {
$html .= ' title="' . $this->{specDays}{$content}[1] . '"';
}
if($this->{specDays}{$content}[2]) {
$link = $this->{specDays}{$content}[2];
}
}
if($link) {
$html .= ' onMouseOver="this.className=\'cssHilight' . $cal_ID . '\'"';
$html .= ' onMouseOut="this.className=\'' . $class . '\'"';
$html .= ' onClick="document.location.href=\'' . $link . '?date=' . $date . '\'"';
}
}
if($style) { $html .= ' style="' . $style . '"'; }
$html .= '>' . $content . '</td>';
return $html;
}