Пример #1
0
$estimator->set_id($task->get_value("estimatorID"));
$estimator->select();
$TPL["estimator_username"] = $estimator->get_name();
$TPL["estimator_username_personID"] = $estimator->get_id();
// If we've been sent here by a "New Message" or "New Fault" option in the Quick List dropdown
if (!$taskID && $_GET["tasktype"]) {
    $task->set_value("taskTypeID", $_GET["tasktype"]);
}
// If we've been sent here by a "New Task" link from the calendar
if (!$taskID && $_GET["dateTargetStart"]) {
    $TPL["task_dateTargetStart"] = $_GET["dateTargetStart"];
    $task->set_value("personID", $_GET["personID"]);
}
// Set options for the dropdown boxen
$task->set_option_tpl_values();
$time_billed = $task->get_time_billed(false);
$time_billed_label = seconds_to_display_format($time_billed);
if ($time_billed != "") {
    $TPL["time_billed_link"] = "<a href=\"" . $TPL["url_alloc_timeSheetList"] . "taskID=" . $task->get_id() . "&dontSave=true&applyFilter=true\">" . $time_billed_label . "</a>";
}
$TPL["task_timeLimit"] or $TPL["task_timeLimit"] = "";
$TPL["task_timeBest"] or $TPL["task_timeBest"] = "";
$TPL["task_timeWorst"] or $TPL["task_timeWorst"] = "";
$TPL["task_timeExpected"] or $TPL["task_timeExpected"] = "";
$TPL["percentComplete"] = $task->get_percentComplete();
// Generate navigation links
if (has("project") && $task->get_id()) {
    $project = $task->get_foreign_object("project");
    $project->set_values("project_");
    if ($project->get_id()) {
        $ops["taskID"] = $task->get_id();
Пример #2
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;
 }
Пример #3
0
    function email_move_status_to_manager($direction, $info)
    {
        $current_user =& singleton("current_user");
        $project = $this->get_foreign_object("project");
        $projectManagers = $project->get_timeSheetRecipients();
        // Can get forwards to "manager" only from "edit" or "rejected"
        if ($direction == "forwards") {
            //forward to manager requires the timesheet to be owned by the current
            //user or TIME_INVOICE_TIMESHEETS
            //project managers may not do this
            if (!($this->get_value("personID") == $current_user->get_id() || $this->have_perm(PERM_TIME_INVOICE_TIMESHEETS))) {
                alloc_error("You do not have permission to change this timesheet.");
            }
            $this->set_value("dateSubmittedToManager", date("Y-m-d"));
            $this->set_value("dateRejected", "");
            // Check for time overrun
            $overrun_tasks = array();
            $db = new db_alloc();
            $task_id_query = prepare("SELECT DISTINCT taskID FROM timeSheetItem WHERE timeSheetID=%d ORDER BY dateTimeSheetItem, timeSheetItemID", $this->get_id());
            $db->query($task_id_query);
            while ($db->next_record()) {
                $task = new task();
                $task->read_db_record($db);
                $task->select();
                if ($task->get_value('timeLimit') > 0) {
                    $total_billed_time = $task->get_time_billed(false) / 3600;
                    if ($total_billed_time > $task->get_value('timeLimit')) {
                        $overrun_tasks[] = sprintf(" * %d %s (limit: %.02f hours, billed so far: %.02f hours)", $task->get_id(), $task->get_value('taskName'), $task->get_value('timeLimit'), $total_billed_time);
                    }
                }
                $hasItems = true;
            }
            if (!$hasItems) {
                return alloc_error('Unable to submit time sheet, no items have been added.');
            }
            if (count($overrun_tasks)) {
                $overrun_notice = "\n\nThe following tasks billed on this timesheet have exceeded their time estimates:\n";
                $overrun_notice .= implode("\n", $overrun_tasks);
            }
            foreach ($info["projectManagers"] as $pm) {
                $email = array();
                $email["type"] = "timesheet_submit";
                $email["to"] = $info["people_cache"][$pm]["emailAddress"];
                $email["subject"] = commentTemplate::populate_string(config::get_config_item("emailSubject_timeSheetToManager"), "timeSheet", $this->get_id());
                $email["body"] = <<<EOD
  To Manager: {$info["people_cache"][$pm]["name"]}
  Time Sheet: {$info["url"]}
Submitted By: {$info["timeSheet_personID_name"]}
 For Project: {$info["projectName"]}

A timesheet has been submitted for your approval. If it is satisfactory,
submit the timesheet to the Administrator. If not, make it editable again for
re-submission.{$overrun_notice}

EOD;
                $this->get_value("billingNote") and $email["body"] .= "\n\nBilling Note: " . $this->get_value("billingNote");
                $msg[] = $this->shootEmail($email);
            }
            // Can get backwards to "manager" only from "admin"
        } else {
            if ($direction == "backwards") {
                //admin->manager requires APPROVE_TIMESHEETS
                if (!$this->have_perm(PERM_TIME_INVOICE_TIMESHEETS)) {
                    //no permission, go away
                    alloc_error("You do not have permission to change this timesheet.");
                }
                $email = array();
                $email["type"] = "timesheet_reject";
                $email["to"] = $info["approvedByManagerPersonID_email"];
                $email["subject"] = commentTemplate::populate_string(config::get_config_item("emailSubject_timeSheetFromAdministrator"), "timeSheet", $this->get_id());
                $email["body"] = <<<EOD
  To Manager: {$info["approvedByManagerPersonID_name"]}
  Time Sheet: {$info["url"]}
Submitted By: {$info["timeSheet_personID_name"]}
 For Project: {$info["projectName"]}
 Rejected By: {$info["people_cache"][$current_user->get_id()]["name"]}

EOD;
                $this->get_value("billingNote") and $email["body"] .= "Billing Note: " . $this->get_value("billingNote");
                $msg[] = $this->shootEmail($email);
                $this->set_value("dateRejected", date("Y-m-d"));
            }
        }
        $this->set_value("status", "manager");
        $this->set_value("dateSubmittedToAdmin", "");
        $this->set_value("approvedByAdminPersonID", "");
        return $msg;
    }
Пример #4
0
function show_timeSheet_list($template)
{
    global $TPL;
    global $timeSheet;
    global $db;
    global $tskDesc;
    global $timeSheetItem;
    global $timeSheetID;
    $db_task = new db_alloc();
    if (is_object($timeSheet) && ($timeSheet->get_value("status") == "edit" || $timeSheet->get_value("status") == "rejected")) {
        $TPL["timeSheetItem_buttons"] = '
        <button type="submit" name="timeSheetItem_delete" value="1" class="delete_button">Delete<i class="icon-trash"></i></button>
        <button type="submit" name="timeSheetItem_edit" value="1">Edit<i class="icon-edit"></i></button>';
    }
    $TPL["currency"] = page::money($timeSheet->get_value("currencyTypeID"), '', "%S");
    $timeUnit = new timeUnit();
    $unit_array = $timeUnit->get_assoc_array("timeUnitID", "timeUnitLabelA");
    $item_query = prepare("SELECT * from timeSheetItem WHERE timeSheetID=%d", $timeSheetID);
    // If editing a timeSheetItem then don't display it in the list
    $timeSheetItemID = $_POST["timeSheetItemID"] or $timeSheetItemID = $_GET["timeSheetItemID"];
    $timeSheetItemID and $item_query .= prepare(" AND timeSheetItemID != %d", $timeSheetItemID);
    $item_query .= prepare(" GROUP BY timeSheetItemID ORDER BY dateTimeSheetItem, timeSheetItemID");
    $db->query($item_query);
    if (is_object($timeSheet)) {
        $project = $timeSheet->get_foreign_object("project");
        $row_projectPerson = projectPerson::get_projectPerson_row($project->get_id(), $timeSheet->get_value("personID"));
        $default_rate = array();
        if ($row_projectPerson && $row_projectPerson['rate'] > 0) {
            $default_rate['rate'] = $row_projectPerson['rate'];
            $default_rate['unit'] = $row_projectPerson['rateUnitID'];
        }
    }
    while ($db->next_record()) {
        $timeSheetItem = new timeSheetItem();
        $timeSheetItem->currency = $timeSheet->get_value("currencyTypeID");
        $timeSheetItem->read_db_record($db);
        $timeSheetItem->set_tpl_values("timeSheetItem_");
        $TPL["timeSheet_totalHours"] += $timeSheetItem->get_value("timeSheetItemDuration");
        $TPL["unit"] = $unit_array[$timeSheetItem->get_value("timeSheetItemDurationUnitID")];
        $br = "";
        $commentPrivateText = "";
        $text = $timeSheetItem->get_value('description', DST_HTML_DISPLAY);
        if ($timeSheetItem->get_value("commentPrivate")) {
            $commentPrivateText = "<b>[Private Comment]</b> ";
        }
        $text and $TPL["timeSheetItem_description"] = "<a href=\"" . $TPL["url_alloc_task"] . "taskID=" . $timeSheetItem->get_value('taskID') . "\">" . $text . "</a>";
        $text && $timeSheetItem->get_value("comment") and $br = "<br>";
        $timeSheetItem->get_value("comment") and $TPL["timeSheetItem_comment"] = $br . $commentPrivateText . page::to_html($timeSheetItem->get_value("comment"));
        $TPL["timeSheetItem_unit_times_rate"] = $timeSheetItem->calculate_item_charge($timeSheet->get_value("currencyTypeID"), $timeSheetItem->get_value("rate"));
        $m = new meta("timeSheetItemMultiplier");
        $tsMultipliers = $m->get_list();
        $timeSheetItem->get_value('multiplier') and $TPL["timeSheetItem_multiplier"] = $tsMultipliers[$timeSheetItem->get_value('multiplier')]['timeSheetItemMultiplierName'];
        // Check to see if this tsi is part of an overrun
        $TPL["timeSheetItem_class"] = "panel";
        $TPL["timeSheetItem_status"] = "";
        $row_messages = array();
        if ($timeSheetItem->get_value('taskID')) {
            $task = new task();
            $task->set_id($timeSheetItem->get_value('taskID'));
            $task->select();
            if ($task->get_value('timeLimit') > 0) {
                $total_billed_time = $task->get_time_billed(false) / 3600;
                // get_time_billed returns seconds, limit hours is in hours
                if ($total_billed_time > $task->get_value('timeLimit')) {
                    $row_messages[] = "<em class='faint warn nobr'>[ Exceeds Limit ]</em>";
                }
            }
        }
        // Highlight the rate if the project person has a non-zero rate and it doesn't match the item's rate
        if ($default_rate) {
            if ($timeSheetItem->get_value('rate') != $default_rate['rate'] || $timeSheetItem->get_value('timeSheetItemDurationUnitID') != $default_rate['unit']) {
                $row_messages[] = "<em class='faint warn nobr'>[ Modified rate ]</em>";
            }
        }
        if ($row_messages) {
            $TPL["timeSheetItem_status"] = implode("<br />", $row_messages);
            $TPL["timeSheetItem_class"] = "panel loud";
        }
        include_template($template);
    }
    $TPL["summary_totals"] = $timeSheet->pay_info["summary_unit_totals"];
}
Пример #5
0
    $q = prepare("SELECT rate,rateUnitID FROM projectPerson WHERE personID = %d AND projectID = %d", $personID, $projectID);
    $db->query($q);
    $db->next_record();
    $rate = $db->f("rate");
    $unitID = $db->f("rateUnitID");
    $t = new timeUnit();
    $timeUnits = $t->get_assoc_array("timeUnitID", "timeUnitSeconds", $unitID);
    $rate && $timeUnits[$unitID] and $hourly_rate = $rate / ($timeUnits[$unitID] / 60 / 60);
    return $hourly_rate;
}
if (is_object($project) && $project->get_id()) {
    if (is_array($TPL["taskListRows"])) {
        // $tasks is a global defined in show_tasks() for performance reasons
        foreach ($TPL["taskListRows"] as $tid => $t) {
            $hourly_rate = get_projectPerson_hourly_rate($t["personID"], $t["projectID"]);
            $time_remaining = $t["timeLimit"] - task::get_time_billed($t["taskID"]) / 60 / 60;
            $cost_remaining = $hourly_rate * $time_remaining;
            if ($cost_remaining > 0) {
                #echo "<br>Tally: ".$TPL["cost_remaining"] += $cost_remaining;
                $TPL["cost_remaining"] += $cost_remaining;
                $TPL["time_remaining"] += $time_remaining;
            }
            $t["timeLimit"] and $count_quoted_tasks++;
        }
        $TPL["time_remaining"] and $TPL["time_remaining"] = sprintf("%0.1f", $TPL["time_remaining"]) . " Hours.";
        $TPL["count_incomplete_tasks"] = count($TPL["taskListRows"]);
        $not_quoted = count($TPL["taskListRows"]) - $count_quoted_tasks;
        $not_quoted and $TPL["count_not_quoted_tasks"] = "(" . sprintf("%d", $not_quoted) . " tasks not included in estimate)";
    }
    $TPL["invoice_links"] .= "<a href=\"" . $TPL["url_alloc_invoice"] . "clientID=" . $clientID . "&projectID=" . $project->get_id() . "\">New Invoice</a>";
}