<?php
include ("cookie_check.php");
class report_4 {
var $in_ex_type; //类型
var $money_old;//被对照金额
var $money_new;//被对照金额
// 本方法生成某用户的收支情况明细表
function add_item ($user, $date_begin_old,$date_end_old,
$date_begin_new,$date_end_new) {
$sum_old_0=0;
$sum_new_0=0;
$sum_old_1=0;
$sum_new_1=0;
$i=1;
$this->in_ex_type[1]='收入';
$query = "select distinct in_ex_type.name as
in_ex_type,in_ex_type.code as id_in_ex_type from in_ex_condition,
in_ex_type
where ((date>='".$date_begin_old."' and date<='".$date_end_old."')
or (date>='".$date_begin_new."' and date<='".$date_end_new."')) and
in_ex_condition.user='".$user."' and in_ex_condition.in_ex_type= in_ex_type.
code and in_ex_type.type=0 and in_ex_type<>44 and in_ex_type<>1";
$res = mysql_query($query);
$row = @mysql_fetch_array($res);
while ($row)
{$i++;
$this->in_ex_type[$i] = $row['in_ex_type'];
$query = "select sum(money*exchange_rate) as mymoney from
in_ex_condition,account,currency
where date>='".$date_begin_old."' and date<='".$date_end_old."'
and account.currency=currency.code and in_ex_condition.account=account.code
and in_ex_condition.user='".$user."' and
in_ex_condition.in_ex_type=".$row['id_in_ex_type']." group by in_ex_type";
$res1 = mysql_query($query);
$row1 = @mysql_fetch_array($res1);
$this->money_old[$i] = $row1['mymoney'];
$sum_old_0=$sum_old_0+$row1['mymoney'];
$query = "select sum(money*exchange_rate) as mymoney
from in_ex_condition,account,currency where
date>='".$date_begin_new."'
and date<='".$date_end_new."' and account.currency=currency.code
and in_ex_condition.account=account.code and
in_ex_condition.user='".$user."'
and in_ex_condition.in_ex_type=".$row['id_in_ex_type']."
group by in_ex_type";
$res1 = mysql_query($query);
$row1 = @mysql_fetch_array($res1);
$this->money_new[$i] = $row1['mymoney'];
$sum_new_0=$sum_new_0+$row1['mymoney'];
$row = @mysql_fetch_array($res);
}
$i++;
$this->money_old[$i] = $sum_old_0;
$this->money_new[$i] = $sum_new_0;
$i++;
$this->in_ex_type[$i]='支出';
$query = "select distinct in_ex_type.name as in_ex_type,in_ex_type.code
as id_in_ex_type from in_ex_condition,in_ex_type
where ((date>='".$date_begin_old."' and date<='".$date_end_old."') or
(date>='".$date_begin_new."' and date<='".$date_end_new."')) and
in_ex_condition.user='".$user."' and in_ex_condition.in_ex_type= in_ex_type.code
and in_ex_type.type=1 and in_ex_type<>44 and in_ex_type<>1";
$res = mysql_query($query);
$row = @mysql_fetch_array($res);
while ($row)
{$i++;
$this->in_ex_type[$i] = $row['in_ex_type'];
$query = "select sum(money*exchange_rate) as mymoney from
in_ex_condition,account,currency where date>='".$date_begin_old."'
and date<='".$date_end_old."' and account.currency=currency.code and
in_ex_condition.account=account.code and
in_ex_condition.user='".$user."' and
in_ex_condition.in_ex_type=".$row['id_in_ex_type']." group by in_ex_type";
$res1 = mysql_query($query);
$row1 = @mysql_fetch_array($res1);
$this->money_old[$i] = $row1['mymoney'];
$sum_old_1=$sum_old_1+$row1['mymoney'];
$query = "select sum(money*exchange_rate) as mymoney from
in_ex_condition,account,currency where date>='".$date_begin_new."'
and date<='".$date_end_new."' and account.currency=currency.code and
in_ex_condition.account=account.code and
in_ex_condition.user='".$user."' and
in_ex_condition.in_ex_type=".$row['id_in_ex_type']." group by in_ex_type";
$res1 = mysql_query($query);
$row1 = @mysql_fetch_array($res1);
$this->money_new[$i] = $row1['mymoney'];
$sum_new_1=$sum_new_1+$row1['mymoney'];
$row = @mysql_fetch_array($res);
}
$i++;
$this->money_old[$i] = $sum_old_1;
$this->money_new[$i] = $sum_new_1;
$i++;
$this->money_old[$i] = $sum_old_0-$sum_old_1;
$this->money_new[$i] = $sum_new_0-$sum_new_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_4.php"
STYLE="Text-Decoration:none">收入支出比较表</A>
<P ALIGN=CENTER><FONT FACE="隶书" SIZE="6" COLOR="#0000FF">
收入支出比较表</FONT><BR>
<FORM NAME="report_3" ACTION="report_3.php" METHOD="POST">
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD BGCOLOR="#FFFFFF" width=700>
<Font Face=宋体 Size=2 Color="#0000FF" ><b>将</b><INPUT
TYPE=TEXT NAME="date_begin_new" SIZE="10" MAXLENGTH="10" value='<?php
if (!$date_begin_new)
{$today=getdate();
$date_begin_new=sprintf ("%04s-01-01",$today['year']);}
echo $date_begin_new
?>' onchange=javascript:document.report_3.submit()>-<INPUT TYPE=TEXT
NAME="date_end_new" SIZE="10" MAXLENGTH="10" value='<?php
if (!$date_end_new)
{$today=getdate();
$date_end_new=sprintf ("%04s-%02s-%02s",$today['year'],$today['mon']
,$today['mday']);}
echo $date_end_new
?>' onchange=javascript:document.report_3.submit()><b>与
</b><INPUT TYPE=TEXT NAME="date_begin_old" SIZE="10"
MAXLENGTH="10" value='<?php
if (!$date_begin_old)
{$today=getdate();
$date_begin_old=sprintf ("%04s-01-01",$today['year']-1);}
echo $date_begin_old
?>' onchange=javascript:document.report_3.submit()>-
<INPUT TYPE=TEXT NAME="date_end_old" SIZE="10"
MAXLENGTH="10" value='<?php
if (!$date_end_old)
{$today=getdate();
$date_end_old=sprintf ("%04s-%02s-%02s",$today['year']-1,
$today['mon'],$today['mday']);}
echo $date_end_old
?>' onchange=javascript:document.report_3.submit()>
<b>作比较</b></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="right"
width=250><Font Face=宋体 Size=4 Color="#0000FF" >
<?php echo $date_begin_old."到".$date_end_old ?></FONT>
</TD><TD BGCOLOR="#FFFFFF" ALIGN="right"
width=250><Font Face=宋体 Size=4 Color="#0000FF" >
<?php echo $date_begin_new."到".$date_end_new ?></FONT>
</TD><TD BGCOLOR="#FFFFFF" ALIGN="right" width=150>
<Font Face=宋体 Size=4 Color="#0000FF" >
差额_折算人民币</FONT>
</TD></TR>
<?php
$report_4= new report_4;
$k=$report_4->add_item($cookie_user,$date_begin_old,$date_end_old,
$date_begin_new,$date_end_new);
if (!$limit) $limit=0;
$i=1;
while ($i<=15 and ($i+$limit)<=$k)
{echo "<TR>";
echo "<TD BGCOLOR='#FFFFFF' ALIGN=left>";
if ($report_4->in_ex_type[$limit+$i]!='收入' &&
$report_4->in_ex_type[$limit+$i]!='支出')
echo "<Font Face=宋体 Size=2 Color='#0000FF' >";
else
echo "<Font Face=宋体 Size=3 Color='#000000' >";
echo $report_4->in_ex_type[$limit+$i];
echo "</FONT>";
echo "</TD><TD BGCOLOR='#FFFFFF' ALIGN=right>";
if ($report_4->in_ex_type[$limit+$i])
echo "<Font Face=宋体 Size=2 Color='#0000FF' >";
else
echo "<Font Face=宋体 Size=2 Color='#000000' >";
if ($report_4->in_ex_type[$limit+$i]!='收入' &&
$report_4->in_ex_type[$limit+$i]!='支出')
printf ("%.2f",$report_4->money_old[$limit+$i]);
echo "</FONT>";
echo "</TD><TD BGCOLOR='#FFFFFF' ALIGN=right>";
if ($report_4->in_ex_type[$limit+$i])
echo "<Font Face=宋体 Size=2 Color='#0000FF' >";
else
echo "<Font Face=宋体 Size=2 Color='#000000' >";
if ($report_4->in_ex_type[$limit+$i]!='收入' &&
$report_4->in_ex_type[$limit+$i]!='支出')
printf ("%.2f",$report_4->money_new[$limit+$i]);
echo "</FONT>";
echo "</TD><TD BGCOLOR='#FFFFFF' ALIGN=right>";
if ($report_4->in_ex_type[$limit+$i])
echo "<Font Face=宋体 Size=2 Color='#0000FF' >";
else
echo "<Font Face=宋体 Size=2 Color='#000000' >";
if ($report_4->in_ex_type[$limit+$i]!='收入' &&
$report_4->in_ex_type[$limit+$i]!='支出')
printf ("%.2f",$report_4->money_new[$limit+$i]
-$report_4->money_old[$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_3.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_3.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_3.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_3.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>
如果您对本文有任何疑问或者建议,请到讨论区发表您的意见:
>>
论坛入口 <<
上一篇:一个网上理财站点的设计(十四)
下一篇:一个网上理财站点的设计(十七)
【文章评论】
【收藏本文】
【推荐好友】
【打印本文】
【我要投稿】 【论坛讨论】
更多相关文章
|
|