<?
session_start();
include "../config.php";
$jstjr=$_SESSION['username'];
$jstime=time();
if($_POST['jsmc'] && $_GET['ins']){
$jsqx=implode(",",$_POST['jsqx']);
$qxfl=explode(",",$jsqx);
$jsmc=$_POST['jsmc'];
$sql="insert into js(jsmc,jsqx,jstime,jstjr)values('$jsmc','$jsqx','$jstime','$jstjr')";
$tj=$conn->query($sql);
}
//修改角色
if($_GET['jid']){
$jid=$_GET['jid'];
$sqljs="select * from js where jid='$jid'";
$re=$conn->query($sqljs);
$rest=$re->fetch_assoc();
if($_GET['update']){
$jsmc=$_POST['jsmc'];
$jsqx=implode(",",$_POST['jsqx']);
$qxfl=explode(",",$jsqx);
$sqlu="update js set jsmc='$jsmc',jsqx='$jsqx',jstime='$jstime',jstjr='$jstjr' where jid='$jid'";
$upd=$conn->query($sqlu);
echo "<script type=\"text/javascript\"> window.location.href=document.referrer; </script>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>角色编辑</title>
<link rel="stylesheet" type="text/css" href="../layui-v2.6.7/layui/css/layui.css"/>
<script src="../layui-v2.6.7/layui/layui.js"></script>
</head>
<body>
<div style="width: 70%; margin: 10px auto; padding: 10px;">
<form id="form" method="post" class="layui-form"
<?php if($jid){
echo "action=\"jseditor.php?update=1&jid=$jid\"";
}
else{
echo "action=\"jseditor.php?ins=1\"";
}
?> >
角色名称:<input type="text" name="jsmc" <?php if($jid){ echo "value=\"".$rest['jsmc']."\" ";}?> class="layui-input" />
<br>
角色权限:<br>
<input <?php if($jid&&in_array('glygl',explode(',',$rest['jsqx'])) ){ echo "checked=\"checked\"";}?> type="checkbox" name="jsqx[]" title="管理员管理" value="glygl" />
<input <?php if($jid&&in_array('jsgl',explode(',',$rest['jsqx'])) ){ echo "checked=\"checked\"";}?> type="checkbox" name="jsqx[]" title="角色管理" value="jsgl" />
<input <?php if($jid&&in_array('lsgl',explode(',',$rest['jsqx'])) ){ echo "checked=\"checked\"";}?> type="checkbox" name="jsqx[]" title="教师管理" value="lsgl" />
<input <?php if($jid&&in_array('ttkgl',explode(',',$rest['jsqx'])) ){ echo "checked=\"checked\"";}?> type="checkbox" name="jsqx[]" title="调停课管理" value="ttkgl" />
<input <?php if($jid&&in_array('rzgl',explode(',',$rest['jsqx'])) ){ echo "checked=\"checked\"";}?> type="checkbox" name="jsqx[]" title="日志管理" value="rzgl" />
<input <?php if($jid&&in_array('gggl',explode(',',$rest['jsqx'])) ){ echo "checked=\"checked\"";}?> type="checkbox" name="jsqx[]" title="公告管理" value="gggl" />
<p></p>
<p></p>
<button type="submit" style="margin: 30px auto;" class="layui-btn layui-btn-normal">提交角色信息</button>
<script>
layui.use('form', function(){
var form = layui.form;
});
</script>
</form><?if($tj||$upd){?><span style="font-size: 14px; color: limegreen; ">角色编辑成功!</span><?}?><a href="js.php">返回列表</a>
</div>
</body>
</html>