$allCampaigns = array();
$exportCampaign = FALSE;
- $phoneTypes = CRM_Core_PseudoConstant::phoneType();
- $imProviders = CRM_Core_PseudoConstant::IMProvider();
+ $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
+ $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
$contactRelationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(
NULL,
NULL,
}
if ($fields) {
//construct return properties
- $locationTypes = CRM_Core_PseudoConstant::locationType();
+ $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
$locationTypeFields = array(
'street_address',
'supplemental_address_1',
$relIDs = $ids;
}
elseif ($exportMode == CRM_Export_Form_Select::ACTIVITY_EXPORT) {
- $query = "SELECT source_contact_id FROM civicrm_activity
- WHERE id IN ( " . implode(',', $ids) . ")";
+ $activityContacts = CRM_Core_PseudoConstant::activityContacts('name');
+ $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
+ $query = "SELECT contact_id FROM civicrm_activity_contact
+ WHERE activity_id IN ( " . implode(',', $ids) . ") AND
+ record_type_id = {$sourceID}";
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
- $relIDs[] = $dao->source_contact_id;
+ $relIDs[] = $dao->contact_id;
}
}
else {
$component = 'civicrm_pledge';
break;
- case CRM_Export_Form_Select::CASE_EXPORT:
- $component = 'civicrm_case';
- break;
-
case CRM_Export_Form_Select::GRANT_EXPORT:
$component = 'civicrm_grant';
break;
}
- $relIDs = CRM_Core_DAO::getContactIDsFromComponent($ids, $component);
+
+ if ($exportMode == CRM_Export_Form_Select::CASE_EXPORT) {
+ $relIDs = CRM_Case_BAO_Case::retrieveContactIdsByCaseId($ids);
+ }
+ else {
+ $relIDs = CRM_Core_DAO::getContactIDsFromComponent($ids, $component);
+ }
}
$relationshipJoin = $relationshipClause = '';
$count++;
$row = array();
+ //convert the pseudo constants
+ $query->convertToPseudoNames($dao);
+
//first loop through returnproperties so that we return what is required, and in same order.
$relationshipField = 0;
foreach ($returnProperties as $field => $value) {
$row[$field] = $dao->contact_id;
// special case for calculated field
}
+ elseif ($field == 'source_contact_id') {
+ $row[$field] = $dao->contact_id;
+ }
elseif ($field == 'pledge_balance_amount') {
$row[$field] = $dao->pledge_amount - $dao->pledge_total_paid;
// special case for calculated field
elseif ($field == 'pledge_next_pay_amount') {
$row[$field] = $dao->pledge_next_pay_amount + $dao->pledge_outstanding_amount;
}
+ elseif ($field == 'prefix_id' || $field == 'suffix_id' || $field == 'gender_id') {
+ if ($field == 'prefix_id') {
+ $row[$field] = $dao->individual_prefix;
+ }
+ elseif ($field == 'suffix_id') {
+ $row[$field] = $dao->individual_suffix;
+ }
+ else {
+ $row[$field] = $dao->gender;
+ }
+ }
elseif (is_array($value) && $field == 'location') {
// fix header for location type case
foreach ($value as $ltype => $val) {
foreach (array_keys($paymentHeaders) as $paymentHdr) {
self::sqlColumnDefn($query, $sqlColumns, $paymentHdr);
}
- $addPaymentHeader = FALSE;
}
if ($setHeader) {
// If specific payment fields have been selected for export, payment
// data will already be in $row. Otherwise, add payment related
// information, if appropriate.
- if (!$selectedPaymentFields) {
- if ($paymentFields) {
- $paymentData = CRM_Utils_Array::value($row[$paymentTableId], $paymentDetails);
- if (!is_array($paymentData) || empty($paymentData)) {
- $paymentData = $nullContributionDetails;
+ if ($addPaymentHeader) {
+ if (!$selectedPaymentFields) {
+ if ($paymentFields) {
+ $paymentData = CRM_Utils_Array::value($row[$paymentTableId], $paymentDetails);
+ if (!is_array($paymentData) || empty($paymentData)) {
+ $paymentData = $nullContributionDetails;
+ }
+ $row = array_merge($row, $paymentData);
+ }
+ elseif (!empty($paymentDetails)) {
+ $row = array_merge($row, $nullContributionDetails);
}
- $row = array_merge($row, $paymentData);
- }
- elseif (!empty($paymentDetails)) {
- $row = array_merge($row, $nullContributionDetails);
}
}
-
//remove organization name for individuals if it is set for current employer
if (CRM_Utils_Array::value('contact_type', $row) &&
$row['contact_type'] == 'Individual' && array_key_exists('organization_name', $row)
if (isset($query->_fields[$field]['type'])) {
switch ($query->_fields[$field]['type']) {
case CRM_Utils_Type::T_INT:
- case CRM_Utils_Type::T_BOOL:
case CRM_Utils_Type::T_BOOLEAN:
$sqlColumns[$fieldName] = "$fieldName varchar(16)";
break;