PHPBuilder - Simple calender and scheduler



RSS Twitter
Snippets Calendars Dates

Simple calender and scheduler

by: Mohammad Riaz
|
July 12, 2001

Version: 0.1

Type: Full Script

Category: Calendars/Dates

License: GNU General Public License

Description: Simple calender and scheduler script. It displays calender for anymonth upto year 2010 and lets users add events to the dates. To view the script in action and to download the script, visit : http://rockhopper.monmouth.edu/~s0451223/calender/calender.php



//File : calender.php
//Author : Mohammad Riaz
// Date : 07/12/2001
<html>
<head>
<title>
Calender</title>
</head>
<body>
<form method=get action=http://rockhopper.monmouth.edu/~s0451223/calender/calender.php>
<table border="0" width="100%" bgcolor="#CCCCFF">
  <tr>
    <td width="100%" align=center><font color="black" face="Arial"><b>Calender
    </b></font></td>
  </tr>
</table>
<center>

<?php
if($submit) {
$tmpd = getdate(mktime(0, 0, 0, $sel_month, 1, $sel_year));
$month = $tmpd["mon"]; 
$fwday= $tmpd["wday"];
$year = $tmpd["year"];
$month_textual = $tmpd["month"];
#$today = date("F, Y");            
echo "<font face=Arial, Helvetica color = red><b>";
echo"<b>$month_textual, $year</b></font>";
}
else {
$month=$sel_month;
$tmpd = getdate(mktime(0, 0, 0, date("m"), 1, date("Y")));
$month = $tmpd["mon"]; 
$fwday= $tmpd["wday"];
$year = $tmpd["year"];
$month_textual = $tmpd["month"];
echo "<font face=Arial, Helvetica color = red><b>";
echo"<b>$month_textual, $year</b></font>";
}
echo"<br><br>";
if($month == 2) {
	if(($year%4) == 0) {
		$no_days = 29;
	}
	else {
		$no_days = 28;
	}
}
elseif(($month == 1) || ($month == 3) || ($month == 5) ||  
($month == 7) ||  ($month == 8) ||  ($month == 10) ||  ($month == 12)) {
	$no_days = 31;
}
else {
	$no_days = 30;
}

echo"<table border=1><tr bgcolor=#CCCCFF>";
echo"<td bgcolor=red>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td>
<td>Thu</td><td>Fri</td><td>Sat</td>";
echo"</tr><tr>";

#$firstday = date("l", mktime(0, 0, 0, 7, 1, 2001)); 

if($fwday == 0) {
	$index = 1;
}
if($fwday == 1) {
	$index = 2;
}
if($fwday == 2) {
	$index = 3;
}
if($fwday == 3) {
	$index = 4;
}
if($fwday == 4) {
	$index = 5;
}
if($fwday == 5) {
	$index = 6;
}
if($fwday == 6) {
	$index = 7;
}

#echo $index;
$count = 0;
#$day = date("l", mktime(0, 0, 0, 8, $i, 2001)); 
for($a = 1; $a <= $fwday; $a++) {
	echo"<td></td>";
}
for($i = 1; $i <= (7 - $fwday) ; $i++) {
echo"<td align=center width=50 height=50><b>
<a href=http://rockhopper.monmouth.edu/~s0451223/calender/insert.php?date=$i&month=$month&year=$year>
$i<b><a></td>";
$count++;
}
echo"</tr>";

echo"<tr>";
for($j = $i; $j <= ($i + 6); $j++) {
echo"<td align=center width=50 height=50><b>
<a href=http://rockhopper.monmouth.edu/~s0451223/calender/insert.php?date=$j&month=$month&year=$year>
$j </b></td>";
}
echo"</tr>";

echo"<tr>";
for($k = $j; $k <= ($j + 6); $k++) {
echo"<td align=center width=50 height=50><b>
<a href=http://rockhopper.monmouth.edu/~s0451223/calender/insert.php?date=$k&month=$month&year=$year>
$k</b></td>";
}
echo"</tr>";

echo"<tr>";
for($l = $k; $l <= ($k + 6); $l++) {
echo"<td align=center width=50 height=50><b>
<a href=http://rockhopper.monmouth.edu/~s0451223/calender/insert.php?date=$l&month=$month&year=$year>
$l</td>";
}
echo"</tr>";

