function group_table($group_id)
{
    global $table_prefix, $indent, $edit;
    $q = "SELECT group_id, name from " . $table_prefix . "groups where sub_of = " . $group_id . " order by name";
    $query = mysql_query($q);
    if (!$query) {
        echo "Database Error : " . $q;
    } else {
        while ($row = mysql_fetch_row($query)) {
            echo "<tr><td style=\"text-align:center\">" . $row[0] . "</td>";
            if (!$edit) {
                $q = "select * from " . $table_prefix . "users_to_groups where group_id = " . $row[0] . " and user_id = " . $_SESSION["user_id"];
                $qu = mysql_query($q);
            }
            echo "<td>" . $indent . $row[1] . "</td></tr>\n";
            $indent .= "__";
            group_table($row[0]);
            $indent = substr($indent, 2);
        }
    }
}
function uploadForm()
{
    global $table_prefix, $lang;
    ?>
<div class="sidebar">
<h4><?php 
    echo $lang["csv_upload_instructions_title"];
    ?>
</h4>
<?php 
    echo $lang["csv_upload_instructions"];
    ?>
<table class="grid" style="margin: 10px 0px;">
<tr><th style="width:auto;"><?php 
    echo $lang["id"];
    ?>
</th><th style="width:auto;"><?php 
    echo $lang["city"];
    ?>
</th><th style="width:auto;"><?php 
    echo $lang["state"];
    ?>
</th><th style="width:auto;"><?php 
    echo $lang["company"];
    ?>
</th></tr>
<tr><td style="text-align:center">1</td><td colspan="3"><?php 
    echo $lang["default_information_shown_event_description"];
    ?>
</td></tr>
<?php 
    $q = "SELECT link_id, state, city, company from " . $table_prefix . "links where state !='' and city != '' order by state, city, company";
    $query = mysql_query($q);
    if (!$query) {
        echo "Database Error : " . $q;
    } else {
        while ($row = mysql_fetch_row($query)) {
            echo "<tr><td style=\"text-align:center;\">" . $row[0] . "</td><td>" . $row[1] . "</td><td>" . $row[2] . "</td><td>" . $row[3] . "</td></tr>\n";
        }
    }
    ?>
</table>
<h4><?php 
    echo $lang["table_categories_title"];
    ?>
</h4>
<?php 
    echo $lang["table_categories"];
    ?>
<table class="grid" style="margin: 10px 0px;">
<tr><th style="width:auto;">ID</th><th style="width:auto;">Category</th></tr>
<?php 
    category_table(0);
    ?>
</table>
<h4><?php 
    echo $lang["table_groups_title"];
    ?>
</h4>
<?php 
    echo $lang["table_groups"];
    ?>
<table class="grid" style="margin: 10px 0px;">
<tr><th style="width:auto;">ID</th><th style="width:auto;">Group</th></tr>
<?php 
    group_table(0);
    ?>
</table>
</div>
<form action="<?php 
    echo $PHP_SELF;
    ?>
" method="post" enctype="multipart/form-data">
<h3><?php 
    echo $lang["upload_csv_file"];
    ?>
</h3>

<?php 
    include "includes/hidden_fields.php";
    ?>
<input type="hidden" name="MAX_FILE_SIZE" value="5120000">
<table>
<tr><td><?php 
    echo $lang["file"];
    ?>
:</td><td><input name="data" type="file" size="30"></td></tr>
<tr><td><?php 
    echo $lang["fields_separated_by"];
    ?>
:</td><td><input type="text" name="separator" id="separator" value="," size="2"></td></tr>
<tr><td><?php 
    echo $lang["default_group"];
    ?>
:</td><td><select name="group" id="group" size="1">
<?php 
    group_tree(0, 1);
    ?>
</select></td></tr>
<tr><td><?php 
    echo $lang["default_category"];
    ?>
:</td><td><select name="category" id="category" size="1">
<?php 
    category_tree(0, 1);
    ?>
</select></td></tr>
<tr><td><?php 
    echo $lang["default_venue"];
    ?>
:</td><td><select name="venue" id="venue" size="1"><option value="1"><?php 
    echo $lang["in_main_description"];
    ?>
</option>
<?php 
    select_place(1);
    ?>
</select></td></tr>
<tr><td><?php 
    echo $lang["default_contact"];
    ?>
:</td><td><select name="contact" id="contact" size="1"><option value="1"><?php 
    echo $lang["none"];
    ?>
</option>
<?php 
    select_place(1);
    ?>
</select></td></tr>
</table>
<input type="submit" NAME="mode" VALUE="<?php 
    echo $lang["upload_csv_file"];
    ?>
">
</form>
<div style="clear:right"></div>
<?php 
}