一、登录页面
css样式
@charset "utf-8";
*{
margin:0px auto;
padding:0px;
}
#login{
background-color:#0CF;
width:30%;
height:200px;
margin-top:50px;
border:5px double #060;
}
#dl{
color:#00F;
background-color:#9FF;
height:30px;
text-indent:10px;
vertical-align:bottom;
line-height:30px;
}
#pwd{
background-color:#CFF;
height:70px;
}
#sb{
background-color:#060;
width:200px;
height:30px;
color:#CFF;
margin-top:3px;
} /* CSS Document */
布局
<body>
<form method="post" action="dengluchuli.php">
<div id="login">
<div align="left" id="dl">登录页面</div><br />
<div id="yhm" align="center">用户名:
<input type="text" placeholder="请输入用户名" name="uid"/></div><br />
<div id="pwd" align="center">密 码:
<input type="password" placeholder="请输入密码" name="pwd"/></div>
<div align="center"><input type="submit" value="登录" id="sb"/></div>
</div>
</form>
</body>
二、主页面
<body>
<?php
session_start();
if(empty($_SESSION["uid"])){
header("location:denglu.php");
exit;
}
?>
<div>
<div><a href="faqi.php">发起流程</a></div><br>
<div><a href="shenhe.php">流程审核</a></div>
</div>
</body>
发起流程
css样式
*{
margin:0px auto;
padding:0px;
}
#wai{
width:40%;
border:#00F inset 1px;
}
#tm{
background-color:#060;
color:#CFF;
font-size:30px;
text-align:center;
height:60px;
vertical-align:bottom;
line-height:85px;
font-weight:bold;
}
#xl{
height:60px;
color:#060;
font-weight:bold;
vertical-align:middle;
line-height:60px;
}
select,textarea{
width:200px;
height:35px;
font-size:18px;
font-weight:bold;
background-color:#060;
color:#FFF;
}
textarea{
width:100%;
height:60px;
}
#bt{
height:40px;
text-align:center;
}
input{
width:100px;
height:35px;
background-color:#090;
color:#FFF;
}
布局
<body>
<form action="faqichuli.php" method="post">
<div id="wai">
<div id="tm">发 起 流 程</div>
<div id="xl">
选择要发起的流程:
<select name="liucheng">
<?php
require_once "../DBDA.class.php";
$db = new DBDA();
$sql = "select * from liucheng";
$arr = $db->query($sql);
foreach($arr as $v){
echo"<option value='{$v[0]}'>{$v[1]}</option>";
}
?>
</select>
</div>
<div id="tt">
<textarea name="neirong" placeholder="请输入内容"></textarea>
</div>
<div id="bt">
<input type="submit" value="发起" />
</div>
</div>
</form>
</body>
处理页
<?php
session_start();
require_once "../DBDA.class.php";
$db = new DBDA();
$uid = $_SESSION["uid"];
$liucheng = $_POST["liucheng"];
$neirong = $_POST["neirong"];
$t = date("Y-m-d H:i:s");
$sql = "insert into userflow values(0,'{$liucheng}','{$uid}','{$neirong}',0,'{$t}',0)";
if($db->query($sql,1)){
header("location:main.php");
}
审核页
css样式
@charset "utf-8";
/* CSS Document */
*{
margin:0px auto;
padding:0px;
}
#tt{
background-color:#060;
color:#CFF;
width:100%;
height:60px;
font-size:30px;
text-align:center;
vertical-align:bottom;
line-height:85px;
}
#b{
text-align:center;
}
#bt{
background-color:#099;
color:#CFF;
}
布局页
<body>
<div>
<div id="tt">流 程 审 核</div>
<div id="b">
<table width="100%" border="1" bordercolor="#0000FF">
<tr id="bt">
<td>流程代号</td>
<td>发起者</td>
<td>内容</td>
<td>是否结束</td>
<td>发起时间</td>
<td>操作</td>
</tr>
<?php
session_start();
require_once "../DBDA.class.php";
$db = new DBDA();
$uid = $_SESSION["uid"];
$sql = "select * from userflow a where towhere>=(select b.orders from flowpath b where b.uids='{$uid}' and b.code=a.code)";
$arr = $db->query($sql);
foreach($arr as $v){
$cz = "<span style='color:green'>已通过</span>";
$sql = "select orders from flowpath where code='{$v[1]}' and uids='{$uid}'";
$order = $db->strquery($sql);
if($order==$v[6]){
$cz="<a href=\"tongguo.php?code={$v[0]}\">通过</a>";
}
echo "<tr>
<td>{$v[1]}</td>
<td>{$v[2]}</td>
<td>{$v[3]}</td>
<td>{$v[4]}</td>
<td>{$v[5]}</td>
<td>{$cz}</td>
</tr>";
}
?>
</table>
</div>
</div>
</body>
处理页
<?php
session_start();
require_once "../DBDA.class.php";
$db = new DBDA();
$code = $_GET["code"];
$sql = "update userflow set towhere=towhere+1 where ids='{$code}'";
$db->query($sql,1);
//判断流程是否结束
$sql = "select towhere from userflow where ids='{$code}'";
$towhere = $db->strquery($sql);
$sql = "select count(*) from flowpath where code=(select code from userflow where ids='{$code}')";
$count = $db->strquery($sql);
if($towhere>=$count){
$sql = "update userflow set isok=1 where ids='{$code}'";
$db->query($sql,1);
}
header("location:shenhe.php");
DBDA.class.php
<?php
class DBDA{
public $host="localhost"; //服务器地址
public $uid="root"; //用户名
public $pwd="123"; //密码
public $dbname="crud"; //数据库名称
/*
执行一条SQL语句的方法
@param sql 要执行的SQL语句
@param type SQL语句的类型,0代表查询 1代表增删改
@return 如果是查询语句返回二维数组,如果是增删改返回true或false
*/
public function query($sql,$type=0){
$db = new MySQLi($this->host,$this->uid,$this->pwd,$this->dbname);
$result = $db->query($sql);
if($type){
return $result;
}else{
return $result->fetch_all();
}
}
public function strquery($sql,$type=0){
$db = new MySQLi($this->host,$this->uid,$this->pwd,$this->dbname);
$result = $db->query($sql);
if($type){
return $result;
}else{
$arr = $result->fetch_all();
$str = "";
foreach($arr as $v){
$str .= implode("^",$v)."|";
}
$str = substr($str,0,strlen($str)-1);
return $str;
}
}
//返回json数据的方法
public function jsonquery($sql,$type=0){
$db = new MySQLi($this->host,$this->uid,$this->pwd,$this->dbname);
$result = $db->query($sql);
if($type){
return $result;
}else{
$arr = $result->fetch_all(MYSQLI_ASSOC);//关联数组
return json_encode($arr);//转换json
//json_decode()分解json
}
}
}