echo"<tr>";
if(($no_days - $l) >= 7) {
$roll_over = $l + 6;
}
for($m = $l; $m <= $roll_over; $m++) {
echo"<td align=center width=50 height=50><b>
<a href=http://rockhopper.monmouth.edu/~s0451223/calender/insert.php?date=$m&month=$month&year=$year>
$m </b></td>";
}
echo"</tr>";

echo"<tr>";
for($n = $m; $n <= $no_days; $n++) {
echo"<td align=center width=50 height=50><b>
<a href=http://rockhopper.monmouth.edu/~s0451223/calender/insert.php?date=$n&month=$month&year=$year>
$n</td>";
}
echo"</tr>";

echo"</table>";
echo"<hr>";
?>
<b>Select date to view or add Schedule</b>
<table>
<tr>
    <td>
      <select name="sel_year">
	<?php
	$tyear = date("Y");
	for($i = $tyear; $i < ($tyear+10); $i++)
          echo"<option value=$i>$i";
	?>
      </select>
    </td>
    <td>
      <select name="sel_month">
	<?php
	$tmonth = date("m");
	for($j = 1; $j <= 12; $j++)
          echo"<option value=$j>$j";
	?>
      </select>
    </td>
    <td><input type=submit name=submit value=Go></td>
  </tr>
  <tr>
    <td><font size=-1>(year/month)</font></td>
  </tr>
</table>
</center>
</html>

//------------------------------------------------------------------------------------------
//File : insert.php
//Author : Mohammad Riaz
//Date : 07/12/2001

<html>
<body>
<form method=post action=http://rockhopper.monmouth.edu/~s0451223/calender/insert2.php>
<table border="0" width="100%" bgcolor="#CCCCFF">
  <tr>
    <td width="100%"><font color="black" face="Arial"><b>Your 
Schedule for
<?php 
$this_date = date("F j, Y", mktime(0, 0, 0, $month, $date, $year)); 
echo $this_date; ?>
</b></font></td>
</table>
<br>
<center>

<?php

if(mktime(0, 0, 0, $month, $date, $year) < mktime(0, 0, 0, date("m"), 
date("d"), date("Y"))) {

echo "Display schedule for that date";

echo "<table border=1>\n";

echo "<tr bgcolor=#C0C0C0><td>Item</td>
      <td>Due Date</td>
      <td>Due Time</td>
      <td>Days left</td>
</tr>\n";
echo "</table>\n";
echo "</center>";
}
else {

echo"<input type=hidden name=month value=$month>
<input type=hidden name=date value=$date>
<input type=hidden name=year value=$year>

<table border=0 width=100%>
  <tr>
    <td colspan=2>
       <p><b>Enter your ToDo Item</b>
       </p>
    </td>
  </tr>  

  <tr>
    <td width=20%>ToDo?</td>
    <td width=80%><input type=text name=todo size=30></td>
  </tr>
</table>

<hr>

<table border=0 width=100%>
  <tr>
    <td width=20%>Time</td>
    <td width=80%>
      <input type=text name=hours size=2>
      <input type=text name=minutes size=2>
      <font size=-1>(hh/mm)</font>
    </td>
  </tr>
  <tr>
  </tr>
</table>
<hr>
<center>
<table>
  <tr>
    <td colspan=2 align=center><input type=submit name=submit value=Add>&nbsp<input type=reset name=clear value=Clear>
    </td>
  </tr>
</table>
</center>";
}
?>
</body>
</html>

//------------------------------------------------------------------------------------------
// Filename : insert2.php
// Author : Mohammad Riaz
// Date : 07/12/2001
<?php
if($submit) {

function validate_input($todo, $hours, $minutes, $urgent) {

$err_code = 0; 

if(!$todo)
{
        echo"<b><font color=red>-Please enter a To-Do item</font></b><br>";
        $err_code++;
}

if(!$hours || !$minutes)
{
        echo"<b><font color=red>-Please enter time</font></b><br>";
        $err_code++;
}

return $err_code;

}

$result = validate_input($todo, $hours, $minutes, $urgent);

if($result == 0) {
	echo "<b><br>$date<br>$month<br>$year<br>$todo<br>$hours<br>$minutes
	<br></b>";
	echo"<font color=red><b>Do something with this data</b></font>";
}
}
?>

///End







Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Mohammad Riaz

Comment:



Comment:

(Maximum characters: 1200). You have characters left.