protected $_summary = NULL;
protected $_totalPaid = FALSE;
- protected $_pledgeStatuses = array();
- protected $_customGroupExtends = array(
+ protected $_pledgeStatuses = [];
+ protected $_customGroupExtends = [
'Pledge',
'Individual',
- );
+ ];
/**
* This report has not been optimised for group filtering.
*/
public function __construct() {
$this->_pledgeStatuses = CRM_Core_OptionGroup::values('pledge_status',
- FALSE, FALSE, FALSE, NULL, 'label'
+ FALSE, FALSE, FALSE, NULL, 'name'
);
- $this->_columns = array(
- 'civicrm_contact' => array(
+ $this->_columns = [
+ 'civicrm_contact' => [
'dao' => 'CRM_Contact_DAO_Contact',
- 'fields' => array(
- 'sort_name' => array(
+ 'fields' => [
+ 'sort_name' => [
'title' => ts('Contact Name'),
'required' => TRUE,
'no_repeat' => TRUE,
- ),
- ),
- 'filters' => array(
- 'sort_name' => array('title' => ts('Contact Name')),
- 'id' => array('no_display' => TRUE),
- ),
+ ],
+ ],
+ 'filters' => [
+ 'sort_name' => ['title' => ts('Contact Name')],
+ 'id' => ['no_display' => TRUE],
+ ],
'grouping' => 'contact-fields',
- ),
- 'civicrm_email' => array(
+ ],
+ 'civicrm_email' => [
'dao' => 'CRM_Core_DAO_Email',
- 'fields' => array(
- 'email' => array('no_repeat' => TRUE),
- ),
+ 'fields' => [
+ 'email' => ['no_repeat' => TRUE],
+ ],
'grouping' => 'contact-fields',
- ),
- 'civicrm_pledge' => array(
+ ],
+ 'civicrm_pledge' => [
'dao' => 'CRM_Pledge_DAO_Pledge',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'no_display' => TRUE,
'required' => TRUE,
- ),
- 'contact_id' => array(
+ ],
+ 'contact_id' => [
'no_display' => TRUE,
'required' => TRUE,
- ),
- 'financial_type_id' => array(
+ ],
+ 'financial_type_id' => [
'title' => ts('Financial Type'),
- ),
- 'amount' => array(
+ ],
+ 'amount' => [
'title' => ts('Pledge Amount'),
'required' => TRUE,
'type' => CRM_Utils_Type::T_MONEY,
- ),
- 'currency' => array(
+ ],
+ 'currency' => [
'required' => TRUE,
'no_display' => TRUE,
- ),
- 'frequency_unit' => array(
+ ],
+ 'frequency_unit' => [
'title' => ts('Frequency Unit'),
- ),
- 'installments' => array(
+ ],
+ 'installments' => [
'title' => ts('Installments'),
- ),
- 'pledge_create_date' => array(
+ ],
+ 'pledge_create_date' => [
'title' => ts('Pledge Made Date'),
- ),
- 'start_date' => array(
+ ],
+ 'start_date' => [
'title' => ts('Pledge Start Date'),
'type' => CRM_Utils_Type::T_DATE,
- ),
- 'end_date' => array(
+ ],
+ 'end_date' => [
'title' => ts('Pledge End Date'),
'type' => CRM_Utils_Type::T_DATE,
- ),
- 'status_id' => array(
+ ],
+ 'status_id' => [
'title' => ts('Pledge Status'),
'required' => TRUE,
- ),
- ),
- 'filters' => array(
- 'pledge_create_date' => array(
+ ],
+ ],
+ 'filters' => [
+ 'pledge_create_date' => [
'title' => ts('Pledge Made Date'),
'operatorType' => CRM_Report_Form::OP_DATE,
- ),
- 'pledge_amount' => array(
+ ],
+ 'pledge_amount' => [
'title' => ts('Pledged Amount'),
'operatorType' => CRM_Report_Form::OP_INT,
- ),
- 'currency' => array(
+ ],
+ 'currency' => [
'title' => ts('Currency'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Core_OptionGroup::values('currencies_enabled'),
'default' => NULL,
'type' => CRM_Utils_Type::T_STRING,
- ),
- 'sid' => array(
+ ],
+ 'sid' => [
'name' => 'status_id',
'title' => ts('Pledge Status'),
'type' => CRM_Utils_Type::T_INT,
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Core_OptionGroup::values('pledge_status'),
- ),
- 'financial_type_id' => array(
+ ],
+ 'financial_type_id' => [
'title' => ts('Financial Type'),
'type' => CRM_Utils_Type::T_INT,
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Contribute_PseudoConstant::financialType(),
- ),
+ ],
- ),
- ),
- 'civicrm_pledge_payment' => array(
+ ],
+ ],
+ 'civicrm_pledge_payment' => [
'dao' => 'CRM_Pledge_DAO_PledgePayment',
- 'fields' => array(
- 'total_paid' => array(
+ 'fields' => [
+ 'total_paid' => [
'title' => ts('Total Amount Paid'),
'type' => CRM_Utils_Type::T_MONEY,
- ),
- 'balance_due' => array(
+ ],
+ 'balance_due' => [
'title' => ts('Balance Due'),
'default' => TRUE,
'type' => CRM_Utils_Type::T_MONEY,
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
- $this->_columns += $this->getAddressColumns(array('group_by' => FALSE)) + $this->getPhoneColumns();
+ $this->_columns += $this->getAddressColumns(['group_by' => FALSE]) + $this->getPhoneColumns();
// If we have a campaign, build out the relevant elements
$this->addCampaignFields('civicrm_pledge', TRUE);
*/
public function selectClause(&$tableName, $tableKey, &$fieldName, &$field) {
if ($fieldName == 'total_paid') {
- $this->_totalPaid = TRUE; // add pledge_payment join
- $this->_columnHeaders["{$tableName}_{$fieldName}"] = array(
+ // add pledge_payment join
+ $this->_totalPaid = TRUE;
+ $this->_columnHeaders["{$tableName}_{$fieldName}"] = [
'title' => $field['title'],
'type' => $field['type'],
- );
+ ];
return "COALESCE(sum({$this->_aliases[$tableName]}.actual_amount), 0) as {$tableName}_{$fieldName}";
}
if ($fieldName == 'balance_due') {
$cancelledStatus = array_search('Cancelled', $this->_pledgeStatuses);
$completedStatus = array_search('Completed', $this->_pledgeStatuses);
- $this->_totalPaid = TRUE; // add pledge_payment join
+ // add pledge_payment join
+ $this->_totalPaid = TRUE;
$this->_columnHeaders["{$tableName}_{$fieldName}"] = $field['title'];
- $this->_columnHeaders["{$tableName}_{$fieldName}"] = array(
+ $this->_columnHeaders["{$tableName}_{$fieldName}"] = [
'title' => $field['title'],
'type' => $field['type'],
- );
+ ];
return "IF({$this->_aliases['civicrm_pledge']}.status_id IN({$cancelledStatus}, $completedStatus), 0, COALESCE({$this->_aliases['civicrm_pledge']}.amount, 0) - COALESCE(sum({$this->_aliases[$tableName]}.actual_amount),0)) as {$tableName}_{$fieldName}";
}
return FALSE;
public function groupBy() {
parent::groupBy();
if (empty($this->_groupBy) && $this->_totalPaid) {
- $groupBy = array("{$this->_aliases['civicrm_pledge']}.id", "{$this->_aliases['civicrm_pledge']}.currency");
+ $groupBy = ["{$this->_aliases['civicrm_pledge']}.id", "{$this->_aliases['civicrm_pledge']}.currency"];
$this->_groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, $groupBy);
}
}
$this->from();
$this->customDataFrom();
if (!$this->_having) {
- $totalAmount = $average = array();
+ $totalAmount = $average = [];
$count = 0;
$select = "
SELECT COUNT({$this->_aliases['civicrm_pledge']}.amount ) as count,
$average = CRM_Utils_Money::format($dao->avg, $dao->currency);
$count = $dao->count;
$totalCount .= $count;
- $statistics['counts']['amount' . $index] = array(
+ $statistics['counts']['amount' . $index] = [
'title' => ts('Total Pledged') . ' (' . $dao->currency . ')',
'value' => $totalAmount,
'type' => CRM_Utils_Type::T_STRING,
- );
- $statistics['counts']['avg' . $index] = array(
+ ];
+ $statistics['counts']['avg' . $index] = [
'title' => ts('Average') . ' (' . $dao->currency . ')',
'value' => $average,
'type' => CRM_Utils_Type::T_STRING,
- );
- $statistics['counts']['count' . $index] = array(
+ ];
+ $statistics['counts']['count' . $index] = [
'title' => ts('Total No Pledges') . ' (' . $dao->currency . ')',
'value' => $count,
'type' => CRM_Utils_Type::T_INT,
- );
+ ];
$index++;
}
if ($totalCount > $count) {
- $statistics['counts']['count' . $index] = array(
+ $statistics['counts']['count' . $index] = [
'title' => ts('Total No Pledges'),
'value' => $totalCount,
'type' => CRM_Utils_Type::T_INT,
- );
+ ];
}
}
// reset from clause
}
public function where() {
- $clauses = array();
+ $clauses = [];
foreach ($this->_columns as $tableName => $table) {
if (array_key_exists('filters', $table)) {
foreach ($table['filters'] as $fieldName => $field) {
// get the acl clauses built before we assemble the query
$this->buildACLClause($this->_aliases['civicrm_contact']);
$sql = $this->buildQuery();
- $rows = $payment = array();
+ $rows = $payment = [];
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
$pledgeID = $dao->civicrm_pledge_id;
foreach ($this->_columnHeaders as $columnHeadersKey => $columnHeadersValue) {
- $row = array();
+ $row = [];
if (property_exists($dao, $columnHeadersKey)) {
$display[$pledgeID][$columnHeadersKey] = $dao->$columnHeadersKey;
}
}
// Add Special headers
- $this->_columnHeaders['scheduled_date'] = array(
+ $this->_columnHeaders['scheduled_date'] = [
'type' => CRM_Utils_Type::T_DATE,
'title' => ts('Next Payment Due'),
- );
- $this->_columnHeaders['scheduled_amount'] = array(
+ ];
+ $this->_columnHeaders['scheduled_amount'] = [
'type' => CRM_Utils_Type::T_MONEY,
'title' => ts('Next Payment Amount'),
- );
+ ];
$this->_columnHeaders['status_id'] = NULL;
/*
* (arguably the pledge amount should be moved to after these fields too)
*
*/
- $tableHeaders = array(
+ $tableHeaders = [
'civicrm_pledge_payment_total_paid',
'civicrm_pledge_payment_balance_due',
- );
+ ];
foreach ($tableHeaders as $header) {
//per above, unset & reset them so they move to the end
// Displaying entire data on the form
if (!empty($display)) {
foreach ($display as $key => $value) {
- $row = array();
+ $row = [];
foreach ($this->_columnHeaders as $columnKey => $columnValue) {
if (array_key_exists($columnKey, $value)) {
$row[$columnKey] = !empty($value[$columnKey]) ? $value[$columnKey] : '';
*/
public function alterDisplay(&$rows) {
$entryFound = FALSE;
- $checkList = array();
+ $checkList = [];
$display_flag = $prev_cid = $cid = 0;
foreach ($rows as $rowNum => $row) {