Maison > Article > développement back-end > Un exemple complet de partage de code de gestion de processus PHP
1. Ajouter une nouvelle page de processus :
<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. Ajouter une nouvelle page de traitement (et autres) :
fc0b6078f7037ca40ed9b44d92377dd5Query($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. Après vous être connecté à la page principale :
78c9f1981ad44a4e00fcfaf12bf13e6d发起流程5db79b134e9f6b82c0b36e0489ee08ed fc0cdfe1e1be1cb58a3b4c642ad29fde a34de1251f0d9fe1e645927f19a896e8 b6c5a531a458a2e790c1fd6421739d1c发起者b90dd5946f0946207856a8a37f441edf b6c5a531a458a2e790c1fd6421739d1c发起时间b90dd5946f0946207856a8a37f441edf b6c5a531a458a2e790c1fd6421739d1c流程名称b90dd5946f0946207856a8a37f441edf b6c5a531a458a2e790c1fd6421739d1c流程内容b90dd5946f0946207856a8a37f441edf b6c5a531a458a2e790c1fd6421739d1c是否结束b90dd5946f0946207856a8a37f441edf b6c5a531a458a2e790c1fd6421739d1c操作b90dd5946f0946207856a8a37f441edf fd273fcf5bcad3dfdad3c41bd81ad3e5 8f3754627d84bd4d43c8233f9815fdffQuery($sql); foreach($attr as $v) { $v[1];//流程代号 $v[6]; //流程走到哪了 //根据流程代号和当前登录者用户名查orders $szai="select count(*) from flowpath where code='{$v[1]}' and uids='{$uid}'"; $n = $db->StrQuery($szai); //该人员在该流程下 if($n>0) { $sorder = "select orders from flowpath where code='{$v[1]}' and uids='{$uid}'"; $order = $db->StrQuery($sorder); if($v[6]>=$order) { $str = ""; if($v[6]==$order) { $str = "2d4ebcf16653e26fbcd9841ad7c12823通过5db79b134e9f6b82c0b36e0489ee08ed"; } else { $str = "e27b8bcdf08dff5eb128dd133ac2593f已处理54bdf357c58b8a65c66d7c19c8e4d114"; } echo "a34de1251f0d9fe1e645927f19a896e8b6c5a531a458a2e790c1fd6421739d1c{$v[2]}b90dd5946f0946207856a8a37f441edf b6c5a531a458a2e790c1fd6421739d1c{$v[5]}b90dd5946f0946207856a8a37f441edf b6c5a531a458a2e790c1fd6421739d1c{$v[1]}b90dd5946f0946207856a8a37f441edf b6c5a531a458a2e790c1fd6421739d1c{$v[3]}b90dd5946f0946207856a8a37f441edf b6c5a531a458a2e790c1fd6421739d1c{$v[4]}b90dd5946f0946207856a8a37f441edf b6c5a531a458a2e790c1fd6421739d1c{$str}b90dd5946f0946207856a8a37f441edffd273fcf5bcad3dfdad3c41bd81ad3e5"; } } } ?> f16b1740fad44fb09bfe928bcc527e08
4. Page de lancement du processus :
4a249f0d628e2318394fd9b75b4636b1发起流程473f0a7621bec819994bb5020d29372a dc6dce4a544fdca2df29d5ac0ea9906b 请选择要发起的流程: 6666a6a3a80b8116945caf8c02cf64a7 306efb49a880f07a7027f693b82391c9Query($sql); foreach($attr as $v) { echo "8dfcd5164ba7c14d3a3a5df4cc194797{$v[1]}4afa15d3069109ac30911f04c56f3338"; } ?> 18bb6ffaf0152bbe49cd8a3620346341 16b28748ea4df4d9c2150843fecfba68 ff9d32c555bb1d9133a29eb4371c1213 dc6dce4a544fdca2df29d5ac0ea9906b 请输入流程的详情: 625e16c506fddb9f179c3dd097a6269140587128eee8df8f03d0b607fe983014 16b28748ea4df4d9c2150843fecfba68 ff9d32c555bb1d9133a29eb4371c1213 41f8bad7ea7b81314257e508834f8d31 8019067d09615e43c7904885b5246f0a $("#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"; } }); }) 2cacc6d41bbb37262a98f745aa00fbf0
4. Déterminez si le processus lancé passe la page :
ca08904bef23298b20a6648a9e31cacbQuery($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");
.
Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!