倡导流程和检查核对流程,ajax发起流程和调查流

2019-07-07 03:32 来源:未知

正文实例为大家大快朵颐了ajax和PHP达成轻松的流水生产线管理,供大家仿照效法,具体内容如下

上一篇小说中早已关系如何新建流程,那么今后大家就来看一下什么样发起一个流水生产线和检查核对流程~~~

上一篇博文是新建流程,此篇是流程管理的继续内容:发起流程和审查流程

第一要先有一个新建流程的页面xinjian.php

先说一下思路:

 一. 发起流程和检查核对流程供给选取的三张表

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>新建</title>
<script src="../FENGZHUANG/jquery-3.1.1.min.js"></script>
</head>

<body>
<h1>新建流程</h1>

<div>
请选择节点人员:
<select id="user">
 <?php
 session_start();//需要将一些数据暂时存在session里
 include("../FENGZHUANG/DBDA.class.php");
 $db = new DBDA();

 $sql = "select * from users";
 $arr = $db->Query($sql);
 foreach($arr as $v)
 {
  echo "<option value='{$v[0]}'>{$v[2]}</option>";
 }
 ?>
</select>
<input type="button" value="添加节点" id="add" />
</div>
<br />
<div>
 <?php
 if(!empty($_SESSION["user"]))
 {
  $attr = $_SESSION["user"];
  foreach($attr as $k=>$v) //索引为$k,取值为$v
  {
   $sname = "select name from users where uid='{$v}'"; //取出名称
   $name = $db->StrQuery($sname);
   echo "<div>{$k}--{$name}--<input type='button' value='删除' key='{$k}' class='del' /></div>"; //向处理页面传的是key的值
  }
 }
 ?>
</div>
<br />
<div>请输入流程名称:<input type="text" id="name" /></div>
<br />
<input type="button" value="保存" id="btn" />


</body>
<script type="text/javascript">
//添加节点按钮加点击
$("#add").click(function(){
  var uid = $("#user").val();
  $.ajax({
   url:"chuli.php",
   data:{uid:uid,type:0}, //传入一个type参数,以确保在同一页面处理时与其它的分开处理
   type:"POST",
   dataType:"TEXT",
   success: function(data){
     window.location.href="xinjian.php" rel="external nofollow" rel="external nofollow" ; //刷新页面
    }
   });
 })

//给删除按钮加点击
$(".del").click(function(){
  var key = $(this).attr("key"); //取删除的是哪条数据
  $.ajax({
   url:"chuli.php",
   data:{key:key,type:1},
   type:"POST",
   dataType:"TEXT",
   success:function(data){
    window.location.href="xinjian.php" rel="external nofollow" rel="external nofollow" ;
    }
   });
 })
//给保存按钮加点击
$("#btn").click(function(){
  var name = $("#name").val(); //取输入框中输入内容的值
  $.ajax({
   url:"chuli.php",
   data:{name:name,type:2},
   type:"POST",
   dataType:"TEXT",
   success:function(data){
     alert("保存成功!");
    }
   });
 })
</script>
</html>

(1)登入用session获取到用户的id

图片 1

图片 2

 (2) 用户发起八个流程

图片 3

数据库图片:

         注意:供给写申请事由

图片 4

图片 5

(3)处于节点的考察人去每家每户核实

二.写代码

图片 6

          注意:每检查核对通过一个,对应towhere字段要加1; 检查核对到最终时,对应的isok字段要造成1(此处1表示截至,0象征未停止)

1. 用ajax做了三个报到页面,用session获取用户名:

图片 7

共用到三张表:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="../jquery-3.2.0.min.js"></script>
<title>无标题文档</title>
</head>

<body>
<h1>登录页面</h1>

<form action="dlchuli.php" method="post">
<div>用户名:<input type="text" id="uid" /></div>
<div>密码:<input type="password" id="pwd" /></div>
<input type="button"  value="登录" id="btn" />
</form>

</body>

<script type="text/javascript"> //!!!用ajax之前一定先引用jqery
$("#btn").click(function(){  //对登录按钮添加单击事件
  var uid=$("#uid").val();  //获取用户的值
  var pwd=$("#pwd").val();  //获取密码的值
  $.ajax({
            url:"dlchuli.php",  //编写登录的处理页面
            data:{uid:uid,pwd:pwd},  //将用户和密码传到处理页面
            type:"POST",
            dataType:"TEXT",
            success: function(data)
            {
              if(data.trim()=="OK")
              {
                window.location.href="main.php";    //处理页面执行成功后,跳转到主页面
              }
              else
              {
                alert("用户名或密码输入错误");  //否则就提示错误
              }
            }
       })      
})
</script>
</html>

