<?php
include ("cookie_check.php");
class report_2 {
var $name; //帐户名称
var $date;//日期
var $in_ex_type;//收支类目
var $comment;//描述
var $money;//金额
// 本方法生成某用户的收支情况明细表
function add_item ($user, $date_begin,$date_end) {
$query = "select in_ex_condition.comment as comment,account.name as name,
DATE_FORMAT(date,'%Y-%m-%d') as mydate,
in_ex_type.name as in_ex_type,in_ex_type.type as mytype,money*exchange_rate as
mymoney from in_ex_condition,account,currency,in_ex_type
where date>='".$date_begin."' and date<='".$date_end."'
and account.currency=currency.code and account.user='".$user.
"' and in_ex_condition.account=account.code and in_ex_condition.in_ex_type=
in_ex_type.code and in_ex_type<>1
and in_ex_type<>44 order by in_ex_type.code,in_ex_condition.date";
$res = mysql_query($query);
$sum_0=0;
$sum_1=0;
$row = @mysql_fetch_array($res);
$in_ex_type_pre=$row['in_ex_type'];
$mytype_pre=$row['mytype'];
$my_sum=0;
$i=0;
while ($row)
{$i++;
if ($row['in_ex_type']<>$in_ex_type_pre)
{if ($mytype_pre==0) $this->name[$i] = '
收入';
else $this->name[$i] = '
支出';
$this->money[$i] = $my_sum;
$my_sum=0;
$i++;
}
$in_ex_type_pre=$row['in_ex_type'];
$mytype_pre=$row['mytype'];
$this->name[$i] = $row['name'];
$this->date[$i] = $row['mydate'];
$this->comment[$i] = $row['comment'];
$this->in_ex_type[$i] = $row['in_ex_type'];
$this->money[$i] = $row['mymoney'];
$my_sum=$my_sum+$row['mymoney'];
if ($row['mytype']==0) $sum_0=$sum_0+$row['mymoney'];
else $sum_1=$sum_1+$row['mymoney'];
$row = @mysql_fetch_array($res);
}
$i++;
if ($mytype_pre==0) $this->name[$i] = '
收入';
else $this->name[$i] = '
支出';
$this->money[$i] = $my_sum;
$i++;
$this->name[$i] = '
收入总计';
$this->money[$i] = $sum_0;
$i++;
$this->name[$i] = '
支出总计';
$this->money[$i] = $sum_1;
$i++;
$this->name[$i] = '
差额总计';
$this->money[$i] = $sum_0-$sum_1;
return $i;
}
}
?>
<HTML>
<TITLE> 网上理财:收支情况明细表 </TITLE>
<BODY>
<P ALIGN=CENTER><FONT FACE="隶书" SIZE="7" COLOR="#0000FF">
网上理财</FONT><BR>
<P ALIGN=LEFT>
<FONT FACE="宋体" SIZE="3" COLOR="#0000FF"><a href=index.php
STYLE=Text-Decoration:none>首页</a>>><a href=report_02.php
STYLE=Text-Decoration:none>收支情况明细表</a>
<P ALIGN=CENTER><FONT FACE="隶书" SIZE="6" COLOR="#0000FF">
收支情况明细表</FONT><BR>
<FORM NAME="report_2" ACTION="report_2.php" METHOD="POST">
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD BGCOLOR="#FFFFFF" width=700>
<Font Face=宋体 Size=2 Color="#0000FF" >从<INPUT TYPE=TEXT
NAME="date_begin" SIZE="10" MAXLENGTH="10" value='<?php
if (!$date_begin)
{$today=getdate();
$date_begin=sprintf ("%04s-01-01",$today['year']);}
echo $date_begin
?>' onchange=javascript:document.report_2.submit()>到<INPUT
TYPE=TEXT NAME="date_end" SIZE="10" MAXLENGTH="10" value='<?php
if (!$date_end)
{$today=getdate();
$date_end=sprintf ("%04s-%02s-%02s",$today['year'],$today['mon'],
$today['mday']);}
echo $date_end
?>' onchange=javascript:document.report_2.submit()></FONT>
</TD><TD BGCOLOR="#FFFFFF" width=100>
</TD></TR>
</TABLE>
</FORM><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"
align=center>
<TR>
<TD BGCOLOR="#FFFFFF" ALIGN="left" VALIGN="MIDDLE" width=150>
<Font Face=宋体 Size=4 Color="#0000FF" >
收支类目</FONT>
</TD><TD BGCOLOR="#FFFFFF" ALIGN="left" width=100>
<Font Face=宋体 Size=4 Color="#0000FF" >
日期</FONT>
</TD><TD BGCOLOR="#FFFFFF" ALIGN="left" width=200>
<Font Face=宋体 Size=4 Color="#0000FF" >
描述</FONT>
</TD><TD BGCOLOR="#FFFFFF" ALIGN="left" width=200>
<Font Face=宋体 Size=4 Color="#0000FF" >
帐户</FONT>
</TD><TD BGCOLOR="#FFFFFF" ALIGN="left" width=150>
<Font Face=宋体 Size=4 Color="#0000FF" >
金额_折算人民币</FONT>
</TD></TR>
<?php
$report_2= new report_2;
$k=$report_2->add_item($cookie_user,$date_begin,$date_end);
if (!$limit) $limit=0;
$i=1;
while ($i<=15 and ($i+$limit)<=$k)
{echo "<TR>";
echo "<TD BGCOLOR='#FFFFFF' ALIGN=left>";
echo "<Font Face=宋体 Size=3 Color='#0000FF' >";
echo $report_2->in_ex_type[$limit+$i];
echo "</FONT>";
echo "</TD><TD BGCOLOR='#FFFFFF' ALIGN=left>";
echo "<Font Face=宋体 Size=2 Color='#0000FF' >";
echo $report_2->date[$limit+$i];
echo "</FONT>";
echo "</TD><TD BGCOLOR='#FFFFFF' ALIGN=left>";
echo "<Font Face=宋体 Size=2 Color='#0000FF' >";
echo $report_2->comment[$limit+$i];
echo "</FONT>";
echo "</TD><TD BGCOLOR='#FFFFFF' ALIGN=left>";
echo "<Font Face=宋体 Size=2 Color='#0000FF' >";
echo $report_2->name[$limit+$i];
echo "</FONT>";
echo "</TD><TD BGCOLOR='#FFFFFF' ALIGN=right>";
echo "<Font Face=宋体 Size=2 Color='#0000FF' >";
if ($report_2->money[$limit+$i])
printf ("%.2f",$report_2->money[$limit+$i]);
echo "</FONT>";
echo "</TD></TR>";
$i++;}
echo "</TABLE>";
echo "<P ALIGN=RIGHT>";
$total=floor(($k-1)/15)*15;
$limit_pre=$limit-15;
$limit_next=$limit+15;
echo "<Font Face=宋体 Size=3 Color='#0000FF' >";
echo "第";
echo $limit/15+1;
echo "页 共";
echo $total/15+1;
echo "页 ";
if ($limit!=0)
echo "<a href='report_2.php?limit=0&date_begin=.$date_begin
.&date_end=.$date_end.' STYLE='Text-Decoration:none'>";
echo "首页 ";
if ($limit!=0)
echo "</a>";
if ($limit<$total)
echo "<a href='report_2.php?limit=.$total.&date_begin=.$date_begin
.&date_end=.$date_end.' STYLE='Text-Decoration:none'>";
echo "尾页 ";
if ($limit!=$total)
echo "</a>";
if ($limit_pre>=0)
echo "<a href='report_2.php?limit=.$limit_pre.&date_begin=.$date_begin
.&date_end=.$date_end.' STYLE='Text-Decoration:none'>";
echo "前页 ";
if ($limit_pre>=0) echo "</a>";
if ($limit_next<=$total)
echo "<a href='report_2.php?limit=.$limit_next.&date_begin=.$date_begin
.&date_end=.$date_end.' STYLE='Text-Decoration:none'>";
echo "后页 ";
if ($limit_next<=$total)
echo "</a>";
echo "</FONT>";
?>
</BODY>
</HTML>
如果您对本文有任何疑问或者建议,请到讨论区发表您的意见:
>>
论坛入口 <<
上一篇:一个网上理财站点的设计(十三)
下一篇:一个网上理财站点的设计(十六)
【文章评论】
【收藏本文】
【推荐好友】
【打印本文】
【我要投稿】 【论坛讨论】
更多相关文章
|
|