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>";
     }
 }
Esempio n. 2
0
 public static function get_list_filter($filter = array())
 {
     $current_user =& singleton("current_user");
     // If they want starred, load up the taskID filter element
     if ($filter["starred"]) {
         foreach ((array) $current_user->prefs["stars"]["task"] as $k => $v) {
             $filter["taskID"][] = $k;
         }
         is_array($filter["taskID"]) or $filter["taskID"][] = -1;
     }
     // Filter on taskID
     $filter["taskID"] and $sql[] = sprintf_implode("task.taskID = %d", $filter["taskID"]);
     // No point continuing if primary key specified, so return
     if ($filter["taskID"]) {
         return array($sql, "");
     }
     // This takes care of projectID singular and plural
     has("project") and $projectIDs = project::get_projectID_sql($filter);
     $projectIDs and $sql["projectIDs"] = $projectIDs;
     // project name or project nick name or project id
     $filter["projectNameMatches"] and $sql[] = sprintf_implode("project.projectName LIKE '%%%s%%'\n                                                               OR project.projectShortName LIKE '%%%s%%'\n                                                               OR project.projectID = %d", $filter["projectNameMatches"], $filter["projectNameMatches"], $filter["projectNameMatches"]);
     list($ts_open, $ts_pending, $ts_closed) = task::get_task_status_in_set_sql();
     // New Tasks
     if ($filter["taskDate"] == "new") {
         $past = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 2, date("Y"))) . " 00:00:00";
         date("D") == "Mon" and $past = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 4, date("Y"))) . " 00:00:00";
         $sql[] = prepare("(task.taskStatus NOT IN (" . $ts_closed . ") AND task.dateCreated >= '" . $past . "')");
         // Due Today
     } else {
         if ($filter["taskDate"] == "due_today") {
             $sql[] = "(task.taskStatus NOT IN (" . $ts_closed . ") AND task.dateTargetCompletion = '" . date("Y-m-d") . "')";
             // Overdue
         } else {
             if ($filter["taskDate"] == "overdue") {
                 $sql[] = "(task.taskStatus NOT IN (" . $ts_closed . ")\n                AND \n                (task.dateTargetCompletion IS NOT NULL AND task.dateTargetCompletion != '' AND '" . date("Y-m-d") . "' > task.dateTargetCompletion))";
                 // Date Created
             } else {
                 if ($filter["taskDate"] == "d_created") {
                     $filter["dateOne"] and $sql[] = prepare("(task.dateCreated >= '%s')", $filter["dateOne"]);
                     $filter["dateTwo"] and $sql[] = prepare("(task.dateCreated <= '%s 23:59:59')", $filter["dateTwo"]);
                     // Date Assigned
                 } else {
                     if ($filter["taskDate"] == "d_assigned") {
                         $filter["dateOne"] and $sql[] = prepare("(task.dateAssigned >= '%s')", $filter["dateOne"]);
                         $filter["dateTwo"] and $sql[] = prepare("(task.dateAssigned <= '%s 23:59:59')", $filter["dateTwo"]);
                         // Date Target Start
                     } else {
                         if ($filter["taskDate"] == "d_targetStart") {
                             $filter["dateOne"] and $sql[] = prepare("(task.dateTargetStart >= '%s')", $filter["dateOne"]);
                             $filter["dateTwo"] and $sql[] = prepare("(task.dateTargetStart <= '%s')", $filter["dateTwo"]);
                             // Date Target Completion
                         } else {
                             if ($filter["taskDate"] == "d_targetCompletion") {
                                 $filter["dateOne"] and $sql[] = prepare("(task.dateTargetCompletion >= '%s')", $filter["dateOne"]);
                                 $filter["dateTwo"] and $sql[] = prepare("(task.dateTargetCompletion <= '%s')", $filter["dateTwo"]);
                                 // Date Actual Start
                             } else {
                                 if ($filter["taskDate"] == "d_actualStart") {
                                     $filter["dateOne"] and $sql[] = prepare("(task.dateActualStart >= '%s')", $filter["dateOne"]);
                                     $filter["dateTwo"] and $sql[] = prepare("(task.dateActualStart <= '%s')", $filter["dateTwo"]);
                                     // Date Actual Completion
                                 } else {
                                     if ($filter["taskDate"] == "d_actualCompletion") {
                                         $filter["dateOne"] and $sql[] = prepare("(task.dateActualCompletion >= '%s')", $filter["dateOne"]);
                                         $filter["dateTwo"] and $sql[] = prepare("(task.dateActualCompletion <= '%s')", $filter["dateTwo"]);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // Task status filtering
     $filter["taskStatus"] and $sql[] = task::get_taskStatus_sql($filter["taskStatus"]);
     $filter["taskTypeID"] and $sql[] = sprintf_implode("task.taskTypeID = '%s'", $filter["taskTypeID"]);
     // Filter on %taskName%
     $filter["taskName"] and $sql[] = sprintf_implode("task.taskName LIKE '%%%s%%'", $filter["taskName"]);
     // If personID filter
     $filter["personID"] and $sql["personID"] = sprintf_implode("IFNULL(task.personID,0) = %d", $filter["personID"]);
     $filter["creatorID"] and $sql["creatorID"] = sprintf_implode("IFNULL(task.creatorID,0) = %d", $filter["creatorID"]);
     $filter["managerID"] and $sql["managerID"] = sprintf_implode("IFNULL(task.managerID,0) = %d", $filter["managerID"]);
     // If tags filter
     if ($filter["tags"] && is_array($filter["tags"])) {
         foreach ((array) $filter["tags"] as $k => $tag) {
             $tag and $tags[] = $tag;
         }
         $tags and $sql[] = sprintf_implode("seltag.name = '%s'", $tags);
         $having = prepare("HAVING count(DISTINCT seltag.name) = %d", count($tags));
     }
     // These filters are for the time sheet dropdown list
     if ($filter["taskTimeSheetStatus"] == "open") {
         unset($sql["personID"]);
         $sql[] = prepare("(task.taskStatus NOT IN (" . $ts_closed . "))");
     } else {
         if ($filter["taskTimeSheetStatus"] == "mine") {
             $current_user =& singleton("current_user");
             unset($sql["personID"]);
             $sql[] = prepare("((task.taskStatus NOT IN (" . $ts_closed . ")) AND task.personID = %d)", $current_user->get_id());
         } else {
             if ($filter["taskTimeSheetStatus"] == "not_assigned") {
                 unset($sql["personID"]);
                 $sql[] = prepare("((task.taskStatus NOT IN (" . $ts_closed . ")) AND task.personID != %d)", $filter["personID"]);
             } else {
                 if ($filter["taskTimeSheetStatus"] == "recent_closed") {
                     unset($sql["personID"]);
                     $sql[] = prepare("(task.dateActualCompletion >= DATE_SUB(CURDATE(),INTERVAL 14 DAY))");
                 } else {
                     if ($filter["taskTimeSheetStatus"] == "all") {
                     }
                 }
             }
         }
     }
     $filter["parentTaskID"] and $sql["parentTaskID"] = sprintf_implode("IFNULL(task.parentTaskID,0) = %d", $filter["parentTaskID"]);
     return array($sql, $having);
 }
Esempio n. 3
0
 function task_stats()
 {
     $db = new db_alloc();
     list($ts_open, $ts_pending, $ts_closed) = task::get_task_status_in_set_sql();
     // Get total amount of current tasks for every person
     $q = "SELECT person.personID, person.username, count(taskID) as tally\n            FROM task \n       LEFT JOIN person ON task.personID = person.personID \n           WHERE task.taskStatus NOT IN (" . $ts_closed . ")\n        GROUP BY person.personID";
     $db->query($q);
     while ($db->next_record()) {
         $this->tasks["current"][$db->f("personID")] = $db->f("tally");
         $this->tasks["current"]["total"] += $db->f("tally");
     }
     // Get total amount of completed tasks for every person
     $q = "SELECT person.personID, person.username, count(taskID) as tally\n            FROM task \n       LEFT JOIN person ON task.personID = person.personID \n           WHERE task.taskStatus NOT IN (" . $ts_closed . ")\n        GROUP BY person.personID";
     $db->query($q);
     while ($db->next_record()) {
         $this->tasks["completed"][$db->f("personID")] = $db->f("tally");
         $this->tasks["completed"]["total"] += $db->f("tally");
     }
     // Get total amount of all tasks for every person
     $q = "SELECT person.personID, person.username, count(taskID) as tally\n            FROM task \n       LEFT JOIN person ON task.personID = person.personID \n        GROUP BY person.personID";
     $db->query($q);
     while ($db->next_record()) {
         $this->tasks["total"][$db->f("personID")] = $db->f("tally");
         $this->tasks["total"]["total"] += $db->f("tally");
     }
     // date from which a task is counted as being new. if monday then date back to friday, else the previous day
     $days = date("w") == 1 ? 3 : 1;
     $date = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - $days, date("Y")));
     // Get total amount of completed tasks for every person
     $q = prepare("SELECT person.personID, person.username, count(taskID) as tally, task.dateCreated\n            FROM task \n       LEFT JOIN person ON task.personID = person.personID \n           WHERE ('%s' <= task.dateCreated)\n        GROUP BY person.personID", $date);
     $db->query($q);
     while ($db->next_record()) {
         $d = format_date("Y-m-d", $db->f("dateCreated"));
         $this->tasks["new"][$db->f("personID")][$d] = $db->f("tally");
         $v += $db->f("tally");
         $this->tasks["new"]["total"][$d] = $v;
     }
     return $this->tasks;
 }
Esempio n. 4
0
 function get_cal_tasks_to_complete()
 {
     list($ts_open, $ts_pending, $ts_closed) = task::get_task_status_in_set_sql();
     // Select all tasks which are targetted for completion
     $query = prepare("SELECT * \n                        FROM task \n                       WHERE personID = %d \n                         AND dateTargetCompletion >= '%s' \n                         AND dateTargetCompletion < '%s'\n                         AND taskStatus NOT IN (" . $ts_closed . ")", $this->person->get_id(), $this->first_date, $this->last_date);
     $this->db->query($query);
     $tasks_to_complete = array();
     while ($row = $this->db->next_record()) {
         $tasks_to_complete[$row["dateTargetCompletion"]][] = $row;
     }
     return $tasks_to_complete;
 }
Esempio n. 5
0
 function has_messages()
 {
     if (is_object($this)) {
         list($ts_open, $ts_pending, $ts_closed) = task::get_task_status_in_set_sql();
         $db = new db_alloc();
         $query = prepare("SELECT * \n                          FROM task \n                         WHERE taskTypeID = 'Message'\n                           AND personID = %d\n                           AND taskStatus NOT IN (" . $ts_closed . ")", $this->get_id());
         $db->query($query);
         if ($db->next_record()) {
             return true;
         }
     }
     return false;
 }