2016/04/26 流程 数据库lcdb 四个表 1,用户表users 2,流程表(设定有哪些流程)liucheng 3,流程发起者表(记录谁发起到哪里) 4,流程经过的人员表 flowpath (order排序)

流程:      十一 个页面  

1,denglu.php(登录)  

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>登录</title>
 6 </head>
 7 <body>
 8     <h1>登录页面</h1>
 9 <form action="chulidl.php" method="POST">
10     <div>用户名:<input type="text" name="uid" id="uid"></div>
11     <div>密码<input type="text" name="pwd" id="pwd"></div>
12     <input type="submit" value="登录"></input>
13 </form>
14 </body>
15 </html>
View Code

显示:

2,chulidl(处理登录) 登录成功进入main.php页

 1 <?php 
 2 session_start();
 3 
 4 include("../DBDA.php");
 5 
 6 $db=new DBDA();
 7 
 8 $uid=$_POST["uid"];
 9 $pwd=$_POST["pwd"];
10 
11 
12 
13 $sql="select count(*) from Users where UserName='{$uid}' and Password='{$pwd}' ";
14 $str=$db->StrQuery($sql,1,"lcdb");
15 
16 if ($str=="1") {
17     $_SESSION["uid"]=$uid;
18     header("Location:main.php");
19 }
20 else{
21     header("Location:denglu.php");
22 }
23 
24 
25 
26 
27 
28  ?>
View Code

 

3,main.php(新建流程,发起流程,处理流程  三个条目)链接页面

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Document</title>
 6 <style type="text/css">
 7 .menu
 8 {
 9     width:100px;
10     height:30px;
11     float:left;
12     text-align:center;
13     line-height:30px;
14     vertical-align:middle;
15     font-size:14px;
16     color:white;
17 }
18 </style>
19 </head>
20 
21 <body>
22 <h1>主页面</h1>
23 <div style="width:100%; height:30px; background-color:#6CF">
24 <div class="menu"><a href="xinjian.php">新建流程</a></div>
25 <div class="menu"><a href="faqi.php">发起流程</a></div>
26 <div class="menu"><a href="liuchenggenzong.php">流程处理</a></div>
27 </div>
28 </body>
29 </html>
View Code

显示:

4,xinjian.php(流程创建  节点人员   流程名称)

  1 <?php 
  2 session_start();
  3  ?>
  4 <!DOCTYPE html>
  5 
  6 <html lang="en">
  7 <head>
  8     <meta charset="UTF-8">
  9     <title>首页</title>
 10     <script type="text/javascript" src="../jquery-1.11.2.min.js"></script>
 11 </head>
 12 <body>
 13     <h1>新建流程</h1>
 14     <br>
 15     <div>请选择节点人员:</div><br>
 16     <div>
 17     
 18         <?php 
 19             include("../DBDA.php");
 20             $db=new DBDA();
 21 
 22             $sqlj="select * from Users";
 23 
 24             $strj=$db->StrQuery($sqlj,1,"lcdb");
 25             $hangj=explode("|", $strj);
 26 
 27             for ($i=0; $i <count($hangj) ; $i++) { 
 28                 list($UserName,$Password,$Name)=explode("^", $hangj[$i]);
 29                 echo "<input type='radio' value='{$UserName}' class='ren' name='ren'>{$Name}&nbsp;";
 30             }
 31 
 32 
 33          ?>
 34     </div><br>
 35     <input type="button" value="添加节点" id="tian"></input><br><br>
 36     <div id="biao">
 37         <?php 
 38             if (isset($_SESSION["liuch"])) {
 39                 $attr=$_SESSION["liuch"];
 40                 
 41                 for ($i=0; $i <count($attr) ; $i++) { 
 42                     $sqlu="select Name from Users where UserName='{$attr[$i]}'";
 43                     $stru=$db->StrQuery($sqlu,1,"lcdb");
 44                     echo "<div class='jd' bs='{$attr[$i]}'>{$i}.{$stru}&nbsp;&nbsp;<input type='button' class='delete' bs='{$i}' value='删除'></div>";
 45                 }
 46             }
 47             else
 48             {
 49                 echo "当前没有设置流程!";
 50             }
 51 
 52          ?>
 53     </div><br>
 54     <div>输入流程名:
 55     <input type="text" id="liuch"></input>
 56     </div>
 57     <br>
 58 <input type="button" value="确定" id="add"></input>
 59 
 60 </body><br>
 61 <script type="text/javascript">
 62     $(document).ready(function(e){
 63         //添加节点
 64         $("#tian").click(function(){
 65             var user=$(".ren");
 66             for (var i = 0; i < user.length; i++) {
 67                 if (user.eq(i)[0].checked==true) {
 68 
 69                     var uid=user.eq(i).val();
 70                     $.ajax({
 71                         url:"chulilc.php",
 72                         data:{uid:uid},
 73                         type:"POST",
 74                         dataType:"TEXT",
 75                         success:function(data){
 76                             
 77                             window.location="xinjian.php";
 78                         }
 79                     });
 80                 }
 81             }
 82         })
 83         $(".delete").click(function(){
 84             var ids=$(this).attr("bs");
 85             $.ajax({
 86                 url:"dechuli.php",
 87                 data:{ids:ids},
 88                 type:"POST",
 89                 dataType:"TEXT",
 90                 success:function(data){
 91                     window.location="xinjian.php";
 92                 }
 93             })
 94         })
 95         //添加流程
 96         $("#add").click(function(){
 97             var name=$("#liuch").val();
 98 
 99             $.ajax({
100                 url:"addchuli.php",
101                 data:{name:name},
102                 type:"POST",
103                 dataType:"TEXT",
104                 success:function(data){
105                     if (data="OK") {
106                         alert("添加成功!");
107                         window.location="main.php";
108                     }
109                     else{
110                         alert("添加失败!");
111                     }
112                 }
113             })
114         })
115     });
116 </script>
117 </html>
View Code

 

