*/
public $_groupID;
+ public $_multiRecordDisplay;
/**
* pre processing work done here.
*
*/
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);
* @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);
}
* @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;
}
// reset the group contact cache for this group
CRM_Contact_BAO_GroupContactCache::remove();
}
-}
-
+}
\ No newline at end of file
$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);
}
/**
$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 {
}
return parent::run();
}
-}
-
+}
\ No newline at end of file
$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);
'date_format',
'time_format',
'option_group_id',
+ 'in_selector'
),
'civicrm_custom_group' =>
array(
* @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 = '';
'column_name',
'is_view',
'option_group_id',
+ 'in_selector',
),
'civicrm_custom_group' =>
array(
'extends',
'extends_entity_column_value',
'table_name',
+ 'is_multiple',
),
);
$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) {
// 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
* @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;
$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);
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;
}
if ($this->_action & CRM_Core_Action::UPDATE) {
$params['id'] = $this->_id;
}
-
$customField = CRM_Core_BAO_CustomField::create($params);
$this->_id = $customField->id;
protected $_contactId = NULL;
protected $_customGroupTitle = NULL;
+
+ protected $_pageViewType = NULL;
+
+ protected $_contactType = NULL;
/**
* Get BAO Name
*
* @return array (reference) of action links
*/
function &links() {
- if (!(self::$_links)) {
+ if (!(self::$_links[$this->_pageViewType])) {
// helper variable for nicer formatting
$links = array();
$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];
}
/**
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();
* @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,
$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);
$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);
{* this template is used for building tabbed custom data *}
{if $cdType }
{include file="CRM/Custom/Form/CustomData.tpl"}
+{if $multiRecordDisplay eq 'single'}
+ <div class="html-adjust">{$form.buttons.html}</div>
+{/if}
{else}
+{debug}
<div id="customData"></div>
<div class="html-adjust">{$form.buttons.html}</div>
{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 *}
<div class="form-item">
on_load_init_blocks(showBlocks, hideBlocks);
</script>
{/if}
+{/if}
\ No newline at end of file
{/if}
{else}
{foreach from=$groupTree item=cd_edit key=group_id name=custom_sets}
- <div id="{$cd_edit.name}" class="crm-accordion-wrapper {if $cd_edit.collapse_display and !$skipTitle}collapsed{/if}">
+ {if $cd_edit.is_multiple and $multiRecordDisplay eq 'single'}
+ <div id="{$cd_edit.name}">
+ {if $cd_edit.help_pre}
+ <div class="messages help">{$cd_edit.help_pre}</div>
+ {/if}
+ <table>
+ {foreach from=$cd_edit.fields item=element key=field_id}
+ {include file="CRM/Custom/Form/CustomField.tpl"}
+ {/foreach}
+ </table>
+ <div class="spacer"></div>
+ {if $cd_edit.help_post}
+ <div class="messages help">{$cd_edit.help_post}</div>
+ {/if}
+ </div>
+ {else}
+ <div id="{$cd_edit.name}" class="crm-accordion-wrapper {if $cd_edit.collapse_display and !$skipTitle}collapsed{/if}">
{if !$skipTitle}
<div class="crm-accordion-header">
{$cd_edit.title}
<div class="messages help">{$cd_edit.help_post}</div>
{/if}
</div>
- </div>
- {if $cd_edit.is_multiple and ( ( $cd_edit.max_multiple eq '' ) or ( $cd_edit.max_multiple > 0 and $cd_edit.max_multiple >= $cgCount ) ) }
+ </div>
+ {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 *}
<div class="messages help">
<em>{ts 1=$cd_edit.title}Click "Edit Contact" to add more %1 records{/ts}</em>
</div>
{else}
- <div id="add-more-link-{$cgCount}"><a href="#" onclick="CRM.buildCustomData('{$cd_edit.extends}',{if $cd_edit.subtype}'{$cd_edit.subtype}'{else}'{$cd_edit.extends_entity_column_id}'{/if}, '', {$cgCount}, {$group_id}, true ); return false;">{ts 1=$cd_edit.title}Add another %1 record{/ts}</a></div>
+ <div id="add-more-link-{$cgCount}"><a href="#" onclick="CRM.buildCustomData('{$cd_edit.extends}',{if $cd_edit.subtype}'{$cd_edit.subtype}'{else}'{$cd_edit.extends_entity_column_id}'{/if}, '', {$cgCount}, {$group_id}, true ); return false;">{ts 1=$cd_edit.title}Add another %1 record{/ts}</a></div>
{/if}
{/if}
+ {/if}
<div id="custom_group_{$group_id}_{$cgCount}"></div>
{/foreach}
<script type="text/javascript">
{foreach from=$customValues item=cd_edit key=cvID}
<table class="no-border">
{assign var='index' value=$groupId|cat:"_$cvID"}
- {if ($editOwnCustomData and $showEdit) or ($showEdit and $editCustomData and $groupId)}
+ {if $multiRecordDisplay neq 'single' and (($editOwnCustomData and $showEdit) or ($showEdit and $editCustomData and $groupId))}
<tr>
<td>
<a
</tr>
{/if}
{assign var="showEdit" value=0}
- <tr id="statusmessg_{$index}" class="hiddenElement">
- <td><span class="success-status"></span></td>
- </tr>
+ {if $multiRecordDisplay neq 'single'}
+ <tr id="statusmessg_{$index}" class="hiddenElement">
+ <td><span class="success-status"></span></td>
+ </tr>
+ {/if}
<tr>
<td id="{$cd_edit.name}_{$index}" class="section-shown form-item">
- <div class="crm-accordion-wrapper {if $cd_edit.collapse_display eq 0 or $skipTitle} {else}collapsed{/if}">
+ <div {if $multiRecordDisplay neq 'single'} class="crm-accordion-wrapper {if $cd_edit.collapse_display eq 0 or $skipTitle} {else}collapsed{/if}"{/if}>
{if !$skipTitle}
<div class="crm-accordion-header">
{$cd_edit.title}
</div>
{/if}
- <div class="crm-accordion-body">
- {if $groupId and $cvID and $editCustomData}
+ <div {if $multiRecordDisplay neq 'single'} class="crm-accordion-body" {/if}>
+ {if $groupId and $cvID and $editCustomData and $multiRecordDisplay neq 'single'}
<div class="crm-submit-buttons">
<a href="#"
onclick="showDelete( {$cvID}, '{$cd_edit.name}_{$index}', {$customGroupId}, {$contactId} ); return false;"
</div>
{/if}
{foreach from=$cd_edit.fields item=element key=field_id}
- <table class="crm-info-panel">
+ <table class="crm-info-panel crm-section">
<tr>
{if $element.options_per_line != 0}
<td class="label">{$element.field_title}</td>
- <td class="html-adjust">
+ <td class="html-adjust content">
{* sort by fails for option per line. Added a variable to iterate through the element array*}
{foreach from=$element.field_value item=val}
{$val}
<td class="label">{$element.field_title}</td>
{if $element.field_type == 'File'}
{if $element.field_value.displayURL}
- <td class="html-adjust">
+ <td class="html-adjust content">
<a href="{$element.field_value.displayURL}" class='crm-image-popup'>
<img src="{$element.field_value.displayURL}" height="100" width="100">
</a>
</td>
{else}
- <td class="html-adjust">
+ <td class="html-adjust content">
<a href="{$element.field_value.fileURL}">{$element.field_value.fileName}</a>
</td>
{/if}
{else}
{if $element.field_data_type == 'Money'}
{if $element.field_type == 'Text'}
- <td class="html-adjust">{$element.field_value|crmMoney}</td>
+ <td class="html-adjust content">{$element.field_value|crmMoney}</td>
{else}
- <td class="html-adjust">{$element.field_value}</td>
+ <td class="html-adjust content">{$element.field_value}</td>
{/if}
{else}
- <td class="html-adjust">
+ <td class="html-adjust content">
{if $element.contact_ref_id}
<a href='{crmURL p="civicrm/contact/view" q="reset=1&cid=`$element.contact_ref_id`"}'>
{/if}
+--------------------------------------------------------------------+
*}
{if $showListing}
- <h1>{ts}{$customGroupTitle}{/ts}</h1>
+ {if $dontShowTitle neq 1}<h1>{ts}{$customGroupTitle}{/ts}</h1>{/if}
+ {if $pageViewType eq 'customDataView'}
+ {assign var='dialogId' value='custom-record-dialog'}
+ {else}
+ {assign var='dialogId' value='profile-dialog'}
+ {/if}
{if $records and $headers}
{include file="CRM/common/jsortable.tpl"}
<div id="browseValues">
{/strip}
</div>
</div>
- <div id='profile-dialog' class="hiddenElement"></div>
+ <div id='{$dialogId}' class="hiddenElement"></div>
{elseif !$records}
<div class="messages status no-popup">
<div class="icon inform-icon"></div>
{ts 1=$customGroupTitle}No records of type '%1' found.{/ts}
</div>
- <div id='profile-dialog' class="hiddenElement"></div>
+ <div id='{$dialogId}' class="hiddenElement"></div>
{/if}
{if !$reachedMax}
- <a accesskey="N" href="{crmURL p='civicrm/profile/edit' q="reset=1&id=`$contactId`&multiRecord=add&gid=`$gid`&snippet=1&context=multiProfileDialog&onPopupClose=`$onPopupClose`"}"
+ {if $pageViewType eq 'customDataView'}
+ <a accesskey="N" href="{crmURL p='civicrm/contact/view/cd/edit' q="reset=1&snippet=1&type=$ctype&groupID=$customGroupId&entityID=$contactId&cgcount=$cgcount&multiRecordDisplay=single"}"
+ class="button action-item"><span><div class="icon add-icon"></div>{ts 1=$customGroupTitle}Add %1 Record{/ts}</span></a>
+ {else}
+ <a accesskey="N" href="{crmURL p='civicrm/profile/edit' q="reset=1&id=`$contactId`&multiRecord=add&gid=`$gid`&snippet=1&context=multiProfileDialog&onPopupClose=`$onPopupClose`"}"
class="button action-item"><span><div class="icon add-icon"></div>{ts}Add New Record{/ts}</span></a>
+ {/if}
{/if}
{/if}
{literal}
<script type='text/javascript'>
cj(function () {
+ var dialogId = '{/literal}{$dialogId}{literal}';
+ var pageViewType = '{/literal}{$pageViewType}{literal}';
// NOTE: Triggers two events, "profile-dialog:FOO:open" and "profile-dialog:FOO:close",
// where "FOO" is the internal name of a profile form
function formDialog(dialogName, dataURL, dialogTitle) {
cj.ajax({
url: dataURL,
success: function (content) {
- cj('#profile-dialog').show().html(content).dialog({
+ cj('#' + dialogId).show().html(content).dialog({
title: dialogTitle,
modal: true,
width: 680,
background: "black"
},
open: function(event, ui) {
- cj('#profile-dialog').trigger({
+ cj('#' + dialogId).trigger({
type: "crmFormLoad",
profileName: dialogName
});
},
close: function (event, ui) {
- cj('#profile-dialog').trigger({
+ cj('#' + dialogId).trigger({
type: "crmFormClose",
profileName: dialogName
});
- cj('#profile-dialog').html('');
+ cj('#' + dialogId).html('');
}
});
cj('.action-link').hide();
- cj('#profile-dialog #crm-profile-block .edit-value label').css('display', 'inline');
+ if (pageViewType != 'customDataView') {
+ cj('#profile-dialog #crm-profile-block .edit-value label').css('display', 'inline');
+ }
}
});
}
}
});
- cj(".crm-profile-name-" + profileName + " .action-item").click(function () {
+ if (pageViewType == 'customDataView') {
+ var actionItemHeirarchy = '.action-item';
+ profileName = 'customRecordView';
+ }
+ else {
+ var actionItemHeirarchy = '.crm-profile-name-' + profileName + ' .action-item';
+ }
+
+ cj(actionItemHeirarchy).click(function () {
dataURL = cj(this).attr('jshref');
dialogTitle = cj(this).attr('title');
formDialog(profileName, dataURL, dialogTitle);