$fields = ['is_deceased', 'do_not_mail', 'street_address', 'supplemental_address_1'];
foreach ($fields as $index => $field) {
if (!empty($this->getReturnProperties()[$field])) {
- unset($field[$index]);
+ unset($fields[$index]);
}
}
$this->additionalFieldsForPostalExport = array_fill_keys($fields, 1);
* @return array
*/
public function getQueryFields() {
- return $this->queryFields;
+ return array_merge(
+ $this->queryFields,
+ $this->getComponentPaymentFields()
+ );
}
/**
return $this->getQueryFields()[$field]['title'];
}
elseif ($this->isExportPaymentFields() && array_key_exists($field, $this->getcomponentPaymentFields())) {
- return CRM_Utils_Array::value($field, $this->getcomponentPaymentFields());
+ return CRM_Utils_Array::value($field, $this->getcomponentPaymentFields())['title'];
}
else {
return $field;
$addressWhere .= " OR civicrm_address.supplemental_address_1 <> ''";
}
}
- $whereClauses['address'] = $addressWhere;
+ $whereClauses['address'] = '(' . $addressWhere . ')';
}
}
*/
public function getComponentPaymentFields() {
return [
- 'componentPaymentField_total_amount' => ts('Total Amount'),
- 'componentPaymentField_contribution_status' => ts('Contribution Status'),
- 'componentPaymentField_received_date' => ts('Date Received'),
- 'componentPaymentField_payment_instrument' => ts('Payment Method'),
- 'componentPaymentField_transaction_id' => ts('Transaction ID'),
+ 'componentPaymentField_total_amount' => ['title' => ts('Total Amount'), 'type' => CRM_Utils_Type::T_MONEY],
+ 'componentPaymentField_contribution_status' => ['title' => ts('Contribution Status'), 'type' => CRM_Utils_Type::T_STRING],
+ 'componentPaymentField_received_date' => ['title' => ts('Date Received'), 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME],
+ 'componentPaymentField_payment_instrument' => ['title' => ts('Payment Method'), 'type' => CRM_Utils_Type::T_STRING],
+ 'componentPaymentField_transaction_id' => ['title' => ts('Transaction ID'), 'type' => CRM_Utils_Type::T_STRING],
];
}
*/
public function getPaymentHeaders() {
if ($this->isExportPaymentFields() && !$this->isExportSpecifiedPaymentFields()) {
- return $this->getcomponentPaymentFields();
+ return CRM_Utils_Array::collect('title', $this->getcomponentPaymentFields());
}
return [];
}
if ($exportMode !== $this->getExportMode() || $componentTable !== $this->getComponentTable()) {
CRM_Core_Error::deprecatedFunctionWarning('altering the export mode and/or component table in the hook is no longer supported.');
}
+ if ($ids !== $this->getIds()) {
+ CRM_Core_Error::deprecatedFunctionWarning('altering the ids in the hook is no longer supported.');
+ }
if ($exportTempTable !== $this->getTemporaryTable()) {
CRM_Core_Error::deprecatedFunctionWarning('altering the export table in the hook is deprecated (in some flows the table itself will be)');
$this->setTemporaryTable($exportTempTable);
$query = "SELECT * FROM $exportTempTable";
+ $this->instantiateTempTable($headerRows);
while (1) {
$limitQuery = $query . "
LIMIT $offset, $limit
}
$componentDetails[] = $row;
}
- CRM_Core_Report_Excel::writeCSVFile($this->getExportFileName(),
- $headerRows,
- $componentDetails,
- NULL,
- $writeHeader
- );
-
- $writeHeader = FALSE;
+ $this->writeRows($headerRows, $componentDetails);
+
$offset += $limit;
}
}
+ /**
+ * Set up the temp table.
+ *
+ * @param array $headerRows
+ */
+ protected function instantiateTempTable(array $headerRows) {
+ CRM_Utils_System::download(CRM_Utils_String::munge($this->getExportFileName()),
+ 'text/x-csv',
+ CRM_Core_DAO::$_nullObject,
+ 'csv',
+ FALSE
+ );
+ CRM_Core_Report_Excel::makeCSVTable($headerRows, [], NULL, TRUE, TRUE);
+ }
+
+ /**
+ * @param array $headerRows
+ * @param array $componentDetails
+ */
+ protected function writeRows(array $headerRows, array $componentDetails) {
+ CRM_Core_Report_Excel::writeCSVFile($this->getExportFileName(),
+ $headerRows,
+ $componentDetails,
+ NULL,
+ FALSE
+ );
+ }
+
}