<?php

include("../includes/site_config.php");
include('../session_handler.inc');
include('../message.php');
require_once('../error.php');
require_once('../functions.php');
if ($Sess_UserType != "A") {
    exit;
}

if (empty($_REQUEST['region_id'])) {
     header("Location: $CONST_LINK_ROOT/admin/admin_geography.php?PHPSESSID=".session_id());
    exit;
}

if($_POST[act]) {
//    $_status = (isset($_POST[gcn_status]))?1:0;
    $sql_query = "UPDATE geo_region SET grg_name = '$_POST[grg_name]', grg_order = '$_POST[grg_order]' WHERE grg_regionid = '$_POST[region_id]'";
//print_r($sql_query);
    mysql_query($sql_query, $link);
     header("Location: $CONST_LINK_ROOT/admin/admin_geography.php?PHPSESSID=".session_id());
    exit;
}

$query = "SELECT * FROM geo_region WHERE grg_regionid = '".$_REQUEST['region_id']."'";
$res = mysql_query($query);
$region = mysql_fetch_object($res);

$query="SELECT *
        FROM geo_region
        ORDER BY grg_order, grg_name";
$regions = mysql_query($query,$link) or die(mysql_error());

# retrieve the template
$area = 'member';

?>
<?php include("include/header.php"); ?>
<table width="<?php print("$CONST_TABLE_WIDTH"); ?>" align="<?php print("$CONST_TABLE_ALIGN"); ?>" border="0" cellspacing="<?php print("$CONST_TABLE_CELLSPACING"); ?>" cellpadding="<?php print("$CONST_TABLE_CELLPADDING"); ?>">
  <tr>
    <td align="right">
      <?php require_once("$CONST_INCLUDE_ROOT/user_status.inc.php");?>
    </td>
  </tr>
  <tr>
    <td class="pageheader"><?php echo GEOGRAPHY_SECTION_NAME ?></td>
  </tr>

    <tr>
        <td>
            <table border="0" width="100%" cellpadding="2" cellspacing="10">
                <form method="post" action="<?php echo $CONST_LINK_ROOT?>/admin/admin_regionedit.php<?php print("?PHPSESSID=".session_id()); ?>">
                <input type="hidden" name="region_id" value="<?=$_REQUEST['region_id']?>">
                <input type="hidden" name="act" value="save">
                <tr>
                    <td colspan="3" align="left" valign="top" class="tdhead">&nbsp; </td>
                </tr>
                <tr align=center>
                    <th align=right>
                        <?=SEARCH_REGION?>
                    </th>
                    <td align="left">
                        <input type="text" class="input" name="grg_name" value="<?=$region->grg_name?>" style="width:200px">
                    </td>
                    <td></td>
                </tr>
                <tr align=center>
                    <th align=right>
                        <?=ADM_CORDER?>
                    </th>
                    <td align="left">
                        <input type="text" class="input" name="grg_order" value="<?=$region->grg_order?>" style="width:200px">
                    </td>
                    <td></td>
                </tr>
                <tr>
                    <td align="center"  colspan="3" class="tdfoot">
                        <input type=submit class=button name=SAVE value="<?=GENERAL_SAVE?>">
                        <input type=button class=button name=CANCEL value="Cancel" onClick="location.href='<?=$CONST_LINK_ROOT?>/admin/admin_geography.php<?php print("?PHPSESSID=".session_id()); ?>'">
                    </td>
                </tr>
                </form>
           </table>

        </td>
    </tr>

</table>
<?php mysql_close( $link ); ?>
<?php include("include/footer.php"); ?>