コード例 #1
0
ファイル: projectPerson.inc.php プロジェクト: cjbayliss/alloc
 function get_rate($projectID, $personID)
 {
     // Try to get the person's rate from the following sources:
     // project.defaultTimeSheetRate
     // person.defaultTimeSheetRate
     // config.name == defaultTimeSheetRate
     // First check the project for a rate
     $project = new project($projectID);
     $row = array('rate' => $project->get_value("defaultTimeSheetRate"), 'unit' => $project->get_value("defaultTimeSheetRateUnitID"));
     if (imp($row['rate']) && $row['unit']) {
         return $row;
     }
     // Next check person, which is in global currency rather than project currency - conversion required
     $db = new db_alloc();
     $q = prepare("SELECT defaultTimeSheetRate as rate, defaultTimeSheetRateUnitID as unit FROM person WHERE personID = %d", $personID);
     $db->query($q);
     $row = $db->row();
     if (imp($row['rate']) && $row['unit']) {
         if ($project->get_value("currencyTypeID") != config::get_config_item("currency")) {
             $row['rate'] = exchangeRate::convert(config::get_config_item("currency"), $row["rate"], $project->get_value("currencyTypeID"));
         }
         return $row;
     }
     // Lowest priority: global
     $rate = config::get_config_item("defaultTimeSheetRate");
     $unit = config::get_config_item("defaultTimeSheetUnit");
     if (imp($rate) && $unit) {
         if (config::get_config_item("currency") && $project->get_value("currencyTypeID")) {
             $rate = exchangeRate::convert(config::get_config_item("currency"), $rate, $project->get_value("currencyTypeID"));
         }
         return array('rate' => $rate, 'unit' => $unit);
     }
 }
コード例 #2
0
ファイル: weeklyTime.php プロジェクト: cjbayliss/alloc
function show_timeSheetItems($template_name)
{
    global $date_to_view;
    $current_user =& singleton("current_user");
    global $TPL;
    $query = prepare("SELECT * \n                      FROM timeSheetItem \n                           LEFT JOIN timeSheet ON timeSheetItem.timeSheetID = timeSheet.timeSheetID\n                           LEFT JOIN project ON timeSheet.projectID = project.projectID\n                      WHERE dateTimeSheetItem='%s'\n                            AND timeSheet.personID=%d", date("Y-m-d", $date_to_view), $current_user->get_id());
    $db = new db_alloc();
    $db->query($query);
    while ($db->next_record()) {
        $timeSheetItem = new timeSheetItem();
        $timeSheetItem->read_db_record($db);
        $timeSheetItem->set_values();
        if ($timeSheetItem->get_value("unit") == "Hour") {
            $TPL["daily_hours_total"] += $timeSheetItem->get_value("timeSheetItemDuration");
        }
        $project = new project();
        $project->read_db_record($db);
        $project->set_values();
        if ($project->get_value("projectShortName")) {
            $TPL["item_description"] = $project->get_value("projectShortName");
        } else {
            $TPL["item_description"] = $project->get_value("projectName");
        }
        include_template($template_name);
    }
}
コード例 #3
0
ファイル: stats.inc.php プロジェクト: cjbayliss/alloc
 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;
 }
