通达OA工作流插件--保存OA流程中的所有附件+流程表单到指定目录(2013adv,2015,2016)

<?php
/*********************/
/*                   */
/*  Version : 5.1.0  */
/*  Author  : RM     */
/*  Comment : 071223 */
/*                   */
/*********************/
//联系人    qq:874689017
include_once( "inc/auth.inc.php" );
include_once( "inc/utility_all.php" );
include_once( "inc/utility_flow.php" );
include_once( "inc/utility_file.php" );
include_once( "inc/mobile_seal/seal_data.php" );
include_once( "../../prcs_role.php" );
include_once( "inc/workflow/inc/common.inc.php" );
include_once( "inc/workflow/inc/workflow.inc.php" );
include_once( "inc/workflow/tform/twork_export.class.php" );
include_once( "inc/workflow/inc/workpriv.inc.php" );
$HTML_PAGE_TITLE = _( "导出" );
include_once( "inc/header.inc.php" );
$archive_time = $_GET['archive_time'];
//HTML=1&RUN_ID=479&FLOW_ID=134&PRCS_ID=&FLOW_PRCS=&archive_time=&FLOW_VIEW=1234
//$RUN_ID=447;
//$FLOW_ID=132;
$FLOW_VIEW="12345";
if ( $archive_time != "" && $archive_time != "undefined" )
{
		$use_databases = "td_oa_archive.";  
}
else
{
		$use_databases = "";
		$archive_time = "";
}
$role_str = run_role( $RUN_ID, 0, $archive_time );
$PRIV_TYPE_STR = getflowprivofmanage( $FLOW_ID, $_SESSION['LOGIN_USER_ID'], $_SESSION['LOGIN_DEPT_ID'], $_SESSION['LOGIN_USER_PRIV'], $_SESSION['LOGIN_DEPT_ID_OTHER'], $_SESSION['LOGIN_USER_PRIV_OTHER'] );

