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

if (!($editnum)) { Header("Location:index.php"); } 

$num_comments = mysql_num_rows(qDB("SELECT id FROM $commentstable WHERE todoid=$editnum"));

$q = "SELECT id,priority,owner,task,DATE_FORMAT(due_date, '%m.%d.%y') AS due_date, DATE_FORMAT(due_date, '%m') AS due_month,";
$q .= " DATE_FORMAT(due_date, '%d') AS due_day, DATE_FORMAT(due_date, '%Y') AS due_year, DATE_FORMAT(due_date, '%l') AS due_hour,";
$q .= " DATE_FORMAT(due_date, '%i') AS due_minutes, DATE_FORMAT(due_date, '%p') AS due_ampm,";
$q .= " DATE_FORMAT(created_date, '%m.%d.%y') AS created_date,closed,categoryid FROM $todotable WHERE id=$editnum";

$r = qDB($q);
$d = mysql_fetch_array($r);

if ($d["closed"]) { $openCloseStr = "closed"; } else { $openCloseStr = "open"; }
$r = qDB("SELECT ".$openCloseStr."_sortby FROM $categorytable WHERE id=".$d["categoryid"]);
$categoryD = mysql_fetch_array($r);

// NEXT URL
$r = qDB("SELECT id FROM $todotable WHERE owner=\"$currentuser\" ORDER BY categoryid, closed DESC, ".$categoryD[0]);
while ($rowD = mysql_fetch_row($r)) { 
 if ($rowD[0] == $editnum) { 
  $rowD = mysql_fetch_row($r);
  if ($rowD[0] != "") { $nextNavURL = "<a href=\"edittask.php?editnum=".$rowD[0]."\">"; }
  break;
 }
}

// PREVIOUS URL
$r = qDB("SELECT id FROM $todotable WHERE owner=\"$currentuser\" ORDER BY categoryid, closed DESC, ".$categoryD[0]);
while ($rowD = mysql_fetch_row($r)) { 
 if ($rowD[0] == $editnum) {
  if ($oldID != "") { $prevNavURL = "<a href=\"edittask.php?editnum=$oldID\">"; }
  break;  
 }
 $oldID = $rowD[0];
} 

// LAST URL
$r = qDB("SELECT id FROM $todotable WHERE owner=\"$currentuser\" ORDER BY categoryid, closed DESC, ".$categoryD[0]);
while ($rowD = mysql_fetch_row($r)) {
 if ($rowD[0] != $editnum) { $lastNavURL = "<a href=\"edittask.php?editnum=".$rowD[0]."\">"; }
 else { $lastNavURL = ""; }
}

// FIRST URL
$r = qDB("SELECT id FROM $todotable WHERE owner=\"$currentuser\" ORDER BY categoryid, closed DESC, ".$categoryD[0]);
$rowD = mysql_fetch_array($r);
if ($rowD[0] != $editnum) { $firstNavURL = "<a href=\"edittask.php?editnum=".$rowD[0]."\">"; }

// FIRST IN CATEGORY URL
$q = "SELECT id FROM $todotable WHERE owner=\"$currentuser\" AND categoryid=".$d["categoryid"];
$q = $q." ORDER BY closed DESC, ".$categoryD[0];
$r = qDB($q);
$rowD = mysql_fetch_array($r);
if ($rowD[0] != $editnum) { $ficNavURL = "<a href=\"edittask.php?editnum=".$rowD[0]."\">"; }

$q = "SELECT id FROM $todotable WHERE owner=\"$currentuser\" AND categoryid=".$d["categoryid"];
$q = $q." ORDER BY closed DESC, ".$categoryD[0];
$r = qDB($q);
while ($rowD = mysql_fetch_row($r)) { 
 if ($rowD[0] != $editnum) { $licNavURL = "<a href=\"edittask.php?editnum=".$rowD[0]."\">"; }
 else { $licNavURL = ""; }
}

if ($currentuser != $d["owner"]) { Header("Location:index.php"); }

$r = qDB("SELECT owner,category FROM $categorytable WHERE id=".$d["categoryid"]);
$categoryD = mysql_fetch_array($r);

$confirmStr = "Are you sure you want to delete this item and all its comments?";
$currentPage = "STD->edit task";
$fromEditTodo = 1;
require "header.php";
if ($HTTP_REFERER == "") { $referer_url = "index.php"; } else { $referer_url = $HTTP_REFERER; }
?>
<form action="<?PHP echo $referer_url ?>" method="post">
<table border="0" cellpadding="5" width="90%">
<tr><td>
<font face="<?PHP echo $pageFont ?>" size="+<?PHP echo $pageFontsize+2 ?>">
<strong>Task:</strong><br>
</font>