图片 8

图片 9

 2.登入分界面包车型大巴拍卖页面 dlchuli.php

管理页面chuli.php

第一步:先做八个简便的报到页面,用session获取用户名:

<?php
session_start(); 
require "../DBDA.class.php"; 
$db = new DBDA();  //造新对象
//传过来的值
$uid = $_POST["uid"];
$pwd = $_POST["pwd"];
//查询语句
$sql = " select pwd from users where uid='{$uid}' and pwd='{$pwd}'";
//执行语句
$attr = $db->query($sql,1);
if(!empty($pwd) && !empty($attr) && $attr[0][0]==$pwd)
{
    $_SESSION["uid"] =$uid; //session接收用户值
    echo "OK";
}
else
{
    echo "NO";
}
<?php
session_start();
include("../FENGZHUANG/DBDA.class.php");
$db = new DBDA();

$type = $_POST["type"];

switch($type)
{
 case 0://添加节点的加载数据,向session数组中添加数据
  $uid = $_POST["uid"];
  if(empty($_SESSION["user"]))
  {
   $arr = array($uid);
   $_SESSION["user"] = $arr;
  }
  else
  {
   $arr = $_SESSION["user"];
   array_push($arr,$uid);
   $_SESSION["user"] = $arr;
  }
  break;

 case 1://取节点的索引,然后删除,重新索引
  $key = $_POST["key"];
  $arr = $_SESSION["user"];
  unset($arr[$key]); //删除
  $arr = array_values($arr); //重新索引
  $_SESSION["user"] = $arr;
  break;

 case 2:
  $name = $_POST["name"];
  $code = time();
  //添加流程
  $sql = "insert into liucheng values('{$code}','{$name}')";
  $db->Query($sql,0);
  //添加流程节点
  $arr = $_SESSION["user"];
  foreach($arr as $k=>$v)
  {
   $sql = "insert into flowpath values('','{$code}','{$v}','{$k}')";
   $db->Query($sql,0);
  }
  break;

 case 3: //用户发起流程
  $code = $_POST["code"];
  $nr = $_POST["content"];
  $uid = $_SESSION["uid"];
  $time = date("Y-m-d H:i:s");
  $sql = "insert into userflow values('','{$code}','{$uid}','{$nr}',0,'{$time}',0)";
  $db->Query($sql,0);
  break;

}

denglu.php页面

      图片 10           图片 11

倡议流程页面faqi.php

<!DOCTYPE html>
<html>
 <head>
 <meta charset="UTF-8">
 <title></title>
 </head>
 <body>
 <form method="post" action="denglu-cl.php">
  用户名:<input type="text" name="uid" /><br />
  密码:<input type="password" name="pwd" /><br />
  <input type="submit" value="登录" />
 </form>
 </body>
</html> 

3.主页面 main.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>发起流程</title><br />
<script src="../FENGZHUANG/jquery-3.1.1.min.js"></script>

</head>

<body>

<h1>发起流程</h1>

<div>
请选择发起的流程:
 <select id="liucheng">
  <?php
  session_start();
  include("../FENGZHUANG/DBDA.class.php");
  $db = new DBDA();
  $sql = "select * from liucheng";
  $arr = $db->Query($sql);
  foreach($arr as $v)
  {
   echo "<option value='{$v[0]}'>{$v[1]}</option>";
  }
  ?>
 </select>
</div>
<br />
<div>
请输入内容:
 <textarea id="nr"></textarea>
</div>
<br />
<input type="button" value="发起" id="btn" />


</body>
<script type="text/javascript">
$("#btn").click(function(){
  var code = $("#liucheng").val();
  var content = $("#nr").val();

  $.ajax({
   url:"chuli.php",
   data:{code:code,content:content,type:3},
   type:"POST",
   dataType:"TEXT",
   success: function(data){
    alert("发起成功!");
    }   
   });
 })
</script>
</html>

  denglu-cl.php页面

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<h1>主页面</h1>

<div><a href="faqi.php">发起流程</a> <a href="shenhe.php">审核流程</a></div>

</body>
</html>

图片 12

