首页 > 代码库 > 流程例子
流程例子
添加节点:
<body> <div> 请选择节点:<br /><br /> <?php session_start(); include("../fzl/czy.class.php"); $db = new czy(); $suser = "select * from user"; $auser = $db->Query($suser); foreach($auser as $v) { echo "<input class=‘rd‘ type=‘radio‘ name=‘user‘ value=http://www.mamicode.com/‘{$v[0]}‘ />{$v[2]} "; } ?> </div>
<div><input type="button" value="http://www.mamicode.com/添加节点" id="jiedian" name="user"/></div> <br /> <div> <?php $attr =array(); //造一个数组,存入session if(!empty($_SESSION["user"])) { $attr = $_SESSION["user"]; } foreach($attr as $k=>$v) { $sname = "select name from user where uid =‘{$v}‘"; $name = $db->strQuery($sname); echo "<div>{$k}=>{$name}=><input class=‘shanchu‘ type=‘button‘ value=http://www.mamicode.com/‘删除‘ bs=‘{$k}‘ /></div>"; } ?> </div> <br /> <div> 请输入流程名称: <input type="text" id="name" /> </div> <br /> <input type="button" value="http://www.mamicode.com/保存" 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="http://www.mamicode.com/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="http://www.mamicode.com/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="http://www.mamicode.com/add.php";
}
});
})
</script> </body>
处理总页面:
<?php session_start(); include("../fzl/czy.class.php"); $db = new czy(); $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}‘)"; $db->Query($slc,0); $attr = array(); if($_SESSION["user"]) { $attr = $_SESSION["user"]; } foreach($attr as $k=>$v) { $sfp = "insert into flowpath values(‘‘,‘{$code}‘,‘{$v}‘,‘{$k}‘)"; $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)"; $db->Query($sql,0); break; }
登录:
<body><br /> <form action="loginchuli.php" method="post"> <div><input type="text" name="uid" /></div> <div><input type="text" name="pwd" /></div> <div><input type="submit" value="http://www.mamicode.com/登录" /></div> </form> </body>
登录处理:
<?php session_start(); include("../fzl/czy.class.php"); $db = new czy(); $uid = $_POST["uid"]; $pwd = $_POST["pwd"]; $sql = "select pwd from user where uid=‘{$uid}‘"; $mm = $db->StrQuery($sql); if($mm == $pwd && $pwd!="") { $_SESSION["uid"] = $uid; header("location:main.php"); } else { echo "登录失败!"; }
主页面:(main.php)
点击main页面发起流程<a>标签,到faqi.php页面完成流程发起
<body> <a href="http://www.mamicode.com/faqi.php">发起流程</a> <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("../fzl/czy.class.php"); $db = new czy(); $uid = $_SESSION["uid"]; $sql = "select * from userflow"; $attr = $db->Query($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 = "<a href=http://www.mamicode.com/‘tongguo.php?ids={$v[0]}‘>审核</a>"; } else { $str = "<span style=‘color:green‘>已通过</span>"; } echo "<tr> <td>{$v[2]}</td> <td>{$v[5]}</td> <td>{$v[1]}</td> <td>{$v[3]}</td> <td>{$v[4]}</td> <td>{$str}</td> </tr>"; } } } ?>
发起流程界面:
<body> <h1>发起流程</h1> <div> 请选择要发起的流程: <select id="sel"> <?php include("../fzl/czy.class.php"); $db = new czy(); $sql = "select * from liucheng"; $attr = $db->Query($sql); foreach($attr as $v) { echo "<option value=http://www.mamicode.com/‘{$v[0]}‘>{$v[1]}</option>"; } ?> </select> </div> <br /> <div> 请输入流程的详情: <textarea id="xq"></textarea> </div> <br /> <input type="button" value="http://www.mamicode.com/发起" id="btn" /> </body> <script type="text/javascript"> $("#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="http://www.mamicode.com/main.php"; } }); }) </script>
流程审核通过处理界面:
<?php session_start(); include("../fzl/czy.class.php"); $db = new czy(); $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");
流程例子
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。