<?php
require_once('session.php');
require_once('global4app.php');
if ($_SESSION['uid'] == "")
{
echo '<html><head><meta http-equiv="refresh" content="5; URL=index.php"></head><body>';
echo '<center>Fatal Error. You haven\'t logged in properly<br/><a href=index.php>'.'Click Here To exit and login again </a> (forwarded in 5 sec.)</center></body></html>';
exit();
}
?>
<html>
<head>
<title>Timesheet4dP : Task Logs</title>
<link rel=stylesheet type="text/css" href="./css/main.css">
<script language="javascript" type="text/javascript" src="./js/getObj.js"></script>
<script>
function acceptTask(costCodeList, task_id)
{
//alert(getObj(costCodeList).value +" - "+ task_id);
var http = getHTTPObject();
var URLString = 'updateTask.php'
http.open("POST", URLString, true);
var params = "task_id=" + task_id + "&task_costcode=" + getObj(costCodeList).value;
//alert (params);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");
http.onreadystatechange = function()
{
if (http.readyState == 4)
{
var replyValue = http.responseText;
alert (replyValue);
//history.go(0);
location.reload(true);
//location.href = 'getMyTaskLogs.php';
}
}
http.send(params);
}
function deleteTask(task_id)
{
result = confirm ('Are you certain to delete this task ?');
if(result)
{
var http = getHTTPObject();
var URLString = 'deleteTask.php'
http.open("POST", URLString, true);
var params = "task_id=" + task_id ;
//alert (params);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");
http.onreadystatechange = function()
{
if (http.readyState == 4)
{
var replyValue = http.responseText;
alert (replyValue);
//history.go(0);
location.reload(true);
//location.href = 'getMyTaskLogs.php';
}
}
http.send(params);
}
}
</script>
</head>
<body class=" yui-skin-sam" bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<br><br>
<table width=90% cellpadding=7 cellspacing=1 border=1 align=center valign=center>
<tr>
<td colspan=8 align=left>Logged in as - <? echo $_SESSION["username"]?></td>
<td align=right colspan=2><a href="startPage.php"><b><h1>Home</h1></b></a></td>
</tr>
<tr><td colspan=6><form method=POST action=getMyTaskLogs.php>Select a user to view his/her logs...
<input type=hidden id=selectedUsername name=selectedUsername>
<select id=selecteduser name=selecteduser onChange="javascript:document.forms[0].selectedUsername.value =document.forms[0].selecteduser.options[document.forms[0].selecteduser.selectedIndex].text;document.forms[0].submit();"><option value=0>Select a user</option>
<?php
if ($_SESSION["admin"] == "true")
{
$result = db_loadList('select * from users where user_username != \'admin\'');
foreach($result as $row)
{
echo '<option value='.$row['user_id'].'>'.$row['user_username'].'</option>';
}
}
else
{
echo '<option value='.$_SESSION['uid'].'>'.$_SESSION['username'].'</option>';
$result = db_loadList('select * from users where user_reporting_to = \''.$_SESSION['uid'].'\'');
foreach($result as $row)
{
echo '<option value='.$row['user_id'].'>'.$row['user_username'].'</option>';
}
}
?>
</select>
</td><td colspan=4><a href="graphInputs.php">User Graphs</a> <a href=pgraphs.php>Utilization Report</a></td></tr>
<?php
if ($_POST['selectedUsername'] == "")
{
?>
<tr><td colspan=10 align=center> Last 60 task logs displayed for user - <b><? echo $_SESSION['username'] ?></b></td></tr>
<?php
}
else
{
?>
<tr><td colspan=10 align=center> Last 60 task logs displayed for user - <b><? echo $_POST['selectedUsername'] ?></b></td></tr>
<?php
}
?>
<tr>
<td><b>S.No.</b></td>
<td><b>Date</b></td>
<td><b>Company</b></td>
<td><b>Project</b></td>
<td><b>Task</b></td>
<td><b>Description</b></td>
<td><b>Duration</b></td>
<td><b>Status</b></td>
<td><b>Cost Code</b></td>
<td><b>Accept/ Delete</b></td>
</tr>
<?php
//get session uid and then bring the last 60 task logs entred by him... for display :)
//echo $_SESSION['uid'];
$Row_count = 1;
$billginCodeSQL= 'select * from dotproject.billingcode where company_id = 0 order by billingcode_value';
$bc_result = db_loadList($billginCodeSQL);
$bc_codes = "<option value=-1>Select Code</option>";
foreach($bc_result as $row)
{
$bc_codes = $bc_codes . '<option value='.$row['billingcode_id'].'>'.$row['billingcode_name'].' - '.$row['billingcode_value'].'</option>';
}
$bc_codes = $bc_codes . '</select>';
$returnArray = array();
//echo 'select * from tasks where task_project = '. $_POST['projectId'];
$limited = "no";
if (($_REQUEST['selecteduser'] == "") || $_REQUEST['selecteduser'] == $_SESSION['uid'])
{
$getAllTasks_query = 'SELECT task_log_id, task_log_costcode, task_log_date as ts1, DATE_FORMAT(task_log_date,"%a,%D-%b-%Y" ) as task_log_date, company_name, project_name, task_name, Concat(task_log_name, \' || \', task_log_description) as task_log_description, task_log_hours, task_approved FROM dotproject.task_log, dotproject.tasks, dotproject.projects, dotproject.companies where task_log_creator = '.$_SESSION['uid'].' and task_log_task = task_id and task_project = project_id and project_company = company_id order by ts1 desc limit 0,60';
$limited = "yes";
}
else
$getAllTasks_query = 'SELECT task_log_id, task_log_costcode, task_log_date as ts1, DATE_FORMAT(task_log_date,"%a,%D-%b-%Y" ) as task_log_date, company_name, project_name, task_name, Concat(task_log_name, \' || \', task_log_description) as task_log_description, task_log_hours, task_approved FROM dotproject.task_log, dotproject.tasks, dotproject.projects, dotproject.companies where task_log_creator = '.$_REQUEST['selecteduser'].' and task_log_task = task_id and task_project = project_id and project_company = company_id order by ts1 desc limit 0,60';
//echo $getAllTasks_query;
$result = db_loadList($getAllTasks_query);
foreach($result as $row)
{
$tsk_status = "X";
if ($row['task_approved'] != "0")
{
$tsk_status = "Accepted";
}
//$returnArray[] = $row;
echo "<tr><td>".$Row_count."</td><td>".$row['task_log_date']."</td><td>".$row['company_name']."</td><td>".$row['project_name']."</td><td>".$row['task_name']."</td><td width=530>".$row['task_log_description']."</td><td align=right >".$row['task_log_hours']."</td><td>".$tsk_status."</td> ";
if($limited == "yes" || $tsk_status == "Accepted")
{
echo "<td> ".$row['task_log_costcode']."</td><td>NA </td></tr>";
$Row_count++;
}
else
{
echo "<td> <select id=task".$Row_count.">".$bc_codes."</td><td><a href=# onClick=acceptTask('task".$Row_count++."','".$row['task_log_id']."');>Accept</a> <a href=# onClick=deleteTask('".$row['task_log_id']."');>Delete</a> </td></tr>";
}
}
//echo ('<script>alert(\''.json_encode($returnArray).'\');</script>');
//echo '{"ResultSet":'.json_encode($returnArray).'}';
?></form>
</table>
<br><br>
<hr>
<br><br>
</body>
</html>