流程(0529)

流  程:

 一、

登录页面:login.php

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5 <style>
 6 #dl{
 7     width:300px;
 8     height:400px;
 9     margin-left:500px;    
10     }
11 
12 </style>
13 <title>登录</title>
14 </head>
15 
16 <body>
17 <br />
18 <div id="dl">
19     <h1>登录页面</h1>
20 <br />
21 <form action="loginchu.php" method="post">
22     <div>用户名:<input type="text" name="uid" /></div><br /><br />
23     <div>密&nbsp;&nbsp;码:<input type="text" name="psw" /></div><br /> <br />
24     <div><input type="submit" value="登录" /></div>
25 </form>
26 </div>
27 </body>
28 </html>
View Code

登录页面处理:loginchu.php

 1 <?php
 2 session_start();
 3 include("../DBDA.class.php");
 4 $db=new DBDA();
 5 
 6 $uid=$_POST["uid"];
 7 $psw=$_POST["psw"];
 8 
 9 $sql="select count(*) from users where username='{$uid}' and password='{$psw}'";
10 $r=$db->StrQuery($sql);
11 
12 if($r==1)
13 {
14     $_SESSION["uid"]=$uid;
15     header("location:main.php");    
16     }
17 else
18 {
19     header("location:login.php");
20     }
View Code

运行登录页面:

二、

新建流程主页面:xjlc.php

  1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2 <html xmlns="http://www.w3.org/1999/xhtml">
  3 <head>
  4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5 <title>新建流程</title>
  6 <script src="../jquery-1.11.2.min.js"></script>
  7 <style type="text/css">
  8 #aa{
  9     
 10     width:500px;
 11     height:500px;
 12     margin:10px 100px 0px 300px;}
 13 
 14 </style>
 15 
 16 </head>
 17 
 18 <body>
 19 <br />
 20 <?php
 21 session_start();
 22 include("../DBDA.class.php");
 23 $db=new DBDA();
 24 //获取添加的节点
 25 $attr=array();
 26 if(!empty($_SESSION["jiedian"]))
 27 {
 28     $attr=$_SESSION["jiedian"];
 29 }
 30 ?>
 31 
 32 <div id="aa">
 33 <h1>新建流程</h1><br />
 34 <!--选择节点人员 -->
 35 <div>请选择节点人员:
 36     <?php
 37     $sql="select * from users";
 38     $ary=$db->Query($sql);
 39     foreach($ary as $v)
 40     { 
 41         echo "<input type='radio' value='{$v[0]}' name='ry' class='ry' />{$v[2]}&nbsp;&nbsp;";
 42     }
 43     ?>
 44 </div><br />
 45 
 46 <!--添加节点 -->
 47 <div>
 48     <input type="button" id="tianjia" value="添加节点" />
 49 </div><br />
 50 
 51 <div>    
 52     <?php
 53     if(is_array($attr))
 54     {  
 55         foreach($attr as $k=>$v)
 56         {
 57             $sname="select Name from Users where username='{$v}'";
 58             $name=$db->StrQuery($sname);
 59             echo "<div>{$k}--{$name}--<input type='button' value='删除' bs='{$k}' class='del' /></div>";
 60             }
 61     }
 62     ?>
 63 </div><br />
 64 
 65 <!--新建流程 -->
 66 <div>
 67     请输入新建流程名称:
 68     <input type="text" id="lcmc">
 69 </div><br />
 70 <div>
 71     <input type="button" value="新建" id="xinjian">&nbsp;&nbsp;
 72     <a href="main.php">返回</a>
 73 </div>
 74 </div>
 75 
 76 </body>
 77 
 78 <script type="text/javascript">
 79 $(document).ready(function(e) {
 80     
 81     //设置默认选中第一个人
 82     $(".ry").eq(0).prop("checked",true);
 83     //1.点击添加按钮添加节点人员
 84     $("#tianjia").click(function(){
 85         
 86         //取选中的人员名        
 87         var ry=$(".ry");
 88         var uid="";        
 89         for(var i=0;i<ry.length;i++)
 90         {
 91             if(ry.eq(i).prop("checked"))
 92             {
 93                 uid=ry.eq(i).val();
 94             }
 95         }
 96         
 97         $.ajax({
 98             
 99             url:"tianjiacl.php",
100             data:{uid:uid},
101             type:"POST",
102             dataType:"TEXT",
103             success: function(data){                
104                 window.location="xjlc.php";                
105                 }
106             
107             });
108         
109         })
110     
111     //2.删除节点
112     $(".del").click(function(){
113         var id=$(this).attr("bs");
114         $.ajax({
115             url:"scjd.php",
116             data:{id:id},
117             type:"POST",
118             dataType:"TEXT",
119             success: function(data){
120                 window.location="xjlc.php";                        
121                 }
122     
123             });
124 
125         })
126         
127         
128     //3.点击新建流程
129     $("#xinjian").click(function(){
130         
131         //取文本框的值
132         var name=$("#lcmc").val();
133         
134         $.ajax({            
135             url:"addlc.php",
136             data:{name:name},
137             type:"POST",
138             dataType:"TEXT",
139             success: function(data){
140             
141                     if(data.trim()=="OK")
142                     {
143                         alert("添加成功");
144                     }
145                     else
146                     {
147                         alert("添加失败!");
148                     }
149 
150                 }
151 
152             });
153 
154         })
155     
156 
157 });
158 
159 </script>
160 
161 </html>
View Code

