5月29日 流程
Posted D董小姐
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了5月29日 流程相关的知识,希望对你有一定的参考价值。
这是类似批条似的审核流程,登陆者可以通过登录,在新建流程页面选择要批复的人形成节点,流程名称,提交到数据库;在发起流程页面,写入内容,提交到数据库,节点人员依次进行审核,直至完成。
log.php:
<body> <form action="logchuli.php" method="post"> <div>用户名:<input type="text" name="uid" /></div> <div>密码:<input type="text" name="pwd" /></div> <input type="submit" value="登录" /> </form> </body>
logchuli.php:
<?php session_start(); include("../DBDA.class.php"); $db = new DBDA(); $username = $_POST["uid"]; $pwd = $_POST["pwd"]; $sql = "select count(*) from userso where username=‘{$username}‘ and password=‘{$pwd}‘"; $r = $db->StrQuery($sql); if($r==1) { $_SESSION["username"]=$username; header("location:main.php"); } else { header("location:log.php"); }
main.php:
<?php session_start(); if(empty($_SESSION["username"])) { header("location:log.php"); } include("../DBDA.class.php"); $db = new DBDA(); ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style type="text/css"> #menue { width:100%; height:30px; } .z { width:100%; height:30px; float:left; } </style> </head> <body> <br /><br /> <center><h1>主页面</h1><center> <br /> <div id="menue"> <div class="z"><a href="xinjian.php">新建流程</a></div> <div class="z"><a href="faqi.php">发起流程</a></div> <div class="z"><a href="shenhe.php">审核流程</a></div> </div> </body>
xinjian.php:
<head> <script src="../jquery-2.2.3.min.js"></script> </head> <body> <?php session_start(); include("../DBDA.class.php"); $db = new DBDA(); $attr = array(); if(!empty($_SESSION["jiedian"])) { $attr = $_SESSION["jiedian"]; } ?> <h1>新建流程</h1> <div> 请选择节点人员: <?php $sry = "select * from userso"; $ary = $db->Query($sry); foreach($ary as $v) { echo "<input name=‘ry‘ class=‘ry‘ type=‘radio‘ value=‘{$v[0]}‘ /> {$v[2]}"; } ?> </div> <br /> <div> <input type="button" value="添加节点" id="tjjd" /> </div> <br /> <div> <?php foreach($attr as $k=>$v) { $sname = "select name from userso where username=‘{$v}‘"; $name = $db->StrQuery($sname); echo "<div>{$k}--{$name}--<input type=‘button‘ value=‘删除‘ bs=‘{$k}‘ class=‘sc‘ /></div>"; } ?> </div> <br /> <div> 请输入流程名称: <input type="text" id="mc" /> </div> <br /> <div> <input type="button" value="添加" id="add" /> </div> <a href="main.php">返回</a> </body> <script type="text/javascript"> $(document).ready(function(e) { //设置默认选中第一项 $(".ry").eq(0).prop("checked",true); //添加节点按钮点击事件 $("#tjjd").click(function(){ var rd = $(".ry"); for(var i=0;i<rd.length;i++) { if(rd.eq(i).prop("checked")) { uid = rd.eq(i).val(); } } $.ajax({ url:"tjjd.php", data:{uid:uid}, type:"POST", dataType:"TEXT", success: function(data){ window.location = "xinjian.php"; } }); }) //删除节点事件 $(".sc").click(function(){ var id = $(this).attr("bs"); $.ajax({ url:"scjd.php", data:{id:id}, type:"POST", dataType:"TEXT", success: function(data){ window.location = "xinjian.php"; } }); }) //添加流程 $("#add").click(function(){ var name = $("#mc").val(); $.ajax({ url:"tjlc.php", data:{name:name}, type:"POST", dataType:"TEXT", success: function(data){ if(data.trim()=="OK") { alert("添加成功"); } else { alert("添加失败"); } } }); }) }); </script>
tjjd.php:
<?php session_start(); include("../DBDA.class.php"); $db = new DBDA(); $uid = $_POST["uid"]; if(empty($_SESSION["jiedian"])) { $attr = array($uid); $_SESSION["jiedian"] = $attr; } else { $attr = $_SESSION["jiedian"]; array_push($attr,$uid); $_SESSION["jiedian"] = $attr; }
scjd.php:
<?php session_start(); $id = $_POST["id"]; $attr = $_SESSION["jiedian"]; unset($attr[$id]); $attr = array_values($attr); $_SESSION["jiedian"]=$attr;
tjlc.php:
<?php session_start(); include("../DBDA.class.php"); $db = new DBDA(); $attr = array(); if(!empty($_SESSION["jiedian"])) { $attr = $_SESSION["jiedian"]; } $name = $_POST["name"]; //向流程表中添加数据 $code = date("YmdHis"); $sql = "insert into liucheng values(‘{$code}‘,‘{$name}‘)"; //判断是否执行成功的变量 $isok = true; if($db->Query($sql,0)) { foreach($attr as $k=>$v) { //向流程对应节点表添加数据 $sfl = "insert into flowpath values(‘‘,‘{$code}‘,‘{$v}‘,{$k})"; $isok = $isok && $db->Query($sfl,0); } } if($isok) { echo "OK";; } else { echo "NO"; }
faqi.php:
<head> <script src="../jquery-2.2.3.min.js"> </script> </head> <body> <?php include("../DBDA.class.php"); $db = new DBDA(); ?> <h1>发起流程</h1> <div> 请选择流程: <select id="lc"> <?php $sql = "select * from liucheng"; $str = $db->Query($sql); foreach($str as $v) { echo "<option value=‘{$v[0]}‘>{$v[1]}</option>"; } ?> </select> </div> <br /> <div> 请输入内容: <textarea id="nr" style="width:300px; height:200px"> </textarea> </div> <br /> <input type="button" value="发起" id="fq" /> <br /> <a href="main.php">返回</a> </body> <script type="text/javascript"> $(document).ready(function(e) { $("#fq").click(function(){ var code = $("#lc").val(); var nr = $("#nr").val(); $.ajax({ url:"fqcl.php", data:{code:code,nr:nr}, type:"POST", dataType:"TEXT", success: function(data){ if(data.trim()=="OK") { alert("发起成功"); } else { alert("发起失败"); } } }); }) }); </script>
fqcl.php;
<?php session_start(); include("../DBDA.class.php"); $db = new DBDA(); $code = $_POST["code"]; $nr = $_POST["nr"]; $username = $_SESSION["username"]; $rq = date("Y-m-d H:i:s"); $sql = "insert into userflow values(‘‘,‘{$code}‘,‘{$username}‘,‘{$nr}‘,false,‘{$rq}‘,0)"; if($db->Query($sql,0)) { echo "OK"; } else { echo "NO"; }
shenhe.php:
<?php session_start(); include("../DBDA.class.php"); $db = new DBDA(); ?> <body> <h1>审核流程</h1> <br /> <table width="100%" border="1" cellpadding="0" cellspacing="0"> <tr> <td>流程名称</td> <td>发起者</td> <td>内容</td> <td>是否结束</td> <td>发起时间</td> <td>操作</td> </tr> <?php $sql = "select * from userflow order by riqi desc"; $attr = $db->Query($sql); foreach($attr as $v) { //根据流程代号到flowpath表查登陆者在该流程中的次序 $sfl = "select code,orders from flowpath where code=‘{$v[1]}‘ and uids=‘{$username}‘"; $cx = $db->Query($sfl); if($cx) { $ucode = $cx[0][0];//流程代号 $ucx = $cx[0][1];//次序 //判断该流程是否走到该次序 if($v[1]== $ucode && $v[6]>=$ucx) { $lname = Lname($v[1]); $fname = Fname($v[2]); //处理是否结束 $isok = $v[4]?"已结束":"处理中"; //处理操作 $chuli = ""; if($v[6]==$uck) { $chuli="<a href=‘sh.php‘?id=‘{$v[0]}‘>审核</a>"; } else { $chuli="已通过"; } echo "<tr> <td>{$v[1]}</td> <td>{$v[2]}</td> <td>{$v[3]}</td> <td>{$isok}</td> <td>{$v[5]}</td> <td>{$chuli}</td> </tr>"; } } } //处理流程名 function Lname($code) { $sqln = "select name from liucheng where code = ‘{$code}‘"; return $db->StrQuery($sqln); } //处理发起者 function Fname($uid) { $sqln = "select name from userso where uid = ‘{$username}‘"; return $db->StrQuery($sqln); } ?> </table> </body>
sh.php:
<?php include("../DBDA.class.php"); $db = new DBDA(); $id = $_GET["id"]; $sql = "update userflow set towhere = towhere+1 where ids = ‘{$id}‘"; if($db->Query($sql,0)) { //查询流程走到哪了 $stw = "select code,towhere from userflow where ids=‘{$id}‘"; $atw = $db->Query($stw); $code = $atw[0][0];//流程代号 $tw = $atw[0][1];//流程到哪 //查询该流程的节点数 $sfp = "select count(*) from flowpath where code = ‘{%code}‘"; $sl = $db->StrQuery($sfp); //如果流程走到位置大于等于该流程中结点的数量 if($tw>=$sl) { $sok = "update userflow set isok = true where ids=‘{$id}‘"; $db->Query($sok,0); } header("location:shenhe.php"); } else { echo "审核失败"; }
以上是关于5月29日 流程的主要内容,如果未能解决你的问题,请参考以下文章