显示:

5,chulilc.php(重点是value值传入session中  保存在数组里  ajax返回)

 1 <?php 
 2     session_start();
 3 
 4     $uid=$_POST["uid"];
 5 
 6     if (isset($_SESSION["liuch"])) {
 7         $shuzu=$_SESSION["liuch"];
 8         array_push($shuzu,$uid);
 9         $_SESSION["liuch"]=$shuzu;
10     }
11     else
12     {
13         $shuzu=array();
14         array_push($shuzu, $uid);
15         $_SESSION["liuch"]=$shuzu;
16     }
17 
18  ?>
View Code

 

6,addchuli.php(节点人员增加)

 1 <?php 
 2     session_start();
 3     include("../DBDA.php");
 4 
 5     $db=new DBDA();
 6 
 7     $name=$_POST["name"];
 8 
 9     if (empty($_SESSION["liuch"])) {
10         echo "请添加节点人员!";
11     }
12     else
13 {    
14     $attr=$_SESSION["liuch"];
15     $code=date("Ymdhisms",time());
16 
17     $sqll="insert into liuCheng values ('{$code}','{$name}')";
18 
19     if ($db->StrQuery($sqll,0,"lcdb")) 
20     {
21 
22     for ($i=0; $i <count($attr) ; $i++) { 
23         $sql="insert into FlowPath values('','{$code}','{$attr[$i]}','{$i}')"; 
24         $db->StrQuery($sql,0,"lcdb");
25     }
26 
27 }
28     echo "添加成功!";
29 
30 }
31 
32 
33 
34 
35 
36  ?>
View Code

 

7,dechuli.php(删除节点人员)

 1 <?php 
 2 session_start();
 3 $ids=$_POST["ids"];
 4 
 5 $array=$_SESSION["liuch"];
 6 
 7 unset($array[$ids]); //删除元素
 8 
 9 $array=array_values($array); //重新索引
10 
11 $_SESSION["liuch"]=$array;
12 
13 
14 
15  ?>
View Code

显示:

比上面少了张三

 

8,faqi.php(流程发起页面)

 1 <?php 
 2   session_start();
 3   
 4  ?>
 5 <!DOCTYPE html>
 6 <html lang="en">
 7 <head>
 8     <meta charset="UTF-8">
 9     <title>流程发起</title>
10     <script type="text/javascript" src="../jquery-1.11.2.min.js"></script>
11 </head>
12 <body>
13     <h1>发起流程</h1>
14     <div>请选择流程:
15         <select id="lc">
16             <?php 
17                 include("../DBDA.php");
18                 $db=new DBDA();
19 
20                 $sql="select *  from LiuCheng";
21 
22                 $str=$db->StrQuery($sql,1,"lcdb");
23                 $hang=explode("|", $str);
24                 for($i=0;$i<count($hang);$i++) { 
25                     list($code,$name)=explode("^", $hang[$i]);
26 
27                     echo "<option value='{$code}'>{$name}</option>";
28                     
29                 }
30 
31 
32 
33 
34 
35              ?>
36         </select>
37     </div><br>
38 
39     <div>
40         <div>请输入流程内容:</div><br>
41         <div><textarea id="neir" style="width: 400px; height: 300px;"></textarea></div>
42     </div><br>
43 
44     <input type="button" value="确定" id="btn"></input>
45 <a href="liuchenggenzong.php">处理页面</a>
46 </body>
47  <script type="text/javascript">
48      $(document).ready(function(e){
49              $("#btn").click(function(){
50                  var lc=$("#lc").val();
51                  
52                  var nr=$("#neir").val();
53                  $.ajax({
54                      url:"chulifq.php",
55                      data:{lc:lc,nr:nr},
56                      type:"POST",
57                      dataType:"TEXT",
58                      success:function(data){
59                          if (data=="OK") {
60                              alert("发起成功!")
61                          }
62                          else{
63                              alert("发起失败!");
64                          }
65                      }
66                  });
67              })
68      });
69 
70 
71  </script>
72 </html>
View Code