setcookie( "FLOW_VIEW_COOKIE", $FLOW_VIEW, time( ) + 259200000 );
$flag_hidden_type = 1;
$table_flow_run_prcs = $use_databases."flow_run_prcs".$archive_time;
if ( $PRCS_ID == NULL || $PRCS_ID == "" )
{
		if ( find_id( $role_str, 1 ) || find_id( $role_str, 3 ) || find_id( $role_str, 5 ) || find_id( $role_str, 9 ) || find_id( $role_str, 10 ) || find_id( $role_str, 11 ) )
		{
				$PRCS_ID = 0;
				$flag_hidden_type = 0;
		}
		else if ( find_id( $role_str, 2 ) || find_id( $role_str, 4 ) || find_id( $role_str, 6 ) )
		{
				$query = "select prcs_id from ".$table_flow_run_prcs."\r\n                   where id = (\r\n                   select MAX(id) from ".$table_flow_run_prcs." where run_id = '".$RUN_ID."'\r\n                   AND (user_id = '".$_SESSION['LOGIN_USER_ID']."'\r\n                   or FIND_IN_SET('".$_SESSION['LOGIN_USER_ID']."',OTHER_USER))) ";
				$cursor = exequery( TD::conn( ), $query );
				if ( $row = mysql_fetch_array( $cursor ) )
				{
						$PRCS_ID = $row['prcs_id'];
				}
				$flag_hidden_type = 1;
		}
		else if ( find_id( $role_str, 8 ) || find_id( $role_str, 7 ) )
		{
				$PRCS_ID = 0;
				$flag_hidden_type = 2;
		}
}
if ( find_id( $role_str, 8 ) )
{
		$query = "select 1 from APP_LOG where MODULE = '7' and OPP_ID = '".$RUN_ID."' and USER_ID = '".$_SESSION['LOGIN_USER_ID']."'";
		$cursor = exequery( TD::conn( ), $query );
		if ( !( $row = mysql_fetch_array( $cursor ) ) )
		{
				$CUR_TIME = date( "Y-m-d H:i:s", time( ) );
				$query1 = "insert into APP_LOG(USER_ID,TIME,MODULE,OPP_ID,TYPE) values ('".$_SESSION['LOGIN_USER_ID'].( "','".$CUR_TIME."','7','{$RUN_ID}','1')" );
				exequery( TD::conn( ), $query1 );
		}
}
if ( $flag_hidden_type == 0 )
{
		$secret_fields = "";
}
else if ( $flag_hidden_type == 1 )
{
		$query = "select FLOW_PRCS from ".$table_flow_run_prcs." where RUN_ID = '".$RUN_ID."' and PRCS_ID = '".$PRCS_ID."' limit 1";
		$cursor = exequery( TD::conn( ), $query );
		if ( $row = mysql_fetch_array( $cursor ) )
		{
				$FLOW_PRCS = $row['FLOW_PRCS'];
		}
		$table_flow_prcocess = $use_databases."flow_process".$archive_time;
		$secret_fields = "";
		$query = "select HIDDEN_ITEM from ".$table_flow_prcocess." where FLOW_ID = '".$FLOW_ID."' and PRCS_ID = '".$FLOW_PRCS."' ";
		$cursor = exequery( TD::conn( ), $query );
		if ( $row = mysql_fetch_array( $cursor ) )
		{
				$secret_fields = $row['HIDDEN_ITEM'];
		}
}
else if ( $flag_hidden_type == 2 )
{
		$table_flow_prcocess = $use_databases."flow_process".$archive_time;
		$secret_fields = "";
		$query = "select HIDDEN_ITEM from ".$table_flow_prcocess." where FLOW_ID = '".$FLOW_ID."' ";
		$cursor = exequery( TD::conn( ), $query );
		while ( $row = mysql_fetch_array( $cursor ) )
		{
				$secret_fields .= $row['HIDDEN_ITEM'].",";
		}
		$secret_fields = td_trim( $secret_fields );
		$secret_fields = str_remove_dup( $secret_fields );
}
$archive_time = $_GET['archive_time'];
if ( $archive_time != "" && $archive_time != "undefined" )
{
		$use_databases = "td_oa_archive.";
}
else
{
		$use_databases = "";
		$archive_time = "";
}
$query = "select RUN_NAME from ".$use_databases."flow_run".$archive_time." where RUN_ID = '".$RUN_ID."' ";
$cursor = exequery( TD::conn( ), $query );
while ( $row = mysql_fetch_array( $cursor ) )
{
		$RUN_NAME = $row['RUN_NAME'];
}
ob_start( );
echo "<script>\r\n\r\n//定义全局变量\r\nvar g_run_id = \"";
echo $RUN_ID;
echo "\";       //流水号\r\nvar g_flow_id = \"";
echo $FLOW_ID;
echo "\";     //流程ID\r\nvar g_prcs_id = \"";
echo $PRCS_ID;
echo "\";     //实际流程步骤序号\r\nvar g_form_view = 2;                 //打印表单\r\nvar doPrint = \"";
echo $doPrint;
echo "\";\r\nvar printView = \"";
echo $printView;
echo "\";\r\n</script>\r\n\r\n<body style=\"background:none;margin: 0;\" topmargin=\"5\">\r\n<div  id='bodyScroll' >\r\n";
$query = "SELECT DEL_FLAG from ".$use_databases."FLOW_RUN".$archive_time.( " WHERE RUN_ID='".$RUN_ID."'" );
$cursor = exequery( TD::conn( ), $query );
if ( $ROW = mysql_fetch_array( $cursor ) )
{
		$DEL_FLAG = $ROW['DEL_FLAG'];
}
if ( $DEL_FLAG == 1 )
{
		message( "", _( "此流程已经被删除!" ) );
}
$config = array(
		"db" => $use_databases,
		"archive_time" => $archive_time,
		"secret_fields" => $secret_fields,
		"export_type" => "html"
);
$PRINT_FLAG = 1;
$HTML = 1;
$doc_content = "";
if ( strstr( $FLOW_VIEW, "1" ) )
{
		echo "<style type=\"text/css\"> ".$CSS."</style>";
		echo "<form name=\"form1\" method=\"post\" action=\"\">";
		$obj_work_export = new TWorkExport( $FLOW_ID, $RUN_ID, $PRCS_ID, $FLOW_PRCS, $config );
		echo $obj_work_export->get_form_html( );
		echo "</form>";
		$arr_files = $obj_work_export->get_form_files( );
		$arr_files_count = count( $arr_files );
		$arr_files_count /= 2;
		$arr_files = array_slice( $arr_files, $arr_files_count );
}
if ( strstr( $FLOW_VIEW, "2" ) )
{
		echo "<br>";
		include_once( "../../list/public_attach.php" );
}
if ( strstr( $FLOW_VIEW, "3" ) )
{
		echo "<br>";
		include_once( "../../list/personal_sign.php" );
}
if ( strstr( $FLOW_VIEW, "4" ) )
{
		echo "<br>";
		include_once( "../../list/flow_view/view_list.php" );
}
if ( strstr( $FLOW_VIEW, "5" ) )
{
		echo "<br>";
		include_once( "../../list/flow_view/view_user.php" );
}
$doc_content = ob_get_contents( );
ob_end_clean( );
$RUN_NAME = str_replace( ":", "_", $RUN_NAME );
$RUN_NAME = str_replace( "\"", "", $RUN_NAME );
$RUN_NAME = str_replace( "<", "", $RUN_NAME );
$RUN_NAME = str_replace( ">", "", $RUN_NAME );
$RUN_NAME = str_replace( "|", "", $RUN_NAME );
$RUN_NAME = str_replace( "*", "", $RUN_NAME );
$RUN_NAME = str_replace( "?", "", $RUN_NAME );
$RUN_NAME = str_replace( "/", "", $RUN_NAME );
$RUN_NAME = str_replace( "\\", "", $RUN_NAME );

		echo "<html><head>";
		echo "<title>".$RUN_NAME."</title>";
		echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=".MYOA_CHARSET."\">";
		echo "</head>";
		echo $doc_content;
		ob_end_clean();

