>  기사  >  백엔드 개발  >  PHP 예제-php+ajax 초기화 프로세스 및 검토 프로세스(휴직을 예로 들어)

PHP 예제-php+ajax 초기화 프로세스 및 검토 프로세스(휴직을 예로 들어)

微波
微波원래의
2017-06-28 12:46:531097검색

이번 글은 주로 php+ajax 초기화 과정과 검토 과정을 소개합니다(휴가를 예로 들어요). 필요하신 친구들은 참고하시면 됩니다

새 프로세스를 만드는 방법은 이전 에세이에서 언급했으니 이제 살펴보도록 하겠습니다. 프로세스를 시작하고 프로세스를 검토하는 방법을 살펴보세요~~~

아이디어에 대해 먼저 이야기하겠습니다.

(1) 로그인하고 세션을 사용하여 사용자 ID를 가져옵니다

(2) 사용자가 시작합니다. a process

참고: 신청 이유를 작성해야 합니다点 (3) 노드의 검토자가 차례로 검토를 진행합니다. 참고: 각 검토가 통과되며 최종 검토 시 해당 Towhere 필드가 추가되어야 합니다. 끝나지 않았음을 나타냄)

세 개의 테이블을 공유합니다:

1단계: 먼저 간단한 로그인 페이지를 만들고 세션을 사용하여 사용자 이름을 가져옵니다:

denglu.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>

 denglu-cl. php 페이지

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

렌더링:

2단계: 간단한 노트 페이지 만들기: liucheng.php

<!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>
 <p id="body">
 <h2>主页面</h2>
 <p>
  <a href="faqi.php" rel="external nofollow" >发起流程</a><br />
  <a href=&#39;shenhe.php&#39;>审核流程</a>
 </p>
 </p>
 </body>
</html>
렌더링:

3단계: 프로세스 페이지 시작 faqi.php

(1 ) 먼저 , 드롭다운 목록에 모든 프로세스 표시

(2) 프로세스 시작 이유는 로그인한 사용자가 입력해야 합니다

<!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>
 <p 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=&#39;{$v[0]}&#39;>{$v[1]}</option>"; 
   }   
  ?>
  </select><br />
  发起流程事由:
  <textarea class="nr"> </textarea><br />
  <input type="button" value="确定发起" /> 
  </form>
 </p>
 </body>
</html>

4단계: 프로세스 시작을 위한 처리 페이지 작성 fq-cl.ph

<?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 (&#39;&#39;,&#39;{$code}&#39;,&#39;{$uid}&#39;,&#39;{$nr}&#39;,0,&#39;{$time}&#39;,0)";
$db->query($sql,0);
header("location:liucheng.php");
?>

"시작 확인"을 클릭하면 이 데이터가 데이터베이스에 추가됩니다

5단계: 프로세스 검토 페이지 shenhe.php

사용된 지식 포인트: 하위 쿼리: 관련 없는 하위 쿼리(하위 쿼리 및 상위 쿼리) 쿼리는 독립적으로 실행 가능) ; 관련 하위 쿼리(하위 쿼리의 조건은 상위 쿼리의 내용을 사용함)

<!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>
 <p 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=&#39;{$uid}&#39;) and towhere >=(select orders from liuchengjiedian b where b.code = a.code and b.uids = &#39;{$uid}&#39;)";
  $arr = $db->query($sql);
  //var_dump($arr);
  echo "<table border=&#39;1&#39; width=&#39;100%&#39; cellpadding=&#39;0&#39; cellspacing=&#39;0&#39;>
    <tr>
    <td>流程代号</td>
    <td>发起者</td>
    <td>发起内容</td>
    <td>发起时间</td>
    <td>是否结束</td>
    <td>操作</td>
    </tr>";
  foreach($arr as $v){
   //操作最后一列
   //设置默认项
   $zt = "<a href=&#39;tongguo-cl.php?code={$v[0]}&#39;>审核未通过</a>";
   $sql = "select orders from liuchengjiedian where code =&#39;{$v[1]}&#39; and uids =&#39;{$uid}&#39;";
   $wz = $db->strquery($sql);
   if($v[6]>$wz)
   {
   $zt = "<span style=&#39;color:green&#39;>审核已通过</span>";
   }
   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>";  
  ?>
 </p>
 </body>
</html>

 6단계: tongguo-cl.php 페이지 작성(중요)

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

이 단계 작성이 끝나면 다음을 클릭하세요. "검토 승인되지 않음" "통과"는 "감사 통과"가 됩니다.

효과를 처음부터 확인해 보겠습니다.

첫 번째: 새로운 휴가 프로세스 시작:

두 번째: zhangsan이 첫 번째입니다. 검토할 사람

"검토 실패 후"를 클릭하고,

마지막으로: zhaoliu가 마지막 검토자입니다

"검토 실패"를 클릭한 후, end 가 1이 됩니다. 녹색 "Audit Passed"로 변경됩니다~~

위는 편집자가 소개한 php+ajax 초기화 프로세스와 리뷰 프로세스입니다(예를 들어). 모두에게 도움이 됩니다. 질문이 있으시면 메시지를 남겨주세요. 그러면 편집자가 제 시간에 답변해 드릴 것입니다!

위 내용은 PHP 예제-php+ajax 초기화 프로세스 및 검토 프로세스(휴직을 예로 들어)의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.