function show_tasks()
 {
     $current_user =& singleton("current_user");
     global $tasks_date;
     list($ts_open, $ts_pending, $ts_closed) = task::get_task_status_in_set_sql();
     $q = prepare("SELECT * \n                  FROM task \n                  WHERE (task.taskStatus NOT IN (" . $ts_closed . ") AND task.taskTypeID = 'Message') \n                  AND (personID = %d) \n                  ORDER BY priority\n                 ", $current_user->get_id());
     $db = new db_alloc();
     $db->query($q);
     while ($db->next_record()) {
         $task = new task();
         $task->read_db_record($db);
         echo $br . $task->get_task_image() . $task->get_task_link(array("return" => "html"));
         $br = "<br>";
     }
 }
Пример #2
0
 function get_list_summary($_FORM = array())
 {
     //$_FORM["fromDate"] = "2010-08-20";
     //$_FORM["projectID"] = "22";
     $_FORM["maxCommentLength"] or $_FORM["maxCommentLength"] = 500;
     list($filter1, $filter2, $filter3) = comment::get_list_summary_filter($_FORM);
     is_array($filter1) && count($filter1) and $filter1 = " AND " . implode(" AND ", $filter1);
     is_array($filter2) && count($filter2) and $filter2 = " AND " . implode(" AND ", $filter2);
     is_array($filter3) && count($filter3) and $filter3 = " AND " . implode(" AND ", $filter3);
     if ($_FORM["clients"]) {
         $client_join = " LEFT JOIN clientContact on comment.commentCreatedUserClientContactID = clientContact.clientContactID";
         $client_fields = " , clientContact.clientContactName";
     }
     $q = prepare("SELECT commentID as id\n                       , commentCreatedUser as personID\n                       , UNIX_TIMESTAMP(commentCreatedTime) as sortDate\n                       , date(commentCreatedTime) as date\n                       , commentCreatedTime as displayDate\n                       , commentMasterID as taskID\n                       , task.taskName\n                       , SUBSTRING(comment.comment,1,%d) AS comment_text\n                       , commentCreatedUserText\n                         " . $client_fields . "\n                    FROM comment\n               LEFT JOIN task on comment.commentMasterID = task.taskID\n                         " . $client_join . "\n                   WHERE commentMaster = 'task'\n                         " . $filter1 . "\n                ORDER BY commentCreatedTime, commentCreatedUser", $_FORM["maxCommentLength"]);
     $q .= " ";
     $people =& get_cached_table("person");
     $db = new db_alloc();
     $db->query($q);
     while ($row = $db->row()) {
         $row["icon"] = 'icon-comments-alt';
         $row["id"] = "comment_" . $row["id"];
         $row["personID"] and $row["person"] = $people[$row["personID"]]["name"];
         $row["clientContactName"] and $row["person"] = $row["clientContactName"];
         $row["person"] or list($e, $row["person"]) = parse_email_address($row["commentCreatedUserText"]);
         $row["displayDate"] = format_date("Y-m-d g:ia", $row["displayDate"]);
         if (!$tasks[$row["taskID"]]) {
             $t = new task();
             $t->set_id($row["taskID"]);
             $t->set_value("taskName", $row["taskName"]);
             $tasks[$row["taskID"]] = $t->get_task_link(array("prefixTaskID" => true));
         }
         $rows[$row["taskID"]][$row["sortDate"]][] = $row;
     }
     // Note that timeSheetItemID is selected twice so that the perms checking can work
     // timeSheetID is also used by the perms checking.
     $q2 = prepare("SELECT timeSheetItemID as id\n                         ,timeSheetItemID\n                         ,timeSheetID\n                         ,timeSheetItem.personID\n                         ,dateTimeSheetItem as date\n                         ,UNIX_TIMESTAMP(CONCAT(dateTimeSheetItem, ' 23:59:58')) as sortDate\n                         ,dateTimeSheetItem as displayDate\n                         ,timeSheetItem.taskID\n                         ,task.taskName\n                         ,timeSheetItemDuration as duration\n                         ,SUBSTRING(timeSheetItem.comment,1,%d) AS comment_text\n                     FROM timeSheetItem\n                LEFT JOIN task on timeSheetItem.taskID = task.taskID\n                    WHERE 1\n                          " . $filter2 . "\n                 ORDER BY dateTimeSheetItem", $_FORM["maxCommentLength"]);
     $db->query($q2);
     while ($row = $db->row()) {
         $timeSheetItem = new timeSheetItem();
         if (!$timeSheetItem->read_row_record($row)) {
             continue;
         }
         $row["icon"] = 'icon-time';
         $row["id"] = "timeitem_" . $row["id"];
         $row["person"] = $people[$row["personID"]]["name"];
         if (!$tasks[$row["taskID"]]) {
             $t = new task();
             $t->set_id($row["taskID"]);
             $t->set_value("taskName", $row["taskName"]);
             $tasks[$row["taskID"]] = $t->get_task_link(array("prefixTaskID" => true));
         }
         $totals[$row["taskID"]] += $row["duration"];
         $rows[$row["taskID"]][$row["sortDate"]][] = $row;
     }
     // get manager's guestimates about time worked from tsiHint table
     $q3 = prepare("SELECT tsiHintID as id\n                         ,tsiHintID\n                         ,tsiHint.personID\n                         ,tsiHint.date\n                         ,UNIX_TIMESTAMP(CONCAT(tsiHint.date,' 23:59:59')) as sortDate\n                         ,tsiHint.date as displayDate\n                         ,tsiHint.taskID\n                         ,tsiHint.duration\n                         ,tsiHint.tsiHintCreatedUser\n                         ,SUBSTRING(tsiHint.comment,1,%d) AS comment_text\n                         ,task.taskName\n                     FROM tsiHint\n                LEFT JOIN task on tsiHint.taskID = task.taskID\n                    WHERE 1\n                          " . $filter3 . "\n                 ORDER BY tsiHint.date", $_FORM["maxCommentLength"]);
     $db->query($q3);
     while ($row = $db->row()) {
         //$tsiHint = new tsiHint();
         //if (!$tsiHint->read_row_record($row))
         //  continue;
         $row["icon"] = 'icon-bookmark-empty';
         $row["id"] = "tsihint_" . $row["id"];
         $row["person"] = $people[$row["personID"]]["name"];
         $row["comment_text"] .= ' [by ' . $people[$row["tsiHintCreatedUser"]]["name"] . ']';
         if (!$tasks[$row["taskID"]]) {
             $t = new task();
             $t->set_id($row["taskID"]);
             $t->set_value("taskName", $row["taskName"]);
             $tasks[$row["taskID"]] = $t->get_task_link(array("prefixTaskID" => true));
         }
         $totals_tsiHint[$row["taskID"]] += $row["duration"];
         $rows[$row["taskID"]][$row["sortDate"]][] = $row;
     }
     // If there is a time sheet entry for 2010-10-10 but there is no comment entry
     // for that date, then the time sheet entry will appear out of sequence i.e. at
     // the very end of the whole list. So we need to manually sort them.
     foreach ((array) $rows as $tid => $arr) {
         ksort($arr, SORT_NUMERIC);
         $rows[$tid] = $arr;
     }
     foreach ((array) $rows as $taskID => $dates) {
         $rtn .= comment::get_list_summary_header($tasks[$taskID], $totals[$taskID], $totals_tsiHint[$taskID], $_FORM);
         foreach ($dates as $date => $more_rows) {
             foreach ($more_rows as $row) {
                 $rtn .= comment::get_list_summary_body($row);
             }
         }
         $rtn .= comment::get_list_summary_footer($rows, $tasks);
     }
     return $rtn;
 }
