public $_groupID;
public $_multiRecordDisplay;
+
+ public $_copyValueId;
/**
* pre processing work done here.
*
if ($this->_multiRecordDisplay) {
$this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this);
$this->_tableID = $this->_entityId;
+ $this->_copyValueId = CRM_Utils_Request::retrieve('copyValueId', 'Positive', $this);
}
return;
}
);
if ($isMultiple) {
$this->assign('multiRecordDisplay', $this->_multiRecordDisplay);
+ $saveButtonName = $this->_copyValueId ? 'Save a Copy': 'Save';
$this->addButtons(array(
array(
'type' => 'upload',
- 'name' => ts('Save'),
+ 'name' => ts('%1', array(1 => $saveButtonName)),
'isDefault' => TRUE,
),
array(
*/
function setDefaultValues() {
if ($this->_cdType || $this->_multiRecordDisplay == 'single') {
- $customDefaultValue = CRM_Custom_Form_CustomData::setDefaultValues($this);
+ if ($this->_copyValueId) {
+ // cached tree is fetched
+ $groupTree = &CRM_Core_BAO_CustomGroup::getTree($this->_type,
+ $this,
+ $this->_entityId,
+ $this->_groupID
+ );
+ $valueIdDefaults = array();
+ $groupTreeValueId = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, $this->_copyValueId, $this);
+ CRM_Core_BAO_CustomGroup::setDefaults($groupTreeValueId, $valueIdDefaults, FALSE, FALSE, $this->get('action'));
+ $tableId = $groupTreeValueId[$this->_groupID]['table_id'];
+ foreach ($valueIdDefaults as $valueIdElementName => $value) {
+ // build defaults for COPY action for new record saving
+ $valueIdElementNamePieces = explode('_', $valueIdElementName);
+ $valueIdElementNamePieces[2] = "-{$this->_groupCount}";
+ $elementName = implode('_', $valueIdElementNamePieces);
+ $customDefaultValue[$elementName] = $value;
+ }
+ }
+ else {
+ $customDefaultValue = CRM_Custom_Form_CustomData::setDefaultValues($this);
+ }
return $customDefaultValue;
}
$update = array_search(CRM_Core_Action::UPDATE, CRM_Core_Action::$_names);
$delete = array_search(CRM_Core_Action::DELETE, CRM_Core_Action::$_names);
+ // names and titles
$links[CRM_Core_Action::VIEW] = array(
'name' => ts('View'),
'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'),
'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'),
'title' => ts('Delete %1', array( 1 => $this->_customGroupTitle . ' record')),
);
+ // urls and queryStrings
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%%";
+
+ $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%%";
+
$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%%";
+
+ }
+ 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';
+
+ // 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';
+ // NOTE : links for DELETE action for customDataView is handled in browse
+
+ // copy action
+ $links[CRM_Core_Action::COPY] = array(
+ 'name' => ts('Copy'),
+ 'title' => ts('Copy %1', array( 1 => $this->_customGroupTitle . ' record')),
+ 'url' => 'civicrm/contact/view/cd/edit',
+ 'qs' => 'reset=1&snippet=1&type=%%type%%&groupID=%%groupID%%&entityID=%%entityID%%&cgcount=%%newCgCount%%&multiRecordDisplay=single©ValueId=%%cgcount%%'
+ );
}
- // NOTE : links for DELETE action for customDataView is handled in browse
self::$_links[$this->_pageViewType] = $links;
}
}
}
$linkAction = array_sum(array_keys($this->links()));
+
+ if ($reached) {
+ unset($links[CRM_Core_Action::COPY]);
+ }
+ $newCgCount = (!$reached) ? count($result) + 1 : NULL;
foreach ($result as $recId => &$value) {
foreach ($value as $fieldId => &$val) {
if (is_numeric($fieldId)) {
$actionParams['recId'] = $recId;
$actionParams['type'] = $this->_contactType;
$actionParams['cgcount'] = $cgcount;
+ $actionParams['newCgCount'] = $newCgCount;
// DELETE action links
$links[CRM_Core_Action::DELETE]['url'] = '#';
{if !$reachedMax}
{if $pageViewType eq 'customDataView'}
- <a accesskey="N" title="{ts 1=$customGroupTitle}Add %1 Record{/ts}" href="{crmURL p='civicrm/contact/view/cd/edit' q="reset=1&snippet=1&type=$ctype&groupID=$customGroupId&entityID=$contactId&cgcount=$cgcount&multiRecordDisplay=single"}"
+ <br/><a accesskey="N" title="{ts 1=$customGroupTitle}Add %1 Record{/ts}" 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`"}"
}
});
cj('.action-link').hide();
- if (pageViewType != 'customDataView') {
- cj('#profile-dialog #crm-profile-block .edit-value label').css('display', 'inline');
+ if (pageViewType == 'customDataView') {
+ var labelElement = cj('#custom-record-dialog .html-adjust label').css('display', 'inline');
+ }
+ else {
+ var labelElement = cj('#profile-dialog #crm-profile-block .edit-value label').css('display', 'inline');
}
}
});