ClockController.php
3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
/**
* Created by PhpStorm.
* auther: sgj
* Date: 2020/10/14
* Time: 20:13
*/
namespace app\admin\controller;
use cmf\controller\AdminBaseController;
class ClockController extends AdminBaseController
{
/**
* @return mixed
*/
public function index(){
$param=$this->request->param();
$map=[];
if(!empty($param['keyword'])){
$map['c.activity_name']=['like',"%$param[keyword]%"];
}
$data= db('clock')->alias('c')
->field('v.name as user_name,v.photo,c.*')
->join('user u','u.id=c.user_id')
->join('volunteer v','v.user_id=c.user_id')
->where($map)
->order('c.id desc')
->paginate();
$data->appends($param);
$list=$data->items();
$this->assign([
'data'=>$list,
'page'=>$data->render(),
'keyword'=>$param['keyword']??''
]);
return $this->fetch();
}
public function addclock(){
$param=input();
$map['j.id']=$param['id'];
$data= db('join')->alias('j')
->field('v.name as user_name,v.photo,v.sex,v.birthday,v.move_phone,v.card_number as id_card,j.*,a.activity_name,a.start_time,a.long,a.lat')
->join('user u','u.id=j.user_id')
->join('volunteer v','v.user_id=j.user_id')
->join('activity a','a.id=j.activity_id')
->where($map)
->find();
$this->assign('data',$data);
return $this->fetch();
}
/**
*提交信息
*/
public function addpost(){
$update= $this->request->param();
$result=db('clock')->insert($update);
if ($result){
$this->success('操作成功!');
}else{
$this->error('操作失败!');
}
}
public function info(){
$param=$this->request->param();
$map=[];
}
/**
* 编辑信息
* @return mixed
*/
public function edit(){
$id = input('id');
$param = $this->request->param();
$map['c.id'] = $id;
$data = db('clock')->alias('c')
->field('v.name as user_name,v.photo,c.*')
->join('user u','u.id=c.user_id')
->join('volunteer v','v.user_id=c.user_id')
->where($map)
->find();
if(empty($data['user_start'])){
$data['user_start']='';
}else{
$data['user_start']=date('Y-m-d H:i:s',$data['user_start']);
}
if(empty($data['user_end'])){
$data['user_end']='';
}else{
$data['user_end']=date('Y-m-d H:i:s',$data['user_end']);
}
$this->assign('data', $data);
return $this->fetch();
}
/**
* 添加信息
* @return mixed
*/
public function add(){
return $this->fetch();
}
public function editPost(){
$id = input('id');
$update= $this->request->param();
$update['user_start']=strtotime($update['user_start']);
$update['user_end']=strtotime($update['user_end']);
$result=db('clock')->where('id',$id)->update($update);
$this->success('操作成功!');
}
}