<?php
session_start();
require "../DB.class.php";
$db = new DB();
$uid = $_POST["uid"];
$pwd = $_POST["pwd"];
$sql = "select pwd from users where uid='{$uid}'";
$mm = $db->strquery($sql);
if($pwd==$mm && !empty($pwd))
{
 $_SESSION["uid"]=$uid;
 header("location:liucheng.php");
}
else
{
 echo "密码或登录名输入错误";
}
?> 

 图片 13

核算页面shenhe.php

  效果图:

4.倡议流程页面 faqi.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>审核</title>
</head>

<body>
<h1>审核页面</h1>
<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("../FENGZHUANG/DBDA.class.php");
 $db = new DBDA();
 $uid = $_SESSION["uid"];
 echo $uid;
 //查找登录者参与的所有流程
 $sql = "select * from userflow where code in(select code from flowpath where uids='{$uid}')";
 $arr = $db->Query($sql);

 //显示
 foreach($arr as $v)
 {
  //判断该流程走到登录者
  $lcdh = $v[1]; //流程代号
  $towhere = $v[6];//流程走到哪
  $sql = "select orders from flowpath where code='{$lcdh}' and uids='{$uid}'";
  $order = $db->StrQuery($sql);//该人员在流程中的次序

  if($towhere>=$order)
  {
   $caozuo = "";
   if($towhere==$order)
   {
    $caozuo="<a href='tongguo.php?code={$v[0]}'>通过</a>";
   }
   else
   {
    $caozuo="已通过";
   }
   echo "<tr>
  <td>{$v[1]}</td>
  <td>{$v[2]}</td>
  <td>{$v[3]}</td>
  <td>{$v[4]}</td>
  <td>{$v[5]}</td>
  <td>{$caozuo}</td> 
 </tr>";
  }

 }
 ?>
</table>
</body>
</html>

图片 14

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<h1>发起流程</h1>

<form action="fqchuli.php" method="post">
<div>请选择发起的流程:
    <select name="lc">
        <?php
        require "../DBDA.class.php";
        $db = new DBDA();
        $sql = "select * from liucheng";
        $arr = $db->query($sql,1);
        foreach($arr as $v)
        {
            echo "<option value='{$v[0]}'>{$v[1]}</option>";
        }
        ?>
    </select>
</div>
<br />
<div>
请输入发起的内容:<textarea name="nr"></textarea>
</div>
<br />
<input type="submit" value="发起" />
</form>

</body>
</html>

图片 15

第二步:做个简单的注页面:liucheng.php

 5.发起流程管理页面 fqchuli.php

图片 16

<!DOCTYPE html>
<html>
 <head>
 <meta charset="UTF-8">
 <title></title>
 <style>
  #body{
  height: 200px;
  width: 300px;
  background-color: gainsboro;
  margin: 200px auto;
  text-align: center;
  vertical-align: middle;
  line-height: 30px;
  }
 </style>
 </head>
 <body>
 <div id="body">
 <h2>主页面</h2>
 <div>
  <a href="faqi.php" rel="external nofollow" >发起流程</a><br />
  <a href='shenhe.php'>审核流程</a>
 </div>
 </div>
 </body>
</html> 
<?php
session_start();
require "../DBDA.class.php";
$db = new DBDA();

$code =$_POST["lc"];
$nr =$_POST["nr"];

$uid = $_SESSION["uid"];
$time =date("Y-m-d H:i:s");

$sql = "insert into userflow values('','{$code}','{$uid}','{$nr}',0,'{$time}',0)";
$db->query($sql);

header("location:main.php");

图片 17

 效果图:

 图片 18

图片 19

图片 20

点击“发起”,数据库中就能够增加此条数据

图片 21

其三步:发起流程页面faqi.php

6.流程调查页面 shenhe.php

图片 22

(1)先将具有流程用下拉列表展现

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<h1>流程审核页面</h1>

<?php
session_start();
$uid = $_SESSION["uid"];
require "../DBDA.class.php";
$db = new DBDA();

$sql = "select * from userflow a where code in(select code from flowpath where uids='{$uid}') 
and towhere >=(select orders from flowpath b where b.code=a.code and b.uids='{$uid}' )" ;

$arr = $db->query($sql,1);

echo "<table width='100%' border='1' cellpadding='0' cellspacing='0'>
    <tr>
        <td>流程代号</td>
        <td>发起者</td>
        <td>发起内容</td>
        <td>是否结束</td>
        <td>发起时间</td>
        <td>操作</td>
    </tr>
