The events part doesn’t work yet.
The part I need help first is on the way the days are populated. I use a for loop but I think there might be a better way, getting the first day of the calendar and then probably adding +1 day using strtotime or something like that.
I will continue tweaking it but if you guys have a recommendation please let me know.
Thanks
createMonth($events=array())
{
if(isset($events)&&!is_array($events))
{
exit('<p>Is not array inside createMonth function!</p>');
}
$output = '<p><a href="'.$_SERVER['PHP_SELF'].'?workDate='.$this->_previousMonth.'">Previous Month</a> | <a href="'.$_SERVER['PHP_SELF'].'?workDate='.$this->_nextMonth.'">Next Month</a></p>';
$output .= '<table><caption>'.date('F Y',strtotime($this->_workDate)).'</caption>
<tr>
<th>Sunday</th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
<th>Saturday</th>
</tr>';
for($x=1;$x<7;$x++)
{
$tdDay = '<tr>';
$tdContent = '<tr>';
for($i=1;$i<8;$i++)
{
// place something inside the tdContent td
// $tdContent .= date('m',strtotime($this->_workDate));
// $tdInside = date('Y',strtotime($this->_workDate)).'-'.date('m',strtotime($this->_workDate)).'-'.$this->_currentDate;
// $tdInside = $this->_currentDate;
$tdContent .= '<td ';
// if it's not from this month
if($this->_inThisMonth==0)
{
$tdDay .= '<td class="notThisMonth">'.$this->_currentDate++.'</td>';
$tdContent .= 'class="notThisMonth">';
}
// days from this month
else
{
if( $this->_currentDate == date("j") && date("n",strtotime($this->_workDate)) == date("n") && date("y",strtotime($this->_workDate)) == date("y") )
{
$tdDay .= '<td class="today">'.$this->_currentDate++.'</td>';
$tdContent .= 'class="today">';
}
else
{
$tdDay .= '<td>'.$this->_currentDate++.'</td>';
$tdContent .= '>';
}
}
// close tdContent td
$tdContent .= $tdInside.'</td>';
if( $this->_inThisMonth == 0 && $this->_currentDate > $this->_daysLastMonth )
{
$this->_currentDate = 1;
$this->_inThisMonth = 1;
}
elseif($this->_inThisMonth == 1 && $this->_currentDate > $this->_daysThisMonth )
{
$this->_currentDate = 1;
$this->_inThisMonth = 0;
}
}
$tdDay .= '</tr>';
$tdContent .= '</tr>';
$output .= $tdDay.$tdContent;
}
$output .= '</table>';
return $output;
}