<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.6 |
+ | CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
*/
protected $_options = array();
- protected $_defaults = array();
-
/**
* By default most reports hide contact id.
* Setting this to true makes it available
}
}
else {
+ if ((CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_INT) && is_array($field['default'])) {
+ $this->_defaults["{$fieldName}_min"] = CRM_Utils_Array::value('min', $field['default']);
+ $this->_defaults["{$fieldName}_max"] = CRM_Utils_Array::value('max', $field['default']);
+ }
$this->_defaults["{$fieldName}_value"] = $field['default'];
}
}
if (!$groupTitle && isset($table['group_title'])) {
$groupTitle = $table['group_title'];
// Having a group_title is secret code for being a custom group
- // which cryptically translates to needing an accordian.
+ // which cryptically translates to needing an accordion.
// here we make that explicit.
$colGroups[$tableName]['use_accordian_for_field_selection'] = TRUE;
}
public function groupBy() {
$groupBys = array();
if (!empty($this->_params['group_bys']) &&
- is_array($this->_params['group_bys']) &&
- !empty($this->_params['group_bys'])
+ is_array($this->_params['group_bys'])
) {
foreach ($this->_columns as $tableName => $table) {
if (array_key_exists('group_bys', $table)) {
//Load the image
$chart = imagecreatefrompng($uploadUrl);
//convert it into formatted png
- header('Content-type: image/png');
+ CRM_Utils_System::setHttpHeader('Content-type', 'image/png');
//overwrite with same image
imagepng($chart, $uploadImg);
//delete the object
}
$clause = "{$field['dbAlias']} IN (" . implode(', ', $value) . ")";
- return " {$this->_aliases['civicrm_contact']}.id {$sqlOp} (
+ $contactAlias = $this->_aliases['civicrm_contact'];
+ if (!empty($this->relationType) && $this->relationType == 'b_a') {
+ $contactAlias = $this->_aliases['civicrm_contact_b'];
+ }
+ return " {$contactAlias}.id {$sqlOp} (
SELECT DISTINCT {$this->_aliases['civicrm_group']}.contact_id
FROM civicrm_group_contact {$this->_aliases['civicrm_group']}
WHERE {$clause} AND {$this->_aliases['civicrm_group']}.status = 'Added'
}
/**
- * Check for empty order_by configurations and remove them; also set
- * template to hide them.
+ * Check for empty order_by configurations and remove them.
+ *
+ * Also set template to hide them.
*
* @param array $formValues
*/
* @param array $rows
* @param int $rowNum
* @param string $baseUrl
- * @param string $urltxt
+ * @param string $linkText
*
* @return bool
*/
- public function alterDisplayAddressFields(&$row, &$rows, &$rowNum, $baseUrl, $urltxt) {
+ public function alterDisplayAddressFields(&$row, &$rows, &$rowNum, $baseUrl, $linkText) {
$criteriaQueryParams = CRM_Report_Utils_Report::getPreviewCriteriaQueryParams($this->_defaults, $this->_params);
$entryFound = FALSE;
// handle country
);
$rows[$rowNum]['civicrm_address_country_id_link'] = $url;
$rows[$rowNum]['civicrm_address_country_id_hover'] = ts("%1 for this country.",
- array(1 => $urltxt)
+ array(1 => $linkText)
);
}
);
$rows[$rowNum]['civicrm_address_county_id_link'] = $url;
$rows[$rowNum]['civicrm_address_county_id_hover'] = ts("%1 for this county.",
- array(1 => $urltxt)
+ array(1 => $linkText)
);
}
$entryFound = TRUE;
);
$rows[$rowNum]['civicrm_address_state_province_id_link'] = $url;
$rows[$rowNum]['civicrm_address_state_province_id_hover'] = ts("%1 for this state.",
- array(1 => $urltxt)
+ array(1 => $linkText)
);
}
$entryFound = TRUE;
* @param array $row
* @param array $rows
* @param int $rowNum
+ * @param string $baseUrl
+ * @param string $linkText
*
* @return bool
*/
- public function alterDisplayContactFields(&$row, &$rows, &$rowNum) {
+ public function alterDisplayContactFields(&$row, &$rows, &$rowNum, $baseUrl, $linkText) {
$entryFound = FALSE;
- if (array_key_exists('civicrm_contact_prefix_id', $row)) {
- $prefixes = CRM_Contact_BAO_Contact::buildOptions('prefix_id');
- if ($value = $row['civicrm_contact_prefix_id']) {
- $rows[$rowNum]['civicrm_contact_prefix_id'] = $prefixes[$rows[$rowNum]['civicrm_contact_prefix_id']];
- }
- $entryFound = TRUE;
- }
- if (array_key_exists('civicrm_contact_suffix_id', $row)) {
- $suffixes = CRM_Contact_BAO_Contact::buildOptions('suffix_id');
- if ($value = $row['civicrm_contact_suffix_id']) {
- $rows[$rowNum]['civicrm_contact_suffix_id'] = $suffixes[$rows[$rowNum]['civicrm_contact_suffix_id']];
- }
- $entryFound = TRUE;
- }
- if (array_key_exists('civicrm_contact_gender_id', $row)) {
- $genders = CRM_Contact_BAO_Contact::buildOptions('gender_id');
- if ($value = $row['civicrm_contact_gender_id']) {
- $rows[$rowNum]['civicrm_contact_gender_id'] = $genders[$rows[$rowNum]['civicrm_contact_gender_id']];
+ // There is no reason not to add links for all fields but it seems a bit odd to be able to click on
+ // 'Mrs'. Also, we don't have metadata about the title. So, add selectively to addLinks.
+ $addLinks = array('gender_id' => 'Gender');
+ foreach (array('prefix_id', 'suffix_id', 'gender_id') as $fieldName) {
+ if (array_key_exists('civicrm_contact_' . $fieldName, $row)) {
+ if (($value = $row['civicrm_contact_' . $fieldName]) != FALSE) {
+ $rows[$rowNum]['civicrm_contact_' . $fieldName] = CRM_Core_Pseudoconstant::getLabel('CRM_Contact_BAO_Contact', $fieldName, $value);
+ if (($title = CRM_Utils_Array::value($fieldName, $addLinks)) != FALSE) {
+ $this->addLinkToRow($rows[$rowNum], $baseUrl, $linkText, $value, $fieldName, 'civicrm_contact', $title);
+ }
+ }
+ $entryFound = TRUE;
}
- $entryFound = TRUE;
}
return $entryFound;
}
);
}
+ /**
+ * Add link fields to the row.
+ *
+ * Function adds the _link & _hover fields to the row.
+ *
+ * @param array $row
+ * @param string $baseUrl
+ * @param string $linkText
+ * @param string $value
+ * @param string $fieldName
+ * @param string $tablePrefix
+ * @param string $fieldLabel
+ *
+ * @return mixed
+ */
+ protected function addLinkToRow(&$row, $baseUrl, $linkText, $value, $fieldName, $tablePrefix, $fieldLabel) {
+ $criteriaQueryParams = CRM_Report_Utils_Report::getPreviewCriteriaQueryParams($this->_defaults, $this->_params);
+ $url = CRM_Report_Utils_Report::getNextUrl($baseUrl,
+ "reset=1&force=1&{$criteriaQueryParams}&" .
+ $fieldName . "_op=in&{$fieldName}_value={$value}",
+ $this->_absoluteUrl, $this->_id
+ );
+ $row["{$tablePrefix}_{$fieldName}_link"] = $url;
+ $row["{$tablePrefix}_{$fieldName}_hover"] = ts("%1 for this %2.",
+ array(1 => $linkText, 2 => $fieldLabel)
+ );
+ }
+
+
+ public function getPermissionedFTQuery(&$query, $alias = NULL) {
+ CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes);
+ if (empty($financialTypes)) {
+ $contFTs = "0";
+ $liFTs = implode(',' , array_keys(CRM_Contribute_Pseudoconstant::financialType()));
+ }
+ else {
+ $contFTs = $liFTs = implode(',' , array_keys($financialTypes));
+ }
+ if ($alias) {
+ $temp = $query->_aliases['civicrm_line_item'];
+ $query->_aliases['civicrm_line_item'] = $alias;
+ }
+ if (empty($query->_where)) {
+ $query->_where = "WHERE {$query->_aliases['civicrm_contribution']}.id IS NOT NULL ";
+ }
+ CRM_Core_DAO::executeQuery("DROP TEMPORARY TABLE IF EXISTS civicrm_contribution_temp");
+
+ $sql = "CREATE TEMPORARY TABLE civicrm_contribution_temp AS SELECT {$query->_aliases['civicrm_contribution']}.id {$query->_from}
+ LEFT JOIN civicrm_line_item {$query->_aliases['civicrm_line_item']}
+ ON {$query->_aliases['civicrm_contribution']}.id = {$query->_aliases['civicrm_line_item']}.contribution_id AND
+ {$query->_aliases['civicrm_line_item']}.entity_table = 'civicrm_contribution'
+ AND {$query->_aliases['civicrm_line_item']}.financial_type_id NOT IN (" . $liFTs . ")
+ {$query->_where}
+ AND {$query->_aliases['civicrm_contribution']}.financial_type_id IN (" . $contFTs . ")
+ AND {$query->_aliases['civicrm_line_item']}.id IS NULL
+ GROUP BY {$query->_aliases['civicrm_contribution']}.id";
+ CRM_Core_DAO::executeQuery($sql);
+ $query->_from .= "
+ INNER JOIN civicrm_contribution_temp temp ON {$query->_aliases['civicrm_contribution']}.id = temp.id ";
+ if (isset($temp)) {
+ $query->_aliases['civicrm_line_item'] = $temp;
+ }
+ }
+
}