Location: PHPKode > projects > Insecticida > insecticida_wiki/main2.php
<?
###################################################
#Copyright (C) 2001 Stuart Wigley (hide@address.com)
#
#main.php 19/04/2001
#
#This file is part of workbench.
#
#workbench 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.
#
#workbench 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 workbench; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#####################################################
session_register("login");
session_register("group");
session_register("thisuserID");
require_once("config.php");

# if user has logged in get $login from session
if ($HTTP_SESSION_VARS["login"] && session_is_registered("login"))
{
	$login = $HTTP_SESSION_VARS["login"];
	require_once("$path/connect.php");
	require_once("$path/general.php");
	include("$path/header.php");
	
$profile = 0;
$time1 = getmicrotime();

  $today = currentDate( $now );
  $mydate = $today->mydate;
  $tomorrow = nextDays( $today, 1 );
  $thisMonday = prevMondayForWeek( $today, 0 );
  $prevMonday = prevMondayForWeek( $today, 1 );
  $prev2Monday = prevMondayForWeek( $today, 2 );
  $prev3Monday = prevMondayForWeek( $today, 3 );
  $prev7Monday = prevMondayForWeek( $today, 7 );
  $prev11Monday = prevMondayForWeek( $today, 11 );
  $prev15Monday = prevMondayForWeek( $today, 15 );
  $prev19Monday = prevMondayForWeek( $today, 19 );
  $prev23Monday = prevMondayForWeek( $today, 23 );
  $prev27Monday = prevMondayForWeek( $today, 27 );
  $prev31Monday = prevMondayForWeek( $today, 31 );
  $prev35Monday = prevMondayForWeek( $today, 35 );
  
	# queries
	$query = mysql_query("select * from users where users.login='$login'") or die(mysql_error());
	$result = mysql_fetch_array($query);
	$query2 = mysql_query("select * from groups where grpID='$result[grpID]'") or die(mysql_error());
	$result2 = mysql_fetch_array($query2);
	$query3 = mysql_query("select * from bugs where assTo='$login' and statusID!='3'") or die(mysql_error());
	$queryInvestigating = mysql_query("select * from bugs where assTo='$login' and statusID = '11'") or die(mysql_error());
	$queryEstimated = mysql_query("select * from bugs where assTo='$login' and (estimate like '% Know' or estimateDatetime is null)") or die(mysql_error());
	$queryOverDue = mysql_query("select * from bugs where assTo='$login' and dueDate != '' and dueDate <= '" . $myyear . "/" . $mymon . "/" . $myday . "'") or die(mysql_error());
	$query4 = mysql_query("select email from users where userID='1'") or die(mysql_error());
	$result4 = mysql_fetch_array($query4);
	$query5 = mysql_query("select * from bugs where openedBy='$login' and statusID!='3'") or die(mysql_error());
	# update accessLog table
	$query7 = mysql_query("select * from accessLog where sessionID='".session_id()."'") or die(mysql_error());
	if (!mysql_num_rows($query7))
	{
		mysql_query("insert into accessLog (logID,sessionID,date,useragent,userID) values('','".session_id()."','$now','$HTTP_USER_AGENT','$result[userID]')") or die(mysql_error());
	}
?>
<table cellspacing="0" class="table3">
	<tr class="rowtitle">
		<td><h5>Hello <?=$result[fName]." ".$result[sName]?> (<?=$login?>) and welcome to <?=$theVersion?></h5></td>
	</tr>
	<tr>
    	<td><p>I am a <i> <?=$result2[grpName]?></i>. If this is inaccurate I will contact the <a class="nav2" href="mailto:<?=$result4[email]?>">Administrator</a>.</p></td>
	</tr>
   	<tr>
    	<td><p>Issues assigned to me: <a class="nav2" href="<?=$relative?>/bugtracking/viewbugs.php?assTo=<?=$login?>"><?=mysql_num_rows($query3)?></a>. 
<?
	if ($result[grpID] == '2' || $result[grpID] == '3')
	{
		echo( "I'm investigating <a class=\"nav2\" href=\"" . $relative . "/bugtracking/viewbugs.php?assTo=" . $login . "&status=11\">" );
		echo( mysql_num_rows( $queryInvestigating ) );
		echo( "</a> issues." );
		$estim = mysql_num_rows( $queryEstimated );
		if ( $estim > 0 )
		{
		   echo( " I have <strong>" );
		   echo( $estim );
		   echo( "</strong> issues not estimated." );
		}
		$overDue = mysql_num_rows( $queryOverDue );
		if ( $overDue > 0 )
		{
		   echo( " I have <strong>" );
		   echo( $overDue );
		   echo( "</strong> issues overdue." );
		}
	}
?></p>
	<p> Outstanding issues opened by me : <a class="nav2" href="<?=$relative?>/bugtracking/viewbugs.php?openBy=<?=$login?>"><?=mysql_num_rows($query5)?></a></p>
            <p>Project Statistics:</p>
	<ul>
	<div>
            <p>Project is 100% operational.</p>
<?
  $periodName[ 1 ] = "Today";
  	$dateFirst[ 1 ] = "$mydate"; $dateLast[ 1 ] = "$tomorrow";
  $periodName[ 2 ] = "This Week";
  	$dateFirst[ 2 ] = "$thisMonday"; $dateLast[ 2 ] = "$tomorrow";
  $periodName[ 3 ] = "Week - 1";
  	$dateFirst[ 3 ] = "$prevMonday"; $dateLast[ 3 ] = "$thisMonday";
  $periodName[ 4 ] = "Week - 2";
  	$dateFirst[ 4 ] = "$prev2Monday"; $dateLast[ 4 ] = "$prevMonday";
  $periodName[ 5 ] = "Week - 3";
  	$dateFirst[ 5 ] = "$prev3Monday"; $dateLast[ 5 ] = "$prev2Monday";
  $periodName[ 6 ] = "Month - 1";
  	$dateFirst[ 6 ] = "$prev7Monday"; $dateLast[ 6 ] = "$prev3Monday";
  $periodName[ 7 ] = "Month - 2";
  	$dateFirst[ 7 ] = "$prev11Monday"; $dateLast[ 7 ] = "$prev7Monday";
  $periodName[ 8 ] = "Month - 3";
  	$dateFirst[ 8 ] = "$prev15Monday"; $dateLast[ 8 ] = "$prev11Monday";
  $periodName[ 9 ] = "Month - 4";
  	$dateFirst[ 9 ] = "$prev19Monday"; $dateLast[ 9 ] = "$prev15Monday";
  $periodName[ 10 ] = "Month - 5";
  	$dateFirst[ 10 ] = "$prev23Monday"; $dateLast[ 10 ] = "$prev19Monday";
  $periodName[ 11 ] = "Month - 6";
  	$dateFirst[ 11 ] = "$prev27Monday"; $dateLast[ 11 ] = "$prev23Monday";
  $periodName[ 12 ] = "Month - 7";
  	$dateFirst[ 12 ] = "$prev31Monday"; $dateLast[ 12 ] = "$prev27Monday";
  $periodName[ 13 ] = "Month - 8";
  	$dateFirst[ 13 ] = "$prev35Monday"; $dateLast[ 13 ] = "$prev31Monday";

  # echo "today =", $mydate, "=", $dateFirst[1] . "<BR>";
  # echo "tomorrow =", $tomorrow, "=", $dateLast[1] . "<BR>";
  # echo $thisMonday . "<BR>";

?>
<table cellspacing="0" class="table5">
	<tr class="rowtitle">
		<td><h5>Period </h5> </td>
		<td align=right><h5>Opened </h5> </td>
		<td align=right><h5>Reopened </h5> </td>
		<td align=right><h5>Checked-in </h5> </td>
		<td align=right><h5>Closed </h5> </td>
	</tr>
<?
$time3 = getmicrotime();
if ( $profile == 1 ) echo "<p>Time elapsed: ", $time3 - $time1, " seconds";
$bgcolor = "#dddddd"; 
for ( $i = 1; $i <= 13; $i++ )
{
	$queryOpen = mysql_query( "select * from bugs where openDateTime >= '$dateFirst[$i]' and openDateTime < '$dateLast[$i]'" ) or die( mysql_error() );
	$queryReopen = mysql_query( "select * from bugs where reopenDateTime >= '$dateFirst[$i]' and reopenDateTime < '$dateLast[$i]'" ) or die( mysql_error() );
	$queryCheckIn = mysql_query( "select * from bugs where checkinDateTime >= '$dateFirst[$i]' and checkinDateTime < '$dateLast[$i]'" ) or die( mysql_error() );
	$queryClose = mysql_query( "select * from bugs where closeDateTime >= '$dateFirst[$i]' and closeDateTime < '$dateLast[$i]'" ) or die( mysql_error() );
	if ($bgcolor == "#dddddd")
        {
             $bgcolor = "#eeeeee";
        }
        elseif ($bgcolor == "#eeeeee")
        {
             $bgcolor = "#dddddd";
        } 
 	echo("<tr bgcolor=\"$bgcolor\">");
?>
            <td><?= $periodName[$i] ?></td>
	    <td align=right><strong> 
	<? 
	   $number = mysql_num_rows( $queryOpen );
	   if ( $number != 0 )
           {
		echo( $number );
	   }
	   else {
		echo( "&nbsp;" );
	   }
        ?> 
	    </strong></td>
	    <td align=right><strong> 
	<? 
	   $number = mysql_num_rows( $queryReopen );
	   if ( $number != 0 )
           {
		echo( $number );
	   }
	   else {
		echo( "&nbsp;" );
	   }
        ?> 
		</strong></td>
	    <td align=right><strong> 
	<? 
	   $number = mysql_num_rows( $queryCheckIn );
	   if ( $number != 0 )
           {
		echo( $number );
	   }
	   else {
		echo( "&nbsp;" );
	   }
        ?> 
		</strong></td>
	    <td align=right><strong> 
	<? 
	   $number = mysql_num_rows( $queryClose );
	   if ( $number != 0 )
           {
		echo( $number );
	   }
	   else {
		echo( "&nbsp;" );
	   }
        ?> 
		</strong></td>
	</tr>
<?
}
$time4 = getmicrotime();
if ( $profile == 1 ) echo "<p>Time elapsed: ", $time4 - $time3, " seconds";
?>
</tr>
</table>
	</div>
	</ul>
	</table>
<?
           
}
else {
	include("login.php");
}
include("footer.php");

$time2 = getmicrotime();
if ( $profile == 1 ) echo "<p>Time elapsed: ", $time2 - $time1, " seconds";
?>
Return current item: Insecticida