function resetConfigValue($fieldName) { include("table_names.inc"); //get the default value list($qh, $num) = dbQuery("SELECT $fieldName FROM $CONFIG_TABLE WHERE config_set_id='0';"); $resultset = dbResult($qh); //set it dbQuery("UPDATE $CONFIG_TABLE SET $fieldName='" . $resultset[$fieldName] . "' WHERE config_set_id='1';"); }
function getDailyTimes($month, $day, $year, $id, $proj_id) { include "table_names.inc"; list($qhq, $numq) = dbQuery("select timeformat from {$CONFIG_TABLE} where config_set_id = '1'"); $configData = dbResult($qhq); $query = "select date_format(start_time,'%d') as day_of_month, trans_num, "; if ($configData["timeformat"] == "12") { $query .= "date_format(end_time, '%l:%i%p') as endd, date_format(start_time, '%l:%i%p') as start, "; } else { $query .= "date_format(end_time, '%k:%i') as endd, date_format(start_time, '%k:%i') as start, "; } $query .= "unix_timestamp(end_time) - unix_timestamp(start_time) as diff_sec, " . "unix_timestamp(start_time) as start_time, " . "unix_timestamp(end_time) as end_time, " . "end_time as end_time_str, " . "start_time as start_time_str, " . "{$PROJECT_TABLE}.title as project_title, " . "{$TASK_TABLE}.name, {$TIMES_TABLE}.proj_id, {$TIMES_TABLE}.task_id " . "FROM {$TIMES_TABLE}, {$TASK_TABLE}, {$PROJECT_TABLE} " . "WHERE {$TASK_TABLE}.proj_id={$PROJECT_TABLE}.proj_id AND " . "uid='{$id}' AND "; $query .= "{$TASK_TABLE}.task_id = {$TIMES_TABLE}.task_id AND " . "((start_time >= '{$year}-{$month}-{$day} 00:00:00' AND start_time <= '{$year}-{$month}-{$day} 23:59:59') " . " OR (end_time >= '{$year}-{$month}-{$day} 00:00:00' AND end_time <= '{$year}-{$month}-{$day} 23:59:59') " . " OR (start_time < '{$year}-{$month}-{$day} 00:00:00' AND end_time > '{$year}-{$month}-{$day} 23:59:59')) " . " order by day_of_month, start_time"; list($my_qh, $num) = dbQuery($query); return array($num, $my_qh); }
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table_body"> <tr class="inner_table_head"> <td class="inner_table_column_heading">First Name</td> <td class="inner_table_column_heading">Last Name</td> <td class="inner_table_column_heading">Access</td> <td class="inner_table_column_heading">Login Username</td> <td class="inner_table_column_heading">Email Address</td> <td class="inner_table_column_heading">Phone Number</td> <td class="inner_table_column_heading">Bill Rate</td> <td class="inner_table_column_heading"><i>Actions</i></td> </tr> <? list($qh,$num) = dbQuery("select * from $USER_TABLE where username!='guest' order by last_name, first_name"); while ($data = dbResult($qh)) { $firstNameField = empty($data["first_name"]) ? " ": $data["first_name"]; $lastNameField = empty($data["last_name"]) ? " ": $data["last_name"]; $usernameField = empty($data["username"]) ? " ": $data["username"]; $emailAddressField = empty($data["email_address"]) ? " ": $data["email_address"]; $phoneField = empty($data["phone"]) ? " ": $data["phone"]; $billRateField = empty($data["bill_rate"]) ? " ": $data["bill_rate"]; $isAdministrator = ($data["level"] >= 10); print "<tr>\n"; print "<td class=\"calendar_cell_middle\">$firstNameField</td>"; print "<td class=\"calendar_cell_middle\">$lastNameField</td>"; if ($isAdministrator) print "<td class=\"calendar_cell_middle\"><span class=\"calendar_total_value_weekly\">Admin</span></td>"; else print "<td class=\"calendar_cell_middle\">Basic</td>";
/** * returns true if there is a record under that username in the database */ function userExists($username) { require "table_names.inc"; //check whether the user exists list($qh, $num) = dbQuery("select username from {$USER_TABLE} where username='******'"); //if there is a match return $data = dbResult($qh); }
//print "<PRE>$data[date]\n$data[time]\n$data[log_message]\n$data[title]\n$data[client]\n$data[first_name]\n$data[last_name]</PRE>"; ?> <html> <head> <title>Task Info</title> <? include ("header.inc"); ?> </head> <body width="100%" height="100%" style="margin: 0px;" <? include ("body.inc"); ?> > <table border="0" width="100%" height="100%" align="center" valign="center"> <? list($qh, $num) = dbQuery($query); if ($num > 0) { $data = dbResult($qh); ?> <tr> <td> <table width="100%" border="0" class="section_body"> <tr> <td> <span class="label">Project:</span> <span class="project_title"><?php echo stripslashes($data["projectTitle"]); ?></span> <span class="project_status"><<?php echo $data["projectStatus"]; ?>></span> </td> </tr> <tr> <td> <span class="label">Task:</span>
function clockoff($timeString) { include("table_names.inc"); //import global vars global $contextUser, $year, $month, $day, $task_id, $proj_id, $Location; global $destination, $clock_on_time_hour, $clock_off_time_hour, $clock_on_time_min, $clock_off_time_min, $clockonoff; global $log_message, $log_message_presented, $fromPopupWindow; //check that we are actually clocked on $querystring = "SELECT start_time, start_time < '$timeString' AS valid FROM $TIMES_TABLE WHERE ". "uid='$contextUser' AND ". "end_time=0 AND ". //"start_time >= '$year-$month-$day' AND ". //"start_time <= '$year-$month-$day 23:59:59' AND ". "proj_id=$proj_id AND ". "task_id=$task_id"; list($qh,$num) = dbQuery($querystring); $data = dbResult($qh); if ($num == 0) errorPage("You are not currently clocked on. You must clock on before you can clock off.", $fromPopupWindow); //also check that the clockoff time is after the clockon time else if ($data["valid"] == 0) errorPage("You must clock off <i>after</i> you clock on.", $fromPopupWindow); //do we need to present the user with a log message screen? if ($log_message_presented == false) getLogMessage(); //now insert the record for this clock off $log_message = addslashes($log_message); $querystring = "UPDATE $TIMES_TABLE SET log_message='$log_message', end_time='$timeString' WHERE ". "uid='$contextUser' AND ". "proj_id=$proj_id AND ". "end_time=0 AND ". //"start_time >= '$year-$month-$day' AND ". //"start_time < '$year-$month-$day 23:59:59' AND ". "task_id=$task_id"; list($qh,$num) = dbQuery($querystring); Header("Location: $Location"); }
} // Connect to database. $dbh = dbConnect(); $contextUser = strtolower($_SESSION['contextUser']); //define the command menu include("timesheet_menu.inc"); //Get the result set for the config set 1 list($qh, $num) = dbQuery("select locale, timezone, timeformat, headerhtml, bodyhtml, footerhtml, " . "errorhtml, bannerhtml, tablehtml, useLDAP, LDAPScheme, LDAPHost, LDAPPort, " . "LDAPBaseDN, LDAPUsernameAttribute, LDAPSearchScope, LDAPFilter, LDAPProtocolVersion, ". "LDAPBindUsername, LDAPBindPassword, weekstartday " . "from $CONFIG_TABLE where config_set_id = '1'"); $resultset = dbResult($qh); ?> <html> <head> <title>Timesheet.php Configuration Parameters</title> <? include ("header.inc"); ?> </head> <script language="Javascript"> //store the current LDAP entry method in this variable var currentLDAPEntryMethod = 'normal'; function onChangeLDAPEntryMethod() {
?> </table> </td> <td width="30%"> <div class="project_task_list"> <a href="task_maint.php?proj_id=<?php echo $data["proj_id"]; ?>"><span class="label">Tasks:</span></a> <br> <?php //get tasks list($qh3, $num_tasks) = dbQuery("select name, task_id FROM $TASK_TABLE WHERE proj_id=$data[proj_id]"); //are there any tasks? if ($num_tasks > 0) { while ($task_data = dbResult($qh3)) { $taskName = str_replace(" ", " ", $task_data["name"]); print "<a href=\"javascript:void(0)\" onclick=window.open(\"task_info.php?proj_id=$data[proj_id]&task_id=$task_data[task_id]\",\"TaskInfo\",\"location=0,directories=no,status=no,menubar=no,resizable=1,width=550,height=220\")>$taskName</a><br>"; } } else print "None."; ?> </div> </td> </tr> </table> </td> </tr> </table> </td>
print "<td width=\"14%\" height=\"25%\" valign=\"top\" class=\"calendar_cell_middle\">\n"; } print "\t<table width=\"100%\">\n"; // Print out date. /*print "<tr><td valign=\"top\"><tt><A HREF=\"daily.php?month=$month&year=$year&". "day=$day&client_id=$client_id&proj_id=$proj_id&task_id=$task_id\">$day</a></tt></td></tr>";*/ $popup_href = "javascript:void(0)\" onclick=window.open(\"popup.php" . "?client_id={$client_id}" . "&proj_id={$proj_id}" . "&task_id={$task_id}" . "&year={$year}" . "&month={$month}" . "&day={$day}" . "&destination={$_SERVER['PHP_SELF']}" . "\",\"Popup\",\"location=0,directories=no,status=no,menubar=no,resizable=1,width=420,height=310\") dummy=\""; print "<tr><td valign=\"top\"><table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">"; print "<tr><td valign=\"top\"><A HREF=\"daily.php?month={$month}&year={$year}&" . "day={$day}&client_id={$client_id}&proj_id={$proj_id}&task_id={$task_id}\">{$day}</a></td>"; print "<td valign=\"top\" align=\"right\"><a href=\"{$popup_href}\" class=\"action_link\">" . "<img src=\"images/add.gif\" width=\"11\" height=\"11\" border=\"0\">" . "</a></td>"; print "</tr>"; print "</table></td></tr>"; $data_seen = 0; // If the day has data, print it. for ($i = 0; $i < $num; $i++) { $data = dbResult($qh, $i); //Due to a bug in mysql with converting to unix timestamp from the string, //we are going to use php's strtotime to make the timestamp from the string. //the problem has something to do with timezones. $data["start_time"] = strtotime($data["start_time_str"]); $data["end_time"] = strtotime($data["end_time_str"]); if ($data["start_time"] < mktime(0, 0, 0, $month, $day, $year) && $data["end_time"] > mktime(23, 59, 59, $month, $day, $year) || $data["start_time"] >= mktime(0, 0, 0, $month, $day, $year) && $data["start_time"] <= mktime(23, 59, 59, $month, $day, $year) || $data["end_time"] >= mktime(0, 0, 0, $month, $day, $year) && $data["end_time"] <= mktime(23, 59, 59, $month, $day, $year)) { // This day has data in it. Therefore we want to print out a summary at the bottom of each day. $data_seen = 1; $todays_total_sec = 0; //print out client name if its a new client if ($client_id == 0 && $last_client_id != $data["client_id"]) { $last_client_id = $data["client_id"]; $clientName = $data["organisation"]; print "<tr><td valign=\"top\" class=\"client_name_small\">{$clientName}</td></tr>"; }
//different (unique) TASKS //which has an array of DAYS (7) which has //and array of size 4: // -index 0 is task entries array for tasks which started on a previous day and finish on a following day // -index 1 is task entries array for tasks which started on a previous day and finish today // -index 2 is task entreis array for tasks which started and finished today // -index 3 is task entries array for tasks which started today and finish on a following day $structuredArray = array(); $previousTaskId = -1; $currentTaskId = -1; //iterate through results for ($i=0; $i<$num5; $i++) { //get the record for this task entry $data = dbResult($qh5,$i); //Due to a bug in mysql with converting to unix timestamp from the string, //we are going to use php's strtotime to make the timestamp from the string. //the problem has something to do with timezones. $data["start_time"] = strtotime($data["start_time_str"]); $data["end_time"] = strtotime($data["end_time_str"]); //get the current task properties $currentTaskId = $data["task_id"]; $currentTaskStartDate = $data["start_time"]; $currentTaskEndDate = $data["end_time"]; $currentTaskName = stripslashes($data["taskName"]); $currentProjectTitle = stripslashes($data["projectTitle"]); $currentProjectId = $data["proj_id"];
$proj_id = $_REQUEST['proj_id']; //define the command menu $commandMenu->add(new TextCommand("Back", true, "javascript:history.back()")); $dbh = dbConnect(); list($qh, $num) = dbQuery("select proj_id, title, client_id, description, DATE_FORMAT(start_date, '%m') as start_month, ". "date_format(start_date, '%d') as start_day, date_format(start_date, '%Y') as start_year, ". "DATE_FORMAT(deadline, '%m') as end_month, date_format(deadline, '%d') as end_day, date_format(deadline, '%Y') as end_year, ". "http_link, proj_status, proj_leader from $PROJECT_TABLE where proj_id = $proj_id order by proj_id"); $data = dbResult($qh); list($qh, $num) = dbQuery("SELECT username from $ASSIGNMENTS_TABLE where proj_id = $proj_id"); $selected_array = array(); $i = 0; while ($datanext = dbResult($qh)) { $selected_array[$i] = $datanext["username"]; $i++; } ?> <html> <head> <title>Edit Project</title> <?php include "header.inc"; ?> </head> <body <? include ("body.inc"); ?> > <?php include "banner.inc";
<table width="100%" border="0" class="section_body"> <tr> <td valign="center"> <span class="project_title"><?php echo stripslashes($data_task["name"]); ?></span> <span class="project_status"><<?php echo $data_task["status"]; ?>></span><br> <? echo stripslashes($data_task["description"]); ?> </td> </tr> <tr> <td align="left" colspan="2" align="top"> <span class="label">Assigned persons:</span><br> <? //get assigned users list($qh3, $num_3) = dbQuery("select username, task_id from $TASK_ASSIGNMENTS_TABLE where task_id=$data_task[task_id]"); if ($num_3 > 0) { while ($data_3 = dbResult($qh3)) { print "$data_3[username] "; } } else { print "<i>None</i>"; } ?> </td> <tr> </table> </td> </tr> <?php }
if ($action == "delete") { dbquery("delete from {$USER_TABLE} where uid='{$uid}'"); dbquery("delete from {$ASSIGNMENTS_TABLE} where username='******'"); dbquery("delete from {$TASK_ASSIGNMENTS_TABLE} where username='******'"); } else { if ($action == "addupdate") { //set the level if ($isAdministrator == "true") { $level = 11; } else { $level = 1; } //check whether the user exists, and get his encrypted password. list($qh, $num) = dbQuery("select username, password from {$USER_TABLE} where uid='{$uid}'"); //if there is a match if ($data = dbResult($qh)) { //has the username changed if ($data["username"] != $username) { //update the assignments dbQuery("UPDATE {$ASSIGNMENTS_TABLE} SET username='******' WHERE username='******'username']}'"); dbQuery("UPDATE {$TASK_ASSIGNMENTS_TABLE} SET username='******' WHERE username='******'username']}'"); dbQuery("UPDATE {$PROJECT_TABLE} SET proj_leader='{$username}' WHERE proj_leader='{$data['username']}'"); } if ($data["password"] == $password) { //then we are not updating the password dbquery("UPDATE {$USER_TABLE} SET first_name='{$first_name}', last_name='{$last_name}', " . "username='******', " . "email_address='{$email_address}', phone='{$phone}', bill_rate='{$bill_rate}', " . "level='{$level}' " . "WHERE uid='{$uid}'"); } else { //set the password as well dbquery("UPDATE {$USER_TABLE} SET first_name='{$first_name}', last_name='{$last_name}', " . "username='******', " . "email_address='{$email_address}', phone='{$phone}', bill_rate='{$bill_rate}', " . "level='{$level}', " . "password={$DATABASE_PASSWORD_FUNCTION}('{$password}') " . "WHERE username='******'"); } } else {
//print "<p>there were $num3 results</p>"; //we're going to put the data into an array of //different (unique) TASKS //which has an array of DAYS (7) which has //and array of size 4: // -index 0 is task entries array for tasks which started on a previous day and finish on a following day // -index 1 is task entries array for tasks which started on a previous day and finish today // -index 2 is task entreis array for tasks which started and finished today // -index 3 is task entries array for tasks which started today and finish on a following day $structuredArray = array(); $previousTaskId = -1; $currentTaskId = -1; //iterate through results for ($i = 0; $i < $num3; $i++) { //get the record for this task entry $data = dbResult($qh3, $i); //Due to a bug in mysql with converting to unix timestamp from the string, //we are going to use php's strtotime to make the timestamp from the string. //the problem has something to do with timezones. $data["start_time"] = strtotime($data["start_time_str"]); $data["end_time"] = strtotime($data["end_time_str"]); //get the current task properties $currentTaskId = $data["task_id"]; $currentTaskStartDate = $data["start_time"]; $currentTaskEndDate = $data["end_time"]; $currentTaskName = $data["taskName"]; $currentProjectTitle = $data["projectTitle"]; $currentProjectId = $data["proj_id"]; $currentClientName = $data["clientName"]; //debug //print "<p>taskId:$currentTaskId '$data[taskName]', start time:$data[start_time_str], end time:$data[end_time_str]</p>";