SettingInfoController.class.php
4.11 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
132
133
134
135
136
137
138
139
140
141
142
143
<?php
/**
* Created by PhpStorm.
* User: liyifei2012it
* Date: 16/9/27
* Time: 20:44
* @reader zs_anything 2017-06-29
*/
namespace Apicp\Controller\Invite;
use Common\Common\User;
use Common\Common\Department;
use Common\Model\AttrModel;
use Common\Service\AttrService;
use Common\Service\InviteSettingService;
class SettingInfoController extends AbstractController
{
/**
* 【通讯录】获取邀请函设置
* @author liyifei
*/
public function Index_post()
{
$settingServ = new InviteSettingService();
$data = $settingServ->get_by_conds([]);
if (empty($data)) {
E('_ERR_DATA_IS_NULL');
}
// 读取所有已设置开启的属性详情
$newForm = [];
$attrServ = new AttrService();
$attrs = $attrServ->getAttrList(true, [AttrModel::ATTR_TYPE_SPECIAL, AttrModel::ATTR_TYPE_LEADER], true);
foreach ($attrs as $k => $attr) {
$newForm[$k] = [
'order' => intval($attr['order']),
'postion' => intval($attr['postion']),
'attr_name' => $attr['attr_name'],
'field_name' => $attr['field_name'],
'is_open' => intval($attr['is_open']),
'is_open_edit' => intval($attr['is_open_edit']),
'is_required' => intval($attr['is_required']),
'is_required_edit' => intval($attr['is_required_edit']),
];
}
// 格式化邀请人员、审批人员、部门信息
$inviteUdpids = array(
'selectedList' => array()
);
if (!empty($data['invite_udpids'])) {
$inviteUdpids = unserialize($data['invite_udpids']);
if (empty($inviteUdpids['selectedList'])) {
$inviteUdpids['selectedList'] = array();
} else {
// add zs_anything 2017-06-28 begin
// 过滤已不存在的邀请授权对象
list($existAuthIds, $existAuthInfoList) = $this->filterNonExistAuthTarget($inviteUdpids['selectedList']);
$inviteUdpids['selectedList'] = $existAuthInfoList;
$inviteUdpids['auths'] = $existAuthIds;
// add zs_anything 2017-06-28 end
}
}
// 格式化审核人员
$checkUdpids = '';
if (!empty($data['check_udpids'])) {
$checkUdpids = $this->formateUser(unserialize($data['check_udpids']));
}
// 格式化部门
$department = '';
if (!empty($data['departments'])) {
$department = $this->formateDepartment(unserialize($data['departments']));
}
// 邀请者填写
$inviterWrite = array();
if (!empty($data['inviter_write'])) {
$inviterWrite = unserialize($data['inviter_write']);
}
$this->_result = [
'type' => intval($data['type']),
'qrcode_expire' => intval($data['qrcode_expire']),
'departments' => $department,
'inviter' => $inviteUdpids,
'checker' => $checkUdpids,
'form' => $newForm,
'check_type' => $data['check_type'],
'inviter_write' => $inviterWrite
];
return true;
}
/**
* 格式化人员信息
* @param $uids
* @return array
*/
public function formateUser($uids)
{
$data = [];
$user = new User();
$list = $user->listByUid($uids);
foreach ($list as $k => $item) {
$data[] = [
'uid' => $item['memUid'],
'name' => $item['memUsername'],
'face' => $item['memFace'],
];
}
return $data;
}
/**
* 格式化部门信息
* @param $dps
* @return array
*/
public function formateDepartment($dps)
{
$data = [];
$department = new Department();
$list = $department->listById($dps);
foreach ($list as $k => $item) {
$data[] = [
'dp_id' => $item['dpId'],
'dp_name' => $item['dpName'],
];
}
return $data;
}
}