7e47ce238b
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
198 lines
7.3 KiB
PHP
198 lines
7.3 KiB
PHP
<?php
|
|
//-------------------------------短消息-界面
|
|
header("Content-type: text/html; charset=utf-8");
|
|
$json_data="{";
|
|
if(THIS_IN!="edt_ipad")
|
|
exit("错误的访问!");
|
|
|
|
$uid=check_cookie_jxs();
|
|
$msg_login=get_db_msg("select * from ".$table_pre."client where id='".$uid."'");
|
|
|
|
$arr_report=array("new"=>"新消息","all"=>"历史信息","send_box"=>"发件箱","js"=>"发送消息");
|
|
|
|
$_a=$_a?$_a:"new";
|
|
|
|
if($_a=="new" || $_a=="all" || $_a=="send_box" || $_a=="js"){
|
|
$json_data.="\"s_a\":\"".$_a."\",";
|
|
$str_tab="";
|
|
foreach($arr_report as $k1=>$v1){
|
|
$str_tab.="{\"_a\":\"".$k1."\",\"title\":\"".$v1."\"},";
|
|
}
|
|
$str_tab=deel_end($str_tab);
|
|
$json_data.="\"tab\":[".$str_tab."],";
|
|
}
|
|
switch($_a){
|
|
case "all":
|
|
$return_msg="";
|
|
$count=0;
|
|
$sql="select * from ".$table_pre."msg where to_cid='".$uid."' order by add_date";
|
|
$res=$db->query($sql);
|
|
while($msg=$db->fetch_array($res)){
|
|
$msg_from=get_db_msg("select * from ".$table_pre."client where id='".$msg["from_cid"]."'");
|
|
$return_msg.="{";
|
|
$return_msg.="\"msgid\":\"".$msg["id"]."\",";
|
|
$return_msg.="\"msguser\":\"".$msg_from["username"]."\",";
|
|
$return_msg.="\"msgdate\":\"".date("d日 H时i分s秒",$msg["add_date"])."\",";
|
|
$return_msg.="\"msgfrom\":\"".$msg_from["title"]."\",";
|
|
$return_msg.="\"msgtext\":\"".dhtmlchars($msg["text"])."\"";
|
|
$return_msg.="},";
|
|
$count++;
|
|
}
|
|
if($return_msg){
|
|
$json_data.="\"msgcount\":\"".$count."\",\"msgcontent\":[".substr($return_msg,0,-1)."],";
|
|
}else{
|
|
$json_data.="\"msgcount\":\"0\",\"msgcontent\":[],";
|
|
}
|
|
|
|
break;
|
|
|
|
case "new":
|
|
$return_msg="";
|
|
$count=0;
|
|
$sql="select * from ".$table_pre."msg where to_cid='".$uid."' and is_read='n' order by add_date";
|
|
$res=$db->query($sql);
|
|
while($msg=$db->fetch_array($res)){
|
|
$msg_from=get_db_msg("select * from ".$table_pre."client where id='".$msg["from_cid"]."'");
|
|
$return_msg.="{";
|
|
$return_msg.="\"msgid\":\"".$msg["id"]."\",";
|
|
$return_msg.="\"msguser\":\"".$msg_from["username"]."\",";
|
|
$return_msg.="\"msgdate\":\"".date("d日 H时i分s秒",$msg["add_date"])."\",";
|
|
$return_msg.="\"msgfrom\":\"".$msg_from["title"]."\",";
|
|
$return_msg.="\"msgtext\":\"".dhtmlchars($msg["text"])."\"";
|
|
$return_msg.="},";
|
|
$count++;
|
|
if($init=="y"){
|
|
$db->query("update ".$table_pre."msg set is_read='y' where id='".$msg["id"]."'");
|
|
}
|
|
}
|
|
if($return_msg){
|
|
$json_data.="\"msgcount\":\"".$count."\",\"msgcontent\":[".substr($return_msg,0,-1)."],";
|
|
}else{
|
|
$json_data.="\"msgcount\":\"0\",\"msgcontent\":[],";
|
|
}
|
|
break;
|
|
|
|
case "send_box":
|
|
$return_msg="";
|
|
$count=0;
|
|
$sql="select * from ".$table_pre."msg where from_cid='".$uid."' order by add_date";
|
|
$res=$db->query($sql);
|
|
while($msg=$db->fetch_array($res)){
|
|
$msg_from=get_db_msg("select * from ".$table_pre."client where id='".$msg["to_cid"]."'");
|
|
$return_msg.="{";
|
|
$return_msg.="\"msgid\":\"".$msg["id"]."\",";
|
|
$return_msg.="\"msguser\":\"".$msg_from["username"]."\",";
|
|
$return_msg.="\"msgdate\":\"".date("d日 H时i分s秒",$msg["add_date"])."\",";
|
|
$return_msg.="\"msgto\":\"".$msg_from["title"]."\",";
|
|
$return_msg.="\"msgtext\":\"".dhtmlchars($msg["text"])."\"";
|
|
$return_msg.="},";
|
|
$count++;
|
|
}
|
|
if($return_msg){
|
|
$json_data.="\"msgcount\":\"".$count."\",\"msgcontent\":[".substr($return_msg,0,-1)."],";
|
|
}else{
|
|
$json_data.="\"msgcount\":\"0\",\"msgcontent\":[],";
|
|
}
|
|
break;
|
|
|
|
case "js":
|
|
$op_auto_username="";
|
|
//根据uid判断可以发送给谁
|
|
if($msg_login["face"]=="4"){
|
|
//店铺
|
|
//总经理
|
|
$q="select * from ".$table_pre."client where face='1'";
|
|
$r=$db->query($q);
|
|
while($m=$db->fetch_array($r)){
|
|
$op_auto_username.="{\"no\":\"".$m["username"]."\",\"title\":\"总经理-".$m["title"]."(".$m["username"].")\"},";
|
|
}
|
|
//区域经理
|
|
$q="select * from ".$table_pre."client where face='2'";
|
|
$r=$db->query($q);
|
|
while($m=$db->fetch_array($r)){
|
|
$c1=explode(",",$m["charge_path"]);
|
|
if(in_array($upath,$c1)){
|
|
$op_auto_username.="{\"no\":\"".$m["username"]."\",\"title\":\"区域经理-".$m["title"]."(".$m["username"].")\"},";
|
|
}
|
|
}
|
|
//上级代理商
|
|
$m=get_db_msg("select * from ".$table_pre."client where face='3' and id='".get_parent_id($msg_login["path"])."'");
|
|
if($m["id"]>0)
|
|
$op_auto_username.="{\"no\":\"".$m["username"]."\",\"title\":\"上级代理-".$m["title"]."(".$m["username"].")\"},";
|
|
//软件反馈
|
|
$q="select * from ".$table_pre."client where face='8'";
|
|
$r=$db->query($q);
|
|
while($m=$db->fetch_array($r)){
|
|
$op_auto_username.="{\"no\":\"".$m["username"]."\",\"title\":\"软件反馈-".$m["title"]."(".$m["username"].")\"},";
|
|
}
|
|
|
|
}else if($msg_login["face"]=="2"){
|
|
//区域经理
|
|
//所属客户
|
|
$arr1=explode(",",$msg_login["charge_path"]);
|
|
for($i=0;$i<count($arr1);$i++){
|
|
$m=get_db_msg("select * from ".$table_pre."client where id='".get_parent_id($arr1[$i])."'");
|
|
if($m["id"]!=$uid){
|
|
$op_auto_username.="{\"no\":\"".$m["username"]."\",\"title\":\"".$m["title"]."(".$m["username"].")\"},";
|
|
}
|
|
}
|
|
//软件反馈
|
|
$q="select * from ".$table_pre."client where face='8'";
|
|
$r=$db->query($q);
|
|
while($m=$db->fetch_array($r)){
|
|
$op_auto_username.="{\"no\":\"".$m["username"]."\",\"title\":\"软件反馈-".$m["title"]."(".$m["username"].")\"},";
|
|
}
|
|
}else if($msg_login["face"]=="3"){//代理商
|
|
//下级客户
|
|
$q="select id,title,username,path,CONCAT(path,'-',id) 'abs_path' from ".$table_pre."client where path='".$upath."' or path like '".$upath."-%' order by abs_path";
|
|
$r=$db->query($q);
|
|
while($m=$db->fetch_array($r)){
|
|
$op_auto_username.="{\"no\":\"".$m["username"]."\",\"title\":\"".$m["title"]."(".$m["username"].")\"},";
|
|
}
|
|
//软件反馈
|
|
$q="select * from ".$table_pre."client where face='8'";
|
|
$r=$db->query($q);
|
|
while($m=$db->fetch_array($r)){
|
|
$op_auto_username.="{\"no\":\"".$m["username"]."\",\"title\":\"软件反馈-".$m["title"]."(".$m["username"].")\"},";
|
|
}
|
|
}else{
|
|
//所有客户
|
|
$q="select id,title,username,path,CONCAT(path,'-',id) 'abs_path' from ".$table_pre."client where id<>'".$uid."' order by abs_path";
|
|
$r=$db->query($q);
|
|
while($m=$db->fetch_array($r)){
|
|
$op_auto_username.="{\"no\":\"".$m["username"]."\",\"title\":\"".$m["title"]."(".$m["username"].")\"},";
|
|
}
|
|
}
|
|
|
|
$op_auto_username=deel_end($op_auto_username);
|
|
$json_data.="\"username_to\":\"".$auto_username."\",";
|
|
$json_data.="\"select_group_by\":{\"no\":\"auto_username\",\"title\":\"用户组\",\"value\":\"".$auto_username."\",\"op\":[".$op_auto_username."]},";
|
|
break;
|
|
case "save":
|
|
$check=get_db_msg("select * from ".$table_pre."client where username='".$username_to."' limit 0,1");
|
|
if($check["id"]>0){
|
|
$query="insert into ".$table_pre."msg (from_cid,to_cid,text,add_date) values ('".$uid."','".$check["id"]."','".mysql_escape_string($text)."','".time()."')";
|
|
$db->query($query);
|
|
$str="发送成功";
|
|
$json_data.="\"code\":\"1\",\"msgerror\":\"".$msgerror."\",";
|
|
}else{
|
|
$msgerror="发送失败,用户不存在!";
|
|
$json_data.="\"code\":\"0\",\"msgerror\":\"".$msgerror."\",";
|
|
}
|
|
break;
|
|
|
|
case "queren":
|
|
if($id){
|
|
$msg=get_db_msg("select * from ".$table_pre."msg where id='".$id."'");
|
|
$db->query("update ".$table_pre."msg set is_read='y' where id='".$msg["id"]."'");
|
|
$json_data.="\"code\":\"1\",";
|
|
}else{
|
|
$msgerror="发送失败,用户不存在!";
|
|
$json_data.="\"code\":\"0\",";
|
|
}
|
|
break;
|
|
}
|
|
$json_data=substr($json_data,0,-1)."}";
|
|
echo $json_data;
|
|
?>
|