首页 > php教程 > PHP源码 > 正文

公司内部管理系统

PHP中文网
发布: 2016-05-25 17:00:23
原创
2075人浏览过

1.计算收入或支出表的金额总和

<?php
 
//sum的function是用来记录支出/收入的金额总数。
// 现在遇到的问题是,如何将计算 收入表-支出表的差。
 include 'conn.php';
 
 function sum($name,$table_name){
 
    // 进行数据筛选
    $sql = "SELECT * FROM {$table_name} ";
    $query = mysql_query($sql);
    $list = array();
    $sum1 = 0;
 
    while($res = mysql_fetch_array($query))
    {
        $list[]=$res;
        $sum1 += $res['money'];
    }
    //检测录入的表名,如果是payout,显示负数
    if($table_name == 'payout'){
    echo  '<h3 align = "center" >'.$name.":"." - ".$sum1."</h3>";
    }
    else{
        echo  '<h3 align = "center" >'.$name.":".$sum1."</h3>";
    }
 
}
 // $sum2 = $sum('收入表:','income');
 // $sum1 = $sum('收入表:','payout');
?>
登录后复制

2.收入列表 

<?php
 
     session_start();
   error_reporting(0);
    include 'conn.php';
    include 'header.php';
  include 'sum.php';
    if(!$_SESSION['user']) header('location:index.php');
 
   //分页逻辑
       $length = 5;
        $pagenum=$_GET['page']?$_GET['page']:1;
        $offset = ($pagenum-1) * $length;
        $sql = "SELECT * FROM  income order by id asc limit {$offset},{$length}";
       $query = mysql_query($sql);
 
    //输出表格
    echo '<table width="80%" border="0" cellpadding="0" cellspacing="1" bgcolor="#c9c9c9" align="center">
      <tr>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE1">项目</span></strong></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE1">摘要</span></strong></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE1">金额(元)</span></strong></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE1">签订合同</span></strong></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE1">提成</span></strong></div></td>
         <td height="22" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE1">日期</span></strong></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE1">负责人</span></strong></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE1">操作</span></strong></div></td>
      </tr>';
        echo "<h3 align='center'>收入明细表</h3>";
    while($res = mysql_fetch_array($query))
    {
 
?>
<html>
<meta http-equiv='Content-Type' content='text/html' charset='UTF-8' >
<head>
    <title></title>
</head>
<body>
  <form action="income_action.php" method="post">
         
        <tr>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><?php echo $res['project']; ?></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><span class="STYLE3"><?php echo $res['abs']; ?></span></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><span class="STYLE3"><?php echo $res['money']; ?></span></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><span class="STYLE3"><?php echo $res['whether']; ?> </span></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center" class="STYLE5"><?php echo $res['commi']; ?></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center" class="STYLE5"><?php echo $res['dates']; ?></div></td>                                                                       
 
        <td height="22" bgcolor="#FFFFFF"><div align="center" class="STYLE5"><?php echo $res['user']; ?></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center" class="STYLE5"><a href="income_edit.php?id=<?php echo $res['id'];?>">编辑</a>
                                          <a href="income_del.php?id=<?php echo $res['id'];?>">删除</a></div></td>
      </tr>
 
         
         
 
    </form>
        </body>
</html>
 
<?php
}
echo "</table>";
//获取上一页下一页
        $prevpage = $pagenum-1;
        $nextpage = $pagenum+1;
?>
<html>
<meta http-equiv='Content-Type' content='text/html' charset='UTF-8' >
<head>
  <title></title>
</head>
<body>
  <h3 align="center" ><a href="inlist.php?page=<?php echo $prevpage ?>">上一页</a> | <a href="inlist.php?page=<?php echo $nextpage ?>">下一页</a> </h3>
</body>
</html>
<?php
  
 // 计算总价
   
  echo $table =sum('收入表明细','income');
 
?>
登录后复制

3.支出列表 

<?php
 
  //读取payout表中的内容,并以表格形式显示
  session_start();
  error_reporting(0);
  include("conn.php");
  include 'function.php';
  include 'sum.php';
  if(!$_SESSION['user']) header("location:login.php");
  include("header.php");
  echo '<meta http-equiv="Content-Type" content="text/html" charset="utf-8" />';
 
  //分页逻辑
        $pagesize = 20;
        $pagenum = $_GET['page'] ? $_GET['page'] : 1;
        $offset = ($pagenum - 1) * $pagesize;
        $sql = "SELECT * FROM payout order by pid asc limit {$pagenum},{$pagesize} ";
        $query = mysql_query($sql);
         
 
  //表格开始
  echo '<table width="80%" border="0" cellpadding="0" cellspacing="1" bgcolor="#c9c9c9" align="center">'; 
  echo '<tr>
        <td height="26" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE2">项目明细</span></strong></div></td>
        <td height="26" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE2">摘要</span></strong></div></td>
        <td height="26" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE2">金额</span></strong></div></td>
        <td height="26" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE2">日期</span></strong></div></td>
        <td height="26" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE2">经手人</span></strong></div></td>
      </tr>';
     echo "<h3 align='center'>支出明细表</h3>";
 
  //循环读取数据开始
  while ( $res = mysql_fetch_array($query)) {
?>
<!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>
<title>支出表填写</title>
<style type="text/css">
<!--
.STYLE1 {font-size: 12px}
.STYLE3 {color: #707070; font-size: 12px; }
.STYLE5 {color: #707070; font-size: 14px; }
body {
    margin-top: 0px;
    margin-bottom: 0px;
}
.STYLE7 {font-size: 12}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
 
<body>
<form action="payout_action.php" method="post" >
 
  <tr>
    <td>
      <tr>
        <td height="26" bgcolor="#FFFFFF"><div align="center" class="STYLE5"><?php echo $res['project']; ?> </div></td>
        <td height="26" bgcolor="#FFFFFF"><div align="center" class="STYLE5"><?php echo $res['abs']; ?></div></td>
        <td height="26" bgcolor="#FFFFFF"><div align="center" class="STYLE5"><?php echo $res['money']; ?></div></td>
        <td height="26" bgcolor="#FFFFFF"><div align="center" class="STYLE5"><?php echo $res['dates']; ?></div></td>
        <td height="26" bgcolor="#FFFFFF"><div align="center" class="STYLE5"> <?php echo $res['user']; ?></div></td>
      </tr>
 
<?php
}
 echo "</table>";
 
  //获取上一页下一页
        $prevpage = $pagenum-1;
     
        $nextpage = $pagenum+1;
 
 
?>
 
  <h3 align="center" ><a href="paylist.php?page=<?php echo $prevpage ?>">上一页</a> | <a href="paylist.php?page=<?php echo $nextpage ?>">下一页</a> </h3>
</form>
</body>
</html>
<?php
  
 $sql = "SELECT * from payout";
 $query = mysql_query($sql);
 
 //开始计算
   
  echo $sum = sum("收入表","payout");
 mysql_close();
 
 
?>
登录后复制
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号