Location: PHPKode > scripts > ScreamingToDos > std-0.9/calendar.php
<?PHP
require "login.php";

$categoryR = qDB("SELECT id,category FROM $categorytable WHERE owner=\"$currentuser\" ORDER BY sort_number");
if (mysql_num_rows($categoryR) == 0) {
 Header ("Location:category.php");
}

$fromCalendar = 1;
$currentPage = "STD->calendar view";
$confirmStr = "Are you sure you want to delete this item and all its comments?";
require 'header.php';
if (!($print)) { showAddTask(); }
?>
<center>
<table border="0" width="90%">
 <tr valign="top">
  <td colspan="3" align="center">
<?PHP

if ($month == "") { $month = date("m"); }
if ($year == "") { $year = date("Y"); }

if ($date) {

  if ($from_cal == "daily") {
    $new_month = $month;
    $new_year = $year;
  }

  list ($month, $day, $year) = explode("-",$date);

  if (($new_month > 0) && ($new_year > 0) && (($month != $new_month) || ($year != $new_year))) {
    $next_month = $new_month+1;
    $last_day = date(d, mktime(0,0,0,$next_month,0,$year));
    if ($day > $last_day) { $day = $last_day; }
  }

  if ($from_cal == "daily") {
    $month = $new_month;
    $year = $new_year;
    $date = "$month-$day-$year";
  }

  $todays_date_query = "$year-$month-$day";
 
  $last_day_query = date(d, mktime(0,0,0,$month,0,$year));

  if ($day == $last_day_query) {
   if ($month == 12) { $tom_month = 1; $tom_year = $year + 1; } else { $tom_month = $month + 1; $tom_year = $year; }
   $tom_day = 1;
  } else { $tom_day = $day + 1; $tom_month = $month; $tom_year = $year; }
 
  $tomorrows_date_query = "$tom_year-$tom_month-$tom_day";

?>
 <table border="0">
  <tr>
   <td align="center">
<font face="<?PHP echo $pageFont ?>" size="+<?PHP echo $pageFontsize+3 ?>"><strong>
<?PHP echo date("F jS, Y", mktime(0,0,0,$month,$day,$year)) ?>
</strong></font>
<br><p></p>
<?PHP
  $q = "SELECT id,category,open_sortby,closed_sortby,owner,closed_show,open_show,open_show_comments,closed_show_comments";
  $q .= " FROM $categorytable WHERE owner=\"$currentuser\" ORDER BY sort_number";

  $categoryR = qDB($q);
  while ($categoryD = mysql_fetch_array($categoryR)) {

    $q = "SELECT id,priority,owner,task,DATE_FORMAT(due_date, '%m.%d.%y') AS due_date,closed,DATE_FORMAT(created_date, '%m.%d.%y')";
    $q .= " AS created_date,categoryid FROM $todotable WHERE closed=\"0\" AND";
    $q .= " (due_date>=\"$todays_date_query\" AND due_date<\"$tomorrows_date_query\") AND categoryid=".$categoryD["id"];
    $q .= " ORDER BY ".$categoryD["open_sortby"];
    $r = qDB($q);
    $totaltasks = mysql_num_rows($r);
    $totalopentasks = $totaltasks;
    if (($totaltasks > 0) || ($show_empty_categories)) {
      showTableHeader($categoryD,"open",$categoryD["open_show_comments"]);
      while ($d = mysql_fetch_array($r)) {
        if (($d["priority"] >= 1) && ($d["priority"] <= 3)){ $foreCol = $highForeCol; $backCol = $highBackCol; }
        elseif (($d["priority"] > 3) && ($d["priority"] < 8)) { $foreCol = $medForeCol; $backCol = $medBackCol; }
        elseif (($d["priority"] >= 8) && ($d["priority"] <= 10)) { $foreCol = $lowForeCol; $backCol = $lowBackCol; }
        showitem($d, "open","1",$categoryD["open_show_comments"]);
      }
    } ?>
    </table></form>
      <?PHP

    $q = "SELECT id,priority,owner,task,DATE_FORMAT(closed_date, '%m.%d.%y') AS closed_date, closed,";
    $q .= " DATE_FORMAT(created_date, '%m.%d.%y') AS created_date, categoryid";
    $q .= " FROM $todotable WHERE closed=\"1\" AND (closed_date>=\"$todays_date_query\" AND";
    $q .= " closed_date<\"$tomorrows_date_query\") AND categoryid=".$categoryD["id"]." ORDER BY ".$categoryD["closed_sortby"];
    $r = qDB($q);
    $totaltasks = mysql_num_rows($r);
    $totalclosedtasks = $totaltasks;
    if (($totaltasks > 0) || ($show_empty_categories)) {
      showTableHeader($categoryD,"closed",$categoryD["closed_show_comments"]);
      $foreCol = $doneForeCol;
      $backCol = $doneBackCol;
      while ($d = mysql_fetch_array($r)) {
        showitem($d, "closed","1",$categoryD["closed_show_comments"]);
      }
    } 
   
  if ((!($totalclosedtasks)) && (!($totalopentasks))) { ?>
<font face="<?PHP echo $pageFont ?>" size="+<?PHP echo $pageFontsize+3 ?>" color="<?PHP echo $errorForeCol ?>"><strong>
  You do not have any tasks for today!
</strong></font>
<?PHP }

?>
</td></tr></table>
<br><p></p>
<br><p></p>
<?PHP
  }

?></td></tr></table></td>
<td align="center">
 <table border="0">
  <tr>
   <td align="center">
<?PHP



  if ($month == 1) { show_calendar(12, $year-1); }
  else { show_calendar($month-1, $year); }

  ?></td><td align="center" id="bordered"><?PHP

  show_calendar($month, $year);

  ?></td><td align="center"><?PHP

  if ($month == 12) { show_calendar(1, $year+1); }
  else { show_calendar($month+1, $year); }

  ?></td></tr></table><?PHP
} else {

show_calendar($month, $year);

 } ?>
