<?php
include_once("shangmian.php");
?>
<table align="center" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100%"></td>
</tr>
<tr>
<td align="left" valign="top"><table align="center" width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#B3B3B3">
<tr>
<th align="left" valign="middle" bgcolor="#EBEBEB">亲,欢迎使用php mysql简单记账程序。</th>
</tr>
</table>
<table align="center" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="5"></td>
</tr>
</table>
<?php
include("config.php");
$income=0;
$spending=0;
$zuorishou=0;
$zuorifu=0;
$yueshou=0;
$yuefu=0;
$nianshou=0;
$nianfu=0;
$qiannianshou=0;
$qiannianfu=0;
?>
<table width='100%' border='0' align='center' cellpadding='5' cellspacing='1' bgcolor='#B3B3B3'>
<tr>
<th width='20%' bgcolor='#EBEBEB'></th>
<th width='20%' bgcolor='#EBEBEB'>本日</th>
<th width='20%' bgcolor='#EBEBEB'>本周</th>
<th width='20%' bgcolor='#EBEBEB'>本月</th>
<th width='20%' bgcolor='#EBEBEB'>本年</th>
</tr>
<tr><td align='center' bgcolor='#FFFFFF'><font color="#FF0000">支出</font></td>
<td align='center' bgcolor='#FFFFFF'><font color="#FF0000" id="ri2"></font></td>
<td align='center' bgcolor='#FFFFFF'><font color="#FF0000" id="zhou2"></font></td>
<td align='center' bgcolor='#FFFFFF'><font color="#FF0000" id="yue2"></font></td>
<td align='center' bgcolor='#FFFFFF'><font color="#FF0000" id="nian2"></font></td>
</tr>
<tr><td align='center' bgcolor='#FFFFFF'><font color="blue">收入</font></td>
<td align='center' bgcolor='#FFFFFF'><font color="blue" id="ri1"></font></td>
<td align='center' bgcolor='#FFFFFF'><font color="blue" id="zhou1"></font></td>
<td align='center' bgcolor='#FFFFFF'><font color="blue" id="yue1"></font></td>
<td align='center' bgcolor='#FFFFFF'><font color="blue" id="nian1"></font></td>
</tr>
</table>
<table align="center" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="5"></td>
</tr>
</table>
<table width='100%' border='0' align='center' cellpadding='5' cellspacing='1' bgcolor='#B3B3B3'>
<tr>
<th width='20%' bgcolor='#EBEBEB'></th>
<th width='20%' bgcolor='#EBEBEB'>昨日</th>
<th width='20%' bgcolor='#EBEBEB'>上周</th>
<th width='20%' bgcolor='#EBEBEB'>上月</th>
<th width='20%' bgcolor='#EBEBEB'>去年</th>
</tr>
<tr><td align='center' bgcolor='#FFFFFF'><font color="#FF0000">支出</font></td>
<td align='center' bgcolor='#FFFFFF'><font color="#FF0000" id="qianri2"></font></td>
<td align='center' bgcolor='#FFFFFF'><font color="#FF0000" id="qianzhou2"></font></td>
<td align='center' bgcolor='#FFFFFF'><font color="#FF0000" id="qianyue2"></font></td>
<td align='center' bgcolor='#FFFFFF'><font color="#FF0000" id="qiannian2"></font></td>
</tr>
<tr><td align='center' bgcolor='#FFFFFF'><font color="blue">收入</font></td>
<td align='center' bgcolor='#FFFFFF'><font color="blue" id="qianri1"></font></td>
<td align='center' bgcolor='#FFFFFF'><font color="blue" id="qianzhou1"></font></td>
<td align='center' bgcolor='#FFFFFF'><font color="blue" id="qianyue1"></font></td>
<td align='center' bgcolor='#FFFFFF'><font color="blue" id="qiannian1"></font></td>
</tr>
</table>
<tr>
<td height="35"><font id="tongji"></font></td>
</tr>
<?php
//每页显示的数
$pagesize = 10;
//确定页数 p 参数
$p = $_GET['p']?$_GET['p']:1;
//数据指针
$offset = ($p-1)*$pagesize;
//查询本页显示的数据
$query_sql = "SELECT * FROM jizhang_account ORDER BY actime DESC LIMIT $offset , $pagesize";
$query=mysql_query($query_sql);
echo "<table width='100%' border='0' align='center' cellpadding='5' cellspacing='1' bgcolor='#B3B3B3'>
<tr>
<th width='120' bgcolor='#EBEBEB'>账目分类</th>
<th width='50' bgcolor='#EBEBEB'>金额</th>
<th width='90' bgcolor='#EBEBEB'>支出/收入</th>
<th width='150' bgcolor='#EBEBEB'>时间</th>
<th width='60' bgcolor='#EBEBEB'>备注</th>
<th width='90' bgcolor='#EBEBEB'>操作</th>
</tr>";
if($result === FALSE) {
die(mysql_error()); // TODO: better error handling
}
while($row = mysql_fetch_array($query)){
$sql="select * from jizhang_account_class where classid= $row[acclassid]";
$classquery=mysql_query($sql);
$classinfo = mysql_fetch_array($classquery);
echo "<tr>";
echo "<td align='center' bgcolor='#FFFFFF'>" . $classinfo['classname'] . "</td>";
echo "<td align='center' bgcolor='#FFFFFF'>" . $row['acmoney'] . "</td>";
if($classinfo[classtype]==1){
echo "<td align='center' bgcolor='#FFFFFF'><font color='blue'>收入</font></td>";
$income=$income+$row[acmoney];
}else{
echo "<td align='center' bgcolor='#FFFFFF'><font color='red'>支出</font></td>";
$spending=$spending+$row[acmoney];
}
echo "<td align='center' bgcolor='#FFFFFF'>".date("Y-m-d G:i",$row[actime])."</td>";
echo "<td align='center' bgcolor='#FFFFFF'>" . $row[acremark] . "</td>";
echo "<td align='center' bgcolor='#FFFFFF'><a href=xiugai.php?id=".$row['acid'].">编辑</a> <a href=shanchu.php?id=".$row['acid'].">删除</a></td>";
echo "</tr>";
}
echo "</table>";
echo "<table width='100%' border='0' align='center' cellpadding='5' cellspacing='1' bgcolor='#B3B3B3'>
<tr><td align='center' bgcolor='#FFFFFF'>";
//分页代码
//计算总数
$count_result = mysql_query("SELECT count(*) as count FROM jizhang_account");
$count_array = mysql_fetch_array($count_result);
//计算总的页数
$pagenum=ceil($count_array['count']/$pagesize);
echo '共记 ',$count_array['count'],' 条';
//循环输出各页数目及连接
if ($pagenum > 1) {
for($i=1;$i<=$pagenum;$i++) {
if($i==$p) {
echo ' [',$i,']';
} else {
echo ' <a href="index.php?p=',$i,'">',$i,'</a>';
}
}
}
echo "</td></tr></table>";
?>
<?php
//当日收付统计
$k=date("Y-m-d");
$sqltime=" actime >".strtotime($k." 0:0:0")." and actime <".strtotime($k." 23:59:59");
$query_sql = "SELECT * FROM jizhang_account where ".$sqltime." ";
$query=mysql_query($query_sql);
while($row = mysql_fetch_array($query)){
$sql="select * from jizhang_account_class where classid= $row[acclassid]";
$classquery=mysql_query($sql);
$classinfo = mysql_fetch_array($classquery);
if($classinfo[classtype]==1){
$rishou=$rishou+$row[acmoney];
}else{
$rifu=$rifu+$row[acmoney];
}
} ?>
<?php
//周收付统计
$k=date("Y-m-d",mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y")));
$j=date("Y-m-d",mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y")));
$sqltime=" actime >".strtotime($k." 0:0:0")." and actime <".strtotime($j." 23:59:59");
$query_sql = "SELECT * FROM jizhang_account where ".$sqltime." ";
$query=mysql_query($query_sql);
while($row = mysql_fetch_array($query)){