/************************************************************************/

//创建目录
//$powneronfile="../../../../powneronfile";
$powneronfile="D:/MYOA/webroot/powneronfile";
if (!file_exists($powneronfile)){
mkdir($powneronfile);  //如果没有的话创建webroot下的powneronfile
}
$mulu=$powneronfile."/".$RUN_ID."";  //powneronfile下按流水号创建文件夹
if (!file_exists($mulu)){
mkdir($mulu);
}

/************************************************************************/

$run_name = "";
$run_time = "";

$query = "SELECT * from flow_data_".$FLOW_ID." where run_id = '".$RUN_ID."' limit 1";
$cursor = exequery( TD::conn(), $query );
if( $ROW = mysql_fetch_array( $cursor ) )
{	
    $run_name = $ROW["run_name"];
	$run_time = $ROW["begin_time"];
	$begin_user = $ROW["begin_user"];
}

$query7="select BYNAME from user where USER_ID='$begin_user' limit 1";
$cursor7=exequery(TD::conn(),$query7);
while($row7=mysql_fetch_array($cursor7)){
	$byname=$row7["BYNAME"];
	}

//$folder_name="[".$RUN_ID."]".$RUN_NAME;
$folder_name=$RUN_ID."-".$RUN_NAME;	
/********  工作流表单中的附件*****************/
$query4="show COLUMNS from flow_data_".$FLOW_ID;
//echo $query4."<br>";
$cursor4=exequery(TD::conn(),$query4);
while($row4=mysql_fetch_array($cursor4)){
	$ziduan=$row4["Field"];
	//echo $ziduan."<br>";
	$ziduan_arr=explode("_",$ziduan);
	if($ziduan_arr[2]=="key"){
		//echo $ziduan."<br>";
		$wenjian_name=$ziduan_arr[0]."_".$ziduan_arr[1];
		$wenjian_id=$ziduan_arr[0]."_".$ziduan_arr[1]."_".$ziduan_arr[2];
		$query6="select ".$wenjian_id.",".$wenjian_name." from flow_data_".$FLOW_ID." where run_id='$RUN_ID'";   
		//echo $query6."<br>";
		//将OA流程中表单中的附件获取出来,必须用数组拆分
$cursor6 = exequery( TD::conn(), $query6 );
while( $ROW6 = mysql_fetch_array( $cursor6 ) ){
				$att_arr=explode(",",$ROW6[$wenjian_id]);
				$att_name_arr=explode("*",$ROW6[$wenjian_name]);
				for($i=0;$i<count($att_arr)-1;$i++){
				$yuan_name1 = attach_real_path($att_arr[$i], $att_name_arr[$i], $MODULE = "" );  //每一个附件copy一次
				$to_name1 = $mulu."/".$att_name_arr[$i]."";	
				//$yuan_name1 = attach_real_path("2682@1511_1589471134", "哈电国际--通达OA实施方案--通达OA孙忠海.docx", $MODULE = "" );
				//$to_name1 = "../../../../powneronfile/".$RUN_ID."/哈电国际--通达OA实施方案--通达OA孙忠海.docx";
				copy($yuan_name1,$to_name1);  //每次只能是一个文件
				$file_size=filesize($to_name1); 
				$file_name=$att_name_arr[$i];
				$file_ext=substr(strrchr($file_name, '.'), 1);
				$query5="INSERT INTO `powneronfile` (`flow_id`, `run_id`, `file_path`,`file_name`,`file_ext`,`file_size`,`create_user`, `t_flag`) VALUES ('$FLOW_ID', '$RUN_ID','".$RUN_ID."/".$att_name_arr[$i]."','$file_name','$file_ext','$file_size','$byname','0')";
				exequery(TD::conn(),$query5);
				
				}
				}  //end  while 
		} // end if($ziduan_arr[2]=="key"){
	}
