• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP流程管理,堪比小小程序

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

这个流程管理是从用户登录界面开始,然后提交申请,页面逐级审核通过。这个做起来其实挺简单,只是在某些逻辑方面需要

好好考虑一下。

登录页面就不再多说了,如果要存session的话,我们可以建一个假的登录页面,只把uid存进session里面。

 

weilogin:假的登录页面

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<?php
session_start();
$_SESSION["uid"] = "zhangsan";
?>
</body>
</html>

新建流程页面,里面有选择节点人员,发起流程,等操作

xinjian.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="../jquery/jquery-1.11.2.min.js"></script>
</head>

<body>
<h1>新建流程</h1>

<div>
请选择节点人员:
<select >
	<?php
	session_start();
	include("../fengzhuang/DBDA.class.php");
	$db = new DBDA();
	
	$sql = "select * from users";
	$arr = $db->Query($sql);
	foreach($arr as $v)
	{
		echo "<option value='{$v[0]}'>{$v[2]}</option>";
	}
	?>
</select>
<input type="button" value="添加节点"  />
</div>
<br />
<div>
	<?php
	if(!empty($_SESSION["user"]))
	{
		$attr = $_SESSION["user"];
		foreach($attr as $k=>$v)
		{
			$sname = "select name from users where uid='{$v}'";
			$name = $db->StrQuery($sname);
			echo "<div>{$k}--{$name}--<input type='button' value='删除' key='{$k}' class='del' /></div>";
		}
	}
	?>
</div>
<br />
<div>请输入流程名称:<input type="text"  /></div>
<br />
<input type="button" value="保存"  />


</body>
<script type="text/javascript">
//添加节点按钮加点击
$("#add").click(function(){
		var uid = $("#user").val();
		$.ajax({
			url:"chuli.php",
			data:{uid:uid,type:0},
			type:"POST",
			dataType:"TEXT",
			success: function(data){
					window.location.href="xinjian.php";
				}
			});
	})
	
//给删除按钮加点击
$(".del").click(function(){
		var key = $(this).attr("key");
		$.ajax({
			url:"chuli.php",
			data:{key:key,type:1},
			type:"POST",
			dataType:"TEXT",
			success:function(data){
				window.location.href="xinjian.php";
				}
			});
	})
//给保存按钮加点击
$("#btn").click(function(){
		var name = $("#name").val();
		$.ajax({
			url:"chuli.php",
			data:{name:name,type:2},
			type:"POST",
			dataType:"TEXT",
			success:function(data){
					alert("保存成功!");
				}
			});
	})
</script>
</html>

 

 

 

 

他们的每种方法都被引用在了一个页面,用switch方法,

chuli.php

<?php
session_start();
include("../fengzhuang/DBDA.class.php");
$db = new DBDA();

$type = $_POST["type"];

switch($type)
{
	case 0:
		$uid = $_POST["uid"];
		if(empty($_SESSION["user"]))
		{
			$arr = array($uid);
			$_SESSION["user"] = $arr;
		}
		else
		{
			$arr = $_SESSION["user"];
			array_push($arr,$uid);
			$_SESSION["user"] = $arr;
		}
		break;
		
	case 1:
		$key = $_POST["key"];
		$arr = $_SESSION["user"];
		unset($arr[$key]); //删除
		$arr = array_values($arr); //重新索引
		$_SESSION["user"] = $arr;
		break;
		
	case 2:
		$name = $_POST["name"];
		$code = time();
		//添加流程
		$sql = "insert into liucheng values('{$code}','{$name}')";
		$db->Query($sql,0);
		//添加流程节点
		$arr = $_SESSION["user"];
		foreach($arr as $k=>$v)//获取索引
		{
			$sql = "insert into flowpath values('','{$code}','{$v}','{$k}')";
			$db->Query($sql,0);
		}
		break;
		
	case 3: //用户发起流程
		$code = $_POST["code"];
		$nr = $_POST["content"];
		$uid = $_SESSION["uid"];
		$time = date("Y-m-d H:i:s");
		$sql = "insert into userflow values('','{$code}','{$uid}','{$nr}',0,'{$time}',0)";
		$db->Query($sql,0);
		break;
		
}

然后是发起流程环节,

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title><br />
<script src="../jquery/jquery-1.11.2.min.js"></script>

</head>

<body>

<h1>发起流程</h1>

<div>
请选择发起的流程:
	<select >
    	<?php
		session_start();
		include("../fengzhuang/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>
<br />
<div>
请输入内容:
	<textarea ></textarea>
</div>
<br />
<input type="button" value="发起"  />


</body>
<script type="text/javascript">
$("#btn").click(function(){
		var code = $("#liucheng").val();
		var content = $("#nr").val();
		
		$.ajax({
			url:"chuli.php",
			data:{code:code,content:content,type:3},
			type:"POST",
			dataType:"TEXT",
			success: function(data){
				alert("发起成功!");
				}			
			});
	})
</script>
</html>

 

 

 

 

紧接着是审核页面,这个需要判断流程走到哪个登录者,流程代号,流程走到哪,和该人员在流程中的次序。shenhe.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<h1>审核页面</h1>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
	<tr>
    	<td>流程代号</td>
        <td>发起者</td>
        <td>发起内容</td>
        <td>是否结束</td>
        <td>发起时间</td>
        <td>操作</td> 
    </tr>

	<?php
	session_start();
	include("../fengzhuang/DBDA.class.php");
	$db = new DBDA();
	$uid = $_SESSION["uid"];
	echo $uid;
	//查找登录者参与的所有流程
	$sql = "select * from userflow where code in(select code from flowpath where uids='{$uid}')";
	$arr = $db->Query($sql);
	
	//显示
	foreach($arr as $v)
	{
		//判断该流程走到登录者
		$lcdh = $v[1]; //流程代号
		$towhere = $v[6];//流程走到哪
		$sql = "select orders from flowpath where code='{$lcdh}' and uids='{$uid}'";
		$order = $db->StrQuery($sql);//该人员在流程中的次序
		
		if($towhere>=$order)
		{
			$caozuo = "";
			if($towhere==$order)
			{
				$caozuo="<a href='tongguo.php?code={$v[0]}'>通过</a>";
			}
			else
			{
				$caozuo="<span style='background-color:green;color:white'>已通过</span>";
			}
			echo "<tr>
    	<td>{$v[1]}</td>
        <td>{$v[2]}</td>
        <td>{$v[3]}</td>
        <td>{$v[4]}</td>
        <td>{$v[5]}</td>
        <td>{$caozuo}</td> 
    </tr>";
		}
		
	}

    
    ?>
</table>
</body>
</html>

 

 

最后我们要通过了处理了....tongguo.php

<?php
session_start();
include("../fengzhuang/DBDA.class.php");
$db = new DBDA();

//流程往下走
$code = $_GET["code"];
$sql = "update userflow set towhere=towhere+1 where ids='{$code}'";
$db->Query($sql,0);

//判断流程是否结束
$sql = "select * from userflow where ids='{$code}'";
$arr = $db->Query($sql);

$lcdh = $arr[0][1]; //流程代号
$tw = $arr[0][6]; //流程走到哪

$sql = "select count(*) from flowpath where code='{$lcdh}'";
$count = $db->StrQuery($sql); //该流程节点人数
if($tw>=$count)
{
$sql = "update userflow set isok=1 where ids='{$code}'";
$db->Query($sql,0);
}


header("location:shenhe.php");

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap