主页面
<!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> <style type="text/css"> .menu { width:100px; height:30px; float:left; text-align:center; line-height:30px; vertical-align:middle; font-size:14px; color:white; } </style> </head> <body> <h1>主页面</h1> <div style="100%; height:30px; background-color:#6CF"> <div class="menu"><a href="xinjian.php">新建流程</a></div> <div class="menu"><a href="faqi.php">发起流程</a></div> <div class="menu"><a href="chuli.php">流程处理</a></div> </div> </body> </html>
登录
<!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="LoginChuLi.php" method="post">
<div>用户名:<input type="text" name="uid" /></div>
<div>密码:<input type="text" name="pwd" /></div>
<div><input type="submit" value="登录"/></div>
</form>
</body>
</html>
登录处理
<?php session_start(); $uid = $_POST["uid"]; $pwd = $_POST["pwd"]; include("DBDA.php"); $db = new DBDA(); $sql = "select count(*) from Users where Uid='{$uid}' and Pwd = '{$pwd}'"; if($db->StrQuery($sql)=="1") { $_SESSION["uid"] = $uid; header("location:Main.php"); } else { header("location:login.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="jquery-1.11.2.min.js"></script> </head> <body> <h1>新建流程</h1> <div> <div>请选择节点人员代号:</div> <br /> <div> <?php session_start(); include("DBDA.php"); $db = new DBDA(); $sqlu = "select * from Users"; $attru = $db->Query($sqlu); foreach($attru as $arru) { echo "<input type='radio' value='{$arru[0]}' class='user' name='user' />{$arru[2]} "; } ?> </div> <br /> <input type="button" value="添加节点" id="addjd" /> <br /> <br /> <div> <?php if(empty($_SESSION["user"])) { echo "当前节点人员为空!"; } else { $attr = $_SESSION["user"]; foreach($attr as $k=>$v) { $sqlname = "select Name from Users where Uid='{$v}'"; $name = $db->StrQuery($sqlname); echo "<div>{$k}--{$name}-<input type='button' value='删除' bs='{$k}' class='del' /></div>"; } } ?> </div> <br /> <div>请输入流程名称:<input type="text" id="lcname" /></div> <br /> <div><input type="button" id="sure" value="添加" /></div> </div><a href="Main.php">返回</a> <script type="text/javascript"> $(document).ready(function(e) { //添加节点 $("#addjd").click(function(){ var user = $(".user"); for(var i=0;i<user.length;i++) { if(user.eq(i)[0].checked) { var uid = user.eq(i).val(); $.ajax({ url:"Addjd.php", data:{uid:uid}, type:"POST", dataType:"TEXT", success: function(data){ window.location = "xinjian.php"; } }); } } }) //删除节点 $(".del").click(function(){ var code = $(this).attr("bs"); $.ajax({ url:"Del.php", data:{code:code}, type:"POST", dataType:"TEXT", success: function(data){ window.location = "xinjian.php"; } }); }) //新建流程 $("#sure").click(function(){ var name = $("#lcname").val(); $.ajax({ url:"Add.php", data:{name:name}, type:"POST", dataType:"TEXT", success: function(data){ alert(data); } }); }) }); </script> </body> </html>
添加节点处理
<?php session_start(); $uid = $_POST["uid"]; if(empty($_SESSION["user"])) { $attr = array($uid); $_SESSION["user"] = $attr; } else { $attr = $_SESSION["user"]; array_push($attr,$uid); $_SESSION["user"] = $attr; }
删除节点处理
<?php session_start(); $code = $_POST["code"]; $attr = $_SESSION["user"]; unset($attr[$code]); $attr = array_values($attr); $_SESSION["user"] = $attr;
添加流程处理
<?php session_start(); include("DBDA.php"); $db = new DBDA(); $name = $_POST["name"]; if(empty($_SESSION["user"])) { echo "请选择节点人员!"; } else { $attr = $_SESSION["user"]; $code = date("YmdHis",time()); $sqll = "insert into LiuCheng values('{$code}','{$name}')"; if($db->Query($sqll,0)) { foreach($attr as $k=>$v) { $sqlf = "insert into FlowPath values('','{$code}','{$v}','{$k}')"; $db->Query($sqlf,0); } } echo "添加成功!"; }
发起流程
<!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="jquery-1.11.2.min.js"></script> </head> <body> <h1>发起流程</h1> <div> 请选择要发起的流程: <select id="lc"> <?php include("DBDA.php"); $db = new DBDA(); $sql = "select * from LiuCheng"; $attr = $db->Query($sql); foreach($attr as $v) { echo "<option value='{$v[0]}'>{$v[1]}</option>"; } ?> </select> </div> <br /> <div> 请输入要发起的内容: <textarea id="nr" style="300px; height:200px"></textarea> </div> <br /> <div><input type="button" value="发起" id="fq" /></div> <a href="Main.php">返回</a> </body> <script type="text/javascript"> $(document).ready(function(e) { $("#fq").click(function(){ var lc = $("#lc").val(); var nr = $("#nr").val(); $.ajax({ url:"fqchuli.php", data:{lc:lc,nr:nr}, type:"POST", dataType:"TEXT", success: function(data){ alert(data); } }); }) }); </script> </html>
发起流程处理
<?php session_start(); $code = $_POST["lc"]; $nr = $_POST["nr"]; include("DBDA.php"); $db = new DBDA(); $uid = $_SESSION["uid"]; $rq = date("Y-m-d H:i:s",time()); $sql = "insert into UserFlow values('','{$code}','{$uid}','{$nr}',false,'{$rq}',0)"; if($db->Query($sql,0)) { echo "发起成功!"; } else { echo "发起失败!"; }
流程操作
<!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="jquery-1.11.2.min.js"></script> </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(); $uid = $_SESSION["uid"]; include("DBDA.php"); $db = new DBDA(); $sqlall = "select * from UserFlow"; $attr = $db->Query($sqlall); foreach($attr as $arr) { list($ids,$code,$yh,$nr,$isok,$rq,$where) = $arr; //根据登录者和流程代号取出该登陆者在该流程中的次序 $sqlorder = "select Orders from FlowPath where Uids='{$uid}' and Code = '{$code}'"; $order = $db->StrQuery($sqlorder); //判断该用户在流程中的次序和流程走到哪个地方的关系 if($where>=$order) { //处理流程名称 $sqlname = "select Name from LiuCheng where Code='{$code}'"; $name = $db->StrQuery($sqlname); //处理发起者名称 $sqln = "select Name from Users where Uid='{$yh}'"; $n = $db->StrQuery($sqln); //处理是否结束 $ok = $isok?"<span style='color:red'>已结束</span>":"<span>处理中</span>"; //处理操作 $cz = $where==$order?"<a href='shenhe.php?ids={$ids}'>审核</a>":"<span style='color:green'>已通过</span>"; echo "<tr> <td>{$name}</td> <td>{$n}</td> <td>{$nr}</td> <td>{$ok}</td> <td>{$rq}</td> <td>{$cz}</td> </tr>"; } } ?> </table> </body> </html>
操作处理
<?php $ids = $_GET["ids"]; include("DBDA.php"); $db = new DBDA(); $sql = "update UserFlow set ToWhere=ToWhere+1 where Ids={$ids}"; $db->Query($sql,0); //找到流程代号 $sqlcode = "select * from UserFlow where Ids = {$ids}"; $attr = $db->Query($sqlcode); $lccode = $attr[0][1]; $where = $attr[0][6]; //根据流程代号查节点个数 $sqljd = "select count(*) from FlowPath where Code='{$lccode}'"; $count = $db->StrQuery($sqljd); if($where>=$count) { $sqlok = "update UserFlow set IsOk=true where Ids={$ids}"; $db->Query($sqlok,0); } header("location:chuli.php");
<?php $ids = $_GET["ids"]; include("DBDA.php"); $db = new DBDA(); $sql = "update UserFlow set ToWhere=ToWhere+1 where Ids={$ids}"; $db->Query($sql,0); //找到流程代号 $sqlcode = "select * from UserFlow where Ids = {$ids}"; $attr = $db->Query($sqlcode); $lccode = $attr[0][1]; $where = $attr[0][6]; //根据流程代号查节点个数 $sqljd = "select count(*) from FlowPath where Code='{$lccode}'"; $count = $db->StrQuery($sqljd); if($where>=$count) { $sqlok = "update UserFlow set IsOk=true where Ids={$ids}"; $db->Query($sqlok,0); } header("location:chuli.php");
类DBDA
<?php class DBDA { public $host = "localhost"; //服务器地址 public $uid = "root"; //数据库的用户名 public $pwd = "123"; //数据库的密码 //执行SQL语句,返回相应结果的函数 //$sql是要执行的SQL语句 //$type是SQL语句的类型,0代表增删改,1代表查询 //$db代表要操作的数据库 public function Query($sql,$type=1,$db="mydb") { //造连接对象 $conn = new MySQLi($this->host,$this->uid,$this->pwd,$db); //判断连接是否成功 !mysqli_connect_error() or die("连接失败!"); //执行SQL语句 $result = $conn->query($sql); //判断SQL语句类型 if($type==1) { //如果是查询语句返回结果集的二维数组 return $result->fetch_all(); } else { //如果是其他语句,返回true或false return $result; } } //Ajax调用返回JSON public function JsonQuery($sql,$type=1,$db="mydb") { //定义数据源 $dsn = "mysql:dbname={$db};host={$this->host}"; //造pdo对象 $pdo = new PDO($dsn,"{$this->uid}","{$this->pwd}"); //准备执行SQL语句 $st = $pdo->prepare($sql); //执行预处理语句 if($st->execute()) { if($type==1) { $attr = $st->fetchAll(PDO::FETCH_ASSOC); return json_encode($attr); } else { if($st) { return "OK"; } else { return "NO"; } } } else { echo "执行失败!"; } } //Ajax调用返回字符串 public function StrQuery($sql,$type=1,$db="mydb") { //造连接对象 $conn = new MySQLi($this->host,$this->uid,$this->pwd,$db); //判断连接是否成功 !mysqli_connect_error() or die("连接失败!"); //执行SQL语句 $result = $conn->query($sql); //判断SQL语句类型 if($type==1) { $attr = $result->fetch_all(); $str = ""; //如果是查询语句返回字符串 for($i=0;$i<count($attr);$i++) { for($j=0;$j<count($attr[$i]);$j++) { $str = $str.$attr[$i][$j]; $str = $str."^"; } $str = substr($str,0,strlen($str)-1); $str = $str."|"; } $str = substr($str,0,strlen($str)-1); return $str; } else { //如果是其他语句,返回true或false if($result) { return "OK"; } else { return "NO"; } } } }