<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link rel="stylesheet" type="text/css" href="public/layui/css/layui.css"/>
<script src="public/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="public/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<title>Document</title>
</head>
<body>
<div class="demoTable" style="margin-left: 1%;">
请输入班级:
<div class="layui-inline">
<input name="id" class="layui-input" id="demoReload" autocomplete="off">
</div>
<button class="layui-btn" data-type="reload">搜索</button>
<span class="site-demo-button" id="layerDemo">
<button class="layui-btn" data-method="notice">添加</button>
</span>
</div>
<table class="layui-hide" id="test" lay-filter="demo"></table>
</body>
</html>
<script type="text/html" id="barDemo">
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script type="text/javascript">
layui.use('table', function(){
var table = layui.table;
table.render({
elem: '#test'
,url:'php/projectchuli.php'
,cellMinWidth: 80 //全局定义常规单元格的最小宽度,layui 2.2.1 新增
,limit:8
,limits:[5,8,10,15,20]
,method:'post'
,where:{
type:'load'
}
,cols: [[
//{type:'checkbox'}
{field:'id', width:"14.2%", title: 'ID', sort: true, edit:"text"}
,{field:'uid', width:"14.2%", title: '账号', edit:"text"}
,{field:'name', width:"14.2%", title: '姓名', sort: true, edit:"text"}
,{field:'pwd', width:"14.2%", title: '密码', edit:"text"}
,{field:'class', title: '班级', width:"14.2%", minWidth: 100, edit:"text"}
,{field:'bk', title: '博客', width:"14.2%", minWidth: 100, edit:"text"}
,{fixed: 'right',width:"14.2%", align:'center', toolbar: '#barDemo', edit:"text"} //minWidth:局部定义当前单元格的最小宽度,layui 2.2.1 新增
]]
,id: 'testReload'
,page:true
});
//监听表格复选框选择
table.on('checkbox(demo)', function(obj){
console.log(obj)
});
//监听工具条
table.on('tool(demo)', function(obj){
var data = obj.data;
if(obj.event === 'del'){
layer.confirm('真的删除行么', function(index){
shanchu(data.id);//alert(data.id);
obj.del();
layer.close(index);
});
}
});
//监听单元格实时编辑
table.on('edit(demo)',function(obj){
//注:tool是工具条事件名,test是table原始容器的属性 lay-filter="对应的值"
var data = obj.data;
var field = obj.field;//字段名
var value = obj.value;//修改后的值
// var id = obj.id;
//console.log(obj);
$.ajax({
type:"post",
url:"php/projectchuli.php",
async:true,
data:{
type:"bj",
field:field,
value:value,
id:data.id
},
dataType:"text",
success:function(data){
console.log(data);
}
});
});
var $ = layui.$, active = {
reload: function(){
var demoReload = $('#demoReload');
//执行重载
table.reload('testReload', {
page: {
curr: 1 //重新从第 1 页开始
}
,where: {
type:"chazhao",
bj: demoReload.val()
}
});
}
};
//console.log( $('.demoTable .layui-btn'));
$('.demoTable .layui-btn').on('click', function(){
var type = $(this).data('type');
console.log(type);
active[type] ? active[type].call(this) : '';
});
});
function shanchu(t){
$.ajax({
type:"post",
url:"php/projectchuli.php",
async:true,
data:{
type:"shanchu",
id:t
},
dataType:"text",
success:function(data){
alert(data);
location.reload();
}
});
}
//添加人员弹出框
layui.use('layer', function(){ //独立版的layer无需执行这一句
var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
});
var active = {
notice: function(){
//示范一个公告层
layer.open({
type: 2
,title: false //不显示标题栏
,closeBtn: false
,area: ['40%', '100%']
,shade: 0.8
,id: 'LAY_layuipro' //设定一个id,防止重复弹出
,btn: ['提交', '返回']
,btnAlign: 'c'
,moveType: 1 //拖拽模式,0或者1
,content: 'add.php'
,success: function(layero,index){
var btn = layero.find('.layui-layer-btn');
btn.find('.layui-layer-btn0').click(function(){
var body = layer.getChildFrame('body', index);
var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
var zh = body.find('#zh').val();
var xm = body.find('#xm').val();
var mm = body.find('#mm').val();
var bj = body.find('#sel').val();
var bk = body.find('#bk').val();
var sj = body.find('#test1').val();
console.log(bj);
console.log(zh);
console.log(xm);
console.log(mm);
var ret = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$/;
if(ret.test(mm)){
$.ajax({
type:"post",
url:"php/projectchuli.php",
async:true,
data:{
type:"add",
zh:zh,
xm:xm,
mm:mm,
bj:bj,
bk:bk,
sj:sj
},
dataType:"text",
success:function(data){
if(data.trim()=="ok"){
alert("添加成功");
window.location.href="addjuese.php";
}
}
});
}
});
}
});
}
}
$('#layerDemo .layui-btn').on('click', function(){
var othis = $(this), method = othis.data('method');
active[method] ? active[method].call(this, othis) : '';
});
</script>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link rel="stylesheet" type="text/css" href="public/layui/css/layui.css"/>
<script src="public/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="public/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<title>Document</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
font-family: "微软雅黑";
}
body{
background-color: rgba(0,0,0,0.5);
}
#wai{
width:100%;
line-height: 70px;
}
.spp{
margin-left: 39px;
}
h1{
text-align: center;
}
p{
margin-left: -13%;
font-size: 18px;
}
input{
width: 200px;
height:30px;
border-radius: 5px;
border-color: lawngreen;
}
.p1{
margin-left: -7%;
margin-left: 13px;
}
#sel{
width: 200px;
border-radius: 5px;
border-color: lawngreen;
margin-left: 5px;
}
#spp1{
display: none;
color: red;
}
#spp2{
display: none;
color: red;
}
#spp3{
display: none;
color: red;
}
</style>
</head>
<body>
<div id="zong">
<h1>添加人员</h1>
<div id="wai">
<span class="spp">请输入账号:</span>
<input type="text" id="zh" value="" placeholder="请输入大小写英文字母"/><span id="spp1">请重新输入</span><br />
<span class="spp">请输入姓名:</span>
<input type="text" id="xm" value="" placeholder="请输入中文字符"/><span id="spp2">请重新输入</span><br />
<span class="spp">请输入密码:</span>
<input type="password" id="mm" value="" placeholder="8-16位,至少1个大写字母,小写字母和数字"/><span id="spp3">请重新输入</span><br />
<span class="p1">请选择角色信息:</span><select id="sel"></select><br />
<span class="p1">请输入博客地址:</span>
<input class= "inp" type="text" id="bk" value="" /><br />
<span class="p1">请输入开课时间:</span>
<input class= "inp" type="text" id="test1" placeholder="年-月-日"><br />
</div>
</div>
</body>
</html>
<script type="text/javascript">
$(function (){
jiazai();
//$("#zh").focus();
layui.use('laydate', function(){
var laydate = layui.laydate;
laydate.render({
elem: '#test1'
});
});
});
//账号的input失去焦点事件
$("#zh").blur(function(){
var zh = $("#zh").val();
var ret = /[a-zA-Z]/;
if(!ret.test(zh)){
$("#spp1").css("display","inline-block");//inline-block在一行里显示
}
})
//姓名的input失去焦点事件
$("#xm").blur(function(){
var xm = $("#xm").val();
var ret = /^[\u4e00-\u9fa5]+$/;//只能输入中文
if(!ret.test(xm)){
$("#spp2").css("display","inline-block");
}
})
//密码的input失去焦点事件
$("#mm").blur(function(){
var mm = $("#mm").val();
var ret = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$/;
//至少8-16个字符,至少1个大写字母,1个小写字母和1个数字,其他可以是任意字符
if(!ret.test(mm)){
$("#spp3").css("display","inline-block");
}
})
function jiazai(){
$.ajax({
type:"post",
url:"php/projectchuli.php",
async:true,
data:{
type:"jiazai"
},
dataType:"json",
success:function(data){
var str ="";
for(var i=0;i<data.length;i++){
str +="<option>"+data[i]+"</option>";
}
$("#sel").html(str);
}
});
}
</script>
<?php
session_start();
$conn = new mysqli("localhost","root","","project");
$conn->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 time1<$endtime";
$cdres = $conn->query($cdsql);
$cd = $cdres->fetch_row();
$ztsql ="select count(*) from workattendance where type='早退'and studentname='{$name}'and time1>=$starttime and time1<$endtime";
$ztres = $conn->query($ztsql);
$zt = $ztres->fetch_row();
$zxsql ="select count(*) from zixi where type='自习'and studentname='{$name}'and time1>=$starttime and time1<$endtime";
$zxres = $conn->query($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 time<$endtime";
$yxres = $conn->query($yxsql);
$yx = $yxres->fetch_row();
$lhsql ="select count(*) from weisheng where wsqk='良好'and student='{$name}'and time>=$starttime and time<$endtime";
$lhres = $conn->query($lhsql);
$lh = $lhres->fetch_row();
$ybsql ="select count(*) from weisheng where wsqk='一般'and student='{$name}'and time>=$starttime and time<$endtime";
$ybres = $conn->query($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 times<$endtime";
$gaofenres = $conn->query($gaofensql);
$gaofen = $gaofenres->fetch_row();
$zhongfensql = "select count(*)from examination where score>=60 and score<=80 and studentname='{$name}'and times>=$starttime and times<$endtime";
$zhongfenres = $conn->query($zhongfensql);
$zhongfen = $zhongfenres->fetch_row();
$difensql = "select count(*)from examination where score>80 and studentname='{$name}'and times>=$starttime and times<$endtime";
$difenres = $conn->query($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 times<$endtime";
$jiafenres = $conn->query($jiafensql);
$jiafen = $jiafenres->fetch_row();
$jianfensql="select count(*) from project where score<60 and studentname='{$name}'and times>=$starttime and times<$endtime";
$jianfenres = $conn->query($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 time<$endtime";
$weiwancres = $conn->query($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 time<$endtime";
$bkjfres = $conn->query($bkjfsql);
$bkjf = $bkjfres->fetch_row();
$bkkfsql= "select count(*) from boke where fen='-100' and student='{$name}'and time>=$starttime and time<$endtime";
$bkkfres = $conn->query($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 time1<$endtime";
$cdres = $conn->query($cdsql);
$cd = $cdres->fetch_row();
$ztsql ="select count(*) from workattendance where type='早退'and studentname='{$name}'and time1>=$starttime and time1<$endtime";
$ztres = $conn->query($ztsql);
$zt = $ztres->fetch_row();
$zxsql ="select count(*) from zixi where type='自习'and studentname='{$name}'and time1>=$starttime and time1<$endtime";
$zxres = $conn->query($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 time<$endtime";
$yxres = $conn->query($yxsql);
$yx = $yxres->fetch_row();
$lhsql ="select count(*) from weisheng where wsqk='良好'and student='{$name}'and time>=$starttime and time<$endtime";
$lhres = $conn->query($lhsql);
$lh = $lhres->fetch_row();
$ybsql ="select count(*) from weisheng where wsqk='一般'and student='{$name}'and time>=$starttime and time<$endtime";
$ybres = $conn->query($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 times<$endtime";
$gaofenres = $conn->query($gaofensql);
$gaofen = $gaofenres->fetch_row();
$zhongfensql = "select count(*)from examination where score>=60 and score<=80 and studentname='{$name}'and times>=$starttime and times<$endtime";
$zhongfenres = $conn->query($zhongfensql);
$zhongfen = $zhongfenres->fetch_row();
$difensql = "select count(*)from examination where score>80 and studentname='{$name}'and times>=$starttime and times<$endtime";
$difenres = $conn->query($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 times<$endtime";
$jiafenres = $conn->query($jiafensql);
$jiafen = $jiafenres->fetch_row();
$jianfensql="select count(*) from project where score<60 and studentname='{$name}'and times>=$starttime and times<$endtime";
$jianfenres = $conn->query($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 time<$endtime";
$weiwancres = $conn->query($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 time<$endtime";
$bkjfres = $conn->query($bkjfsql);
$bkjf = $bkjfres->fetch_row();
$bkkfsql= "select count(*) from boke where fen='-100' and student='{$name}'and time>=$starttime and time<$endtime";
$bkkfres = $conn->query($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 time1<$endtime";
$cdres = $conn->query($cdsql);
$cd = $cdres->fetch_row();
$ztsql ="select count(*) from workattendance where type='早退'and studentname='{$name}'and time1>=$starttime and time1<$endtime";
$ztres = $conn->query($ztsql);
$zt = $ztres->fetch_row();
$zxsql ="select count(*) from zixi where type='自习'and studentname='{$name}'and time1>=$starttime and time1<$endtime";
$zxres = $conn->query($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 time<$endtime";
$yxres = $conn->query($yxsql);
$yx = $yxres->fetch_row();
$lhsql ="select count(*) from weisheng where wsqk='良好'and student='{$name}'and time>=$starttime and time<$endtime";
$lhres = $conn->query($lhsql);
$lh = $lhres->fetch_row();
$ybsql ="select count(*) from weisheng where wsqk='一般'and student='{$name}'and time>=$starttime and time<$endtime";
$ybres = $conn->query($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 times<$endtime";
$gaofenres = $conn->query($gaofensql);
$gaofen = $gaofenres->fetch_row();
$zhongfensql = "select count(*)from examination where score>=60 and score<=80 and studentname='{$name}'and times>=$starttime and times<$endtime";
$zhongfenres = $conn->query($zhongfensql);
$zhongfen = $zhongfenres->fetch_row();
$difensql = "select count(*)from examination where score>80 and studentname='{$name}'and times>=$starttime and times<$endtime";
$difenres = $conn->query($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 times<$endtime";
$jiafenres = $conn->query($jiafensql);
$jiafen = $jiafenres->fetch_row();
$jianfensql="select count(*) from project where score<60 and studentname='{$name}'and times>=$starttime and times<$endtime";
$jianfenres = $conn->query($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 time<$endtime";
$weiwancres = $conn->query($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 time<$endtime";
$bkjfres = $conn->query($bkjfsql);
$bkjf = $bkjfres->fetch_row();
$bkkfsql= "select count(*) from boke where fen='-100' and student='{$name}'and time>=$starttime and time<$endtime";
$bkkfres = $conn->query($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 time1<$endtime";
$cdres = $conn->query($cdsql);
$cd = $cdres->fetch_row();
$ztsql ="select count(*) from workattendance where type='早退'and studentname='{$name}'and time1>=$starttime and time1<$endtime";
$ztres = $conn->query($ztsql);
$zt = $ztres->fetch_row();
$zxsql ="select count(*) from zixi where type='自习'and studentname='{$name}'and time1>=$starttime and time1<$endtime";
$zxres = $conn->query($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 time<$endtime";
$yxres = $conn->query($yxsql);
$yx = $yxres->fetch_row();
$lhsql ="select count(*) from weisheng where wsqk='良好'and student='{$name}'and time>=$starttime and time<$endtime";
$lhres = $conn->query($lhsql);
$lh = $lhres->fetch_row();
$ybsql ="select count(*) from weisheng where wsqk='一般'and student='{$name}'and time>=$starttime and time<$endtime";
$ybres = $conn->query($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 times<$endtime";
$gaofenres = $conn->query($gaofensql);
$gaofen = $gaofenres->fetch_row();
$zhongfensql = "select count(*)from examination where score>=60 and score<=80 and studentname='{$name}'and times>=$starttime and times<$endtime";
$zhongfenres = $conn->query($zhongfensql);
$zhongfen = $zhongfenres->fetch_row();
$difensql = "select count(*)from examination where score>80 and studentname='{$name}'and times>=$starttime and times<$endtime";
$difenres = $conn->query($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 times<$endtime";
$jiafenres = $conn->query($jiafensql);
$jiafen = $jiafenres->fetch_row();
$jianfensql="select count(*) from project where score<60 and studentname='{$name}'and times>=$starttime and times<$endtime";
$jianfenres = $conn->query($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 time<$endtime";
$weiwancres = $conn->query($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 time<$endtime";
$bkjfres = $conn->query($bkjfsql);
$bkjf = $bkjfres->fetch_row();
$bkkfsql= "select count(*) from boke where fen='-100' and student='{$name}'and time>=$starttime and time<$endtime";
$bkkfres = $conn->query($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;
}
?>