Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
8c9251b3 | 6 | | Copyright CiviCRM LLC (c) 2004-2018 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
8c9251b3 | 31 | * @copyright CiviCRM LLC (c) 2004-2018 |
6a488035 TO |
32 | * |
33 | */ | |
34 | class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { | |
35 | ||
36 | /** | |
fe482240 | 37 | * The action links that we need to display for the browse screen. |
6a488035 TO |
38 | * |
39 | * @var array | |
6a488035 TO |
40 | */ |
41 | static $_links = NULL; | |
42 | ||
43 | protected $_fields = NULL; | |
44 | ||
45 | protected $_profileId = NULL; | |
366fe2a3 | 46 | |
5a2c7bb9 | 47 | public $_contactId = NULL; |
6a488035 | 48 | |
5a2c7bb9 | 49 | public $_customGroupTitle = NULL; |
e41f4660 | 50 | |
5a2c7bb9 | 51 | public $_pageViewType = NULL; |
e41f4660 | 52 | |
5a2c7bb9 | 53 | public $_contactType = NULL; |
fcc8f207 | 54 | |
6a488035 | 55 | /** |
fe482240 | 56 | * Get BAO Name. |
6a488035 | 57 | * |
a6c01b45 CW |
58 | * @return string |
59 | * Classname of BAO. | |
6a488035 | 60 | */ |
00be9182 | 61 | public function getBAOName() { |
6a488035 TO |
62 | return ''; |
63 | } | |
64 | ||
65 | /** | |
fe482240 | 66 | * Get action Links. |
6a488035 | 67 | * |
a6c01b45 CW |
68 | * @return array |
69 | * (reference) of action links | |
6a488035 | 70 | */ |
00be9182 | 71 | public function &links() { |
e41f4660 | 72 | if (!(self::$_links[$this->_pageViewType])) { |
6a488035 TO |
73 | // helper variable for nicer formatting |
74 | $links = array(); | |
75 | ||
76 | $view = array_search(CRM_Core_Action::VIEW, CRM_Core_Action::$_names); | |
77 | $update = array_search(CRM_Core_Action::UPDATE, CRM_Core_Action::$_names); | |
78 | $delete = array_search(CRM_Core_Action::DELETE, CRM_Core_Action::$_names); | |
366fe2a3 | 79 | |
1dde099b | 80 | // names and titles |
6a488035 TO |
81 | $links[CRM_Core_Action::VIEW] = array( |
82 | 'name' => ts('View'), | |
481a74f4 | 83 | 'title' => ts('View %1', array(1 => $this->_customGroupTitle . ' record')), |
6a488035 TO |
84 | ); |
85 | ||
86 | $links[CRM_Core_Action::UPDATE] = array( | |
87 | 'name' => ts('Edit'), | |
481a74f4 | 88 | 'title' => ts('Edit %1', array(1 => $this->_customGroupTitle . ' record')), |
6a488035 TO |
89 | ); |
90 | ||
91 | $links[CRM_Core_Action::DELETE] = array( | |
92 | 'name' => ts('Delete'), | |
481a74f4 | 93 | 'title' => ts('Delete %1', array(1 => $this->_customGroupTitle . ' record')), |
6a488035 | 94 | ); |
366fe2a3 | 95 | |
1dde099b | 96 | // urls and queryStrings |
e41f4660 | 97 | if ($this->_pageViewType == 'profileDataView') { |
1dde099b | 98 | $links[CRM_Core_Action::VIEW]['url'] = 'civicrm/profile/view'; |
7ab9bfe8 | 99 | $links[CRM_Core_Action::VIEW]['qs'] = "reset=1&id=%%id%%&recordId=%%recordId%%&gid=%%gid%%&multiRecord={$view}"; |
1dde099b PJ |
100 | |
101 | $links[CRM_Core_Action::UPDATE]['url'] = 'civicrm/profile/edit'; | |
7ab9bfe8 | 102 | $links[CRM_Core_Action::UPDATE]['qs'] = "reset=1&id=%%id%%&recordId=%%recordId%%&gid=%%gid%%&multiRecord={$update}"; |
1dde099b | 103 | |
e41f4660 | 104 | $links[CRM_Core_Action::DELETE]['url'] = 'civicrm/profile/edit'; |
7ab9bfe8 | 105 | $links[CRM_Core_Action::DELETE]['qs'] = "reset=1&id=%%id%%&recordId=%%recordId%%&gid=%%gid%%&multiRecord={$delete}"; |
1dde099b PJ |
106 | |
107 | } | |
108 | elseif ($this->_pageViewType == 'customDataView') { | |
109 | // custom data specific view links | |
110 | $links[CRM_Core_Action::VIEW]['url'] = 'civicrm/contact/view/cd'; | |
e1d48b72 | 111 | $links[CRM_Core_Action::VIEW]['qs'] = 'reset=1&gid=%%gid%%&cid=%%cid%%&recId=%%recId%%&cgcount=%%cgcount%%&multiRecordDisplay=single&mode=view'; |
1dde099b PJ |
112 | |
113 | // custom data specific update links | |
114 | $links[CRM_Core_Action::UPDATE]['url'] = 'civicrm/contact/view/cd/edit'; | |
525faea3 | 115 | $links[CRM_Core_Action::UPDATE]['qs'] = 'reset=1&type=%%type%%&groupID=%%groupID%%&entityID=%%entityID%%&cgcount=%%cgcount%%&multiRecordDisplay=single&mode=edit'; |
1dde099b PJ |
116 | // NOTE : links for DELETE action for customDataView is handled in browse |
117 | ||
118 | // copy action | |
119 | $links[CRM_Core_Action::COPY] = array( | |
120 | 'name' => ts('Copy'), | |
481a74f4 | 121 | 'title' => ts('Copy %1', array(1 => $this->_customGroupTitle . ' record')), |
1dde099b | 122 | 'url' => 'civicrm/contact/view/cd/edit', |
21dfd5f5 | 123 | 'qs' => 'reset=1&type=%%type%%&groupID=%%groupID%%&entityID=%%entityID%%&cgcount=%%newCgCount%%&multiRecordDisplay=single©ValueId=%%cgcount%%&mode=copy', |
1dde099b | 124 | ); |
e41f4660 PJ |
125 | } |
126 | ||
127 | self::$_links[$this->_pageViewType] = $links; | |
6a488035 | 128 | } |
e41f4660 | 129 | return self::$_links[$this->_pageViewType]; |
6a488035 TO |
130 | } |
131 | ||
132 | /** | |
fe482240 | 133 | * Run the page. |
6a488035 TO |
134 | * |
135 | * This method is called after the page is created. It checks for the type | |
136 | * of action and executes that action. Finally it calls the parent's run | |
137 | * method. | |
138 | * | |
6a488035 | 139 | */ |
00be9182 | 140 | public function run() { |
6a488035 TO |
141 | // get the requested action, default to 'browse' |
142 | $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, FALSE); | |
143 | ||
144 | // assign vars to templates | |
145 | $this->assign('action', $action); | |
146 | $profileId = CRM_Utils_Request::retrieve('profileId', 'Positive', $this, FALSE); | |
147 | if (!is_array($profileId) && is_numeric($profileId)) { | |
366fe2a3 | 148 | $this->_profileId = $profileId; |
6a488035 | 149 | } |
366fe2a3 | 150 | |
6a488035 | 151 | $this->_contactId = CRM_Utils_Request::retrieve('contactId', 'Positive', $this, FALSE); |
e41f4660 PJ |
152 | $this->_pageViewType = CRM_Utils_Request::retrieve('pageViewType', 'Positive', $this, FALSE, 'profileDataView'); |
153 | $this->_customGroupId = CRM_Utils_Request::retrieve('customGroupId', 'Positive', $this, FALSE, 0); | |
154 | $this->_contactType = CRM_Utils_Request::retrieve('contactType', 'String', $this, FALSE); | |
6a488035 | 155 | if ($action & CRM_Core_Action::BROWSE) { |
366fe2a3 | 156 | //browse |
6a488035 TO |
157 | $this->browse(); |
158 | return; | |
159 | } | |
160 | // parent run | |
161 | return parent::run(); | |
162 | } | |
163 | ||
164 | /** | |
fe482240 | 165 | * Browse the listing. |
6a488035 | 166 | * |
6a488035 | 167 | */ |
00be9182 | 168 | public function browse() { |
b05a0fb6 | 169 | $dateFields = NULL; |
d4c2682f | 170 | $newCgCount = $cgcount = 0; |
f1eae8d1 | 171 | $attributes = $result = $headerAttr = array(); |
b05a0fb6 | 172 | $dateFieldsVals = NULL; |
e41f4660 | 173 | if ($this->_pageViewType == 'profileDataView' && $this->_profileId) { |
6a488035 TO |
174 | $fields = CRM_Core_BAO_UFGroup::getFields($this->_profileId, FALSE, NULL, |
175 | NULL, NULL, | |
176 | FALSE, NULL, | |
177 | FALSE, | |
178 | NULL, | |
179 | CRM_Core_Permission::EDIT | |
180 | ); | |
dc98079b | 181 | $multiRecordFields = array(); |
6a488035 TO |
182 | $fieldIDs = NULL; |
183 | $result = NULL; | |
184 | $multiRecordFieldsWithSummaryListing = CRM_Core_BAO_UFGroup::shiftMultiRecordFields($fields, $multiRecordFields, TRUE); | |
366fe2a3 | 185 | |
6a488035 TO |
186 | $multiFieldId = CRM_Core_BAO_CustomField::getKeyID(key($multiRecordFields)); |
187 | $customGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $multiFieldId, 'custom_group_id'); | |
188 | $reached = CRM_Core_BAO_CustomGroup::hasReachedMaxLimit($customGroupId, $this->_contactId); | |
189 | if (!$reached) { | |
190 | $this->assign('contactId', $this->_contactId); | |
191 | $this->assign('gid', $this->_profileId); | |
192 | } | |
193 | $this->assign('reachedMax', $reached); | |
366fe2a3 | 194 | |
6a488035 TO |
195 | if ($multiRecordFieldsWithSummaryListing && !empty($multiRecordFieldsWithSummaryListing)) { |
196 | $fieldIDs = array_keys($multiRecordFieldsWithSummaryListing); | |
197 | } | |
198 | } | |
e41f4660 PJ |
199 | elseif ($this->_pageViewType == 'customDataView') { |
200 | // require custom group id for _pageViewType of customDataView | |
201 | $customGroupId = $this->_customGroupId; | |
ac9dd8dc | 202 | $this->assign('customGroupId', $customGroupId); |
e41f4660 PJ |
203 | $reached = CRM_Core_BAO_CustomGroup::hasReachedMaxLimit($customGroupId, $this->_contactId); |
204 | if (!$reached) { | |
205 | $this->assign('contactId', $this->_contactId); | |
e41f4660 PJ |
206 | $this->assign('ctype', $this->_contactType); |
207 | } | |
208 | $this->assign('reachedMax', $reached); | |
209 | // custom group info : this consists of the field title of group fields | |
210 | $groupDetail = CRM_Core_BAO_CustomGroup::getGroupDetail($customGroupId, NULL, CRM_Core_DAO::$_nullObject, TRUE); | |
211 | // field ids of fields in_selector for the custom group id provided | |
212 | $fieldIDs = array_keys($groupDetail[$customGroupId]['fields']); | |
213 | // field labels for headers | |
214 | $fieldLabels = $groupDetail[$customGroupId]['fields']; | |
215 | ||
216 | // from the above customGroupInfo we can get $this->_customGroupTitle | |
217 | $this->_customGroupTitle = $groupDetail[$customGroupId]['title']; | |
218 | } | |
9082df1a | 219 | if (!empty($fieldIDs) && $this->_contactId) { |
dc98079b | 220 | $options = array(); |
353ffa53 TO |
221 | $returnProperities = array( |
222 | 'html_type', | |
223 | 'data_type', | |
224 | 'date_format', | |
225 | 'time_format', | |
226 | 'default_value', | |
acb1052e | 227 | 'is_required', |
a5f3119b | 228 | 'is_view', |
353ffa53 | 229 | ); |
6a488035 | 230 | foreach ($fieldIDs as $key => $fieldID) { |
e41f4660 | 231 | $fieldIDs[$key] = !is_numeric($fieldID) ? CRM_Core_BAO_CustomField::getKeyID($fieldID) : $fieldID; |
6a488035 | 232 | $param = array('id' => $fieldIDs[$key]); |
dc98079b | 233 | $returnValues = array(); |
6a488035 | 234 | CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $param, $returnValues, $returnProperities); |
b05a0fb6 PJ |
235 | if ($returnValues['data_type'] == 'Date') { |
236 | $dateFields[$fieldIDs[$key]] = 1; | |
ed0ca248 | 237 | $actualPHPFormats = CRM_Utils_Date::datePluginToPHPFormats(); |
791590df | 238 | $dateFormat = (array) CRM_Utils_Array::value($returnValues['date_format'], $actualPHPFormats); |
239 | $timeFormat = CRM_Utils_Array::value('time_format', $returnValues); | |
b05a0fb6 | 240 | } |
366fe2a3 | 241 | |
6a488035 TO |
242 | $optionValuePairs = CRM_Core_BAO_CustomOption::getCustomOption($fieldIDs[$key]); |
243 | if (!empty($optionValuePairs)) { | |
244 | foreach ($optionValuePairs as $optionPairs) { | |
245 | $options[$fieldIDs[$key]][$optionPairs['value']] = $optionPairs['label']; | |
246 | } | |
247 | } | |
366fe2a3 | 248 | |
6a488035 TO |
249 | $options[$fieldIDs[$key]]['attributes']['html_type'] = $returnValues['html_type']; |
250 | $options[$fieldIDs[$key]]['attributes']['data_type'] = $returnValues['data_type']; | |
4411002f CW |
251 | $options[$fieldIDs[$key]]['attributes']['is_required'] = !empty($returnValues['is_required']); |
252 | $options[$fieldIDs[$key]]['attributes']['default_value'] = CRM_Utils_Array::value('default_value', $returnValues); | |
a5f3119b | 253 | $options[$fieldIDs[$key]]['attributes']['is_view'] = CRM_Utils_Array::value('is_view', $returnValues); |
366fe2a3 | 254 | |
acb1052e WA |
255 | $options[$fieldIDs[$key]]['attributes']['format'] |
256 | = $options[$fieldIDs[$key]]['attributes']['date_format'] = CRM_Utils_Array::value('date_format', $returnValues); | |
6a488035 TO |
257 | $options[$fieldIDs[$key]]['attributes']['time_format'] = CRM_Utils_Array::value('time_format', $returnValues); |
258 | } | |
9082df1a | 259 | $linkAction = array_sum(array_keys($this->links())); |
260 | } | |
366fe2a3 | 261 | |
d4c2682f | 262 | if (!empty($fieldIDs) && $this->_contactId) { |
c693f065 | 263 | $DTparams = !empty($this->_DTparams) ? $this->_DTparams : NULL; |
e41f4660 | 264 | // commonly used for both views i.e profile listing view (profileDataView) and custom data listing view (customDataView) |
e525d6af | 265 | $result = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_contactId, NULL, $fieldIDs, TRUE, $DTparams); |
f5eda27f | 266 | $resultCount = !empty($result['count']) ? $result['count'] : count($result); |
e525d6af | 267 | $sortedResult = !empty($result['sortedResult']) ? $result['sortedResult'] : array(); |
c693f065 | 268 | unset($result['count']); |
e525d6af | 269 | unset($result['sortedResult']); |
366fe2a3 | 270 | |
e41f4660 PJ |
271 | if ($this->_pageViewType == 'profileDataView') { |
272 | if (!empty($fieldIDs)) { | |
273 | //get the group info of multi rec fields in listing view | |
274 | $fieldInput = $fieldIDs; | |
275 | $fieldIdInput = $fieldIDs[0]; | |
276 | } | |
277 | else { | |
278 | //if no listing fields exist, take the group title for display | |
279 | $nonListingFieldIds = array_keys($multiRecordFields); | |
280 | $singleField = CRM_Core_BAO_CustomField::getKeyID($nonListingFieldIds[0]); | |
281 | $fieldIdInput = $singleField; | |
282 | $singleField = array($singleField); | |
353ffa53 | 283 | $fieldInput = $singleField; |
e41f4660 PJ |
284 | } |
285 | $customGroupInfo = CRM_Core_BAO_CustomGroup::getGroupTitles($fieldInput); | |
286 | $this->_customGroupTitle = $customGroupInfo[$fieldIdInput]['groupTitle']; | |
287 | } | |
abdd5e3e | 288 | // $cgcount is defined before 'if' condition as entity may have no record |
e41f4660 PJ |
289 | // and $cgcount is used to build new record url |
290 | $cgcount = 1; | |
d4c2682f | 291 | $newCgCount = (!$reached) ? $resultCount + 1 : NULL; |
292 | if (!empty($result) && empty($this->_headersOnly)) { | |
eb2b4bdb | 293 | $links = self::links(); |
e41f4660 PJ |
294 | if ($this->_pageViewType == 'profileDataView') { |
295 | $pageCheckSum = $this->get('pageCheckSum'); | |
296 | if ($pageCheckSum) { | |
297 | foreach ($links as $key => $link) { | |
298 | $links[$key] = $link['qs'] . "&cs=%%cs%%"; | |
299 | } | |
300 | } | |
301 | } | |
1dde099b PJ |
302 | |
303 | if ($reached) { | |
304 | unset($links[CRM_Core_Action::COPY]); | |
305 | } | |
c693f065 | 306 | if (!empty($DTparams)) { |
307 | $this->_total = $resultCount; | |
308 | $cgcount = $DTparams['offset'] + 1; | |
5a2c7bb9 | 309 | } |
e41f4660 PJ |
310 | foreach ($result as $recId => &$value) { |
311 | foreach ($value as $fieldId => &$val) { | |
312 | if (is_numeric($fieldId)) { | |
313 | $customValue = &$val; | |
5f1aa3a5 | 314 | if (!empty($dateFields) && array_key_exists($fieldId, $dateFields)) { |
b44e3f84 | 315 | // formatted date capture value capture |
8cee0c70 | 316 | $dateFieldsVals[$fieldId][$recId] = CRM_Core_BAO_CustomField::displayValue($customValue, $fieldId); |
791590df | 317 | |
318 | //set date and time format | |
319 | switch ($timeFormat) { | |
320 | case 1: | |
32bb1fb6 | 321 | $dateFormat[1] = 'g:iA'; |
791590df | 322 | break; |
323 | ||
324 | case 2: | |
32bb1fb6 | 325 | $dateFormat[1] = 'G:i'; |
791590df | 326 | break; |
327 | ||
328 | default: | |
329 | // if time is not selected remove time from value | |
330 | $result[$recId][$fieldId] = substr($result[$recId][$fieldId], 0, 10); | |
331 | } | |
332 | $result[$recId][$fieldId] = CRM_Utils_Date::processDate($result[$recId][$fieldId], NULL, FALSE, implode(" ", $dateFormat)); | |
b05a0fb6 PJ |
333 | } |
334 | else { | |
335 | // assign to $result | |
8cee0c70 | 336 | $customValue = CRM_Core_BAO_CustomField::displayValue($customValue, $fieldId); |
e41f4660 PJ |
337 | } |
338 | ||
4411002f CW |
339 | // Set field attributes to support crmEditable |
340 | // Note that $fieldAttributes[data-type] actually refers to the html type not the sql data type | |
341 | // TODO: Not all widget types and validation rules are supported by crmEditable so some fields will not be in-place editable | |
342 | $fieldAttributes = array('class' => "crmf-custom_{$fieldId}_$recId"); | |
343 | $editable = FALSE; | |
b27f479b | 344 | if (!$options[$fieldId]['attributes']['is_view'] && $linkAction & CRM_Core_Action::UPDATE) { |
4411002f CW |
345 | $spec = $options[$fieldId]['attributes']; |
346 | switch ($spec['html_type']) { | |
347 | case 'Text': | |
348 | // Other data types like money would require some extra validation | |
349 | // FIXME: crmEditable currently does not support any validation rules :( | |
350 | $supportedDataTypes = array('Float', 'String', 'Int'); | |
351 | $editable = in_array($spec['data_type'], $supportedDataTypes); | |
352 | break; | |
dc98079b | 353 | |
4411002f CW |
354 | case 'TextArea': |
355 | $editable = TRUE; | |
356 | $fieldAttributes['data-type'] = 'textarea'; | |
357 | break; | |
dc98079b | 358 | |
4411002f CW |
359 | case 'Radio': |
360 | case 'Select': | |
361 | case 'Select Country': | |
362 | case 'Select State/Province': | |
363 | $editable = TRUE; | |
364 | $fieldAttributes['data-type'] = $spec['data_type'] == 'Boolean' ? 'boolean' : 'select'; | |
365 | if (!$spec['is_required']) { | |
366 | $fieldAttributes['data-empty-option'] = ts('- none -'); | |
367 | } | |
368 | break; | |
369 | } | |
370 | } | |
371 | if ($editable) { | |
372 | $fieldAttributes['class'] .= ' crm-editable'; | |
373 | } | |
374 | $attributes[$fieldId][$recId] = $fieldAttributes; | |
375 | ||
e41f4660 PJ |
376 | $op = NULL; |
377 | if ($this->_pageViewType == 'profileDataView') { | |
dc98079b | 378 | $actionParams = array( |
353ffa53 TO |
379 | 'recordId' => $recId, |
380 | 'gid' => $this->_profileId, | |
acb1052e | 381 | 'id' => $this->_contactId, |
353ffa53 | 382 | ); |
e41f4660 PJ |
383 | $op = 'profile.multiValue.row'; |
384 | } | |
385 | else { | |
386 | // different set of url params | |
387 | $actionParams['gid'] = $actionParams['groupID'] = $this->_customGroupId; | |
388 | $actionParams['cid'] = $actionParams['entityID'] = $this->_contactId; | |
389 | $actionParams['recId'] = $recId; | |
390 | $actionParams['type'] = $this->_contactType; | |
1c66bdc7 | 391 | $actionParams['cgcount'] = empty($DTparams['sort']) ? $cgcount : $sortedResult[$recId]; |
1dde099b | 392 | $actionParams['newCgCount'] = $newCgCount; |
eb2b4bdb PJ |
393 | |
394 | // DELETE action links | |
a801aa5c CW |
395 | $deleteData = array( |
396 | 'valueID' => $recId, | |
397 | 'groupID' => $this->_customGroupId, | |
398 | 'contactId' => $this->_contactId, | |
399 | 'key' => CRM_Core_Key::get('civicrm/ajax/customvalue'), | |
400 | ); | |
eb2b4bdb | 401 | $links[CRM_Core_Action::DELETE]['url'] = '#'; |
86bfa4f6 | 402 | $links[CRM_Core_Action::DELETE]['extra'] = ' data-delete_params="' . htmlspecialchars(json_encode($deleteData)) . '"'; |
a801aa5c | 403 | $links[CRM_Core_Action::DELETE]['class'] = 'delete-custom-row'; |
e41f4660 PJ |
404 | } |
405 | if (!empty($pageCheckSum)) { | |
406 | $actionParams['cs'] = $pageCheckSum; | |
407 | } | |
eb2b4bdb | 408 | |
d51e02d3 | 409 | $value['action'] = CRM_Core_Action::formLink( |
e41f4660 PJ |
410 | $links, |
411 | $linkAction, | |
412 | $actionParams, | |
413 | ts('more'), | |
414 | FALSE, | |
415 | $op, | |
416 | 'customValue', | |
c5c263ca | 417 | $fieldId |
e41f4660 PJ |
418 | ); |
419 | } | |
420 | } | |
421 | $cgcount++; | |
422 | } | |
423 | } | |
6a488035 | 424 | } |
366fe2a3 | 425 | |
dc98079b | 426 | $headers = array(); |
6a488035 | 427 | if (!empty($fieldIDs)) { |
9082df1a | 428 | $fields = array('Radio', 'Select', 'Select Country', 'Select State/Province'); |
6a488035 | 429 | foreach ($fieldIDs as $fieldID) { |
f1eae8d1 | 430 | if ($this->_pageViewType == 'profileDataView') { |
431 | $headers[$fieldID] = $customGroupInfo[$fieldID]['fieldLabel']; | |
432 | } | |
9082df1a | 433 | elseif (!empty($this->_headersOnly)) { |
434 | if (!$options[$fieldID]['attributes']['is_view'] && $linkAction & CRM_Core_Action::UPDATE) { | |
435 | $spec = $options[$fieldID]['attributes']; | |
436 | ||
437 | if (in_array($spec['html_type'], $fields)) { | |
438 | $headerAttr[$fieldID]['dataType'] = $spec['data_type'] == 'Boolean' ? 'boolean' : 'select'; | |
439 | if (!$spec['is_required']) { | |
440 | $headerAttr[$fieldID]['dataEmptyOption'] = ts('- none -'); | |
441 | } | |
442 | } | |
443 | elseif ($spec['html_type'] == 'TextArea') { | |
444 | $headerAttr[$fieldID]['dataType'] = 'textarea'; | |
445 | } | |
446 | } | |
f1eae8d1 | 447 | $headers[$fieldID] = $fieldLabels[$fieldID]['label']; |
448 | $headerAttr[$fieldID]['columnName'] = $fieldLabels[$fieldID]['column_name']; | |
449 | } | |
6a488035 TO |
450 | } |
451 | } | |
b05a0fb6 | 452 | $this->assign('dateFields', $dateFields); |
dc98079b | 453 | $this->assign('dateFieldsVals', $dateFieldsVals); |
e41f4660 | 454 | $this->assign('cgcount', $cgcount); |
d4c2682f | 455 | $this->assign('newCgCount', $newCgCount); |
5a2c7bb9 | 456 | $this->assign('contactId', $this->_contactId); |
457 | $this->assign('contactType', $this->_contactType); | |
6a488035 TO |
458 | $this->assign('customGroupTitle', $this->_customGroupTitle); |
459 | $this->assign('headers', $headers); | |
c693f065 | 460 | $this->assign('headerAttr', $headerAttr); |
6a488035 | 461 | $this->assign('records', $result); |
c693f065 | 462 | $this->assign('attributes', $attributes); |
5a2c7bb9 | 463 | |
c693f065 | 464 | return array($result, $attributes); |
6a488035 TO |
465 | } |
466 | ||
467 | /** | |
fe482240 | 468 | * Get name of edit form. |
6a488035 | 469 | * |
a6c01b45 CW |
470 | * @return string |
471 | * classname of edit form | |
6a488035 | 472 | */ |
00be9182 | 473 | public function editForm() { |
6a488035 TO |
474 | return ''; |
475 | } | |
476 | ||
477 | /** | |
fe482240 | 478 | * Get edit form name. |
6a488035 | 479 | * |
a6c01b45 CW |
480 | * @return string |
481 | * name of this page | |
6a488035 | 482 | */ |
00be9182 | 483 | public function editName() { |
6a488035 TO |
484 | return ''; |
485 | } | |
486 | ||
487 | /** | |
fe482240 | 488 | * Get user context. |
6a488035 | 489 | * |
77b97be7 EM |
490 | * @param null $mode |
491 | * | |
a6c01b45 CW |
492 | * @return string |
493 | * user context | |
6a488035 | 494 | */ |
00be9182 | 495 | public function userContext($mode = NULL) { |
6a488035 TO |
496 | return ''; |
497 | } | |
96025800 | 498 | |
6a488035 | 499 | } |