|
1
|
|
|
<?php |
|
2
|
|
|
/* +*********************************************************************************** |
|
3
|
|
|
* The contents of this file are subject to the vtiger CRM Public License Version 1.0 |
|
4
|
|
|
* ("License"); You may not use this file except in compliance with the License |
|
5
|
|
|
* The Original Code is: vtiger CRM Open Source |
|
6
|
|
|
* The Initial Developer of the Original Code is vtiger. |
|
7
|
|
|
* Portions created by vtiger are Copyright (C) vtiger. |
|
8
|
|
|
* All Rights Reserved. |
|
9
|
|
|
* Contributor(s): YetiForce S.A. |
|
10
|
|
|
* *********************************************************************************** */ |
|
11
|
|
|
|
|
12
|
|
|
class Vtiger_DetailView_Model extends \App\Base |
|
13
|
|
|
{ |
|
14
|
|
|
protected $module = false; |
|
15
|
|
|
protected $record = false; |
|
16
|
|
|
public $widgetsList = []; |
|
17
|
|
|
public $widgets = []; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Function to get Module instance. |
|
21
|
|
|
* |
|
22
|
|
|
* @return Vtiger_Module_Model |
|
23
|
|
|
*/ |
|
24
|
|
|
public function getModule() |
|
25
|
|
|
{ |
|
26
|
|
|
return $this->module; |
|
|
|
|
|
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Function to set the module instance. |
|
31
|
|
|
* |
|
32
|
|
|
* @param Vtiger_Module_Model $moduleInstance - module model |
|
33
|
|
|
* |
|
34
|
|
|
* @return Vtiger_DetailView_Model> |
|
35
|
|
|
*/ |
|
36
|
|
|
public function setModule($moduleInstance) |
|
37
|
|
|
{ |
|
38
|
|
|
$this->module = $moduleInstance; |
|
39
|
|
|
|
|
40
|
|
|
return $this; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Function to get the Record model. |
|
45
|
|
|
* |
|
46
|
|
|
* @return Vtiger_Record_Model |
|
47
|
|
|
*/ |
|
48
|
|
|
public function getRecord() |
|
49
|
|
|
{ |
|
50
|
|
|
return $this->record; |
|
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Function to set the record instance3. |
|
55
|
|
|
* |
|
56
|
|
|
* @param <type> $recordModuleInstance - record model |
|
|
|
|
|
|
57
|
|
|
* |
|
58
|
|
|
* @return Vtiger_DetailView_Model |
|
59
|
|
|
*/ |
|
60
|
|
|
public function setRecord($recordModuleInstance) |
|
61
|
|
|
{ |
|
62
|
|
|
$this->record = $recordModuleInstance; |
|
63
|
|
|
|
|
64
|
|
|
return $this; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Function to get the detail view links (links, widgets, button). |
|
69
|
|
|
* |
|
70
|
|
|
* @param array $linkParams array of link models |
|
71
|
|
|
* |
|
72
|
|
|
* @return array |
|
73
|
|
|
*/ |
|
74
|
|
|
public function getDetailViewLinks(array $linkParams): array |
|
75
|
|
|
{ |
|
76
|
|
|
if ($this->has('Links')) { |
|
77
|
|
|
return $this->get('Links'); |
|
|
|
|
|
|
78
|
|
|
} |
|
79
|
|
|
$moduleModel = $this->getModule(); |
|
80
|
|
|
$recordModel = $this->getRecord(); |
|
81
|
|
|
$moduleName = $moduleModel->getName(); |
|
82
|
|
|
$recordId = $recordModel->getId(); |
|
83
|
|
|
$linkModelList = []; |
|
84
|
|
|
if ($recordModel->isReadOnly()) { |
|
85
|
|
|
if (\Config\Components\InterestsConflict::$isActive && \App\Components\InterestsConflict::getParent($recordId, $moduleName)) { |
|
|
|
|
|
|
86
|
|
|
$linkModelList['DETAIL_VIEW_ADDITIONAL'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
87
|
|
|
'linktype' => 'DETAIL_VIEW_ADDITIONAL', |
|
88
|
|
|
'linkdata' => ['url' => "index.php?module={$moduleName}&view=InterestsConflictModal&mode=unlock&fromView=Detail&record={$recordId}"], |
|
89
|
|
|
'linkicon' => 'fas fa-lock-open', |
|
90
|
|
|
'linkhint' => 'LBL_INTERESTS_CONFLICT_UNLOCK', |
|
91
|
|
|
'linkclass' => 'btn-outline-primary btn-sm js-show-modal', |
|
92
|
|
|
]); |
|
93
|
|
|
} |
|
94
|
|
|
} else { |
|
95
|
|
|
$userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel(); |
|
96
|
|
|
if (\Config\Components\InterestsConflict::$isActive && \App\Components\InterestsConflict::getParent($recordId, $moduleName)) { |
|
97
|
|
|
$linkModelList['DETAIL_VIEW_ADDITIONAL'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
98
|
|
|
'linktype' => 'DETAIL_VIEW_ADDITIONAL', |
|
99
|
|
|
'linkdata' => ['url' => "index.php?module={$moduleName}&view=InterestsConflictModal&mode=confirmation&fromView=Detail&record={$recordId}"], |
|
100
|
|
|
'linkicon' => 'yfi yfi-confirm-conflict', |
|
101
|
|
|
'linkhint' => 'LBL_INTERESTS_CONFLICT_CONFIRMATION', |
|
102
|
|
|
'linkclass' => 'btn-outline-primary btn-sm js-show-modal', |
|
103
|
|
|
]); |
|
104
|
|
|
if ($moduleModel->isPermitted('InterestsConflictUsers')) { |
|
105
|
|
|
$linkModelList['DETAIL_VIEW_ADDITIONAL'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
106
|
|
|
'linktype' => 'DETAIL_VIEW_ADDITIONAL', |
|
107
|
|
|
'linkdata' => ['url' => "index.php?module={$moduleName}&view=InterestsConflictModal&mode=users&fromView=Detail&record={$recordId}"], |
|
108
|
|
|
'linkicon' => 'yfi yfi-conflict-list', |
|
109
|
|
|
'linkhint' => 'LBL_INTERESTS_CONFLICT_USERS', |
|
110
|
|
|
'linkclass' => 'btn-outline-primary btn-sm', |
|
111
|
|
|
'modalView' => true, |
|
112
|
|
|
]); |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
if ($moduleModel->isPermitted('WorkflowTrigger') |
|
116
|
|
|
&& ($recordModel->isEditable() || ($recordModel->isPermitted('EditView') && $moduleModel->isPermitted('WorkflowTriggerWhenRecordIsBlocked') && $recordModel->isBlocked()))) { |
|
117
|
|
|
Vtiger_Loader::includeOnce('~~modules/com_vtiger_workflow/include.php'); |
|
118
|
|
|
Vtiger_Loader::includeOnce('~~modules/com_vtiger_workflow/VTEntityMethodManager.php'); |
|
119
|
|
|
$wfs = new VTWorkflowManager(); |
|
120
|
|
|
$workflows = $wfs->getWorkflowsForModule($moduleName, VTWorkflowManager::$TRIGGER); |
|
121
|
|
|
if (\count($workflows) > 0) { |
|
122
|
|
|
$linkModelList['DETAIL_VIEW_ADDITIONAL'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
123
|
|
|
'linktype' => 'DETAIL_VIEW_ADDITIONAL', |
|
124
|
|
|
'linklabel' => '', |
|
125
|
|
|
'linkurl' => 'javascript:Vtiger_Detail_Js.showWorkflowTriggerView(this)', |
|
126
|
|
|
'linkicon' => 'fas fa-plus-circle', |
|
127
|
|
|
'linkhint' => 'BTN_WORKFLOW_TRIGGER', |
|
128
|
|
|
'linkclass' => 'btn-outline-warning btn-sm', |
|
129
|
|
|
]); |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
if ($moduleModel->isPermitted('RecordMapping')) { |
|
133
|
|
|
$handlerClass = Vtiger_Loader::getComponentClassName('Model', 'MappedFields', $moduleName); |
|
134
|
|
|
$mfModel = new $handlerClass(); |
|
135
|
|
|
if ($mfModel && $mfModel->checkActiveTemplates($recordId, $moduleName, 'Detail')) { |
|
136
|
|
|
$linkModelList['DETAIL_VIEW_ADDITIONAL'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
137
|
|
|
'linktype' => 'DETAIL_VIEW_ADDITIONAL', |
|
138
|
|
|
'linklabel' => '', |
|
139
|
|
|
'linkdata' => ['url' => "index.php?module={$moduleName}&view=GenerateModal&fromview=Detail&record={$recordId}"], |
|
140
|
|
|
'linkicon' => 'fas fa-external-link-alt', |
|
141
|
|
|
'linkclass' => 'btn js-show-modal btn-outline-dark btn-sm', |
|
142
|
|
|
'linkhint' => 'BTN_GENERATE_RECORD', |
|
143
|
|
|
]); |
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
|
if (App\Config::module('ModTracker', 'WATCHDOG') && $moduleModel->isPermitted('WatchingRecords')) { |
|
147
|
|
|
$watchdog = Vtiger_Watchdog_Model::getInstanceById($recordId, $moduleName); |
|
148
|
|
|
$class = 'btn-outline-dark btn-sm'; |
|
149
|
|
|
$iconClass = 'fa-eye-slash'; |
|
150
|
|
|
if ($watchdog->isWatchingRecord()) { |
|
151
|
|
|
$class = 'btn-dark btn-sm'; |
|
152
|
|
|
$iconClass = 'fa-eye'; |
|
153
|
|
|
} |
|
154
|
|
|
$linkModelList['DETAIL_VIEW_ADDITIONAL'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
155
|
|
|
'linktype' => 'DETAIL_VIEW_ADDITIONAL', |
|
156
|
|
|
'linklabel' => '', |
|
157
|
|
|
'linkurl' => 'javascript:Vtiger_Index_Js.changeWatching(this)', |
|
158
|
|
|
'linkicon' => 'fas ' . $iconClass, |
|
159
|
|
|
'linkhint' => 'BTN_WATCHING_RECORD', |
|
160
|
|
|
'linkclass' => $class, |
|
161
|
|
|
'linkdata' => ['off' => 'btn-outline-dark', 'on' => 'btn-dark', 'value' => $watchdog->isWatchingRecord() ? 0 : 1, 'record' => $recordId], |
|
162
|
|
|
]); |
|
163
|
|
|
} |
|
164
|
|
|
if ($userPrivilegesModel->hasModulePermission('Notification') && $userPrivilegesModel->hasModuleActionPermission('Notification', 'CreateView')) { |
|
|
|
|
|
|
165
|
|
|
$linkModelList['DETAIL_VIEW_ADDITIONAL'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
166
|
|
|
'linktype' => 'DETAIL_VIEW_ADDITIONAL', |
|
167
|
|
|
'linklabel' => '', |
|
168
|
|
|
'linkurl' => 'javascript:Vtiger_Index_Js.sendNotification(this)', |
|
169
|
|
|
'linkicon' => 'fas fa-paper-plane', |
|
170
|
|
|
'linkhint' => 'LBL_SEND_NOTIFICATION', |
|
171
|
|
|
'linkclass' => 'btn-outline-dark btn-sm', |
|
172
|
|
|
]); |
|
173
|
|
|
} |
|
174
|
|
|
if ($userPrivilegesModel->hasModulePermission('PermissionInspector')) { |
|
175
|
|
|
$linkModelList['DETAIL_VIEW_ADDITIONAL'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
176
|
|
|
'linktype' => 'DETAIL_VIEW_ADDITIONAL', |
|
177
|
|
|
'linkhint' => 'BTN_PERMISSION_INSPECTOR', |
|
178
|
|
|
'linkdata' => ['url' => "index.php?module=PermissionInspector&view=UserListModal&srcModule=$moduleName&srcRecord=$recordId"], |
|
179
|
|
|
'linkicon' => 'fas fa-user-secret', |
|
180
|
|
|
'linkclass' => 'btn-outline-dark btn-sm', |
|
181
|
|
|
'modalView' => true, |
|
182
|
|
|
]); |
|
183
|
|
|
} |
|
184
|
|
|
if ($moduleModel->isPermitted('RecordConventer') && \App\RecordConverter::isAvailable($recordModel, 'Detail')) { |
|
185
|
|
|
$linkModelList['DETAIL_VIEW_ADDITIONAL'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
186
|
|
|
'linktype' => 'DETAIL_VIEW_ADDITIONAL', |
|
187
|
|
|
'linklabel' => 'LBL_RECORD_CONVERTER', |
|
188
|
|
|
'linkdata' => ['url' => "index.php?module={$moduleModel->getName()}&view=RecordConverter&sourceView=Detail&selected_ids=[{$recordModel->getId()}]"], |
|
189
|
|
|
'linkicon' => 'fas fa-exchange-alt', |
|
190
|
|
|
'linkclass' => 'btn-outline-dark btn-sm', |
|
191
|
|
|
'modalView' => true, |
|
192
|
|
|
]); |
|
193
|
|
|
} |
|
194
|
|
|
$smsModuleModel = Vtiger_Module_Model::getInstance('SMSNotifier'); |
|
195
|
|
|
if ($smsModuleModel->isSMSActiveForModule($moduleName) |
|
|
|
|
|
|
196
|
|
|
&& $smsModuleModel->isQuickCreateSupported() |
|
197
|
|
|
&& array_filter($recordModel->getModule()->getFieldsByType('phone', true), fn ($fieldModel) => !$recordModel->isEmpty($fieldModel->getName())) |
|
198
|
|
|
) { |
|
199
|
|
|
$linkModelList['DETAIL_VIEW_ADDITIONAL'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
200
|
|
|
'linktype' => 'DETAIL_VIEW_ADDITIONAL', |
|
201
|
|
|
'linklabel' => 'BTN_SMSNOTIFIER', |
|
202
|
|
|
'linkurl' => 'javascript:Vtiger_Detail_Js.triggerSMSmodal(this)', |
|
203
|
|
|
'linkicon' => 'yfm-SMSNotifier', |
|
204
|
|
|
'linkclass' => 'btn-outline-dark btn-sm', |
|
205
|
|
|
]); |
|
206
|
|
|
} |
|
207
|
|
|
if ($fields = App\Field::getQuickChangerFields($moduleModel->getId())) { |
|
208
|
|
|
foreach ($fields as $field) { |
|
209
|
|
|
if (App\Field::checkQuickChangerConditions($field, $recordModel)) { |
|
|
|
|
|
|
210
|
|
|
$linkModelList['DETAIL_VIEW_BASIC'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
211
|
|
|
'linktype' => 'DETAIL_VIEW_BASIC', |
|
212
|
|
|
'linklabel' => $field['btn_name'], |
|
213
|
|
|
'linkurl' => "javascript:Vtiger_Detail_Js.runRecordChanger({$field['id']})", |
|
214
|
|
|
'linkicon' => $field['icon'] ?? 'mdi mdi-nfc-tap', |
|
215
|
|
|
'linkhint' => $field['btn_name'], |
|
216
|
|
|
'linkclass' => 'btn-sm ' . $field['class'], |
|
217
|
|
|
]); |
|
218
|
|
|
} |
|
219
|
|
|
} |
|
220
|
|
|
} |
|
221
|
|
|
if ($recordModel->isEditable()) { |
|
222
|
|
|
$linkModelList['DETAIL_VIEW_BASIC'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
223
|
|
|
'linktype' => 'DETAIL_VIEW_BASIC', |
|
224
|
|
|
'linklabel' => 'BTN_RECORD_EDIT', |
|
225
|
|
|
'linkurl' => $recordModel->getEditViewUrl(), |
|
226
|
|
|
'linkicon' => 'yfi yfi-full-editing-view', |
|
227
|
|
|
'linkclass' => 'js-edit-btn btn btn-outline-dark btn-sm', |
|
228
|
|
|
'linkhint' => 'BTN_RECORD_EDIT', |
|
229
|
|
|
]); |
|
230
|
|
|
} elseif ($recordModel->isUnlockByFields()) { |
|
231
|
|
|
$linkModelList['DETAIL_VIEW_BASIC'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
232
|
|
|
'linktype' => 'DETAIL_VIEW_BASIC', |
|
233
|
|
|
'linklabel' => 'BTN_RECORD_OPEN', |
|
234
|
|
|
'linkdata' => ['url' => 'index.php?module=' . $recordModel->getModuleName() . '&view=RecordUnlock&record=' . $recordModel->getId()], |
|
235
|
|
|
'linkicon' => 'fas fa-lock-open', |
|
236
|
|
|
'linkclass' => 'js-show-modal btn-outline-dark btn-sm', |
|
237
|
|
|
'linkhint' => 'BTN_RECORD_OPEN', |
|
238
|
|
|
]); |
|
239
|
|
|
} |
|
240
|
|
|
if ($recordModel->isPermitted('AutoAssignRecord') && \App\AutoAssign::getAutoAssignForRecord($recordModel, \App\AutoAssign::MODE_MANUAL)) { |
|
241
|
|
|
$linkModelList['DETAIL_VIEW_BASIC'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
242
|
|
|
'linktype' => 'DETAIL_VIEW_BASIC', |
|
243
|
|
|
'linklabel' => 'BTN_ASSIGN_TO', |
|
244
|
|
|
'linkdata' => ['url' => 'index.php?module=' . $recordModel->getModuleName() . '&view=AutoAssignRecord&record=' . $recordModel->getId()], |
|
245
|
|
|
'linkicon' => 'yfi yfi-automatic-assignment', |
|
246
|
|
|
'linkclass' => 'js-show-modal btn-outline-dark btn-sm', |
|
247
|
|
|
'linkhint' => 'BTN_ASSIGN_TO', |
|
248
|
|
|
]); |
|
249
|
|
|
} |
|
250
|
|
|
$stateColors = App\Config::search('LIST_ENTITY_STATE_COLOR'); |
|
251
|
|
|
if ($recordModel->privilegeToActivate()) { |
|
252
|
|
|
$linkModelList['DETAIL_VIEW_EXTENDED'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
253
|
|
|
'linktype' => 'DETAIL_VIEW_EXTENDED', |
|
254
|
|
|
'linklabel' => 'LBL_ACTIVATE_RECORD', |
|
255
|
|
|
'title' => \App\Language::translate('LBL_ACTIVATE_RECORD'), |
|
256
|
|
|
'dataUrl' => 'index.php?module=' . $recordModel->getModuleName() . '&action=State&state=Active&record=' . $recordModel->getId(), |
|
257
|
|
|
'linkdata' => ['confirm' => \App\Language::translate('LBL_ACTIVATE_RECORD_DESC'), 'source-view' => 'Href'], |
|
258
|
|
|
'linkicon' => 'fas fa-undo-alt', |
|
259
|
|
|
'linkclass' => 'entityStateBtn btn-outline-dark btn-sm js-action-confirm', |
|
260
|
|
|
'style' => empty($stateColors['Active']) ? '' : "background: {$stateColors['Active']};", |
|
261
|
|
|
]); |
|
262
|
|
|
} |
|
263
|
|
|
if ($recordModel->privilegeToArchive()) { |
|
264
|
|
|
$linkModelList['DETAIL_VIEW_EXTENDED'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
265
|
|
|
'linktype' => 'DETAIL_VIEW_EXTENDED', |
|
266
|
|
|
'linklabel' => 'LBL_ARCHIVE_RECORD', |
|
267
|
|
|
'title' => \App\Language::translate('LBL_ARCHIVE_RECORD'), |
|
268
|
|
|
'dataUrl' => 'index.php?module=' . $recordModel->getModuleName() . '&action=State&state=Archived&record=' . $recordModel->getId(), |
|
269
|
|
|
'linkdata' => ['confirm' => \App\Language::translate('LBL_ARCHIVE_RECORD_DESC'), 'source-view' => 'Href'], |
|
270
|
|
|
'linkicon' => 'fas fa-archive', |
|
271
|
|
|
'linkclass' => 'entityStateBtn btn-outline-dark btn-sm js-action-confirm', |
|
272
|
|
|
'style' => empty($stateColors['Archived']) ? '' : "background: {$stateColors['Archived']};", |
|
273
|
|
|
]); |
|
274
|
|
|
} |
|
275
|
|
|
if ($recordModel->privilegeToMoveToTrash()) { |
|
276
|
|
|
$linkModelList['DETAIL_VIEW_EXTENDED'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
277
|
|
|
'linktype' => 'DETAIL_VIEW_EXTENDED', |
|
278
|
|
|
'linklabel' => 'LBL_MOVE_TO_TRASH', |
|
279
|
|
|
'title' => \App\Language::translate('LBL_MOVE_TO_TRASH'), |
|
280
|
|
|
'dataUrl' => 'index.php?module=' . $recordModel->getModuleName() . '&action=State&state=Trash&record=' . $recordModel->getId(), |
|
281
|
|
|
'linkdata' => ['confirm' => \App\Language::translate('LBL_MOVE_TO_TRASH_DESC'), 'source-view' => 'Href'], |
|
282
|
|
|
'linkicon' => 'fas fa-trash-alt', |
|
283
|
|
|
'linkclass' => 'entityStateBtn btn-outline-dark btn-sm js-action-confirm', |
|
284
|
|
|
'style' => empty($stateColors['Trash']) ? '' : "background: {$stateColors['Trash']};", |
|
285
|
|
|
]); |
|
286
|
|
|
} |
|
287
|
|
|
if ($recordModel->privilegeToDelete()) { |
|
288
|
|
|
$linkModelList['DETAIL_VIEW_EXTENDED'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
289
|
|
|
'linktype' => 'DETAIL_VIEW_EXTENDED', |
|
290
|
|
|
'linklabel' => 'LBL_DELETE_RECORD_COMPLETELY', |
|
291
|
|
|
'title' => \App\Language::translate('LBL_DELETE_RECORD_COMPLETELY'), |
|
292
|
|
|
'dataUrl' => 'index.php?module=' . $recordModel->getModuleName() . '&action=Delete&record=' . $recordModel->getId(), |
|
293
|
|
|
'linkdata' => ['confirm' => \App\Language::translate('LBL_DELETE_RECORD_COMPLETELY_DESC'), 'source-view' => 'Href'], |
|
294
|
|
|
'linkicon' => 'fas fa-eraser', |
|
295
|
|
|
'linkclass' => 'btn-dark btn-sm js-action-confirm', |
|
296
|
|
|
]); |
|
297
|
|
|
} |
|
298
|
|
|
if ($moduleModel->isPermitted('DuplicateRecord')) { |
|
299
|
|
|
$linkModelList['DETAIL_VIEW_BASIC'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
300
|
|
|
'linktype' => 'DETAIL_VIEW_BASIC', |
|
301
|
|
|
'linklabel' => 'LBL_DUPLICATE', |
|
302
|
|
|
'linkurl' => $recordModel->getDuplicateRecordUrl(), |
|
303
|
|
|
'linkicon' => 'fas fa-clone', |
|
304
|
|
|
'linkclass' => 'js-duplicate-btn btn-outline-dark btn-sm', |
|
305
|
|
|
'title' => \App\Language::translate('LBL_DUPLICATE_RECORD'), |
|
306
|
|
|
]); |
|
307
|
|
|
} |
|
308
|
|
|
if ($moduleModel->isPermitted('ExportPdf')) { |
|
309
|
|
|
$handlerClass = Vtiger_Loader::getComponentClassName('Model', 'PDF', $moduleName); |
|
310
|
|
|
$pdfModel = new $handlerClass(); |
|
311
|
|
|
$additionalClass = ''; |
|
312
|
|
|
if (!$pdfModel->checkActiveTemplates($recordId, $moduleName, 'Detail')) { |
|
313
|
|
|
$additionalClass = ' d-none'; |
|
314
|
|
|
} |
|
315
|
|
|
$linkModelList['DETAIL_VIEW_BASIC'][] = Vtiger_Link_Model::getInstanceFromValues([ |
|
316
|
|
|
'linktype' => 'DETAIL_VIEW_BASIC', |
|
317
|
|
|
'linklabel' => \App\Language::translate('LBL_EXPORT_PDF'), |
|
318
|
|
|
'dataUrl' => 'index.php?module=' . $moduleName . '&view=PDF&fromview=Detail&record=' . $recordId, |
|
319
|
|
|
'linkicon' => 'fas fa-file-pdf', |
|
320
|
|
|
'linkclass' => 'btn-outline-dark btn-sm showModal js-pdf' . $additionalClass, |
|
321
|
|
|
'title' => \App\Language::translate('LBL_EXPORT_PDF'), |
|
322
|
|
|
]); |
|
323
|
|
|
} |
|
324
|
|
|
} |
|
325
|
|
|
$relatedLinks = $this->getDetailViewRelatedLinks(); |
|
326
|
|
|
foreach ($relatedLinks as &$relatedLinkEntry) { |
|
327
|
|
|
$relatedLink = Vtiger_Link_Model::getInstanceFromValues($relatedLinkEntry); |
|
328
|
|
|
$linkModelList[$relatedLink->getType()][] = $relatedLink; |
|
329
|
|
|
} |
|
330
|
|
|
$allLinks = Vtiger_Link_Model::getAllByType($moduleModel->getId(), ['DETAIL_VIEW_ADDITIONAL', 'DETAIL_VIEW_BASIC', 'DETAIL_VIEW_HEADER_WIDGET', 'DETAIL_VIEW_EXTENDED', 'DETAILVIEWTAB', 'DETAILVIEWRELATED'], $linkParams); |
|
331
|
|
|
if (!empty($allLinks)) { |
|
332
|
|
|
foreach ($allLinks as $type => &$allLinksByType) { |
|
333
|
|
|
$linkModelList[$type] = $linkModelList[$type] ?? []; |
|
334
|
|
|
foreach ($allLinksByType as $linkModel) { |
|
335
|
|
|
$linkModelList[$type][] = $linkModel; |
|
336
|
|
|
} |
|
337
|
|
|
} |
|
338
|
|
|
} |
|
339
|
|
|
$this->set('Links', $linkModelList); |
|
340
|
|
|
return $linkModelList; |
|
341
|
|
|
} |
|
342
|
|
|
|
|
343
|
|
|
/** |
|
344
|
|
|
* Function to get the detail view related links. |
|
345
|
|
|
* |
|
346
|
|
|
* @return <array> - list of links parameters |
|
|
|
|
|
|
347
|
|
|
*/ |
|
348
|
|
|
public function getDetailViewRelatedLinks() |
|
349
|
|
|
{ |
|
350
|
|
|
$recordModel = $this->getRecord(); |
|
351
|
|
|
$parentModuleModel = $this->getModule(); |
|
352
|
|
|
$this->getWidgets(); |
|
353
|
|
|
$relatedLinks = []; |
|
354
|
|
|
if (class_exists($parentModuleModel->getName() . '_ProcessWizard_Model') && $recordModel->isEditable()) { |
|
355
|
|
|
$relatedLinks[] = [ |
|
356
|
|
|
'linktype' => 'DETAILVIEWTAB', |
|
357
|
|
|
'linklabel' => 'LBL_RECORD_PROCESS_WIZARD', |
|
358
|
|
|
'linkKey' => 'LBL_RECORD_PROCESS_WIZARD', |
|
359
|
|
|
'linkurl' => $recordModel->getDetailViewUrl() . '&mode=processWizard', |
|
360
|
|
|
'linkicon' => '', |
|
361
|
|
|
'related' => 'Summary', |
|
362
|
|
|
]; |
|
363
|
|
|
} |
|
364
|
|
|
if ($parentModuleModel->isSummaryViewSupported() && $this->widgetsList) { |
|
365
|
|
|
$relatedLinks[] = [ |
|
366
|
|
|
'linktype' => 'DETAILVIEWTAB', |
|
367
|
|
|
'linklabel' => 'LBL_RECORD_SUMMARY', |
|
368
|
|
|
'linkKey' => 'LBL_RECORD_SUMMARY', |
|
369
|
|
|
'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showDetailViewByMode&requestMode=summary', |
|
370
|
|
|
'linkicon' => '', |
|
371
|
|
|
'related' => 'Summary', |
|
372
|
|
|
]; |
|
373
|
|
|
} |
|
374
|
|
|
//link which shows the summary information(generally detail of record) |
|
375
|
|
|
$relatedLinks[] = [ |
|
376
|
|
|
'linktype' => 'DETAILVIEWTAB', |
|
377
|
|
|
'linklabel' => 'LBL_RECORD_DETAILS', |
|
378
|
|
|
'linkKey' => 'LBL_RECORD_DETAILS', |
|
379
|
|
|
'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showDetailViewByMode&requestMode=full', |
|
380
|
|
|
'linkicon' => '', |
|
381
|
|
|
'related' => 'Details', |
|
382
|
|
|
]; |
|
383
|
|
|
if ($parentModuleModel->isCommentEnabled() && ($modCommentsModel = Vtiger_Module_Model::getInstance('ModComments')) && $modCommentsModel->isPermitted('DetailView')) { |
|
384
|
|
|
$relatedLinks[] = [ |
|
385
|
|
|
'linktype' => 'DETAILVIEWTAB', |
|
386
|
|
|
'linklabel' => 'ModComments', |
|
387
|
|
|
'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showAllComments', |
|
388
|
|
|
'linkicon' => '', |
|
389
|
|
|
'related' => $modCommentsModel->getName(), |
|
390
|
|
|
'countRelated' => App\Config::relation('SHOW_RECORDS_COUNT'), |
|
391
|
|
|
]; |
|
392
|
|
|
} |
|
393
|
|
|
if ($parentModuleModel->isTrackingEnabled() && $parentModuleModel->isPermitted('ModTracker')) { |
|
394
|
|
|
$relatedLinks[] = [ |
|
395
|
|
|
'linktype' => 'DETAILVIEWTAB', |
|
396
|
|
|
'linklabel' => 'LBL_UPDATES', |
|
397
|
|
|
'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showRecentActivities&page=1', |
|
398
|
|
|
'linkicon' => '', |
|
399
|
|
|
'related' => 'ModTracker', |
|
400
|
|
|
'countRelated' => App\Config::module('ModTracker', 'UNREVIEWED_COUNT') && $parentModuleModel->isPermitted('ReviewingUpdates'), |
|
401
|
|
|
'badgeClass' => 'bgDanger', |
|
402
|
|
|
]; |
|
403
|
|
|
} |
|
404
|
|
|
if ( |
|
405
|
|
|
\App\User::getCurrentUserId() === \App\User::getCurrentUserRealId() |
|
406
|
|
|
&& \App\Module::isModuleActive('Chat') && !\App\RequestUtil::getBrowserInfo()->ie |
|
407
|
|
|
&& false !== \App\ModuleHierarchy::getModuleLevel($parentModuleModel->getName()) |
|
408
|
|
|
) { |
|
409
|
|
|
$relatedLinks[] = [ |
|
410
|
|
|
'linktype' => 'DETAILVIEWTAB', |
|
411
|
|
|
'linklabel' => 'LBL_CHAT', |
|
412
|
|
|
'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showChat', |
|
413
|
|
|
'linkicon' => 'fas fa-comments', |
|
414
|
|
|
]; |
|
415
|
|
|
} |
|
416
|
|
|
foreach ($parentModuleModel->getRelations() as $relation) { |
|
417
|
|
|
if ($relation->isRelatedViewType('RelatedTab') && (!$relation->isDirectRelation() || !($relationField = $relation->getRelationField()) || $relationField->isActiveField())) { |
|
418
|
|
|
$relatedLinks[] = [ |
|
419
|
|
|
'linktype' => 'DETAILVIEWRELATED', |
|
420
|
|
|
'linklabel' => $relation->get('label'), |
|
421
|
|
|
'linkurl' => $relation->getListUrl($recordModel), |
|
422
|
|
|
'linkicon' => '', |
|
423
|
|
|
'relatedModuleName' => $relation->get('relatedModuleName'), |
|
424
|
|
|
'relationId' => $relation->getId(), |
|
425
|
|
|
]; |
|
426
|
|
|
} |
|
427
|
|
|
} |
|
428
|
|
|
return $relatedLinks; |
|
429
|
|
|
} |
|
430
|
|
|
|
|
431
|
|
|
/** |
|
432
|
|
|
* @param type $viewType |
|
433
|
|
|
* |
|
434
|
|
|
* @return type |
|
435
|
|
|
*/ |
|
436
|
|
|
public function getBlocks($viewType) |
|
437
|
|
|
{ |
|
438
|
|
|
$recordModel = $this->getRecord(); |
|
439
|
|
|
$relatedLinks = []; |
|
440
|
|
|
foreach ($this->getModule()->getRelations() as $relation) { |
|
441
|
|
|
if ($relation->isRelatedViewType($viewType)) { |
|
442
|
|
|
$relatedLinks[] = Vtiger_Link_Model::getInstanceFromValues([ |
|
443
|
|
|
'linklabel' => $relation->get('label'), |
|
444
|
|
|
'linkurl' => $relation->getListUrl($recordModel), |
|
445
|
|
|
'linkicon' => '', |
|
446
|
|
|
'relatedModuleName' => $relation->get('relatedModuleName'), |
|
447
|
|
|
'relationId' => $relation->getId(), |
|
448
|
|
|
]); |
|
449
|
|
|
} |
|
450
|
|
|
} |
|
451
|
|
|
return $relatedLinks; |
|
|
|
|
|
|
452
|
|
|
} |
|
453
|
|
|
|
|
454
|
|
|
/** |
|
455
|
|
|
* Function to get the detail view widgets. |
|
456
|
|
|
*/ |
|
457
|
|
|
public function getWidgets() |
|
458
|
|
|
{ |
|
459
|
|
|
if (empty($this->widgetsList)) { |
|
460
|
|
|
$moduleModel = $this->getModule(); |
|
461
|
|
|
$moduleName = $this->getModuleName(); |
|
462
|
|
|
$recordId = $this->getRecord()->getId(); |
|
463
|
|
|
$modelWidgets = $moduleModel->getWidgets($moduleName); |
|
464
|
|
|
foreach ($modelWidgets as $widgetCol) { |
|
465
|
|
|
foreach ($widgetCol as $widget) { |
|
466
|
|
|
$widgetName = Vtiger_Loader::getComponentClassName('Widget', $widget['type'], $moduleName); |
|
467
|
|
|
if (class_exists($widgetName)) { |
|
468
|
|
|
$this->widgetsList[] = $widget['type']; |
|
469
|
|
|
$widgetInstance = new $widgetName($moduleName, $moduleModel, $recordId, $widget); |
|
470
|
|
|
$widgetObject = $widgetInstance->getWidget(); |
|
471
|
|
|
if (\count($widgetObject) > 0 && (!method_exists($widgetInstance, 'isPermitted') || $widgetInstance->isPermitted())) { |
|
472
|
|
|
$this->widgets[$widgetObject['wcol']][] = $widgetObject; |
|
473
|
|
|
} |
|
474
|
|
|
} |
|
475
|
|
|
} |
|
476
|
|
|
} |
|
477
|
|
|
} |
|
478
|
|
|
} |
|
479
|
|
|
|
|
480
|
|
|
/** |
|
481
|
|
|
* Function to get the Quick Links for the Detail view of the module. |
|
482
|
|
|
* |
|
483
|
|
|
* @param <Array> $linkParams |
|
|
|
|
|
|
484
|
|
|
* |
|
485
|
|
|
* @return <Array> List of Vtiger_Link_Model instances |
|
|
|
|
|
|
486
|
|
|
*/ |
|
487
|
|
|
public function getSideBarLinks($linkParams) |
|
|
|
|
|
|
488
|
|
|
{ |
|
489
|
|
|
$linkTypes = ['SIDEBARLINK', 'SIDEBARWIDGET']; |
|
490
|
|
|
$moduleLinks = $this->getModule()->getSideBarLinks($linkTypes); |
|
491
|
|
|
|
|
492
|
|
|
$listLinkTypes = ['DETAILVIEWSIDEBARLINK', 'DETAILVIEWSIDEBARWIDGET']; |
|
493
|
|
|
$listLinks = Vtiger_Link_Model::getAllByType($this->getModule()->getId(), $listLinkTypes); |
|
494
|
|
|
|
|
495
|
|
|
if (isset($listLinks['DETAILVIEWSIDEBARLINK'])) { |
|
496
|
|
|
foreach ($listLinks['DETAILVIEWSIDEBARLINK'] as $link) { |
|
497
|
|
|
$link->linkurl = $link->linkurl . '&record=' . $this->getRecord()->getId() . '&source_module=' . $this->getModule()->getName(); |
|
498
|
|
|
$moduleLinks['SIDEBARLINK'][] = $link; |
|
499
|
|
|
} |
|
500
|
|
|
} |
|
501
|
|
|
|
|
502
|
|
|
if (isset($listLinks['DETAILVIEWSIDEBARWIDGET'])) { |
|
503
|
|
|
foreach ($listLinks['DETAILVIEWSIDEBARWIDGET'] as $link) { |
|
504
|
|
|
$link->linkurl = $link->linkurl . '&record=' . $this->getRecord()->getId() . '&source_module=' . $this->getModule()->getName(); |
|
505
|
|
|
$moduleLinks['SIDEBARWIDGET'][] = $link; |
|
506
|
|
|
} |
|
507
|
|
|
} |
|
508
|
|
|
return $moduleLinks; |
|
509
|
|
|
} |
|
510
|
|
|
|
|
511
|
|
|
/** |
|
512
|
|
|
* Function to get the module label. |
|
513
|
|
|
* |
|
514
|
|
|
* @return string - label |
|
515
|
|
|
*/ |
|
516
|
|
|
public function getModuleLabel() |
|
517
|
|
|
{ |
|
518
|
|
|
return $this->getModule()->get('label'); |
|
519
|
|
|
} |
|
520
|
|
|
|
|
521
|
|
|
/** |
|
522
|
|
|
* Function to get the module name. |
|
523
|
|
|
* |
|
524
|
|
|
* @return string - name of the module |
|
525
|
|
|
*/ |
|
526
|
|
|
public function getModuleName() |
|
527
|
|
|
{ |
|
528
|
|
|
return $this->getModule()->get('name'); |
|
529
|
|
|
} |
|
530
|
|
|
|
|
531
|
|
|
/** |
|
532
|
|
|
* Function to get the instance. |
|
533
|
|
|
* |
|
534
|
|
|
* @param string $moduleName - module name |
|
535
|
|
|
* @param string $recordId - record id |
|
536
|
|
|
* |
|
537
|
|
|
* @return Vtiger_DetailView_Model |
|
538
|
|
|
*/ |
|
539
|
|
|
public static function getInstance($moduleName, $recordId) |
|
540
|
|
|
{ |
|
541
|
|
|
$modelClassName = Vtiger_Loader::getComponentClassName('Model', 'DetailView', $moduleName); |
|
542
|
|
|
$instance = new $modelClassName(); |
|
543
|
|
|
|
|
544
|
|
|
$moduleModel = Vtiger_Module_Model::getInstance($moduleName); |
|
545
|
|
|
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName); |
|
|
|
|
|
|
546
|
|
|
|
|
547
|
|
|
return $instance->setModule($moduleModel)->setRecord($recordModel); |
|
548
|
|
|
} |
|
549
|
|
|
|
|
550
|
|
|
public function getCustomHeaderFields() |
|
551
|
|
|
{ |
|
552
|
|
|
$moduleName = $this->getModuleName(); |
|
553
|
|
|
$path = 'modules' . DIRECTORY_SEPARATOR . $moduleName . DIRECTORY_SEPARATOR . 'headerfields'; |
|
554
|
|
|
if (!is_dir($path)) { |
|
555
|
|
|
return []; |
|
556
|
|
|
} |
|
557
|
|
|
$headerFields = []; |
|
558
|
|
|
foreach (new DirectoryIterator($path) as $fileinfo) { |
|
559
|
|
|
if (!$fileinfo->isDot()) { |
|
560
|
|
|
$filename = explode('.', $fileinfo->getFilename()); |
|
561
|
|
|
$name = reset($filename); |
|
562
|
|
|
|
|
563
|
|
|
$modelClassName = Vtiger_Loader::getComponentClassName('HeaderField', $name, $moduleName); |
|
564
|
|
|
$instance = new $modelClassName(); |
|
565
|
|
|
if (method_exists($instance, 'checkPermission') && !$instance->checkPermission()) { |
|
566
|
|
|
continue; |
|
567
|
|
|
} |
|
568
|
|
|
if ($result = $instance->process($this)) { |
|
569
|
|
|
$headerFields[$name] = $result; |
|
570
|
|
|
} |
|
571
|
|
|
} |
|
572
|
|
|
} |
|
573
|
|
|
ksort($headerFields); |
|
574
|
|
|
|
|
575
|
|
|
return $headerFields; |
|
576
|
|
|
} |
|
577
|
|
|
} |
|
578
|
|
|
|