PHP 实现发件箱功能2

sendBox.html 模板

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="__ADMIN__/css/base.css" />
<link rel="stylesheet" href="__ADMIN__/css/info-mgt.css" />
<link rel="stylesheet" href="__ADMIN__/css/WdatePicker.css" />
<title>移动办公自动化系统</title>
<style type='text/css'>
    table tr .id{ width:63px; text-align: center;}
    table tr .name{ width:118px; padding-left:17px;}
    table tr .nickname{ width:63px; padding-left:17px;}
    table tr .dept_id{ width:63px; padding-left:13px;}
    table tr .sex{ width:63px; padding-left:13px;}
    table tr .birthday{ width:80px; padding-left:13px;}
    table tr .tel{ width:113px; padding-left:13px;}
    table tr .email{ width:160px; padding-left:13px;}
    table tr .addtime{ width:160px; padding-left:13px;}
    table tr .operate{ padding-left:13px;}
</style>
</head>

<body>
<div class="title"><h2>邮件管理</h2></div>
<div class="table-operate ue-clear">
    <a href="__CONTROLLER__/add" class="add">添加</a>
    <a href="javascript:;" class="del">删除</a>
    <a href="javascript:;" class="edit">编辑</a>
    <a href="javascript:;" class="check">审核</a>
</div>
<div class="table-box">
    <table>
        <thead>
            <tr>
                <th class="id">序号</th>
                <th class="name">收件人</th>
                <th class="name">标题</th>
                <th class="file">附件</th>
                <th class="content">内容</th>
                <th class="addtime">发送时间</th>
                <th class="status">状态</th>
                <th class="operate">操作</th>
            </tr>
        </thead>
        <tbody>
            <volist name='data' id='vo'>
            <tr>
                <td class="id">{$vo.id}</td>
                <td class="name">{$vo.truename}</td>
                <td class="name">{$vo.title}</td>
                <td class="file">{$vo.filename}<if condition='$vo.hasfile == 1'>【<a href="__CONTROLLER__/download/id/{$vo.id}">下载</a>】</if></td>
                <td class="content">{$vo.content|msubstr=###,0,10}</td>
                <td class="addtime">{$vo.addtime|date='Y-m-d H:i:s',###}</td>
                <td class="status"><if condition='$vo.isread == 0'><span style="color: red;">未读</span><else/><span style="color:grey;">已读</span></if></td>
                <td class="operate">
                    <a href ='javascript:;'>删除</a> 
                </td>
            </tr>
            </volist>
        </tbody>
    </table>
</div>
<div class="pagination ue-clear">
    <div class="pagin-list">
        {$page}
    </div>
    <div class="pxofy">共 {$count} 条记录</div>
</div>
</body>
<script type="text/javascript" src="__ADMIN__/js/jquery.js"></script>
<script type="text/javascript" src="__ADMIN__/js/common.js"></script>
<script type="text/javascript" src="__ADMIN__/js/WdatePicker.js"></script>
<script type="text/javascript">
$(".select-title").on("click",function(){
    $(".select-list").hide();
    $(this).siblings($(".select-list")).show();
    return false;
})
$(".select-list").on("click","li",function(){
    var txt = $(this).text();
    $(this).parent($(".select-list")).siblings($(".select-title")).find("span").text(txt);
})

$("tbody").find("tr:odd").css("backgroundColor","#eff6fa");

showRemind('input[type=text], textarea','placeholder');
</script>
</html>

 

EmailController.class.php

 

//sendBox
    public function sendBox(){
        //查询当前用户发送的邮件
        //查询语句 select t1.*,t2.truename as truename from sp_email as t1 left join sp_user as t2 on t1.to_id = t2.id where t1.from_id = 1
        $data = M('Email') -> field('t1.*,t2.truename as truename') -> alias(' t1') -> join('left join sp_user as t2 on t1.to_id = t2.id') -> where('t1.from_id = 1')->select();
        //dump($data);die;
        //将数据传递给模板
        $this -> assign('data',$data);
        //传递给模板
        $this -> display();
    }

    //download方法
    public function download(){
        //接收id
        $id = I('get.id');
        //查询信息
        $data = M('Email') -> find($id);
        //下载代码
        $file = WORKING_PATH . $data['file'];   //文件的根目录路径
        //dump($file);die;
        header('Content-type: application/octee-stream'); //流信息
        header('Content-Disposition: attachment; filename="' .basename($file) . '"');  // 附件
        header("Content-Length: ". filesize($file)); // 文件大小
        readfile($file);  // 输出文件
    }
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值