";
foreach($arr as $v)
{
    $zt = "<a href='tongguo.php?code={$v[0]}'>通过</a>";
    $sql = "select orders from flowpath where code='{$v[1]}' and uids='{$uid}'";
    $wz = $db->strquery($sql);
    if($v[6]>$wz)
    {
        $zt = "已通过";
    }


    echo "<tr>
        <td>{$v[1]}</td>
        <td>{$v[2]}</td>
        <td>{$v[3]}</td>
        <td>{$v[4]}</td>
        <td>{$v[5]}</td>
        <td>{$zt}</td>
    </tr>";
}

echo "</table>";

?>


</body>
</html>

tongguo.php

(2)发起流程事由索要由登陆用户填写

 7.写检查核对管理页面 tongguo.php(*)

<?php
session_start();
include("../FENGZHUANG/DBDA.class.php");
$db = new DBDA();

//流程往下走
$code = $_GET["code"];
$sql = "update userflow set towhere=towhere 1 where ids='{$code}'"; //使流程向下走
$db->Query($sql,0);

//判断流程是否结束
$sql = "select * from userflow where ids='{$code}'";
$arr = $db->Query($sql);

$lcdh = $arr[0][1]; //流程代号
$tw = $arr[0][6]; //流程走到哪

$sql = "select count(*) from flowpath where code='{$lcdh}'";
$count = $db->StrQuery($sql); //该流程节点人数
if($tw>=$count)
{
 $sql = "update userflow set isok=1 where ids='{$code}'"; //如果结束了流程,将isok项改为结束。
 $db->Query($sql,0);
}


header("location:shenhe.php");
<!DOCTYPE html>
<html>
 <head>
 <meta charset="UTF-8">
 <title></title>
  <style>
  #body{
  height: 250px;
  width: 300px;
  background-color: gainsboro;
  margin: 200px auto;
  text-align: left;
  vertical-align: middle;
  line-height: 30px;
  padding-left: 30px;
  }
 </style>
 </head>
 <body>
 <div id="body">
  <form method="post" action="faqi-cl.php">
  <h2>发起流程页面</h2>
  <select id="lc">
  <?php
   require "../DB.class.php";
   $db = new DB();
   $sql = "select * from liucheng";
   $arr = $db->query($sql);
   foreach($arr as $v)
   {
   echo "<option value='{$v[0]}'>{$v[1]}</option>"; 
   }   
  ?>
  </select><br />
  发起流程事由:
  <textarea class="nr"> </textarea><br />
  <input type="button" value="确定发起" /> 
  </form>
 </div>
 </body>
</html> 

 

上述正是本文的全体内容,希望对大家的求学抱有协理,也冀望我们多多帮助脚本之家。

图片 23

<?php
$ids = $_GET["code"];
require "../DBDA.class.php";
$db = new DBDA();

//让流程往下走,每审核通过一个,对应towhere字段要加1
$sql = "update userflow set towhere = towhere 1 where ids='{$ids}'";
$db->query($sql);

//判断流程是否结束
$sql = "select max(orders) from flowpath where code=( select code from userflow where ids='{$ids}')";
$maxsx = $db->strquery($sql);

$sql = "select towhere from userflow where ids='{$ids}'";
$towhere = $db->strquery($sql);

if($towhere>$maxsx)
{
    //如果结束了,修改状态 ;审核到最后时,对应的isok字段要变为1(此处1表示结束,0表示未结束)
    $sql = "update userflow set isok = 1 where ids='{$ids}'";
    $db->query($sql);
}


header("location:shenhe.php");

你或然感兴趣的篇章:

  • php ajax发起流程和核实流程(以请假为例)

第四步:写发起流程的管理页面fq-cl.php

 

<?php
session_start();
require "../DB.class.php";
$db = new DB();
$code = $_POST["lc"];
$nr =$_POST["nr"];
$uid = $_SESSION["uid"];
$time = date("Y-m-d H:i:s",time());
$sql = "insert into liuchengpath values ('','{$code}','{$uid}','{$nr}',0,'{$time}',0)";
$db->query($sql,0);
header("location:liucheng.php");
?> 

 当写好这一步时,点击“通过”则会产生“已经过”;

  点击“确认发起”,数据库中就能加多此条数据

