Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > PHP
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help.

Google
Closed Thread
 
LinkBack Thread Tools Display Modes
Old 07-01-2007, 3:59 PM   #1
Craig Keightley
 
Craig Keightley's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Calender Function - week view help needed

Hi all
I have been using this php calendar class i found on the net and was
wondering if anyone knows how to extend the class to create a week view.

I have included the following code (with a few tweaks by me) below:

cut here
=============================================
<?php require_once('../../Connections/connwsdAdmin.php'); ?>
<?

// PHP Calendar Class Version 1.4 (5th March 2001)
//
// Copyright David Wilkinson 2000 - 2001. All Rights reserved.
//
// This software may be used, modified and distributed freely
// providing this copyright notice remains intact at the head
// of the file.
//
// This software is freeware. The author accepts no liability for
// any loss or damages whatsoever incurred directly or indirectly
// from the use of this script. The author of this software makes
// no claims as to its fitness for any purpose whatsoever. If you
// wish to use this software you should first satisfy yourself that
// it meets your requirements.
//
// URL: http://www.cascade.org.uk/software/php/calendar/
// Email: davidw@cascade.org.uk
class Calendar
{


/*
Constructor for the Calendar class
*/
function Calendar()
{
}


/*
Get the array of strings used to label the days of the week. This
array contains seven
elements, one for each day of the week. The first entry in this
array represents Sunday.
*/
function getDayNames()
{
return $this->dayNames;
}


/*
Set the array of strings used to label the days of the week. This
array must contain seven
elements, one for each day of the week. The first entry in this
array represents Sunday.
*/
function setDayNames($names)
{
$this->dayNames = $names;
}

/*
Get the array of strings used to label the months of the year. This
array contains twelve
elements, one for each month of the year. The first entry in this
array represents January.
*/
function getMonthNames()
{
return $this->monthNames;
}

/*
Set the array of strings used to label the months of the year. This
array must contain twelve
elements, one for each month of the year. The first entry in this
array represents January.
*/
function setMonthNames($names)
{
$this->monthNames = $names;
}



/*
Gets the start day of the week. This is the day that appears in the
first column
of the calendar. Sunday = 0.
*/
function getStartDay()
{
return $this->startDay;
}

/*
Sets the start day of the week. This is the day that appears in the
first column
of the calendar. Sunday = 0.
*/
function setStartDay($day)
{
$this->startDay = $day;
}


/*
Gets the start month of the year. This is the month that appears
first in the year
view. January = 1.
*/
function getStartMonth()
{
return $this->startMonth;
}

/*
Sets the start month of the year. This is the month that appears
first in the year
view. January = 1.
*/
function setStartMonth($month)
{
$this->startMonth = $month;
}


/*
Return the URL to link to in order to display a calendar for a given
month/year.
You must override this method if you want to activate the "forward"
and "back"
feature of the calendar.

Note: If you return an empty string from this function, no
navigation link will
be displayed. This is the default behaviour.

If the calendar is being displayed in "year" view, $month will be
set to zero.
*/
function getCalendarLink($month, $year)
{
return "";
}

/*
Return the URL to link to for a given date.
You must override this method if you want to activate the date
linking
feature of the calendar.

Note: If you return an empty string from this function, no
navigation link will
be displayed. This is the default behaviour.
*/
function getDateLink($day, $month, $year, $selected)
{
return "";
}

/*
Return the HTML for the current month
*/
function getCurrentMonthView()
{
$d = getdate(time());
return $this->getMonthView($d["mon"], $d["year"]);
}


/*
Return the HTML for the current year
*/
function getCurrentYearView()
{
$d = getdate(time());
return $this->getYearView($d["year"]);
}


/*
Return the HTML for a specified month
*/
function getMonthView($month, $year, $selected)
{
return $this->getMonthHTML($month, $year, $selected);
}


/*
Return the HTML for a specified year
*/
function getYearView($year)
{
return $this->getYearHTML($year);
}




/************************************************** *************************
*****

The rest are private methods. No user-servicable parts inside.

You shouldn't need to call any of these functions directly.


************************************************** **************************
*****/


/*
Calculate the number of days in a month, taking into account leap
years.
*/
function getDaysInMonth($month, $year)
{
if ($month < 1 || $month > 12)
{
return 0;
}

$d = $this->daysInMonth[$month - 1];

if ($month == 2)
{
// Check for leap year
// Forget the 4000 rule, I doubt I'll be around then...

if ($year%4 == 0)
{
if ($year%100 == 0)
{
if ($year%400 == 0)
{
$d = 29;
}
}
else
{
$d = 29;
}
}
}

return $d;
}


/*
Generate the HTML for a given month
*/
function getMonthHTML($m, $y, $selected, $showYear = 1)
{
$s = "";

$a = $this->adjustDate($m, $y);
$month = $a[0];
$year = $a[1];

$daysInMonth = $this->getDaysInMonth($month, $year);
$date = getdate(mktime(12, 0, 0, $month, 1, $year));

$first = $date["wday"];
$monthName = $this->monthNames[$month - 1];

$prev = $this->adjustDate($month - 1, $year);
$next = $this->adjustDate($month + 1, $year);

if ($showYear == 1)
{
$prevMonth = $this->getCalendarLink($prev[0], $prev[1]);
$nextMonth = $this->getCalendarLink($next[0], $next[1]);
}
else
{
$prevMonth = "";
$nextMonth = "";
}

$header = $monthName . (($showYear > 0) ? " " . $year : "");

$s .= "<table class=\"calendar\" cellpadding=\"0\" cellspacing=\"0\"
width=\"100%\">\n";
$s .= "<tr>\n";
$s .= "<td align=\"center\" valign=\"top\" class=\"contactcellbg\">" .
(($prevMonth == "") ? "&nbsp;" : "<a href=\"$prevMonth\"><font
face=\"webdings\" color=\"#FFFFFF\">3</font></a>") . "</td>\n";
$s .= "<td align=\"center\" valign=\"top\" class=\"contactcellbg\"
colspan=\"5\">$header</td>\n";
$s .= "<td align=\"center\" valign=\"top\" class=\"contactcellbg\">" .
(($nextMonth == "") ? "&nbsp;" : "<a href=\"$nextMonth\"><font
face=\"webdings\" color=\"#FFFFFF\">4</font></a>") . "</td>\n";
$s .= "</tr>\n";

$s .= "<tr>\n";
$s .= "<td align=\"center\" valign=\"top\"
class=\"calendarHeader\"><img src=\"../../../transparent.gif\" width=\"75\"
height=\"1\"><br>" . $this->dayNames[($this->startDay)%7] . "</td>\n";
$s .= "<td align=\"center\" valign=\"top\"
class=\"calendarHeader\"><img src=\"../../../transparent.gif\" width=\"75\"
height=\"1\"><br>" . $this->dayNames[($this->startDay+1)%7] . "</td>\n";
$s .= "<td align=\"center\" valign=\"top\"
class=\"calendarHeader\"><img src=\"../../../transparent.gif\" width=\"75\"
height=\"1\"><br>" . $this->dayNames[($this->startDay+2)%7] . "</td>\n";
$s .= "<td align=\"center\" valign=\"top\"
class=\"calendarHeader\"><img src=\"../../../transparent.gif\" width=\"75\"
height=\"1\"><br>" . $this->dayNames[($this->startDay+3)%7] . "</td>\n";
$s .= "<td align=\"center\" valign=\"top\"
class=\"calendarHeader\"><img src=\"../../../transparent.gif\" width=\"75\"
height=\"1\"><br>" . $this->dayNames[($this->startDay+4)%7] . "</td>\n";
$s .= "<td align=\"center\" valign=\"top\"
class=\"calendarHeader\"><img src=\"../../../transparent.gif\" width=\"75\"
height=\"1\"><br>" . $this->dayNames[($this->startDay+5)%7] . "</td>\n";
$s .= "<td align=\"center\" valign=\"top\"
class=\"calendarHeader\"><img src=\"../../../transparent.gif\" width=\"75\"
height=\"1\"><br>" . $this->dayNames[($this->startDay+6)%7] . "</td>\n";
$s .= "</tr>\n";

// We need to work out what date to start at so that the first appears
in the correct column
$d = $this->startDay + 1 - $first;
while ($d > 1)
{
$d -= 7;
}

// Make sure we know when today is, so that we can use a different
CSS style
$today = getdate(time());

while ($d <= $daysInMonth)
{
$s .= "<tr>\n";
for ($i = 0; $i < 7; $i++)

{
if(($year == $today["year"] && $month == $today["mon"] && $d ==
$today["mday"]) && ($d == $selected)){
$class = "calendarTodaySelect";
} elseif ($d == $selected){
$class = "calendarSelect";
} elseif ($year == $today["year"] && $month == $today["mon"] && $d ==
$today["mday"]){
$class = "calendarToday";
} elseif (!($selected)){
$class = "calendarHeader";
} else {
$class = "calendarHeader";
}
$dateToday = $year."-".$month."-".$d;
//check for holidays, if yes, add a new row with the bgcolour set to the
employee
global $database_connwsdAdmin, $connwsdAdmin;
mysql_select_db($database_connwsdAdmin, $connwsdAdmin);


$s .= "<td class=\"$class\" valign=\"top\"><table width=\"100%\"
cellpadding=\"0\" cellspacing=\"0\">";

$hols = mysql_query("SELECT tblUsers.shortName, tblUsers.colour FROM
tblHolidays, tblUsers WHERE (tblHolidays.hStart <= '".$dateToday."' AND
tblHolidays.hEnd >= '".$dateToday."') AND tblUsers.userID =
tblHolidays.empRef");
$row_hols = mysql_fetch_assoc($hols);
$totalRows_hols = mysql_num_rows($hols);
if($totalRows_hols > 0) {
do {
if($row_hols['colour'] == "#000000"){
$col = "#FFFFFF";
} else {
$col = "#000000";
}
if($d>0){
$s .= "<tr><td bgcolor=\"".$row_hols['colour']."\"valign=\"top\"
align=center><font size=1 color=\"".$col."\"><b>".$row_hols['shortName']." -
Holiday</b></font></td></tr>";
}
} while ($row_hols = mysql_fetch_assoc($hols));
}
$s .= "<tr><td>";
if ($d > 0 && $d <= $daysInMonth)
{
$link = $this->getDateLink($d, $month, $year, $selected);
$dayLink = $this->getDayLink($d, $month, $year);
$taskLink = $this->getTaskLink($d, $month, $year);
$selectedDay = $selected;


global $database_connwsdAdmin, $connwsdAdmin;
mysql_select_db($database_connwsdAdmin, $connwsdAdmin);
$result = mysql_query("SELECT * FROM tblAppts, tblUsers WHERE
tblUsers.userID = tblAppts.empRef and apptDate = '".$dateToday."'");
$row_result = mysql_fetch_assoc($result);
$totalRows_result = mysql_num_rows($result);

$numRows = $row[0];
$t = "<font size=\"1\">";
if($row_result['apptTitle']){
do {

$t .= "<font color=\"".$row_result['colour'] ."\" face=\"webdings\"
title=\"".$row_result['userName']."\">< </font>" .
$row_result['apptTitle']."<br>";
} while ($row_result = mysql_fetch_assoc($result));
}
$s .= (($link == "") ? $d : "<a href=\"$link\"
onClick=\"javascript:todoPage('$taskLink')\"><div
align=\"right\">$d</div></a>$t");
}
else
{
$s .= "&nbsp;";
}
$s .= "</td></tr></table>\n";
$d++;
}
$s .= "</tr>\n";
}

$s .= "</table>\n";

return $s;
}


/*
Generate the HTML for a given year
*/
function getYearHTML($year)
{
$s = "";
$prev = $this->getCalendarLink(0, $year - 1);
$next = $this->getCalendarLink(0, $year + 1);

$s .= "<table class=\"calendar\" border=\"0\">\n";
$s .= "<tr>";
$s .= "<td align=\"center\" valign=\"top\" align=\"left\">" . (($prev
== "") ? "&nbsp;" : "<a href=\"$prev\">&lt;&lt;</a>") . "</td>\n";
$s .= "<td class=\"calendarHeader\" valign=\"top\"
align=\"center\">" . (($this->startMonth > 1) ? $year . " - " . ($year + 1)
: $year) ."</td>\n";
$s .= "<td align=\"center\" valign=\"top\" align=\"right\">" . (($next
== "") ? "&nbsp;" : "<a href=\"$next\">&gt;&gt;</a>") . "</td>\n";
$s .= "</tr>\n";
$s .= "<tr>";
$s .= "<td class=\"calendar\" valign=\"top\">" .
$this->getMonthHTML(0 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "<td class=\"calendar\" valign=\"top\">" .
$this->getMonthHTML(1 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "<td class=\"calendar\" valign=\"top\">" .
$this->getMonthHTML(2 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "</tr>\n";
$s .= "<tr>\n";
$s .= "<td class=\"calendar\" valign=\"top\">" .
$this->getMonthHTML(3 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "<td class=\"calendar\" valign=\"top\">" .
$this->getMonthHTML(4 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "<td class=\"calendar\" valign=\"top\">" .
$this->getMonthHTML(5 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "</tr>\n";
$s .= "<tr>\n";
$s .= "<td class=\"calendar\" valign=\"top\">" .
$this->getMonthHTML(6 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "<td class=\"calendar\" valign=\"top\">" .
$this->getMonthHTML(7 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "<td class=\"calendar\" valign=\"top\">" .
$this->getMonthHTML(8 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "</tr>\n";
$s .= "<tr>\n";
$s .= "<td class=\"calendar\" valign=\"top\">" .
$this->getMonthHTML(9 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "<td class=\"calendar\" valign=\"top\">" .
$this->getMonthHTML(10 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "<td class=\"calendar\" valign=\"top\">" .
$this->getMonthHTML(11 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "</tr>\n";
$s .= "</table>\n";

return $s;
}

/*
Adjust dates to allow months > 12 and < 0. Just adjust the years
appropriately.
e.g. Month 14 of the year 2001 is actually month 2 of year 2002.
*/
function adjustDate($month, $year)
{
$a = array();
$a[0] = $month;
$a[1] = $year;

while ($a[0] > 12)
{
$a[0] -= 12;
$a[1]++;
}

while ($a[0] <= 0)
{
$a[0] += 12;
$a[1]--;
}

return $a;
}

/*
The start day of the week. This is the day that appears in the first
column
of the calendar. Sunday = 0.
*/
var $startDay = 0;

/*
The start month of the year. This is the month that appears in the
first slot
of the calendar in the year view. January = 1.
*/
var $startMonth = 1;

/*
The labels to display for the days of the week. The first entry in
this array
represents Sunday.
*/
var $dayNames = array("<font color=#ff0000>Sunday</font>", "Monday",
"Tuesday", "Wednesday", "Thursday", "Friday", "<font
color=#ff0000>Saturday</font>");

/*
The labels to display for the months of the year. The first entry in
this array
represents January.
*/
var $monthNames = array("January", "February", "March", "April", "May",
"June",
"July", "August", "September", "October",
"November", "December");


/*
The number of days in each month. You're unlikely to want to change
this...
The first entry in this array represents January.
*/
var $daysInMonth = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,
31);

}
class MyCalendar extends Calendar
{
function getCalendarLink($month, $year)
{
// Redisplay the current page, but with some parameters
// to set the new month and year
$s = getenv('SCRIPT_NAME');
return "$s?month=$month&year=$year";
}
}

class LinkCalendar extends Calendar
{
function getCalendarLink($month, $year)
{
$s = getenv('SCRIPT_NAME');
return "$s?month=$month&year=$year";
}
function getDateLink($day, $month, $year, $selected)
{
global $link, $selectTemp;
//$dir = $link . "/" . getDirName($day, $month, $year);
$s = getenv('SCRIPT_NAME');
$selectTemp = $day;
return
"$s?day=$day&month=$month&year=$year&selected=$sel ectTemp";
}
function getDayLink($day, $month, $year)
{
global $link;
//$dir = $link . "/" . getDirName($day, $month, $year);
$s = getenv('SCRIPT_NAME');
return "day.php?day=$day&month=$month&year=$year";
}
function getTaskLink($day, $month, $year)
{
global $link;
//$dir = $link . "/" . getDirName($day, $month, $year);
$s = getenv('SCRIPT_NAME');
return "todo.php?day=$day&month=$month&year=$year";
}

}

?>
<?
// If no month/year set, use current month/year

$d = getdate(time());

if ($month == "")
{
$month = $d["mon"];
}

if ($year == "")
{
$year = $d["year"];
}
//$selected = $d["mon"];
$cal = new LinkCalendar;

?>
==============================================
end cut



 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Advertisements
Old 07-01-2007, 4:00 PM   #2
Warstar
 
Warstar's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Calender Function - week view help needed

To say the week code u can use:
date('W',(mktime(0,0,0,$month,$day,$year)))

for the rest i dunno how to do it in this code i could give u a code
with comments that generates a calender with weeks beside it.
but is is not in a class just 2 functions

On Thu, 31 Jul 2003 12:16:06 +0100, "Craig Keightley"
<craig@sitedesign.net> wrote:

>Hi all
>I have been using this php calendar class i found on the net and was
>wondering if anyone knows how to extend the class to create a week view.
>
>I have included the following code (with a few tweaks by me) below:
>
>cut here
>=============================================
><?php require_once('../../Connections/connwsdAdmin.php'); ?>
><?
>
>// PHP Calendar Class Version 1.4 (5th March 2001)
>//
>// Copyright David Wilkinson 2000 - 2001. All Rights reserved.
>//
>// This software may be used, modified and distributed freely
>// providing this copyright notice remains intact at the head
>// of the file.
>//
>// This software is freeware. The author accepts no liability for
>// any loss or damages whatsoever incurred directly or indirectly
>// from the use of this script. The author of this software makes
>// no claims as to its fitness for any purpose whatsoever. If you
>// wish to use this software you should first satisfy yourself that
>// it meets your requirements.
>//
>// URL: http://www.cascade.org.uk/software/php/calendar/
>// Email: davidw@cascade.org.uk
>class Calendar
>{
>
>
> /*
> Constructor for the Calendar class
> */
> function Calendar()
> {
> }
>
>
> /*
> Get the array of strings used to label the days of the week. This
>array contains seven
> elements, one for each day of the week. The first entry in this
>array represents Sunday.
> */
> function getDayNames()
> {
> return $this->dayNames;
> }
>
>
> /*
> Set the array of strings used to label the days of the week. This
>array must contain seven
> elements, one for each day of the week. The first entry in this
>array represents Sunday.
> */
> function setDayNames($names)
> {
> $this->dayNames = $names;
> }
>
> /*
> Get the array of strings used to label the months of the year. This
>array contains twelve
> elements, one for each month of the year. The first entry in this
>array represents January.
> */
> function getMonthNames()
> {
> return $this->monthNames;
> }
>
> /*
> Set the array of strings used to label the months of the year. This
>array must contain twelve
> elements, one for each month of the year. The first entry in this
>array represents January.
> */
> function setMonthNames($names)
> {
> $this->monthNames = $names;
> }
>
>
>
> /*
> Gets the start day of the week. This is the day that appears in the
>first column
> of the calendar. Sunday = 0.
> */
> function getStartDay()
> {
> return $this->startDay;
> }
>
> /*
> Sets the start day of the week. This is the day that appears in the
>first column
> of the calendar. Sunday = 0.
> */
> function setStartDay($day)
> {
> $this->startDay = $day;
> }
>
>
> /*
> Gets the start month of the year. This is the month that appears
>first in the year
> view. January = 1.
> */
> function getStartMonth()
> {
> return $this->startMonth;
> }
>
> /*
> Sets the start month of the year. This is the month that appears
>first in the year
> view. January = 1.
> */
> function setStartMonth($month)
> {
> $this->startMonth = $month;
> }
>
>
> /*
> Return the URL to link to in order to display a calendar for a given
>month/year.
> You must override this method if you want to activate the "forward"
>and "back"
> feature of the calendar.
>
> Note: If you return an empty string from this function, no
>navigation link will
> be displayed. This is the default behaviour.
>
> If the calendar is being displayed in "year" view, $month will be
>set to zero.
> */
> function getCalendarLink($month, $year)
> {
> return "";
> }
>
> /*
> Return the URL to link to for a given date.
> You must override this method if you want to activate the date
>linking
> feature of the calendar.
>
> Note: If you return an empty string from this function, no
>navigation link will
> be displayed. This is the default behaviour.
> */
> function getDateLink($day, $month, $year, $selected)
> {
> return "";
> }
>
> /*
> Return the HTML for the current month
> */
> function getCurrentMonthView()
> {
> $d = getdate(time());
> return $this->getMonthView($d["mon"], $d["year"]);
> }
>
>
> /*
> Return the HTML for the current year
> */
> function getCurrentYearView()
> {
> $d = getdate(time());
> return $this->getYearView($d["year"]);
> }
>
>
> /*
> Return the HTML for a specified month
> */
> function getMonthView($month, $year, $selected)
> {
> return $this->getMonthHTML($month, $year, $selected);
> }
>
>
> /*
> Return the HTML for a specified year
> */
> function getYearView($year)
> {
> return $this->getYearHTML($year);
> }
>
>
>
>
>/************************************************** *************************
>*****
>
> The rest are private methods. No user-servicable parts inside.
>
> You shouldn't need to call any of these functions directly.
>
>
>************************************************* ***************************
>*****/
>
>
> /*
> Calculate the number of days in a month, taking into account leap
>years.
> */
> function getDaysInMonth($month, $year)
> {
> if ($month < 1 || $month > 12)
> {
> return 0;
> }
>
> $d = $this->daysInMonth[$month - 1];
>
> if ($month == 2)
> {
> // Check for leap year
> // Forget the 4000 rule, I doubt I'll be around then...
>
> if ($year%4 == 0)
> {
> if ($year%100 == 0)
> {
> if ($year%400 == 0)
> {
> $d = 29;
> }
> }
> else
> {
> $d = 29;
> }
> }
> }
>
> return $d;
> }
>
>
> /*
> Generate the HTML for a given month
> */
> function getMonthHTML($m, $y, $selected, $showYear = 1)
> {
> $s = "";
>
> $a = $this->adjustDate($m, $y);
> $month = $a[0];
> $year = $a[1];
>
> $daysInMonth = $this->getDaysInMonth($month, $year);
> $date = getdate(mktime(12, 0, 0, $month, 1, $year));
>
> $first = $date["wday"];
> $monthName = $this->monthNames[$month - 1];
>
> $prev = $this->adjustDate($month - 1, $year);
> $next = $this->adjustDate($month + 1, $year);
>
> if ($showYear == 1)
> {
> $prevMonth = $this->getCalendarLink($prev[0], $prev[1]);
> $nextMonth = $this->getCalendarLink($next[0], $next[1]);
> }
> else
> {
> $prevMonth = "";
> $nextMonth = "";
> }
>
> $header = $monthName . (($showYear > 0) ? " " . $year : "");
>
> $s .= "<table class=\"calendar\" cellpadding=\"0\" cellspacing=\"0\"
>width=\"100%\">\n";
> $s .= "<tr>\n";
> $s .= "<td align=\"center\" valign=\"top\" class=\"contactcellbg\">" .
>(($prevMonth == "") ? "&nbsp;" : "<a href=\"$prevMonth\"><font
>face=\"webdings\" color=\"#FFFFFF\">3</font></a>") . "</td>\n";
> $s .= "<td align=\"center\" valign=\"top\" class=\"contactcellbg\"
>colspan=\"5\">$header</td>\n";
> $s .= "<td align=\"center\" valign=\"top\" class=\"contactcellbg\">" .
>(($nextMonth == "") ? "&nbsp;" : "<a href=\"$nextMonth\"><font
>face=\"webdings\" color=\"#FFFFFF\">4</font></a>") . "</td>\n";
> $s .= "</tr>\n";
>
> $s .= "<tr>\n";
> $s .= "<td align=\"center\" valign=\"top\"
>class=\"calendarHeader\"><img src=\"../../../transparent.gif\" width=\"75\"
>height=\"1\"><br>" . $this->dayNames[($this->startDay)%7] . "</td>\n";
> $s .= "<td align=\"center\" valign=\"top\"
>class=\"calendarHeader\"><img src=\"../../../transparent.gif\" width=\"75\"
>height=\"1\"><br>" . $this->dayNames[($this->startDay+1)%7] . "</td>\n";
> $s .= "<td align=\"center\" valign=\"top\"
>class=\"calendarHeader\"><img src=\"../../../transparent.gif\" width=\"75\"
>height=\"1\"><br>" . $this->dayNames[($this->startDay+2)%7] . "</td>\n";
> $s .= "<td align=\"center\" valign=\"top\"
>class=\"calendarHeader\"><img src=\"../../../transparent.gif\" width=\"75\"
>height=\"1\"><br>" . $this->dayNames[($this->startDay+3)%7] . "</td>\n";
> $s .= "<td align=\"center\" valign=\"top\"
>class=\"calendarHeader\"><img src=\"../../../transparent.gif\" width=\"75\"
>height=\"1\"><br>" . $this->dayNames[($this->startDay+4)%7] . "</td>\n";
> $s .= "<td align=\"center\" valign=\"top\"
>class=\"calendarHeader\"><img src=\"../../../transparent.gif\" width=\"75\"
>height=\"1\"><br>" . $this->dayNames[($this->startDay+5)%7] . "</td>\n";
> $s .= "<td align=\"center\" valign=\"top\"
>class=\"calendarHeader\"><img src=\"../../../transparent.gif\" width=\"75\"
>height=\"1\"><br>" . $this->dayNames[($this->startDay+6)%7] . "</td>\n";
> $s .= "</tr>\n";
>
> // We need to work out what date to start at so that the first appears
>in the correct column
> $d = $this->startDay + 1 - $first;
> while ($d > 1)
> {
> $d -= 7;
> }
>
> // Make sure we know when today is, so that we can use a different
>CSS style
> $today = getdate(time());
>
> while ($d <= $daysInMonth)
> {
> $s .= "<tr>\n";
> for ($i = 0; $i < 7; $i++)
>
> {
> if(($year == $today["year"] && $month == $today["mon"] && $d ==
>$today["mday"]) && ($d == $selected)){
> $class = "calendarTodaySelect";
> } elseif ($d == $selected){
> $class = "calendarSelect";
> } elseif ($year == $today["year"] && $month == $today["mon"] && $d ==
>$today["mday"]){
> $class = "calendarToday";
> } elseif (!($selected)){
> $class = "calendarHeader";
> } else {
> $class = "calendarHeader";
> }
> $dateToday = $year."-".$month."-".$d;
> //check for holidays, if yes, add a new row with the bgcolour set to the
>employee
> global $database_connwsdAdmin, $connwsdAdmin;
> mysql_select_db($database_connwsdAdmin, $connwsdAdmin);
>
>
> $s .= "<td class=\"$class\" valign=\"top\"><table width=\"100%\"
>cellpadding=\"0\" cellspacing=\"0\">";
>
> $hols = mysql_query("SELECT tblUsers.shortName, tblUsers.colour FROM
>tblHolidays, tblUsers WHERE (tblHolidays.hStart <= '".$dateToday."' AND
>tblHolidays.hEnd >= '".$dateToday."') AND tblUsers.userID =
>tblHolidays.empRef");
> $row_hols = mysql_fetch_assoc($hols);
> $totalRows_hols = mysql_num_rows($hols);
> if($totalRows_hols > 0) {
> do {
> if($row_hols['colour'] == "#000000"){
> $col = "#FFFFFF";
> } else {
> $col = "#000000";
> }
> if($d>0){
> $s .= "<tr><td bgcolor=\"".$row_hols['colour']."\"valign=\"top\"
>align=center><font size=1 color=\"".$col."\"><b>".$row_hols['shortName']." -
>Holiday</b></font></td></tr>";
> }
> } while ($row_hols = mysql_fetch_assoc($hols));
> }
> $s .= "<tr><td>";
> if ($d > 0 && $d <= $daysInMonth)
> {
> $link = $this->getDateLink($d, $month, $year, $selected);
> $dayLink = $this->getDayLink($d, $month, $year);
> $taskLink = $this->getTaskLink($d, $month, $year);
> $selectedDay = $selected;
>
>
> global $database_connwsdAdmin, $connwsdAdmin;
> mysql_select_db($database_connwsdAdmin, $connwsdAdmin);
> $result = mysql_query("SELECT * FROM tblAppts, tblUsers WHERE
>tblUsers.userID = tblAppts.empRef and apptDate = '".$dateToday."'");
>$row_result = mysql_fetch_assoc($result);
>$totalRows_result = mysql_num_rows($result);
>
> $numRows = $row[0];
> $t = "<font size=\"1\">";
> if($row_result['apptTitle']){
> do {
>
> $t .= "<font color=\"".$row_result['colour'] ."\" face=\"webdings\"
>title=\"".$row_result['userName']."\">< </font>" .
>$row_result['apptTitle']."<br>";
> } while ($row_result = mysql_fetch_assoc($result));
> }
> $s .= (($link == "") ? $d : "<a href=\"$link\"
>onClick=\"javascript:todoPage('$taskLink')\"><div
>align=\"right\">$d</div></a>$t");
> }
> else
> {
> $s .= "&nbsp;";
> }
> $s .= "</td></tr></table>\n";
> $d++;
> }
> $s .= "</tr>\n";
> }
>
> $s .= "</table>\n";
>
> return $s;
> }
>
>
> /*
> Generate the HTML for a given year
> */
> function getYearHTML($year)
> {
> $s = "";
> $prev = $this->getCalendarLink(0, $year - 1);
> $next = $this->getCalendarLink(0, $year + 1);
>
> $s .= "<table class=\"calendar\" border=\"0\">\n";
> $s .= "<tr>";
> $s .= "<td align=\"center\" valign=\"top\" align=\"left\">" . (($prev
>== "") ? "&nbsp;" : "<a href=\"$prev\">&lt;&lt;</a>") . "</td>\n";
> $s .= "<td class=\"calendarHeader\" valign=\"top\"
>align=\"center\">" . (($this->startMonth > 1) ? $year . " - " . ($year + 1)
>: $year) ."</td>\n";
> $s .= "<td align=\"center\" valign=\"top\" align=\"right\">" . (($next
>== "") ? "&nbsp;" : "<a href=\"$next\">&gt;&gt;</a>") . "</td>\n";
> $s .= "</tr>\n";
> $s .= "<tr>";
> $s .= "<td class=\"calendar\" valign=\"top\">" .
>$this->getMonthHTML(0 + $this->startMonth, $year, 0) ."</td>\n";
> $s .= "<td class=\"calendar\" valign=\"top\">" .
>$this->getMonthHTML(1 + $this->startMonth, $year, 0) ."</td>\n";
> $s .= "<td class=\"calendar\" valign=\"top\">" .
>$this->getMonthHTML(2 + $this->startMonth, $year, 0) ."</td>\n";
> $s .= "</tr>\n";
> $s .= "<tr>\n";
> $s .= "<td class=\"calendar\" valign=\"top\">" .
>$this->getMonthHTML(3 + $this->startMonth, $year, 0) ."</td>\n";
> $s .= "<td class=\"calendar\" valign=\"top\">" .
>$this->getMonthHTML(4 + $this->startMonth, $year, 0) ."</td>\n";
> $s .= "<td class=\"calendar\" valign=\"top\">" .
>$this->getMonthHTML(5 + $this->startMonth, $year, 0) ."</td>\n";
> $s .= "</tr>\n";
> $s .= "<tr>\n";
> $s .= "<td class=\"calendar\" valign=\"top\">" .
>$this->getMonthHTML(6 + $this->startMonth, $year, 0) ."</td>\n";
> $s .= "<td class=\"calendar\" valign=\"top\">" .
>$this->getMonthHTML(7 + $this->startMonth, $year, 0) ."</td>\n";
> $s .= "<td class=\"calendar\" valign=\"top\">" .
>$this->getMonthHTML(8 + $this->startMonth, $year, 0) ."</td>\n";
> $s .= "</tr>\n";
> $s .= "<tr>\n";
> $s .= "<td class=\"calendar\" valign=\"top\">" .
>$this->getMonthHTML(9 + $this->startMonth, $year, 0) ."</td>\n";
> $s .= "<td class=\"calendar\" valign=\"top\">" .
>$this->getMonthHTML(10 + $this->startMonth, $year, 0) ."</td>\n";
> $s .= "<td class=\"calendar\" valign=\"top\">" .
>$this->getMonthHTML(11 + $this->startMonth, $year, 0) ."</td>\n";
> $s .= "</tr>\n";
> $s .= "</table>\n";
>
> return $s;
> }
>
> /*
> Adjust dates to allow months > 12 and < 0. Just adjust the years
>appropriately.
> e.g. Month 14 of the year 2001 is actually month 2 of year 2002.
> */
> function adjustDate($month, $year)
> {
> $a = array();
> $a[0] = $month;
> $a[1] = $year;
>
> while ($a[0] > 12)
> {
> $a[0] -= 12;
> $a[1]++;
> }
>
> while ($a[0] <= 0)
> {
> $a[0] += 12;
> $a[1]--;
> }
>
> return $a;
> }
>
> /*
> The start day of the week. This is the day that appears in the first
>column
> of the calendar. Sunday = 0.
> */
> var $startDay = 0;
>
> /*
> The start month of the year. This is the month that appears in the
>first slot
> of the calendar in the year view. January = 1.
> */
> var $startMonth = 1;
>
> /*
> The labels to display for the days of the week. The first entry in
>this array
> represents Sunday.
> */
> var $dayNames = array("<font color=#ff0000>Sunday</font>", "Monday",
>"Tuesday", "Wednesday", "Thursday", "Friday", "<font
>color=#ff0000>Saturday</font>");
>
> /*
> The labels to display for the months of the year. The first entry in
>this array
> represents January.
> */
> var $monthNames = array("January", "February", "March", "April", "May",
>"June",
> "July", "August", "September", "October",
>"November", "December");
>
>
> /*
> The number of days in each month. You're unlikely to want to change
>this...
> The first entry in this array represents January.
> */
> var $daysInMonth = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,
>31);
>
>}
>class MyCalendar extends Calendar
>{
> function getCalendarLink($month, $year)
> {
> // Redisplay the current page, but with some parameters
> // to set the new month and year
> $s = getenv('SCRIPT_NAME');
> return "$s?month=$month&year=$year";
> }
>}
>
>class LinkCalendar extends Calendar
>{
> function getCalendarLink($month, $year)
> {
> $s = getenv('SCRIPT_NAME');
> return "$s?month=$month&year=$year";
> }
> function getDateLink($day, $month, $year, $selected)
> {
> global $link, $selectTemp;
> //$dir = $link . "/" . getDirName($day, $month, $year);
> $s = getenv('SCRIPT_NAME');
> $selectTemp = $day;
> return
>"$s?day=$day&month=$month&year=$year&selected=$se lectTemp";
> }
> function getDayLink($day, $month, $year)
> {
> global $link;
> //$dir = $link . "/" . getDirName($day, $month, $year);
> $s = getenv('SCRIPT_NAME');
> return "day.php?day=$day&month=$month&year=$year";
> }
> function getTaskLink($day, $month, $year)
> {
> global $link;
> //$dir = $link . "/" . getDirName($day, $month, $year);
> $s = getenv('SCRIPT_NAME');
> return "todo.php?day=$day&month=$month&year=$year";
> }
>
>}
>
>?>
><?
>// If no month/year set, use current month/year
>
>$d = getdate(time());
>
>if ($month == "")
>{
> $month = $d["mon"];
>}
>
>if ($year == "")
>{
> $year = $d["year"];
>}
>//$selected = $d["mon"];
>$cal = new LinkCalendar;
>
>?>
>==============================================
>end cut
>
>


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 4:11 PM   #3
Warstar
 
Warstar's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Calender Function - week view help needed

Ok here we go (sorry some bad comments don't have anytime @ the moment
to make them english and i know i should hope this helps):
<?php
#Code was made By Warnar Boekkooi Contact me @ warstar-web@gmx.net
//Little lang. stuff
$L_Words[1] = "Monday";
$L_Words[2] = "Tuesday";
$L_Words[3] = "Wednesday";
$L_Words[4] = "Thursday";
$L_Words[5] = "Friday";
$L_Words[6] = "Saturday";
$L_Words[7] = "Sunday";
/* Calender functie's */
/* hier staan alle functie's die met de calender te maken hebben */

/* main calender functie */
function Calender_main($jaar,$maand)
{
global $L_Words; //laad globale variabelen in
$date_now = getdate(); //maak van var. $date_now alle info over
vandaag
if((!isset($jaar))||(!isset($maand)))//als de maand niet van te
voren is aangegeven dan zet maand,jaar naar de maand,jaar van Nu.
{
$maand = $date_now['mon'];
$jaar = $date_now['year'];
}
if($maand == 13)//als maand 13 is dan maak je jaar + 1 en maand
word 1
{
$jaar++;
$maand = 1;
}
if($maand == 0)//als maand 0 is dan maak je jaar - 1 en maand word
12
{
$jaar--;
$maand = 12;
}
//Maak een var. die de dag van week weet(0 (for Sunday) through 6
(for Saturday)) zo dat we deze later kunnen gebruiken
$dagWeek = getdate(mktime(0,0,0,$maand,1,$jaar));
$maandNaam = $dagWeek['month']; //naam van de maand die er wordt
laten zien
$dagWeek = $dagWeek['wday'];
//maake var. voor kijken of dit eerste keer is dat loop loopt
$firstTimeLoop = true;
//var. eerstedag maand = 1 altijd, var. laastedag maand berekend
met functie laastedag
$maandEerstDag = 1;
$maandLaasteDag = Calender_laastedag($jaar,$maand);
//start tabel voor maand(next,back), Calender, Weeken
$output .= "<table border='1'><tr>";
$output .= "<td><table width='100%'><tr><td align='left'><a
href='".$PHP_SELF."?maand=".($maand-1)."&jaar=".$jaar."'><-</a></td><td
align='center'>".$maandNaam." ".$jaar."</td><td align='right'><a
href='".$PHP_SELF."?maand=".($maand+1)."&jaar=".$j aar."'>-></a></td></tr></table></td></tr>";
//start tabel voor weken
$outputWeek = "<table border='1'
width='100%'><tr><td>Weeks</td></tr>"; #bijwerken lang
//start tabel voor de calender en zet de namen van de dagen
$output .= "<tr><td><table width='5%' border='1'><tr>";
for($i = 1; $i <= '7'; $i++)
{
$output .= "<td>".$L_Words[$i]."</td>";
}
$output .= "</tr>";
//maak een loop die alle datums van de maand in een tabel print in
var. $output
while ($maandEerstDag <= $maandLaasteDag)
{
//kijk of dit de eerste keer is dat loop loopt zo ja zoek dag
op van de eerste dag
if($firstTimeLoop)
{
$output .= "<tr>";
//echo $maandEerstDag;
$outputWeek .= Calender_Week($maand,$maandEerstDag,$jaar);
if($dagWeek == "0")
{
//$outputWeek .=
Calender_Week($maand,$maandEerstDag,$jaar);
for($i=1; $i<=6 ; $i++)
{
$output .= "<td>&nbsp;</td>";
}
} else
{
for($i=1; $i<$dagWeek ; $i++)
{
$output .= "<td>&nbsp;</td>";
}
}
$firstTimeLoop = false;
} else {
//Als de weekdag 1 is (Maandag) maak dan een nieuwe row in
de table
if($dagWeek == 1)
{
$output .= "<tr>";
//echo $maandEerstDag;
$outputWeek .=
Calender_Week($maand,$maandEerstDag,$jaar);
}
}

//Print datum in tabel
$output .= "<td align='right'>".$maandEerstDag."</td>";

//Als de weekdag 0 is (zondag) maak dan een sluit row in de
table
if($dagWeek == 0)
{
$output .= "</tr>";
}
$maandEerstDag++; //1 dag er bij op want we zijn 1 dag verder
$dagWeek++; //1 dag er bij op want we zijn 1 dag verder
$dagWeek = $dagWeek % 7;
}
//$outputWeek .= Calender_Week($maand,($maandEerstDag-1),$jaar);
$outputWeek .= "</table>"; //sluit tabel week
$output .= "</table></td>"; //sluit tabel van calender
$output .= "<td>".$outputWeek."</td></tr></table>";
return($output);//return resultaat van de functie
}
/* End main calender functie */

/* functie laastdag(maand) */
function Calender_laastedag($jaar,$maand)
{
$dag = "28"; //dit is de korste dag mogelijk in een maand
$maand_tmp = $maand; //maak een tijdelijke maand aan die later
word gebruikt
while( $maand == $maand_tmp )//zolang maand en tijdelijke maand
gelijk zijn loop uit voeren
{
$dag++;//dag met 1 verhogen
$date_tmp = getdate(mktime(0,0,0,$maand,$dag,$year));//maak
een datum die zegt welke dag maand het wordt met de dag
$maand_tmp = $date_tmp['mon'];//maak gemaakte maand de
tijdelijke maand
}
$dag--;//haal bij dag 1 af
return($dag);//return resultaat van de functie
}
/* End functie laastdag(maand) */

/* functie week(berekener) */
function Calender_Week($maand,$dag,$jaar)
{
$output = "<tr><td align='right'>".
date('W',(mktime(0,0,0,$maand,$dag,$jaar)))."</td></tr>";
return $output;//return resultaat van de functie
}
/* End functie week(berekener) */

/* End Calender functie's */
echo Calender_main($jaar,$maand);
?>
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 4:12 PM   #4
Craig Keightley
 
Craig Keightley's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Calender Function - week view help needed

Thats exactly what i need,
however, how can i display one week at a time on the page?

"Warstar" <warstar@NSA.com> wrote in message
news:375jivo8or9d5crg3drv9q6iqk1etk19bi@4ax.com...
> Ok here we go (sorry some bad comments don't have anytime @ the moment
> to make them english and i know i should hope this helps):
> <?php
> #Code was made By Warnar Boekkooi Contact me @ warstar-web@gmx.net
> //Little lang. stuff
> $L_Words[1] = "Monday";
> $L_Words[2] = "Tuesday";
> $L_Words[3] = "Wednesday";
> $L_Words[4] = "Thursday";
> $L_Words[5] = "Friday";
> $L_Words[6] = "Saturday";
> $L_Words[7] = "Sunday";
> /* Calender functie's */
> /* hier staan alle functie's die met de calender te maken hebben */
>
> /* main calender functie */
> function Calender_main($jaar,$maand)
> {
> global $L_Words; //laad globale variabelen in
> $date_now = getdate(); //maak van var. $date_now alle info over
> vandaag
> if((!isset($jaar))||(!isset($maand)))//als de maand niet van te
> voren is aangegeven dan zet maand,jaar naar de maand,jaar van Nu.
> {
> $maand = $date_now['mon'];
> $jaar = $date_now['year'];
> }
> if($maand == 13)//als maand 13 is dan maak je jaar + 1 en maand
> word 1
> {
> $jaar++;
> $maand = 1;
> }
> if($maand == 0)//als maand 0 is dan maak je jaar - 1 en maand word
> 12
> {
> $jaar--;
> $maand = 12;
> }
> //Maak een var. die de dag van week weet(0 (for Sunday) through 6
> (for Saturday)) zo dat we deze later kunnen gebruiken
> $dagWeek = getdate(mktime(0,0,0,$maand,1,$jaar));
> $maandNaam = $dagWeek['month']; //naam van de maand die er wordt
> laten zien
> $dagWeek = $dagWeek['wday'];
> //maake var. voor kijken of dit eerste keer is dat loop loopt
> $firstTimeLoop = true;
> //var. eerstedag maand = 1 altijd, var. laastedag maand berekend
> met functie laastedag
> $maandEerstDag = 1;
> $maandLaasteDag = Calender_laastedag($jaar,$maand);
> //start tabel voor maand(next,back), Calender, Weeken
> $output .= "<table border='1'><tr>";
> $output .= "<td><table width='100%'><tr><td align='left'><a
> href='".$PHP_SELF."?maand=".($maand-1)."&jaar=".$jaar."'><-</a></td><td
> align='center'>".$maandNaam." ".$jaar."</td><td align='right'><a
>

href='".$PHP_SELF."?maand=".($maand+1)."&jaar=".$j aar."'>-></a></td></tr></t
able></td></tr>";
> //start tabel voor weken
> $outputWeek = "<table border='1'
> width='100%'><tr><td>Weeks</td></tr>"; #bijwerken lang
> //start tabel voor de calender en zet de namen van de dagen
> $output .= "<tr><td><table width='5%' border='1'><tr>";
> for($i = 1; $i <= '7'; $i++)
> {
> $output .= "<td>".$L_Words[$i]."</td>";
> }
> $output .= "</tr>";
> //maak een loop die alle datums van de maand in een tabel print in
> var. $output
> while ($maandEerstDag <= $maandLaasteDag)
> {
> //kijk of dit de eerste keer is dat loop loopt zo ja zoek dag
> op van de eerste dag
> if($firstTimeLoop)
> {
> $output .= "<tr>";
> //echo $maandEerstDag;
> $outputWeek .= Calender_Week($maand,$maandEerstDag,$jaar);
> if($dagWeek == "0")
> {
> //$outputWeek .=
> Calender_Week($maand,$maandEerstDag,$jaar);
> for($i=1; $i<=6 ; $i++)
> {
> $output .= "<td>&nbsp;</td>";
> }
> } else
> {
> for($i=1; $i<$dagWeek ; $i++)
> {
> $output .= "<td>&nbsp;</td>";
> }
> }
> $firstTimeLoop = false;
> } else {
> //Als de weekdag 1 is (Maandag) maak dan een nieuwe row in
> de table
> if($dagWeek == 1)
> {
> $output .= "<tr>";
> //echo $maandEerstDag;
> $outputWeek .=
> Calender_Week($maand,$maandEerstDag,$jaar);
> }
> }
>
> //Print datum in tabel
> $output .= "<td align='right'>".$maandEerstDag."</td>";
>
> //Als de weekdag 0 is (zondag) maak dan een sluit row in de
> table
> if($dagWeek == 0)
> {
> $output .= "</tr>";
> }
> $maandEerstDag++; //1 dag er bij op want we zijn 1 dag verder
> $dagWeek++; //1 dag er bij op want we zijn 1 dag verder
> $dagWeek = $dagWeek % 7;
> }
> //$outputWeek .= Calender_Week($maand,($maandEerstDag-1),$jaar);
> $outputWeek .= "</table>"; //sluit tabel week
> $output .= "</table></td>"; //sluit tabel van calender
> $output .= "<td>".$outputWeek."</td></tr></table>";
> return($output);//return resultaat van de functie
> }
> /* End main calender functie */
>
> /* functie laastdag(maand) */
> function Calender_laastedag($jaar,$maand)
> {
> $dag = "28"; //dit is de korste dag mogelijk in een maand
> $maand_tmp = $maand; //maak een tijdelijke maand aan die later
> word gebruikt
> while( $maand == $maand_tmp )//zolang maand en tijdelijke maand
> gelijk zijn loop uit voeren
> {
> $dag++;//dag met 1 verhogen
> $date_tmp = getdate(mktime(0,0,0,$maand,$dag,$year));//maak
> een datum die zegt welke dag maand het wordt met de dag
> $maand_tmp = $date_tmp['mon'];//maak gemaakte maand de
> tijdelijke maand
> }
> $dag--;//haal bij dag 1 af
> return($dag);//return resultaat van de functie
> }
> /* End functie laastdag(maand) */
>
> /* functie week(berekener) */
> function Calender_Week($maand,$dag,$jaar)
> {
> $output = "<tr><td align='right'>".
> date('W',(mktime(0,0,0,$maand,$dag,$jaar)))."</td></tr>";
> return $output;//return resultaat van de functie
> }
> /* End functie week(berekener) */
>
> /* End Calender functie's */
> echo Calender_main($jaar,$maand);
> ?>



 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 4:22 PM   #5
Craig Keightley
 
Craig Keightley's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Calender Function - week view help needed

I noticed that the week starts on a monday, what do i need to change to make
the week begin on a sunday?

"Warstar" <warstar@NSA.com> wrote in message
news:kdfkivs8qkf2uefhj4i9fo6bhk3l6najtg@4ax.com...
> Somethink like this:
>
> <?php
> #Code was made By Warnar Boekkooi Contact me @ warstar-web@gmx.net
> //Little lang. stuff
> $L_Words[1] = "Monday";
> $L_Words[2] = "Tuesday";
> $L_Words[3] = "Wednesday";
> $L_Words[4] = "Thursday";
> $L_Words[5] = "Friday";
> $L_Words[6] = "Saturday";
> $L_Words[7] = "Sunday";
>
> function Calender_week_main($jaar,$maand,$dag)
> {
> global $L_Words;
> $week = date('W',(mktime(0,0,0,$maand,$dag,$jaar)));
> $week_tmp = date('W',(mktime(0,0,0,$maand,$dag,$jaar)));
> $dag_tmp = $dag;
> while($week == $week_tmp)
> {
> $dag_tmp--;
> $week_tmp = date('W',(mktime(0,0,0,$maand,$dag_tmp,$jaar)));
> }
> $dag_tmp++;
> $output .= "<table width='5%' border='1'><tr>";
> for($i = 1; $i <= '7'; $i++)
> {
> $output .= "<td>".$L_Words[$i]."</td>";
> }
> $output .= "</tr><tr>";
> $week_tmp = date('W',(mktime(0,0,0,$maand,$dag_tmp,$jaar)));
> while($week == $week_tmp)
> {
> $output .= "<td>".
> date("d",mktime(0,0,0,$maand,$dag_tmp,$jaar))."</td>";
> $dag_tmp++;
> $week_tmp = date('W',(mktime(0,0,0,$maand,$dag_tmp,$jaar)));
> }
> return($output);
> }
> /* Calender functie's */
> /* hier staan alle functie's die met de calender te maken hebben */
>
> /* main calender functie */
> function Calender_main($jaar,$maand)
> {
> global $L_Words; //laad globale variabelen in
> $date_now = getdate(); //maak van var. $date_now alle info over
> vandaag
> if((!isset($jaar))||(!isset($maand)))//als de maand niet van te
> voren is aangegeven dan zet maand,jaar naar de maand,jaar van Nu.
> {
> $maand = $date_now['mon'];
> $jaar = $date_now['year'];
> }
> if($maand == 13)//als maand 13 is dan maak je jaar + 1 en maand
> word 1
> {
> $jaar++;
> $maand = 1;
> }
> if($maand == 0)//als maand 0 is dan maak je jaar - 1 en maand word
> 12
> {
> $jaar--;
> $maand = 12;
> }
> //Maak een var. die de dag van week weet(0 (for Sunday) through 6
> (for Saturday)) zo dat we deze later kunnen gebruiken
> $dagWeek = getdate(mktime(0,0,0,$maand,1,$jaar));
> $maandNaam = $dagWeek['month']; //naam van de maand die er wordt
> laten zien
> $dagWeek = $dagWeek['wday'];
> //maake var. voor kijken of dit eerste keer is dat loop loopt
> $firstTimeLoop = true;
> //var. eerstedag maand = 1 altijd, var. laastedag maand berekend
> met functie laastedag
> $maandEerstDag = 1;
> $maandLaasteDag = Calender_laastedag($jaar,$maand);
> //start tabel voor maand(next,back), Calender, Weeken
> $output .= "<table border='1'><tr>";
> $output .= "<td><table width='100%'><tr><td align='left'><a
> href='".$PHP_SELF."?maand=".($maand-1)."&jaar=".$jaar."'><-</a></td><td
> align='center'>".$maandNaam." ".$jaar."</td><td align='right'><a
>

href='".$PHP_SELF."?maand=".($maand+1)."&jaar=".$j aar."'>-></a></td></tr></t
able></td></tr>";
> //start tabel voor weken
> $outputWeek = "<table border='1'
> width='100%'><tr><td>Weeks</td></tr>"; #bijwerken lang
> //start tabel voor de calender en zet de namen van de dagen
> $output .= "<tr><td><table width='5%' border='1'><tr>";
> for($i = 1; $i <= '7'; $i++)
> {
> $output .= "<td>".$L_Words[$i]."</td>";
> }
> $output .= "</tr>";
> //maak een loop die alle datums van de maand in een tabel print in
> var. $output
> while ($maandEerstDag <= $maandLaasteDag)
> {
> //kijk of dit de eerste keer is dat loop loopt zo ja zoek dag
> op van de eerste dag
> if($firstTimeLoop)
> {
> $output .= "<tr>";
> //echo $maandEerstDag;
> $outputWeek .= Calender_Week($maand,$maandEerstDag,$jaar);
> if($dagWeek == "0")
> {
> //$outputWeek .=
> Calender_Week($maand,$maandEerstDag,$jaar);
> for($i=1; $i<=6 ; $i++)
> {
> $output .= "<td>&nbsp;</td>";
> }
> } else
> {
> for($i=1; $i<$dagWeek ; $i++)
> {
> $output .= "<td>&nbsp;</td>";
> }
> }
> $firstTimeLoop = false;
> } else {
> //Als de weekdag 1 is (Maandag) maak dan een nieuwe row in
> de table
> if($dagWeek == 1)
> {
> $output .= "<tr>";
> //echo $maandEerstDag;
> $outputWeek .=
> Calender_Week($maand,$maandEerstDag,$jaar);
> }
> }
>
> //Print datum in tabel
> $output .= "<td align='right'><a
>

href=?jaar=".$jaar."&maand=".$maand."&dag=".$maand EerstDag.">".$maandEerstDa
g."</a></td>";
>
> //Als de weekdag 0 is (zondag) maak dan een sluit row in de
> table
> if($dagWeek == 0)
> {
> $output .= "</tr>";
> }
> $maandEerstDag++; //1 dag er bij op want we zijn 1 dag verder
> $dagWeek++; //1 dag er bij op want we zijn 1 dag verder
> $dagWeek = $dagWeek % 7;
> }
> //$outputWeek .= Calender_Week($maand,($maandEerstDag-1),$jaar);
> $outputWeek .= "</table>"; //sluit tabel week
> $output .= "</table></td>"; //sluit tabel van calender
> $output .= "<td>".$outputWeek."</td></tr></table>";
> return($output);//return resultaat van de functie
> }
> /* End main calender functie */
>
> /* functie laastdag(maand) */
> function Calender_laastedag($jaar,$maand)
> {
> $dag = "28"; //dit is de korste dag mogelijk in een maand
> $maand_tmp = $maand; //maak een tijdelijke maand aan die later
> word gebruikt
> while( $maand == $maand_tmp )//zolang maand en tijdelijke maand
> gelijk zijn loop uit voeren
> {
> $dag++;//dag met 1 verhogen
> $date_tmp = getdate(mktime(0,0,0,$maand,$dag,$year));//maak
> een datum die zegt welke dag maand het wordt met de dag
> $maand_tmp = $date_tmp['mon'];//maak gemaakte maand de
> tijdelijke maand
> }
> $dag--;//haal bij dag 1 af
> return($dag);//return resultaat van de functie
> }
> /* End functie laastdag(maand) */
>
> /* functie week(berekener) */
> function Calender_Week($maand,$dag,$jaar)
> {
> $output = "<tr><td align='right'>".
> date('W',(mktime(0,0,0,$maand,$dag,$jaar)))."</td></tr>";
> return $output;//return resultaat van de functie
> }
> /* End functie week(berekener) */
>
> /* End Calender functie's */
> echo Calender_main($jaar,$maand);
> if(isset($dag))
> {
> echo Calender_week_main($jaar,$maand,$dag);
> }
> ?>



 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Featured Websites
Free Space
Free Space
Free Space Free Space
Closed Thread
Tags: , , , , ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
view mchenry Database 2 06-10-2007 12:27 AM
Is this a bug with week function? Dale Database 2 06-10-2007 12:22 AM
BLU-RAY IN DECLINE ALREADY: Fox abandons Blu-Ray, while Amazon reports HD-DVD outselling it week on week. Blig Merk II: XFLOP Fanboy. Computer Consoles 15 05-30-2007 6:17 PM
In it's third week on sale, UK PS3 sales plummet another 50%, Wii outselling it by nearly 9k a week. Sammus McMouldenus Computer Consoles 17 05-30-2007 5:42 PM
Calender Template Nova Design Graphics in general 1 05-28-2007 7:55 PM


Featured Websites




All times are GMT +1. The time now is 12:03 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008