
Originally Posted by
mattura
Ok, if nobody else does it in the meantime, I might look into this at the weekend. Unfortunately I'm working long hours these days... (on damned complicated c++ code)
c++ is scary!
Fortunately, I have done quite a bit of groundwork here and managed to get a month view created in php - but no dynamic links and no navigation yet...
The calendar page is at http://www.freecrm.x10hosting.com/cr...calendar_m.php
The code so far is
PHP Code:
<?php
session_start();
//set page timezone
if ($_SESSION['MM_UTZ'] == NULL){
$_SESSION['MM_UTZ']="UTC";}
putenv ("TZ=".$_SESSION['MM_UTZ']);
//set page timeformat
if ($_SESSION['MM_UTF'] == NULL){
$_SESSION['MM_UTF']="Y-m-d H:i:s";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/fullpagetemplate.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="EditRegionhead" -->
<title>Welcome to Free CRM</title>
<meta name="Description" content="Free CRM (Customer Relations Management) provides an unlimited fully functional online multi user CRM system." />
<meta name="Keywords" content="CRM, Customer Relations Management, PRM, Contact Management, Contact Database, Online, Opportunity, Tasks, Calendar, To Do, Reports" />
<style type="text/css">
.calday
{
font-family: Arial;
border: 1px solid #006666;
background-color:#E3E9F1;
padding: 2px;
border-collapse: collapse;
empty-cells:show;
}
.caltoday {
font-family: Arial;
color:#FF3300;
border: 3px solid #006666;
background-color:#E3E9F1;
padding: 2px;
border-collapse: collapse;
empty-cells:show;
}
</style>
<?php
class Calendar
{
function generate_calendar($year, $month, $day_func = NULL, $day_heading_length = 3)
{
$first_of_month = mktime (0,0,0, $month, 1, $year);
static $day_headings = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
$maxdays = date('t', $first_of_month); #number of days in the month
$date_info = getdate($first_of_month); #get info about the first day of the month
$month = $date_info['mon'];
$year = $date_info['year'];
$calendar = "<br /><table width='100%' class='datatable'>";
$calendar .= "<tr><td colspan='7' class='databox'>$date_info[month] $year</td></tr>";
$calendar .= "
<tr class='dataheading'>
<td class='databox'>Sun</td>
<td class='databox'>Mon</td>
<td class='databox'>Tue</td>
<td class='databox'>Wed</td>
<td class='databox'>Thu</td>
<td class='databox'>Fri</td>
<td class='databox'>Sat</td>
</tr>";
$calendar .= "<tr>";
$class = "";
$weekday = $date_info['wday']; #weekday (zero based) of the first day of the month
$day = 1; #starting day of the month
#take care of the first "empty" days of the month
if($weekday > 0)
{
$calendar .= "<td colspan='$weekday'> </td>";
} #print the days of the month
while ($day <= $maxdays)
{
if($weekday == 7)
{ #start a new week
$calendar .= "</tr><tr>";
$weekday = 0;
}
$linkDate = mktime (0,0,0, $month, $day, $year);
if((($day<10 AND "0$day"==date('d')) OR ($day>=10 AND "$day"==date('d'))) AND (($month<10 AND "0$month"==date('m')) OR ($month>=10 AND "$month"==date('m'))) AND $year==date('Y'))
{
$class="caltoday";
}
else
{
$d = date('m/d/Y', $linkDate);
$class = "calday";
}
$link = "dates.php?date=$linkDate";
$calendar .= "<td class='$class'>$day</td>";
$day++;
$weekday++;
}
if($weekday != 7)
{
$calendar .= "<td colspan='" . (7 - $weekday) . "'> </td>";
}
return $calendar . "</tr></table>";
}
}
?>
<!-- InstanceEndEditable -->
<link href="../css/page.css" rel="stylesheet" type="text/css" />
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>
<?php include ("../includes/googleanalytics.php");?>
<body class="oneColFixCtr">
<div id="container">
<td>
<?php include ("../includes/header.php");?>
</td>
<div id="mainContent">
<!-- InstanceBeginEditable name="EditRegionmaincontent" -->
<h1>Calendar</h1>
<p>
<?php
$MCal = new Calendar;
echo $MCal -> generate_calendar(date('Y'), date('m'), $day_func = NULL, $day_heading_length = 3);
?>
</p>
<!-- InstanceEndEditable -->
<!-- end #mainContent -->
</div>
<td>
<?php include("../includes/footer.php");?>
</td>
<!-- end #container -->
</div>
</body>
<!-- InstanceEnd --></html>