您好,登錄后才能下訂單哦!
不懂php實現流程管理的方法?其實想解決這個問題也不難,下面讓小編帶著大家一起學習怎么去解決,希望大家閱讀完這篇文章后大所收獲。
php實現流程管理的方法:首先新建流程頁面,并建好節點;然后點擊選擇節點人員可以從數據庫調所有人員名單;最后做一個登陸用戶,提交請假流程的所有步驟即可。
php實現流程管理的方法:
我們首先做一個新建流程頁面,先把節點做好
xinjian.php
<!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="../dist/js/jquery-1.11.2.min.js"></script> </head> <body> <h2>新建流程</h2> <div> 請選擇節點人員: <select id="user"> <?php session_start(); include("../fengzhuang/DBDA.class.php"); $db = new DBDA(); $sql = "select * from lc_users"; $arr = $db->Query($sql); foreach($arr as $v) { echo "<option value='{$v[0]}'>{$v[2]}</option>"; } ?> </select> <input type="button" value="添加節點" id="add" /> </div> <br /> <div> <?php if(!empty($_SESSION["user"])) { $attr = $_SESSION["user"]; foreach($attr as $k=>$v) { $sname = "select name from lc_users where uid='{$v}'"; $name = $db->StrQuery($sname); echo "<div>{$k}--{$name}--<input type='button' value='刪除' key='{$k}' class='del' /></div>"; } } ?> </div> <br /> <div>請輸入流程名稱:<input type="text" id="name" /></div> <br /> <input type="button" value="保存" id="btn" /> </body> <script type="text/javascript"> //添加節點按鈕加點擊 $("#add").click(function(){ var uid = $("#user").val(); $.ajax({ url:"chuli.php", data:{uid:uid,type:0}, type:"POST", dataType:"TEXT", success: function(data){ window.location.href="xinjian.php"; } }); }) //給刪除按鈕加點擊 $(".del").click(function(){ var key = $(this).attr("key"); $.ajax({ url:"chuli.php", data:{key:key,type:1}, type:"POST", dataType:"TEXT", success:function(data){ window.location.href="xinjian.php"; } }); }) //給保存按鈕加點擊 $("#btn").click(function(){ var name = $("#name").val(); $.ajax({ url:"chuli.php", data:{name:name,type:2}, type:"POST", dataType:"TEXT", success:function(data){ alert("保存成功!"); } }); }) </script> </html>
chuli.php
<?php session_start(); include("../fengzhuang/DBDA.class.php"); $db = new DBDA(); $type = $_POST["type"]; switch($type) { case 0: $uid = $_POST["uid"]; if(empty($_SESSION["user"])) { $arr = array($uid); $_SESSION["user"] = $arr; } else { $arr = $_SESSION["user"]; array_push($arr,$uid); $_SESSION["user"] = $arr; } break; case 1: $key = $_POST["key"]; $arr = $_SESSION["user"]; unset($arr[$key]); //刪除 $arr = array_values($arr); //重新索引 $_SESSION["user"] = $arr; break; case 2: $name = $_POST["name"]; $code = time(); //添加流程 $sql = "insert into lc_liucheng values('{$code}','{$name}')"; $db->Query($sql,0); //添加流程節點 $arr = $_SESSION["user"]; foreach($arr as $k=>$v) { $sql = "insert into lc_flowpath values('','{$code}','{$v}','{$k}')"; $db->Query($sql,0); } break; case 3: //用戶發起流程 $code = $_POST["code"]; $nr = $_POST["content"]; $uid = $_SESSION["uid"]; $time = date("Y-m-d H:i:s"); $sql = "insert into lc_userflow values('','{$code}','{$uid}','{$nr}',0,'{$time}',0)"; $db->Query($sql,0); break; }
完成的效果,如圖:
點擊選擇節點人員可以從數據庫調所有人員名單,現在把李四,馬七和張三放入流程中,做一個請假流程:
點擊保存,存到數據庫:
注意:Code必須用varchar,不能用time,因為在上面用了時間戳
現在我們在做一個登陸用戶,提交請假流程的所有步驟:
weilogin.php 一個偽賬戶
<!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> <?php session_start(); $_SESSION["uid"] = "zhangsan"; ?> </body> </html>
faqi.php
<!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><br /> <script src="../dist/js/jquery-1.11.2.min.js"></script> </head> <body> <h2>發起流程</h2> <div> 請選擇發起的流程: <select id="liucheng"> <?php session_start(); include("../fengzhuang/DBDA.class.php"); $db = new DBDA(); $sql = "select * from lc_liucheng"; $arr = $db->Query($sql); foreach($arr as $v) { echo "<option value='{$v[0]}'>{$v[1]}</option>"; } ?> </select> </div> <br /> <div> 請輸入內容: <textarea id="nr"></textarea> </div> <br /> <input type="button" value="發起" id="btn" /> </body> <script type="text/javascript"> $("#btn").click(function(){ var code = $("#liucheng").val(); var content = $("#nr").val(); $.ajax({ url:"chuli.php", data:{code:code,content:content,type:3}, type:"POST", dataType:"TEXT", success: function(data){ alert("發起成功!"); } }); }) </script> </html>
shenhe.php
<!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> <h2>審核頁面</h2> <table width="100%" border="1" cellpadding="0" cellspacing="0"> <tr> <td>流程代號</td> <td>發起者</td> <td>發起內容</td> <td>是否結束</td> <td>發起時間</td> <td>操作</td> </tr> <?php session_start(); include("../fengzhuang/DBDA.class.php"); $db = new DBDA(); $uid = $_SESSION["uid"]; echo $uid; //查找登錄者參與的所有流程 $sql = "select * from lc_userflow where code in(select code from lc_flowpath where uids='{$uid}')"; $arr = $db->Query($sql); //顯示 foreach($arr as $v) { //判斷該流程走到登錄者 $lcdh = $v[1]; //流程代號 $towhere = $v[6];//流程走到哪 $sql = "select orders from lc_flowpath where code='{$lcdh}' and uids='{$uid}'"; $order = $db->StrQuery($sql);//該人員在流程中的次序 if($towhere>=$order) { $caozuo = ""; if($towhere==$order) { $caozuo="<a href='tongguo.php?code={$v[0]}'>通過</a>"; } else { $caozuo="<span style='background-color:green;color:white'>已通過</span>"; } echo "<tr> <td>{$v[1]}</td> <td>{$v[2]}</td> <td>{$v[3]}</td> <td>{$v[4]}</td> <td>{$v[5]}</td> <td>{$caozuo}</td> </tr>"; } } ?> </table> </body> </html>
tongguo.php
<?php session_start(); include("../fengzhuang/DBDA.class.php"); $db = new DBDA(); //流程往下走 $code = $_GET["code"]; $sql = "update lc_userflow set towhere=towhere+1 where ids='{$code}'"; $db->Query($sql,0); //判斷流程是否結束 $sql = "select * from lc_userflow where ids='{$code}'"; $arr = $db->Query($sql); $lcdh = $arr[0][1]; //流程代號 $tw = $arr[0][6]; //流程走到哪 $sql = "select count(*) from lc_flowpath where code='{$lcdh}'"; $count = $db->StrQuery($sql); //該流程節點人數 if($tw>=$count) { $sql = "update lc_userflow set isok=1 where ids='{$code}'"; $db->Query($sql,0); } header("location:shenhe.php");
張三發個請假流程,
李四的頁面:
點擊通過后
數據庫:towhere變成1了
接著該馬七:
然后是張三:
數據庫:isok變成1了
感謝你能夠認真閱讀完這篇文章,希望小編分享php實現流程管理的方法內容對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,遇到問題就找億速云,詳細的解決方法等著你來學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。