1 |
www |
1 |
<?php
|
|
|
2 |
declare(strict_types=1);
|
|
|
3 |
|
|
|
4 |
namespace LeadersLinked\Controller;
|
|
|
5 |
|
|
|
6 |
use Laminas\Db\Adapter\AdapterInterface;
|
16768 |
efrain |
7 |
|
1 |
www |
8 |
use Laminas\Mvc\Controller\AbstractActionController;
|
|
|
9 |
use Laminas\Log\LoggerInterface;
|
|
|
10 |
use Laminas\View\Model\ViewModel;
|
|
|
11 |
use Laminas\View\Model\JsonModel;
|
|
|
12 |
use Laminas\Db\Sql\Expression;
|
|
|
13 |
use LeadersLinked\Model\Job;
|
|
|
14 |
use LeadersLinked\Mapper\JobSkillMapper;
|
|
|
15 |
use LeadersLinked\Mapper\SkillMapper;
|
|
|
16 |
use LeadersLinked\Mapper\UserMapper;
|
|
|
17 |
use LeadersLinked\Model\User;
|
|
|
18 |
use LeadersLinked\Mapper\CompanyLocationMapper;
|
|
|
19 |
use LeadersLinked\Mapper\CompanySizeMapper;
|
|
|
20 |
use LeadersLinked\Mapper\CompanyFollowerMapper;
|
|
|
21 |
use LeadersLinked\Model\Company;
|
|
|
22 |
use LeadersLinked\Mapper\GroupMapper;
|
|
|
23 |
use LeadersLinked\Mapper\GroupMemberMapper;
|
|
|
24 |
use LeadersLinked\Mapper\GroupTypeMapper;
|
|
|
25 |
use LeadersLinked\Model\Group;
|
|
|
26 |
use LeadersLinked\Model\Notification;
|
|
|
27 |
use LeadersLinked\Mapper\NotificationMapper;
|
|
|
28 |
use LeadersLinked\Mapper\UserProfileMapper;
|
|
|
29 |
use LeadersLinked\Mapper\ProfileVisitMapper;
|
|
|
30 |
use LeadersLinked\Mapper\ConnectionMapper;
|
|
|
31 |
use LeadersLinked\Model\CompanyFollower;
|
17002 |
efrain |
32 |
use LeadersLinked\Mapper\MicrolearningUserProgressMapper;
|
|
|
33 |
use LeadersLinked\Mapper\MicrolearningUserLogMapper;
|
16951 |
efrain |
34 |
use LeadersLinked\Mapper\DailyPulseRecordMapper;
|
|
|
35 |
use LeadersLinked\Model\DailyPulseRecord;
|
|
|
36 |
use LeadersLinked\Mapper\SurveyCampaignMapper;
|
|
|
37 |
use LeadersLinked\Mapper\RecruitmentSelectionApplicationMapper;
|
|
|
38 |
use LeadersLinked\Mapper\RecruitmentSelectionVacancyMapper;
|
|
|
39 |
use LeadersLinked\Mapper\PerformanceEvaluationTestMapper;
|
1 |
www |
40 |
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
class DashboardController extends AbstractActionController
|
|
|
44 |
{
|
|
|
45 |
/**
|
|
|
46 |
*
|
16769 |
efrain |
47 |
* @var \Laminas\Db\Adapter\AdapterInterface
|
1 |
www |
48 |
*/
|
|
|
49 |
private $adapter;
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
*
|
16769 |
efrain |
53 |
* @var \LeadersLinked\Cache\CacheInterface
|
1 |
www |
54 |
*/
|
16769 |
efrain |
55 |
private $cache;
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
/**
|
|
|
59 |
*
|
|
|
60 |
* @var \Laminas\Log\LoggerInterface
|
|
|
61 |
*/
|
1 |
www |
62 |
private $logger;
|
|
|
63 |
|
|
|
64 |
/**
|
|
|
65 |
*
|
16766 |
efrain |
66 |
* @var array
|
|
|
67 |
*/
|
|
|
68 |
private $config;
|
|
|
69 |
|
16769 |
efrain |
70 |
|
16766 |
efrain |
71 |
/**
|
|
|
72 |
*
|
16769 |
efrain |
73 |
* @var \Laminas\Mvc\I18n\Translator
|
|
|
74 |
*/
|
|
|
75 |
private $translator;
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
/**
|
|
|
79 |
*
|
|
|
80 |
* @param \Laminas\Db\Adapter\AdapterInterface $adapter
|
|
|
81 |
* @param \LeadersLinked\Cache\CacheInterface $cache
|
|
|
82 |
* @param \Laminas\Log\LoggerInterface LoggerInterface $logger
|
1 |
www |
83 |
* @param array $config
|
16769 |
efrain |
84 |
* @param \Laminas\Mvc\I18n\Translator $translator
|
1 |
www |
85 |
*/
|
16769 |
efrain |
86 |
public function __construct($adapter, $cache, $logger, $config, $translator)
|
1 |
www |
87 |
{
|
16769 |
efrain |
88 |
$this->adapter = $adapter;
|
|
|
89 |
$this->cache = $cache;
|
|
|
90 |
$this->logger = $logger;
|
|
|
91 |
$this->config = $config;
|
|
|
92 |
$this->translator = $translator;
|
1 |
www |
93 |
}
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
public function indexAction()
|
|
|
97 |
{
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
101 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
$request = $this->getRequest();
|
|
|
105 |
if($request->isGet()) {
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
|
16943 |
efrain |
110 |
|
1 |
www |
111 |
$this->layout()->setTemplate('layout/layout-backend.phtml');
|
|
|
112 |
$viewModel = new ViewModel();
|
16951 |
efrain |
113 |
|
16947 |
efrain |
114 |
$company = $currentUserPlugin->getCompany();
|
|
|
115 |
if($company) {
|
|
|
116 |
|
17002 |
efrain |
117 |
$microlearningUserLogMapepr = MicrolearningUserLogMapper::getInstance($this->adapter);
|
|
|
118 |
$end_date = $microlearningUserLogMapepr->fetchOneMaxDateActivityFromCompanyId($company->id);
|
16951 |
efrain |
119 |
if($end_date) {
|
16947 |
efrain |
120 |
|
16951 |
efrain |
121 |
|
|
|
122 |
$t = strtotime($end_date);
|
|
|
123 |
$start_date = date('Y-m-d', strtotime('-30 days', $t));
|
|
|
124 |
|
17002 |
efrain |
125 |
$closed_capsules_x_days = $microlearningUserLogMapepr->fetchAllCountClosedCapsulesDailyByCompanyIdAndStartDateAndEndDate($company->id, $start_date, $end_date);
|
|
|
126 |
$users_with_closed_capsules_x_days = $microlearningUserLogMapepr->fetchAllCountUsersWithClosedCapsulesDailyByCompanyIdAndStartDateAndEndDate($company->id, $start_date, $end_date);
|
16951 |
efrain |
127 |
|
|
|
128 |
|
|
|
129 |
} else {
|
|
|
130 |
$closed_capsules_x_days = [];
|
|
|
131 |
$users_with_closed_capsules_x_days = [];
|
|
|
132 |
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
$average_closed_capsules_x_days = 0;
|
|
|
136 |
$average_users_with_closed_capsules_x_day = 0;
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
$max = count($closed_capsules_x_days);
|
|
|
140 |
if($max) {
|
|
|
141 |
for($i = 0; $i < $max; $i++)
|
|
|
142 |
{
|
|
|
143 |
$average_closed_capsules_x_days += $closed_capsules_x_days[$i]['total'];
|
|
|
144 |
}
|
|
|
145 |
$average_closed_capsules_x_days = $average_closed_capsules_x_days / $max;
|
|
|
146 |
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
|
|
|
150 |
$max = count($users_with_closed_capsules_x_days);
|
|
|
151 |
if($max) {
|
|
|
152 |
for($i = 0; $i < $max; $i++)
|
|
|
153 |
{
|
|
|
154 |
$average_users_with_closed_capsules_x_day += $users_with_closed_capsules_x_days[$i]['total'];
|
|
|
155 |
}
|
|
|
156 |
$average_users_with_closed_capsules_x_day = $average_users_with_closed_capsules_x_day / $max;
|
|
|
157 |
|
|
|
158 |
}
|
|
|
159 |
|
|
|
160 |
|
|
|
161 |
$users_with_daily_pulse_x_days = [];
|
|
|
162 |
$average_users_with_daily_pulse_x_days = 0;
|
|
|
163 |
|
|
|
164 |
$dailyPulseRecordMapper = DailyPulseRecordMapper::getInstance($this->adapter);
|
|
|
165 |
$end_date = $dailyPulseRecordMapper->fetchOneMaxDateActivityFromCompanyId($company->id);
|
|
|
166 |
if($end_date) {
|
|
|
167 |
|
|
|
168 |
|
|
|
169 |
$t = strtotime($end_date);
|
|
|
170 |
$start_date = date('Y-m-d', strtotime('-30 days', $t));
|
|
|
171 |
|
|
|
172 |
$users_with_daily_pulse_x_days = $dailyPulseRecordMapper->fetchAllCountUsersWithClosedCapsulesDailyByCompanyIdAndStartDateAndEndDate($company->id, $start_date, $end_date);
|
|
|
173 |
$average_users_with_daily_pulse_x_days = 0;
|
|
|
174 |
|
|
|
175 |
$max = count($users_with_daily_pulse_x_days);
|
|
|
176 |
if($max) {
|
|
|
177 |
|
|
|
178 |
for($i = 0; $i < $max; $i++)
|
|
|
179 |
{
|
|
|
180 |
$average_users_with_daily_pulse_x_days += $users_with_daily_pulse_x_days[$i]['total'];
|
|
|
181 |
}
|
|
|
182 |
$average_users_with_daily_pulse_x_days = $average_users_with_daily_pulse_x_days / $max;
|
|
|
183 |
|
|
|
184 |
}
|
|
|
185 |
|
|
|
186 |
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
$followerMapper = CompanyFollowerMapper::getInstance($this->adapter);
|
|
|
190 |
$total_followers = $followerMapper->fetchCountByCompanyId($company->id);
|
|
|
191 |
|
|
|
192 |
|
|
|
193 |
$surveyCampaignMapper = SurveyCampaignMapper::getInstance($this->adapter);
|
|
|
194 |
$total_surveys = $surveyCampaignMapper->fetchCountByCompanyId($company->id);
|
|
|
195 |
|
|
|
196 |
$recruitmentSelectionVacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
|
|
197 |
$total_recruitment_selection_vacancies = $recruitmentSelectionVacancyMapper->fetchCountByCompanyId($company->id);
|
|
|
198 |
|
|
|
199 |
$performanceEvaluationTestMapper = PerformanceEvaluationTestMapper::getInstance($this->adapter);
|
|
|
200 |
$total_performance_evaluation_tests = $performanceEvaluationTestMapper->fetchCountByCompanyId($company->id);
|
|
|
201 |
|
|
|
202 |
|
16947 |
efrain |
203 |
$viewModel->setTemplate('leaders-linked/dashboard/company.phtml');
|
16951 |
efrain |
204 |
$viewModel->setVariables([
|
|
|
205 |
'average_closed_capsules_x_days' => $average_closed_capsules_x_days,
|
|
|
206 |
'average_users_with_closed_capsules_x_day' => $average_users_with_closed_capsules_x_day,
|
|
|
207 |
'closed_capsules_x_days' => $closed_capsules_x_days,
|
|
|
208 |
'users_with_closed_capsules_x_days' => $users_with_closed_capsules_x_days,
|
|
|
209 |
'users_with_daily_pulse_x_days' => $users_with_daily_pulse_x_days,
|
|
|
210 |
'average_users_with_daily_pulse_x_days' => $average_users_with_daily_pulse_x_days,
|
|
|
211 |
'total_followers' => $total_followers,
|
|
|
212 |
'total_surveys' => $total_surveys,
|
|
|
213 |
'total_recruitment_selection_vacancies' => $total_recruitment_selection_vacancies,
|
|
|
214 |
'total_performance_evaluation_tests' => $total_performance_evaluation_tests,
|
|
|
215 |
]);
|
16947 |
efrain |
216 |
|
|
|
217 |
} else {
|
|
|
218 |
$viewModel->setTemplate('leaders-linked/dashboard/index.phtml');
|
|
|
219 |
}
|
16951 |
efrain |
220 |
|
16947 |
efrain |
221 |
|
16951 |
efrain |
222 |
|
1 |
www |
223 |
return $viewModel ;
|
|
|
224 |
}
|
|
|
225 |
|
|
|
226 |
return new JsonModel([
|
|
|
227 |
'success' => false,
|
|
|
228 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
229 |
]);
|
|
|
230 |
}
|
|
|
231 |
|
|
|
232 |
public function notificationActions()
|
|
|
233 |
{
|
|
|
234 |
|
|
|
235 |
}
|
14692 |
efrain |
236 |
|
|
|
237 |
public function csrfAction()
|
|
|
238 |
{
|
|
|
239 |
$request = $this->getRequest();
|
|
|
240 |
if($request->isGet()) {
|
|
|
241 |
|
|
|
242 |
$token = md5(uniqid('CSFR-' . mt_rand(), true));
|
|
|
243 |
$_SESSION['token'] = $token;
|
|
|
244 |
|
|
|
245 |
|
|
|
246 |
return new JsonModel([
|
|
|
247 |
'success' => true,
|
|
|
248 |
'data' => $token
|
|
|
249 |
]);
|
|
|
250 |
|
|
|
251 |
|
|
|
252 |
} else {
|
|
|
253 |
return new JsonModel([
|
|
|
254 |
'success' => false,
|
|
|
255 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
256 |
]);
|
|
|
257 |
}
|
|
|
258 |
|
|
|
259 |
|
|
|
260 |
}
|
17002 |
efrain |
261 |
|
|
|
262 |
public function chatAction()
|
|
|
263 |
{
|
|
|
264 |
}
|
|
|
265 |
|
|
|
266 |
|
|
|
267 |
|
|
|
268 |
public function inMailPersonalAction()
|
|
|
269 |
{
|
|
|
270 |
}
|
|
|
271 |
|
|
|
272 |
public function inMailCompanyAction()
|
|
|
273 |
{
|
|
|
274 |
}
|
1 |
www |
275 |
|
|
|
276 |
}
|