connect_error?die():"";//mysqli_query($conn, 'set names utf8');
$type = $_POST['type'];switch($type){case "chakanxiangqing":
$limit = $_POST['limit'];$page = ($_POST['page']-1)*$limit;$name = $_SESSION['name'];$sql1 = "select class,student,wsqk,FROM_UNIXTIME(time) from weisheng where student ='{$name}'";$result1 = $conn->query($sql1);$attr1 = $result1->fetch_all();foreach($attr1 as $k=>$v){$attr1[$k][2] = $attr1[$k][2]."/(卫生)";
}$sql2 = "select class,student,fen,FROM_UNIXTIME(time) from boke where student ='{$name}'";$result2 = $conn->query($sql2);$attr2 = $result2->fetch_all();foreach($attr2 as $k=>$v){$attr2[$k][2] = $attr2[$k][2]."/(博客)";
}$sql3 = "select class,studentname,score,FROM_UNIXTIME(times) from examination where studentname ='{$name}'";$result3 = $conn->query($sql3);$attr3 = $result3->fetch_all();foreach($attr3 as $k=>$v){$attr3[$k][2] = $attr3[$k][2]."/(考试)";
}$sql4 = "select class,student,wcqk,FROM_UNIXTIME(time) from job where student ='{$name}'";$result4 = $conn->query($sql4);$attr4 = $result4->fetch_all();foreach($attr4 as $k=>$v){$attr4[$k][2] = $attr4[$k][2]."/(作业)";
}$sql5 = "select class,studentname,score,FROM_UNIXTIME(times) from project where studentname ='{$name}'";$result5 = $conn->query($sql5);$attr5 = $result5->fetch_all();foreach($attr5 as $k=>$v){$attr5[$k][2] = $attr5[$k][2]."/(项目)";
}$sql6 = "select class,studentname,type,FROM_UNIXTIME(time1) from workattendance where studentname ='{$name}'";$result6 = $conn->query($sql6);$attr6 = $result6->fetch_all();//为数组里面的字段拼接文字
foreach($attr6 as $k=>$v){$attr6[$k][2] = $attr6[$k][2]."/(考勤)";
}$sql7 = "select class,studentname,type,FROM_UNIXTIME(time1) from zixi where studentname ='{$name}'";$result7 = $conn->query($sql7);$attr7 = $result7->fetch_all();foreach($attr7 as $k=>$v){$attr7[$k][2] = $attr7[$k][2]."/(自习)";
}$zong = array_merge($attr1,$attr2,$attr3,$attr4,$attr5,$attr6,$attr7);$attrzong = array_slice($zong,$page,$limit,false);//把数组分页
//把数组和总条数放到一个数组里
$he = array($attrzong,count($zong));echo json_encode($he);break;case "gmm":
$uid = $_SESSION['uid'];$mm = $_POST['mm'];$sql = "update user1 set pwd='{$mm}' where uid='{$uid}'";if($result = $conn->query($sql)){echo "ok";
}break;case "chaupfile":
$sql = "select count(*) from xiazai";$result = $conn->query($sql);$attr = $result->fetch_row();echo json_encode($attr);break;case "cha":
$limit = $_POST['limit'];$page = ($_POST['page']-1)*$limit;$sql = "select * from xiazai limit $page,$limit ";$result = $conn->query($sql);$attr = $result->fetch_all();echo json_encode($attr);break;case "upfile_shanchu":
$uid = $_SESSION['uid'];$sql = "select class from user1 where uid = '{$uid}'";$result = $conn->query($sql);$attr = $result->fetch_row();if(($attr[0]=='教师')or($attr[0]=='教务')){$t = $_POST['t'];$d = $_POST['d'];unlink("$d");$sql = "delete from xiazai where id = '{$t}' ";$result = $conn->query($sql);echo "ok";
}else{echo "no";
}break;case "denglu":
$time = time();$uid = $_POST['uid'];$pwd = $_POST['pwd'];$sql = "select pwd,name from user1 where uid = '{$uid}'";$result = $conn->query($sql);$attr = $result->fetch_row();if($pwd==$attr[0]){$_SESSION['uid'] = $uid;$_SESSION['name']= $attr[1];$name = $_SESSION['name'];$sql ="select jibengongzi,starttime,endtime from basicwages where jieduan='阶段一' and student='{$name}'";$result = $conn->query($sql);$gz_time = $result->fetch_row();if(empty($gz_time[0])){echo "ok";
}else{$_SESSION['jiben'] = $gz_time[0];$starttime = $gz_time[1];$endtime = $gz_time[2];//========考勤自习===========
$cdsql ="select count(*) from workattendance where type='迟到'and studentname='{$name}'and time1>=$starttime and time1query($cdsql);$cd = $cdres->fetch_row();$ztsql ="select count(*) from workattendance where type='早退'and studentname='{$name}'and time1>=$starttime and time1query($ztsql);$zt = $ztres->fetch_row();$zxsql ="select count(*) from zixi where type='自习'and studentname='{$name}'and time1>=$starttime and time1query($zxsql);$zx = $zxres->fetch_row();$kq_fen = $cd[0]*(-100)+$zt[0]*(-100);$zx_fen = $zx[0]*100;$_SESSION['kq_fen'] = $kq_fen;$_SESSION['zx_fen'] = $zx_fen;//=====================卫生================
$yxsql ="select count(*) from weisheng where wsqk='优秀'and student='{$name}'and time>=$starttime and timequery($yxsql);$yx = $yxres->fetch_row();$lhsql ="select count(*) from weisheng where wsqk='良好'and student='{$name}'and time>=$starttime and timequery($lhsql);$lh = $lhres->fetch_row();$ybsql ="select count(*) from weisheng where wsqk='一般'and student='{$name}'and time>=$starttime and timequery($ybsql);$yb = $ybres->fetch_row();$ws_fen = $yx[0]*100+$lh[0]*50+$yb[0]*(-50);$_SESSION['ws_fen'] = $ws_fen;//========================考试========================
$gaofensql = "select count(*)from examination where score<60 and studentname='{$name}'and times>=$starttime and timesquery($gaofensql);$gaofen = $gaofenres->fetch_row();$zhongfensql = "select count(*)from examination where score>=60 and score<=80 and studentname='{$name}'and times>=$starttime and timesquery($zhongfensql);$zhongfen = $zhongfenres->fetch_row();$difensql = "select count(*)from examination where score>80 and studentname='{$name}'and times>=$starttime and timesquery($difensql);$difen = $difenres->fetch_row();$ks_fen = $gaofen[0]*100+$zhongfen[0]*50+$difen[0]*(-50);$_SESSION['ks_fen'] = $ks_fen;//========================项目========================
$jiafensql="select count(*) from project where score>=60 and studentname='{$name}'and times>=$starttime and timesquery($jiafensql);$jiafen = $jiafenres->fetch_row();$jianfensql="select count(*) from project where score<60 and studentname='{$name}'and times>=$starttime and timesquery($jianfensql);$jianfen = $jianfenres->fetch_row();$xm_fen = $jiafen[0]*100+$jianfen[0]*(-100);$_SESSION['xm_fen'] = $xm_fen;//========================作业========================
$weiwancsql ="select count(*) from job where wcqk='未完成' and student='{$name}'and time>=$starttime and timequery($weiwancsql);$weiwanc = $weiwancres->fetch_row();$zy_fen = $weiwanc[0]*(-50);$_SESSION['zy_fen'] = $zy_fen;//========================博客========================
$bkjfsql= "select count(*) from boke where fen='100' and student='{$name}'and time>=$starttime and timequery($bkjfsql);$bkjf = $bkjfres->fetch_row();$bkkfsql= "select count(*) from boke where fen='-100' and student='{$name}'and time>=$starttime and timequery($bkkfsql);$bkkf = $bkkfres->fetch_row();$bk_fen =$bkjf[0]*100+ $bkkf[0]*(-100);$_SESSION['bk_fen'] = $bk_fen;$shijigz = $gz_time[0]+$kq_fen+$zx_fen+$ws_fen+$ks_fen+$xm_fen+$zy_fen+$bk_fen;$_SESSION['shijigz'] = $shijigz;$sql ="select jibengongzi,starttime,endtime from basicwages where jieduan='阶段二' and student='{$name}'";$result = $conn->query($sql);$gz_time = $result->fetch_row();$_SESSION['jiben2'] = $gz_time[0];$starttime = $gz_time[1];$endtime = $gz_time[2];//========考勤自习===========
$cdsql ="select count(*) from workattendance where type='迟到'and studentname='{$name}'and time1>=$starttime and time1query($cdsql);$cd = $cdres->fetch_row();$ztsql ="select count(*) from workattendance where type='早退'and studentname='{$name}'and time1>=$starttime and time1query($ztsql);$zt = $ztres->fetch_row();$zxsql ="select count(*) from zixi where type='自习'and studentname='{$name}'and time1>=$starttime and time1query($zxsql);$zx = $zxres->fetch_row();$kq_fen = $cd[0]*(-100)+$zt[0]*(-100);$zx_fen = $zx[0]*100;$_SESSION['kq_fen2'] = $kq_fen;$_SESSION['zx_fen2'] = $zx_fen;//=====================卫生================
$yxsql ="select count(*) from weisheng where wsqk='优秀'and student='{$name}'and time>=$starttime and timequery($yxsql);$yx = $yxres->fetch_row();$lhsql ="select count(*) from weisheng where wsqk='良好'and student='{$name}'and time>=$starttime and timequery($lhsql);$lh = $lhres->fetch_row();$ybsql ="select count(*) from weisheng where wsqk='一般'and student='{$name}'and time>=$starttime and timequery($ybsql);$yb = $ybres->fetch_row();$ws_fen = $yx[0]*100+$lh[0]*50+$yb[0]*(-50);$_SESSION['ws_fen2'] = $ws_fen;//========================考试========================
$gaofensql = "select count(*)from examination where score<60 and studentname='{$name}'and times>=$starttime and timesquery($gaofensql);$gaofen = $gaofenres->fetch_row();$zhongfensql = "select count(*)from examination where score>=60 and score<=80 and studentname='{$name}'and times>=$starttime and timesquery($zhongfensql);$zhongfen = $zhongfenres->fetch_row();$difensql = "select count(*)from examination where score>80 and studentname='{$name}'and times>=$starttime and timesquery($difensql);$difen = $difenres->fetch_row();$ks_fen = $gaofen[0]*100+$zhongfen[0]*50+$difen[0]*(-50);$_SESSION['ks_fen2'] = $ks_fen;//========================项目========================
$jiafensql="select count(*) from project where score>=60 and studentname='{$name}'and times>=$starttime and timesquery($jiafensql);$jiafen = $jiafenres->fetch_row();$jianfensql="select count(*) from project where score<60 and studentname='{$name}'and times>=$starttime and timesquery($jianfensql);$jianfen = $jianfenres->fetch_row();$xm_fen = $jiafen[0]*100+$jianfen[0]*(-100);$_SESSION['xm_fen2'] = $xm_fen;//========================作业========================
$weiwancsql ="select count(*) from job where wcqk='未完成' and student='{$name}'and time>=$starttime and timequery($weiwancsql);$weiwanc = $weiwancres->fetch_row();$zy_fen = $weiwanc[0]*(-50);$_SESSION['zy_fen2'] = $zy_fen;//========================博客========================
$bkjfsql= "select count(*) from boke where fen='100' and student='{$name}'and time>=$starttime and timequery($bkjfsql);$bkjf = $bkjfres->fetch_row();$bkkfsql= "select count(*) from boke where fen='-100' and student='{$name}'and time>=$starttime and timequery($bkkfsql);$bkkf = $bkkfres->fetch_row();$bk_fen =$bkjf[0]*100+ $bkkf[0]*(-100);$_SESSION['bk_fen2'] = $bk_fen;$shijigz = $gz_time[0]+$kq_fen+$zx_fen+$ws_fen+$ks_fen+$xm_fen+$zy_fen+$bk_fen;$_SESSION['shijigz2'] = $shijigz;$sql ="select jibengongzi,starttime,endtime from basicwages where jieduan='阶段三' and student='{$name}'";$result = $conn->query($sql);$gz_time = $result->fetch_row();$_SESSION['jiben3'] = $gz_time[0];$starttime = $gz_time[1];$endtime = $gz_time[2];//========考勤自习===========
$cdsql ="select count(*) from workattendance where type='迟到'and studentname='{$name}'and time1>=$starttime and time1query($cdsql);$cd = $cdres->fetch_row();$ztsql ="select count(*) from workattendance where type='早退'and studentname='{$name}'and time1>=$starttime and time1query($ztsql);$zt = $ztres->fetch_row();$zxsql ="select count(*) from zixi where type='自习'and studentname='{$name}'and time1>=$starttime and time1query($zxsql);$zx = $zxres->fetch_row();$kq_fen = $cd[0]*(-100)+$zt[0]*(-100);$zx_fen = $zx[0]*100;$_SESSION['kq_fen3'] = $kq_fen;$_SESSION['zx_fen3'] = $zx_fen;//=====================卫生================
$yxsql ="select count(*) from weisheng where wsqk='优秀'and student='{$name}'and time>=$starttime and timequery($yxsql);$yx = $yxres->fetch_row();$lhsql ="select count(*) from weisheng where wsqk='良好'and student='{$name}'and time>=$starttime and timequery($lhsql);$lh = $lhres->fetch_row();$ybsql ="select count(*) from weisheng where wsqk='一般'and student='{$name}'and time>=$starttime and timequery($ybsql);$yb = $ybres->fetch_row();$ws_fen = $yx[0]*100+$lh[0]*50+$yb[0]*(-50);$_SESSION['ws_fen3'] = $ws_fen;//========================考试========================
$gaofensql = "select count(*)from examination where score<60 and studentname='{$name}'and times>=$starttime and timesquery($gaofensql);$gaofen = $gaofenres->fetch_row();$zhongfensql = "select count(*)from examination where score>=60 and score<=80 and studentname='{$name}'and times>=$starttime and timesquery($zhongfensql);$zhongfen = $zhongfenres->fetch_row();$difensql = "select count(*)from examination where score>80 and studentname='{$name}'and times>=$starttime and timesquery($difensql);$difen = $difenres->fetch_row();$ks_fen = $gaofen[0]*100+$zhongfen[0]*50+$difen[0]*(-50);$_SESSION['ks_fen3'] = $ks_fen;//========================项目========================
$jiafensql="select count(*) from project where score>=60 and studentname='{$name}'and times>=$starttime and timesquery($jiafensql);$jiafen = $jiafenres->fetch_row();$jianfensql="select count(*) from project where score<60 and studentname='{$name}'and times>=$starttime and timesquery($jianfensql);$jianfen = $jianfenres->fetch_row();$xm_fen = $jiafen[0]*100+$jianfen[0]*(-100);$_SESSION['xm_fen3'] = $xm_fen;//========================作业========================
$weiwancsql ="select count(*) from job where wcqk='未完成' and student='{$name}'and time>=$starttime and timequery($weiwancsql);$weiwanc = $weiwancres->fetch_row();$zy_fen = $weiwanc[0]*(-50);$_SESSION['zy_fen3'] = $zy_fen;//========================博客========================
$bkjfsql= "select count(*) from boke where fen='100' and student='{$name}'and time>=$starttime and timequery($bkjfsql);$bkjf = $bkjfres->fetch_row();$bkkfsql= "select count(*) from boke where fen='-100' and student='{$name}'and time>=$starttime and timequery($bkkfsql);$bkkf = $bkkfres->fetch_row();$bk_fen =$bkjf[0]*100+ $bkkf[0]*(-100);$_SESSION['bk_fen3'] = $bk_fen;$shijigz = $gz_time[0]+$kq_fen+$zx_fen+$ws_fen+$ks_fen+$xm_fen+$zy_fen+$bk_fen;$_SESSION['shijigz3'] = $shijigz;$sql ="select jibengongzi,starttime,endtime from basicwages where jieduan='阶段四' and student='{$name}'";$result = $conn->query($sql);$gz_time = $result->fetch_row();$_SESSION['jiben4'] = $gz_time[0];$starttime = $gz_time[1];$endtime = $gz_time[2];//========考勤自习===========
$cdsql ="select count(*) from workattendance where type='迟到'and studentname='{$name}'and time1>=$starttime and time1query($cdsql);$cd = $cdres->fetch_row();$ztsql ="select count(*) from workattendance where type='早退'and studentname='{$name}'and time1>=$starttime and time1query($ztsql);$zt = $ztres->fetch_row();$zxsql ="select count(*) from zixi where type='自习'and studentname='{$name}'and time1>=$starttime and time1query($zxsql);$zx = $zxres->fetch_row();$kq_fen = $cd[0]*(-100)+$zt[0]*(-100);$zx_fen = $zx[0]*100;$_SESSION['kq_fen4'] = $kq_fen;$_SESSION['zx_fen4'] = $zx_fen;//=====================卫生================
$yxsql ="select count(*) from weisheng where wsqk='优秀'and student='{$name}'and time>=$starttime and timequery($yxsql);$yx = $yxres->fetch_row();$lhsql ="select count(*) from weisheng where wsqk='良好'and student='{$name}'and time>=$starttime and timequery($lhsql);$lh = $lhres->fetch_row();$ybsql ="select count(*) from weisheng where wsqk='一般'and student='{$name}'and time>=$starttime and timequery($ybsql);$yb = $ybres->fetch_row();$ws_fen = $yx[0]*100+$lh[0]*50+$yb[0]*(-50);$_SESSION['ws_fen4'] = $ws_fen;//========================考试========================
$gaofensql = "select count(*)from examination where score<60 and studentname='{$name}'and times>=$starttime and timesquery($gaofensql);$gaofen = $gaofenres->fetch_row();$zhongfensql = "select count(*)from examination where score>=60 and score<=80 and studentname='{$name}'and times>=$starttime and timesquery($zhongfensql);$zhongfen = $zhongfenres->fetch_row();$difensql = "select count(*)from examination where score>80 and studentname='{$name}'and times>=$starttime and timesquery($difensql);$difen = $difenres->fetch_row();$ks_fen = $gaofen[0]*100+$zhongfen[0]*50+$difen[0]*(-50);$_SESSION['ks_fen4'] = $ks_fen;//========================项目========================
$jiafensql="select count(*) from project where score>=60 and studentname='{$name}'and times>=$starttime and timesquery($jiafensql);$jiafen = $jiafenres->fetch_row();$jianfensql="select count(*) from project where score<60 and studentname='{$name}'and times>=$starttime and timesquery($jianfensql);$jianfen = $jianfenres->fetch_row();$xm_fen = $jiafen[0]*100+$jianfen[0]*(-100);$_SESSION['xm_fen4'] = $xm_fen;//========================作业========================
$weiwancsql ="select count(*) from job where wcqk='未完成' and student='{$name}'and time>=$starttime and timequery($weiwancsql);$weiwanc = $weiwancres->fetch_row();$zy_fen = $weiwanc[0]*(-50);$_SESSION['zy_fen4'] = $zy_fen;//========================博客========================
$bkjfsql= "select count(*) from boke where fen='100' and student='{$name}'and time>=$starttime and timequery($bkjfsql);$bkjf = $bkjfres->fetch_row();$bkkfsql= "select count(*) from boke where fen='-100' and student='{$name}'and time>=$starttime and timequery($bkkfsql);$bkkf = $bkkfres->fetch_row();$bk_fen =$bkjf[0]*100+ $bkkf[0]*(-100);$_SESSION['bk_fen4'] = $bk_fen;$shijigz = $gz_time[0]+$kq_fen+$zx_fen+$ws_fen+$ks_fen+$xm_fen+$zy_fen+$bk_fen;$_SESSION['shijigz4'] = $shijigz;echo "ok";
}
}break;case "pd_class":
$uid = $_SESSION['uid'];$sql="select class from user1 where uid ='{$uid}'";$result = $conn->query($sql);$attr = $result->fetch_row();echo json_encode($attr);break;case "load":
$page = $_POST['page'];$limit = $_POST['limit'];$tg = ($page-1)*$limit;$sql ="select * from user1 limit $tg,$limit";//limit m,n 跳过m条显示n条
$result = $conn->query($sql);$arrr = array();while($attr = $result->fetch_assoc()){array_push($arrr,$attr);
};$sql1 ="select count(*) from user1";$result1 = $conn->query($sql1);$attr1 = $result1->fetch_row();$arr = array();//layui接口接受的数据格式
/*{
code: 0,
msg: "",
count: 1000,//数据条数
data: []
}*/
$arr['code'] = 0;$arr['msg'] ="";$arr['count'] = $attr1[0];$arr['data'] = $arrr;echo json_encode($arr);break;//==========按班级查找==================
case "chazhao":
$bj = $_POST['bj'];$page = $_POST['page'];$limit = $_POST['limit'];$tg = ($page-1)*$limit;$sql ="select * from user1 where class like '%{$bj}%' limit $tg,$limit";$result = $conn->query($sql);$arrr = array();while($attr = $result->fetch_assoc()){array_push($arrr,$attr);
};$sql1 ="select count(*) from user1";$result1 = $conn->query($sql1);$attr1 = $result1->fetch_row();$arr = array();$arr['code'] = 0;$arr['msg'] ="";$arr['count'] = $attr1[0];$arr['data'] = $arrr;echo json_encode($arr);break;case "bj":
$field = $_POST['field'];$value = $_POST['value'];$id = $_POST['id'];$sql = "update user1 set $field='{$value}' where id='{$id}'";$result = $conn->query($sql);break;case"shanchu":
$id = $_POST['id'];$sql = "delete from user1 where id='{$id}'";if($result = $conn->query($sql)){echo "ok";
};break;case "add":
$zh = $_POST['zh'];$xm = $_POST['xm'];$mm = $_POST['mm'];$bj = $_POST['bj'];$bk = $_POST['bk'];$sj1 = strtotime($_POST['sj']);//日期转时间戳
$sj2=$sj1+2592000;$sj3=$sj2+2592000;$sj4=$sj3+2592000;$sj5=$sj4+2592000;if(!empty($zh)&&!empty($xm)&&!empty($mm)&&!empty($bj)&&!empty($bk)&&!empty($sj1)){$sql = "insert into user1 values('','{$zh}','{$xm}','{$mm}','{$bj}','{$bk}')";if($result = $conn->query($sql)){$sql1="insert into basicwages values('','{$xm}','{$sj1}','{$sj2}','2500','阶段一')";$result1 = $conn->query($sql1);$sql2="insert into basicwages values('','{$xm}','{$sj2}','{$sj3}','3000','阶段二')";$result2 = $conn->query($sql2);$sql3="insert into basicwages values('','{$xm}','{$sj3}','{$sj4}','3500','阶段三')";$result3 = $conn->query($sql3);$sql4="insert into basicwages values('','{$xm}','{$sj4}','{$sj5}','4000','阶段四')";$result4 = $conn->query($sql4);echo "ok";
};
}break;case "jiazai":
$sql = "select class from user1";$result = $conn->query($sql);$attr = $result->fetch_all();foreach($attr as $v){$v =join(',',$v);$temp[] = $v;
};$temp = array_values(array_unique($temp));//不用array_values会返回object
/*foreach ($temp as $k => $v){
$temp[$k]=explode(',',$v); //再将拆开的数组重新组装
}*/
echo json_encode($temp);break;case "lian":
$sql ="select distinct class from user1 where class not in('教师','教务')";$result = $conn->query($sql);$attr = $result->fetch_all();echo json_encode($attr);break;case "lian1":
$sel1 = $_POST['sel1'];$sql ="select uid,name from user1 where class ='{$sel1}'";$result = $conn->query($sql);$attr = $result->fetch_all();echo json_encode($attr);break;//============================考勤页面==================================
case "load_kaoqin":
$page = $_POST['page'];$limit = $_POST['limit'];$tg = ($page-1)*$limit;$sql ="select *,from_unixtime(time1,'%Y-%m-%d')as riqi from workattendance order by time1 desc limit $tg,$limit";//limit m,n 跳过m条显示n条
//时间戳转时间
$result = $conn->query($sql);$arrr = array();while($attr = $result->fetch_assoc()){array_push($arrr,$attr);
};$sql1 ="select count(*) from workattendance";$result1 = $conn->query($sql1);$attr1 = $result1->fetch_row();$arr = array();$arr['code'] = 0;$arr['msg'] ="";$arr['count'] = $attr1[0];$arr['data'] = $arrr;echo json_encode($arr);break;case "kq_bj":
$field = $_POST['field'];$value = $_POST['value'];$id = $_POST['id'];$sql = "update workattendance set $field='{$value}' where id='{$id}'";$result = $conn->query($sql);break;case"kq_shanchu":
$id = $_POST['id'];$sql = "delete from workattendance where id='{$id}'";if($result = $conn->query($sql)){echo "ok";
};break;case "kq_chazhao":
$xm = $_POST['xm'];$bj = $_POST['bj'];$lx = $_POST['lx'];$page = $_POST['page'];$limit = $_POST['limit'];$tg = ($page-1)*$limit;$sql ="select *,from_unixtime(time1,'%Y-%m-%d')as riqi from workattendance where studentname like '%{$xm}%' and class like '%{$bj}%' and type like '%{$lx}%' order by time1 desc limit $tg,$limit";$result = $conn->query($sql);$arrr = array();while($attr = $result->fetch_assoc()){array_push($arrr,$attr);
};$sql1 ="select count(*) from workattendance";$result1 = $conn->query($sql1);$attr1 = $result1->fetch_row();$arr = array();$arr['code'] = 0;$arr['msg'] ="";$arr['count'] = $attr1[0];$arr['data'] = $arrr;echo json_encode($arr);break;case "chidao":
if(empty($_POST['time'])){echo "no";
}else{$zl = $_POST['zl'];$bj = $_POST['bj'];$stu_name = $_POST['stu_name'];$time = strtotime($_POST['time']);//日期转时间戳
$tea_name = $_SESSION['uid'];$sql ="insert into workattendance values('','{$tea_name}','{$stu_name}','{$bj}','{$zl}','{$time}')";if($result = $conn->query($sql)){echo "ok";
};
}break;case "zaotui":
if(empty($_POST['time'])){echo "no";
}else{$zl = $_POST['zl'];$bj = $_POST['bj'];$stu_name = $_POST['stu_name'];$time = strtotime($_POST['time']);$tea_name = $_SESSION['uid'];$sql ="insert into workattendance values('','{$tea_name}','{$stu_name}','{$bj}','{$zl}','{$time}')";if($result = $conn->query($sql)){echo "ok";
};
}break;//============================自习页面==========================
case "load_zixi":
$page = $_POST['page'];$limit = $_POST['limit'];$tg = ($page-1)*$limit;$sql ="select *,from_unixtime(time1,'%Y-%m-%d')as riqi from zixi order by time1 desc limit $tg,$limit";//limit m,n 跳过m条显示n条
//时间戳转时间
$result = $conn->query($sql);$arrr = array();while($attr = $result->fetch_assoc()){array_push($arrr,$attr);
};$sql1 ="select count(*) from zixi";$result1 = $conn->query($sql1);$attr1 = $result1->fetch_row();$arr = array();$arr['code'] = 0;$arr['msg'] ="";$arr['count'] = $attr1[0];$arr['data'] = $arrr;echo json_encode($arr);break;case "zx_bj":
$field = $_POST['field'];$value = $_POST['value'];$id = $_POST['id'];$sql = "update zixi set $field='{$value}' where id='{$id}'";$result = $conn->query($sql);break;case"zx_shanchu":
$id = $_POST['id'];$sql = "delete from zixi where id='{$id}'";if($result = $conn->query($sql)){echo "ok";
};break;case "zx_chazhao":
$xm = $_POST['xm'];$bj = $_POST['bj'];$page = $_POST['page'];$limit = $_POST['limit'];$tg = ($page-1)*$limit;$sql ="select *,from_unixtime(time1,'%Y-%m-%d')as riqi from zixi where studentname like '%{$xm}%' and class like '%{$bj}%' order by time1 desc limit $tg,$limit";$result = $conn->query($sql);$arrr = array();while($attr = $result->fetch_assoc()){array_push($arrr,$attr);
};$sql1 ="select count(*) from zixi";$result1 = $conn->query($sql1);$attr1 = $result1->fetch_row();$arr = array();$arr['code'] = 0;$arr['msg'] ="";$arr['count'] = $attr1[0];$arr['data'] = $arrr;echo json_encode($arr);break;case "zixi":
if(empty($_POST['time'])){echo "no";
}else{$zl = $_POST['zl'];$bj = $_POST['bj'];$stu_name = $_POST['stu_name'];$time = strtotime($_POST['time']);//日期转时间戳
$tea_name = $_SESSION['uid'];$sql ="insert into zixi values('','{$tea_name}','{$stu_name}','{$bj}','{$zl}','{$time}')";if($result = $conn->query($sql)){echo "ok";
};
}break;//==========================卫生页面================================
case "load_weisheng":
$page = $_POST['page'];$limit = $_POST['limit'];$tg = ($page-1)*$limit;$sql ="select *,from_unixtime(time,'%Y-%m-%d')as riqi from weisheng order by time desc limit $tg,$limit";//limit m,n 跳过m条显示n条
//时间戳转时间
$result = $conn->query($sql);$arrr = array();while($attr = $result->fetch_assoc()){array_push($arrr,$attr);
};$sql1 ="select count(*) from weisheng";$result1 = $conn->query($sql1);$attr1 = $result1->fetch_row();$arr = array();$arr['code'] = 0;$arr['msg'] ="";$arr['count'] = $attr1[0];$arr['data'] = $arrr;echo json_encode($arr);break;case "ws_bj":
$field = $_POST['field'];$value = $_POST['value'];$id = $_POST['id'];$sql = "update weisheng set $field='{$value}' where id='{$id}'";$result = $conn->query($sql);break;case"ws_shanchu":
$id = $_POST['id'];$sql = "delete from weisheng where id='{$id}'";if($result = $conn->query($sql)){echo "ok";
};break;case "wx_chazhao":
$xm = $_POST['xm'];$bj = $_POST['bj'];$lx = $_POST['lx'];$page = $_POST['page'];$limit = $_POST['limit'];$tg = ($page-1)*$limit;$sql ="select *,from_unixtime(time,'%Y-%m-%d')as riqi from weisheng where student like '%{$xm}%' and class like '%{$bj}%' and wsqk like '%{$lx}%' order by time desc limit $tg,$limit";$result = $conn->query($sql);$arrr = array();while($attr = $result->fetch_assoc()){array_push($arrr,$attr);
};$sql1 ="select count(*) from weisheng";$result1 = $conn->query($sql1);$attr1 = $result1->fetch_row();$arr = array();$arr['code'] = 0;$arr['msg'] ="";$arr['count'] = $attr1[0];$arr['data'] = $arrr;echo json_encode($arr);break;case "wsqk":
if(empty($_POST['time'])){echo "no";
}else{$zl = $_POST['zl'];$bj = $_POST['bj'];$stu_name = $_POST['stu_name'];$time = strtotime($_POST['time']);//日期转时间戳
$sql ="insert into weisheng values('','{$bj}','{$stu_name}','{$time}','{$zl}')";if($result = $conn->query($sql)){echo "ok";
};
}break;//======================考试页面==============================
case "load_kaoshi":
$page = $_POST['page'];$limit = $_POST['limit'];$tg = ($page-1)*$limit;$sql ="select *,from_unixtime(times,'%Y-%m-%d')as riqi from examination order by times desc limit $tg,$limit";//limit m,n 跳过m条显示n条
//时间戳转时间
$result = $conn->query($sql);$arrr = array();while($attr = $result->fetch_assoc()){array_push($arrr,$attr);
};$sql1 ="select count(*) from examination";$result1 = $conn->query($sql1);$attr1 = $result1->fetch_row();$arr = array();$arr['code'] = 0;$arr['msg'] ="";$arr['count'] = $attr1[0];$arr['data'] = $arrr;echo json_encode($arr);break;case "ks_bj":
$field = $_POST['field'];$value = $_POST['value'];$id = $_POST['id'];$sql = "update examination set $field='{$value}' where id='{$id}'";$result = $conn->query($sql);break;case"ks_shanchu":
$id = $_POST['id'];$sql = "delete from examination where id='{$id}'";if($result = $conn->query($sql)){echo "ok";
};break;case "ks_chazhao":
$xm = $_POST['xm'];$bj = $_POST['bj'];$fs = $_POST['fs'];$page = $_POST['page'];$limit = $_POST['limit'];$tg = ($page-1)*$limit;$sql ="select *,from_unixtime(times,'%Y-%m-%d')as riqi from examination where studentname like '%{$xm}%' and class like '%{$bj}%' and score like '%{$fs}%' order by times desc limit $tg,$limit";$result = $conn->query($sql);$arrr = array();while($attr = $result->fetch_assoc()){array_push($arrr,$attr);
};$sql1 ="select count(*) from examination";$result1 = $conn->query($sql1);$attr1 = $result1->fetch_row();$arr = array();$arr['code'] = 0;$arr['msg'] ="";$arr['count'] = $attr1[0];$arr['data'] = $arrr;echo json_encode($arr);break;case "tj_score":
if(empty($_POST['time'])){echo "no";
}else{$score = $_POST['score'];$bj = $_POST['bj'];$stu_name = $_POST['stu_name'];$time = strtotime($_POST['time']);//日期转时间戳
$tea_name = $_SESSION['uid'];$sql ="insert into examination values('','{$tea_name}','{$stu_name}','{$bj}','{$score}','{$time}')";if($result = $conn->query($sql)){echo "ok";
};
}break;//======================项目页面==============================
case "load_xiangmu":
$page = $_POST['page'];$limit = $_POST['limit'];$tg = ($page-1)*$limit;$sql ="select *,from_unixtime(times,'%Y-%m-%d')as riqi from project order by times desc limit $tg,$limit";//limit m,n 跳过m条显示n条
//时间戳转时间
$result = $conn->query($sql);$arrr = array();while($attr = $result->fetch_assoc()){array_push($arrr,$attr);
};$sql1 ="select count(*) from project";$result1 = $conn->query($sql1);$attr1 = $result1->fetch_row();$arr = array();$arr['code'] = 0;$arr['msg'] ="";$arr['count'] = $attr1[0];$arr['data'] = $arrr;echo json_encode($arr);break;case "xm_bj":
$field = $_POST['field'];$value = $_POST['value'];$id = $_POST['id'];$sql = "update project set $field='{$value}' where id='{$id}'";$result = $conn->query($sql);break;case"xm_shanchu":
$id = $_POST['id'];$sql = "delete from project where id='{$id}'";if($result = $conn->query($sql)){echo "ok";
};break;case "xm_chazhao":
$xm = $_POST['xm'];$bj = $_POST['bj'];$fs = $_POST['fs'];$page = $_POST['page'];$limit = $_POST['limit'];$tg = ($page-1)*$limit;$sql ="select *,from_unixtime(times,'%Y-%m-%d')as riqi from project where studentname like '%{$xm}%' and class like '%{$bj}%' and score like '%{$fs}%' order by times desc limit $tg,$limit";$result = $conn->query($sql);$arrr = array();while($attr = $result->fetch_assoc()){array_push($arrr,$attr);
};$sql1 ="select count(*) from project";$result1 = $conn->query($sql1);$attr1 = $result1->fetch_row();$arr = array();$arr['code'] = 0;$arr['msg'] ="";$arr['count'] = $attr1[0];$arr['data'] = $arrr;echo json_encode($arr);break;case "xm_score":
if(empty($_POST['time'])){echo "no";
}else{$score = $_POST['score'];$bj = $_POST['bj'];$stu_name = $_POST['stu_name'];$pro_name = $_POST['pro_name'];$time = strtotime($_POST['time']);//日期转时间戳
$tea_name = $_SESSION['uid'];$sql ="insert into project values('','{$tea_name}','{$stu_name}','{$bj}','{$pro_name}','{$score}','{$time}')";if($result = $conn->query($sql)){echo "ok";
};
}break;//======================作业页面==============================
case "load_zuoye":
$page = $_POST['page'];$limit = $_POST['limit'];$tg = ($page-1)*$limit;$sql ="select *,from_unixtime(time,'%Y-%m-%d')as riqi from job order by time desc limit $tg,$limit";//limit m,n 跳过m条显示n条
//时间戳转时间
$result = $conn->query($sql);$arrr = array();while($attr = $result->fetch_assoc()){array_push($arrr,$attr);
};$sql1 ="select count(*) from job";$result1 = $conn->query($sql1);$attr1 = $result1->fetch_row();$arr = array();$arr['code'] = 0;$arr['msg'] ="";$arr['count'] = $attr1[0];$arr['data'] = $arrr;echo json_encode($arr);break;case "zy_bj":
$field = $_POST['field'];$value = $_POST['value'];$id = $_POST['id'];$sql = "update job set $field='{$value}' where id='{$id}'";$result = $conn->query($sql);break;case"zy_shanchu":
$id = $_POST['id'];$sql = "delete from job where id='{$id}'";if($result = $conn->query($sql)){echo "ok";
};break;case "zy_chazhao":
$xm = $_POST['xm'];$bj = $_POST['bj'];$wcqk = $_POST['wcqk'];$page = $_POST['page'];$limit = $_POST['limit'];$tg = ($page-1)*$limit;$sql ="select *,from_unixtime(time,'%Y-%m-%d')as riqi from job where student like '%{$xm}%' and class like '%{$bj}%' and wcqk like '%{$wcqk}%' order by time desc limit $tg,$limit";$result = $conn->query($sql);$arrr = array();while($attr = $result->fetch_assoc()){array_push($arrr,$attr);
};$sql1 ="select count(*) from job";$result1 = $conn->query($sql1);$attr1 = $result1->fetch_row();$arr = array();$arr['code'] = 0;$arr['msg'] ="";$arr['count'] = $attr1[0];$arr['data'] = $arrr;echo json_encode($arr);break;case "tj_zy":
if(empty($_POST['time'])){echo "no";
}else{$qk = $_POST['qk'];$bj = $_POST['bj'];$stu_name = $_POST['stu_name'];$time = strtotime($_POST['time']);//日期转时间戳
$sql ="insert into job values('','{$bj}','{$stu_name}','{$time}','{$qk}')";if($result = $conn->query($sql)){echo "ok";
};
}break;//======================博客页面==============================
case "load_boke":
$page = $_POST['page'];$limit = $_POST['limit'];$tg = ($page-1)*$limit;$sql ="select *,from_unixtime(time,'%Y-%m-%d')as riqi from boke order by time desc limit $tg,$limit";//limit m,n 跳过m条显示n条
//时间戳转时间
$result = $conn->query($sql);$arrr = array();while($attr = $result->fetch_assoc()){array_push($arrr,$attr);
};$sql1 ="select count(*) from boke";$result1 = $conn->query($sql1);$attr1 = $result1->fetch_row();$arr = array();$arr['code'] = 0;$arr['msg'] ="";$arr['count'] = $attr1[0];$arr['data'] = $arrr;echo json_encode($arr);break;case "bk_bj":
$field = $_POST['field'];$value = $_POST['value'];$id = $_POST['id'];$sql = "update boke set $field='{$value}' where id='{$id}'";$result = $conn->query($sql);break;case"bk_shanchu":
$id = $_POST['id'];$sql = "delete from boke where id='{$id}'";if($result = $conn->query($sql)){echo "ok";
};break;case "bk_chazhao":
$xm = $_POST['xm'];$bj = $_POST['bj'];$fen = $_POST['fen'];$page = $_POST['page'];$limit = $_POST['limit'];$tg = ($page-1)*$limit;$sql ="select *,from_unixtime(time,'%Y-%m-%d')as riqi from boke where student like '%{$xm}%' and class like '%{$bj}%' and fen like '%{$fen}%' order by time desc limit $tg,$limit";$result = $conn->query($sql);$arrr = array();while($attr = $result->fetch_assoc()){array_push($arrr,$attr);
};$sql1 ="select count(*) from boke";$result1 = $conn->query($sql1);$attr1 = $result1->fetch_row();$arr = array();$arr['code'] = 0;$arr['msg'] ="";$arr['count'] = $attr1[0];$arr['data'] = $arrr;echo json_encode($arr);break;case "tj_bk":
if(empty($_POST['time'])){echo "no";
}else{$fen = $_POST['fen'];$bj = $_POST['bj'];$stu_name = $_POST['stu_name'];$time = strtotime($_POST['time']);//日期转时间戳
$sql ="insert into boke values('','{$stu_name}','{$bj}','{$fen}','{$time}')";if($result = $conn->query($sql)){echo "ok";
};
}break;case "clear":
session_destroy();break;
}?>