<br><p></p>
<font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>">
<?PHP
if ($d["closed"]) {
 $foreCol = $doneForeCol;
 $backCol = $doneBackCol;
} else {
 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; }
}
?>

<center>
<table width="90%" border="0" align="center">
 <tr>
  <td align="center"><strong><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>">Date Added</font></strong></td>
  <td align="center"><strong><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>">Due Date</font></strong></td>
  <td align="center"><strong><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>">Priority</font></strong></td>
<?PHP if ($multiuser) { ?>
  <td align="center"><strong><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>">Owner</font></strong></td>
<?PHP } ?>
 <td align="center" width="99%"><strong><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>">Task</font>
</strong></td>
  <td align="center" width="99%"><strong><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>">Category</font>
  <td align="center" width="99%"><strong><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>">Comments</font>
  <td align="center" width="99%"><strong><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>">Delete</font>
</tr>

<tr>
 <td bgcolor="<?PHP echo $backCol ?>" align="center"><font face="<?PHP echo $pageFont ?>" color="<?PHP echo $foreCol ?>" size="<?PHP echo $pageFontsize ?>"><nobr><?PHP echo substr($d["created_date"],0,10) ?></nobr></font></td>

 <td bgcolor="<?PHP echo $backCol ?>" align="center"><font face="<?PHP echo $pageFont ?>" color="<?PHP echo $foreCol ?>" size="<?PHP echo $pageFontsize ?>"><nobr><?PHP echo substr($d["due_date"],0,10) ?></nobr></font></td>

 <td bgcolor="<?PHP echo $backCol ?>" align="center"><font face="<?PHP echo $pageFont ?>" color="<?PHP echo $foreCol ?>" size="<?PHP echo $pageFontsize ?>"><?PHP echo $d["priority"] ?></font></td>

<?PHP if ($multiuser) { ?>
<td bgcolor="<?PHP echo $backCol ?>" align="center"><font face="<?PHP echo $pageFont ?>" color="<?PHP echo $foreCol ?>" size="<?PHP echo $pageFontsize ?>"><?PHP echo $d["owner"] ?></font></td>
<?PHP } ?>

<td bgcolor="<?PHP echo $backCol ?>" align="center"><font face="<?PHP echo $pageFont ?>" color="<?PHP echo $foreCol ?>" size="<?PHP echo $pageFontsize ?>"><?PHP echo $d["task"] ?></font></td>

<td bgcolor="<?PHP echo $backCol ?>" align="center"><font face="<?PHP echo $pageFont ?>" color="<?PHP echo $foreCol ?>" size="<?PHP echo $pageFontsize ?>"><?PHP echo $categoryD["category"] ?></font></td>

<td bgcolor="<?PHP echo $backCol ?>" align="center"><font face="<?PHP echo $pageFont ?>" color="<?PHP echo $foreCol ?>" size="<?PHP echo $pageFontsize ?>"><a href="comments.php?id=<?PHP echo $d["id"] ?>">Modify</a> :<?PHP echo $num_comments ?>:</font></td>

<td bgcolor="<?PHP echo $backCol ?>" align="center"><font face="<?PHP echo $pageFont ?>" color="<?PHP echo $foreCol ?>" size="<?PHP echo $pageFontsize ?>"><a href="javascript:if(doublecheck()){ document.location.href='<?PHP echo $HTTP_REFERER ?>?deletenum=<?PHP echo $d["id"] ?>' }">Delete</a></font></td>

</tr>
</table>
</center>
<br><p></p>
<table border="0" cellpadding="5">
 <tr>
  <td><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>"><strong>Due Date:</strong></font></td>   
  <td>
   <select name="mon">
    <option value="">---------
<?PHP
  $monArray = array('January','February','March','April','May','June','July','August','September','October','November','December');
  for ($x = 1; $x <= 12; $x++) {
    if ($x == $d["due_month"]) { $SEL = "SELECTED"; } else { $SEL = ""; }
    $y = $x - 1;
    echo "<option $SEL value=\"$x\">$monArray[$y]\n";
  }
?>
   </select>
-
   <select name="day">
    <option value="">--
<?PHP
  for ($x = 1; $x <= 31; $x++) {
    if ($x == $d["due_day"]) { $SEL = "SELECTED"; } else { $SEL = ""; }
    echo "<option $SEL value=\"$x\">$x\n";
  }
