123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <?php
- // +—————————————————————————————————————————————————————————————————————
- // | Created by Yunbao
- // +—————————————————————————————————————————————————————————————————————
- // | Copyright (c) 2013~2022 http://www.yunbaokj.com All rights reserved.
- // +—————————————————————————————————————————————————————————————————————
- // | Author: https://gitee.com/yunbaokeji
- // +—————————————————————————————————————————————————————————————————————
- // | Date: 2022-04-30
- // +—————————————————————————————————————————————————————————————————————
- /**
- * 管理员日志
- */
- namespace app\admin\controller;
- use cmf\controller\AdminBaseController;
- use think\Db;
- class AdminlogController extends AdminbaseController {
- function index(){
-
- $data = $this->request->param();
- $map=[];
-
- $start_time=isset($data['start_time']) ? $data['start_time']: '';
- $end_time=isset($data['end_time']) ? $data['end_time']: '';
-
- if($start_time!=""){
- $map[]=['addtime','>=',strtotime($start_time)];
- }
- if($end_time!=""){
- $map[]=['addtime','<=',strtotime($end_time) + 60*60*24];
- }
-
- $adminid=isset($data['adminid']) ? $data['adminid']: '';
- if($adminid!=''){
- $map[]=['adminid','=',$adminid];
- }
-
- $lists = Db::name("admin_log")
- ->where($map)
- ->order("id DESC")
- ->paginate(20);
-
- $lists->appends($data);
- $page = $lists->render();
- $this->assign('lists', $lists);
- $this->assign("page", $page);
-
- return $this->fetch();
- }
-
- function del(){
- $id = $this->request->param('id', 0, 'intval');
-
- $rs = DB::name('admin_log')->where("id={$id}")->delete();
- if(!$rs){
- $this->error("删除失败!");
- }
-
- $this->success("删除成功!");
-
- }
-
- function export(){
- $data = $this->request->param();
- $map=[];
-
- $start_time=isset($data['start_time']) ? $data['start_time']: '';
- $end_time=isset($data['end_time']) ? $data['end_time']: '';
-
- if($start_time!=""){
- $map[]=['addtime','>=',strtotime($start_time)];
- }
- if($end_time!=""){
- $map[]=['addtime','<=',strtotime($end_time) + 60*60*24];
- }
-
- $adminid=isset($data['adminid']) ? $data['adminid']: '';
- if($adminid!=''){
- $map[]=['adminid','=',$adminid];
- }
-
-
- $xlsName = "管理员日志";
- $xlsData=Db::name("admin_log")->where($map)->order("addtime DESC")->select()->toArray();
-
- foreach ($xlsData as $k => $v)
- {
- $xlsData[$k]['ip']=long2ip($v['ip']);
- $xlsData[$k]['addtime']=date("Y-m-d H:i:s",$v['addtime']);
- }
- $cellName = array('A','B','C','D','E');
- $xlsCell = array(
- array('id','序号'),
- array('admin','管理员'),
- array('action','行为'),
- array('ip','IP'),
- array('addtime','提交时间'),
- );
- exportExcel($xlsName,$xlsCell,$xlsData,$cellName);
- }
-
- }
|