添加节点人员:tianjiacl.php

 1 <?php
 2 
 3 session_start();
 4 
 5 $uid=$_POST["uid"];
 6 
 7 
 8 //判断是否是第一次添加
 9 if(empty($_SESSION["jiedian"]))//如果是第一次
10 {
11     //新建一个数组来储存节点
12     $attr=array($uid);
13     $_SESSION["jiedian"]=$attr;
14     }
15 
16 else
17 {
18     $attr=$_SESSION["jiedian"];
19     array_push($attr,$uid);
20     $_SESSION["jiedian"]=$attr;
21     }
View Code

删除节点:scjd.php

1 <?php
2 session_start();
3 
4 $id = $_POST["id"];
5 $attr = $_SESSION["jiedian"];
6 unset($attr[$id]);
7 $attr = array_values($attr);
8 
9 $_SESSION["jiedian"] = $attr;
View Code

新建流程处理页面:addlc.php

 1 <?php
 2 
 3 session_start();
 4 
 5 include("../DBDA.class.php");
 6 $db = new DBDA();
 7 
 8 $attr = array();
 9 if(!empty($_SESSION["jiedian"]))
10 {
11     $attr = $_SESSION["jiedian"];
12 }
13 
14 $name = $_POST["name"];
15 
16 //向流程表添加数据
17 $code = date("YmdHis");
18 $slc = "insert into LiuCheng values('{$code}','{$name}')";
19 //判断是否执行成功的变量
20 $isok = true;
21 if($db->Query($slc,1))
22 {
23     foreach($attr as $k=>$v)
24     {
25         //向流程对应节点表添加数据
26         $sfl = "insert into FlowPath values('','{$code}','{$v}',{$k})";
27         $isok = $isok && $db->Query($sfl,1);
28     }
29 }
30 if($isok)
31 {
32     echo "OK";
33 }
34 else
35 {
36     echo "NO";
37 }
View Code

运行新建流程主页面:

 

三、

发起流程页面:fqlc.php

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5 <title>发起流程</title>
 6 <script type="text/javascript" src="../jquery-1.11.2.min.js"></script>
 7 <style type="text/css">
 8 #aa{
 9     