/********  工作流表单中的附件
//将工作流中的附件备份到其他目录下
$query1="select * from flow_data_".$FLOW_ID." where run_id='$RUN_ID'";   //将OA流程中表单中的附件获取出来,必须用数组拆分
$cursor1 = exequery( TD::conn(), $query1 );
while( $ROW1 = mysql_fetch_array( $cursor1 ) )
{	//echo $ROW1["data_22"]; echo "<br>";
	//echo $ROW1["data_22_key"]; echo "<br>";
$att_arr=explode(",",$ROW1["data_22_key"]);
$att_name_arr=explode("*",$ROW1["data_22"]);
for($i=0;$i<count($att_arr)-1;$i++){
	$yuan_name1 = attach_real_path($att_arr[$i], $att_name_arr[$i], $MODULE = "" );  //每一个附件copy一次
	$to_name1 = "../../../../powneronfile/".$RUN_ID."/".$att_name_arr[$i]."";	
	//$yuan_name1 = attach_real_path("2682@1511_1589471134", "哈电国际--通达OA实施方案--通达OA孙忠海.docx", $MODULE = "" );
	//$to_name1 = "../../../../powneronfile/".$RUN_ID."/哈电国际--通达OA实施方案--通达OA孙忠海.docx";
	//echo $yuan_name1; echo "<br>";
	//echo $to_name1; echo "<br>";
	copy($yuan_name1,$to_name1);  //每次只能是一个文件
	}
		
}
	****/
