Location: PHPKode > projects > Internet Task Management System > itms_mysql_build_0111/index.php
<?php

/*
 * ITMS ValleyData source file version 1.0 May 11, 2001
 *
 * ITMS homepage, shows pending tasks assigned to the current user
 * as well as current tasks the current user has assigned
 *
 *
 * Internet Task Management System: An online system used for recording information about and assigning tasks and processes.
 * Copyright (C) 2001  ValleyData Programming Group
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * See file named "gpl.txt" included with source code or
 * visit http://www.gnu.org/copyleft/gpl.txt on the internet.
 */
$title="Pending Tasks";
include("header.php");

print("<IMG SRC=\"images/pending_tasks.jpg\" WIDTH=\"400\" HEIGHT=\"41\" BORDER=\"0\" ALT=\"Welcome to ITMS $user\">");

if($viewPending == "Show Details")
{
    $viewPending = "Hide";
    $viewPendingNot = "Show";
}
else
{
    $viewPending = "Show";
    $viewPendingNot = "Hide";
}

if($viewAssigned == "Show Details")
{
    $viewAssigned = "Hide";
    $viewAssignedNot = "Show";
}
else
{
    $viewAssigned = "Show";
    $viewAssignedNot = "Hide";
}

$PENDING_START = <<<PENDING_START
<table>
<tr>
<td>
    <B>Pending Tasks Currently Assigned to me:</B>
    <table border="0">
    <form name="pending_tasks" METHOD="POST" ACTION="index.php">
    <tr class="table-header">
        <td><a href="index.php?orderby=taskname">Task Name</a></td>
        <td><a href="index.php?orderby=assigned">Assigned By</a></td>
        <td><a href="index.php?orderby=priority">Priority</a></td>
        <td><a href="index.php?orderby=duedate">Due Date</a></td>
        <td>
        <INPUT TYPE="hidden" name="viewAssigned" value="$viewAssignedNot Details">
		<INPUT TYPE="submit" name="viewPending" value="$viewPending Details">
        </td>
    </tr>
    </form>
	<form name="save" METHOD="POST" ACTION="index.php">
PENDING_START;

$PENDING_END = <<<PENDING_END
	<tr class="table-header">
	    <td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	    <td>&nbsp;</td>
		<td>
		<INPUT TYPE="hidden" name="save" value="save">
		<INPUT TYPE="submit" value="Complete Selected Tasks" name="save">
		</td>
	</tr>
	</form>
    </table>
<br>
PENDING_END;

$ASSIGNED_START = <<<ASSIGNED_START
    <br>
    <B>Pending Tasks I have Assigned:</B>
    <table border="0">
    <form METHOD="POST" ACTION="index.php">
    <tr class="table-header">
        <td><a href="index.php?orderby=taskname">Task Name</a></td>
        <td><a href="index.php?orderby=assigned">Assigned To</a></td>
        <td><a href="index.php?orderby=priority">Priority</a></td>
        <td><a href="index.php?orderby=duedate">Due Date</a></td>
        <td colspan="2">
            <INPUT TYPE="hidden" name="viewPending" value="$viewPendingNot Details">
            <INPUT TYPE="submit" name="viewAssigned" value="$viewAssigned Details">
        </td>
    </tr>
    </form>
ASSIGNED_START;

$ASSIGNED_START_ALL = <<<ASSIGNED_START_ALL
    <br>
    <B>Pending Tasks in the System:</B>
    <table border="0">
    <form METHOD="POST" ACTION="index.php">
    <tr class="table-header">
        <td><a href="index.php?orderby=taskname">Task Name</a></td>
        <td><a href="index.php?orderby=assigned">Assigned To</a></td>
        <td><a href="index.php?orderby=assigner">Assigned By</a></td>
        <td><a href="index.php?orderby=priority">Priority</a></td>
        <td><a href="index.php?orderby=duedate">Due Date</a></td>
        <td colspan="2">
            <INPUT TYPE="hidden" name="viewPending" value="$viewPendingNot Details">
            <INPUT TYPE="submit" name="viewAssigned" value="$viewAssigned Details">
        </td>
    </tr>
    </form>
ASSIGNED_START_ALL;

$ASSIGNED_END = <<<ASSIGNED_END
    </table>
</td>
</tr>
</table>
ASSIGNED_END;

db_open();
db_use();

if($orderby == "taskname")
{
    $orderby = "title";
}
else if($orderby == "assigned")
{
    $orderby = "name";
}
else if($orderby == "assigner")
{
    $orderby = "assigned_by";
}
else if($orderby == "priority")
{
    $orderby = "priority DESC";
}
else if($orderby == "duedate")
{
    $orderby = "due_date";
}
else
{
    $orderby = "due_date";
}

$query = "SELECT tid, title, name, priority, due_date, date_assigned, info FROM pending_tasks, users WHERE pending_tasks.uid = '$uid' AND pending_tasks.assigner = users.uid ORDER BY $orderby";

//$query = "SELECT * FROM pending_tasks WHERE uid = '$uid' ORDER BY due_date";

