Exemplo n.º 1
0
 function project_stats()
 {
     // date from which a project 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")));
     $query = "SELECT * FROM project";
     $db = new db_alloc();
     $db_sub = new db_alloc();
     $db->query($query);
     while ($db->next_record()) {
         $project = new project();
         $project->read_db_record($db);
         $this->projects["total"]["total"]++;
         switch ($project->get_value("projectStatus")) {
             case "current":
             case "overdue":
                 $this->projects["current"]["total"]++;
                 break;
             case "archived":
                 $this->projects["archived"]["total"]++;
                 break;
         }
         $query = prepare("SELECT * FROM projectPerson WHERE projectID=%d", $project->get_id());
         $db_sub->query($query);
         while ($db_sub->next_record()) {
             $projectPerson = new projectPerson();
             $projectPerson->read_db_record($db_sub);
             $this->projects["total"][$projectPerson->get_value("personID")]++;
             switch ($project->get_value("projectStatus")) {
                 case "current":
                 case "overdue":
                     $this->projects["current"][$projectPerson->get_value("personID")]++;
                     break;
                 case "archived":
                     $this->projects["archived"][$projectPerson->get_value("personID")]++;
                     break;
             }
             if ($project->get_value("dateActualStart") != "") {
                 if (!isset($this->projects["all"][$projectPerson->get_value("personID")])) {
                     $this->projects["all"][$projectPerson->get_value("personID")] = array();
                 }
                 $this->projects["all"][$projectPerson->get_value("personID")][$project->get_value("dateActualStart")]++;
                 $this->projects["all"][$projectPerson->get_value("personID")]["total"]++;
                 $this->projects["all"]["total"][$project->get_value("dateActualStart")]++;
                 if (strcmp($date, $project->get_value("dateActualStart")) <= 0) {
                     if (!isset($this->projects["new"][$projectPerson->get_value("personID")])) {
                         $this->projects["new"][$projectPerson->get_value("personID")] = array();
                     }
                     $this->projects["new"][$projectPerson->get_value("personID")][$project->get_value("dateActualStart")]++;
                     $this->projects["new"][$projectPerson->get_value("personID")]["total"]++;
                     $this->projects["new"]["total"][$project->get_value("dateActualStart")]++;
                 }
             }
         }
     }
     return $this->projects;
 }