10     width:500px;
11     height:500px;
12     margin:10px 100px 0px 400px;}
13 
14 </style>
15 
16 </head>
17 
18 <body>
19 <div id="aa"><br />
20 <br />
21 
22 <h1>发起流程</h1>
23 <div>请选择流程:
24     <select id="select" style="width:100px;">
25     <?php
26     include("../DBDA.class.php");
27     $db=new DBDA();
28     $sql="select * from LiuCheng";
29     $attr=$db->Query($sql);
30     foreach($attr as $v)
31     {
32         echo "<option value='{$v[0]}'>{$v[1]}</option>";
33         }
34     ?>
35     </select>
36 </div><br />
37 <br />
38 
39 <div>请输入内容:
40     <textarea rows="7" cols="40" id="nr" ></textarea>
41 </div><br />
42 <br />
43 <div>
44     <input type="button" value="发起" id="faqi" />&nbsp;&nbsp;
45     <a href="main.php">返回</a>
46 </div>
47 </div>
48 </body>
49 <script type="text/javascript">
50 $(document).ready(function(e) {
51     
52     $("#faqi").click(function(){
53         
54         var name=$("#select").val();
55         var nr=$("#nr").val();
56         $.ajax({
57             url:"fqcl.php",
58             data:{name:name,nr:nr},
59             type:"POST",
60             dataType:"TEXT",
61             success: function(data){
62             
63                 if(data.trim()=="OK")
64                 {
65                     alert("发起成功!");
66                     }
67                 else
68                 {
69                     alert("发起失败!");
70                     }                
71                 }
72 
73             });
74         
75         })
76 
77 });
78 
79 </script>
80 
81 </html>
View Code

发起流程处理页面:fqcl.php

 1 <?php
 2 session_start();
 3 include("../DBDA.class.php");
 4 $db=new DBDA();
 5 
 6 $code=$_POST["name"];
 7 $uid=$_SESSION["uid"];
 8 $nr=$_POST["nr"];
 9 $time=date("Y-m-d H:i:s");
10 
11 $sql="insert into UserFlow values ('','{$code}','{$uid}','{$nr}',false,'{$time}',0)";
12 
13 if($db->Query($sql,1))
14 {
15     echo "OK";
16     }
17 else
18 {
19     echo "NO";
20     }
View Code

运行发起流程页面:

 

四、

审核流程页面:shlc.php

  1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2 <html xmlns="http://www.w3.org/1999/xhtml">
  3 <head>
  4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5 <title>审核流程</title>
  6 </head>
  7 
  8 <body>
  9 <?php
 10 session_start();
 11 $uid=$_SESSION["uid"];
 12 include("../DBDA.class.php");
 13 $db=new DBDA();
 14 ?>
 15 <br />
 16 <br />
 17 <h1>审核流程</h1>
 18 <br />
 19 <table width="70%" border="1" cellspacing="2" cellpadding="2">
 20 <tr>
 21     <td>流程名称</td>
 22     <td>发起者</td>
 23     <td>内容</td>
 24     <td>是否结束</td>
 25     <td>发起时间</td>
 26     <td>操作</td>
 27 </tr>
 28 <?php
 29 $sql="select * from UserFlow order by RiQi desc";
 30 $r=$db->Query($sql);
 31 foreach($r as $v)
 32 {
 33         //$v[1]流程代号
 34         //$v[6]流程到哪
 35     
 36         ////根据流程代号到flowpath表查该登录者在该流程中的次序
 37         $sqlcx="select code, orders from FlowPath where code='{$v[1]}'and uids='{$uid}'";
 38         
 39         $cx=$db->Query($sqlcx);
 40         if($cx)
 41         {
 42             $ucode=$cx[0][0];//流程代号
 43             $ucx=$cx[0][1];//次序    
 44             
 45             //判断该流程是否走到了该用户
 46             if($v[1]==$ucode && $v[6]>=$ucx)
 47             {
 48                 $lcname=Lname($db,$v[1]);
 49                 $fqname=Fname($db,$v[2]);
 50                 
 51                 //处理是否结束
 52                 $isok=$v[4]?"<span style='background-color:#FF3737'>已结束</span>":"<span style='background-color:#80FFFF'>处理中</span>";    
 53                 
 54                 //处理操作
 55                 $cz="";
 56                 if($v[6]==$ucx)
 57                 {
 58                     $cz="<a href='shcl.php?id={$v[0]}'>审核</a>";
 59                 }
 60                 else
 61                 {
 62                     $cz="<span style='color:red'>已通过</span>";    
 63                 }
 64                 
 65                 echo "<tr>
 66             <td>{$lcname}</td>
 67             <td>{$fqname}</td>
 68             <td>{$v[3]}</td>
 69             <td>{$isok}</td>
 70             <td>{$v[5]}</td>
 71             <td>{$cz}</td>
 72             </tr>";
 73 
 74             }
 75             
 76         }
 77 
 78     }
 79     
 80     //处理流程名
 81     function Lname($db,$code)
 82     {
 83         $sql1 = "select Name from LiuCheng where Code = 
 84 
 85 '{$code}'";
 86     return $db->StrQuery($sql1);
 87         
 88         }
 89         
 90     //处理发起者名称
 91     function Fname($db,$uid)
 92     {
 93         $sql2 = "select Name from Users where username = '{$uid}'";
 94         return $db->StrQuery($sql2);
 95         
 96         }
 97 
 98 ?>
 99 </table>
