<?php
/*
 * 注意：此文件由tpl_engine编译型模板引擎编译生成。
 * 如果您的模板要进行修改，请修改 templates/default/modules/mypals/pals_manager_sort.html
 * 如果您的模型要进行修改，请修改 models/modules/mypals/pals_manager_sort.php
 *
 * 修改完成之后需要您进入后台重新编译，才会重新生成。
 * 如果您开启了debug模式运行，那么您可以省去上面这一步，但是debug模式每次都会判断程序是否更新，debug模式只适合开发调试。
 * 如果您正式运行此程序时，请切换到service模式运行！
 * 
 * 如有您有问题请到官方论坛（http://tech.jooyea.com/bbs/）提问，谢谢您的支持。
 */
?><?php
	//必须登录才能浏览该页面
	require("foundation/auser_mustlogin.php");

	//引入语言包
	$mp_langpackage=new mypalslp;
	$b_langpackage=new bloglp;

  //变量定义
  $user_id=get_sess_userid();   
  
  //数据表定义  
  $t_pals_sort=$tablePreStr."pals_sort";
  
  //读写分离方法-读操作
   dbtarget('r',$dbServs);   
   $dbo=new dbex; 
	 $sql="select * from $t_pals_sort where user_id=$user_id";
   $pals_sort_rs=$dbo->getRs($sql);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>blog</title>
<link rel="stylesheet" type="text/css" href="skin/<?php echo $skinUrl;?>/css/row_menus.css">
<link rel="stylesheet" type="text/css" href="skin/<?php echo $skinUrl;?>/css/iframe.css">
<SCRIPT language=JavaScript src="servtools/ajax_client/ajax.js"></SCRIPT>
<SCRIPT language=JavaScript src="skin/default/js/jooyea.js"></SCRIPT>
<script type="text/javascript">

function xmlchange(){
	if(xmlhttp.readyState==4&&xmlhttp.status==200){
			var return_str=xmlhttp.responseText;
			var	return_text=return_str.replace(/[\s\n\r]/g,"");
	}
}

function save_sort(sort_id,text_id){
	var sort_value=document.getElementById(text_id).value;
	if(trim(sort_value)==''){
		parent.Dialog.alert('<?php echo $mp_langpackage->mp_sort_wrong;?>');
	}else{
		xmlhttp=InitAjax();
		xmlhttp.open("POST","do.php?act=pals_sort_change&id="+sort_id,true);
		xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlhttp.onreadystatechange=xmlchange;
		document.getElementById('info_'+sort_id).style.display="";
		document.getElementById('info_'+sort_id+'_edit').style.display="none";
		document.getElementById('show_info_'+sort_id).innerHTML=sort_value;
		xmlhttp.send("name="+sort_value);
	}
}

function exit_sort(info_id,show_id,text_id){
	document.getElementById(info_id).style.display="";
	document.getElementById(info_id+"_edit").style.display="none";
}

function edit_sort(info_id){
	document.getElementById(info_id).style.display="none";
	document.getElementById(info_id+"_edit").style.display="";
}

parent.guide("mypals");

function show_add(){
	document.getElementById("show_add_button").style.display="none";
	document.getElementById("add_area").style.display="";
}

function exit_add(){
	document.getElementById("add_area").style.display="none";
	document.getElementById("show_add_button").style.display="";
	document.getElementById("new_sort").value="";
}

function check_form(){
	var new_sort=document.getElementById("new_sort").value;
	if(trim(new_sort)==''){
		parent.Dialog.alert('<?php echo $mp_langpackage->mp_sort_wrong;?>');
		return false;
	}else{
		return true;
	}
}

</script>
</head>
<body>
  <div class="main_right_title">
     <span class="main_title_dot3"></span>
     <span class="main_title_txt"><?php echo $mp_langpackage->mp_mypals;?></span>
  </div>
<div id="tabsB">
  <ul>
    <li><a href="?app=mypals" title="<?php echo $mp_langpackage->mp_list;?>"><span><?php echo $mp_langpackage->mp_list;?></span></a></li>
    <li><a href="?app=mypals_request" title="<?php echo $mp_langpackage->mp_list;?>"><span><?php echo $mp_langpackage->mp_req;?></span></a></li>
    <li><a href="?app=mypals_invite" title="<?php echo $mp_langpackage->mp_invite;?>"><span><?php echo $mp_langpackage->mp_invite;?></span></a></li>
    <li><a href="?app=mypals_sort" title="<?php echo $mp_langpackage->mp_m_sort;?>" class="nowbutl"><span class="nowbutr"><?php echo $mp_langpackage->mp_m_sort;?></span></a></li>
  </ul>
	<div class="div_but" onclick="location.href='?app=mypals_search'"><?php echo $mp_langpackage->mp_add;?></div>
</div>
  
	<table class="pals_ms_table rs_list" id='sort_table' cellspacing="0">
		<tr>
			<td class="td_a">
				<a href='?app=mypals&sort_id=0'><?php echo $mp_langpackage->mp_no_sort;?></a>（<?php echo $mp_langpackage->mp_def_sort;?>）
			</td>
			<td class="td_b">&nbsp</td>
		</tr>
		
		<?php foreach($pals_sort_rs as $rs){?>
			
		<tr id="info_<?php echo $rs['id'];?>">
			<td class="td_a">
					<div id="show_info_<?php echo $rs['id'];?>">
						<a href='?app=mypals&sort_id=<?php echo $rs["id"];?>'><?php echo $rs['name'];?></a>
					</div>
			</td>
			<td class="td_b">
					<a class="log_edit_link" href=javascript:edit_sort("info_<?php echo $rs['id'];?>");><?php echo $b_langpackage->b_edit;?></a>&nbsp &nbsp
					<a class="log_del_link" href='do.php?act=pals_sort_del&id=<?php echo $rs["id"];?>' onclick='return confirm("<?php echo $b_langpackage->b_a_del;?>")'><?php echo $b_langpackage->b_del;?></a>
			</td>
		</tr>
		
		<tr id="info_<?php echo $rs['id'];?>_edit" style="display:none;">
				<td class="td_a">
						<input type='text' id="change_sort_<?php echo $rs['id'];?>" value="<?php echo $rs['name'];?>" maxlength="20">
				</td>
				<td class="td_b">
					<a href="javascript:void(0);" class='log_edit_link' onclick=save_sort("<?php echo $rs['id'];?>","change_sort_<?php echo $rs['id'];?>"); ><?php echo $b_langpackage->b_button_save;?></a>&nbsp &nbsp
				    <a href="javascript:void(0);" class='log_del_link' onclick=exit_sort("info_<?php echo $rs['id'];?>","show_info_<?php echo $rs['id'];?>","change_sort_<?php echo $rs['id'];?>"); ><?php echo $b_langpackage->b_button_cancel;?></a>
				</td>

		</tr>
		
		<?php }?>

		<tr><td>&nbsp</td></tr>	
		<tr>
			<td>
				<input type='button' id='show_add_button' class="anniu" style='display:""' value='<?php echo $mp_langpackage->mp_add_sort;?>' onclick='show_add();' />
				<div id='add_area' style='display:none'>
					<form action='do.php?act=pals_sort_add' method='post' onsubmit='return check_form();'>
						<input class="text" type='text' name='new_sort' id='new_sort' />
						<input type='submit' value='<?php echo $mp_langpackage->mp_t_sort;?>' class='anniu' />&nbsp
						<input type='button' value='<?php echo $b_langpackage->b_button_cancel;?>' class='anniu' onclick='exit_add();' />
					</form>
				</div>
			</td>
		</tr>
	</table>							
</body>
</html>