?>
   </select>
-
   <select name="year">
    <option value="">----
<?PHP
  for ($x = 2000; $x <= 2020; $x++) {
    if ($x == $d["due_year"]) { $SEL = "SELECTED"; } else { $SEL = ""; }            
    echo "<option $SEL value=\"$x\">$x\n";
  }
?>
   </select>
&nbsp;&nbsp;&nbsp;
   <select name="hour">
    <option value="">--
<?PHP
  for ($x = 1; $x <= 12; $x++) {
   if ($x == $d["due_hour"]) { $SEL = "SELECTED"; } else { $SEL = ""; }
   if (strlen($x) == 1) { $x_str = "0".$x; } else { $x_str = $x; }
   echo "<option $SEL value=\"$x\">$x_str\n";
  }
?>
    </select>
:
   <select name="minutes">
    <option value="">--
<?PHP
  for ($x = 0; $x <= 59; $x++) {
   if ((strlen($d["due_minutes"]) > 0) && ($x == $d["due_minutes"])) { $SEL = "SELECTED"; } else { $SEL = ""; }
   if (strlen($x) == 1) { $x_str = "0".$x; } else { $x_str = $x; }
   echo "<option $SEL value=\"$x\">$x_str\n";
  }
?>
    </select>
&nbsp;
   <select name="ampm">
    <option value="">--
    <option <?PHP if (strtoupper($d["due_ampm"]) == "AM") { echo "SELECTED "; } ?>value="AM">AM
    <option <?PHP if (strtoupper($d["due_ampm"]) == "PM") { echo "SELECTED "; } ?>value="PM">PM
   </select>

  </td>
 </tr>
 <tr>
  <td><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>"><strong>Priority:</strong></font></td>  
  <td>
   <select name="priority">
<?PHP
  for ($x = 1; $x <= 10; $x++) {
    if ($d["priority"] == $x) { $SEL = "SELECTED"; } else { $SEL = ""; }
    echo "<option $SEL value=\"$x\">$x\n";
  }
?>
   </select>
  </td>
 </tr>
<?PHP if ($multiuser) { ?>
 <tr>
  <td><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>"><strong>Owner:</strong></font></td>
  <td>
<?PHP
  $owner = "<select name=\"owner\" size=\"1\">\n";
  $r = qDB("SELECT username FROM $usertable ORDER BY username");
  while ($userD = mysql_fetch_array($r)) {
   if ($userD[0] == $currentuser) { $SEL = "SELECTED"; } else { $SEL = ""; }
   $owner = $owner."<option $SEL value=\"".$userD[0]."\">".$userD[0]."\n";
  }
  $owner = $owner."</select>";
  echo $owner;
?>
  </td>
 </tr>
<?PHP } ?>
 <tr>
  <td><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>"><strong>Task:</strong></font></td>
  <td><input type="text" name="task" size="45" value="<?PHP echo $d["task"] ?>"></td>
  <td>&nbsp;</td>                                                                                                    
 </tr>
 <tr>
  <td><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>"><strong>Category:</strong></font></td>
  <td>
<?PHP
  $categoryStr = "<select name=\"category\" size=\"1\">\n";
  $r = qDB("SELECT id,category FROM $categorytable WHERE owner=\"$currentuser\"");
  while ($categoryD = mysql_fetch_array($r)) {
   if ($categoryD[0] == $d["categoryid"]) { $SEL = "SELECTED"; } else { $SEL = ""; }
   $categoryStr = $categoryStr."<option $SEL value=\"$categoryD[0]\">$categoryD[1]\n";
  }
  $categoryStr = $categoryStr."</select>";
  echo $categoryStr;
?>
  </td>
 </tr>
 <tr>
  <td><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>"><strong>Status:</strong></font></td>
  <td>
   <select name="closed">
    <option value="0">Open
    <option <?PHP if ($d["closed"]) { echo "SELECTED "; } ?>value="1">Closed
   </select>
  </td>
 </tr>
 <tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
 </tr>
 <tr>
  <td>&nbsp;</td>                                                                                         
  <td>
<?PHP if (!($multiuser)) { ?>
   <input type="hidden" name="owner" value="<?PHP echo $currentuser ?>">
<?PHP } ?>
   <input type="hidden" name="updatenum" value="<?PHP echo $editnum ?>">
   <input type="submit" value="Update"></td>
 </tr>
</table>
</td>
</tr>
</table>
</form>
<?PHP
 $footerURL = $referer_url;
 require 'footer.php';
?>
Return current item: ScreamingToDos