zhangsan是首先个考察人,从zhangsan起始逐项核查

图片 24

图片 25

第五步:流程检查核对页面shenhe.php

图片 26

用到知识点:子查询:非亲非故子查询(子查询和父查询能够单独实施); 相关子查询(子查询里的标准使用到了父查询的某部东西   )

 

<!DOCTYPE html>
<html>
 <head>
 <meta charset="UTF-8">
 <title></title>
  <style>
  #body{
  height: 450px;
  width: 800px;
  background-color: gainsboro;
  margin: 200px auto;
  text-align: left;
  vertical-align: middle;
  line-height: 30px;
  padding-left: 30px;
   }
 </style>
 </head>
 <body>
 <div id="body">
  <h2>流程审核页面</h2>
  <?php
  session_start();
  $uid = $_SESSION["uid"];
  require "../DB.class.php";
  $db = new DB();
  //先取该用户参与的所有流程
  //并且取流程步骤到达该用户或已经被改用户审核通过的记录
  $sql="select * from liuchengpath a where code in(select code from liuchengjiedian where uids='{$uid}') and towhere >=(select orders from liuchengjiedian b where b.code = a.code and b.uids = '{$uid}')";
  $arr = $db->query($sql);
  //var_dump($arr);
  echo "<table border='1' width='100%' cellpadding='0' cellspacing='0'>
    <tr>
    <td>流程代号</td>
    <td>发起者</td>
    <td>发起内容</td>
    <td>发起时间</td>
    <td>是否结束</td>
    <td>操作</td>
    </tr>";
  foreach($arr as $v){
   //操作最后一列
   //设置默认项
   $zt = "<a href='tongguo-cl.php?code={$v[0]}'>审核未通过</a>";
   $sql = "select orders from liuchengjiedian where code ='{$v[1]}' and uids ='{$uid}'";
   $wz = $db->strquery($sql);
   if($v[6]>$wz)
   {
   $zt = "审核已通过";
   }
   echo "<tr>
    <td>{$v[1]}</td>
    <td>{$v[2]}</td>
    <td>{$v[3]}</td>
    <td>{$v[4]}</td>
    <td>{$v[5]}</td>
    <td>{$zt}</td>
   </tr>";   
  }
  echo "</table>";  
  ?>
 </div>
 </body>
</html> 

niuniu是最终三个调查人,结束突显1

  第六步:写tongguo-cl.php页面(重要)

图片 27

<?php
$ids = $_GET["code"];
require "../DB.class.php";
$db = new DB();
//点击审核后,towhere列加1,目的是使流程向下走
$sql = "update liuchengpath set towhere = towhere 1 where ids ='{$ids}' ";
$db->query($sql,0);
//当流程走到最后一个审核的人时,流程要结束
//获取该流程最大的orders
$sql =" select max(orders) from liuchengjiedian where code = (select code from liuchengpath where ids ='{$ids}')";
$maxorders = $db->strquery($sql);
//获取该用户处于哪个位置,也就是towhere等于多少
$sql ="select towhere from liuchengpath where ids ='{$ids}'";
$towhere = $db->strquery($sql);
//判断是否已到达最后一个审核的人
if($towhere>$maxorders)
{
 $sql = "update liuchengpath set isok=1 where ids='{$ids}'";
// var_dump($sql);
 $db->query($sql,0);
}
header("location:shenhe.php");
?> 

图片 28

  当写好这一步时,点击“调查未通过”则会形成“调查已由此”;

END

图片 29

大家从头来验证一下效率:

先是:发起三个新的请假流程:

图片 30 图片 31

附带:zhangsan是首先个要调查人

图片 32

图片 33

点击“调查未通过后“,

图片 34

末尾:zhaoliu是最后多少个考察人

图片 35

图片 36

点击“调查未经过”后,是还是不是得了变为  1 ;操作变为土褐的  “考察已因而”~~~

图片 37

以上所述是我给大家介绍的php ajax发起流程和调查流程(以请假为例),希望对我们持有支持,倘诺大家有其它问题迎接给本人留言,作者会及时回复我们的!

您恐怕感兴趣的稿子:

  • 使用ajax和PHP实现轻便的流水生产线管理
版权声明:本文由韦德娱乐1946_韦德娱乐1946网页版|韦德国际1946官网发布于网络编程,转载请注明出处:倡导流程和检查核对流程,ajax发起流程和调查流