function show_users_stats($template) { global $TPL; global $db; $stats = new stats(); $projects = $stats->project_stats(); $tasks = $stats->task_stats(); $comments = $stats->comment_stats(); $persons = array(); $query = "SELECT * FROM person ORDER BY username"; $db->query($query); while ($db->next_record()) { $person = new person(); $person->read_db_record($db); array_push($persons, $person->get_id()); } usort($persons, "compare"); for ($i = 0; $i < count($persons); $i++) { $person = new person(); $person->set_id($persons[$i]); $person->select(); $TPL["user_username"] = $person->get_value("username"); $TPL["user_projects_current"] = $projects["current"][$person->get_id()] + 0; $TPL["user_projects_total"] = $projects["current"][$person->get_id()] + $projects["archived"][$person->get_id()]; $TPL["user_tasks_current"] = $tasks["current"][$person->get_id()] + 0; $TPL["user_tasks_total"] = $tasks["current"][$person->get_id()] + $tasks["completed"][$person->get_id()]; $TPL["user_comments_total"] = $comments["total"][$person->get_id()] + 0; $TPL["user_graph"] = "<a href=\"" . $TPL["url_alloc_statsImage"] . "id=" . $person->get_id() . "&width=640&multiplier=8&labels=true\">"; $TPL["user_graph"] .= "<img alt=\"User graph\" src=\"" . $TPL["url_alloc_statsImage"] . "id=" . $person->get_id() . "&width=400&multiplier=2\"></a>"; if ($TPL["user_projects_total"] + $TPL["user_tasks_total"] + $TPL["user_comments_total"] > 0) { $TPL["odd_even"] = $TPL["odd_even"] == "odd" ? "even" : "odd"; include_template($template); } } }
function find_email($debug = false, $get_blobs = false, $ignore_date = false) { $info = inbox::get_mail_info(); $mailbox = $this->get_value("commentMaster") . $this->get_value("commentMasterID"); $mail = new email_receive($info); $mail->open_mailbox(config::get_config_item("allocEmailFolder") . "/" . $mailbox, OP_HALFOPEN + OP_READONLY); $mail->check_mail(); $msg_nums = $mail->get_all_email_msg_uids(); $debug and print "<hr><br><b>find_email(): " . date("Y-m-d H:i:s") . " found " . count($msg_nums) . " emails for mailbox: " . $mailbox . "</b>"; // fetch and parse email foreach ((array) $msg_nums as $num) { $debug and print "<hr><br>Examining message number: " . $num; unset($mimebits); // this will stream output $mail->set_msg($num); $mail->get_msg_header(); $text = $mail->fetch_mail_text(); list($from1, $e1n) = parse_email_address($mail->mail_headers["from"]); list($from2, $e2n) = parse_email_address($this->get_value("commentCreatedUserText")); if (!$from2 && $this->get_value("commentCreatedUser")) { $p = new person(); $p->set_id($this->get_value("commentCreatedUser")); $p->select(); $from2 = $p->get_value("emailAddress"); } if (!$from2 && $this->get_value("commentCreatedUserClientContactID")) { $p = new clientContact(); $p->set_id($this->get_value("commentCreatedUserClientContactID")); $p->select(); $from2 = $p->get_value("clientContactEmail"); } $text1 = str_replace(array("\\s", "\n", "\r"), "", trim($text)); $text2 = str_replace(array("\\s", "\n", "\r"), "", trim($this->get_value("comment"))); $date = format_date("U", $this->get_value("commentCreatedTime")); $date1 = strtotime($mail->mail_headers["date"]) - 300; $date3 = strtotime($mail->mail_headers["date"]) + 300; similar_text($text1, $text2, $percent); if ($percent >= 99 && ($from1 == $from2 || !$from2 || same_email_address($from1, config::get_config_item("AllocFromEmailAddress"))) && ($date > $date1 && $date < $date3 || $ignore_date)) { $debug and print "<br><b style='color:green'>Found you! Msg no: " . $num . " in mailbox: " . $mailbox . " for commentID: " . $this->get_id() . "</b>"; foreach ((array) $mail->mail_parts as $v) { $s = $v["part_object"]; // structure $raw_data = imap_fetchbody($mail->connection, $mail->msg_uid, $v["part_number"], FT_UID | FT_PEEK); $thing = $mail->decode_part($s->encoding, $raw_data); $filename = $mail->get_parameter_attribute_value($s->parameters, "name"); $filename or $filename = $mail->get_parameter_attribute_value($s->parameters, "filename"); $filename or $filename = $mail->get_parameter_attribute_value($s->dparameters, "name"); $filename or $filename = $mail->get_parameter_attribute_value($s->dparameters, "filename"); $bits = array(); $bits["part"] = $v["part_number"]; $bits["name"] = $filename; $bits["size"] = strlen($thing); $get_blobs and $bits["blob"] = $thing; $filename and $mimebits[] = $bits; } $mail->close(); return array($mail, $text, $mimebits); } else { similar_text($text1, $text2, $percent); $debug and print "<br>TEXT: " . sprintf("%d", $text1 == $text2) . " (" . sprintf("%d", $percent) . "%)"; #$debug and print "<br>Text1:<br>".$text1."<br>* * *<br>"; #$debug and print "Text2:<br>".$text2."<br>+ + +</br>"; $debug and print "<br>FROM: " . sprintf("%d", $from1 == $from2 || !$from2 || same_email_address($from1, config::get_config_item("AllocFromEmailAddress"))); $debug and print " From1: " . page::htmlentities($from1); $debug and print " From2: " . page::htmlentities($from2); $debug and print "<br>DATE: " . sprintf("%d", $date > $date1 && $date < $date3) . " (" . date("Y-m-d H:i:s", $date) . " | " . date("Y-m-d H:i:s", $date1) . " | " . date("Y-m-d H:i:s", $date3) . ")"; $debug and print "<br>"; } } $mail->close(); return array(false, false, false); }
function get_all_parties($projectID = "") { $db = new db_alloc(); $interestedPartyOptions = array(); if ($_GET["projectID"]) { $projectID = $_GET["projectID"]; } else { if (!$projectID) { $projectID = $this->get_value("projectID"); } } if ($projectID) { $project = new project($projectID); $interestedPartyOptions = $project->get_all_parties(false, $this->get_id()); } $extra_interested_parties = config::get_config_item("defaultInterestedParties") or $extra_interested_parties = array(); foreach ($extra_interested_parties as $name => $email) { $interestedPartyOptions[$email]["name"] = $name; } if ($this->get_value("creatorID")) { $p = new person(); $p->set_id($this->get_value("creatorID")); $p->select(); if ($p->get_value("emailAddress")) { $interestedPartyOptions[$p->get_value("emailAddress")]["name"] = $p->get_name(); $interestedPartyOptions[$p->get_value("emailAddress")]["role"] = "creator"; $interestedPartyOptions[$p->get_value("emailAddress")]["personID"] = $this->get_value("creatorID"); } } if ($this->get_value("personID")) { $p = new person(); $p->set_id($this->get_value("personID")); $p->select(); if ($p->get_value("emailAddress")) { $interestedPartyOptions[$p->get_value("emailAddress")]["name"] = $p->get_name(); $interestedPartyOptions[$p->get_value("emailAddress")]["role"] = "assignee"; $interestedPartyOptions[$p->get_value("emailAddress")]["personID"] = $this->get_value("personID"); $interestedPartyOptions[$p->get_value("emailAddress")]["selected"] = 1; } } if ($this->get_value("managerID")) { $p = new person(); $p->set_id($this->get_value("managerID")); $p->select(); if ($p->get_value("emailAddress")) { $interestedPartyOptions[$p->get_value("emailAddress")]["name"] = $p->get_name(); $interestedPartyOptions[$p->get_value("emailAddress")]["role"] = "manager"; $interestedPartyOptions[$p->get_value("emailAddress")]["personID"] = $this->get_value("managerID"); $interestedPartyOptions[$p->get_value("emailAddress")]["selected"] = 1; } } // return an aggregation of the current task/proj/client parties + the existing interested parties $interestedPartyOptions = interestedParty::get_interested_parties("task", $this->get_id(), $interestedPartyOptions); return $interestedPartyOptions; }
function get_all_parties($projectID = "") { $db = new db_alloc(); $interestedPartyOptions = array(); if (!$projectID && is_object($this)) { $projectID = $this->get_value("projectID"); } if ($projectID) { $project = new project($projectID); $interestedPartyOptions = $project->get_all_parties(); } $extra_interested_parties = config::get_config_item("defaultInterestedParties") or $extra_interested_parties = array(); foreach ($extra_interested_parties as $name => $email) { $interestedPartyOptions[$email] = array("name" => $name); } if (is_object($this)) { if ($this->get_value("personID")) { $p = new person(); $p->set_id($this->get_value("personID")); $p->select(); $p->get_value("emailAddress") and $interestedPartyOptions[$p->get_value("emailAddress")] = array("name" => $p->get_name(), "selected" => true, "personID" => $this->get_value("personID")); } if ($this->get_value("productSaleCreatedUser")) { $p = new person(); $p->set_id($this->get_value("productSaleCreatedUser")); $p->select(); $p->get_value("emailAddress") and $interestedPartyOptions[$p->get_value("emailAddress")] = array("name" => $p->get_name(), "selected" => true, "personID" => $this->get_value("productSaleCreatedUser")); } $this_id = $this->get_id(); } // return an aggregation of the current proj/client parties + the existing interested parties $interestedPartyOptions = interestedParty::get_interested_parties("productSale", $this_id, $interestedPartyOptions); return $interestedPartyOptions; }
function get_all_parties($projectID = "") { $db = new db_alloc(); $interestedPartyOptions = array(); if (!$projectID && is_object($this)) { $projectID = $this->get_value("projectID"); } if ($projectID) { $project = new project($projectID); $interestedPartyOptions = $project->get_all_parties(); } $extra_interested_parties = config::get_config_item("defaultInterestedParties") or $extra_interested_parties = array(); foreach ($extra_interested_parties as $name => $email) { $interestedPartyOptions[$email] = array("name" => $name); } if (is_object($this)) { if ($this->get_value("personID")) { $p = new person(); $p->set_id($this->get_value("personID")); $p->select(); $p->get_value("emailAddress") and $interestedPartyOptions[$p->get_value("emailAddress")] = array("name" => $p->get_value("firstName") . " " . $p->get_value("surname"), "role" => "assignee", "selected" => false, "personID" => $this->get_value("personID")); } if ($this->get_value("approvedByManagerPersonID")) { $p = new person(); $p->set_id($this->get_value("approvedByManagerPersonID")); $p->select(); $p->get_value("emailAddress") and $interestedPartyOptions[$p->get_value("emailAddress")] = array("name" => $p->get_value("firstName") . " " . $p->get_value("surname"), "role" => "manager", "selected" => true, "personID" => $this->get_value("approvedByManagerPersonID")); } $this_id = $this->get_id(); } // return an aggregation of the current task/proj/client parties + the existing interested parties $interestedPartyOptions = interestedParty::get_interested_parties("timeSheet", $this_id, $interestedPartyOptions); return $interestedPartyOptions; }
$item = new item(); $loan = new loan(); $db = new db_alloc(); $db->query("select * from item where itemID=%d", $itemID); $db->next_record(); $item->read_db_record($db); $item->set_values(); // new crap if ($current_user->have_role("admin") || $current_user->have_role("manage")) { $users = array(); $_db = new db_alloc(); $_db->query("SELECT * FROM person ORDER BY username"); while ($_db->next_record()) { $person = new person(); $person->read_db_record($_db); $users[$person->get_id()] = $person->get_value('username'); } $TPL["userSelect"] = "<select name=\"userID\">" . page::select_options($users, $current_user->get_id()) . "</select><br>\n"; } else { $TPL["userSelect"] = ""; } $temp = mktime(0, 0, 0, date("m") + $_POST["timePeriod"], date("d"), date("Y")); $whenToReturn = date("Y", $temp) . "-" . date("m", $temp) . "-" . date("d", $temp); $today = date("Y") . "-" . date("m") . "-" . date("d"); if ($loanID) { $loan->set_id($loanID); $loan->select(); } if ($_POST["borrowItem"]) { $db->query("select * from loan where itemID=%d and dateReturned='0000-00-00'", $itemID); if ($db->next_record()) {
function export_gnome_planner($projectID) { $project = new project(); $project->set_id($projectID); $project->select(); // Note: DOM_Document is a wrapper that wraps DOMDocument for PHP5 and DomDocument for PHP4 $doc = get_xml_document(); $doc->load(ALLOC_MOD_DIR . "shared" . DIRECTORY_SEPARATOR . "export_templates" . DIRECTORY_SEPARATOR . "template.planner"); // General metadata $rootNode = $doc->getElementsByTagName("project"); $rootNode = $rootNode->item(0); $rootNode->setAttribute("company", config::get_config_item("companyName")); // Get the project manager $projectManager = $project->get_project_manager(); $rootNode->setAttribute("manager", person::get_fullname($projectManager[0])); $rootNode->setAttribute("name", $project->get_value("projectName")); if ($project->get_value("dateActualStart")) { $projectStartDate = export_planner_date(planner_date_timestamp($project->get_value("dateActualStart"))); } else { $projectStartDate = export_planner_date(planner_date_timestamp($project->get_value("dateTargetStart"))); } $rootNode->setAttribute("project-start", $projectStartDate); $resourcesUsed = array(); // Export all tasks in the project $taskOptions["projectIDs"] = array($project->get_id()); $taskOptions["return"] = "array"; $taskOptions["taskView"] = "byProject"; $tasks = task::get_list($taskOptions); // We need to sort by taskID (we assume taskIDs were assigned linearly on import) otherwise Planner will get very confused with ordering foreach ($tasks as $task) { $taskIDs[] = $task['taskID']; } array_multisort($taskIDs, $tasks); $taskRootNode = $doc->getElementsByTagName("tasks"); $taskRootNode = $taskRootNode->item(0); foreach ($tasks as $task) { $taskNode = $doc->createElement("task"); // Use the alloc internal ID rather than pointlessly renumbering things $taskNode->setAttribute("id", $task["taskID"]); $taskNode->setAttribute("name", $task["taskName"]); $taskNode->setAttribute("note", $task["taskDescription"]); // Ugly date handling if (!$task["dateActualStart"]) { if (!$task["dateTargetStart"]) { // This is a reasonably bad situation $taskStartDate = time(); } else { $taskStartDate = planner_date_timestamp($task["dateTargetStart"]); } } else { $taskStartDate = planner_date_timestamp($task["dateActualStart"]); } if (!$task["dateActualCompletion"]) { if (!$task["dateTargetCompletion"]) { //The task has to last for some amount of time, so end = start (otherwise we get end = 1970) $taskEndDate = $taskStartDate; } else { $taskEndDate = planner_date_timestamp($task["dateTargetCompletion"]); } } else { $taskEndDate = planner_date_timestamp($task["dateActualCompletion"]); } // Take a stab at the duration we need to give this task $taskDuration = $taskEndDate - $taskStartDate; // That's the total number of seconds, Planner expects the number of 8-hour days worth of seconds $taskDuration = $taskDuration / 86400 * 28800; // note: the above doesn't account for weekends so there is a discrepancy between task durations in alloc and those in Planner, the solution is to make people work on the weekends $taskNode->setAttribute("work", $taskDuration); $taskNode->setAttribute("start", export_planner_date($taskStartDate)); $taskNode->setAttribute("work-start", export_planner_date($taskStartDate)); $taskNode->setAttribute("end", export_planner_date($taskEndDate)); $taskNode->setAttribute("scheduling", "fixed-work"); $constraintNode = $doc->createElement("constraint"); $constraintNode->setAttribute("type", "start-no-earlier-than"); $constraintNode->setAttribute("time", export_planner_date($taskStartDate)); $taskNode->appendChild($constraintNode); if ($task["taskTypeID"] == "Milestone") { $taskNode->setAttribute("type", "milestone"); } $resourcesUsed[$task["taskID"]] = $task['personID']; $taskRootNode->appendChild($taskNode); } // Now do the resources and their linkage to tasks $resourcesRootNode = $doc->getElementsByTagName("resources"); $resourcesRootNode = $resourcesRootNode->item(0); $allocationsRootNode = $doc->getElementsByTagName("allocations"); $allocationsRootNode = $allocationsRootNode->item(0); $resources = array(); //Store the users that need to be added to <resources> foreach ($resourcesUsed as $taskID => $resourceID) { if (isset($resources[$resourceID])) { $person = $resources[$resourceID]; } else { $person = new person(); $person->set_id($resourceID); $person->select(); $resources[$resourceID] = $person; // Add this person to <resources> $resourceNode = $doc->createElement("resource"); $resourceNode->setAttribute("id", $person->get_id()); $resourceNode->setAttribute("name", $person->get_value("firstName") . " " . $person->get_value("surname")); $resourceNode->setAttribute("short-name", $person->get_value("username")); $resourceNode->setAttribute("email", $person->get_value("emailAddress")); $resourceNode->setAttribute("units", "0"); $resourceNode->setAttribute("type", "1"); //1 means "Work" (the other option being Materials) $resourcesRootNode->appendChild($resourceNode); } //Now the actual allocation $allocationNode = $doc->createElement("allocation"); //Units means "percentage working on this" for which alloc has no analgoue $allocationNode->setAttribute("units", "100"); $allocationNode->setAttribute("task-id", $taskID); $allocationNode->setAttribute("resource-id", $resourceID); $allocationsRootNode->appendChild($allocationNode); } return $doc->saveXML(); }
$db->query($q); $num_rows = $db->num_rows(); $row = $db->row(); if ($num_rows > 0 && !$person->get_id() || $num_rows > 0 && $person->get_id() != $row["personID"]) { alloc_error("That username is already taken. Please select another."); } } else { alloc_error("Please enter a username."); } $person->set_value("personActive", $_POST["personActive"] ? 1 : "0"); $max_alloc_users = get_max_alloc_users(); if (!$person->get_id() && $max_alloc_users && get_num_alloc_users() >= $max_alloc_users && $_POST["personActive"]) { alloc_error(get_max_alloc_users_message()); } if (!$TPL["message"]) { $person->set_value("availability", rtrim($person->get_value("availability"))); $person->set_value("areasOfInterest", rtrim($person->get_value("areasOfInterest"))); $person->set_value("comments", rtrim($person->get_value("comments"))); $person->set_value("emergencyContact", rtrim($person->get_value("emergencyContact"))); $person->set_value("managementComments", rtrim($person->get_value("managementComments"))); $person->currency = config::get_config_item('currency'); $person->save(); alloc_redirect($TPL["url_alloc_personList"]); } } else { if ($_POST["delete"]) { $person->delete(); alloc_redirect($TPL["url_alloc_personList"]); } } #$person = new person();
function get_stats_for_email($format) { if ($format == "html") { $msg = "<br><br><h4>Alloc Stats For Today</h4>"; $msg .= sprintf("%d New and %d Active Projects<br><br>", $this->projects["new"]["total"], $this->projects["current"]["total"]); $msg .= "<table >"; } else { $msg = "\n- - - - - - - - - -\n"; $msg .= "Alloc Stats For Today\n"; $msg .= "\n"; $msg .= sprintf("%d New and %d Active Projects\n", $this->projects["new"]["total"], $this->projects["current"]["total"]); $msg .= "\n"; $msg .= "Top Users:\n"; } $num_users = 3; for ($i = 0; $i < $num_users && $i < count($this->persons); $i++) { $person = new person(); $person->set_id($this->persons[$i]["id"]); $person->select(); if ($format == "html") { $msg .= "<tr>"; $msg .= sprintf("<td>%s has</td>", $person->get_value("username")); $msg .= sprintf("<td>%d New and</td>", $this->tasks["new"][$person->get_id()]["total"]); $msg .= sprintf("<td>%d Active Tasks</td>", $this->tasks["current"][$person->get_id()]); $msg .= "</tr>"; } else { $msg .= sprintf("* %-15s %-15s %s\n", sprintf("%s has", $person->get_value("username")), sprintf("%d New and", $this->tasks["new"][$person->get_id()]["total"]), sprintf("%d Active Tasks", $this->tasks["current"][$person->get_id()])); } } if ($format == "html") { $msg .= "<hr />\nTo disable these daily emails, change the \"Daily Email\" setting on the Personal page.\n"; $msg .= "</table>"; } else { $msg .= "\n- - - - - - - - - -\nTo disable these daily emails, change the \"Daily Email\" setting on the Personal page.\n"; } return $msg; }
$person = new person(); $person->read_db_record($db); $person->set_id($db->f("personID")); $person->load_prefs(); if (!$person->prefs["dailyTaskEmail"]) { continue; } $msg = ""; $tasks = ""; $to = ""; if ($announcement["heading"]) { $msg .= $announcement["heading"]; $msg .= "\n" . $announcement["body"] . "\n"; $msg .= "\n- - - - - - - - - -\n"; } if ($person->get_value("emailAddress")) { $tasks = $person->get_tasks_for_email(); $msg .= $tasks; $subject = commentTemplate::populate_string(config::get_config_item("emailSubject_dailyDigest", "")); $to = $person->get_value("emailAddress"); if ($person->get_value("firstName") && $person->get_value("surname") && $to) { $to = $person->get_value("firstName") . " " . $person->get_value("surname") . " <" . $to . ">"; } if ($tasks && $to) { $email = new email_send($to, $subject, $msg, "daily_digest"); if ($email->send()) { echo "\n<br>Sent email to: " . $to; } } } }
function attach_email_to_existing_task($req = array()) { global $TPL; $info = inbox::get_mail_info(); $current_user =& singleton("current_user"); $orig_current_user =& $current_user; $req["taskID"] = sprintf("%d", $req["taskID"]); $task = new task(); $task->set_id($req["taskID"]); if ($task->select()) { $email_receive = new email_receive($info); $email_receive->open_mailbox($info["folder"]); $email_receive->set_msg($req["id"]); $email_receive->get_msg_header(); $email_receive->save_email(); $c = comment::add_comment_from_email($email_receive, $task); $commentID = $c->get_id(); $commentID and $TPL["message_good_no_esc"][] = "Created comment " . $commentID . " on task " . $task->get_task_link(array("prefixTaskID" => true)); // Possibly change the identity of current_user list($from_address, $from_name) = parse_email_address($email_receive->mail_headers["from"]); $person = new person(); $personID = $person->find_by_email($from_address); $personID or $personID = $person->find_by_name($from_name); if ($personID) { $current_user = new person(); $current_user->load_current_user($personID); singleton("current_user", $current_user); } // swap back to normal user $current_user =& $orig_current_user; singleton("current_user", $current_user); // manually add task manager and assignee to ip list $extraips = array(); if ($task->get_value("personID")) { $p = new person($task->get_value("personID")); if ($p->get_value("emailAddress")) { $extraips[$p->get_value("emailAddress")]["name"] = $p->get_name(); $extraips[$p->get_value("emailAddress")]["role"] = "assignee"; $extraips[$p->get_value("emailAddress")]["personID"] = $task->get_value("personID"); $extraips[$p->get_value("emailAddress")]["selected"] = 1; } } if ($task->get_value("managerID")) { $p = new person($task->get_value("managerID")); if ($p->get_value("emailAddress")) { $extraips[$p->get_value("emailAddress")]["name"] = $p->get_name(); $extraips[$p->get_value("emailAddress")]["role"] = "manager"; $extraips[$p->get_value("emailAddress")]["personID"] = $task->get_value("managerID"); $extraips[$p->get_value("emailAddress")]["selected"] = 1; } } // add all the other interested parties $ips = interestedParty::get_interested_parties("task", $req["taskID"], $extraips); foreach ((array) $ips as $k => $inf) { $inf["entity"] = "comment"; $inf["entityID"] = $commentID; $inf["email"] and $inf["emailAddress"] = $inf["email"]; if ($req["emailto"] == "internal" && !$inf["external"] && !$inf["clientContactID"]) { $id = interestedParty::add_interested_party($inf); $recipients[] = $inf["name"] . " " . add_brackets($k); } else { if ($req["emailto"] == "default") { $id = interestedParty::add_interested_party($inf); $recipients[] = $inf["name"] . " " . add_brackets($k); } } } $recipients and $recipients = implode(", ", (array) $recipients); $recipients and $TPL["message_good"][] = "Sent email to " . $recipients; // Re-email the comment out comment::send_comment($commentID, array("interested"), $email_receive); // File email away in the task's mail folder $mailbox = "INBOX/task" . $task->get_id(); $email_receive->create_mailbox($mailbox) and $TPL["message_good"][] = "Created mailbox: " . $mailbox; $email_receive->move_mail($req["id"], $mailbox) and $TPL["message_good"][] = "Moved email " . $req["id"] . " to " . $mailbox; $email_receive->close(); } }
public static function get_list($_FORM = array()) { global $TPL; $current_user =& singleton("current_user"); list($filter, $filter2) = person::get_list_filter($_FORM); $debug = $_FORM["debug"]; $debug and print "<pre>_FORM: " . print_r($_FORM, 1) . "</pre>"; $debug and print "<pre>filter: " . print_r($filter, 1) . "</pre>"; $_FORM["return"] or $_FORM["return"] = "html"; // Get averages for hours worked over the past fortnight and year if ($current_user->have_perm(PERM_PERSON_READ_MANAGEMENT) && $_FORM["showHours"]) { $t = new timeSheetItem(); list($ts_hrs_col_1, $ts_dollars_col_1) = $t->get_averages(date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 14, date("Y")))); list($ts_hrs_col_2, $ts_dollars_col_2) = $t->get_fortnightly_average(); } else { unset($_FORM["showHours"]); } // A header row $summary .= person::get_list_tr_header($_FORM); if (is_array($filter) && count($filter)) { $filter = " WHERE " . implode(" AND ", $filter); } if (is_array($filter2) && count($filter2)) { unset($filter["skill"]); $filter .= " AND " . implode(" OR ", $filter2); } $q = "SELECT person.*\n FROM person\n LEFT JOIN proficiency ON person.personID = proficiency.personID\n " . $filter . "\n GROUP BY username\n ORDER BY firstName,surname,username"; $debug and print "Query: " . $q; $db = new db_alloc(); $db->query($q); while ($row = $db->next_record()) { $p = new person(); if (!$p->read_db_record($db)) { continue; } $row = $p->perm_cleanup($row); // this is not the right way to do this - alla $print = true; $_FORM["showHours"] and $row["hoursSum"] = $ts_hrs_col_1[$row["personID"]]; $_FORM["showHours"] and $row["hoursAvg"] = $ts_hrs_col_2[$row["personID"]]; $row["name"] = $p->get_name(); $row["name_link"] = $p->get_link($_FORM); $row["personActive_label"] = $p->get_value("personActive") == 1 ? "Y" : ""; if ($_FORM["showSkills"]) { $senior_skills = $p->get_skills('Senior'); $advanced_skills = $p->get_skills('Advanced'); $intermediate_skills = $p->get_skills('Intermediate'); $junior_skills = $p->get_skills('Junior'); $novice_skills = $p->get_skills('Novice'); $skills = array(); $senior_skills and $skills[] = "<img src=\"../images/skill_senior.png\" alt=\"Senior=\"> " . page::htmlentities($senior_skills); $advanced_skills and $skills[] = "<img src=\"../images/skill_advanced.png\" alt=\"Advanced=\"> " . page::htmlentities($advanced_skills); $intermediate_skills and $skills[] = "<img src=\"../images/skill_intermediate.png\" alt=\"Intermediate=\"> " . page::htmlentities($intermediate_skills); $junior_skills and $skills[] = "<img src=\"../images/skill_junior.png\" alt=\"Junior=\"> " . page::htmlentities($junior_skills); $novice_skills and $skills[] = "<img src=\"../images/skill_novice.png\" alt=\"Novice\"> " . page::htmlentities($novice_skills); $row["skills_list"] = implode("<br>", $skills); } if ($_FORM["showLinks"]) { $row["navLinks"] = '<a href="' . $TPL["url_alloc_taskList"] . 'personID=' . $row["personID"] . '&taskView=byProject&applyFilter=1'; $row["navLinks"] .= '&dontSave=1&taskStatus=open&projectType=Current">Tasks</a> '; has("project") and $row["navLinks"] .= '<a href="' . $TPL["url_alloc_personGraph"] . 'personID=' . $row["personID"] . '">Graph</a> '; $row["navLinks"] .= '<a href="' . $TPL["url_alloc_taskCalendar"] . 'personID=' . $row["personID"] . '">Calendar</a> '; $dateFrom = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 28, date("Y"))); $dateTo = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y"))); $row["navLinks"] .= '<a href="' . $TPL["url_alloc_timeSheetGraph"] . 'personID=' . $row["personID"] . '&dateFrom=' . $dateFrom . '&dateTo=' . $dateTo . '&applyFilter=1&dontSave=1">Hours</a>'; } $summary .= person::get_list_tr($row, $_FORM); $rows[$row["personID"]] = $row; } $rows or $rows = array(); if ($print && $_FORM["return"] == "array") { return $rows; } else { if ($print && $_FORM["return"] == "html") { return "<table class=\"list sortable\">" . $summary . "</table>"; } else { if (!$print && $_FORM["return"] == "html") { return "<table style=\"width:100%\"><tr><td colspan=\"10\" style=\"text-align:center\"><b>No People Found</b></td></tr></table>"; } } } }
function get_people_header() { global $TPL; global $people_ids; global $people_header; global $talent; global $skill_class; $people_ids = array(); $where = FALSE; $db = new db_alloc(); $query = "SELECT * FROM person"; $query .= " LEFT JOIN proficiency ON person.personID=proficiency.personID"; $query .= " LEFT JOIN skill ON proficiency.skillID=skill.skillID WHERE personActive = 1 "; if ($talent) { $query .= prepare(" AND skill.skillID=%d", $talent); } else { if ($skill_class) { $query .= prepare(" AND skill.skillClass='%s'", $skill_class); } } $query .= " GROUP BY username ORDER BY username"; $db->query($query); while ($db->next_record()) { $person = new person(); $person->read_db_record($db); array_push($people_ids, $person->get_id()); $people_header .= sprintf("<th style=\"text-align:center\">%s</th>\n", $person->get_value('username')); } }