Home >Backend Development >PHP Tutorial >A complete PHP process management example code sharing
1. 添加新流程页面:
<div> 请选择流程节点:<br /><br /> <?php session_start(); include("../DBDA.class.php"); $db = new DBDA(); $suser ="select * from users"; $auser = $db->Query($suser); foreach($auser as $v) { echo "<input class='rd' type='radio' name='user' value='{$v[0]}' /> {$v[2]} "; } ?> </div> <br /> <div><input type="button" value="添加节点" id="jiedian" /></div> <br /> <div> <?php $attr = array(); if(!empty($_SESSION["user"])) { $attr = $_SESSION["user"]; } 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='shanchu' /></div>"; } ?> </div> <br /> <div> 请输入流程名称: <input type="text" id="name" /> </div> <br /> <input type="button" value="保存" id="xinjian" /> <script type="text/javascript"> $("#jiedian").click(function(){ //取选中的用户名 var uid =""; var rd = $(".rd"); for(var i=0;i<rd.length;i++) { if(rd.eq(i).prop("checked")) { uid = rd.eq(i).val(); } } $.ajax({ url:"chuli.php", data:{uid:uid,type:0}, type:"POST", dataType:"TEXT", success: function(data){ window.location.href="add.php"; } }); }) $(".shanchu").click(function(){ var sy = $(this).attr("bs"); $.ajax({ url:"chuli.php", data:{sy:sy,type:1}, type:"POST", dataType:"TEXT", success: function(data){ window.location.href="add.php"; } }); }) $("#xinjian").click(function(){ var name = $("#name").val(); $.ajax({ url:"chuli.php", data:{name:name,type:2}, type:"POST", dataType:"TEXT", success: function(data){ window.location.href="add.php"; } }); }) </script>
2. 添加新流程(及其他)处理页面:
<?php session_start(); include("../DBDA.class.php"); $db = new DBDA(); $type = $_POST["type"]; switch($type) { case 0: $uid = $_POST["uid"]; if(empty($_SESSION["user"])) { $_SESSION["user"] = array($uid); } else { $attr = $_SESSION["user"]; $attr[] = $uid; $_SESSION["user"] = $attr; } break; case 1: $sy = $_POST["sy"]; $attr = $_SESSION["user"]; unset($attr[$sy]); $attr = array_values($attr); $_SESSION["user"] = $attr; break; case 2: $name = $_POST["name"]; $code = time(); $slc = "insert into liucheng values('{$code}','{$name}')"; //liucheng 名字 代号 $db->Query($slc,0); $attr = array(); if(!empty($_SESSION["user"])) { $attr = $_SESSION["user"]; } foreach($attr as $k=>$v) { $sfp = "insert into flowpath values('','{$code}','{$v}','{$k}')"; //flowpath 流程具体经过哪些人 $db->Query($sfp,0); } break; case 3: $code = $_POST["code"]; $nr = $_POST["nr"]; $uid = $_SESSION["uid"]; $rq = time(); $sql = "insert into userflow values('','{$code}','{$uid}','{$nr}',0,'{$rq}',0)"; //userflow 流程具体内容,名字,发起人 $db->Query($sql,0); //,内容,是否通过,事件,进行到哪一步 break; }
3. 登录后主页面:
<a>发起流程</a>
发起者 | 发起时间 | 流程名称 | 流程内容 | 是否结束 | 操作 |
{$v[2]} | {$v[5]} | {$v[1]} | {$v[3]} | {$v[4]} | {$str} |
4. 发起流程页面:
<h1>发起流程</h1> <div> 请选择要发起的流程: <select> <?php include("../DBDA.class.php"); $db = new DBDA(); $sql = "select * from liucheng"; $attr = $db->Query($sql); foreach($attr as $v) { echo "<option>{$v[1]}</option>"; } ?> </select> </div> <br> <div> 请输入流程的详情: <textarea></textarea> </div> <br> <input> <script> $("#btn").click(function(){ var code = $("#sel").val(); var nr = $("#xq").val(); $.ajax({ url:"chuli.php", data:{code:code,nr:nr,type:3}, type:"POST", dataType:"TEXT", success: function(data){ window.location.href="main.php"; } }); }) </script>
4. 判断发起的流程是否通过页面:
<?php session_start(); include("../DBDA.class.php"); $db = new DBDA(); $ids = $_GET["ids"]; $sql = "update userflow set towhere = towhere+1 where ids='{$ids}'"; $db->Query($sql,0); $stw = "select code,towhere from userflow where ids='{$ids}'"; $atw = $db->Query($stw); $lcdaihao = $atw[0][0]; $towhere = $atw[0][1]; $jiedian = "select count(*) from flowpath where code='{$lcdaihao}'"; $shuliang = $db->StrQuery($jiedian); if($towhere>=$shuliang) { $su = "update userflow set isok =1 where ids='{$ids}' "; $db->Query($su,0); } header("location:main.php");
The above is the detailed content of A complete PHP process management example code sharing. For more information, please follow other related articles on the PHP Chinese website!