2db47680
hexiaodong
chore: 初始提交 php 遗...
|
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
<?php
namespace app\admin\controller\antis\canlendar;
use addons\antis\model\Staff;
use app\admin\controller\antis\Base;
use addons\antis\model\Event;
use addons\antis\model\Customer;
use addons\antis\model\Contacts;
use addons\antis\model\Contract;
use addons\antis\model\Leads;
use think\DB;
use fast\Tree;
/**
* 日程
*/
class Canlendar extends Base {
public function _initialize() {
parent::_initialize();
$this->model = new Event();
}
/**
* 日程列表
*/
public function index() {
$this->request->filter(['strip_tags']);
$need = input('need','');
if ($this->request->isAjax()) {
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$wheres['type'] =1;
$wheres['staff_id'] = ['in',Staff::getMyStaffIds()];
if(isset($need) && $need == 'canlendar'){
$wheres['staff_id'] = $this->_staff->id;
$wheres['status'] = array('in','0,1');
}
if(isset($need) && $need == 'task'){
$wheres['staff_id'] = $this->_staff->id;
$wheres['status'] = array('in','0,1');
$wheres['start_time'] = ['lt', date('Y-m-d', strtotime('+1 day'))];
}
$list = $this->model->where($where)->where($wheres)->order($sort, $order)->paginate($limit);
$row = $list->items();
$result = array("total" => $list->total(), "rows" => $row);
return json($result);
}
return $this->view->fetch();
}
/**
* 添加日程
*/
public function add() {
if ($this->request->isAjax()) {
$data = $this->request->post('row/a');
$staff = Staff::info();
$data['staff_id'] = $staff->id;
$result = $this->model->save($data);
if (!$result) {
$this->error('提交失败');
}
$this->success('提交成功');
}
$customer = Customer::where(['owner_staff_id'=>['in',Staff::getMyStaffIds()]])->field('id,name')->select();
$this->view->assign("customer", $customer);
return $this->view->fetch();
}
/**
* 修改日程
*/
public function edit($ids = null) {
$map['id'] = $ids;
if ($this->request->isAjax()) {
$data = $this->request->post('row/a');
$result = $this->model->save($data, $map);
if (!$result) {
$this->error('修改失败');
}
$this->success('修改成功');
}
$data = $this->model->where($map)->find();
if($data['relation_type'] == 1){
$customer = Customer::where(['owner_staff_id'=>['in',Staff::getMyStaffIds()]])->field('id,name')->select();
}elseif($data['relation_type'] == 2){
$customer = Contacts::where(['owner_staff_id'=>['in',Staff::getMyStaffIds()]])->field('id,name')->select();
}elseif($data['relation_type'] == 3){
$customer = Contract::where(['owner_staff_id'=>['in',Staff::getMyStaffIds()]])->field('id,name')->select();
}elseif($data['relation_type'] == 4){
$customer = Leads::where(['owner_staff_id'=>['in',Staff::getMyStaffIds()]])->field('id,name')->select();
}else{
$customer = Customer::where(['owner_staff_id'=>['in',Staff::getMyStaffIds()]])->field('id,name')->select();
}
$this->view->assign("customer", $customer);
$this->view->assign("row", $data);
return $this->view->fetch();
}
/**
* 删除日程
*/
public function del($ids = null) {
if ($this->request->isAjax()) {
$map['id'] = array('in', $ids);
$result = $this->model->destroy($map);
if (!$result) {
$this->error('删除失败');
}
$this->success('删除成功');
}
return $this->view->fetch();
}
/**
* 获取客户列表
*/
public function customer(){
$list = Customer::where(['owner_staff_id'=>['in',Staff::getMyStaffIds()]])->field('id,name')->select();
$this->success('','',$list);
}
/**
* 获取联系人列表
*/
public function contacts(){
$list = Contacts::where(['owner_staff_id'=>['in',Staff::getMyStaffIds()]])->field('id,name')->select();
$this->success('','',$list);
}
/**
* 获取合同列表
*/
public function contract(){
$list = Contract::where(['owner_staff_id'=>['in',Staff::getMyStaffIds()]])->field('id,name')->select();
$this->success('','',$list);
}
/**
* 获取线索列表
*/
public function leads(){
$list = Leads::where(['owner_staff_id'=>['in',Staff::getMyStaffIds()]])->field('id,name')->select();
$this->success('','',$list);
}
}
|