コード例 #4
0
ファイル: expenseForm.php プロジェクト: cjbayliss/alloc
function show_all_exp($template)
{
    global $TPL;
    global $expenseForm;
    global $db;
    global $transaction_to_edit;
    if ($expenseForm->get_id()) {
        if ($_POST["transactionID"] && ($_POST["edit"] || is_object($transaction_to_edit) && $transaction_to_edit->get_id())) {
            // if edit is clicked OR if we've rejected changes made to something so are still editing it
            $query = prepare("SELECT * FROM transaction WHERE expenseFormID=%d AND transactionID<>%d ORDER BY transactionID DESC", $expenseForm->get_id(), $_POST["transactionID"]);
        } else {
            $query = prepare("SELECT * FROM transaction WHERE expenseFormID=%d ORDER BY transactionID DESC", $expenseForm->get_id());
        }
        $db->query($query);
        while ($db->next_record()) {
            $transaction = new transaction();
            $transaction->read_db_record($db);
            $transaction->set_values();
            $transaction->get_value("quantity") and $TPL["amount"] = $transaction->get_value("amount") / $transaction->get_value("quantity");
            $TPL["lineTotal"] = $TPL["amount"] * $transaction->get_value("quantity");
            $tf = new tf();
            $tf->set_id($transaction->get_value("fromTfID"));
            $tf->select();
            $TPL["fromTfIDLink"] = $tf->get_link();
            $tf = new tf();
            $tf->set_id($transaction->get_value("tfID"));
            $tf->select();
            $TPL["tfIDLink"] = $tf->get_link();
            $projectID = $transaction->get_value("projectID");
            if ($projectID) {
                $project = new project();
                $project->set_id($transaction->get_value("projectID"));
                $project->select();
                $TPL["projectName"] = $project->get_value("projectName");
            }
            if ($transaction->get_value("fromTfID") == config::get_config_item("expenseFormTfID")) {
                $TPL['expense_class'] = "loud";
            } else {
                $TPL['expense_class'] = "";
            }
            include_template($template);
        }
    }
}
コード例 #5
0
ファイル: projectGraph.php プロジェクト: cjbayliss/alloc
function show_projects($template_name)
{
    global $TPL;
    global $default;
    $_FORM = task::load_form_data($defaults);
    $arr = task::load_task_filter($_FORM);
    is_array($arr) and $TPL = array_merge($TPL, $arr);
    if (is_array($_FORM["projectID"])) {
        $projectIDs = $_FORM["projectID"];
        foreach ($projectIDs as $projectID) {
            $project = new project();
            $project->set_id($projectID);
            $project->select();
            $_FORM["projectID"] = array($projectID);
            $TPL["graphTitle"] = urlencode($project->get_value("projectName"));
            $arr = task::load_task_filter($_FORM);
            is_array($arr) and $TPL = array_merge($TPL, $arr);
            include_template($template_name);
        }
    }
}
コード例 #6
0
ファイル: productSale.inc.php プロジェクト: cjbayliss/alloc
 function translate_meta_tfID($tfID = "")
 {
     // The special -1 and -2 tfID's represent META TF, i.e. calculated at runtime
     // -1 == META: Project TF
     if ($tfID == -1) {
         if ($this->get_value("projectID")) {
             $project = new project();
             $project->set_id($this->get_value("projectID"));
             $project->select();
             $tfID = $project->get_value("cost_centre_tfID");
         }
         if (!$tfID) {
             alloc_error("Unable to use META: Project TF. Please ensure the project has a TF set, or adjust the transactions.");
         }
         // -2 == META: Salesperson TF
     } else {
         if ($tfID == -2) {
             if ($this->get_value("personID")) {
                 $person = new person();
                 $person->set_id($this->get_value("personID"));
                 $person->select();
                 $tfID = $person->get_value("preferred_tfID");
                 if (!$tfID) {
                     alloc_error("Unable to use META: Salesperson TF. Please ensure the Saleperson has a Preferred Payment TF.");
                 }
             } else {
                 alloc_error("Unable to use META: Salesperson TF. No product salesperson set.");
             }
         } else {
             if ($tfID == -3) {
                 $tfID = $this->get_value("tfID");
                 $tfID or alloc_error("Unable to use META: Sale TF not set.");
             }
         }
     }
     return $tfID;
 }