//查询公共附件	
$query = "SELECT * from flow_run_attach where run_id = '".$RUN_ID."'";
$cursor = exequery( TD::conn(), $query );
while( $ROW = mysql_fetch_array( $cursor ) )
{	
	$yuan_name = attach_real_path($ROW["ATTACHMENT_ID"], $ROW["ATTACHMENT_NAME"], $MODULE = "" );  //flow_run_attach是单个附件存储的
	$to_name = $mulu."/".$ROW["ATTACHMENT_NAME"]."";	
	copy($yuan_name,$to_name);
	//插入到中间表
	//$file_name=$ROW["ATTACHMENT_NAME"];
	//$query2="INSERT INTO `hola_oa_file` (`flow_id`, `run_id`, `folder_name`,`file_path`,`file_name`, `t_flag`) VALUES ('$FLOW_ID', '$RUN_ID','$folder_name','".$RUN_ID."/".$ROW["ATTACHMENT_NAME"]."','$file_name','0')";
	
	//插入到中间表
	$file_name=$ROW["ATTACHMENT_NAME"];
	$file_size=filesize($to_name); 
	$file_ext=substr(strrchr($file_name, '.'), 1);
	$query2="INSERT INTO `powneronfile` (`flow_id`, `run_id`, `file_path`,`file_name`,`file_ext`,`file_size`,`create_user`, `t_flag`) VALUES ('$FLOW_ID', '$RUN_ID','".$RUN_ID."/".$ROW["ATTACHMENT_NAME"]."','$file_name','$file_ext','$file_size','$byname','0')";
	exequery(TD::conn(),$query2);
	
}

//将工作流中的数据添加到数据表中
$biaodan=$RUN_ID."_".$RUN_NAME."[表单].html";
$path=$mulu."/".$biaodan;
wirtefile ($path,$doc_content);
//插入到中间表
	//$query3="INSERT INTO `hola_oa_file` (`flow_id`, `run_id`, `folder_name`, `file_path`,`file_name`, `t_flag`) VALUES ('$FLOW_ID', '$RUN_ID','$folder_name', '".$RUN_ID."/".$biaodan."','$biaodan','0')";
	
	$file_name=$biaodan;
	$file_size=filesize($path); 
	$file_ext=substr(strrchr($file_name, '.'), 1);
	$query3="INSERT INTO `powneronfile` (`flow_id`, `run_id`, `file_path`,`file_name`,`file_ext`,`file_size`,`create_user`, `t_flag`) VALUES ('$FLOW_ID', '$RUN_ID','".$RUN_ID."/".$biaodan."','$file_name','$file_ext','$file_size','$byname','0')";
	exequery(TD::conn(),$query3);
	


function wirtefile ($fn,$data)
{
$fp=fopen($fn,"wb");
fwrite($fp,$data);
fclose($fp);

}
?>

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
通达OA工作流升级4.6【适用于2019版本工作流流程心】》是通达OA软件升级的一个版本,主要针对2019版本的工作流流程心进行改进和优化。 首先,在用户界面方面,4.6版本进行了界面调整和优化,使用户更加方便使用和操作。界面布局更加清晰,功能按钮更加醒目,提升了用户的操作体验。 其次,4.6版本对工作流引擎进行了改进和优化。引擎性能得到了提升,能够更快速、高效地处理工作流流程的相关操作。同时,引擎的稳定性也得到了加强,减少了因为错误或异常导致的系统崩溃的情况。 另外,在流程设计方面,4.6版本提供了更多的流程设计器功能,方便用户进行工作流的创建和定制。用户可以根据自己的需求,灵活地设计流程图,并进行相关的设置和调整。这样可以更好地适应不同类型的工作流程。 此外,4.6版本还增加了一些新的功能和特性。比如,增加了一键审批、多条件分支等功能,使得工作流流程更加灵活和高效。同时,还提供了更多的审批流模板供用户选择和使用,方便用户根据实际需要进行相关设置。 总的来说,通达OA工作流升级4.6版本适用于2019版本的工作流流程心,通过界面调整和优化、工作流引擎改进和优化、流程设计功能增强以及新增功能和特性等方面的改进,提升了用户在工作流流程的使用体验和效率。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hai7425

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值