Beispiel #1
0
        $demo_list[] = $rows;
    }
    $smarty->assign('demo_list', $demo_list);
    assign_query_info();
    $smarty->display('store_shipping_area.htm');
} elseif ($_REQUEST['act'] == 'add_shipping_area_new') {
    $array = array(1 => 'province', 2 => 'city', 3 => 'district', 4 => 'xiangcun');
    $citys = $_POST['city'];
    $parent_id = intval($_POST['parent_id']);
    $insert = array();
    $linshi = array();
    if (count($citys) <= 0) {
        sys_msg('请返回重新选择具体城市区域', 1);
    }
    //获取有五级区域的四级城市
    $five_city = is_have_five_city();
    foreach ($citys as $key => $val) {
        $where = '';
        unset($linshi);
        $arr = explode('.', $val);
        if (count($arr) == 4 && !empty($five_city)) {
            //判断此四级下面是否有五级城市
            if (isset($five_city[$arr[3]])) {
                continue;
                //不保存有五级区域的四级区域节点
            }
        }
        if (count($arr) > 3) {
            foreach ($arr as $k => $v) {
                if ($k > 0) {
                    $where .= " and " . $array[$k] . "=" . $v;
Beispiel #2
0
function create_ever_sql()
{
    global $db, $ecs;
    //判断有没有第五级区域
    $ret = is_have_five_city();
    //获取已经选了哪些四,五级城市
    $supplier_id = isset($_SESSION['supplier_id']) && intval($_SESSION['supplier_id']) > 0 ? intval($_SESSION['supplier_id']) : 0;
    $sql5 = "select * from " . $ecs->table('store_shipping_region') . " where supplier_id=" . $supplier_id;
    $query5 = $db->query($sql5);
    $ret1 = $ret2 = array();
    while ($row5 = $db->fetchRow($query5)) {
        if ($row5['xiangcun'] > 0) {
            $ret1[$row5['district']][$row5['xiangcun']] = $row5['xiangcun'];
        } else {
            $ret2[$row5['district']] = $row5['district'];
        }
    }
    if (count($ret1) > 0) {
        foreach ($ret1 as $key => $val) {
            if (isset($ret[$key]) && $ret[$key] != count($val)) {
                //如果四级城市下的五级城市已经全都选择过,删除四给城市
                unset($ret2[$key]);
            }
            foreach ($val as $k => $v) {
                $ret2[$k] = $v;
            }
        }
    }
    return $ret2;
}