</td>
</tr>
</table>
<?PHP if (!($print)) { ?>
<center>
<form method="post" action="calendar.php">
<input type="hidden" name="date" value="<?PHP echo $date ?>">
<table border="0" cellpadding="0" id="bordered">
 <tr valign="center">
  <td align="center"><font face="<?PHP echo $GLOBALS["pageFont"] ?>" size="<?PHP echo $GLOBALS["pageFontsize"] ?>">Go to month:</font>&nbsp;&nbsp;</td>
  <td>
   <select name="month">
<?PHP
  $monArray = array('January','February','March','April','May','June','July','August','September','October','November','December');
  for ($x = 1; $x <= 12; $x++) {
    if (($x == $month) || (($month == "") && ($x == date("m")))) { $SEL = "SELECTED"; } else { $SEL = ""; }
    $y = $x - 1;
    echo "<option $SEL value=\"$x\">$monArray[$y]\n";
  }
?>
   </select>
  </td>
  <td>
   <select name="year">
<?PHP
  for ($x = 2000; $x <= 2020; $x++) {
    if (($x == $year) || (($year == "") && ($x == date("Y")))) { $SEL = "SELECTED"; } else { $SEL = ""; }
    echo "<option $SEL value=\"$x\">$x\n";
  }
?>
   </select>
  </td>
  <td>&nbsp;&nbsp;<input type="submit" value="Go">
<?PHP if ($date) { ?> 
    <input type="hidden" name="from_cal" value="daily">
    <input type="hidden" name="date" value="<?PHP echo $date ?>">
<?PHP } ?>
  </td>
 </tr>
</table>
</form>
</center>
<?PHP } ?>
<br><p></p>
<br><p></p>
<br><p></p>

<?PHP require 'footer.php' ?>
Return current item: ScreamingToDos