$smarty->assign('action_link', array('href' => 'area.php?act=add', 'text' => '地址点添加')); $sql = "select station_id,station_name from ship_station where flag =1 and station_id <10 "; $res = $db_read->getAll($sql); $smarty->assign('station_list', $res); $sql = "select region_name from ship_region where region_type=2 "; $res = $db_read->getAll($sql); $smarty->assign('region_list', $res); $list = area_list(); //echo '<pre>';print_r($list);echo '</pre>'; $smarty->assign('record_count', $list['record_count']); $smarty->assign('page_count', $list['page_count']); $smarty->assign('filter', $list['filter']); $smarty->assign('area', $list['list']); $smarty->display('area_list.html'); } elseif ($_REQUEST['act'] == 'query') { $list = area_list(); $smarty->assign('record_count', $list['record_count']); $smarty->assign('page_count', $list['page_count']); $smarty->assign('filter', $list['filter']); $smarty->assign('area', $list['list']); make_json_result($smarty->fetch('area_list.html'), '', array('filter' => $list['filter'], 'page_count' => $list['page_count'])); } elseif ($_REQUEST['act'] == 'add') { $smarty->assign('ur_here', '地址点添加'); $smarty->assign('action_link', array('href' => 'area.php?act=list', 'text' => '地址点管理')); $sql = "select route_id,route_name from view_ship_route where flag =1 and station_id <10 "; $res = $db_read->getAll($sql); $smarty->assign('route_list', $res); $smarty->assign('form_act', 'insert'); $smarty->display('area_info.html'); } elseif ($_REQUEST['act'] == 'insert') { //print_r($_POST);exit;
if ($region_type < 6) { for ($i = 1; $i < 6 - $region_type; $i++) { $new_region_id = new_region_id($new_region_id); if (count($new_region_id)) { $delete_region = array_merge($delete_region, $new_region_id); } else { continue; } } } $sql = "DELETE FROM " . $ecs->table("region") . "WHERE region_id" . db_create_in($delete_region); $db->query($sql); if ($exc->drop($id)) { admin_log(addslashes($region['region_name']), 'remove', 'area'); /* 获取地区列表 */ $region_arr = area_list($region['parent_id']); $smarty->assign('region_arr', $region_arr); $smarty->assign('region_type', $region['region_type']); make_json_result($smarty->fetch('area_list.htm')); } else { make_json_error($db->error()); } } function new_region_id($region_id) { $regions_id = array(); if (empty($region_id)) { return $regions_id; } $sql = "SELECT region_id FROM " . $GLOBALS['ecs']->table("region") . "WHERE parent_id " . db_create_in($region_id); $result = $GLOBALS['db']->getAll($sql);
function content() { global $HTTP_POST_VARS, $HTTP_GET_VARS, $list_prefix; $MAIN = loadadmintmplate("main"); $BLOCKS = loadadmintmplate("blocks"); //we will process changes here if (0 == strcmp($HTTP_GET_VARS['mode'], "ablocks")) { //process active blocks if (isset($HTTP_POST_VARS['disable'])) { //if we are to disable the block $sql = "DELETE FROM `" . $list_prefix . "blocks` WHERE `name` = '" . $HTTP_POST_VARS['active_blocks'] . "';"; $result = db_query($sql); } else { //otherwise we will process all the fields. //lets read the db info for the block, we will set the default order also $sql = "SELECT * FROM `" . $list_prefix . "blocks` WHERE `name` = '" . $HTTP_POST_VARS['active_blocks'] . "';"; $result = db_query($sql); if ($result) { $rows = db_num_rows($result); } else { $rows = 0; } if ($rows != 0) { $row = db_fetch_array($result); $order = $row['order']; $id = $row['id']; } else { $order = 1; } //we will default to order of 1. //lets determine if there are any moves if (0 == strcmp($HTTP_POST_VARS['position'], "up")) { //if it moves up //now we will find the new value for $order to move to $sql = "SELECT * FROM `" . $list_prefix . "blocks` WHERE `blockset` = '" . $row['blockset'] . "' AND `order` < '" . $order . "' ORDER by `order` DESC;"; $result = db_query($sql); if ($result) { $rows = db_num_rows($result); } else { $rows = 0; } if ($rows != 0) { //if we have no rows we don't move it up, but if there are rows we want to trade places with the one above. $row2 = db_fetch_array($result); //now we will set $row2 to $row's order $sql = "UPDATE " . $list_prefix . "blocks SET `order` = '" . $order . "' WHERE `id` = '" . $row2['id'] . "';"; $result = db_query($sql); if ($result) { //if we succeeded we will now change $order to $row2's previous order $order = $row2['order']; } } } elseif (0 == strcmp($HTTP_POST_VARS['position'], "down")) { //if it doesn't move. //now we will find the new value for $order to move to $sql = "SELECT * FROM `" . $list_prefix . "blocks` WHERE `blockset` = '" . $row['blockset'] . "' AND `order` > '" . $order . "' ORDER by `order`;"; $result = db_query($sql); if ($result) { $rows = db_num_rows($result); } else { $rows = 0; } if ($rows != 0) { //if we have no rows we don't move it down, but if there are rows we want to trade places with the one below. $row2 = db_fetch_array($result); //now we will set $row2 to $row's order $sql = "UPDATE " . $list_prefix . "blocks SET `order` = '" . $order . "' WHERE `id` = '" . $row2['id'] . "';"; $result = db_query($sql); if ($result) { //if we succeeded we will now change $order to $row2's previous order $order = $row2['order']; } } } //now lets see if we are moving the block to a new blockset if (0 != strcmp($HTTP_POST_VARS['block_area'], "-")) { //we are moving the blockset $blockset = $HTTP_POST_VARS['block_area']; //if we are moving to a new block set we need to make 100% sure that we don't break the order so we will put this on the end of that blockset. $sql = "SELECT * FROM `" . $list_prefix . "blocks` WHERE `blockset` = '" . $blockset . "' ORDER by `order` DESC;"; $result = db_query($sql); if ($result) { $rows = db_num_rows($result); } else { $rows = 0; } if (0 != $rows) { $row = db_fetch_array($result); $order = $row['order'] + 1; } else { //there are no blocks in this blockset so we will be the first. $order = 1; } } else { //we are not moving the blockset $blockset = $row['blockset']; } //here is where we will update the db with the new values for block. $sql = "UPDATE " . $list_prefix . "blocks SET `blockset` = '" . $blockset . "', `order` = '" . $order . "' WHERE `id` = '" . $id . "';"; $result = db_query($sql); } //here we will run fix order to correct any issues in the order of the modules. fixorder(1, 1); fixorder(1, 2); fixorder(1, 3); fixorder(1, 4); } if (0 == strcmp($HTTP_GET_VARS['mode'], "iblocks")) { //process inactive blocks //lets figure out what our order and blockset are. $blockset = $HTTP_POST_VARS['block_area']; $sql = "SELECT * FROM `" . $list_prefix . "blocks` WHERE `blockset` = '" . $blockset . "' ORDER by `order` DESC;"; $result = db_query($sql); if ($result) { $rows = db_num_rows($result); } else { $rows = 0; } if (0 != $rows) { $row = db_fetch_array($result); $order = $row['order'] + 1; } else { //there are no blocks in this blockset so we will be the first. $order = 1; } //now lets prepare our sql query $sql = "INSERT INTO " . $list_prefix . "blocks VALUES ('', '" . $HTTP_POST_VARS['inactive_blocks'] . "', '" . $blockset . "', '" . $order . "');"; $result = db_query($sql); } //now we will handle our output. $WORK = insert_into_template($BLOCKS, "{INACTIVE_BLOCK_LIST}", list_inactive_blocks()); $WORK = insert_into_template($WORK, "{ACTIVE_BLOCK_LIST}", list_active_blocks()); $WORK = insert_into_template($WORK, "{MOVE_AREA_LIST}", move_area_list()); $WORK = insert_into_template($WORK, "{AREA_LIST}", area_list()); $WORK = insert_into_template($MAIN, "{CONTENT}", $WORK); printf("%s", striptemplate($WORK)); }