コード例 #7
0
ファイル: import_export.inc.php プロジェクト: cjbayliss/alloc
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();
}
コード例 #8
0
ファイル: rss.php プロジェクト: cjbayliss/alloc
 if (!$row['personID']) {
     $name = "Unassigned";
 } else {
     $name = $people[$row['personID']]['username'];
 }
 if ($row['field'] != "taskStatus" || array_search($row['taskStatus'], $status_types) !== FALSE) {
     $taskName = escape_xml($row['taskName']);
     $project = null;
     if ($show_project) {
         $project = new project();
         $project->set_id($row['projectID']);
         $project->select();
     }
     if ($summary) {
         if ($show_project) {
             $projectName = $project->get_value('projectShortName');
         }
         $el['desc'] = sprintf('%s: %d %s "%s" %s', $name, $row['taskID'], $projectName, $taskName, $row['taskStatus']);
     } else {
         if ($show_project) {
             $projectName = "(" . $project->get_value("projectName") . ")";
         }
         if ($row['field'] == "taskStatus") {
             $el['desc'] = sprintf('Task #%d "%s" %s status changed to %s', $row['taskID'], $taskName, $projectName, $row['taskStatus']);
         } else {
             if ($row['field'] == "personID") {
                 $el['desc'] = sprintf('Task #%d "%s" %s assigned to %s', $row['taskID'], $taskName, $projectName, $name);
             } else {
                 $el['desc'] = "error!";
             }
         }
コード例 #9
0
ファイル: reminder.php プロジェクト: cjbayliss/alloc
         $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');
                 }
コード例 #10
0
ファイル: timeSheet.php プロジェクト: cjbayliss/alloc
    $project->set_id($projectID);
    $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 . " / ";
}
コード例 #11
0
ファイル: project.php プロジェクト: cjbayliss/alloc
 $p->set_id($_POST["copy_projectID"]);
 if ($p->select()) {
     $p2 = new project();
     $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());
コード例 #12
0
ファイル: timeSheet.inc.php プロジェクト: cjbayliss/alloc
 function add_timeSheetItem($stuff)
 {
     $current_user =& singleton("current_user");
     $errstr = "Failed to record new time sheet item. ";
     $taskID = $stuff["taskID"];
     $projectID = $stuff["projectID"];
     $duration = $stuff["duration"];
     $comment = $stuff["comment"];
     $emailUID = $stuff["msg_uid"];
     $emailMessageID = $stuff["msg_id"];
     $date = $stuff["date"];
     $unit = $stuff["unit"];
     $multiplier = $stuff["multiplier"];
     if ($taskID) {
         $task = new task();
         $task->set_id($taskID);
         $task->select();
         $projectID = $task->get_value("projectID");
         $extra = " for task " . $taskID;
     }
     $projectID or alloc_error(sprintf($errstr . "No project found%s.", $extra));
     $row_projectPerson = projectPerson::get_projectPerson_row($projectID, $current_user->get_id());
     $row_projectPerson or alloc_error($errstr . "The person(" . $current_user->get_id() . ") has not been added to the project(" . $projectID . ").");
     if ($row_projectPerson && $projectID) {
         if ($stuff["timeSheetID"]) {
             $q = prepare("SELECT *\n                        FROM timeSheet\n                       WHERE status = 'edit'\n                         AND personID = %d\n                         AND timeSheetID = %d\n                    ORDER BY dateFrom\n                       LIMIT 1\n                  ", $current_user->get_id(), $stuff["timeSheetID"]);
             $db = new db_alloc();
             $db->query($q);
             $row = $db->row();
             $row or alloc_error("Couldn't find an editable time sheet with that ID.");
         } else {
             $q = prepare("SELECT *\n                        FROM timeSheet\n                       WHERE status = 'edit'\n                         AND projectID = %d\n                         AND personID = %d\n                    ORDER BY dateFrom\n                       LIMIT 1\n                  ", $projectID, $current_user->get_id());
             $db = new db_alloc();
             $db->query($q);
             $row = $db->row();
         }
         // If no timeSheets add a new one
         if (!$row) {
             $project = new project();
             $project->set_id($projectID);
             $project->select();
             $timeSheet = new timeSheet();
             $timeSheet->set_value("projectID", $projectID);
             $timeSheet->set_value("status", "edit");
             $timeSheet->set_value("personID", $current_user->get_id());
             $timeSheet->set_value("recipient_tfID", $current_user->get_value("preferred_tfID"));
             $timeSheet->set_value("customerBilledDollars", page::money($project->get_value("currencyTypeID"), $project->get_value("customerBilledDollars"), "%mo"));
             $timeSheet->set_value("currencyTypeID", $project->get_value("currencyTypeID"));
             $timeSheet->save();
             $timeSheetID = $timeSheet->get_id();
             // Else use the first timesheet we found
         } else {
             $timeSheetID = $row["timeSheetID"];
         }
         $timeSheetID or alloc_error($errstr . "Couldn't locate an existing, or create a new Time Sheet.");
         // Add new time sheet item
         if ($timeSheetID) {
             $timeSheet = new timeSheet();
             $timeSheet->set_id($timeSheetID);
             $timeSheet->select();
             $tsi = new timeSheetItem();
             $tsi->currency = $timeSheet->get_value("currencyTypeID");
             $tsi->set_value("timeSheetID", $timeSheetID);
             $d = $date or $d = date("Y-m-d");
             $tsi->set_value("dateTimeSheetItem", $d);
             $tsi->set_value("timeSheetItemDuration", $duration);
             $tsi->set_value("timeSheetItemDurationUnitID", $unit);
             if (is_object($task)) {
                 $tsi->set_value("description", $task->get_name());
                 $tsi->set_value("taskID", sprintf("%d", $taskID));
                 $_POST["timeSheetItem_taskID"] = sprintf("%d", $taskID);
                 // this gets used in timeSheetItem->save();
             }
             $tsi->set_value("personID", $current_user->get_id());
             $tsi->set_value("rate", page::money($timeSheet->get_value("currencyTypeID"), $row_projectPerson["rate"], "%mo"));
             $tsi->set_value("multiplier", $multiplier);
             $tsi->set_value("comment", $comment);
             $tsi->set_value("emailUID", $emailUID);
             $tsi->set_value("emailMessageID", $emailMessageID);
             $tsi->save();
             $id = $tsi->get_id();
             $tsi = new timeSheetItem();
             $tsi->set_id($id);
             $tsi->select();
             $ID = $tsi->get_value("timeSheetID");
         }
     }
     if ($ID) {
         return array("status" => "yay", "message" => $ID);
     } else {
         alloc_error($errstr . "Time not added.");
     }
 }