显示:

9,chulifq.php(处理发起页面)

 1 <?php 
 2     session_start();
 3     include("../DBDA.php");
 4 
 5     $db=new DBDA();
 6     $lc=$_POST["lc"];
 7     $nr=$_POST["nr"];
 8 
 9     $uid=$_SESSION["uid"];
10     //echo $uid;
11     $riqi=date("Y-m-d H:i:s",time());
12 
13     $sqlf="insert into UserFlow values('','{$lc}','{$uid}','{$nr}',false,'{$riqi}',0)";
14 
15     $str=$db->StrQuery($sqlf,0,"lcdb");
16     echo $str;
17  ?>
View Code

 

10,liuchenggenzong.php(流程中各个节点人员审核的表格)

 1 <?php 
 2 session_start();
 3  ?>
 4 <!DOCTYPE html>
 5 <html lang="en">
 6 <head>
 7     <meta charset="UTF-8">
 8     <title></title>
 9 </head>
10 <body>
11     <h1>处理流程</h1>
12     <table width="100%" border="1" cellspacing="0" cellpadding="0">
13         <tr>
14         <td>流程名称</td>
15         <td>发起者</td>
16         <td>内容</td>
17         <td>是否结束</td>
18         <td>发起日期</td>
19         <td>操作</td>
20         </tr>
21         <?php 
22             $uid=$_SESSION["uid"];
23             include("../DBDA.php");
24 
25             $db=new DBDA();
26 
27             $sql="select * from userflow ";
28 
29             $str=$db->StrQuery($sql,1,"lcdb");
30             $hang=explode("|", $str);
31 
32             for ($i=0; $i < count($hang); $i++) { 
33                 list($ids,$code,$uids,$nr,$isok,$riqi,$towhere)=explode("^", $hang[$i]);
34                 
35                 //查流程里面所有的节点
36                 $sqlj="select * from FlowPath where code='{$code}'";
37                 $strj=$db->StrQuery($sqlj,1,"lcdb");
38 
39                 $hangj=explode("|",$strj);
40                 
41                 $bs=false;
42                 $bscl=false;
43                 for ($j=0; $j <count($hangj) ; $j++) { 
44                     list($idsj,$codej,$uidj,$orderj)=explode("^",$hangj[$j]);
45                     if (($uidj==$uid)and($orderj<=$towhere)) {
46                         if ($orderj==$towhere) {
47                             $bscl=true;
48 
49                         }
50                         $bs=true;
51                     }
52                     
53                 }
54                 //处理流程名
55                 $sqllc="select Name from LiuCheng where Code='{$code}'";
56                 $lcname=$db->StrQuery($sqllc,1,"lcdb");
57                 
58                 //处理发起者
59                 $sqlfq="select Name from Users where UserName='{$uid}'";
60                 $fqname=$db->StrQuery($sqlfq,1,"lcdb");
61                 
62 
63                 //处理是否结束
64                 $jieguo=$isok?"<span style='background-color:red'>已结束</span>":"<span style='background-color:green'>进行中</span>";
65 
66                 //处理操作
67                  $caozuo=$bscl?"<a href='tongguo.php?code={$ids}'>通过</a>":"<span style='background-color:gray'>已通过</span>";
68                 if ($bs) {
69                     echo "<tr>
70                     <td>{$lcname}</td>
71                     <td>{$fqname}</td>
72                     <td>{$nr}</td>
73                     <td>{$jieguo}</td>
74                     <td>{$riqi}</td>
75                     <td>{$caozuo}</td></tr>";
76                 }
77             }
78 
79 
80      ?>
81     </table>
82 
83 </body>
84 </html>
View Code

显示:

11,tongguo.php(处理   根据uid是否相等,以及order和towhere的相对大小来处理 是否显示)

 1 <?php 
 2 include("../DBDA.php");
 3 $db=new DBDA();
 4 
 5 $code=$_GET["code"];
 6 
 7 $sql="update UserFlow set ToWhere=ToWhere+1 where ids='{$code}'";
 8 $db->StrQuery($sql,0,"lcdb");
 9 
10 $sqlt="select Code,ToWhere from UserFlow where Ids='{$code}'";
11 $strtw=$db->StrQuery($sqlt,1,"lcdb");
12 list($lccode,$tw)= explode("^",$strtw);
13 
14 //查询该流程下节点数量
15 $sqlf="select count(*) from FlowPath where code='{$lccode}'";
16 $zs=$db->StrQuery($sqlf,1,"lcdb");
17 //判断是否走完流程
18 if($tw>=$zs)
19 {
20     $sqlx="update userFlow set IsOK=true where Ids='{$code}'";
21     $db->StrQuery($sqlx,0,"lcdb");
22 }
23 
24 
25 
26 header("Location:liuchenggenzong.php");
27 
28 
29  ?>
View Code

 

posted on 2016-04-26 20:03  一棵树2016  阅读(273)  评论(0编辑  收藏  举报