Process Control, is also a widely used in office automation and other internal custom processes and auditing functions. such as leave process Ah, apply for office supplies funds, reimbursement applications Ah, and so on, need layers of approval through to complete (according to the regulations, best not leapfrog, you say yes)
Not accustomed to a blog too long, see, this article we first realize the process of new
Look first.
1. There is a drop-down select User, which can be added sequentially to the node location of the process.
2. Show each node of the process below
3. Fill in the process name, click Save to complete the new process
The database requires three tables, 1. User table 2. Process table 3. Process Node Table
Select Users and Add Nodes button
<Div>Please select User:<SelectID= "SEL"> <?php session_start (); Require ". /database.class.php "; $db =new DataBase (); $sql = "SELECT * from users"; $arr = $db->query ($sql); foreach ($arr as $v) {echo "<option>{$v [2]}</option>"; } ?> </Select><inputtype= "button"ID= "Add"value= "Add to process node"/></Div><BR/><Div>
Add an event to a button
1 $ ("#add"). Click (function () {2 var uid=$ ("#sel"). Val ();3 $.ajax ({4 URL: "addjd.php",5 Data:{uid:uid},6 type: "POST",7 dataType: "TEXT",8 success:function (data) {9 Ten One window.location.href= "newbuild.php"; A } - - the - }) -});
Handling Page addjd.php
1<?PHP2 Session_Start();3 $uid=$_post["UID"];4 if(Empty($_session["UID"]))5 {6 $arr=Array($uid);7 $_session["UID"]=$arr;8 }9 Else{Ten One $arr=$_session["UID"]; A $arr[]=$uid; - $_session["UID"]=$arr; - the } - -?>
Load node Information
<div><?PHPif(Empty($_session["UID"])){ Echo"You have not added any nodes"; }Else{ $arr 2=$_session["UID"]; foreach($arr 2 as $k=$v) { $sql 2= "SELECT name from users where Uid= ' {$v}‘"; $name=$db->query ($sql 2); Echo"<div>{$k}----{$v}<input type= ' button ' value= ' delete ' sy= ' {$k} ' class= ' Yichu '/></div> '; } }?></div>
Triggered events that are deleted
1$ (". Yichu"). Click (function (){2 varsy=$ ( This). attr ("Sy");3 $.ajax ({4URL: "removejd.php",5 Data:{sy:sy},6Type: "POST",7DataType: "TEXT",8Successfunction(data) {9window.location.href= "newbuild.php";Ten One A } - - the - }) - - + - +});
Removal of processing pages
<? PHP Session_Start (); $sy=$_post["Sy"]; $arr=$_session["UID"]; unset ($arr[$sy]); // To move an array of divisor elements $arr=array_values($arr// Rebuild index $_session["UID"] =$arr;? >
Saved pages and click events
1 <Div>2Please enter a name for the new process:<inputtype= "text"ID= "Shuru" /><BR/>3 4 <inputtype= "button"value= "Save"ID= "Save" />5 6 </Div>7 <Script>8 $("#save"). Click (function (){9 varMingcheng=$("#shuru"). Val ();Ten $.ajax ({ One URL:"save.php", A Data:{mingcheng:mingcheng}, - Type:"POST", - DataType:"TEXT", the Success:function(data) - { - Alert ("saved successfully") - } + - + A }) at - - - - - }) in - to + </Script>
Saved processing pages
1<?PHP2 Session_Start();3 $name=$_post["Mingcheng"];4 $code= Time();5 6 require".. /database.class.php ";7 $db=NewDataBase ();8 $sql= "INSERT into Liucheng values (' {$code}‘,‘{$name}‘)";9 $db->query ($sql, 0);Ten One A $arr=$_session["UID"]; - foreach($arr as $k=$v) - { the $sql 2= "INSERT into Flowpath values ('", ' {$code}‘,‘{$v}‘,‘{$k}‘)"; - $db->query ($sql 2, 0); - } - +?>
PHP Process Control (new process)