<?php (!defined('IN_ADMIN') || !defined('IN_MUDDER')) && exit('Access Denied'); ?>
<div id="body">
<div class="space">
    <div class="subtitle">操作提示</div>
    <table class="maintable" border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td>
            <li>添加地区先添加大市（例如：宁波），提交后，再下栏编辑地区内，添加省级以下的区/县（例如：海曙区），街道/路口（例如：镇明路）</li>
            <li>这里的地区按照大市，区/县，街道/路口来分成三级；</li>
            <li>第一次添加城市后，必须在“基本设置->界面和显示设置”页面选择默认点评城市；</li>
            <li>本版本的系统暂不提供多城市的功能。</li>
    </td></tr>
    </table>
</div>

<? if($areacode || $areasort) { ?>
<script type="text/javascript">
function remak_mappoint(){
    var obj = document.getElementById('remark_iframe');
    var iframe = document.getElementById('imappoint');
    if(iframe && (iframe.src == '#'|| iframe.src.substr(iframe.src.length-1,1) =='#')) {
        iframe.src = "<?=$_config['siteurl']?>admin/dlg_selectmap.php?action=remark";
    }
    if(obj) obj.style.display = "";
}
</script>
<div class="space">
<form method="post" action="admincp.php?action=<?=$action?>&file=<?=$file?>&">
    <? if($areacode) { ?>
    <input type="hidden" name="areacode" value="<?=$areacode?>" />
    <div class="subtitle">编辑地区</div>
    <? } else { ?>
    <input type="hidden" name="areasort" value="<?=$areasort?>" />
    <input type="hidden" name="upareacode" value="<?=$upareacode?>" />
    <div class="subtitle">添加地区</div>
    <? } ?>
    <table class="maintable" border="0" cellspacing="0" cellpadding="0">
    <tr><td width="40%" class="altbg1">名称：<td><input type="text" name="areaname" value="<?=$area['areaname']?>" class="txtbox2" /></td></tr>
    <!--if($iscity)-->
    <tr><td class="altbg1">默认位置：<br />地图标注时使用，用于确定城市或地区位置<td><input type="text" name="default_mappoint" id="default_mappoint" value="<?=$area['default_mappoint']?>" class="txtbox2" />&nbsp;<button type="button" class="btn2" onclick="remak_mappoint();">设置</button></td></tr>
    <tr id="remark_iframe" style="display:none;">
        <td colspan="2"><iframe src="#" id="imappoint" height="350" width="100%"></iframe></td>
    </tr>
    </table>
    <center><input type="submit" name="areasubmit" value=" 提交 " class="btn" />&nbsp;&nbsp;&nbsp;<input type="button" value=" 返回 " onclick="javascript:history.go(-1);" class="btn" /></center>
</form>
</div>
<? } elseif($delete == 'confirm') { ?>
<form method="post" action="admincp.php?action=<?=$action?>&file=<?=$file?>&">
    <input type="hidden" name="delete" value="yes" />
    <input type="hidden" name="deleteareacode" value="<?=$deleteareacode?>" />
    <div class="subtitle">删除地区</div>
    <table class="maintable" border="0" cellspacing="0" cellpadding="0">
    <tr><td align="center">注意：<span class="font_4">本操作不可恢复</span>，建议先修改或者删除属于本地区的商铺，以免产生冗余的数据。</td></tr>
    </table>
    <br /><center><input type="submit" name="areasubmit" value=" 确定删除 " class="btn" />&nbsp;&nbsp;&nbsp;<input type="button" value=" 返回 " onclick="javascript:history.go(-1);" class="btn" /></center>
</form>
<? } else { ?>
<? if(!$areas['city']) {?>
<div class="space">
<form method="post" action="admincp.php?action=<?=$action?>&file=<?=$file?>&">
    <input type="hidden" name="areasort" value="1" />
    <div class="subtitle">添加地区</div>
    <table class="maintable" border="0" cellspacing="0" cellpadding="0">
    <tr><td width="20%" class="altbg1">城市:</td><td width="30%"><input type="text" name="areaname" class="txtbox2" /></td><td><input type="submit" name="areasubmit" value=" 提交 " class="btn" /></td></tr>
    </table>
</form>
</div>
<? } ?>
<div class="space">
    <div class="subtitle">地区管理</div>
    <table class="maintable" border="0" cellspacing="0" cellpadding="0">
        <tr class="altbg1">
            <td width="100">编号</td>
            <td width="*">名称</td>
            <td width="250">地图中心坐标</td>
            <td width="200">操作</td>
        </tr>
        <? if($areas['city']) foreach($areas['city'] as $city) { ?>
        <tr>
            <td><?=$city['areacode']?></td>
            <td><?=$city['areaname']?></td>
            <td><?=$city['default_mappoint']?></td>
            <td>
                <a href="admincp.php?action=modoer&file=area&areacode=<?=$city['areacode']?>">编辑</a>&nbsp;
                <a href="admincp.php?action=modoer&file=area&areasort=2&upareacode=<?=$city['areacode']?>">添加下级</a>
            </td>
        </tr>
            <? if($areas['borough'][$city['areacode']]) foreach($areas['borough'][$city['areacode']] as $borough) { ?>
            <tr>
                <td><?=$borough['areacode']?></td>
                <td>&nbsp;&nbsp;├ <?=$borough['areaname']?></td>
                <td><?=$borough['default_mappoint']?></td>
                <td>
                    <a href="admincp.php?action=modoer&file=area&areacode=<?=$borough['areacode']?>">编辑</a>&nbsp;
                    <a href="admincp.php?action=modoer&file=area&areasort=3&upareacode=<?=$borough['areacode']?>">添加下级</a>&nbsp;
                    <a href="admincp.php?action=modoer&file=area&delete=confirm&deleteareacode=<?=$borough['areacode']?>">删除</a>
                </td>
            </tr>
                <? if($areas['street'][$borough['areacode']]) foreach($areas['street'][$borough['areacode']] as $street) { ?>
                <tr>
                    <td><?=$street['areacode']?></td>
                    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├ <?=$street['areaname']?></td>
                    <td><?=$street['default_mappoint']?></td>
                    <td>
                        <a href="admincp.php?action=modoer&file=area&areacode=<?=$street['areacode']?>">编辑</a>&nbsp;
                        <a href="admincp.php?action=modoer&file=area&delete=confirm&deleteareacode=<?=$street['areacode']?>">删除</a>
                    </td>
                </tr>
                <? }
            }
        } ?>
    </table>
</div>
<? } ?>
</div>