function initializeGui(&$db, $args)
{
    $tcaseCfg = config_get('testcase_cfg');
    $reqCfg = config_get('req_cfg');
    $gui = new stdClass();
    $gui->mainTitle = '';
    $tprojectMgr = new testproject($db);
    $tcasePrefix = $tprojectMgr->getTestCasePrefix($args->tproject_id);
    $gui->tree_title = '';
    $gui->ajaxTree = new stdClass();
    $gui->ajaxTree->root_node = new stdClass();
    $gui->ajaxTree->dragDrop = new stdClass();
    $gui->ajaxTree->dragDrop->enabled = false;
    $gui->ajaxTree->dragDrop->BackEndUrl = null;
    $gui->ajaxTree->children = '';
    // Prefix for cookie used to save tree state
    $gui->ajaxTree->cookiePrefix = 'print' . str_replace(' ', '_', $args->doc_type) . '_';
    $gui->doc_type = $args->doc_type;
    switch ($args->doc_type) {
        // BUGID 3067
        case 'reqspec':
            $gui->tree_title = lang_get('title_req_print_navigator');
            $gui->ajaxTree->loader = $args->basehref . 'lib/ajax/getrequirementnodes.php?' . "root_node={$args->tproject_id}&" . "show_children=0&operation=print";
            $gui->ajaxTree->loadFromChildren = 0;
            $gui->ajaxTree->root_node->href = "javascript:TPROJECT_PTP_RS({$args->tproject_id})";
            $gui->ajaxTree->root_node->id = $args->tproject_id;
            $req_qty = $tprojectMgr->count_all_requirements($args->tproject_id);
            $gui->ajaxTree->root_node->name = htmlspecialchars($args->tproject_name) . " ({$req_qty})";
            $gui->ajaxTree->cookiePrefix .= $gui->ajaxTree->root_node->id . "_";
            $gui->mainTitle = lang_get('requirement_specification_report');
            break;
            // end BUGID 3067
        // end BUGID 3067
        case 'testspec':
            $gui->tree_title = lang_get('title_tc_print_navigator');
            $gui->ajaxTree->loader = $args->basehref . 'lib/ajax/gettprojectnodes.php?' . "root_node={$args->tproject_id}&" . "show_tcases=0&operation=print&" . "tcprefix=" . urlencode($tcasePrefix . $tcaseCfg->glue_character) . "}";
            $gui->ajaxTree->loadFromChildren = 0;
            $gui->ajaxTree->root_node->href = "javascript:TPROJECT_PTP({$args->tproject_id})";
            $gui->ajaxTree->root_node->id = $args->tproject_id;
            $tcase_qty = $tprojectMgr->count_testcases($args->tproject_id);
            $gui->ajaxTree->root_node->name = htmlspecialchars($args->tproject_name) . " ({$tcase_qty})";
            $gui->ajaxTree->cookiePrefix .= $gui->ajaxTree->root_node->id . "_";
            $gui->mainTitle = lang_get('testspecification_report');
            break;
        case 'testreport':
            $gui->mainTitle = lang_get('test_report');
            break;
        case 'testplan':
            $gui->tree_title = lang_get('title_tp_print_navigator');
            $gui->ajaxTree->loadFromChildren = 1;
            $gui->ajaxTree->loader = '';
            $gui->mainTitle = lang_get('test_plan');
            break;
    }
    $gui->mainTitle .= ' - ' . lang_get('doc_opt_title');
    $gui->outputFormat = array(FORMAT_HTML => lang_get('format_html'), FORMAT_ODT => lang_get('format_odt'), FORMAT_MSWORD => lang_get('format_msword'));
    return $gui;
}
/**
 * Initialize gui (stdClass) object that will be used as argument
 * in call to Template Engine.
 *
 * @param class pointer args: object containing User Input and some session values
 *    TBD structure
 * 
 * ?     tprojectMgr: test project manager object.
 * ?     treeDragDropEnabled: true/false. Controls Tree drag and drop behaivor.
 * 
 * @return stdClass TBD structure
 */
