From f6ad11c1845841118eac28d17022d8b03453b3e5 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Wed, 25 May 2016 15:12:25 +0530 Subject: [PATCH] CRM18586 - add delete link and fix add more button --- CRM/Core/BAO/CustomGroup.php | 4 ++++ CRM/Custom/Form/CustomDataByType.php | 4 ++++ templates/CRM/Custom/Form/CustomData.tpl | 11 +++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index 0a9b3e78bc..1149d1df5d 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -405,6 +405,7 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { 'help_pre', 'help_post', 'collapse_display', + 'style', 'is_multiple', 'extends', 'extends_entity_column_id', @@ -1837,6 +1838,7 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, $formattedGroupTree[$key]['help_post'] = CRM_Utils_Array::value('help_post', $value); $formattedGroupTree[$key]['collapse_display'] = CRM_Utils_Array::value('collapse_display', $value); $formattedGroupTree[$key]['collapse_adv_display'] = CRM_Utils_Array::value('collapse_adv_display', $value); + $formattedGroupTree[$key]['style'] = CRM_Utils_Array::value('style', $value); // this params needed of bulding multiple values $formattedGroupTree[$key]['is_multiple'] = CRM_Utils_Array::value('is_multiple', $value); @@ -1917,6 +1919,7 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, $details[$groupID][$values['id']]['help_post'] = CRM_Utils_Array::value('help_post', $group); $details[$groupID][$values['id']]['collapse_display'] = CRM_Utils_Array::value('collapse_display', $group); $details[$groupID][$values['id']]['collapse_adv_display'] = CRM_Utils_Array::value('collapse_adv_display', $group); + $details[$groupID][$values['id']]['style'] = CRM_Utils_Array::value('style', $group); $details[$groupID][$values['id']]['fields'][$k] = array( 'field_title' => CRM_Utils_Array::value('label', $properties), 'field_type' => CRM_Utils_Array::value('html_type', $properties), @@ -1942,6 +1945,7 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, $details[$groupID][0]['help_post'] = CRM_Utils_Array::value('help_post', $group); $details[$groupID][0]['collapse_display'] = CRM_Utils_Array::value('collapse_display', $group); $details[$groupID][0]['collapse_adv_display'] = CRM_Utils_Array::value('collapse_adv_display', $group); + $details[$groupID][0]['style'] = CRM_Utils_Array::value('style', $group); $details[$groupID][0]['fields'][$k] = array('field_title' => CRM_Utils_Array::value('label', $properties)); } } diff --git a/CRM/Custom/Form/CustomDataByType.php b/CRM/Custom/Form/CustomDataByType.php index ac2aa737cc..70d0b97b0b 100644 --- a/CRM/Custom/Form/CustomDataByType.php +++ b/CRM/Custom/Form/CustomDataByType.php @@ -50,6 +50,10 @@ class CRM_Custom_Form_CustomDataByType extends CRM_Core_Form { $this->assign('cdType', FALSE); $this->assign('cgCount', $this->_groupCount); + $contactTypes = CRM_Contact_BAO_ContactType::contactTypeInfo(); + if (array_key_exists($this->_type, $contactTypes)) { + $this->assign('contactId', $this->_entityId); + } if (!is_array($this->_subType) && strstr($this->_subType, CRM_Core_DAO::VALUE_SEPARATOR)) { $this->_subType = str_replace(CRM_Core_DAO::VALUE_SEPARATOR, ',', trim($this->_subType, CRM_Core_DAO::VALUE_SEPARATOR)); } diff --git a/templates/CRM/Custom/Form/CustomData.tpl b/templates/CRM/Custom/Form/CustomData.tpl index 047e5ddc27..50d1c4bcf6 100644 --- a/templates/CRM/Custom/Form/CustomData.tpl +++ b/templates/CRM/Custom/Form/CustomData.tpl @@ -63,13 +63,20 @@ {/if} {else} -
+
{if !$skipTitle}
{$cd_edit.title}
{/if}
+ {if $cd_edit.is_multiple eq 1 and $cd_edit.table_id and $contactId and !$skipTitle and $cd_edit.style eq 'Inline'} + {assign var=tableID value=$cd_edit.table_id} + + {ts}Delete{/ts} + + {/if} {if $cd_edit.help_pre}
{$cd_edit.help_pre}
{/if} @@ -91,7 +98,7 @@ {ts 1=$cd_edit.title}Click "Edit Contact" to add more %1 records{/ts}
{else} -