Skip to content

Commit

Permalink
CRM-8140: Not possible to select fields for export when using Custom …
Browse files Browse the repository at this point in the history
…Searches
  • Loading branch information
monishdeb committed Dec 26, 2017
1 parent e3e59cc commit ce40afa
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
54 changes: 31 additions & 23 deletions CRM/Export/Form/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class CRM_Export_Form_Select extends CRM_Core_Form {

public $_componentTable;

public $_customSearchID;

/**
* Build all the data structures needed to build the form.
*
Expand All @@ -81,13 +83,7 @@ public function preProcess() {
$this->preventAjaxSubmit();

//special case for custom search, directly give option to download csv file
$customSearchID = $this->get('customSearchID');
if ($customSearchID) {
CRM_Export_BAO_Export::exportCustom($this->get('customSearchClass'),
$this->get('formValues'),
$this->get(CRM_Utils_Sort::SORT_ORDER)
);
}
$this->_customSearchID = $this->get('customSearchID');

$this->_selectAll = FALSE;
$this->_exportMode = self::CONTACT_EXPORT;
Expand All @@ -99,7 +95,11 @@ public function preProcess() {
$isStandalone = $formName == 'CRM_Export_StateMachine_Standalone';

// get the submitted values based on search
if ($this->_action == CRM_Core_Action::ADVANCED) {
if ($this->_customSearchID) {
$values = $this->get('formValues');
$this->assign('exportCustomSearchField', TRUE);
}
elseif ($this->_action == CRM_Core_Action::ADVANCED) {
$values = $this->controller->exportValues('Advanced');
}
elseif ($this->_action == CRM_Core_Action::PROFILE) {
Expand Down Expand Up @@ -231,7 +231,7 @@ public function buildQuickForm() {
$exportOptions = $mergeOptions = $postalMailing = array();
$exportOptions[] = $this->createElement('radio',
NULL, NULL,
ts('Export PRIMARY fields'),
ts('Export %1 fields', array(1 => empty($this->_customSearchID) ? 'PRIMARY' : 'custom search')),
self::EXPORT_ALL,
array('onClick' => 'showMappingOption( );')
);
Expand Down Expand Up @@ -396,20 +396,28 @@ public function postProcess() {
}

if ($exportOption == self::EXPORT_ALL) {
CRM_Export_BAO_Export::exportComponents($this->_selectAll,
$this->_componentIds,
(array) $this->get('queryParams'),
$this->get(CRM_Utils_Sort::SORT_ORDER),
NULL,
$this->get('returnProperties'),
$this->_exportMode,
$this->_componentClause,
$this->_componentTable,
$mergeSameAddress,
$mergeSameHousehold,
$exportParams,
$this->get('queryOperator')
);
if ($this->_customSearchID) {
CRM_Export_BAO_Export::exportCustom($this->get('customSearchClass'),
$this->get('formValues'),
$this->get(CRM_Utils_Sort::SORT_ORDER)
);
}
else {
CRM_Export_BAO_Export::exportComponents($this->_selectAll,
$this->_componentIds,
(array) $this->get('queryParams'),
$this->get(CRM_Utils_Sort::SORT_ORDER),
NULL,
$this->get('returnProperties'),
$this->_exportMode,
$this->_componentClause,
$this->_componentTable,
$mergeSameAddress,
$mergeSameHousehold,
$exportParams,
$this->get('queryOperator')
);
}
}

//reset map page
Expand Down
2 changes: 1 addition & 1 deletion templates/CRM/Export/Form/Select.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div class="crm-block crm-form-block crm-export-form-block">

<div class="help">
<p>{ts}<strong>Export PRIMARY fields</strong> provides the most commonly used data values. This includes primary address information, preferred phone and email.{/ts}</p>
<p>{ts}<strong>Export {if $exportCustomSearchField}custom search{else}PRIMARY{/if} fields</strong> provides the most commonly used data values. This includes primary address information, preferred phone and email.{/ts}</p>
<p>{ts}Click <strong>Select fields for export</strong> and then <strong>Continue</strong> to choose a subset of fields for export. This option allows you to export multiple specific locations (Home, Work, etc.) as well as custom data. You can also save your selections as a 'field mapping' so you can use it again later.{/ts}</p>
</div>

Expand Down

0 comments on commit ce40afa

Please sign in to comment.