| 1 |
www |
1 |
<?php
|
|
|
2 |
namespace LeadersLinked\Helper;
|
|
|
3 |
|
|
|
4 |
use Laminas\View\Helper\AbstractHelper;
|
|
|
5 |
use Laminas\Db\Adapter\AdapterInterface;
|
|
|
6 |
use LeadersLinked\Mapper\UserMapper;
|
|
|
7 |
use LeadersLinked\Model\UserType;
|
| 1445 |
efrain |
8 |
use LeadersLinked\Mapper\ConnectionMapper;
|
|
|
9 |
use LeadersLinked\Mapper\LocationMapper;
|
|
|
10 |
use LeadersLinked\Mapper\ProfileVisitMapper;
|
| 4113 |
efrain |
11 |
use LeadersLinked\Model\CompanySelfEvaluationFormUser;
|
|
|
12 |
use LeadersLinked\Mapper\CompanySelfEvaluationFormUserMapper;
|
|
|
13 |
use LeadersLinked\Mapper\QueryMapper;
|
|
|
14 |
use Laminas\Db\Sql\Expression;
|
|
|
15 |
use LeadersLinked\Mapper\CompanySelfEvaluationFormMapper;
|
|
|
16 |
use LeadersLinked\Model\CompanySelfEvaluationForm;
|
| 1 |
www |
17 |
|
|
|
18 |
class MenuHelper extends AbstractHelper
|
|
|
19 |
{
|
|
|
20 |
/**
|
|
|
21 |
*
|
|
|
22 |
* @var AdapterInterface
|
|
|
23 |
*/
|
|
|
24 |
private $adapter;
|
|
|
25 |
|
|
|
26 |
/**
|
|
|
27 |
*
|
|
|
28 |
* @var array
|
|
|
29 |
*/
|
|
|
30 |
private $config;
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
/**
|
|
|
34 |
*
|
|
|
35 |
* @param AdapterInterface $adapter
|
|
|
36 |
* @param array $config
|
|
|
37 |
*/
|
|
|
38 |
public function __construct($adapter, $config)
|
|
|
39 |
{
|
|
|
40 |
$this->adapter = $adapter;
|
|
|
41 |
$this->config = $config;
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
/**
|
|
|
45 |
*
|
|
|
46 |
* @param int $user_id
|
|
|
47 |
* @return string
|
|
|
48 |
*/
|
|
|
49 |
public function __invoke($user_id)
|
|
|
50 |
{
|
| 1445 |
efrain |
51 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
52 |
$user = $userMapper->fetchOne($user_id);
|
| 1 |
www |
53 |
|
| 1662 |
efrain |
54 |
if($user) {
|
| 4113 |
efrain |
55 |
|
|
|
56 |
|
|
|
57 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
|
|
58 |
|
|
|
59 |
$select = $queryMapper->getSql()->select();
|
|
|
60 |
$select->columns(['total' => new Expression('COUNT(*)')]);
|
|
|
61 |
$select->from(['u' => CompanySelfEvaluationFormUserMapper::_TABLE]);
|
|
|
62 |
$select->join(['f' => CompanySelfEvaluationFormMapper::_TABLE], 'u.form_id = f.id');
|
|
|
63 |
$select->where->equalTo('u.user_i', $user_id);
|
|
|
64 |
$select->where->equalTo('f.status', CompanySelfEvaluationForm::STATUS_ACTIVE);
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
$record = $queryMapper->fetchOne($select);
|
|
|
68 |
$access_for_self_evaluation = $record['total'] > 0;
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
|
| 1662 |
efrain |
72 |
$user_uuid = $user->uuid;
|
|
|
73 |
$fullname = trim($user->first_name . ' ' . $user->last_name);
|
| 1445 |
efrain |
74 |
|
| 1662 |
efrain |
75 |
$profileVisitMapper = ProfileVisitMapper::getInstance($this->adapter);
|
|
|
76 |
$visits = $profileVisitMapper->getTotalByVisitedId($user->id);
|
|
|
77 |
|
|
|
78 |
$connectionMapper = ConnectionMapper::getInstance($this->adapter);
|
|
|
79 |
$connections = $connectionMapper->fetchTotalConnectionByUser($user->id);
|
|
|
80 |
|
|
|
81 |
|
|
|
82 |
if($user->location_id) {
|
|
|
83 |
$locationMapper = LocationMapper::getInstance($this->adapter);
|
|
|
84 |
$location = $locationMapper->fetchOne($user->location_id);
|
|
|
85 |
|
|
|
86 |
$country = $location->country;
|
|
|
87 |
} else {
|
|
|
88 |
$country = '';
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
|
93 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
94 |
$user = $userMapper->fetchOne($user_id);
|
|
|
95 |
if($user && $user->usertype_id == UserType::ADMIN) {
|
|
|
96 |
$link_admin = '/backend/signin-admin';
|
|
|
97 |
} else {
|
|
|
98 |
$link_admin = '';
|
|
|
99 |
}
|
| 1445 |
efrain |
100 |
} else {
|
| 1662 |
efrain |
101 |
$user_uuid= '';
|
|
|
102 |
$fullname = '';
|
| 1445 |
efrain |
103 |
$country = '';
|
| 1662 |
efrain |
104 |
$visits = 0;
|
|
|
105 |
$connections = 0;
|
|
|
106 |
$link_admin = '';
|
| 1445 |
efrain |
107 |
}
|
|
|
108 |
|
|
|
109 |
$data = [
|
| 1662 |
efrain |
110 |
'user_uuid' => $user_uuid,
|
|
|
111 |
'fullname' => $fullname,
|
| 1445 |
efrain |
112 |
'country' => $country,
|
|
|
113 |
'visits' => $visits,
|
|
|
114 |
'connections' => $connections,
|
|
|
115 |
'link_admin' => $link_admin
|
|
|
116 |
];
|
|
|
117 |
|
|
|
118 |
return $this->getView()->render('helpers/menu.phtml', $data);
|
| 1 |
www |
119 |
}
|
|
|
120 |
}
|