コード例 #13
0
ファイル: client.inc.php プロジェクト: cjbayliss/alloc
 function get_client_and_project_dropdowns_and_links($clientID = false, $projectID = false, $onlymine = false)
 {
     // This function returns dropdown lists and links for both client and
     // project. The two dropdown lists are linked, in that if you change the
     // client, then the project dropdown dynamically updates
     global $TPL;
     $project = new project();
     $project->set_id($projectID);
     $project->select();
     if (!$clientID) {
         $clientID = $project->get_value("clientID");
     }
     $client = new client();
     $client->set_id($clientID);
     $client->select();
     $options["clientStatus"] = "Current";
     $ops = client::get_list($options);
     $ops = array_kv($ops, "clientID", "clientName");
     $client->get_id() and $ops[$client->get_id()] = $client->get_value("clientName");
     $client_select = "<select id=\"clientID\" name=\"clientID\" onChange=\"makeAjaxRequest('" . $TPL["url_alloc_updateProjectListByClient"] . "clientID='+\$('#clientID').attr('value')+'&onlymine=" . sprintf("%d", $onlymine) . "','projectDropdown')\"><option></option>";
     $client_select .= page::select_options($ops, $clientID, 100) . "</select>";
     $client_link = $client->get_link();
     $project_select = '<div id="projectDropdown" style="display:inline">' . $project->get_dropdown_by_client($clientID, $onlymine) . '</div>';
     $project_link = $project->get_link();
     return array($client_select, $client_link, $project_select, $project_link);
 }
コード例 #14
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;
 }
コード例 #15
0
ファイル: reminder.inc.php プロジェクト: cjbayliss/alloc
 function is_alive()
 {
     $type = $this->get_value('reminderType');
     if ($type == "project") {
         $project = new project();
         $project->set_id($this->get_value('reminderLinkID'));
         if ($project->select() == false || $project->get_value('projectStatus') == "Archived") {
             return false;
         }
     } else {
         if ($type == "task") {
             $task = new task();
             $task->set_id($this->get_value('reminderLinkID'));
             if ($task->select() == false || substr($task->get_value("taskStatus"), 0, 6) == 'closed') {
                 return false;
             }
         } else {
             if ($type == "client") {
                 $client = new client();
                 $client->set_id($this->get_value('reminderLinkID'));
                 if ($client->select() == false || $client->get_value('clientStatus') == "Archived") {
                     return false;
                 }
             }
         }
     }
     return true;
 }
