xinjian.php
<script src="../jquery-1.11.2.min.js"></script> <style type="text/css"> .biao { padding-left:550px; padding-top:30px; } .div { padding-left:400px; padding-top:20px; } .but { padding-top:20px; padding-left:400px; } </style> <?php session_start(); include("../dbda.php"); $db=new DBDA(); $suser="select * from users"; $auser=$db->Query($suser); ?> </head> <body> <div class="biao"> <h1>新建流程</h1> </div> <div class="div"> <div>请选择节点人员:</div><br /> <div> <?php foreach($auser as $v) { echo"<input type='radio' name='ry' class='ry' value='{$v[0]}'/>{$v[2]}"; } ?> </div><br /> <div class="but"> <input type="button" value="添加节点" id="addjiedian" /> </div><br /> <div id="jiedian"> <?php //判断session里面有没有存节点人员 if(!empty($_SESSION["jiedian"])) { //把session里面的节点人员取出来交给$attr $attr=$_SESSION["jiedian"]; 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='删除' class='del' bs='{$k}' /></div>"; } } ?> </div><br /> <div> 请输入流程名称: </div><br /> <div> <input type="text" id="name" /> </div><br /> <div class="but"> <input type="button" value="新建" /> </div> </div> </body> <script type="text/javascript"> $(document).ready(function(e) { $("#addjiedian").click(function(){ var uid=""; //找到所有的单选按钮 var rd=$(".ry"); for(var i=0;i<rd.length;i++) { //把选中的用户名取出 if(rd.eq(i).prop("checked")) { uid=rd.eq(i).val(); } } //调用ajax把选中的用户名存储到session里面去 $.ajax({ url:"chuli.php", data:{uid:uid,type:0}, type:"POST", dataType:"TEXT", success: function(data){ window.location="xinjian.php"; } }); }) //删除 $(".del").click(function(){ //取出索引 var id = $(this).attr("bs"); //调用ajax删除 $.ajax({ url:"chuli.php", data:{id:id,type:1}, type:"POST", dataType:"TEXT", success: function(data){ window.location = "xinjian.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 = "xinjian.php"; } }); }) }) </script>
chuli.php
<?php session_start(); include("../dbda.php"); $db=new DBDA(); //先取type $type=$_POST["type"]; //判断是哪一个ajax调用的 switch($type) { //将传过来的uid存到session里面 case 0: $uid=$_POST["uid"]; //判断session里面有没有 if(empty($_SESSION["jiedian"])) { $attr=array($uid); $_SESSION["jiedian"]=$attr; } else { $attr=$_SESSION["jiedian"]; //把uid存到attr数组里面 $attr[]=$uid; //把新的数组再存到session里 $_SESSION["jiedian"]=$attr; } break; case 1: $id = $_POST["id"]; $attr = $_SESSION["jiedian"]; unset($attr[$id]); //重新索引 $attr = array_values($attr); $_SESSION["jiedian"]=$attr; break; case 2: $name=$_POST["name"]; $code=date("YmdHis"); @$attr=$_SESSION["jiedian"]; $sadd="insert into liucheng values('{$code}','{$name}')"; $db->Query($sadd,1); foreach($attr as $v) { $saddpath="insert into flowpath values('','{$code}','{$v}','{$k}')"; $db->Query($saddpath,1); } break; }
faqi.php
<style type="text/css"> .biao { padding-left:500px; padding-top:30px; } .div { padding-left:400px; padding-top:20px; } .but { padding-top:20px; padding-left:800px; } </style> </head> <?php session_start(); include("../dbda.php"); $db=new DBDA(); if(empty($_SESSION["uid"])) { header("location:login.php"); exit; } $uid=$_SESSION["uid"]; //查出所有的流程 $sflow="select * from liucheng"; $aflow=$db->Query($sflow); ?> <body> <div class="biao"> <h1>用户发起流程</h1> </div> <div class="div"> <form action="faqichuli.php" method="post"> <div> 请选择要发起的流程: <select name="flow"> <?php foreach($aflow as $v) { echo"<option value='{$v[0]}'>{$v[1]}</option>"; } ?> </select> </div><br /> <div> 请输入要发起的内容: <textarea name="content" style="200px; height:100px"></textarea> </div><br /> </div> <div class="but"> <input type="submit" value="发起" /> </div> </form><br /> <div class="but"> <a href="shenhe.php">审核页面</a> <a href="chakan.php">查看页面</a> </div>
faqichuli.php
<?php session_start(); include("../dbda.php"); $db=new DBDA(); $code=$_POST["flow"]; $content=$_POST["content"]; $uid=$_SESSION["uid"]; $time=date("Y-m-d H:i:s"); $sql="insert into userflow value('','{$code}','{$uid}','{$content}',false,'{$time}',0) "; if($db->Query($sql,1)) { header("location:faqi.php"); }
<style type="text/css"> .biao { padding-left:550px; padding-top:30px; } .div { padding-left:200px; padding-top:20px; } </style> </head> <?php session_start(); include("../dbda.php"); $db=new DBDA(); if(empty($_SESSION["uid"])) { header("location:login.php"); exit; } $uid=$_SESSION["uid"]; //查询用户发起流程表中的所有数据,并按时间降序排列 $suflow="select *from userflow order by riqi desc"; $auflow=$db->Query($suflow); ?> <body> <div class="biao"> <h1>审核流程</h1> </div> <div class="div"> <table width="80%" border="1" cellpadding="0" cellspacing="0"> <tr height="35px" align="center" style="font-weight:bold"> <td>流程名称</td> <td>发起者</td> <td>流程内容</td> <td>是否结束</td> <td>发起时间</td> <td>操作</td> </tr> <?php foreach($auflow as $vuflow) { //取到流程代号 $flowcode=$vuflow[1]; //取到流程走到哪了 $towhere=$vuflow[6]; //根据流程代号和登录者用户名,查询该用户在该流程的次序号 $sorder="select orders from flowpath where code='{$flowcode}' and uids='{$uid}'"; $order=$db->StrQuery($sorder);//次序号 //判断该用户在流程中的次序号是否等于流程走到哪 if($towhere==$order) { //处理流程名称 $sflowname="select name from liucheng where code='{$flowcode}'"; $flowname=$db->strquery($sflowname);//流程名称 //处理发起者名称 $susername="select name from users where uid='{$vuflow[2]}'"; $username=$db->strquery($susername);//发起者姓名 //处理是否结束 $jieshu=$vuflow[4]?"<span style='background-color:red'>已结束</span>":"<span style='background-color:green'>进行中</span>"; echo"<tr height='30px' align='center'> <td>{$flowname}</td> <td>{$username}</td> <td>{$vuflow[3]}</td> <td>{$jieshu}</td> <td>{$vuflow[5]}</td> <td><a href='tongguo.php?code={$vuflow[0]}'>通过</a></td> </tr>"; } } ?> </table> </div>
tongguo.php
<?php include("../dbda.php"); $db=new DBDA(); $code=$_GET["code"]; $sql="update userflow set towhere = towhere+1 where ids='{$code}'"; if($db->Query($sql,1)) { $suflow="select * from userflow where ids='{$code}'"; $auflow=$db->Query($suflow); $flowcode=$auflow[0][1];//流程代号 $towhere=$auflow[0][6];//走到哪了 //根据流程代号查询该流程下人员的个数 $scount="select count(*) from flowpath where code='{$flowcode}'"; $count=$db->StrQuery($scount);//人员个数 //判断流程是否结束 if($towhere>=$count) { $sok="update userflow set isok=true where ids='{$code}'"; $db->Query($sok,1); } header("location:shenhe.php"); }
chakan.php
<style type="text/css"> .biao { padding-left:550px; padding-top:30px; } .div { padding-left:400px; padding-top:20px; } .ming { font-size:20px; } .name { padding-left:100px; } </style> </head> <?php session_start(); include("../dbda.php"); $db=new DBDA(); if(empty($_SESSION["uid"])) { header("location:login.php"); exit; } $uid=$_SESSION["uid"]; $sflow = "select code from userflow where uid ='{$uid}'"; $aflow = $db->Query($sflow); ?> <body> <div class="biao"> <h1>查看流程</h1> </div> <div class="div"> <?php foreach($aflow as $v) { //查询流程名称 $slna = "select name from liucheng where code = '{$v[0]}'"; $name = $db->StrQuery($slna); //查询某个流程的所有uid $spath = "select uids from flowpath where code = '{$v[0]}'"; $orders = $db->Query($spath); $attr = array(); //通过uid查询所有的姓名存到数组里面 foreach($orders as $c) { $sname = "select name from users where uid ='{$c[0]}'"; $attr[] = $db->StrQuery($sname); } ?> <div class="ming">流名称:<?php echo $name ?></div><br /> <div class="ming">审核人:</div> <div class="name"> <?php //遍历输出数组 foreach($attr as $b){ //通过流程代号查询towhere $sql = "select towhere from userflow where code ='{$v[0]}'"; $tow = $db->StrQuery($sql); //通过流程代号查询流程数量 $scount = "select count(*) from flowpath where code = '{$v[0]}'"; $row = $db->StrQuery($scount); //查询是否走完 if($tow>=$row) { echo "已完成"; break; } //通过流程代号和orders查询uid $suid = "select uids from flowpath where orders ='{$tow}' and code = '{$v[0]}'"; $auid = $db->StrQuery($suid); //通过uid查询姓名 $suidname = "select name from users where uid = '$auid'"; $aname = $db->StrQuery($suidname); ?> <?php //给姓名加效果 if($aname == $b) { echo "<b style='color:green;size:30px'>{$b} </b> "; } else { echo "<b style='size:25px'>$b </b> "; } } } ?> </div> </div>