• 流程处理(一)


    流程:先登录用户名,进入主页面,新建一个流程,发起一个流程,对以发起的流程审核

    登录页面:

    <!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>
    <form action="dlchuli.php" method="post">
    <div>用户名:<input type="text" name="uid"/></div>
    <div>密码:<input type="text" name="pwd"/></div>
    <input type="submit" value="登录" />
    </form>
    </body>
    </html>
    View Code

    登录处理:

    <?php
        session_start();
        include("../mydbda.php");
        $db = new mydbda();
        
        $uid = $_POST["uid"];
        $pwd = $_POST["pwd"];
        
        $sql = "select count(*) from Users where Uid = '{$uid}' and Pwd = '{$pwd}'";
        $str = $db->Select($sql,"CX","mydb");
        
        if($str == "1")
        {
            $_SESSION["uid"] = $uid;
            header("Location:faqi.php");
        }
        else
        {
            header("Location:denglu.php");
        }
        
    View Code

    新建流程:

    <?php
        session_start();
    ?>
    <!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-1.11.2.min.js"></script>
    </head>
    
    <body>
    <h1>新建流程</h1>
    <div>输入流程名:
        <input type="text" id="liucheng"/>
    </div><br />
    
    <div>请选择节点人员:</div><br />
    <div>
        <?php
            include("../mydbda.php");
            $db = new mydbda();
            $sqlj = "select * from Users";
            $strj = $db->Select($sqlj,"CX","mydb");
            $hangj = explode("|",$strj);
            for($i=0;$i<count($hangj);$i++)
            {
                list($uid,$pwd,$name) = explode("^",$hangj[$i]);
                echo "<input type='radio' value='{$uid}' class='ry' name='ry'/>{$name}&nbsp;";
            }
        ?>
    </div><br />
    <input type="button" value="添加节点" id="sure" />
    <br /><br />
    <div id="biao">
        <?php
            if(isset($_SESSION["liucheng"]))
            {
                $attr = $_SESSION["liucheng"];
                
                for($i=0;$i<count($attr);$i++)
                {
                    $sqlu = "select Name from Users where Uid = '".$attr[$i]."'";
                    $stru = $db->Select($sqlu,"CX","mydb");
                    echo "<div class='jd' bs='".$attr[$i]."'>{$i}.{$stru}--<input type='button' class='delete' bs='".$i."' value='删除'/></div>";
                }
            }
            else
            {
                echo "当前流程节点为空!";
            }
        ?>
    </div><br />
    <input type="button" value="确定" id="add" />
    <br />
    
    </body><br />
    <script type="text/javascript">
    $(document).ready(function(e) {
        
        //添加节点
        $("#sure").click(function(){
                var user = $(".ry");
                for(var i=0; i<user.length;i++)
                {
                    if(user.eq(i)[0].checked == true)
                    {
                        var uid = user.eq(i).val();
                        
                        $.ajax({
                            
                                url:"chulilc.php",
                                data:{uid:uid},
                                type:"POST",
                                dataType:"TEXT",
                                success: function(data){
                                        window.location = "test.php";
                                    }
                            
                            });
                    }
                }
            
            })
            
        //删除节点
        $(".delete").click(function(){
            
            var ids = $(this).attr("bs");
            
            $.ajax({
                            
                    url:"chulisc.php",
                    data:{ids:ids},
                    type:"POST",
                    dataType:"TEXT",
                    success: function(data){
                            window.location = "test.php";
                        }
                
                });
            
            })
            
        //添加流程
        $("#add").click(function(){
                
                var name = $("#liucheng").val();
                
                $.ajax({
                    
                    url:"add.php",
                    data:{name:name},
                    type:"POST",
                    dataType:"TEXT",
                    success: function(data){
                            if(data=="OK")
                            {
                                alert("添加成功!");
                            }
                            else
                            {
                                alert("添加失败!");
                            }
                        
                        }
                    
                    });
            
            })
        
    });
    </script>
    </html>
    View Code

    添加节点处理页面:

    <?php
        session_start();
        
        $uid = $_POST["uid"];
        
        if(isset($_SESSION["liucheng"]))
        {
            $shuzu = $_SESSION["liucheng"];
            array_push($shuzu,$uid);
            $_SESSION["liucheng"] = $shuzu;
        }
        else
        {
            $shuzu = array();
            array_push($shuzu,$uid);
            $_SESSION["liucheng"] = $shuzu;
        }
    
        
    ?>
    View Code

    删除节点处理

    <?php
        session_start();
        
        $ids = $_POST["ids"];
    
        $shuzu = $_SESSION["liucheng"];
        unset($shuzu[$ids]); //删除元素
        $shuzu = array_values($shuzu); //重新索引
        $_SESSION["liucheng"] = $shuzu;
    
    ?>
    View Code

    添加流程处理:

    <?php
        session_start();
        
        include("../mydbda.php");
        
        $db = new mydbda();
        
        $name = $_POST["name"];
        
        $code = date("YmdHisms",time());
        
        $sqll = "insert into LiuCheng values('{$code}','{$name}')";
        $db->Select($sqll,"QT","mydb");
        
        $attr = $_SESSION["liucheng"];
        
        for($i=0;$i<count($attr);$i++)
        {
            $sqlj = "insert into FlowPath values('','{$code}','{$attr[$i]}','{$i}')";
            $db->Select($sqlj,"QT","mydb");
        }
        echo "OK";
    View Code

    发起流程:

    <?php
        session_start();
    ?>
    <!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-1.11.2.min.js"></script>
    </head>
    
    <body>
    <h1>发起流程</h1>
    <div>请选择流程:
    <select id="lc">
    <?php
    
        include("../mydbda.php");
        $db = new mydbda();
        
        $sql = "select * from LiuCheng";
        $str = $db->Select($sql,"CX","mydb");
        $hang = explode("|",$str);
        for($i=0;$i<count($hang);$i++)
        {
            list($code,$name) = explode("^",$hang[$i]);
            
            echo "<option value='{$code}'>{$name}</option>";
        }
        
    ?>
    </select>
    </div>
    <br />
    <div>
        <div>请输入流程内容:</div><br />
        <div>
            <textarea id="nr" style="400px; height:250px"></textarea>
        </div>
    </div>
    <br />
    <input type="button"  value="确定" id="btn"/>
    <a href="chuliliucheng.php">处理</a>
    </body>
    <script type="text/javascript">
    $(document).ready(function(e) {
        $("#btn").click(function(){
            
            var code = $("#lc").val();
            var nr = $("#nr").val();
            
            $.ajax({
                
                    url:"faqichuli.php",
                    data:{code:code,nr:nr},
                    type:"POST",
                    dataType:"TEXT",
                    success: function(data){
                        
                            if(data == "OK")
                            {
                                alert("发起成功!");
                            }
                            else
                            {
                                alert("发起失败!");
                            }
                        
                        }
                
                });
            
            })
    });
    </script>
    </html>
    View Code

    发起处理:

    <?php
        session_start();
        
        include("../mydbda.php");
        $db = new mydbda();
        
        $code = $_POST["code"];
        $nr = $_POST["nr"];
        
        $uid = $_SESSION["uid"];
        $riqi = date("Y-m-d H:i:s",time());
        
        $sql = "insert into UserFlow values('','{$code}','{$uid}','{$nr}',false,'{$riqi}',0)";
        $str = $db->Select($sql,"QT","mydb");
        echo $str;
    View Code

    操作流程:

    <?php
        session_start();
    ?>
    <!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
            $uid = $_SESSION["uid"];
            
            include("../mydbda.php");
            $db = new mydbda();
            
            $sql = "select * from UserFlow";
            
            $str = $db->Select($sql,"CX","mydb");
            
            $hang = explode("|",$str);
            for($i=0;$i<count($hang);$i++)
            {
                list($ids,$code,$uids,$nr,$isok,$riqi,$towhere) = explode("^",$hang[$i]);
                
                $sqlj = "select * from FlowPath where Code = '{$code}'";
                $strj = $db->Select($sqlj,"CX","mydb");
                $hangj = explode("|",$strj);
                $bs = false;
                $bscl = false;
                for($j=0;$j<count($hangj);$j++)
                {
                    list($idsj,$codej,$uidj,$orderj) = explode("^",$hangj[$j]);
                    
                    if(($uidj == $uid) and ($orderj <= $towhere))
                    {
                        
                        $bs= true;
                    }
                    if(($uidj == $uid) and ($orderj == $towhere))
                    {
                        
                        $bscl= true;
                    }
                }
                
                //处理流程名
                $sqllc = "select Name from LiuCheng where Code = '{$code}'";
                $lcname = $db->Select($sqllc,"CX","mydb");
                //处理发起者名
                $sqlfq = "select Name from Users where Uid = '{$uids}'";
                $fqname = $db->Select($sqlfq,"CX","mydb");
                //处理是否结束
                $jieshu = $isok?"<span style='background-color:green'>已结束</span>":"<span style='background-color:red'>进行中</span>";
                //处理操作
                $caozuo = $bscl?"<a href='tongguo.php?code=".$ids."'>通过</a>":"<span style='background-color:gray'>已通过</span>";
                if($bs)
                {
                    echo "<tr><td>{$lcname}</td><td>{$fqname}</td><td>{$nr}</td><td>{$jieshu}</td><td>{$riqi}</td><td>{$caozuo}</td></tr>";
                }
            }
        ?>
        
    </table>
    </body>
    </html>
    View Code

    处理通过流程:

    <?php
    include("../mydbda.php");
    $db = new mydbda();
    
    $code = $_GET["code"];
    //通过,流程指向下一个人
    $sql = "update UserFlow set ToWhere = ToWhere+1 where Ids = '{$code}' ";
    
    $db->Select($sql,"QT","mydb");
    //查询流程走到哪了
    $sqlt = "select Code,ToWhere from UserFlow where Ids = '{$code}'";
    $strtw = $db->Select($sqlt,"CX","mydb");
    list($lccode,$tw) = explode("^",$strtw);
    //查询该流程下节点数量
    $sqlf = "select count(*) from FlowPath where Code = '{$lccode}'";
    $zs = $db->Select($sqlf,"CX","mydb");
    //判断是否走完流程
    if($tw >= $zs)
    {
        $sqlx = "update UserFlow set IsOk = true where Ids = '{$code}' ";
    
        $db->Select($sqlx,"QT","mydb");
    }
    
    
    header("Location:chuliliucheng.php");
    View Code
  • 相关阅读:
    MyEclipse Ctrl+F搜索框太小
    SqlServer2012评估期已过问题
    $("#form_iframe").contents().find('.nav-tabs').children().eq(2).hide();
    数字格式化
    equals和==的区别
    静态代码块
    this调用有参构造方法
    正则表达式
    日期和时间字符串格式化
    Legacy autograd function with non-static forward method is deprecated and will be removed in 1.3.
  • 原文地址:https://www.cnblogs.com/sjxx/p/5444143.html
Copyright © 2020-2023  润新知