Пример #3
0
$is = "was";
$wasopen and $is = "is";
$pendingTaskLinks and $TPL["message_help_no_esc"][] = "This task " . $is . " pending the completion of:<br>" . implode("<br>", $pendingTaskLinks);
$rows = $task->get_pending_tasks(true);
foreach ((array) $rows as $tID) {
    $realtask = new task();
    $realtask->set_id($tID);
    $realtask->select();
    unset($st1, $st2);
    if (substr($realtask->get_value("taskStatus"), 0, 6) == "closed") {
        $st1 = "<strike>";
        $st2 = "</strike>";
    } else {
        $wasopen = true;
    }
    $blockTaskLinks[] = $st1 . $realtask->get_task_link(array("prefixTaskID" => 1, "return" => "html")) . $st2;
}
$is = "was";
$wasopen and $is = "is";
$blockTaskLinks and $TPL["message_help_no_esc"][] = "This task " . $is . " blocking the start of:<br>" . implode("<br>", $blockTaskLinks);
if (in_str("pending_", $task->get_value("taskStatus"))) {
    $rows = $task->get_reopen_reminders();
    foreach ($rows as $r) {
        $TPL["message_help_no_esc"][] = 'This task is set to
                                    <a href="' . $TPL["url_alloc_reminder"] . 'step=3&reminderID=' . $r["rID"] . '&returnToParent=task">
				    automatically reopen at ' . $r["reminderTime"] . '</a>';
        // Which date gets plugged in is arbitrary, but it would be unusual for there to be more than one
        $TPL['reopen_task'] = strftime("%Y-%m-%d", strtotime($r['reminderTime']));
    }
}
if ($task->get_id()) {
Пример #4
0
 public static function get_list($_FORM)
 {
     $current_user =& singleton("current_user");
     /*
      * This is the definitive method of getting a list of tasks that need a sophisticated level of filtering
      *
      */
     list($filter, $having) = task::get_list_filter($_FORM);
     $debug = $_FORM["debug"];
     $debug and print "\n<pre>_FORM: " . print_r($_FORM, 1) . "</pre>";
     $debug and print "\n<pre>filter: " . print_r($filter, 1) . "</pre>";
     $_FORM["taskView"] or $_FORM["taskView"] = 'prioritised';
     // Zero is a valid limit
     if ($_FORM["limit"] || $_FORM["limit"] === 0 || $_FORM["limit"] === "0") {
         $limit = prepare("limit %d", $_FORM["limit"]);
     }
     $_FORM["return"] or $_FORM["return"] = "html";
     $_FORM["people_cache"] =& get_cached_table("person");
     $_FORM["timeUnit_cache"] =& get_cached_table("timeUnit");
     $_FORM["taskType_cache"] =& get_cached_table("taskType");
     if ($_FORM["taskView"] == "prioritised") {
         unset($filter["parentTaskID"]);
         $order_limit = " " . $limit;
     } else {
         $order_limit = " ORDER BY projectName,taskName " . $limit;
     }
     // Get a hierarchical list of tasks
     if (is_array($filter) && count($filter)) {
         $f = " WHERE " . implode(" AND ", $filter);
     }
     $uid = sprintf("%d", $current_user->get_id());
     $spread = sprintf("%d", config::get_config_item("taskPrioritySpread"));
     $scale = sprintf("%d", config::get_config_item("taskPriorityScale"));
     $scale_halved = sprintf("%d", config::get_config_item("taskPriorityScale") / 2);
     $q = "SELECT task.*\n                ,projectName\n                ,projectShortName\n                ,clientID\n                ,projectPriority\n                ,project.currencyTypeID as currency\n                ,rate\n                ,rateUnitID\n                ,GROUP_CONCAT(pendingTask.pendingTaskID) as pendingTaskIDs\n                ,GROUP_CONCAT(DISTINCT alltag.name SEPARATOR ', ') as tags\n            FROM task\n       LEFT JOIN project ON project.projectID = task.projectID\n       LEFT JOIN projectPerson ON project.projectID = projectPerson.projectID AND projectPerson.personID = '" . $uid . "'\n       LEFT JOIN pendingTask ON pendingTask.taskID = task.taskID\n       LEFT JOIN tag alltag ON alltag.taskID = task.taskID\n       LEFT JOIN tag seltag ON seltag.taskID = task.taskID\n                 " . $f . "\n        GROUP BY task.taskID\n                 " . $having . "\n                 " . $order_limit;
     $debug and print "\n<br>QUERY: " . $q;
     $_FORM["debug"] and print "\n<br>QUERY: " . $q;
     $db = new db_alloc();
     $db->query($q);
     while ($row = $db->next_record()) {
         $task = new task();
         $task->read_db_record($db);
         $row["taskURL"] = $task->get_url();
         $row["taskName"] = $task->get_name($_FORM);
         $row["taskLink"] = $task->get_task_link($_FORM);
         $row["project_name"] = $row["projectShortName"] or $row["project_name"] = $row["projectName"];
         $row["projectPriority"] = $db->f("projectPriority");
         has("project") and $row["projectPriorityLabel"] = project::get_priority_label($db->f("projectPriority"));
         has("project") and list($row["priorityFactor"], $row["daysUntilDue"]) = $task->get_overall_priority($row["projectPriority"], $row["priority"], $row["dateTargetCompletion"]);
         $row["taskTypeImage"] = $task->get_task_image();
         $row["taskTypeSeq"] = $_FORM["taskType_cache"][$row["taskTypeID"]]["taskTypeSeq"];
         $row["taskStatusLabel"] = $task->get_task_status("label");
         $row["taskStatusColour"] = $task->get_task_status("colour");
         $row["creator_name"] = $_FORM["people_cache"][$row["creatorID"]]["name"];
         $row["manager_name"] = $_FORM["people_cache"][$row["managerID"]]["name"];
         $row["assignee_name"] = $_FORM["people_cache"][$row["personID"]]["name"];
         $row["closer_name"] = $_FORM["people_cache"][$row["closerID"]]["name"];
         $row["estimator_name"] = $_FORM["people_cache"][$row["estimatorID"]]["name"];
         $row["creator_username"] = $_FORM["people_cache"][$row["creatorID"]]["username"];
         $row["manager_username"] = $_FORM["people_cache"][$row["managerID"]]["username"];
         $row["assignee_username"] = $_FORM["people_cache"][$row["personID"]]["username"];
         $row["closer_username"] = $_FORM["people_cache"][$row["closerID"]]["username"];
         $row["estimator_username"] = $_FORM["people_cache"][$row["estimatorID"]]["username"];
         $row["newSubTask"] = $task->get_new_subtask_link();
         $_FORM["showPercent"] and $row["percentComplete"] = $task->get_percentComplete();
         $_FORM["showTimes"] and $row["timeActual"] = $task->get_time_billed() / 60 / 60;
         $row["rate"] = page::money($row["currency"], $row["rate"], "%mo");
         $row["rateUnit"] = $_FORM["timeUnit_cache"][$row["rateUnitID"]]["timeUnitName"];
         $row["priorityLabel"] = $task->get_priority_label();
         if (!$_FORM["skipObject"]) {
             $_FORM["return"] == "array" and $row["object"] = $task;
         }
         $row["padding"] = $_FORM["padding"];
         $row["taskID"] = $task->get_id();
         $row["parentTaskID"] = $task->get_value("parentTaskID");
         $row["parentTaskID_link"] = "<a href='" . $task->get_url(false, $task->get_value("parentTaskID")) . "'>" . $task->get_value("parentTaskID") . "</a>";
         $row["timeLimitLabel"] = $row["timeBestLabel"] = $row["timeWorstLabel"] = $row["timeExpectedLabel"] = $row["timeActualLabel"] = "";
         $row["timeLimit"] !== NULL and $row["timeLimitLabel"] = seconds_to_display_format($row["timeLimit"] * 60 * 60);
         $row["timeBest"] !== NULL and $row["timeBestLabel"] = seconds_to_display_format($row["timeBest"] * 60 * 60);
         $row["timeWorst"] !== NULL and $row["timeWorstLabel"] = seconds_to_display_format($row["timeWorst"] * 60 * 60);
         $row["timeExpected"] !== NULL and $row["timeExpectedLabel"] = seconds_to_display_format($row["timeExpected"] * 60 * 60);
         $row["timeActual"] !== NULL and $row["timeActualLabel"] = seconds_to_display_format($row["timeActual"] * 60 * 60);
         if ($_FORM["showComments"] && ($comments = comment::util_get_comments("task", $row["taskID"]))) {
             $row["comments"] = $comments;
         }
         if ($_FORM["taskView"] == "byProject") {
             $rows[$task->get_id()] = array("parentTaskID" => $row["parentTaskID"], "row" => $row);
         } else {
             if ($_FORM["taskView"] == "prioritised") {
                 $rows[$row["taskID"]] = $row;
                 if (is_array($rows) && count($rows)) {
                     uasort($rows, array("task", "priority_compare"));
                 }
             }
         }
     }
     if ($_FORM["taskView"] == "byProject") {
         $parentTaskID = $_FORM["parentTaskID"] or $parentTaskID = 0;
         $t = task::get_recursive_child_tasks($parentTaskID, (array) $rows);
         list($tasks, $done) = task::build_recursive_task_list($t, $_FORM);
         // This bit appends the orphan tasks onto the end..
         foreach ((array) $rows as $taskID => $r) {
             $row = $r["row"];
             $row["padding"] = 0;
             if (!$done[$taskID]) {
                 $tasks += array($taskID => $row);
             }
         }
     } else {
         if ($_FORM["taskView"] == "prioritised") {
             $tasks =& $rows;
         }
     }
     return (array) $tasks;
 }
Пример #5
0
 function convert_email_to_new_task($email_receive, $change_user = false)
 {
     global $TPL;
     $current_user =& singleton("current_user");
     $orig_current_user =& $current_user;
     if ($change_user) {
         inbox::change_current_user($email_receive->mail_headers["from"]);
         $current_user =& singleton("current_user");
         if (is_object($current_user) && method_exists($current_user, "get_id") && $current_user->get_id()) {
             $personID = $current_user->get_id();
         }
     }
     $email_receive->save_email();
     // Subject line is name, email body is body
     $task = new task();
     $task->set_value("taskName", $email_receive->mail_headers["subject"]);
     $task->set_value("taskDescription", $email_receive->mail_text);
     $task->set_value("priority", "3");
     $task->set_value("taskTypeID", "Task");
     $task->save();
     if (!$TPL["message"] && $task->get_id()) {
         $dir = ATTACHMENTS_DIR . DIRECTORY_SEPARATOR . "task" . DIRECTORY_SEPARATOR . $task->get_id();
         if (!is_dir($dir)) {
             mkdir($dir);
             foreach ((array) $email_receive->mimebits as $file) {
                 $fh = fopen($dir . DIRECTORY_SEPARATOR . $file["name"], "wb");
                 fputs($fh, $file["blob"]);
                 fclose($fh);
             }
         }
         rmdir_if_empty(ATTACHMENTS_DIR . DIRECTORY_SEPARATOR . "task" . DIRECTORY_SEPARATOR . $task->get_id());
         $msg = "Created task " . $task->get_task_link(array("prefixTaskID" => true)) . " and moved the email to the task's mail folder.";
         $mailbox = "INBOX/task" . $task->get_id();
         $email_receive->create_mailbox($mailbox) and $msg .= "\nCreated mailbox: " . $mailbox;
         $email_receive->archive($mailbox) and $msg .= "\nMoved email to " . $mailbox;
         $msg and $TPL["message_good_no_esc"][] = $msg;
         list($from_address, $from_name) = parse_email_address($email_receive->mail_headers["from"]);
         $ip["emailAddress"] = $from_address;
         $ip["name"] = $from_name;
         $ip["personID"] = $personID;
         $ip["entity"] = "task";
         $ip["entityID"] = $task->get_id();
         interestedParty::add_interested_party($ip);
     }
     // Put current_user back to normal
     $current_user =& $orig_current_user;
     singleton("current_user", $current_user);
 }