zoukankan      html  css  js  c++  java
  • PHP 流程

    登录页面

    <body>
    <form action="loginchuli.php" method="post">
        <div>用户名:<input type="text" name="uid" /></div>
        <div>密码:<input type="text" name="pwd" /></div>
        <input type="submit" value="登录" />
    </form>
    </body>
    </html>





     登录处理页面
    <?php
    session_start();
    $uid = $_POST["uid"];
    $pwd = $_POST["pwd"];
    
    include("../DBDA.php");
    $db = new DBDA();
    
    $sql = "select count(*) from Users where Uid='{$uid}' and Pwd = '{$pwd}'";
    
    $z = $db->StrQuery($sql);
    
    if($z == 1)
    {
        $_SESSION["uid"] = $uid;
        header("location:main.php");
    }
    else
    {
        header("location:login.php");
    }







    主页面

    <head>
    <?php
    session_start();
    
    if(empty($_SESSION["uid"]))
    {
        header("location:login.php");
        exit;
    }
    $uid = $_SESSION["uid"];
    
    include("../DBDA.php");
    $db = new DBDA();
    ?>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <style type="text/css">
    #menu
    {
        100%;
        height:30px;
    }
    .z
    {
        100px;
        height:30px;
        float:left;
    }
    </style>
    
    </head>
    
    <body>
    <br />
    <br />
    <center><h1>主页面</h1></center>
    <br />
    
    <div id="menu">
        <div class='z'><a href="xinjian.php">新建流程</a></div>
        <div class="z"><a href="faqi.php">发起流程</a></div>
        <div class="z"><a href="shenhe.php">审核流程</a></div>
    </div>
    
    </body>
    </html>






    新建流程页面


    <script src="../jquery-1.11.2.min.js"></script>
    </head>
    
    <body>
    <?php
    session_start();
    
    include("../DBDA.php");
    $db = new DBDA();
    
    $attr = array();
    if(!empty($_SESSION["jiedian"]))
    {
        $attr = $_SESSION["jiedian"];
    }
    
    ?>
    <h1>新建流程</h1>
    <div>
        请选择节点人员:
        <?php
        $sry = "select * from Users";
        $ary = $db->Query($sry);
        
        foreach($ary as $v)
        {
            echo "<input name='ry' class='ry' type='radio' value='{$v[0]}' /> {$v[2]}";
        }
        
        ?>
    </div>
    <br />
    <div>
        <input type="button" value="添加节点" id="tjjd" />
    </div>
    <br />
    <div>
    <?php
        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='删除' bs='{$k}' class='sc' /></div>";
        }
    ?>
    </div>
    <br />
    <div>
        请输入流程名称:
        <input type="text" id="mc" />
    </div>
    <br />
    <div>
        <input type="button" value="添加" id="add" />
    </div>
    <a href="main.php">返回</a>
    </body>
    <script type="text/javascript">
    $(document).ready(function(e) {
        //设置默认选中第一项
        $(".ry").eq(0).prop("checked",true);
        
        //添加节点按钮点击事件
        $("#tjjd").click(function(){
            
            var rd = $(".ry");
            //取选中的用户名
            var uid = "";
            for(var i=0;i<rd.length;i++)
            {
                if(rd.eq(i).prop("checked"))
                {
                    uid = rd.eq(i).val();
                }
            }
            
            $.ajax({
                url:"tjjd.php",
                data:{uid:uid},
                type:"POST",
                dataType:"TEXT",
                success: function(data){
                        window.location = "xinjian.php";
                    }
                
                });
            
            })
        //删除节点按钮事件
        $(".sc").click(function(){
            
            var id = $(this).attr("bs");
            $.ajax({
                url:"scjd.php",
                data:{id:id},
                type:"POST",
                dataType:"TEXT",
                success: function(data){
                        window.location = "xinjian.php";
                    }
                
                });
            
            })
        //添加流程按钮
        $("#add").click(function(){
            
            var name = $("#mc").val();
            $.ajax({
                url:"tjlc.php",
                data:{name:name},
                type:"POST",
                dataType:"TEXT",
                success: function(data){
                        if(data.trim()=="OK")
                        {
                            alert("添加成功");
                        }
                        else
                        {
                            alert("添加失败!");
                        }
                    }
                
                });
            
            })
            
        
    });
    </script>
    </html>











    添加节点页面


    <?php
    session_start();
    
    $uid = $_POST["uid"];
    
    if(empty($_SESSION["jiedian"]))
    {
        $attr = array($uid);
        $_SESSION["jiedian"] = $attr;
    }
    else
    {
        $attr = $_SESSION["jiedian"];
        array_push($attr,$uid);
        $_SESSION["jiedian"] = $attr;
    }






    删除节点页面


    <?php
    session_start();
    
    $id = $_POST["id"];
    $attr = $_SESSION["jiedian"];
    unset($attr[$id]);
    $attr = array_values($attr);
    
    $_SESSION["jiedian"] = $attr;








    添加流程页面

    <?php
    session_start();
    
    include("../DBDA.php");
    $db = new DBDA();
    
    $attr = array();
    if(!empty($_SESSION["jiedian"]))
    {
        $attr = $_SESSION["jiedian"];
    }
    
    $name = $_POST["name"];
    
    //向流程表添加数据
    $code = date("YmdHis");
    $slc = "insert into LiuCheng values('{$code}','{$name}')";
    //判断是否执行成功的变量
    $isok = true;
    if($db->Query($slc,0))
    {
        foreach($attr as $k=>$v)
        {
            //向流程对应节点表添加数据
            $sfl = "insert into FlowPath values('','{$code}','{$v}',{$k})";
            $isok = $isok && $db->Query($sfl,0);
        }
    }
    if($isok)
    {
        echo "OK";
    }
    else
    {
        echo "NO";
    }







    发起流程页面


    <script src="../jquery-1.11.2.min.js"></script>
    </head>
    
    <body>
    <?php
    include("../DBDA.php");
    $db = new DBDA();
    ?>
    <h1>发起流程</h1>
    <div>
        请选择流程:
        <select id="lc">
        <?php
            $sql = "select * from LiuCheng";
            $attr = $db->Query($sql);
            
            foreach($attr as $v)
            {
                echo "<option value='{$v[0]}'>{$v[1]}</option>";
            }
        ?>
        </select>
    </div>
    <br />
    <div>
        请输入内容:
        <textarea style="300px; height:200px" id="nr">
        </textarea>
    </div>
    <br />
    <div>
        <input type="button" value="发起" id="fq" />
    </div>
    <a href="main.php">返回</a>
    </body>
    <script type="text/javascript">
    $(document).ready(function(e) {
        $("#fq").click(function(){
            
            var code = $("#lc").val();
            var nr = $("#nr").val();
            
            $.ajax({
                url:"fqcl.php",
                data:{code:code,nr:nr},
                type:"POST",
                dataType:"TEXT",
                success: function(data){
                        if(data.trim()=="OK")
                        {
                            alert("发起成功");
                        }
                        else
                        {
                            alert("发起失败!");
                        }
                    }
                
                });
            
            })
    });
    </script>
    </html>






    发起处理页面


    <?php
    session_start();
    
    include("../DBDA.php");
    $db = new DBDA();
    
    $code = $_POST["code"];
    $nr = $_POST["nr"];
    $uid = $_SESSION["uid"];
    $rq = date("Y-m-d H:i:s");
    
    $sql = "insert into UserFlow values('','{$code}','{$uid}','{$nr}',false,'{$rq}',0)";
    
    if($db->Query($sql,0))
    {
        echo "OK";
    }
    else
    {
        echo "NO";
    }
     
     
     
     
    审核流程页面
     
    <?php
    session_start();
    
    include("../DBDA.php");
    $db = new DBDA();
    
    $uid = $_SESSION["uid"];
    
    ?>
    <body>
    <h1>审核流程</h1>
    <br />
    <table width="100%" border="1" cellspacing="0" cellpadding="0">
        <tr bgcolor="#3399FF" style="color:white">
            <td>流程名称</td>
            <td>发起者</td>
            <td>内容</td>
            <td>是否结束</td>
            <td>发起时间</td>
            <td>操作</td>
        </tr>
        <?php
        
        /*$sfl = "select Code,Orders from FlowPath where Uids = '{$uid}'";
        $afl = $db->Query($sfl);
        
        foreach($afl as $v)
        {
            $suf = "select * from UserFlow where Code='{$v[0]}' and ToWhere >= {$v[1]}";
            
            $auf = $db->Query($suf);
            foreach($auf as $v1)
            {
                echo "<tr>
                <td>{$v1[1]}</td>
                <td>{$v1[2]}</td>
                <td>{$v1[3]}</td>
                <td>{$v1[4]}</td>
                <td>{$v1[5]}</td>
                <td>操作</td>
                </tr>";
            }    
        }*/
        
        $suf = "select * from UserFlow order by RiQi desc";
        $auf = $db->Query($suf);
        
        foreach($auf as $v)
        {
            //$v[1]流程代号
            //$v[6]流程到哪
            
            //根据流程代号到flowpath表查该登录者在该流程中的次序
            $sfp = "select Code,Orders from FlowPath where Code='{$v[1]}' and Uids='{$uid}'";
            $cx = $db->Query($sfp);
            if($cx)
            {
                $ucode = $cx[0][0];//流程代号
                $ucx = $cx[0][1];//次序        
                //判断该流程是否走到了该用户
                if($v[1]==$ucode && $v[6]>=$ucx)
                {
                    $lname = Lname($db,$v[1]);
                    $fname = Fname($db,$v[2]);
                    //处理是否结束
                    $isok = $v[4]?"<span style='已结束</span>":"<span style='background-color:green'>处理中</span>";
                    //处理操作
                    $chuli = "";
                    if($v[6]==$ucx)
                    {
                        $chuli="<a href='sh.php?id={$v[0]}'>审核</a>";
                    }
                    else
                    {
                        $chuli = "<span style='color:green'>已通过</span>";
                    }
                    
                    echo "<tr>
                    <td>{$lname}</td>
                    <td>{$fname}</td>
                    <td>{$v[3]}</td>
                    <td>{$isok}</td>
                    <td>{$v[5]}</td>
                    <td>{$chuli}</td>
                    </tr>";
                }
            }
            
        }
        //处理流程名
        function Lname($db,$code)
        {
            $sql = "select Name from LiuCheng where Code = '{$code}'";
            return $db->StrQuery($sql);
        }
        //处理发起者名
        function Fname($db,$uid)
        {
            $sql = "select Name from Users where Uid = '{$uid}'";
            return $db->StrQuery($sql);
        }
        
        
        ?>
    </table>
    </body>
    </html>








    审核流程处理页面



    <?php
    include("../DBDA.php");
    $db = new DBDA();
    
    $id = $_GET["id"];
    
    $sql = "update UserFlow set ToWhere = ToWhere+1 where Ids='{$id}'";
    
    if($db->Query($sql,0))
    {
        //查询流程走到哪了
        $stw = "select Code,ToWhere from UserFlow where Ids='{$id}'";
        $atw = $db->Query($stw);
        $code = $atw[0][0];//流程代号
        $tw = $atw[0][1];//流程到哪了
        
        //查询该流程下的节点数
        $sfp = "select count(*) from FlowPath where Code = '{$code}'";
        $sl = $db->StrQuery($sfp);
        
        //如果流程走到位置大于等于了该流程中节点的总数
        if($tw>=$sl)
        {
            $sok = "update UserFlow set IsOk = true where Ids='{$id}'";
            $db->Query($sok,0);
        }
        
        header("location:shenhe.php");
    }
    else
    {
        echo "审核失败!";
    }






  • 相关阅读:
    思维探索者:理解了才是真正的学习 理解会带来巨大的好处
    思维探索者:让记忆与学习更有效率 别在别人的思考中得意着
    思维探索者:从问题到答案的思维过程 像侦探一样思考
    android-HttpClient上传信息(包括图片)到服务端
    java web每天定时执行任务
    基础总结篇之一:Activity生命周期
    Spring面试题一
    J2EE用监听器实现同一用户只能有一个在线
    notepad++快捷键大全
    python for循环巧妙运用(迭代、列表生成式)
  • 原文地址:https://www.cnblogs.com/kevin2016/p/5559463.html
Copyright © 2011-2022 走看看