コード例 #16
0
 function get_printable_timeSheet_file($timeSheetID, $timeSheetPrintMode, $printDesc, $format)
 {
     global $TPL;
     $TPL["timeSheetID"] = $timeSheetID;
     $TPL["timeSheetPrintMode"] = $timeSheetPrintMode;
     $TPL["printDesc"] = $printDesc;
     $TPL["format"] = $format;
     $db = new db_alloc();
     if ($timeSheetID) {
         $timeSheet = new timeSheet();
         $timeSheet->set_id($timeSheetID);
         $timeSheet->select();
         $timeSheet->set_tpl_values();
         $person = $timeSheet->get_foreign_object("person");
         $TPL["timeSheet_personName"] = $person->get_name();
         $timeSheet->set_tpl_values("timeSheet_");
         // Display the project name.
         $project = new project();
         $project->set_id($timeSheet->get_value("projectID"));
         $project->select();
         $TPL["timeSheet_projectName"] = $project->get_value("projectName", DST_HTML_DISPLAY);
         // Get client name
         $client = $project->get_foreign_object("client");
         $client->set_tpl_values();
         $TPL["clientName"] = $client->get_value("clientName", DST_HTML_DISPLAY);
         $TPL["companyName"] = config::get_config_item("companyName");
         $TPL["companyNos1"] = config::get_config_item("companyACN");
         $TPL["companyNos2"] = config::get_config_item("companyABN");
         unset($br);
         $phone = config::get_config_item("companyContactPhone");
         $fax = config::get_config_item("companyContactFax");
         $phone and $TPL["phone"] = "Ph: " . $phone;
         $fax and $TPL["fax"] = "Fax: " . $fax;
         $timeSheet->load_pay_info();
         $db->query(prepare("SELECT max(dateTimeSheetItem) AS maxDate\n                                ,min(dateTimeSheetItem) AS minDate\n                                ,count(timeSheetItemID) as count\n                            FROM timeSheetItem \n                           WHERE timeSheetID=%d ", $timeSheetID));
         $db->next_record();
         $timeSheet->set_id($timeSheetID);
         $timeSheet->select() || alloc_error("Unable to select time sheet, trying to use id: " . $timeSheetID);
         $TPL["period"] = format_date(DATE_FORMAT, $db->f("minDate")) . " to " . format_date(DATE_FORMAT, $db->f("maxDate"));
         $TPL["img"] = config::get_config_item("companyImage");
         $TPL["companyContactAddress"] = config::get_config_item("companyContactAddress");
         $TPL["companyContactAddress2"] = config::get_config_item("companyContactAddress2");
         $TPL["companyContactAddress3"] = config::get_config_item("companyContactAddress3");
         $email = config::get_config_item("companyContactEmail");
         $email and $TPL["companyContactEmail"] = "Email: " . $email;
         $web = config::get_config_item("companyContactHomePage");
         $web and $TPL["companyContactHomePage"] = "Web: " . $web;
         $TPL["footer"] = config::get_config_item("timeSheetPrintFooter");
         $TPL["taxName"] = config::get_config_item("taxName");
         $default_header = "Time Sheet";
         $default_id_label = "Time Sheet ID";
         $default_contractor_label = "Contractor";
         $default_total_label = "TOTAL AMOUNT PAYABLE";
         if ($timeSheetPrintMode == "money") {
             $default_header = "Tax Invoice";
             $default_id_label = "Invoice Number";
         }
         if ($timeSheetPrintMode == "estimate") {
             $default_header = "Estimate";
             $default_id_label = "Estimate Number";
             $default_contractor_label = "Issued By";
             $default_total_label = "TOTAL AMOUNT ESTIMATED";
         }
         if ($format != "html") {
             // Build PDF document
             $font1 = ALLOC_MOD_DIR . "util/fonts/Helvetica.afm";
             $font2 = ALLOC_MOD_DIR . "util/fonts/Helvetica-Oblique.afm";
             $pdf_table_options = array("showLines" => 0, "shaded" => 0, "showHeadings" => 0, "xPos" => "left", "xOrientation" => "right", "fontSize" => 10, "rowGap" => 0, "fontSize" => 10);
             $cols = array("one" => "", "two" => "", "three" => "", "four" => "");
             $cols3 = array("one" => "", "two" => "");
             $cols_settings["one"] = array("justification" => "right");
             $cols_settings["three"] = array("justification" => "right");
             $pdf_table_options2 = array("showLines" => 0, "shaded" => 0, "showHeadings" => 0, "width" => 400, "fontSize" => 10, "xPos" => "center", "xOrientation" => "center", "cols" => $cols_settings);
             $cols_settings2["gst"] = array("justification" => "right");
             $cols_settings2["money"] = array("justification" => "right");
             $pdf_table_options3 = array("showLines" => 2, "shaded" => 0, "width" => 400, "xPos" => "center", "fontSize" => 10, "cols" => $cols_settings2, "lineCol" => array(0.8, 0.8, 0.8), "splitRows" => 1, "protectRows" => 0);
             $cols_settings["two"] = array("justification" => "right", "width" => 80);
             $pdf_table_options4 = array("showLines" => 2, "shaded" => 0, "width" => 400, "showHeadings" => 0, "fontSize" => 10, "xPos" => "center", "cols" => $cols_settings, "lineCol" => array(0.8, 0.8, 0.8));
             $pdf = new Cezpdf();
             $pdf->ezSetMargins(90, 90, 90, 90);
             $pdf->selectFont($font1);
             $pdf->ezStartPageNumbers(436, 80, 10, 'right', 'Page {PAGENUM} of {TOTALPAGENUM}');
             $pdf->ezStartPageNumbers(200, 80, 10, 'left', '<b>' . $default_id_label . ': </b>' . $TPL["timeSheetID"]);
             $pdf->ezSetY(775);
             $TPL["companyName"] and $contact_info[] = array($TPL["companyName"]);
             $TPL["companyContactAddress"] and $contact_info[] = array($TPL["companyContactAddress"]);
             $TPL["companyContactAddress2"] and $contact_info[] = array($TPL["companyContactAddress2"]);
             $TPL["companyContactAddress3"] and $contact_info[] = array($TPL["companyContactAddress3"]);
             $TPL["companyContactEmail"] and $contact_info[] = array($TPL["companyContactEmail"]);
             $TPL["companyContactHomePage"] and $contact_info[] = array($TPL["companyContactHomePage"]);
             $TPL["phone"] and $contact_info[] = array($TPL["phone"]);
             $TPL["fax"] and $contact_info[] = array($TPL["fax"]);
             $pdf->selectFont($font2);
             $y = $pdf->ezTable($contact_info, false, "", $pdf_table_options);
             $pdf->selectFont($font1);
             $line_y = $y - 10;
             $pdf->setLineStyle(1, "round");
             $pdf->line(90, $line_y, 510, $line_y);
             $pdf->ezSetY(782);
             $image_jpg = ALLOC_LOGO;
             if (file_exists($image_jpg)) {
                 $pdf->ezImage($image_jpg, 0, sprintf("%d", config::get_config_item("logoScaleX")), 'none');
                 $y = 700;
             } else {
                 $y = $pdf->ezText($TPL["companyName"], 27, array("justification" => "right"));
             }
             $nos_y = $line_y + 22;
             $TPL["companyNos2"] and $nos_y = $line_y + 34;
             $pdf->ezSetY($nos_y);
             $TPL["companyNos1"] and $y = $pdf->ezText($TPL["companyNos1"], 10, array("justification" => "right"));
             $TPL["companyNos2"] and $y = $pdf->ezText($TPL["companyNos2"], 10, array("justification" => "right"));
             $pdf->ezSetY($line_y - 20);
             $y = $pdf->ezText($default_header, 20, array("justification" => "center"));
             $pdf->ezSetY($y - 20);
             $ts_info[] = array("one" => "<b>" . $default_id_label . ":</b>", "two" => $TPL["timeSheetID"], "three" => "<b>Date Issued:</b>", "four" => date("d/m/Y"));
             $ts_info[] = array("one" => "<b>Client:</b>", "two" => $TPL["clientName"], "three" => "<b>Project:</b>", "four" => $TPL["timeSheet_projectName"]);
             $ts_info[] = array("one" => "<b>" . $default_contractor_label . ":</b>", "two" => $TPL["timeSheet_personName"], "three" => "<b>Billing Period:</b>", "four" => $TPL["period"]);
             if ($timeSheetPrintMode == "estimate") {
                 // This line needs to be glued to the above line
                 $temp = array_pop($ts_info);
                 $temp["three"] = "";
                 // Nuke Billing Period for the Estimate version of the pdf.
                 $temp["four"] = "";
                 // Nuke Billing Period for the Estimate version of the pdf.
                 $ts_info[] = $temp;
             }
             $y = $pdf->ezTable($ts_info, $cols, "", $pdf_table_options2);
             $pdf->ezSetY($y - 20);
             if ($timeSheetPrintMode == "money" || $timeSheetPrintMode == "estimate") {
                 list($rows, $info) = $this->get_timeSheetItem_list_money($TPL["timeSheetID"]);
                 $cols2 = array("desc" => "Description", "units" => "Units", "money" => "Charges", "gst" => $TPL["taxName"]);
                 $taxPercent = config::get_config_item("taxPercent");
                 if ($taxPercent === '') {
                     unset($cols2["gst"]);
                 }
                 $rows[] = array("desc" => "<b>TOTAL</b>", "units" => $info["total_units"], "money" => $info["total"], "gst" => $info["total_gst"]);
                 $y = $pdf->ezTable($rows, $cols2, "", $pdf_table_options3);
                 $pdf->ezSetY($y - 20);
                 if ($taxPercent !== '') {
                     $totals[] = array("one" => "TOTAL " . $TPL["taxName"], "two" => $info["total_gst"]);
                 }
                 $totals[] = array("one" => "TOTAL CHARGES", "two" => $info["total"]);
                 $totals[] = array("one" => "<b>" . $default_total_label . "</b>", "two" => "<b>" . $info["total_inc_gst"] . "</b>");
                 $y = $pdf->ezTable($totals, $cols3, "", $pdf_table_options4);
             } else {
                 if ($timeSheetPrintMode == "units") {
                     list($rows, $info) = $this->get_timeSheetItem_list_units($TPL["timeSheetID"]);
                     $cols2 = array("desc" => "Description", "units" => "Units");
                     $rows[] = array("desc" => "<b>TOTAL</b>", "units" => "<b>" . $info["total"] . "</b>");
                     $y = $pdf->ezTable($rows, $cols2, "", $pdf_table_options3);
                 } else {
                     if ($timeSheetPrintMode == "items") {
                         list($rows, $info) = $this->get_timeSheetItem_list_items($TPL["timeSheetID"]);
                         $cols2 = array("date" => "Date", "units" => "Units", "multiplier_string" => "Multiplier", "desc" => "Description");
                         $rows[] = array("date" => "<b>TOTAL</b>", "units" => "<b>" . $info["total"] . "</b>");
                         $y = $pdf->ezTable($rows, $cols2, "", $pdf_table_options3);
                     }
                 }
             }
             $pdf->ezSetY($y - 20);
             $pdf->ezText(str_replace(array("<br>", "<br/>", "<br />"), "\n", $TPL["footer"]), 10);
             $pdf->ezStream(array("Content-Disposition" => "timeSheet_" . $timeSheetID . ".pdf"));
             // Else HTML format
         } else {
             if (file_exists(ALLOC_LOGO)) {
                 $TPL["companyName"] = '<img alt="Company logo" src="' . $TPL["url_alloc_logo"] . '" />';
             }
             $TPL["this_tsp"] = $this;
             $TPL["main_alloc_title"] = "Time Sheet - " . APPLICATION_NAME;
             include_template(dirname(__FILE__) . "/../templates/timeSheetPrintM.tpl");
         }
     }
 }