function initializeGui(&$db, $args)
{
    $tcaseCfg = config_get('testcase_cfg');
    $reqCfg = config_get('req_cfg');
    $gui = new stdClass();
    $gui->showOptionsCheckBoxes = $gui->showOptions = $args->showOptions;
    $gui->showHelpIcon = $args->showHelpIcon;
    $gui->mainTitle = '';
    $gui->outputFormat = array(FORMAT_HTML => lang_get('format_html'), FORMAT_MSWORD => lang_get('format_pseudo_msword'));
    $gui->outputOptions = init_checkboxes($args);
    if ($gui->showOptions == false) {
        $loop2do = count($gui->outputOptions);
        for ($idx = 0; $idx < $loop2do; $idx++) {
            $gui->outputOptions[$idx]['checked'] = 'y';
        }
    }
    $tprojectMgr = new testproject($db);
    $tcasePrefix = $tprojectMgr->getTestCasePrefix($args->tproject_id);
    $gui->tree_title = '';
    $gui->ajaxTree = new stdClass();
    $gui->ajaxTree->root_node = new stdClass();
    $gui->ajaxTree->dragDrop = new stdClass();
    $gui->ajaxTree->dragDrop->enabled = false;
    $gui->ajaxTree->dragDrop->BackEndUrl = null;
    $gui->ajaxTree->children = '';
    // improved cookie prefix for test spec doc and req spec doc
    $gui->ajaxTree->cookiePrefix = $args->doc_type . '_doc_';
    $gui->doc_type = $args->doc_type;
    $addTestPlanID = false;
    switch ($args->doc_type) {
        case DOC_REQ_SPEC:
            $gui->showOptions = true;
            $gui->showOptionsCheckBoxes = false;
            $gui->tree_title = lang_get('title_req_print_navigator');
            $gui->ajaxTree->loader = $args->basehref . 'lib/ajax/getrequirementnodes.php?' . "root_node={$args->tproject_id}&show_children=0&operation=print";
            $gui->ajaxTree->loadFromChildren = 0;
            $gui->ajaxTree->root_node->href = "javascript:TPROJECT_PTP_RS({$args->tproject_id})";
            $gui->ajaxTree->root_node->id = $args->tproject_id;
            $req_qty = $tprojectMgr->count_all_requirements($args->tproject_id);
            $gui->ajaxTree->root_node->name = htmlspecialchars($args->tproject_name) . " ({$req_qty})";
            $gui->ajaxTree->cookiePrefix .= "tproject_id_" . $gui->ajaxTree->root_node->id . "_";
            $gui->mainTitle = lang_get('requirement_specification_report');
            break;
        case DOC_TEST_SPEC:
            $gui->tree_title = lang_get('title_tc_print_navigator');
            $gui->ajaxTree->loader = $args->basehref . 'lib/ajax/gettprojectnodes.php?' . "root_node={$args->tproject_id}&" . "show_tcases=0&operation=print&" . "tcprefix=" . urlencode($tcasePrefix . $tcaseCfg->glue_character) . "}";
            $gui->ajaxTree->loadFromChildren = 0;
            $gui->ajaxTree->root_node->href = "javascript:TPROJECT_PTP({$args->tproject_id})";
            $gui->ajaxTree->root_node->id = $args->tproject_id;
            $tcase_qty = $tprojectMgr->count_testcases($args->tproject_id);
            $gui->ajaxTree->root_node->name = htmlspecialchars($args->tproject_name) . " ({$tcase_qty})";
            $gui->ajaxTree->cookiePrefix .= "tproject_id_" . $gui->ajaxTree->root_node->id . "_";
            $gui->mainTitle = lang_get('testspecification_report');
            break;
        case DOC_TEST_PLAN_EXECUTION:
            $addTestPlanID = true;
            $gui->mainTitle = lang_get('test_report');
            break;
        case DOC_TEST_PLAN_DESIGN:
            $addTestPlanID = true;
            $gui->tree_title = lang_get('title_tp_print_navigator');
            $gui->ajaxTree->loadFromChildren = 1;
            $gui->ajaxTree->loader = '';
            $gui->mainTitle = lang_get('test_plan');
            break;
        case DOC_TEST_PLAN_EXECUTION_ON_BUILD:
            $addTestPlanID = true;
            $gui->mainTitle = lang_get('test_report_on_build');
            break;
    }
    // Do not move
    if ($args->mainTitle == '') {
        $gui->mainTitle .= ' - ' . lang_get('doc_opt_title');
    } else {
        $gui->mainTitle = $args->mainTitle;
    }
    $gui->getArguments = "&type=" . $args->doc_type;
    if ($addTestPlanID) {
        $gui->getArguments .= '&docTestPlanId=' . $args->tplan_id;
    }
    return $gui;
}