print "<div align=center>" . NEWLINE;
print "<table class=width100 rules=cols>" . NEWLINE;
print "<tr>" . NEWLINE;
print "<td width='50%' nowrap class=grid-header-c>" . lang_get('req_id') . "</td>" . NEWLINE;
print "<td width='50%' nowrap class=grid-header-c>" . lang_get('req_name') . "</td>" . NEWLINE;
print "</tr>" . NEWLINE;
print "<tr>" . NEWLINE;
print "<td width='50%' class=grid-data-c><a href='requirement_detail_page.php?req_id={$s_req_id}&amp;req_version_id={$s_req_version_id}'>" . sprintf("%05s", trim($s_req_id)) . "</a></td>" . NEWLINE;
print "<td width='50%' class=grid-data-c>{$req_name}</td>" . NEWLINE;
print "</tr>" . NEWLINE;
print "</table>" . NEWLINE;
print "<br>";
html_print_requirements_filter($project_id, $filter_doc_type, $filter_status, $filter_area_covered, $filter_functionality, $filter_assign_release, $filter_per_page, $filter_show_versions, $filter_search, $filter_priority);
print "<br>" . NEWLINE;
print "</div>" . NEWLINE;
$rows_requirement = requirement_get_edit_children($project_id, $s_req_id, $page_number, $order_by, $order_dir, $filter_doc_type, $filter_status, $filter_area_covered, $filter_functionality, $filter_assign_release, $filter_show_versions, $filter_search, $filter_priority, $filter_per_page);
################################################################################
# Testset table
if ($rows_requirement) {
    print "<div align=center>" . NEWLINE;
    print "<table class=width100 rules=cols>" . NEWLINE;
    # Table headers
    print "<tr class=tbl_header>" . NEWLINE;
    print "<th></th>";
    html_tbl_print_header(lang_get('req_id'), REQ_ID, $order_by, $order_dir);
    html_tbl_print_header("");
    html_tbl_print_header(lang_get('req_name'), REQ_FILENAME, $order_by, $order_dir);
    html_tbl_print_header(lang_get('req_detail'), REQ_VERS_DETAIL, $order_by, $order_dir);
    html_tbl_print_header(lang_get('req_type'), REQ_DOC_TYPE_NAME, $order_by, $order_dir);
    html_tbl_print_header(lang_get('status'), REQ_VERS_STATUS, $order_by, $order_dir);
    html_tbl_print_header(lang_get('req_area'), REQ_AREA_COVERAGE, $order_by, $order_dir);
function requirement_edit_children($project_id, $req_id, $session_records_name)
{
    global $db;
    $tbl_req = REQ_TBL;
    $f_req_proj_id = $tbl_req . "." . REQ_PROJECT_ID;
    $f_req_id = $tbl_req . "." . REQ_ID;
    $f_req_filename = $tbl_req . "." . REQ_FILENAME;
    $f_req_area_covered = $tbl_req . "." . REQ_AREA_COVERED;
    $f_req_type = $tbl_req . "." . REQ_TYPE;
    $f_req_parent = $tbl_req . "." . REQ_PARENT;
    $f_req_label = $tbl_req . "." . REQ_LABEL;
    $f_req_unique_id = $tbl_req . "." . REQ_UNIQUE_ID;
    $f_req_locked_by = $tbl_req . "." . REQ_LOCKED_BY;
    $f_req_locked_date = $tbl_req . "." . REQ_LOCKED_DATE;
    $f_req_parent = $tbl_req . "." . REQ_PARENT;
    $q = "\tSELECT {$f_req_id}\n\t\t\tFROM {$tbl_req}\n\t\t\tWHERE {$f_req_parent} = {$req_id}";
    $rs = db_query($db, $q);
    foreach (requirement_get_edit_children($project_id, $req_id) as $child) {
        $q = "\tSELECT {$f_req_id}\n\t\t\t\tFROM {$tbl_req}\n\t\t\t\tWHERE {$f_req_id} = " . $child[REQ_ID] . "\n\t\t\t\t\tAND\t{$f_req_parent} = {$req_id}";
        $rs = db_query($db, $q);
        $record_exists = db_num_rows($db, $rs);
        //print"$record_exists--";
        //print"--".session_records_ischecked($session_records_name, $child[REQ_ID]);
        if (session_records_ischecked($session_records_name, $child[REQ_ID])) {
            if (!$record_exists) {
                $q = "\tUPDATE {$tbl_req}\n\t\t\t\t\t\tSET {$f_req_parent} = {$req_id}\n\t\t\t\t\t\tWHERE {$f_req_id} = " . $child[REQ_ID];
            }
        } else {
            if ($record_exists) {
                $q = "\tUPDATE {$tbl_req}\n\t\t\t\t\t\tSET {$f_req_parent} = 0\n\t\t\t\t\t\tWHERE {$f_req_id} = " . $child[REQ_ID];
            }
        }
        db_query($db, $q);
    }
    //print$q;
    db_query($db, $q);
}