100 </body>
101 </html>
View Code

审核处理页面:shcl.php

 1 <?php
 2 include("../DBDA.class.php");
 3 $db=new DBDA();
 4 
 5 $id=$_GET["id"];
 6 
 7 $sql = "update UserFlow set ToWhere = ToWhere+1 where Ids='{$id}'";
 8 echo $sql;
 9 
10 if($db->Query($sql,1))
11 {
12     //查询流程走到哪了
13     $stw = "select Code,ToWhere from UserFlow where Ids='{$id}'";
14     $atw = $db->Query($stw);
15     $code = $atw[0][0];//流程代号
16     $tw = $atw[0][1];//流程到哪了
17     
18     //查询该流程下的节点数
19     $sfp = "select count(*) from FlowPath where Code = '{$code}'";
20     $sl = $db->StrQuery($sfp);
21     
22     //如果流程走到位置大于等于了该流程中节点的总数
23     if($tw>=$sl)
24     {
25         $isok = "update UserFlow set IsOk = true where 
26 
27 Ids='{$id}'";
28         $db->Query($isok,1);
29     }
30     
31     header("location:shlc.php");
32 }
33 else
34 {
35     echo "审核失败!";
36 }
View Code

运行审核流程页面:

五、

主页面:main.php

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5 <style type="text/css">
 6 #zhu{
 7     width:70%;
 8     height:40px;
 9     background:#8080FF;
10     margin:10px 100px 0 200px;    
11     }
12 .a{
13     width:300px;
14     height:40px;
15     color:#FFF;
16     text-align:center;
17     line-height:40px;
18     vertical-align:central;
19     float:left;}
20 
21 </style>
22 <title>主页面</title>
23 </head>
24 
25 <body>
26 <?php
27 session_start();
28 if(empty($_SESSION["uid"]))
29 {
30     header("location:login.php");
31     }
32 $uid=$_SESSION["uid"];
33 ?>
34 <center><h1>主页面</h1></center>
35 <div id="zhu">
36     <div class="a"><a href="xjlc.php">新建流程</a></div>
37     <div class="a"><a href="fqlc.php">发起流程</a></div>
38     <div class="a"><a href="shlc.php">审核流程</a></div>
39 </div>
40 
41 </body>
42 </html>
View Code

运行主页面:

posted @ 2016-05-30 11:16  陌上初薰  阅读(87)  评论(0编辑  收藏