$result = db_query($query); //get pending tasks assigned to current user
$table_separator_string = "table-separator-even";
$row_separator_num = 0;
if($result)
{
    print($PENDING_START);
    while($row = db_fetch_row($result))
    {
        $row_separator_num++;
        if($row_separator_num % 2 == 0)
            $table_separator_string = "table-separator-even";
        else
            $table_separator_string = "table-separator-odd";
		$priority = get_priority_string($row["priority"]);

        print("<tr class=\"$table_separator_string\">\n");
        print("    <td><a href=\"\"  onclick=\"javascript:window.open('task_show.php?task_id=".$row["tid"]."','mywindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=350,height=200')\">" . $row["title"] . "</a></td>\n");  //Added Link to task_show.php Matt Palmerlee 5/16/2003 
        print("    <td>" . $row["name"] . "</td>\n");
		print("    <td>" . $priority . "</td>\n");
        print("    <td>" . convert_date($row["due_date"]) . "</td>\n");
        print("<td><INPUT TYPE=\"checkbox\" NAME=\"done" . $row["tid"] . "\">Task Done</td>");
        print("</tr>\n");
        if($viewPending == "Hide")
        {
			$info = nl2br($row["info"]);
            print("<tr class=\"$table_separator_string\">\n");
            print("<td>&nbsp;</td>");
            print("<td colspan=\"4\">Assigned On: " . convert_date($row["date_assigned"]) . "<br>\n$info</td>");
            print("</tr>");
        }
    }
	if($row_separator_num == 0) //they have no pending tasks
	{
		print("<tr class=\"$table_separator_string\">\n<td colspan=\"5\">No Current Pending Tasks</td></tr>\n");
	}
    print($PENDING_END);
}
if($ALLOW_ADMIN_VIEW_ALL_TASKS && $isAdmin)
{
    $query = "SELECT tid, title, u1.name name, u2.name assigned_by, priority, due_date, date_assigned, info FROM pending_tasks, users u1, users u2  WHERE pending_tasks.uid = u1.uid and pending_tasks.assigner = u2.uid ORDER BY $orderby";
	$info_colspan = 6;
}
else
{
    $query = "SELECT tid, title, name, priority, due_date, date_assigned, info FROM pending_tasks, users WHERE pending_tasks.assigner = '$uid' AND pending_tasks.uid = users.uid ORDER BY $orderby";
	$info_colspan = 5;
}
//$query = "SELECT * FROM pending_tasks WHERE assigner = '$uid' ORDER BY due_date";

$result = db_query($query); //get pending tasks user has assigned
$table_separator_string = "table-separator-even";
$row_separator_num = 0;
if($result)
{
    if($ALLOW_ADMIN_VIEW_ALL_TASKS && $isAdmin)
    {
        print($ASSIGNED_START_ALL);
    }
    else
    {
        print($ASSIGNED_START);
    }
    while($row = db_fetch_row($result))
    {
        $row_separator_num++;
        if($row_separator_num % 2 == 0)
            $table_separator_string = "table-separator-even";
        else
            $table_separator_string = "table-separator-odd";
		$priority = get_priority_string($row["priority"]);
        print("<form name=\"unassign\" METHOD=\"POST\" ACTION=\"task_assigned_delete.php\">");
        print("<tr class=\"$table_separator_string\">\n");
        print("    <td><a href=\"\"  onclick=\"javascript:window.open('task_show.php?task_id=".$row["tid"]."','mywindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=350,height=200')\">" . $row["title"] . "</a></td>\n"); //Added Link to task_show.php Matt Palmerlee 5/16/2003 
        print("    <td>" . $row["name"] . "</td>\n");
        if($ALLOW_ADMIN_VIEW_ALL_TASKS && $isAdmin)
        {
            print("    <td>" . $row["assigned_by"] . "</td>\n");
        }
		print("    <td>" . $priority . "</td>\n");
        print("    <td>" . convert_date($row["due_date"]) . "</td>\n");
        print("<td>\n<INPUT TYPE=\"hidden\" name=\"task_name\" value=\"" . $row["title"] ."\">\n");
        print("<INPUT TYPE=\"hidden\" name=\"tid\" value=\"" . $row["tid"] ."\">\n");
        print("<INPUT TYPE=\"submit\" value=\"Unassign Task\" NAME=\"unassign" . $row["tid"] . "\">\n</td>");
        print("</form>");
        print("<form METHOD=\"POST\" ACTION=\"task_pending_edit.php\">\n");
        print("<td>\n");
        print("<INPUT TYPE=\"hidden\" name=\"edit_pending_name\" value=\"" . $row["title"] . "\">\n");
        print("<INPUT TYPE=\"hidden\" name=\"edit_pending\" value=\"" . $row["tid"] . "\">\n");
        print("<INPUT TYPE=\"submit\" value=\"Edit This Task\">\n");
        print("</td>\n");
        print("</tr>\n");
        print("</form>\n");

        if($viewAssigned == "Hide")
        {
			$info = nl2br($row["info"]);
            print("<tr class=\"$table_separator_string\">\n");
            print("<td>&nbsp;</td>");
            print("<td colspan=\"$info_colspan\">Assigned On: " . convert_date($row["date_assigned"]) . "<br>\n$info</td>");
            print("</tr>");
        }
    }
	if($row_separator_num == 0) //they have no assigned tasks
	{
		print("<tr class=\"$table_separator_string\">\n<td colspan=\"6\">No Current Assigned Tasks</td></tr>\n");
	}
    print($ASSIGNED_END);
}
db_close();
include("footer.php"); 
?>
Return current item: Internet Task Management System