通達OA批量更改流程審批人

 開發前景:有員工離職時,如果員工在多個流程中有審批權限,這個時候需要一個流程一個流程去更改,此工具可以批量更改所有流程的所有節點,更改爲新用戶。

以下爲form 表單:

<form id="form1" name="form1" method="post" action="oa_index.php?action=ture" style="text-align: center">
請輸入原姓名:<input type="text" name="file1" id="file1"  placeholder="(現在審批的姓名)" style="width:200px;"/><br><br>
請輸入現姓名:<input type="text" name="file2" id="file2"  placeholder="(現在審批的姓名)" style="width:200px;"/><br><br>
<input type="submit" name="提交" id="提交" value="修改" style="width:150px;height:50px;font-size:30px;"/>
</form>

數據庫文件:

<?php
$db_host_tdoa="192.168.1.XXX:3336";      //MYSQL服務器名
$db_user_tdoa="root";       //MYSQL用戶名
$db_pass_tdoa="XXXXX";       //MYSQL用戶對應密碼
$db_name_tdoa="TD_OA";      //要操作的數據庫
$link_tdoa=mysql_connect($db_host_tdoa,$db_user_tdoa,$db_pass_tdoa)or die("不能連接到服務器".mysql_error());
mysql_select_db($db_name_tdoa,$link_tdoa);   
mysql_query("SET NAMES 'GBK'",$link_tdoa);
?>

以下爲提交處理:

<?PHP
$action=$_GET['action'];
$yyh=$_POST['file1'];   // 原姓名
$xyh=$_POST['file2'];   // 現姓名
if($action=='ture'){
require_once('/conn/config_252_tdoa.php');
$sql_yyh="select user_id from user where user_name='{$yyh}'";
$sql_xyh="select user_id from user where user_name='{$xyh}'";
$result_yyh=mysql_query($sql_yyh,$link_tdoa);
$result_xyh=mysql_query($sql_xyh,$link_tdoa);
$row_yyh=mysql_fetch_array($result_yyh);
$row_xyh=mysql_fetch_array($result_xyh);
$yyh_userid=$row_yyh['0'];
$xyh_userid=$row_xyh['0'];
if(empty($yyh_userid)){
	echo "<script>alert('原審批用戶不存在,請檢查姓名')</script>";
	exit();
}
if(empty($xyh_userid)){
	echo "<script>alert('現審批用戶不存在,請檢查姓名')</script>";
	exit();
}

//先取用戶的user_id

//總共有3個字段需要替換 分別爲prcs_user,auto_user_op,auto_user
//先查詢含原用戶的流程
$sql_prcs="select id,prcs_user from flow_process where prcs_user like '%{$yyh_userid}%'";
$result_prcs=mysql_query($sql_prcs,$link_tdoa);
while ($row_prcs=mysql_fetch_array($result_prcs)){
		$id=$row_prcs['id'];
		$xwb=str_replace("{$yyh_userid}","{$xyh_userid}","{$row_prcs['prcs_user']}");   //替換後的文本
		$sql_prcs_update="update flow_process set prcs_user='{$xwb}' where id='{$id}'";    //更新對應的記錄
		//echo $sql_prcs_update;
		mysql_query($sql_prcs_update,$link_tdoa);
}
//查詢默認選中
$sql_prcs_op="select id,auto_user_op,auto_user from flow_process where auto_user_op like '%{$yyh_userid}%'";
$result_prcs_op=mysql_query($sql_prcs_op,$link_tdoa);
while ($row_prcs_op=mysql_fetch_array($result_prcs_op)){
	$id=$row_prcs_op['id'];
	$xwb_op=str_replace("{$yyh_userid}","{$xyh_userid}","{$row_prcs_op['auto_user_op']}");   //替換後的文本
	$xwb_user=str_replace("{$yyh_userid}","{$xyh_userid}","{$row_prcs_op['auto_user']}");   //替換後的文本
		$sql_prcs_update_op="update flow_process set auto_user_op='{$xwb_op}',auto_user='{$xwb_user}' where id='{$id}'";    //更新對應的記錄
		//echo $sql_prcs_update_op."<br>";
	
		mysql_query($sql_prcs_update_op,$link_tdoa);

}
echo "<script>alert('修改成功')</script>";
}

?>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章