Linux中国 Linux中国门户站!
设为主页 设为主页
收藏本站 收藏本站
 
当前位置 :首页 ->Linux技术 ->系统管理 ->正文

一个网上理财站点的设计(十四)

来源:Linux-cn.com 作者:Webmaster 时间:2007-05-05 点击: [收藏] [投稿]

  我们这个站点的模拟开发已经逐步进入了尾声,在以后的几个专题内,我们将完成剩下来的几个报表,在专题八中,我们曾经做过一个报表,在下面的几个报表的设计中,我们将仍然沿用那种设计风格。在今天的这个专题内,让我们来看看收支情况明细表的设计,对于这个报表,我们要求可以显示任何时间段内发生的收支情况,并将其按收支类别进行小计,最后给出收入总计、支出总计以及差额总计。下面还是让我们来看看这一部分的源程序:

收支情况明细表(report_2.php)


<?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>


 如果您对本文有任何疑问或者建议,请到讨论区发表您的意见: >> 论坛入口 <<



上一篇:一个网上理财站点的设计(十三)   下一篇:一个网上理财站点的设计(十六)

文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论
更多相关文章