流程
login.php
1 <body>
2 <form action="loginchuli.php" method="post">
3 <div>用户名:<input type="text" name="uid" /></div>
4 <div>密码:<input type="text" name="pwd" /></div>
5 <input type="submit" value="登录" />
6 </form>
7 </body>
8 </html>
loginchuli.php
<?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");
}
main.php
1 <head>
2 <?php
3 session_start();
4
5 if(empty($_SESSION["uid"]))
6 {
7 header("location:login.php");
8 exit;
9 }
10 $uid = $_SESSION["uid"];
11
12 include("../DBDA.php");
13 $db = new DBDA();
14 ?>
15 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
16 <title>无标题文档</title>
17 <style type="text/css">
18 #menu
19 {
20 width:100%;
21 height:30px;
22 }
23 .z
24 {
25 width:100px;
26 height:30px;
27 float:left;
28 }
29 </style>
30
31 </head>
32
33 <body>
34 <br />
35 <br />
36 <center><h1>主页面</h1></center>
37 <br />
38
39 <div id="menu">
40 <div class='z'><a href="xinjian.php">新建流程</a></div>
41 <div class="z"><a href="faqi.php">发起流程</a></div>
42 <div class="z"><a href="shenhe.php">审核流程</a></div>
43 </div>
44
45 </body>
46 </html>
xinjian.php
1 <title>无标题文档</title> 2 <script src="../jquery-1.11.2.min.js"></script> 3 </head> 4 5 <body> 6 <?php 7 session_start(); 8 9 include("../DBDA.php"); 10 $db = new DBDA(); 11 12 $attr = array(); 13 if(!empty($_SESSION["jiedian"])) 14 { 15 $attr = $_SESSION["jiedian"]; 16 } 17 18 ?> 19 <h1>新建流程</h1> 20 <div> 21 请选择节点人员: 22 <?php 23 $sry = "select * from Users"; 24 $ary = $db->Query($sry); 25 26 foreach($ary as $v) 27 { 28 echo "<input name='ry' class='ry' type='radio' value='{$v[0]}' /> {$v[2]}"; 29 } 30 31 ?> 32 </div> 33 <br /> 34 <div> 35 <input type="button" value="添加节点" id="tjjd" /> 36 </div> 37 <br /> 38 <div> 39 <?php 40 foreach($attr as $k=>$v) 41 { 42 $sname = "select Name from Users where Uid='{$v}'"; 43 $name = $db->StrQuery($sname); 44 45 echo "<div>{$k}--{$name}--<input type='button' value='删除' bs='{$k}' class='sc' /></div>"; 46 } 47 ?> 48 </div> 49 <br /> 50 <div> 51 请输入流程名称: 52 <input type="text" id="mc" /> 53 </div> 54 <br /> 55 <div> 56 <input type="button" value="添加" id="add" /> 57 </div> 58 <a href="main.php">返回</a> 59 </body> 60 <script type="text/javascript"> 61 $(document).ready(function(e) { 62 //设置默认选中第一项 63 $(".ry").eq(0).prop("checked",true); 64 65 //添加节点按钮点击事件 66 $("#tjjd").click(function(){ 67 68 var rd = $(".ry"); 69 //取选中的用户名 70 var uid = ""; 71 for(var i=0;i<rd.length;i++) 72 { 73 if(rd.eq(i).prop("checked")) 74 { 75 uid = rd.eq(i).val(); 76 } 77 } 78 79 $.ajax({ 80 url:"tjjd.php", 81 data:{uid:uid}, 82 type:"POST", 83 dataType:"TEXT", 84 success: function(data){ 85 window.location = "xinjian.php"; 86 } 87 88 }); 89 90 }) 91 //删除节点按钮事件 92 $(".sc").click(function(){ 93 94 var id = $(this).attr("bs"); 95 $.ajax({ 96 url:"scjd.php", 97 data:{id:id}, 98 type:"POST", 99 dataType:"TEXT", 100 success: function(data){ 101 window.location = "xinjian.php"; 102 } 103 104 }); 105 106 }) 107 //添加流程按钮 108 $("#add").click(function(){ 109 110 var name = $("#mc").val(); 111 $.ajax({ 112 url:"tjlc.php", 113 data:{name:name}, 114 type:"POST", 115 dataType:"TEXT", 116 success: function(data){ 117 if(data.trim()=="OK") 118 { 119 alert("添加成功"); 120 } 121 else 122 { 123 alert("添加失败!"); 124 } 125 } 126 127 }); 128 129 }) 130 131 132 }); 133 </script> 134 </html>
tjjd.php
1 <?php 2 session_start(); 3 4 $uid = $_POST["uid"]; 5 6 if(empty($_SESSION["jiedian"])) 7 { 8 $attr = array($uid); 9 $_SESSION["jiedian"] = $attr; 10 } 11 else 12 { 13 $attr = $_SESSION["jiedian"]; 14 array_push($attr,$uid); 15 $_SESSION["jiedian"] = $attr; 16 }
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;
tjlc.php
1 <?php 2 session_start(); 3 4 include("../DBDA.php"); 5 $db = new DBDA(); 6 7 $attr = array(); 8 if(!empty($_SESSION["jiedian"])) 9 { 10 $attr = $_SESSION["jiedian"]; 11 } 12 13 $name = $_POST["name"]; 14 15 //向流程表添加数据 16 $code = date("YmdHis"); 17 $slc = "insert into LiuCheng values('{$code}','{$name}')"; 18 //判断是否执行成功的变量 19 $isok = true; 20 if($db->Query($slc,0)) 21 { 22 foreach($attr as $k=>$v) 23 { 24 //向流程对应节点表添加数据 25 $sfl = "insert into FlowPath values('','{$code}','{$v}',{$k})"; 26 $isok = $isok && $db->Query($sfl,0); 27 } 28 } 29 if($isok) 30 { 31 echo "OK"; 32 } 33 else 34 { 35 echo "NO"; 36 }
shenhe.php
1 <?php 2 session_start(); 3 4 include("../DBDA.php"); 5 $db = new DBDA(); 6 7 $uid = $_SESSION["uid"]; 8 9 ?> 10 <body> 11 <h1>审核流程</h1> 12 <br /> 13 <table width="100%" border="1" cellspacing="0" cellpadding="0"> 14 <tr bgcolor="#3399FF" style="color:white"> 15 <td>流程名称</td> 16 <td>发起者</td> 17 <td>内容</td> 18 <td>是否结束</td> 19 <td>发起时间</td> 20 <td>操作</td> 21 </tr> 22 <?php 23 $suf = "select * from UserFlow order by RiQi desc"; 24 $auf = $db->Query($suf); 25 26 foreach($auf as $v) 27 { 28 //$v[1]流程代号 29 //$v[6]流程到哪 30 31 //根据流程代号到flowpath表查该登录者在该流程中的次序 32 $sfp = "select Code,Orders from FlowPath where Code='{$v[1]}' and Uids='{$uid}'"; 33 $cx = $db->Query($sfp); 34 if($cx) 35 { 36 $ucode = $cx[0][0];//流程代号 37 $ucx = $cx[0][1];//次序 38 //判断该流程是否走到了该用户 39 if($v[1]==$ucode && $v[6]>=$ucx) 40 { 41 $lname = Lname($db,$v[1]); 42 $fname = Fname($db,$v[2]); 43 //处理是否结束 44 $isok = $v[4]?"<span style='background-color:red'>已结束</span>":"<span style='background-color:green'>处理中</span>"; 45 //处理操作 46 $chuli = ""; 47 if($v[6]==$ucx) 48 { 49 $chuli="<a href='sh.php?id={$v[0]}'>审核</a>"; 50 } 51 else 52 { 53 $chuli = "<span style='color:green'>已通过</span>"; 54 } 55 56 echo "<tr> 57 <td>{$lname}</td> 58 <td>{$fname}</td> 59 <td>{$v[3]}</td> 60 <td>{$isok}</td> 61 <td>{$v[5]}</td> 62 <td>{$chuli}</td> 63 </tr>"; 64 } 65 } 66 67 } 68 //处理流程名 69 function Lname($db,$code) 70 { 71 $sql = "select Name from LiuCheng where Code = '{$code}'"; 72 return $db->StrQuery($sql); 73 } 74 //处理发起者名 75 function Fname($db,$uid) 76 { 77 $sql = "select Name from Users where Uid = '{$uid}'"; 78 return $db->StrQuery($sql); 79 } 80 81 82 ?> 83 </table> 84 </body> 85 </html>
sh.php
1 <?php 2 include("../DBDA.php"); 3 $db = new DBDA(); 4 5 $id = $_GET["id"]; 6 7 $sql = "update UserFlow set ToWhere = ToWhere+1 where Ids='{$id}'"; 8 9 if($db->Query($sql,1)) 10 { 11 //查询流程走到哪了 12 $stw = "select Code,ToWhere from UserFlow where Ids='{$id}'"; 13 $atw = $db->Query($stw); 14 $code = $atw[0][0];//流程代号 15 $tw = $atw[0][1];//流程到哪了 16 17 //查询该流程下的节点数 18 $sfp = "select count(*) from FlowPath where Code = '{$code}'"; 19 $sl = $db->StrQuery($sfp); 20 21 //如果流程走到位置大于等于了该流程中节点的总数 22 if($tw>=$sl) 23 { 24 $sok = "update UserFlow set IsOk = true where Ids='{$id}'"; 25 $db->Query($sok,1); 26 } 27 28 header("location:shenhe.php"); 29 } 30 else 31 { 32 echo "审核失败!"; 33 }
1 <?php 2 include("../DBDA.php"); 3 $db = new DBDA(); 4 5 $id = $_GET["id"]; 6 7 $sql = "update UserFlow set ToWhere = ToWhere+1 where Ids='{$id}'"; 8 9 if($db->Query($sql,1)) 10 { 11 //查询流程走到哪了 12 $stw = "select Code,ToWhere from UserFlow where Ids='{$id}'"; 13 $atw = $db->Query($stw); 14 $code = $atw[0][0];//流程代号 15 $tw = $atw[0][1];//流程到哪了 16 17 //查询该流程下的节点数 18 $sfp = "select count(*) from FlowPath where Code = '{$code}'"; 19 $sl = $db->StrQuery($sfp); 20 21 //如果流程走到位置大于等于了该流程中节点的总数 22 if($tw>=$sl) 23 { 24 $sok = "update UserFlow set IsOk = true where Ids='{$id}'"; 25 $db->Query($sok,1); 26 } 27 28 header("location:shenhe.php"); 29 } 30 else 31 { 32 echo "审核失败!"; 33 }