コード例 #17
0
<?php

/*
 * Copyright (C) 2006-2011 Alex Lance, Clancy Malcolm, Cyber IT Solutions
 * Pty. Ltd.
 * 
 * This file is part of the allocPSA application <*****@*****.**>.
 * 
 * allocPSA is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 * 
 * allocPSA is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with allocPSA. If not, see <http://www.gnu.org/licenses/>.
*/
define("NO_REDIRECT", 1);
require_once "../alloc.php";
if ($_GET["project"] && $_GET["person"]) {
    $rate = projectPerson::get_rate($_GET["project"], $_GET["person"]);
    $project = new project($_GET["project"]);
    $currency = $project->get_value("currencyTypeID") or $currency = config::get_config_item("currency");
    $rate['rate'] = page::money($currency, $rate['rate'], '%mo');
    echo alloc_json_encode($rate);
}
コード例 #18
0
ファイル: productSale.php プロジェクト: cjbayliss/alloc
if (!$productSale->get_id()) {
    $TPL["message_help"][] = "To create a new Sale, optionally select a Client and/or Project and click the Create Sale button.";
} else {
    if ($productSale->get_value("status") == "edit") {
        $TPL["message_help"][] = "Add as many Sale Items as you like by clicking the 'New' link multiple times, and then clicking the\n                            Save Items button.<br><br>When you are done adding Sale Items click the 'Allocate -->' button\n                            to setup the resulting transactions from this Sale.";
    } else {
        if ($productSale->get_value("status") == "allocate") {
            $TPL["message_help"][] = "If necessary, adjust the transactions below. When you're done, submit this Sale\n                            to the Adminstrator, you will no longer be able to edit this Sale.\n\n                            <br><br>Generally, the transactions for the Sale Items will add up correctly if the\n                            <b>Sell Price</b> is equal to <b>Transactions Incoming</b>, and the <b>Margin</b> is\n                            equal to <b>Transactions Other</b>.";
        } else {
            if ($productSale->get_value("status") == "admin" && $productSale->have_perm(PERM_APPROVE_PRODUCT_TRANSACTIONS)) {
                $TPL["message_help"][] = "Please review the Sale Transactions carefully. If accurate <b>approve</b> and save the transactions,\n                            then move this Sale to status 'Completed'.";
            } else {
                if ($productSale->get_value("status") == "admin") {
                    $TPL["message_help"][] = "This Sale is awaiting approval from the Administrator.";
                }
            }
        }
    }
}
if ($productSale->get_value("projectID")) {
    $project = new project();
    $project->set_id($productSale->get_value("projectID"));
    $project->select();
    $ptf = $project->get_value("cost_centre_tfID");
    $ptf and $TPL["project_tfID"] = " (TF: " . tf::get_name($ptf) . ")";
    $ptf or $TPL["project_tfID"] = " (No project TF)";
}
$TPL["taxName"] = config::get_config_item("taxName");
$TPL["main_alloc_title"] = "Sale - " . APPLICATION_NAME;
$productSale->get_id() and $TPL["main_alloc_title"] = "Sale " . $productSale->get_id() . " - " . APPLICATION_NAME;
include_template("templates/productSaleM.tpl");
コード例 #19
0
ファイル: updateTFList.php プロジェクト: cjbayliss/alloc
/*
 * Copyright (C) 2006-2011 Alex Lance, Clancy Malcolm, Cyber IT Solutions
 * Pty. Ltd.
 * 
 * This file is part of the allocPSA application <*****@*****.**>.
 * 
 * allocPSA is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 * 
 * allocPSA is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with allocPSA. If not, see <http://www.gnu.org/licenses/>.
*/
define("NO_REDIRECT", 1);
require_once "../alloc.php";
if ($_GET["projectID"]) {
    usleep(300000);
    $project = new project();
    $project->set_id($_GET["projectID"]);
    $project->select();
    $tf_sel = $project->get_value("cost_centre_tfID") or $tf_sel = config::get_config_item("mainTfID");
    $tf = new tf();
    $options = page::select_options($tf->get_assoc_array("tfID", "tfName"), $tf_sel);
    echo "<select id=\"tfID\" name=\"tfID\">" . $options . "</select>";
}