⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 import.php

📁 通达网络办公 - Office Anywhere 2008 增强版100%源码(3.4.081216) 内含 通达OA2008增強版接近完美破解补丁20081216集 及 最新通达OA2008ADV(
💻 PHP
字号:
<?php

include_once( "inc/auth.php" );
include_once( "fun_allcompute.php" );
include_once( "inc/utility_all.php" );
echo "<html>\r\n<head>\r\n<title>导入数据</title>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\r\n</head>\r\n<body class=\"bodycolor\" topmargin=\"5\">\r\n";
if ( $FILE_NAME == "" )
{
	$operate = "0";
	$query = "SELECT count(*) from SAL_DATA where FLOW_ID='".$FLOW_ID."'";
	$cursor = exequery( $connection, $query );
	if ( $ROW = mysql_fetch_array( $cursor ) )
	{
		$ROW_COUNT = $ROW[0];
	}
	echo "<script Language=\"JavaScript\">\r\n function chk(input)\r\n  {\r\n    for(var i=0;i<document.form1.c1.length;i++)\r\n    {\r\n      document.form1.c1[i].checked = false;\r\n    }\r\n\r\n    input.checked = true;\r\n    return true;\r\n  }\r\nfunction CheckForm()\r\n{\r\n   if(document.form1.CSV_FILE.value==\"\")\r\n   { alert(\"请选择要导入的文件!\");\r\n     return (false);\r\n   }\r\n\r\n   if (document.form1.CSV_FILE.value!=\"\")\r\n   {\r\n     var file_temp=document.form1.CSV_FILE.value,file_name;\r\n     var Pos;\r\n     Pos=file_temp.lastIndexOf(\"\\\\\");\r\n     file_name=file_temp.substring(Pos+1,file_temp.length);\r\n     document.form1.FILE_NAME.value=file_name;\r\n   }\r\n\r\n   return (true);\r\n}\r\n</script>\r\n\r\n  <table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"3\" class=\"small\">\r\n    <tr>\r\n";
	if ( $ROW_COUNT != 0 )
	{
		echo "      <td class=\"Big\"><img src=\"/images/sys_config.gif\" align=\"absmiddle\"><span class=\"big3\"> 导入CSV工资数据(该流程已录入过数据)</span><br>\r\n      </td>\r\n";
	}
	else
	{
		echo "      <td class=\"Big\"><img src=\"/images/sys_config.gif\" align=\"absmiddle\"><span class=\"big3\"> 导入CSV工资数据</span><br>\r\n      </td>\r\n";
	}
	echo "    </tr>\r\n  </table>\r\n\r\n  <br>\r\n  <br>\r\n\r\n  <div align=\"center\" class=\"Big1\">\r\n  <b>请指定用于导入的CSV文件:</b>\r\n  <form name=\"form1\" method=\"post\" action=\"import.php?FLOW_ID=";
	echo $FLOW_ID;
	echo "\" enctype=\"multipart/form-data\" onSubmit=\"return CheckForm();\">\r\n    <input type=\"file\" name=\"CSV_FILE\" class=\"BigInput\" size=\"30\">\r\n    <input type=\"hidden\" name=\"FILE_NAME\">\r\n    <input type=\"hidden\" name=\"GROUP_ID\" value=\"";
	echo $GROUP_ID;
	echo "\">\r\n    <input type=\"submit\" value=\"导入\" class=\"BigButton\">\r\n    <br><br>\r\n";
	if ( $ROW_COUNT != 0 )
	{
		echo "     <input type=\"checkbox\" name=\"c1\" id=\"Id_c1\" value=\"1\" onClick=\"return chk(this);\" checked><label for=\"Id_c1\">插入新数据</label>&nbsp;&nbsp;\r\n     <input type=\"checkbox\" name=\"c1\" id=\"Id_c2\" value=\"2\" onClick=\"return chk(this);\" ><label for=\"Id_c2\">更新已有的数据</label>&nbsp;&nbsp;\r\n";
	}
	echo "   <br><br>\r\n   <input type=\"checkbox\" name=\"compute\" id=\"Id_compute\" value=\"1\" ><label for=\"Id_compute\">导入的同时计算所有的计算项</label>\r\n  </form>\r\n\r\n  <br>\r\n  <input type=\"button\" value=\"返回\" class=\"BigButton\" onClick=\"location='index.php'\">\r\n  ";
	if ( $FILE_NAME == "" )
	{
		message( "说明", "1)EXECL的工资报表的列顺序为姓名、工资项目,将部门、职务等列删除;<BR>2)将改好的EXECL工资报表另存为CSV格式的文件;" );
	}
	echo "\r\n  </div>\r\n";
	exit( );
}
if ( strtolower( substr( $FILE_NAME, -3 ) ) != "csv" )
{
	message( "错误", "只能导入CSV文件!" );
	button_back( );
	exit( );
}
$query = "SELECT ITEM_ID ,ITEM_NAME from SAL_ITEM";
$cursor = exequery( $connection, $query );
$title = array( );
while ( $ROW = mysql_fetch_array( $cursor ) )
{
	$ITEM_NAME = $ROW['ITEM_NAME'];
	$ITEM_ID = "S".$ROW['ITEM_ID'];
	$title[$ITEM_NAME] = $ITEM_ID;
}
$title += array( "姓名" => "USER_NAME" );
$ROW_COUNT = 0;
$data = file_get_contents( $CSV_FILE );
$lines = csv2array( $data, $title, "," );
if ( !$data )
{
	message( "错误", "打开文件错误!" );
	button_back( );
	exit( );
}
$operate = "0";
if ( $c1 == "2" )
{
	$operate = "1";
}
else
{
	$query = "delete from SAL_DATA where FLOW_ID='".$FLOW_ID."'";
	exequery( $connection, $query );
}
if ( $operate == "0" )
{
	foreach ( $lines as $line )
	{
		$STR_VALUE = "";
		$STR_KEY = "";
		foreach ( $line as $key => $value )
		{
			if ( $key != "USER_NAME" )
			{
				$STR_KEY .= $key.",";
				$STR_VALUE .= "'".$value."',";
			}
			else
			{
				$USER_NAME = $value;
			}
		}
		if ( substr( $STR_KEY, -1 ) == "," )
		{
			$STR_KEY = substr( $STR_KEY, 0, -1 );
		}
		if ( substr( $STR_VALUE, -1 ) == "," )
		{
			$STR_VALUE = substr( $STR_VALUE, 0, -1 );
		}
		$query = "insert into SAL_DATA(FLOW_ID,USER_ID,";
		$query1 = "SELECT USER_ID from USER where USER_NAME='".$USER_NAME."'";
		$cursor1 = exequery( $connection, $query1 );
		if ( !( $ROW = mysql_fetch_array( $cursor1 ) ) )
		{
			echo "<font color=#FF6633><b>员工".$USER_NAME."尚未在OA系统中注册!!</b></font><br>";
		}
		else
		{
			$query .= $STR_KEY.( ") values ('".$FLOW_ID."','{$ROW['0']}'," ).$STR_VALUE.")";
			exequery( $connection, $query );
			echo "员工".$USER_NAME."的工资导入完成!!<br>";
			++$ROW_COUNT;
		}
	}
}
else
{
	foreach ( $lines as $line )
	{
		$STR_UPDATE = "";
		$query = "update SAL_DATA set ";
		foreach ( $line as $key => $value )
		{
			if ( $key != "USER_NAME" )
			{
				$STR_UPDATE .= $key."='".$value."',";
			}
			else
			{
				$USER_NAME = $value;
			}
		}
		if ( substr( $STR_UPDATE, -1 ) == "," )
		{
			$STR_UPDATE = substr( $STR_UPDATE, 0, -1 );
		}
		$query .= $STR_UPDATE;
		$query1 = "SELECT USER_ID from USER where USER_NAME='".$USER_NAME."'";
		$cursor1 = exequery( $connection, $query1 );
		if ( !( $ROW = mysql_fetch_array( $cursor1 ) ) )
		{
			echo "<font color=#FF6633><b>员工".$USER_NAME."尚未在OA系统中注册!!</b></font><br>";
		}
		else
		{
			$query .= " where FLOW_ID=".$FLOW_ID." and USER_ID='{$ROW['0']}'";
			exequery( $connection, $query );
			echo "员工".$USER_NAME."的工资修改完成!!<br>";
			++$ROW_COUNT;
		}
	}
}
if ( file_exists( $CSV_FILE ) )
{
	@unlink( $CSV_FILE );
}
if ( $compute == "1" )
{
	comput_allitem( $FLOW_ID );
}
message( "", "共".$ROW_COUNT."条数据导入!" );
echo "<div align=\"center\">\r\n<input type=\"button\" value=\"返回\" class=\"BigButton\" onClick=\"location='index.php';\" title=\"返回\">\r\n</div>\r\n</body>\r\n</html>\r\n";
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -