首页 > 后端开发 > php教程 > 一个完整的php流程管理实例代码分享

一个完整的php流程管理实例代码分享

伊谢尔伦
发布: 2023-03-11 06:52:01
原创
3095 人浏览过

1. 添加新流程页面:

<div>
请选择流程节点:<br /><br />

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

$suser ="select * from users";
$auser = $db->Query($suser);

foreach($auser as $v)
{
    echo "<input class=&#39;rd&#39; type=&#39;radio&#39; name=&#39;user&#39; value=&#39;{$v[0]}&#39; /> {$v[2]}  ";
}

?>

</div>
<br />
<div><input type="button" value="添加节点" id="jiedian" /></div>
<br />

<div>
<?php
$attr = array();
if(!empty($_SESSION["user"]))
{
    $attr = $_SESSION["user"];
}

foreach($attr as $k=>$v)
{
    $sname = "select name from users where uid=&#39;{$v}&#39;";
    $name = $db->StrQuery($sname);
    
    echo "<div>{$k}--{$name}--<input type=&#39;button&#39; value=&#39;删除&#39; bs=&#39;{$k}&#39; class=&#39;shanchu&#39; /></div>";
}

?>
</div>
<br />
<div>
请输入流程名称:
<input type="text" id="name" />
</div>
<br />
<input type="button" value="保存" id="xinjian" />


<script type="text/javascript">
$("#jiedian").click(function(){
    
        //取选中的用户名
        var uid ="";
        var rd = $(".rd");
        for(var i=0;i<rd.length;i++)
        {
            if(rd.eq(i).prop("checked"))
            {
                uid = rd.eq(i).val();
            }
        }
        
        $.ajax({
                url:"chuli.php",
                data:{uid:uid,type:0},
                type:"POST",
                dataType:"TEXT",
                success: function(data){
                    window.location.href="add.php";
                }
            });
    
    })
    
$(".shanchu").click(function(){
        var sy = $(this).attr("bs");
        $.ajax({
                url:"chuli.php",
                data:{sy:sy,type:1},
                type:"POST",
                dataType:"TEXT",
                success: function(data){
                    window.location.href="add.php";
                }
            });
    })
$("#xinjian").click(function(){
        var name = $("#name").val();
        $.ajax({
                url:"chuli.php",
                data:{name:name,type:2},
                type:"POST",
                dataType:"TEXT",
                success: function(data){
                    window.location.href="add.php";
                }
            });
    })
</script>
登录后复制

2. 添加新流程(及其他)处理页面:

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

$type = $_POST["type"];

switch($type)
{
    case 0:
        $uid = $_POST["uid"];
        if(empty($_SESSION["user"]))
        {
            $_SESSION["user"] = array($uid);
        }
        else
        {
            $attr = $_SESSION["user"];
            $attr[] = $uid;
            $_SESSION["user"] = $attr;
        }
        break;
    case 1:
        $sy = $_POST["sy"];
        $attr = $_SESSION["user"];
        unset($attr[$sy]);
        $attr = array_values($attr);
        $_SESSION["user"] = $attr;
        break;
    case 2:
        $name = $_POST["name"];
        $code = time();
        $slc = "insert into liucheng values(&#39;{$code}&#39;,&#39;{$name}&#39;)";                  //liucheng 名字 代号
        $db->Query($slc,0);
        
        $attr = array();
        if(!empty($_SESSION["user"]))
        {
            $attr = $_SESSION["user"];
        }
        
        foreach($attr as $k=>$v)
        {
            $sfp = "insert into flowpath values(&#39;&#39;,&#39;{$code}&#39;,&#39;{$v}&#39;,&#39;{$k}&#39;)";         //flowpath  流程具体经过哪些人
            $db->Query($sfp,0);
        }
        
        break;
    case 3:
        $code = $_POST["code"];
        $nr = $_POST["nr"];
        $uid = $_SESSION["uid"];
        $rq = time();
        $sql = "insert into userflow values(&#39;&#39;,&#39;{$code}&#39;,&#39;{$uid}&#39;,&#39;{$nr}&#39;,0,&#39;{$rq}&#39;,0)";             //userflow 流程具体内容,名字,发起人
        $db->Query($sql,0);                                                                          //,内容,是否通过,事件,进行到哪一步
        break;
}
登录后复制

3. 登录后主页面:

<a href="faqi.php">发起流程</a>

<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("../DBDA.class.php");
    $db = new DBDA();
    
    $uid = $_SESSION["uid"];
    
    $sql = "select * from userflow";
    $attr = $db->Query($sql);
    
    foreach($attr as $v)
    {
        $v[1];//流程代号
        $v[6]; //流程走到哪了                                                                    
        
        //根据流程代号和当前登录者用户名查orders
        $szai="select count(*) from flowpath where code=&#39;{$v[1]}&#39; and uids=&#39;{$uid}&#39;";
        $n = $db->StrQuery($szai);
        
        //该人员在该流程下
        if($n>0)
        {
            $sorder = "select orders from flowpath where code=&#39;{$v[1]}&#39; and uids=&#39;{$uid}&#39;";
            $order = $db->StrQuery($sorder);
            
            if($v[6]>=$order)
            {
                $str = "";
                if($v[6]==$order)
                {
                    $str = "<a href=&#39;tongguo.php?ids={$v[0]}&#39;>通过</a>";
                }
                else
                {
                    $str = "<span style=&#39;color:green&#39;>已处理</span>";
                }
                echo "<tr><td>{$v[2]}</td>
        <td>{$v[5]}</td>
        <td>{$v[1]}</td>
        <td>{$v[3]}</td>
        <td>{$v[4]}</td>
        <td>{$str}</td></tr>";
            }
        }
    }
    
    ?>
    
</table>
登录后复制

4. 发起流程页面:

<h1>发起流程</h1>
<div>
请选择要发起的流程:
    <select id="sel">
        <?php
        include("../DBDA.class.php");
        $db = new DBDA();
        $sql = "select * from liucheng";
        $attr = $db->Query($sql);
        foreach($attr as $v)
        {
            echo "<option value=&#39;{$v[0]}&#39;>{$v[1]}</option>";
        }
        ?>
    </select>
</div>

<br />
<div>
请输入流程的详情:
<textarea id="xq"></textarea>

</div>

<br />
<input type="button" value="发起" id="btn" />

<script type="text/javascript">
$("#btn").click(function(){
        var code = $("#sel").val();
        var nr = $("#xq").val();
        $.ajax({
                url:"chuli.php",
                data:{code:code,nr:nr,type:3},
                type:"POST",
                dataType:"TEXT",
                success: function(data){
                    window.location.href="main.php";
                }
            });
    })
</script>
登录后复制

4. 判断发起的流程是否通过页面:

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

$ids = $_GET["ids"];

$sql = "update userflow set towhere = towhere+1 where ids=&#39;{$ids}&#39;";

$db->Query($sql,0);

$stw = "select code,towhere from userflow where ids=&#39;{$ids}&#39;";
$atw = $db->Query($stw);

$lcdaihao = $atw[0][0];
$towhere = $atw[0][1];

$jiedian = "select count(*) from flowpath where code=&#39;{$lcdaihao}&#39;";
$shuliang = $db->StrQuery($jiedian);

if($towhere>=$shuliang)
{
    $su = "update userflow set isok =1 where ids=&#39;{$ids}&#39; ";
    $db->Query($su,0);
}


header("location:main.php");
登录后复制

 

以上是一个完整的php流程管理实例代码分享的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板