<?php
-// $Id$
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
'default' => TRUE,
'required' => TRUE,
),
+ 'contact_type' =>
+ array(
+ 'title' => ts('Contact Type'),
+ ),
+ 'contact_sub_type' =>
+ array(
+ 'title' => ts('Contact SubType'),
+ ),
),
'grouping' => 'contact-fields',
'filters' =>
'options' => CRM_Contribute_PseudoConstant::contributionStatus(),
'default' => array(1),
),
- 'financial_type_id' => array(
- 'title' => ts('Financial Type'),
+ 'financial_type_id' => array(
+ 'title' => ts('Financial Type'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Contribute_PseudoConstant::financialType(),
),
if (array_key_exists('fields', $table)) {
foreach ($table['fields'] as $fieldName => $field) {
- if (CRM_Utils_Array::value('required', $field) ||
- CRM_Utils_Array::value($fieldName, $this->_params['fields'])
- ) {
+ if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) {
if ($tableName == 'civicrm_address') {
$this->_addressField = TRUE;
}
continue;
}
- if ($fieldName == 'total_amount') {
- $select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}";
- }
-
- if (CRM_Utils_Array::value('is_statistics', $field)) {
+ if (!empty($field['is_statistics'])) {
$this->_columnHeaders[$fieldName]['type'] = $field['type'];
$this->_columnHeaders[$fieldName]['title'] = $field['title'];
continue;
}
- elseif ($fieldName == 'receive_date') {
- if ((CRM_Utils_Array::value('this_year_op', $this->_params) == 'fiscal' &&
- CRM_Utils_Array::value('this_year_value', $this->_params)) ||
- (CRM_Utils_Array::value('other_year_op', $this->_params == 'fiscal') &&
- CRM_Utils_Array::value('other_year_value', $this->_params)
- )){
+ elseif ($fieldName == 'receive_date') {
+ if ((CRM_Utils_Array::value('this_year_op', $this->_params) == 'fiscal' && !empty($this->_params['this_year_value'])) ||
+ (CRM_Utils_Array::value('other_year_op', $this->_params == 'fiscal') && !empty($this->_params['other_year_value']))){
$select[] = self::fiscalYearOffset($field['dbAlias']) . " as {$tableName}_{$fieldName}";
}else{
$select[] = " YEAR(".$field['dbAlias'].")" . " as {$tableName}_{$fieldName}";
}
}
+ elseif ($fieldName == 'total_amount') {
+ $select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}";
+ }
else {
$select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
$this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field);
$this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'];
}
- if (CRM_Utils_Array::value('no_display', $field)) {
+ if (!empty($field['no_display'])) {
$this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = TRUE;
}
}
function from() {
$this->_from = "
FROM civicrm_contact {$this->_aliases['civicrm_contact']}
- INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
+ INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id AND
{$this->_aliases['civicrm_contribution']}.is_test = 0 ";
if ($this->_emailField) {
- $this->_from .= " LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
- ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
+ $this->_from .= " LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
+ ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
{$this->_aliases['civicrm_email']}.is_primary = 1) ";
}
if ($this->_phoneField) {
- $this->_from .= " LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
- ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
+ $this->_from .= " LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
+ ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
{$this->_aliases['civicrm_phone']}.is_primary = 1) ";
}
$relContacAlias = 'contact_relationship';
- $this->_relationshipFrom = " INNER JOIN civicrm_relationship {$this->_aliases['civicrm_relationship']}
+ $this->_relationshipFrom = " INNER JOIN civicrm_relationship {$this->_aliases['civicrm_relationship']}
ON (({$this->_aliases['civicrm_relationship']}.contact_id_a = {$relContacAlias}.id OR {$this->_aliases['civicrm_relationship']}.contact_id_b = {$relContacAlias}.id ) AND {$this->_aliases['civicrm_relationship']}.is_active = 1) ";
if ($this->_addressField) {
$this->_from .= "
- LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
- ON {$this->_aliases['civicrm_contact']}.id =
- {$this->_aliases['civicrm_address']}.contact_id AND
+ LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
+ ON {$this->_aliases['civicrm_contact']}.id =
+ {$this->_aliases['civicrm_address']}.contact_id AND
{$this->_aliases['civicrm_address']}.is_primary = 1\n";
}
}
$this->_statusClause = " AND " . $clause;
}
- if (CRM_Utils_Array::value('having', $field)) {
+ if (!empty($field['having'])) {
$havingClauses[] = $clause;
}
else {
static function formRule($fields, $files, $self) {
$errors = array();
- if (CRM_Utils_Array::value('this_year_value', $fields) &&
- CRM_Utils_Array::value('other_year_value', $fields) &&
+ if (!empty($fields['this_year_value']) && !empty($fields['other_year_value']) &&
($fields['this_year_value'] == $fields['other_year_value'])
) {
$errors['other_year_value'] = ts("Value for filters 'This Year' and 'Other Years' can not be same.");
}
function fixReportParams() {
- if (CRM_Utils_Array::value('this_year_value', $this->_params)) {
+ if (!empty($this->_params['this_year_value'])) {
$this->_referenceYear['this_year'] = $this->_params['this_year_value'];
}
- if (CRM_Utils_Array::value('other_year_value', $this->_params)) {
+ if (!empty($this->_params['other_year_value'])) {
$this->_referenceYear['other_year'] = $this->_params['other_year_value'];
}
}
$addWhere = '';
- if (CRM_Utils_Array::value('other_year', $this->_referenceYear)) {
+ if (!empty($this->_referenceYear['other_year'])) {
(CRM_Utils_Array::value('other_year_op', $this->_params) == 'calendar') ? $other_receive_date = 'YEAR (contri.receive_date)' : $other_receive_date = self::fiscalYearOffset('contri.receive_date');
$addWhere .= " AND {$this->_aliases['civicrm_contact']}.id NOT IN ( SELECT DISTINCT cont.id FROM civicrm_contact cont, civicrm_contribution contri WHERE cont.id = contri.contact_id AND {$other_receive_date} = {$this->_referenceYear['other_year']} AND contri.is_test = 0 ) ";
}
- if (CRM_Utils_Array::value('this_year', $this->_referenceYear)) {
+ if (!empty($this->_referenceYear['this_year'])) {
(CRM_Utils_Array::value('this_year_op', $this->_params) == 'calendar') ? $receive_date = 'YEAR (contri.receive_date)' : $receive_date = self::fiscalYearOffset('contri.receive_date');
$addWhere .= " AND {$this->_aliases['civicrm_contact']}.id IN ( SELECT DISTINCT cont.id FROM civicrm_contact cont, civicrm_contribution contri WHERE cont.id = contri.contact_id AND {$receive_date} = {$this->_referenceYear['this_year']} AND contri.is_test = 0 ) ";
- }
+ }
$this->limit();
$getContacts = "SELECT SQL_CALC_FOUND_ROWS {$this->_aliases['civicrm_contact']}.id as cid, SUM({$this->_aliases['civicrm_contribution']}.total_amount) as civicrm_contribution_total_amount_sum {$this->_from} {$this->_where} {$addWhere} GROUP BY {$this->_aliases['civicrm_contact']}.id {$this->_having} {$this->_limit}";
-
+
$dao = CRM_Core_DAO::executeQuery($getContacts);
while ($dao->fetch()) {
}
foreach (array_keys($this->_relationshipColumns) as $col) {
- if (CRM_Utils_Array::value($col, $relRow)) {
+ if (!empty($relRow[$col])) {
$relatedRow[$col] = $relRow[$col];
}
}
$dao->free();
return array($relationshipRows, $relatedContactIds);
}
-
+
// Override "This Year" $op options
function getOperationPair($type = "string", $fieldName = NULL) {
- if ($fieldName == 'this_year' || $fieldName == 'other_year') {
- return array('calendar' => ts('Is Calendar Year'), 'fiscal' => ts('Fiscal Year Starting'));
- }
- return parent::getOperationPair($type, $fieldName);
+ if ($fieldName == 'this_year' || $fieldName == 'other_year') {
+ return array('calendar' => ts('Is Calendar Year'), 'fiscal' => ts('Fiscal Year Starting'));
+ }
+ return parent::getOperationPair($type, $fieldName);
}
-
-
function alterDisplay(&$rows) {
if (empty($rows)) {
}
// Convert Display name into link
- if (CRM_Utils_Array::value('civicrm_contact_sort_name', $row) &&
- CRM_Utils_Array::value('civicrm_contact_id', $row)
- ) {
+ if (!empty($row['civicrm_contact_sort_name']) && !empty($row['civicrm_contact_id'])) {
$url = CRM_Report_Utils_Report::getNextUrl('contribute/detail',
'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id'],
$this->_absoluteUrl, $this->_id