Línea 78... |
Línea 78... |
78 |
$request = $this->getRequest();
|
78 |
$request = $this->getRequest();
|
79 |
if($request->isGet()) {
|
79 |
if($request->isGet()) {
|
80 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
80 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
81 |
$currentUser = $currentUserPlugin->getUser();
|
81 |
$currentUser = $currentUserPlugin->getUser();
|
Línea -... |
Línea 82... |
- |
|
82 |
|
- |
|
83 |
$companyMapper = \LeadersLinked\Mapper\CompanyMapper::getInstance($this->adapter);
|
- |
|
84 |
$company = $companyMapper->fetchDefaultForNetworkByNetworkId($currentUser->network_id);
|
- |
|
85 |
|
- |
|
86 |
|
- |
|
87 |
$habitCategoryMapper = \LeadersLinked\Mapper\HabitCategoryMapper::getInstance($this->adapter);
|
- |
|
88 |
$habitUserLogCategoryMapper = \LeadersLinked\Mapper\HabitUserLogCategoryMapper::getInstance($this->adapter);
|
- |
|
89 |
|
- |
|
90 |
$categories = [];
|
- |
|
91 |
$records = $habitCategoryMapper->fetchAllActiveByCompanyId($company->id);
|
- |
|
92 |
|
- |
|
93 |
$date = date('Y-m-d');
|
- |
|
94 |
foreach($records as $record)
|
- |
|
95 |
{
|
- |
|
96 |
$habitUserLogCategory = $habitUserLogCategoryMapper->fetchOneByUserIdAndCategoryIdAndDate($currentUser->id, $record->id, $date);
|
- |
|
97 |
if($habitUserLogCategory) {
|
- |
|
98 |
$code = $habitUserLogCategory->code;
|
- |
|
99 |
} else {
|
- |
|
100 |
$code = '';
|
- |
|
101 |
}
|
- |
|
102 |
|
- |
|
103 |
array_push($categories, [
|
- |
|
104 |
'uuid' => $record->uuid,
|
- |
|
105 |
'name' => $record->name,
|
- |
|
106 |
'selected' => $code
|
- |
|
107 |
]);
|
- |
|
108 |
|
- |
|
109 |
|
- |
|
110 |
}
|
- |
|
111 |
|
- |
|
112 |
$storage = \LeadersLinked\Library\Storage::getInstance($this->config);
|
- |
|
113 |
$path = $storage->getPathHabitEmoji();
|
- |
|
114 |
|
- |
|
115 |
$emojis = [];
|
- |
|
116 |
$habitEmojiMapper = \LeadersLinked\Mapper\HabitEmojiMapper::getInstance($this->adapter);
|
- |
|
117 |
$records = $habitEmojiMapper->fetchAllActiveByCompanyId($company->id);
|
- |
|
118 |
|
- |
|
119 |
foreach($records as $record)
|
- |
|
120 |
{
|
- |
|
121 |
array_push($emojis, [
|
- |
|
122 |
'code' => $record->code,
|
- |
|
123 |
'name' => $record->name,
|
- |
|
124 |
'image' => $storage->getGenericImage($path, $record->uuid, $record->image)
|
- |
|
125 |
]);
|
- |
|
126 |
}
|
- |
|
127 |
|
- |
|
128 |
|
- |
|
129 |
|
82 |
|
130 |
|
83 |
$acl = $this->getEvent()->getViewModel()->getVariable('acl');
|
131 |
$acl = $this->getEvent()->getViewModel()->getVariable('acl');
|
84 |
$allowValues = $acl->isAllowed($currentUser->usertype_id, 'habits/values');
|
132 |
$allowValues = $acl->isAllowed($currentUser->usertype_id, 'habits/values');
|
85 |
$allowParadigms = $acl->isAllowed($currentUser->usertype_id, 'habits/paradigms');
|
133 |
$allowParadigms = $acl->isAllowed($currentUser->usertype_id, 'habits/paradigms');
|
86 |
$allowPurposes = $acl->isAllowed($currentUser->usertype_id, 'habits/purposes');
|
134 |
$allowPurposes = $acl->isAllowed($currentUser->usertype_id, 'habits/purposes');
|
87 |
$allowSkills = $acl->isAllowed($currentUser->usertype_id, 'habits/skills');
|
135 |
$allowSkills = $acl->isAllowed($currentUser->usertype_id, 'habits/skills');
|
Línea 88... |
Línea 136... |
88 |
$allowGoals = $acl->isAllowed($currentUser->usertype_id, 'habits/goals');
|
136 |
$allowGoals = $acl->isAllowed($currentUser->usertype_id, 'habits/goals');
|
89 |
|
137 |
|
90 |
return new JsonModel([
|
138 |
return new JsonModel([
|
- |
|
139 |
'success' => true,
|
- |
|
140 |
'data' => [
|
91 |
'success' => true,
|
141 |
'categories' => $categories,
|
92 |
'data' => [
|
142 |
'emojis' => $emojis,
|
93 |
'link_values' => $allowValues ? $this->url()->fromRoute('habits/values', [], ['force_canonical' => true]) : '',
|
143 |
'link_values' => $allowValues ? $this->url()->fromRoute('habits/values', [], ['force_canonical' => true]) : '',
|
94 |
'link_paradigms' => $allowParadigms ? $this->url()->fromRoute('habits/paradigms', [], ['force_canonical' => true]) : '',
|
144 |
'link_paradigms' => $allowParadigms ? $this->url()->fromRoute('habits/paradigms', [], ['force_canonical' => true]) : '',
|
95 |
'link_purposes' => $allowPurposes ? $this->url()->fromRoute('habits/purposes', [], ['force_canonical' => true]) : '',
|
145 |
'link_purposes' => $allowPurposes ? $this->url()->fromRoute('habits/purposes', [], ['force_canonical' => true]) : '',
|