Exemplo n.º 2
0
{
    global $person_query;
    global $project;
    global $TPL;
    $db = new db_alloc();
    $db->query($person_query);
    while ($db->next_record()) {
        $person = new person();
        $person->read_db_record($db);
        $person->set_values("person_");
        $TPL["graphTitle"] = urlencode($person->get_name());
        include_template($template_name);
    }
}
$projectID = $_POST["projectID"] or $projectID = $_GET["projectID"];
if ($projectID) {
    $project = new project();
    $project->set_id($projectID);
    $project->select();
    $TPL["navigation_links"] = $project->get_navigation_links();
    $person_query = prepare("SELECT person.*\n                             FROM person, projectPerson\n                            WHERE person.personID = projectPerson.personID\n                              AND projectPerson.projectID=%d", $project->get_id());
} else {
    if ($_GET["personID"]) {
        $person_query = prepare("SELECT * FROM person WHERE personID = %d ORDER BY username", $_GET["personID"]);
    } else {
        $person_query = prepare("SELECT * FROM person ORDER BY username");
    }
}
$TPL["projectID"] = $projectID;
$TPL["main_alloc_title"] = "Allocation Graph - " . APPLICATION_NAME;
include_template("templates/personGraphM.tpl");
Exemplo n.º 3
0
         $client = new client();
         $client->read_db_record($db);
         $parent_names[$client->get_id()] = $client->get_value('clientName');
     }
 } else {
     if ($parentType == "project") {
         if ($current_user->have_role("admin")) {
             $query = "SELECT * FROM project WHERE projectStatus != 'Archived' ORDER BY projectName";
         } else {
             $query = prepare("SELECT * \n                          FROM project \n                     LEFT JOIN projectPerson ON project.projectID=projectPerson.projectID \n                         WHERE personID='%d' \n                           AND projectStatus != 'Archived'\n                      ORDER BY projectName", $personID);
         }
         $db->query($query);
         while ($db->next_record()) {
             $project = new project();
             $project->read_db_record($db);
             $parent_names[$project->get_id()] = $project->get_value('projectName');
         }
     } else {
         if ($parentType == "task") {
             if ($current_user->have_role("admin")) {
                 $query = "SELECT * FROM task";
             } else {
                 $query = prepare("SELECT * FROM task WHERE personID=%d ORDER BY taskName", $personID);
             }
             $db->query($query);
             while ($db->next_record()) {
                 $task = new task();
                 $task->read_db_record($db);
                 if (substr($task->get_value("taskStatus"), 0, 6) != "closed") {
                     $parent_names[$task->get_id()] = $task->get_value('taskName');
                 }
Exemplo n.º 4
0
    $project->select();
    $projectManagers = $project->get_timeSheetRecipients();
    if (!$projectManagers) {
        $TPL["managers"] = "N/A";
        $TPL["timeSheet_dateSubmittedToManager"] = "N/A";
        $TPL["timeSheet_approvedByManagerPersonID_username"] = "******";
    } else {
        count($projectManagers) > 1 and $TPL["manager_plural"] = "s";
        $people =& get_cached_table("person");
        foreach ($projectManagers as $pID) {
            $TPL["managers"] .= $commar . $people[$pID]["name"];
            $commar = ", ";
        }
    }
    $clientID = $project->get_value("clientID");
    $projectID = $project->get_id();
    // Get client name
    $client = $project->get_foreign_object("client");
    $TPL["clientName"] = $client_link;
    $TPL["clientID"] = $clientID = $client->get_id();
    $TPL["show_client_options"] = $client_link;
}
list($client_select, $client_link, $project_select, $project_link) = client::get_client_and_project_dropdowns_and_links($clientID, $projectID, true);
$TPL["invoice_link"] = $timeSheet->get_invoice_link();
list($amount_used, $amount_allocated) = $timeSheet->get_amount_allocated();
if ($amount_allocated) {
    $TPL["amount_allocated_label"] = "Amount Used / Allocated:";
    $TPL["amount_allocated"] = $amount_allocated;
    $TPL["amount_used"] = $amount_used . " / ";
}
if (!$timeSheet->get_id() || $timeSheet->get_value("status") == "edit" || $timeSheet->get_value("status") == "rejected") {
Exemplo n.º 5
0
 $p2->read_row_record($p->row());
 $p2->set_id("");
 $p2->set_value("projectName", $_POST["copy_project_name"]);
 $p2->set_value("projectShortName", "");
 $p2->save();
 $TPL["message_good"][] = "Project details copied successfully.";
 // Copy project people
 $q = prepare("SELECT * FROM projectPerson WHERE projectID = %d", $p->get_id());
 $db = new db_alloc();
 $db->query($q);
 while ($row = $db->row()) {
     $projectPerson = new projectPerson();
     $projectPerson->currency = $p->get_value("currencyTypeID");
     $projectPerson->read_row_record($row);
     $projectPerson->set_id("");
     $projectPerson->set_value("projectID", $p2->get_id());
     $projectPerson->save();
     $TPL["message_good"]["projectPeople"] = "Project people copied successfully.";
 }
 // Copy commissions
 $q = prepare("SELECT * FROM projectCommissionPerson WHERE projectID = %d", $p->get_id());
 $db = new db_alloc();
 $db->query($q);
 while ($row = $db->row()) {
     $projectCommissionPerson = new projectCommissionPerson();
     $projectCommissionPerson->read_row_record($row);
     $projectCommissionPerson->set_id("");
     $projectCommissionPerson->set_value("projectID", $p2->get_id());
     $projectCommissionPerson->save();
     $TPL["message_good"]["projectCommissions"] = "Project commissions copied successfully.";
 }
Exemplo n.º 6
0
 function populate_string($str, $entity, $entityID = false)
 {
     // Actually do the text substitution
     $current_user =& singleton("current_user");
     is_object($current_user) and $swap["cu"] = person::get_fullname($current_user->get_id());
     if ($entity == "timeSheet" && $entityID) {
         $timeSheet = new timeSheet();
         $timeSheet->set_id($entityID);
         $timeSheet->select();
         $timeSheet->load_pay_info();
         foreach ($timeSheet->pay_info as $k => $v) {
             $swap[$k] = $v;
         }
         if ($timeSheet->get_value("approvedByManagerPersonID")) {
             $swap["tm"] = person::get_fullname($timeSheet->get_value("approvedByManagerPersonID"));
         } else {
             $project = $timeSheet->get_foreign_object("project");
             $projectManagers = $project->get_timeSheetRecipients();
             if (is_array($projectManagers) && count($projectManagers)) {
                 $people =& get_cached_table("person");
                 foreach ($projectManagers as $pID) {
                     $swap["tm"] .= $commar . $people[$pID]["name"];
                     $commar = ", ";
                 }
             }
         }
         if ($timeSheet->get_value("approvedByAdminPersonID")) {
             $swap["tc"] = person::get_fullname($timeSheet->get_value("approvedByAdminPersonID"));
         } else {
             $people =& get_cached_table("person");
             $timeSheetAdministrators = config::get_config_item('defaultTimeSheetAdminList');
             if (count($timeSheetAdministrators)) {
                 $swap["tc"] = "";
                 $comma = "";
                 foreach ($timeSheetAdministrators as $adminID) {
                     $swap["tc"] .= $comma . $people[$adminID]["name"];
                     $comma = ", ";
                 }
             } else {
                 $swap["tc"] = 'no-one';
             }
         }
         $swap["ti"] = $timeSheet->get_id();
         $swap["to"] = person::get_fullname($timeSheet->get_value("personID"));
         $swap["ta"] = person::get_fullname($timeSheet->get_value("personID"));
         $swap["tf"] = $timeSheet->get_value("dateFrom");
         $swap["tt"] = $timeSheet->get_value("dateTo");
         $swap["ts"] = $timeSheet->get_timeSheet_status();
         $swap["tu"] = config::get_config_item("allocURL") . "time/timeSheet.php?timeSheetID=" . $timeSheet->get_id();
         $projectID = $timeSheet->get_value("projectID");
     }
     if ($entity == "task" && $entityID) {
         $task = new task();
         $task->set_id($entityID);
         $task->select();
         $swap["ti"] = $task->get_id();
         $swap["to"] = person::get_fullname($task->get_value("creatorID"));
         $swap["ta"] = person::get_fullname($task->get_value("personID"));
         $swap["tm"] = person::get_fullname($task->get_value("managerID"));
         $swap["tc"] = person::get_fullname($task->get_value("closerID"));
         $swap["tn"] = $task->get_value("taskName");
         $swap["td"] = $task->get_value("taskDescription");
         $swap["tu"] = config::get_config_item("allocURL") . "task/task.php?taskID=" . $task->get_id();
         $swap["tp"] = $task->get_priority_label();
         $swap["ts"] = $task->get_task_status("label");
         $swap["teb"] = $task->get_value("timeBest");
         $swap["tem"] = $task->get_value("timeExpected");
         $swap["tew"] = $task->get_value("timeWorst");
         $swap["tep"] = person::get_fullname($task->get_value("estimatorID"));
         //time estimate person, when it's implemented
         $projectID = $task->get_value("projectID");
     }
     if ($entity == "project" && $entityID || $projectID) {
         $project = new project();
         if ($projectID) {
             $project->set_id($projectID);
         } else {
             $project->set_id($entityID);
         }
         $project->select();
         $swap["pn"] = $project->get_value("projectName");
         $swap["pi"] = $project->get_id();
         $clientID = $project->get_value("clientID");
     }
     if ($entity == "client" && $entityID || $clientID) {
         $client = new client();
         if ($clientID) {
             $client->set_id($clientID);
         } else {
             $client->set_id($entityID);
         }
         $client->select();
         $swap["li"] = $client->get_id();
         $swap["cc"] = $client->get_value("clientName");
     }
     $swap["cd"] = config::get_config_item("companyContactAddress");
     $swap["cd"] .= " " . config::get_config_item("companyContactAddress2");
     $swap["cd"] .= " " . config::get_config_item("companyContactAddress3");
     $swap["cd"] .= "\nP: " . config::get_config_item("companyContactPhone");
     $swap["cd"] .= "\nF: " . config::get_config_item("companyContactFax");
     $swap["cd"] .= "\nE: " . config::get_config_item("companyContactEmail");
     $swap["cd"] .= "\nW: " . config::get_config_item("companyContactHomePage");
     $swap["cn"] = config::get_config_item("companyName");
     $swap["c1"] = config::get_config_item("companyContactAddress");
     $swap["c2"] = config::get_config_item("companyContactAddress2");
     $swap["c3"] = config::get_config_item("companyContactAddress3");
     $swap["ce"] = config::get_config_item("companyContactEmail");
     $swap["cp"] = config::get_config_item("companyContactPhone");
     $swap["cf"] = config::get_config_item("companyContactFax");
     $swap["cw"] = config::get_config_item("companyContactHomePage");
     foreach ($swap as $k => $v) {
         $str = str_replace("%" . $k, $v, $str);
     }
     return $str;
 }
Exemplo n.º 7
0
function export_csv($projectID)
{
    $project = new project();
    $project->set_id($projectID);
    $project->select();
    $retstr = '"Task Name","Estimated Time","Assignee"';
    // Export all tasks in the project
    $taskOptions["projectIDs"] = array($project->get_id());
    $taskOptions["return"] = "array";
    $taskOptions["taskView"] = "byProject";
    $tasks = task::get_list($taskOptions);
    // Sort by taskID--we assume taskIDs were assigned linearly on import/creation--so as to produce an identical file
    foreach ($tasks as $task) {
        $taskIDs[] = $task['taskID'];
    }
    array_multisort($taskIDs, $tasks);
    foreach ($tasks as $task) {
        $assignee = new person();
        $assignee->set_id($task['personID']);
        $assignee->select();
        $estimatedHours = $task['timeExpected'];
        is_numeric($estimatedHours) or $estimatedHours = 0;
        $retstr .= "\n" . export_escape_csv($task['taskName']) . ',' . export_escape_csv($estimatedHours) . ',' . export_escape_csv($assignee->get_name(array("format" => "nick")));
    }
    return $retstr;
}