From e41f46600121c125cb19538abeca478c6944e0be Mon Sep 17 00:00:00 2001 From: Pratik Joshi Date: Sat, 22 Feb 2014 21:06:46 +0530 Subject: [PATCH] CRM-13992 : handling multi-custom data listing, edit, add, view actions. reused profile code for listing and extended custom data engine for multi-value custom handling --- CRM/Contact/Form/CustomData.php | 49 ++++- CRM/Contact/Page/View/CustomData.php | 41 +++- CRM/Core/BAO/CustomField.php | 1 + CRM/Core/BAO/CustomGroup.php | 19 +- CRM/Custom/Form/Field.php | 4 +- .../Page/MultipleRecordFieldsListing.php | 202 ++++++++++++------ templates/CRM/Contact/Form/CustomData.tpl | 4 + .../CRM/Contact/Page/View/CustomData.tpl | 5 +- templates/CRM/Custom/Form/CustomData.tpl | 25 ++- templates/CRM/Custom/Page/CustomDataView.tpl | 30 +-- .../Page/MultipleRecordFieldsListing.tpl | 42 +++- 11 files changed, 304 insertions(+), 118 deletions(-) diff --git a/CRM/Contact/Form/CustomData.php b/CRM/Contact/Form/CustomData.php index f7931ef13e..d8e9b071ec 100644 --- a/CRM/Contact/Form/CustomData.php +++ b/CRM/Contact/Form/CustomData.php @@ -101,6 +101,7 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form { */ public $_groupID; + public $_multiRecordDisplay; /** * pre processing work done here. * @@ -115,13 +116,22 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form { */ function preProcess() { $this->_cdType = CRM_Utils_Array::value('type', $_GET); - $this->assign('cdType', FALSE); - if ($this->_cdType) { - $this->assign('cdType', TRUE); - return CRM_Custom_Form_CustomData::preProcess($this); + $this->_multiRecordDisplay = CRM_Utils_Request::retrieve('multiRecordDisplay', 'String', $this); + if ($this->_cdType || $this->_multiRecordDisplay == 'single') { + if ($this->_cdType) { + $this->assign('cdType', TRUE); + } + // NOTE : group id is not stored in session from within CRM_Custom_Form_CustomData::preProcess func + // this is due to some condition inside it which restricts it from saving in session + // so doing this for multi record edit action + CRM_Custom_Form_CustomData::preProcess($this); + if ($this->_multiRecordDisplay) { + $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this); + $this->_tableID = $this->_entityId; + } + return; } - $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this, TRUE); $this->_tableID = CRM_Utils_Request::retrieve('tableId', 'Positive', $this, TRUE); @@ -149,7 +159,29 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form { * @access public */ public function buildQuickForm() { - if ($this->_cdType) { + if ($this->_cdType || $this->_multiRecordDisplay == 'single') { + // buttons display for multi-valued fields to perform independednt actions + if ($this->_multiRecordDisplay) { + $isMultiple = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', + $this->_groupID, + 'is_multiple' + ); + if ($isMultiple) { + $this->assign('multiRecordDisplay', $this->_multiRecordDisplay); + $this->addButtons(array( + array( + 'type' => 'upload', + 'name' => ts('Save'), + 'isDefault' => TRUE, + ), + array( + 'type' => 'cancel', + 'name' => ts('Cancel'), + ), + ) + ); + } + } return CRM_Custom_Form_CustomData::buildQuickForm($this); } @@ -181,7 +213,7 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form { * @return array the default array reference */ function setDefaultValues() { - if ($this->_cdType) { + if ($this->_cdType || $this->_multiRecordDisplay == 'single') { $customDefaultValue = CRM_Custom_Form_CustomData::setDefaultValues($this); return $customDefaultValue; } @@ -230,5 +262,4 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form { // reset the group contact cache for this group CRM_Contact_BAO_GroupContactCache::remove(); } -} - +} \ No newline at end of file diff --git a/CRM/Contact/Page/View/CustomData.php b/CRM/Contact/Page/View/CustomData.php index 4c77c3f452..6b0bdc7a58 100644 --- a/CRM/Contact/Page/View/CustomData.php +++ b/CRM/Contact/Page/View/CustomData.php @@ -75,6 +75,10 @@ class CRM_Contact_Page_View_CustomData extends CRM_Core_Page { $this->_groupId = CRM_Utils_Request::retrieve('gid', 'Positive', $this, TRUE); $this->assign('groupId', $this->_groupId); + + $this->_multiRecordDisplay = CRM_Utils_Request::retrieve('multiRecordDisplay', 'String', $this, FALSE); + $this->_cgcount = CRM_Utils_Request::retrieve('cgcount', 'Positive', $this, FALSE); + $this->_recId = CRM_Utils_Request::retrieve('recId', 'Positive', $this, FALSE); } /** @@ -119,7 +123,39 @@ class CRM_Contact_Page_View_CustomData extends CRM_Core_Page { $groupTree = &CRM_Core_BAO_CustomGroup::getTree($entityType, $this, $this->_contactId, $this->_groupId, $entitySubType ); - CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree); + + $displayStyle = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', + $this->_groupId, + 'style' + ); + + if ($displayStyle === 'Tab with table' && $this->_multiRecordDisplay != 'single') { + $ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', + $this->_contactId, + 'contact_type' + ); + + $this->assign('displayStyle', 'tableOriented'); + // here the multi custom data listing code will go + $multiRecordFieldListing = TRUE; + $page = new CRM_Profile_Page_MultipleRecordFieldsListing(); + $page->set('contactId', $this->_contactId); + $page->set('customGroupId', $this->_groupId); + $page->set('action', CRM_Core_Action::BROWSE); + $page->set('multiRecordFieldListing', $multiRecordFieldListing); + $page->set('pageViewType', 'customDataView'); + $page->set('contactType', $ctype); + $page->run(); + } + else { + $recId = NULL; + if ($this->_multiRecordDisplay == 'single') { + $recId = $this->_recId; + $this->assign('multiRecordDisplay', $this->_multiRecordDisplay); + $this->assign('skipTitle', 1); + } + CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, $recId); + } } else { @@ -138,5 +174,4 @@ class CRM_Contact_Page_View_CustomData extends CRM_Core_Page { } return parent::run(); } -} - +} \ No newline at end of file diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index 5fac6b6f60..49334b14f2 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -273,6 +273,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { $customField->copyValues($params); $customField->is_required = CRM_Utils_Array::value('is_required', $params, FALSE); $customField->is_searchable = CRM_Utils_Array::value('is_searchable', $params, FALSE); + $customField->in_selector = CRM_Utils_Array::value('in_selector', $params, FALSE); $customField->is_search_range = CRM_Utils_Array::value('is_search_range', $params, FALSE); $customField->is_active = CRM_Utils_Array::value('is_active', $params, FALSE); $customField->is_view = CRM_Utils_Array::value('is_view', $params, FALSE); diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index 90654c569f..ccb7324c7d 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -355,6 +355,7 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { 'date_format', 'time_format', 'option_group_id', + 'in_selector' ), 'civicrm_custom_group' => array( @@ -836,7 +837,7 @@ ORDER BY civicrm_custom_group.weight, * @static * */ - public static function &getGroupDetail($groupId = NULL, $searchable = NULL, &$extends = NULL) { + public static function &getGroupDetail($groupId = NULL, $searchable = NULL, &$extends = NULL, $inSelector = NULL) { // create a new tree $groupTree = array(); $select = $from = $where = $orderBy = ''; @@ -868,6 +869,7 @@ ORDER BY civicrm_custom_group.weight, 'column_name', 'is_view', 'option_group_id', + 'in_selector', ), 'civicrm_custom_group' => array( @@ -881,6 +883,7 @@ ORDER BY civicrm_custom_group.weight, 'extends', 'extends_entity_column_value', 'table_name', + 'is_multiple', ), ); @@ -908,6 +911,10 @@ ORDER BY civicrm_custom_group.weight, $where .= " AND civicrm_custom_field.is_searchable = 1"; } + if ($inSelector) { + $where .= " AND civicrm_custom_field.in_selector = 1 AND civicrm_custom_group.is_multiple = 1 "; + } + if ($extends) { $clause = array(); foreach ($extends as $e) { @@ -979,8 +986,8 @@ ORDER BY civicrm_custom_group.weight, // for Group's $customGroupDAO = new CRM_Core_DAO_CustomGroup(); - // get only 'Tab' groups - $customGroupDAO->whereAdd("style = 'Tab'"); + // get 'Tab' and 'Tab with table' groups + $customGroupDAO->whereAdd("style IN ('Tab', 'Tab with table')"); $customGroupDAO->whereAdd("is_active = 1"); // add whereAdd for entity type @@ -1770,9 +1777,8 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, * @param array $groupTree associated array * @param boolean $returnCount true if customValue count needs to be returned */ - static function buildCustomDataView(&$form, &$groupTree, $returnCount = FALSE, $gID = NULL, $prefix = NULL) { + static function buildCustomDataView(&$form, &$groupTree, $returnCount = FALSE, $gID = NULL, $prefix = NULL, $customValueId = NULL) { $details = array(); - foreach ($groupTree as $key => $group) { if ($key === 'info') { continue; @@ -1782,6 +1788,9 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, $groupID = $group['id']; if (!empty($properties['customValue'])) { foreach ($properties['customValue'] as $values) { + if (!empty($customValueId) && $customValueId != $values['id']) { + continue; + } $details[$groupID][$values['id']]['title'] = CRM_Utils_Array::value('title', $group); $details[$groupID][$values['id']]['name'] = CRM_Utils_Array::value('name', $group); $details[$groupID][$values['id']]['help_pre'] = CRM_Utils_Array::value('help_pre', $group); diff --git a/CRM/Custom/Form/Field.php b/CRM/Custom/Form/Field.php index 05988af601..f919fded24 100644 --- a/CRM/Custom/Form/Field.php +++ b/CRM/Custom/Form/Field.php @@ -261,7 +261,8 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { if (isset($dontShowLink)) { $this->assign('dontShowLink', $dontShowLink); } - if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_multiple', 'id')) { + if ($this->_action & CRM_Core_Action::ADD && + CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_multiple', 'id')) { $defaults['in_selector'] = 1; } @@ -990,7 +991,6 @@ SELECT id if ($this->_action & CRM_Core_Action::UPDATE) { $params['id'] = $this->_id; } - $customField = CRM_Core_BAO_CustomField::create($params); $this->_id = $customField->id; diff --git a/CRM/Profile/Page/MultipleRecordFieldsListing.php b/CRM/Profile/Page/MultipleRecordFieldsListing.php index fddc3c69d8..03b8b927c9 100644 --- a/CRM/Profile/Page/MultipleRecordFieldsListing.php +++ b/CRM/Profile/Page/MultipleRecordFieldsListing.php @@ -49,6 +49,10 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { protected $_contactId = NULL; protected $_customGroupTitle = NULL; + + protected $_pageViewType = NULL; + + protected $_contactType = NULL; /** * Get BAO Name * @@ -64,7 +68,7 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { * @return array (reference) of action links */ function &links() { - if (!(self::$_links)) { + if (!(self::$_links[$this->_pageViewType])) { // helper variable for nicer formatting $links = array(); @@ -74,28 +78,47 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { $links[CRM_Core_Action::VIEW] = array( 'name' => ts('View'), - 'url' => 'civicrm/profile/view', - 'qs' => "reset=1&id=%%id%%&recordId=%%recordId%%&gid=%%gid%%&multiRecord={$view}&snippet=1&context=multiProfileDialog&onPopupClose=%%onPopupClose%%", 'title' => ts('View %1', array( 1 => $this->_customGroupTitle . ' record')), ); + if ($this->_pageViewType == 'profileDataView') { + $links[CRM_Core_Action::VIEW]['url'] = 'civicrm/profile/view'; + $links[CRM_Core_Action::VIEW]['qs'] = "reset=1&id=%%id%%&recordId=%%recordId%%&gid=%%gid%%&multiRecord={$view}&snippet=1&context=multiProfileDialog&onPopupClose=%%onPopupClose%%"; + } + elseif ($this->_pageViewType == 'customDataView') { + // custom data specific view links + $links[CRM_Core_Action::VIEW]['url'] = 'civicrm/contact/view/cd'; + $links[CRM_Core_Action::VIEW]['qs'] = 'reset=1&snippet=1&gid=%%gid%%&cid=%%cid%%&recId=%%recId%%&multiRecordDisplay=single'; + } + $links[CRM_Core_Action::UPDATE] = array( 'name' => ts('Edit'), - 'url' => 'civicrm/profile/edit', - 'qs' => "reset=1&id=%%id%%&recordId=%%recordId%%&gid=%%gid%%&multiRecord={$update}&snippet=1&context=multiProfileDialog&onPopupClose=%%onPopupClose%%", 'title' => ts('Edit %1', array( 1 => $this->_customGroupTitle . ' record')), ); + if ($this->_pageViewType == 'profileDataView') { + $links[CRM_Core_Action::UPDATE]['url'] = 'civicrm/profile/edit'; + $links[CRM_Core_Action::UPDATE]['qs'] = "reset=1&id=%%id%%&recordId=%%recordId%%&gid=%%gid%%&multiRecord={$update}&snippet=1&context=multiProfileDialog&onPopupClose=%%onPopupClose%%"; + } + elseif ($this->_pageViewType == 'customDataView') { + // custom data specific update links + $links[CRM_Core_Action::UPDATE]['url'] = 'civicrm/contact/view/cd/edit'; + $links[CRM_Core_Action::UPDATE]['qs'] = 'reset=1&snippet=1&type=%%type%%&groupID=%%groupID%%&entityID=%%entityID%%&cgcount=%%cgcount%%&multiRecordDisplay=single'; + } + $links[CRM_Core_Action::DELETE] = array( 'name' => ts('Delete'), - 'url' => 'civicrm/profile/edit', - 'qs' => "reset=1&id=%%id%%&recordId=%%recordId%%&gid=%%gid%%&multiRecord={$delete}&snippet=1&context=multiProfileDialog&onPopupClose=%%onPopupClose%%", 'title' => ts('Delete %1', array( 1 => $this->_customGroupTitle . ' record')), ); - self::$_links = $links; + if ($this->_pageViewType == 'profileDataView') { + $links[CRM_Core_Action::DELETE]['url'] = 'civicrm/profile/edit'; + $links[CRM_Core_Action::DELETE]['qs'] = "reset=1&id=%%id%%&recordId=%%recordId%%&gid=%%gid%%&multiRecord={$delete}&snippet=1&context=multiProfileDialog&onPopupClose=%%onPopupClose%%"; + } + + self::$_links[$this->_pageViewType] = $links; } - return self::$_links; + return self::$_links[$this->_pageViewType]; } /** @@ -120,13 +143,11 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { if (!is_array($profileId) && is_numeric($profileId)) { $this->_profileId = $profileId; } - //record id - $recid = CRM_Utils_Request::retrieve('recid', 'Positive', $this, FALSE, 0); - //custom group id - $groupId = CRM_Utils_Request::retrieve('groupId', 'Positive', $this, FALSE, 0); $this->_contactId = CRM_Utils_Request::retrieve('contactId', 'Positive', $this, FALSE); - + $this->_pageViewType = CRM_Utils_Request::retrieve('pageViewType', 'Positive', $this, FALSE, 'profileDataView'); + $this->_customGroupId = CRM_Utils_Request::retrieve('customGroupId', 'Positive', $this, FALSE, 0); + $this->_contactType = CRM_Utils_Request::retrieve('contactType', 'String', $this, FALSE); if ($action & CRM_Core_Action::BROWSE) { //browse $this->browse(); @@ -143,7 +164,7 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { * @access public */ function browse() { - if ($this->_profileId) { + if ($this->_pageViewType == 'profileDataView' && $this->_profileId) { $fields = CRM_Core_BAO_UFGroup::getFields($this->_profileId, FALSE, NULL, NULL, NULL, FALSE, NULL, @@ -169,12 +190,31 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { $fieldIDs = array_keys($multiRecordFieldsWithSummaryListing); } } - + elseif ($this->_pageViewType == 'customDataView') { + // require custom group id for _pageViewType of customDataView + $customGroupId = $this->_customGroupId; + $reached = CRM_Core_BAO_CustomGroup::hasReachedMaxLimit($customGroupId, $this->_contactId); + if (!$reached) { + $this->assign('contactId', $this->_contactId); + $this->assign('customGroupId', $customGroupId); + $this->assign('ctype', $this->_contactType); + } + $this->assign('reachedMax', $reached); + // custom group info : this consists of the field title of group fields + $groupDetail = CRM_Core_BAO_CustomGroup::getGroupDetail($customGroupId, NULL, CRM_Core_DAO::$_nullObject, TRUE); + // field ids of fields in_selector for the custom group id provided + $fieldIDs = array_keys($groupDetail[$customGroupId]['fields']); + // field labels for headers + $fieldLabels = $groupDetail[$customGroupId]['fields']; + + // from the above customGroupInfo we can get $this->_customGroupTitle + $this->_customGroupTitle = $groupDetail[$customGroupId]['title']; + } if ($fieldIDs && !empty($fieldIDs) && $this->_contactId) { $options = array( ); $returnProperities = array('html_type', 'data_type', 'date_format', 'time_format'); foreach ($fieldIDs as $key => $fieldID) { - $fieldIDs[$key] = CRM_Core_BAO_CustomField::getKeyID($fieldID); + $fieldIDs[$key] = !is_numeric($fieldID) ? CRM_Core_BAO_CustomField::getKeyID($fieldID) : $fieldID; $param = array('id' => $fieldIDs[$key]); $returnValues = array( ); CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $param, $returnValues, $returnProperities); @@ -194,68 +234,90 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { $options[$fieldIDs[$key]]['attributes']['time_format'] = CRM_Utils_Array::value('time_format', $returnValues); } + // commonly used for both views i.e profile listing view (profileDataView) and custom data listing view (customDataView) $result = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_contactId, NULL, $fieldIDs, TRUE); - if (!empty($fieldIDs)) { - //get the group info of multi rec fields in listing view - $fieldInput = $fieldIDs; - $fieldIdInput = $fieldIDs[0]; - } else { - //if no listing fields exist, take the group title for display - $nonListingFieldIds = array_keys($multiRecordFields); - $singleField = CRM_Core_BAO_CustomField::getKeyID($nonListingFieldIds[0]); - $fieldIdInput = $singleField; - $singleField = array($singleField); - $fieldInput = $singleField; - } - $customGroupInfo = CRM_Core_BAO_CustomGroup::getGroupTitles($fieldInput); - $this->_customGroupTitle = $customGroupInfo[$fieldIdInput]['groupTitle']; - - if ($result && !empty($result)) { - $links = self::links(); - $pageCheckSum = $this->get('pageCheckSum'); - if ($pageCheckSum) { - foreach ($links as $key => $link) { - $links[$key] = $link['qs'] . "&cs=%%cs%%"; - } - } - $linkAction = array_sum(array_keys($this->links())); - - foreach ($result as $recId => &$value) { - foreach ($value as $fieldId => &$val) { - if (is_numeric($fieldId)) { - $customValue = &$val; - $customValue = CRM_Core_BAO_CustomField::getDisplayValue($customValue, $fieldId, $options); - if (!$customValue) { - $customValue = ""; - } - $actionParams = array('recordId' => $recId, 'gid' => $this->_profileId, - 'id' => $this->_contactId, 'onPopupClose' => $this->_onPopupClose); - if ($pageCheckSum) { - $actionParams['cs'] = $pageCheckSum; - } - $value['action'] = CRM_Core_Action::formLink( - $links, - $linkAction, - $actionParams, - ts('more'), - FALSE, - 'profile.multiValue.row', - 'customValue', - $fieldId // not ideal, but the one thing not sent in $actionParams - ); - } - } - } - } + if ($this->_pageViewType == 'profileDataView') { + if (!empty($fieldIDs)) { + //get the group info of multi rec fields in listing view + $fieldInput = $fieldIDs; + $fieldIdInput = $fieldIDs[0]; + } + else { + //if no listing fields exist, take the group title for display + $nonListingFieldIds = array_keys($multiRecordFields); + $singleField = CRM_Core_BAO_CustomField::getKeyID($nonListingFieldIds[0]); + $fieldIdInput = $singleField; + $singleField = array($singleField); + $fieldInput = $singleField; + } + $customGroupInfo = CRM_Core_BAO_CustomGroup::getGroupTitles($fieldInput); + $this->_customGroupTitle = $customGroupInfo[$fieldIdInput]['groupTitle']; + } + // $cgcount is defined before 'if' condition as enitiy may have no record + // and $cgcount is used to build new record url + $cgcount = 1; + if ($result && !empty($result)) { + $links = self::links($this->_pageViewType); + if ($this->_pageViewType == 'profileDataView') { + $pageCheckSum = $this->get('pageCheckSum'); + if ($pageCheckSum) { + foreach ($links as $key => $link) { + $links[$key] = $link['qs'] . "&cs=%%cs%%"; + } + } + } + $linkAction = array_sum(array_keys($this->links())); + foreach ($result as $recId => &$value) { + foreach ($value as $fieldId => &$val) { + if (is_numeric($fieldId)) { + $customValue = &$val; + $customValue = CRM_Core_BAO_CustomField::getDisplayValue($customValue, $fieldId, $options); + if (!$customValue) { + $customValue = ""; + } + + $op = NULL; + if ($this->_pageViewType == 'profileDataView') { + $actionParams = array('recordId' => $recId, 'gid' => $this->_profileId, + 'id' => $this->_contactId, 'onPopupClose' => $this->_onPopupClose); + $op = 'profile.multiValue.row'; + } + else { + // different set of url params + $actionParams['gid'] = $actionParams['groupID'] = $this->_customGroupId; + $actionParams['cid'] = $actionParams['entityID'] = $this->_contactId; + $actionParams['recId'] = $recId; + $actionParams['type'] = $this->_contactType; + $actionParams['cgcount'] = $cgcount; + } + if (!empty($pageCheckSum)) { + $actionParams['cs'] = $pageCheckSum; + } + $value['action'] = CRM_Core_Action::formLink( + $links, + $linkAction, + $actionParams, + ts('more'), + FALSE, + $op, + 'customValue', + $fieldId // not ideal, but the one thing not sent in $actionParams + ); + } + } + $cgcount++; + } + } } $headers = array( ); if (!empty($fieldIDs)) { foreach ($fieldIDs as $fieldID) { - $headers[$fieldID] = $customGroupInfo[$fieldID]['fieldLabel']; + $headers[$fieldID] = ($this->_pageViewType == 'profileDataView') ? $customGroupInfo[$fieldID]['fieldLabel'] : $fieldLabels[$fieldID]['label']; } } + $this->assign('cgcount', $cgcount); $this->assign('customGroupTitle', $this->_customGroupTitle); $this->assign('headers', $headers); $this->assign('records', $result); diff --git a/templates/CRM/Contact/Form/CustomData.tpl b/templates/CRM/Contact/Form/CustomData.tpl index b044aedfde..b011b2bc0f 100644 --- a/templates/CRM/Contact/Form/CustomData.tpl +++ b/templates/CRM/Contact/Form/CustomData.tpl @@ -26,7 +26,11 @@ {* this template is used for building tabbed custom data *} {if $cdType } {include file="CRM/Custom/Form/CustomData.tpl"} +{if $multiRecordDisplay eq 'single'} +
{$form.buttons.html}
+{/if} {else} +{debug}
{$form.buttons.html}
diff --git a/templates/CRM/Contact/Page/View/CustomData.tpl b/templates/CRM/Contact/Page/View/CustomData.tpl index 11dc71448d..b5f53d7211 100644 --- a/templates/CRM/Contact/Page/View/CustomData.tpl +++ b/templates/CRM/Contact/Page/View/CustomData.tpl @@ -27,7 +27,9 @@ {if $action eq 0 or $action eq 1 or $action eq 2 or $recordActivity} {include file="CRM/Contact/Form/CustomData.tpl" mainEdit=$mainEditForm} {/if} - +{if $displayStyle eq 'tableOriented'} + {include file='CRM/Profile/Page/MultipleRecordFieldsListing.tpl' showListing=1 dontShowTitle=1 pageViewType='customDataView'} +{else} {strip} {if $action eq 16 or $action eq 4} {* Browse or View actions *}
@@ -52,3 +54,4 @@ on_load_init_blocks(showBlocks, hideBlocks); {/if} +{/if} \ No newline at end of file diff --git a/templates/CRM/Custom/Form/CustomData.tpl b/templates/CRM/Custom/Form/CustomData.tpl index adffd911b5..a9e3d7178e 100644 --- a/templates/CRM/Custom/Form/CustomData.tpl +++ b/templates/CRM/Custom/Form/CustomData.tpl @@ -42,7 +42,23 @@ {/if} {else} {foreach from=$groupTree item=cd_edit key=group_id name=custom_sets} -
+ {if $cd_edit.is_multiple and $multiRecordDisplay eq 'single'} +
+ {if $cd_edit.help_pre} +
{$cd_edit.help_pre}
+ {/if} + + {foreach from=$cd_edit.fields item=element key=field_id} + {include file="CRM/Custom/Form/CustomField.tpl"} + {/foreach} +
+
+ {if $cd_edit.help_post} +
{$cd_edit.help_post}
+ {/if} +
+ {else} +
{if !$skipTitle}
{$cd_edit.title} @@ -62,17 +78,18 @@
{$cd_edit.help_post}
{/if}
-
- {if $cd_edit.is_multiple and ( ( $cd_edit.max_multiple eq '' ) or ( $cd_edit.max_multiple > 0 and $cd_edit.max_multiple >= $cgCount ) ) } +
+ {if $cd_edit.is_multiple and ( ( $cd_edit.max_multiple eq '' ) or ( $cd_edit.max_multiple > 0 and $cd_edit.max_multiple >= $cgCount ) ) } {if $skipTitle} {* We don't yet support adding new records in inline-edit forms *}
{ts 1=$cd_edit.title}Click "Edit Contact" to add more %1 records{/ts}
{else} - + {/if} {/if} + {/if}
{/foreach}