7e47ce238b
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
112 lines
3.1 KiB
PHP
112 lines
3.1 KiB
PHP
<?php
|
|
//-------------------------------------------------------xls2维转置
|
|
require "../config.php";
|
|
include "../../tmpl/config.php";
|
|
require THIS_FILE_ROOT."/include/function.php";
|
|
require THIS_FILE_ROOT."/include/db_mysql.php";
|
|
//require THIS_FILE_ROOT."/include/page.class.php";
|
|
error_reporting(E_ERROR | E_WARNING | E_PARSE);
|
|
//-------------------------------mysql connect
|
|
$msg="";
|
|
$db=new DB_Sql;
|
|
$db->connect($dbhost,$dbuser,$dbpw,$dbname,"p");
|
|
$is_submit=$_POST["is_submit"];
|
|
if($is_submit=="y"){
|
|
$content=$_POST["content"];
|
|
$arr=explode("\n",$content);
|
|
$arr_xm=array();
|
|
$arr_km=array();
|
|
for($i=0;$i<count($arr);$i++){
|
|
$str1=trim($arr[$i]);
|
|
$arr1=explode(" ",$str1);
|
|
$xm=trim($arr1[0]);
|
|
$km=trim($arr1[1]);
|
|
$ys=trim($arr1[2]);
|
|
$zc=trim($arr1[3]);
|
|
if(!in_array($km,$arr_km)){
|
|
$arr_km[]=$km;
|
|
}
|
|
$arr_xm[$xm][]=array($km,$ys,$zc);
|
|
}
|
|
//print_r($arr_km);
|
|
//echo "<br>";
|
|
//print_r($arr_xm);
|
|
//表头
|
|
$res="项目名称 项目预算 项目支出 项目余额 ";
|
|
for($j=0;$j<count($arr_km);$j++){
|
|
$res.=$arr_km[$j]." ";
|
|
}
|
|
$res.="\n";
|
|
//内容
|
|
foreach($arr_xm as $xmmc => $arr_xmnr){
|
|
if($xmmc){
|
|
$xj_ys=$xj_zc=0;//计算预算和支出
|
|
$content1="";
|
|
for($j=0;$j<count($arr_km);$j++){
|
|
$is_find="n";
|
|
$tmp_zc=0;
|
|
for($k=0;$k<count($arr_xmnr);$k++){
|
|
if($arr_xmnr[$k][0]==$arr_km[$j]){
|
|
$tmp_zc+=$arr_xmnr[$k][2];
|
|
$xj_ys+=$arr_xmnr[$k][1];
|
|
$xj_zc+=$arr_xmnr[$k][2];
|
|
$is_find="y";
|
|
}
|
|
}
|
|
if($is_find=="n")
|
|
$content1.=" ";
|
|
else
|
|
$content1.=$tmp_zc." ";
|
|
}
|
|
$res.=$xmmc." ".$xj_ys." ".$xj_zc." ".($xj_ys-$xj_zc)." ".$content1."\n";
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
<!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>xls2维转置</title>
|
|
<style>
|
|
BODY{
|
|
font-family:宋体;FONT-SIZE:12px;margin:0px;padding:0px;
|
|
}
|
|
a,a:link,a:visited,a:active {
|
|
text-decoration:none;COLOR: #0000ff;FONT-SIZE:12px;
|
|
}
|
|
a:hover {
|
|
TEXT-DECORATION: underline;COLOR: #aaaa9f;FONT-SIZE:12px;
|
|
}
|
|
body,input,td,select,div,li,ul,textarea,form {
|
|
font-family:宋体;
|
|
FONT-SIZE:12px;
|
|
}
|
|
.wrong{
|
|
color:#ff0000;font-weight:bold;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<br />
|
|
<table width="80%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#cccccc">
|
|
<form name="form1" action="" method="post">
|
|
<input type="hidden" name="is_submit" value="y">
|
|
<tr>
|
|
<td align="center" bgcolor="#f0f0f0"><b>xls2维转置</b></td>
|
|
</tr>
|
|
<tr>
|
|
<td align="left" bgcolor="#ffffff" style="line-height:25px;">格式说明:从excel复制这4列内容(项目,科目,预算,支出),不含表头。<Br>
|
|
<textarea name="content" style="width:100%;" rows="20"><?php echo $content; ?></textarea></td>
|
|
</tr>
|
|
<tr>
|
|
<td align="center" bgcolor="#f0f0f0"><input type="submit" value=" 计 算 "></td>
|
|
</tr>
|
|
<tr>
|
|
<td align="left" bgcolor="#ffffff" style="line-height:25px;">结果<Br>
|
|
<textarea name="res" style="width:100%;" rows="20"><?php echo $res; ?></textarea></td>
|
|
</tr>
|
|
</form>
|
|
</table>
|
|
</body>
|
|
</html>
|